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 
56  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))) {
57  ombvForce = std::shared_ptr<OpenMBVInteractionArrow>(new OpenMBVInteractionArrow(sideOfInteraction,scaleLength,scaleSize,OpenMBVArrow::toHead,referencePoint,colorRepresentation,minimalColorValue,maximalColorValue,diffuseColor,transparency,pointSize,lineWidth));
58  }
59 
60  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))) {
61  ombvMoment = std::shared_ptr<OpenMBVInteractionArrow>(new OpenMBVInteractionArrow(sideOfInteraction,scaleLength,scaleSize,OpenMBVArrow::toDoubleHead,referencePoint,colorRepresentation,minimalColorValue,maximalColorValue,diffuseColor,transparency,pointSize,lineWidth));
62  }
63 
70  BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVContactPoints, tag, (optional (size,(double),1)(offset,(double),1)(transparency,(double),0)(pointSize,(double),0)(lineWidth,(double),0))) {
71  OpenMBVFrame ombv(size,offset,fmatvec::Vec3(std::vector<double>{-1,1,1}),transparency,pointSize,lineWidth);
72  openMBVContactFrame=ombv.createOpenMBV();
73  }
74 
80  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))) {
81  ombvContact = std::shared_ptr<OpenMBVInteractionArrow>(new OpenMBVInteractionArrow(sideOfInteraction,scaleLength,scaleSize,OpenMBVArrow::toHead,referencePoint,colorRepresentation,minimalColorValue,maximalColorValue,diffuseColor,transparency,pointSize,lineWidth));
82  }
83 
91  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))) {
92  ombvFriction = std::shared_ptr<OpenMBVFrictionArrow>(new OpenMBVFrictionArrow(sideOfInteraction,scaleLength,scaleSize,OpenMBVArrow::toHead,referencePoint,colorRepresentation,minimalColorValue,maximalColorValue,diffuseColor,transparency,pointSize,lineWidth));
93  }
94  };
95 
96 }
97 
98 #endif
class for contacts
Definition: contact.h:48
solver interface for modelling and simulation of dynamic systems
Definition: dynamic_system_solver.h:56
void setDynamicSystemSolver(DynamicSystemSolver *sys) override
sets the used dynamics system solver to the element
Definition: contact_observer.cc:125
void plot() override
plots time dependent data
Definition: contact_observer.cc:87
Definition: openmbv_utils.h:111
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: contact_observer.cc:40
Definition: openmbv_utils.h:139
Definition: openmbv_utils.h:128
InitStage
The stages of the initialization.
Definition: element.h:62
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:91
std::string name
name of element
Definition: element.h:235
Definition: contact_observer.h:32
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:70
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:80
std::shared_ptr< OpenMBV::Frame > openMBVContactFrame
container of ContactFrames to draw
Definition: contact_observer.h:42
Definition: observer.h:26
namespace MBSim
Definition: eigenanalyzer.cc:47