mbsim 4.0.0 MBSim Kernel

contact_observer.h
1 /* Copyright (C) 2004-2016 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 _CONTACT_OBSERVER_H__
21 #define _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
28 namespace MBSim {
29
30 class Contact;
31
32 class ContactObserver : public Observer {
33 protected:
34 std::vector<SingleContactObserver> contactObserver;
35
36 Contact* 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 ContactObserver(const std::string &name="");
49 void setContact(Contact *link_) { link = link_; }
50
51 void init(InitStage stage, const InitConfigSet &config) override;
52 void plot() override;
53 void initializeUsingXML(xercesc::DOMElement *element) override;
54 void setDynamicSystemSolver(DynamicSystemSolver *sys) override;
55 void setOutputFrame(Frame *outputFrame_) { outputFrame = outputFrame_; }
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)(transparency,(double),0)(pointSize,(double),0)(lineWidth,(double),0))) {
75 OpenMBVFrame ombv(size,offset,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
MBSim::Contact
class for contacts
Definition: contact.h:48
MBSim::DynamicSystemSolver
solver interface for modelling and simulation of dynamic systems
Definition: dynamic_system_solver.h:61
MBSim::ContactObserver::setDynamicSystemSolver
void setDynamicSystemSolver(DynamicSystemSolver *sys) override
sets the used dynamics system solver to the element
Definition: contact_observer.cc:135
MBSim::ContactObserver::plot
void plot() override
plots time dependent data
Definition: contact_observer.cc:93
MBSim::OpenMBVInteractionArrow
Definition: openmbv_utils.h:111
MBSim::ContactObserver::init
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: contact_observer.cc:41
MBSim::OpenMBVFrame
Definition: openmbv_utils.h:139
MBSim::Element::getPlotGroup
H5::GroupBase * getPlotGroup()
Definition: element.h:139
H5::GroupBase
MBSim::OpenMBVFrictionArrow
Definition: openmbv_utils.h:128
MBSim::Element::InitStage
InitStage
The stages of the initialization.
Definition: element.h:62
MBSim::ContactObserver::BOOST_PARAMETER_MEMBER_FUNCTION
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: contact_observer.h:95
MBSim::Element::name
std::string name
name of element
Definition: element.h:260
MBSim::ContactObserver
Definition: contact_observer.h:32
MBSim::ContactObserver::BOOST_PARAMETER_MEMBER_FUNCTION
BOOST_PARAMETER_MEMBER_FUNCTION((void), enableOpenMBVContactPoints, tag,(optional(size,(double), 1)(offset,(double), 1)(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: contact_observer.h:74
MBSim::Frame
cartesian frame on bodies used for application of e.g. links and loads
Definition: frame.h:39
MBSim::ContactObserver::BOOST_PARAMETER_MEMBER_FUNCTION
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: contact_observer.h:84
MBSim::ContactObserver::openMBVContactFrame
std::shared_ptr< OpenMBV::Frame > openMBVContactFrame
container of ContactFrames to draw
Definition: contact_observer.h:42
MBSim::Observer
Definition: observer.h:26
MBSim
namespace MBSim
Definition: bilateral_constraint.cc:30