All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
frame_link.h
1 /* Copyright (C) 2004-2014 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@googlemail.com
18  */
19 
20 #ifndef _FRAME_LINK_H_
21 #define _FRAME_LINK_H_
22 
23 #include "mbsim/links/link.h"
24 
25 #include "mbsim/utils/boost_parameters.h"
26 #include "mbsim/utils/openmbv_utils.h"
27 
28 namespace OpenMBV {
29  class Group;
30  class Arrow;
31 }
32 
33 namespace H5 {
34  class Group;
35 }
36 
37 namespace MBSim {
42  class FrameLink : public Link {
43  public:
48  FrameLink(const std::string &name);
49 
50  virtual void init(InitStage stage);
51 
52  /* INHERITED INTERFACE OF ELEMENT */
53  std::string getType() const { return "Link"; }
54  virtual void plot();
55  virtual void closePlot();
56  /***************************************************/
57 
58  void initializeUsingXML(xercesc::DOMElement *element);
59 
60  void updateh(int i=0);
61  void updatedhdz();
62 
63  /* INHERITED INTERFACE OF LINK */
64  virtual void updateWRef(const fmatvec::Mat& ref, int i=0);
65  virtual void updateVRef(const fmatvec::Mat& ref, int i=0);
66  virtual void updatehRef(const fmatvec::Vec &hRef, int i=0);
67  virtual void updatedhdqRef(const fmatvec::Mat& ref, int i=0);
68  virtual void updatedhduRef(const fmatvec::SqrMat& ref, int i=0);
69  virtual void updatedhdtRef(const fmatvec::Vec& ref, int i=0);
70  virtual void updaterRef(const fmatvec::Vec &ref, int i=0);
71  /***************************************************/
72 
73  /* INTERFACE TO BE DEFINED IN DERIVED CLASS */
77  void connect(Frame *frame0, Frame* frame1) {
78  frame[0] = frame0;
79  frame[1] = frame1;
80  }
81 
82  Frame* getFrame(int i) { return frame[i]; }
83 
84  void resetUpToDate();
85  virtual void updatePositions();
86  virtual void updateVelocities();
87  void updateGeneralizedPositions();
88  void updateGeneralizedVelocities();
89  void updateGeneralizedForces();
90  void updateForce();
91  void updateForceDirections();
92  void updateR();
93  virtual void updatelaF() { }
94  virtual void updatelaM() { }
95  const fmatvec::Vec3& evalGlobalRelativePosition() { if(updPos) updatePositions(); return WrP0P1; }
96  const fmatvec::Vec3& evalGlobalRelativeVelocity() { if(updVel) updateVelocities(); return WvP0P1; }
97  const fmatvec::Vec3& evalGlobalRelativeAngularVelocity() { if(updVel) updateVelocities(); return WomP0P1; }
98  const fmatvec::Mat3xV& evalGlobalForceDirection() { if(updFD) updateForceDirections(); return DF; }
99  const fmatvec::Vec3& evalForce() { if(updF) updateForce(); return F; }
100  const fmatvec::Mat3xV& evalRF() { if(updRMV) updateR(); return RF; }
101  const fmatvec::VecV& evallaF() { if(updlaF) updatelaF(); return lambdaF; }
102  const fmatvec::VecV& evallaM() { if(updlaM) updatelaM(); return lambdaM; }
103 
105  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))) {
106  OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toHead,referencePoint,scaleLength,scaleSize);
107  setOpenMBVForce(ombv.createOpenMBV());
108  }
109  void setOpenMBVForce(const std::shared_ptr<OpenMBV::Arrow> &arrow) { openMBVArrowF = arrow; }
110 
111  protected:
115  fmatvec::Vec3 WrP0P1, WvP0P1, WomP0P1;
116 
117  fmatvec::Mat3xV DF;
118 
119  fmatvec::Vec3 F;
120 
121  fmatvec::Mat3xV RF;
122 
123  fmatvec::VecV lambdaF, lambdaM;
124 
128  fmatvec::RangeV iF;
129 
133  std::vector<Frame*> frame;
134 
135  std::shared_ptr<OpenMBV::Group> openMBVForceGrp;
136  std::shared_ptr<OpenMBV::Arrow> openMBVArrowF;
137  std::shared_ptr<OpenMBV::Arrow> openMBVArrowM;
138 
139  bool updPos, updVel, updFD, updF, updRMV, updlaF, updlaM;
140 
141  protected:
142  std::string saved_ref1, saved_ref2;
143  };
144 }
145 
146 #endif /* _LINK_MECHANICS_H_ */
147 
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