All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
rigid_body_link.h
1 /* Copyright (C) 2004-2015 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 _RIGID_BODY_LINK_H_
21 #define _RIGID_BODY_LINK_H_
22 
23 #include "mbsim/links/link.h"
24 #include "mbsim/frames/floating_relative_frame.h"
25 
26 #include "mbsim/utils/boost_parameters.h"
27 #include "mbsim/utils/openmbv_utils.h"
28 
29 namespace MBSim {
30 
31  class RigidBody;
32 
33  class RigidBodyLink : public Link {
34  protected:
35  std::vector<RigidBody*> body;
36  std::vector<double> ratio;
37  std::vector<FloatingRelativeFrame> C;
38  bool updPos, updVel, updFD, updF, updM, updRMV;
39  std::vector<fmatvec::Mat3xV> DF, DM;
40  std::vector<fmatvec::Vec3> F, M;
41  std::vector<fmatvec::Mat3xV> RF, RM;
42  fmatvec::RangeV iF, iM;
43  Frame *support;
44 
45  public:
46  RigidBodyLink(const std::string &name="");
47 
48  void calclaSize(int j) { laSize = 1; }
49  void calcgSize(int j) { gSize = 1; }
50  void calcgdSize(int j) { gdSize = 1; }
51 
52  void updateh(int i=0);
53  void updateW(int i=0);
54  void updateg();
55  void updategd();
56  virtual void updatePositions();
57  void updateGeneralizedPositions();
58  void updateGeneralizedVelocities();
59  void updateForce();
60  void updateMoment();
61  void updateForceDirections();
62  void updateR();
63  void updatewb();
64  const fmatvec::Mat3xV& evalGlobalForceDirection(int i) { if(updFD) updateForceDirections(); return DF[i]; }
65  const fmatvec::Mat3xV& evalGlobalMomentDirection(int i) { if(updFD) updateForceDirections(); return DM[i]; }
66  const fmatvec::Vec3& evalForce(int i) { if(updF) updateForce(); return F[i]; }
67  const fmatvec::Vec3& evalMoment(int i) { if(updM) updateMoment(); return M[i]; }
68  const fmatvec::Mat3xV& evalRF(int i) { if(updRMV) updateR(); return RF[i]; }
69  const fmatvec::Mat3xV& evalRM(int i) { if(updRMV) updateR(); return RM[i]; }
70  void updatehRef(const fmatvec::Vec &hParent, int j=0);
71  void updaterRef(const fmatvec::Vec &hParent, int j=0);
72  void updateWRef(const fmatvec::Mat &WParent, int j=0);
73  void updateVRef(const fmatvec::Mat &WParent, int j=0);
74 
75  std::string getType() const { return "RigidBodyLink"; }
76  void init(InitStage stage);
77 
78  void plot();
79 
80  void initializeUsingXML(xercesc::DOMElement * element);
81 
82  void resetUpToDate();
83 
84  virtual void setSupportFrame(Frame *frame) { support = frame; }
85 
87  BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVForce, tag, (optional (scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(OpenMBV::Arrow::ReferencePoint),OpenMBV::Arrow::toPoint)(diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0))) {
88  OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toHead,referencePoint,scaleLength,scaleSize);
89  setOpenMBVForce(ombv.createOpenMBV());
90  }
91  void setOpenMBVForce(const std::shared_ptr<OpenMBV::Arrow> &arrow) { FArrow[0]=arrow; }
92 
94  BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVMoment, tag, (optional (scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(OpenMBV::Arrow::ReferencePoint),OpenMBV::Arrow::toPoint)(diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0))) {
95  OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toHead,referencePoint,scaleLength,scaleSize);
96  setOpenMBVMoment(ombv.createOpenMBV());
97  }
98  void setOpenMBVMoment(const std::shared_ptr<OpenMBV::Arrow> &arrow) { MArrow[0]=arrow; }
99 
100  protected:
101  std::shared_ptr<OpenMBV::Group> openMBVForceGrp;
102  std::vector<std::shared_ptr<OpenMBV::Arrow> > FArrow, MArrow;
103 
104  private:
105  std::string saved_supportFrame;
106  };
107 
108 }
109 
110 #endif
Definition: openmbv_utils.h:54
InitStage
The stages of the initialization.
Definition: element.h:97
std::string name
name of element
Definition: element.h:298
cartesian frame on bodies used for application of e.g. links and loads
Definition: frame.h:37

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML