mbsim  4.0.0
MBSim Kernel
maxwell_contact_observer.h
1/* Copyright (C) 2004-2018 MBSim Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 *
17 * Contact: martin.o.foerg@gmail.com
18 */
19
20#ifndef _MAXWELL_CONTACT_OBSERVER_H__
21#define _MAXWELL_CONTACT_OBSERVER_H__
22
23#include "mbsim/observers/single_contact_observer.h"
24
25#include <mbsim/utils/boost_parameters.h>
26#include <mbsim/utils/openmbv_utils.h>
27
28namespace MBSim {
29
30 class MaxwellContact;
31
33 protected:
34 std::vector<std::vector<SingleContactObserver>> contactObserver;
35
36 MaxwellContact* link;
37 std::string saved_link;
38
42 std::shared_ptr<OpenMBV::Frame> openMBVContactFrame;
43
44 std::shared_ptr<OpenMBVInteractionArrow> ombvForce, ombvMoment, ombvContact;
45 std::shared_ptr<OpenMBVFrictionArrow> ombvFriction;
46
47 public:
48 MaxwellContactObserver(const std::string &name="");
49 void setMaxwellContact(MaxwellContact *link_) { link = link_; }
50 void setOutputFrame(Frame *outputFrame_) { outputFrame = outputFrame_; }
51
52 void init(InitStage stage, const InitConfigSet &config) override;
53 void plot() override;
54 void initializeUsingXML(xercesc::DOMElement *element) override;
55 void setDynamicSystemSolver(DynamicSystemSolver *sys) override;
56
57 std::shared_ptr<OpenMBV::Group> getObserversOpenMBVGrp() override { return getOpenMBVGrp(); }
58 H5::GroupBase *getObserversPlotGroup() override { return getPlotGroup(); }
59
60 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVForce, tag, (optional (sideOfInteraction,(OpenMBVInteractionArrow::SideOfInteraction),OpenMBVInteractionArrow::action)(scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(OpenMBVArrow::ReferencePoint),OpenMBVArrow::toPoint)(colorRepresentation,(OpenMBVArrow::ColorRepresentation),OpenMBVArrow::none)(minimalColorValue,(double),0)(maximalColorValue,(double),1)(diffuseColor,(const fmatvec::Vec3&),fmatvec::Vec3(std::vector<double>{-1,1,1}))(transparency,(double),0)(pointSize,(double),0)(lineWidth,(double),0))) {
61 ombvForce = std::shared_ptr<OpenMBVInteractionArrow>(new OpenMBVInteractionArrow(sideOfInteraction,scaleLength,scaleSize,OpenMBVArrow::toHead,referencePoint,colorRepresentation,minimalColorValue,maximalColorValue,diffuseColor,transparency,pointSize,lineWidth));
62 }
63
64 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVMoment, tag, (optional (sideOfInteraction,(OpenMBVInteractionArrow::SideOfInteraction),OpenMBVInteractionArrow::action)(scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(OpenMBVArrow::ReferencePoint),OpenMBVArrow::toPoint)(colorRepresentation,(OpenMBVInteractionArrow::ColorRepresentation),OpenMBVArrow::none)(minimalColorValue,(double),0)(maximalColorValue,(double),1)(diffuseColor,(const fmatvec::Vec3&),fmatvec::Vec3(std::vector<double>{-1,1,1}))(transparency,(double),0)(pointSize,(double),0)(lineWidth,(double),0))) {
65 ombvMoment = std::shared_ptr<OpenMBVInteractionArrow>(new OpenMBVInteractionArrow(sideOfInteraction,scaleLength,scaleSize,OpenMBVArrow::toDoubleHead,referencePoint,colorRepresentation,minimalColorValue,maximalColorValue,diffuseColor,transparency,pointSize,lineWidth));
66 }
67
74 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVContactPoints, tag, (optional (size,(double),1)(offset,(double),1)(path,(bool),false)(transparency,(double),0)(pointSize,(double),0)(lineWidth,(double),0))) {
75 OpenMBVFrame ombv(size,offset,path,fmatvec::Vec3(std::vector<double>{-1,1,1}),transparency,pointSize,lineWidth);
76 openMBVContactFrame=ombv.createOpenMBV();
77 }
78
84 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVNormalForce, tag, (optional (sideOfInteraction,(OpenMBVInteractionArrow::SideOfInteraction),OpenMBVInteractionArrow::action)(scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(OpenMBVArrow::ReferencePoint),OpenMBVArrow::toPoint)(colorRepresentation,(OpenMBVArrow::ColorRepresentation),OpenMBVArrow::none)(minimalColorValue,(double),0)(maximalColorValue,(double),1)(diffuseColor,(const fmatvec::Vec3&),fmatvec::Vec3(std::vector<double>{-1,1,1}))(transparency,(double),0)(pointSize,(double),0)(lineWidth,(double),0))) {
85 ombvContact = std::shared_ptr<OpenMBVInteractionArrow>(new OpenMBVInteractionArrow(sideOfInteraction,scaleLength,scaleSize,OpenMBVArrow::toHead,referencePoint,colorRepresentation,minimalColorValue,maximalColorValue,diffuseColor,transparency,pointSize,lineWidth));
86 }
87
95 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVTangentialForce, tag, (optional (sideOfInteraction,(OpenMBVInteractionArrow::SideOfInteraction),OpenMBVInteractionArrow::action)(scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(OpenMBVArrow::ReferencePoint),OpenMBVArrow::toPoint)(colorRepresentation,(OpenMBVFrictionArrow::ColorRepresentation),OpenMBVFrictionArrow::none)(minimalColorValue,(double),0)(maximalColorValue,(double),1)(diffuseColor,(const fmatvec::Vec3&),fmatvec::Vec3(std::vector<double>{-1,1,1}))(transparency,(double),0)(pointSize,(double),0)(lineWidth,(double),0))) {
96 ombvFriction = std::shared_ptr<OpenMBVFrictionArrow>(new OpenMBVFrictionArrow(sideOfInteraction,scaleLength,scaleSize,OpenMBVArrow::toHead,referencePoint,colorRepresentation,minimalColorValue,maximalColorValue,diffuseColor,transparency,pointSize,lineWidth));
97 }
98 private:
99 Frame *outputFrame { nullptr };
100 std::string saved_outputFrame;
101 };
102
103}
104
105#endif
InitStage
The stages of the initialization.
Definition: element.h:62
H5::GroupBase * getPlotGroup()
Definition: element.h:139
std::string path
The path of this object. Is set during the init stage reorganizeHierarchy. Before this the path is ca...
Definition: element.h:267
std::string name
name of element
Definition: element.h:260
cartesian frame on bodies used for application of e.g. links and loads
Definition: frame.h:39
Definition: maxwell_contact_observer.h:32
BOOST_PARAMETER_MEMBER_FUNCTION((void), enableOpenMBVContactPoints, tag,(optional(size,(double), 1)(offset,(double), 1)(path,(bool), false)(transparency,(double), 0)(pointSize,(double), 0)(lineWidth,(double), 0)))
Draw two OpenMBV::Frame's of size 'size' at the contact points if 'enable'==true, otherwise the objec...
Definition: maxwell_contact_observer.h:74
void plot() override
plots time dependent data
Definition: maxwell_contact_observer.cc:99
BOOST_PARAMETER_MEMBER_FUNCTION((void), enableOpenMBVNormalForce, tag,(optional(sideOfInteraction,(OpenMBVInteractionArrow::SideOfInteraction), OpenMBVInteractionArrow::action)(scaleLength,(double), 1)(scaleSize,(double), 1)(referencePoint,(OpenMBVArrow::ReferencePoint), OpenMBVArrow::toPoint)(colorRepresentation,(OpenMBVArrow::ColorRepresentation), OpenMBVArrow::none)(minimalColorValue,(double), 0)(maximalColorValue,(double), 1)(diffuseColor,(const fmatvec::Vec3 &), fmatvec::Vec3(std::vector< double >{-1, 1, 1}))(transparency,(double), 0)(pointSize,(double), 0)(lineWidth,(double), 0)))
Sets the OpenMBV::Arrow to be used for drawing the normal force vector. This vector is the force whic...
Definition: maxwell_contact_observer.h:84
std::shared_ptr< OpenMBV::Frame > openMBVContactFrame
container of ContactFrames to draw
Definition: maxwell_contact_observer.h:42
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: maxwell_contact_observer.cc:41
void setDynamicSystemSolver(DynamicSystemSolver *sys) override
sets the used dynamics system solver to the element
Definition: maxwell_contact_observer.cc:144
BOOST_PARAMETER_MEMBER_FUNCTION((void), enableOpenMBVTangentialForce, tag,(optional(sideOfInteraction,(OpenMBVInteractionArrow::SideOfInteraction), OpenMBVInteractionArrow::action)(scaleLength,(double), 1)(scaleSize,(double), 1)(referencePoint,(OpenMBVArrow::ReferencePoint), OpenMBVArrow::toPoint)(colorRepresentation,(OpenMBVFrictionArrow::ColorRepresentation), OpenMBVFrictionArrow::none)(minimalColorValue,(double), 0)(maximalColorValue,(double), 1)(diffuseColor,(const fmatvec::Vec3 &), fmatvec::Vec3(std::vector< double >{-1, 1, 1}))(transparency,(double), 0)(pointSize,(double), 0)(lineWidth,(double), 0)))
Sets the OpenMBV::Arrow to be used for drawing the friction force vector. This vector is the friction...
Definition: maxwell_contact_observer.h:95
class for maxwell contacts
Definition: maxwell_contact.h:39
Definition: observer.h:26
Definition: openmbv_utils.h:150
Definition: openmbv_utils.h:128
Definition: openmbv_utils.h:111
namespace MBSim
Definition: bilateral_constraint.cc:30