All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
frame.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_H__
21 #define _FRAME_H__
22 
23 #include "mbsim/element.h"
24 
25 #include "mbsim/utils/boost_parameters.h"
26 #include "mbsim/utils/openmbv_utils.h"
27 
28 namespace MBSim {
29 
37  class Frame : public Element {
38  public:
43  Frame(const std::string &name = "dummy");
44 
48  virtual ~Frame() {}
49 
50  /* INHERITED INTERFACE ELEMENT */
51  void init(InitStage stage);
52  std::string getType() const { return "Frame"; }
53  virtual void plot();
54  virtual void closePlot();
55  /***************************************************/
56 
57  /* INTERFACE FOR DERIVED CLASSES */
58  /***************************************************/
59 
60  /* GETTER / SETTER */
61  int gethSize(int i=0) const { return hSize[i]; }
62  int gethInd(int i=0) const { return hInd[i]; }
63  void sethSize(int size, int i=0) { hSize[i] = size; }
64  void sethInd(int ind, int i=0) { hInd[i] = ind; }
65 
66  const fmatvec::Vec3& getPosition(bool check=true) const { assert((not check) or (not updPos)); return WrOP; }
67  fmatvec::Vec3& getPosition(bool check=true) { assert((not check) or (not updPos)); return WrOP; }
68  void setPosition(const fmatvec::Vec3 &v) { WrOP = v; }
69  const fmatvec::Vec3& evalPosition() { if(updPos) updatePositions(); return WrOP; }
70 
71  const fmatvec::SqrMat3& getOrientation(bool check=true) const { assert((not check) or (not updPos)); return AWP; }
72  fmatvec::SqrMat3& getOrientation(bool check=true) { assert((not check) or (not updPos)); return AWP; }
73  void setOrientation(const fmatvec::SqrMat3 &AWP_) { AWP = AWP_; }
74  const fmatvec::SqrMat3& evalOrientation() { if(updPos) updatePositions(); return AWP; }
75 
76  const fmatvec::Vec3& getVelocity(bool check=true) const { assert((not check) or (not updVel)); return WvP; }
77  fmatvec::Vec3& getVelocity(bool check=true) { assert((not check) or (not updVel)); return WvP; }
78  void setVelocity(const fmatvec::Vec3 &v) { WvP = v; }
79  const fmatvec::Vec3& evalVelocity() { if(updVel) updateVelocities(); return WvP; }
80 
81  const fmatvec::Vec3& getAngularVelocity(bool check=true) const { assert((not check) or (not updVel)); return WomegaP; }
82  fmatvec::Vec3& getAngularVelocity(bool check=true) { assert((not check) or (not updVel)); return WomegaP; }
83  void setAngularVelocity(const fmatvec::Vec3 &omega) { WomegaP = omega; }
84  const fmatvec::Vec3& evalAngularVelocity() { if(updVel) updateVelocities(); return WomegaP; }
85 
86  const fmatvec::Vec3& getAcceleration(bool check=true) const { assert((not check) or (not updAcc)); return WaP; }
87  fmatvec::Vec3& getAcceleration(bool check=true) { assert((not check) or (not updAcc)); return WaP; }
88  void setAcceleration(const fmatvec::Vec3 &a) { WaP = a; }
89  const fmatvec::Vec3& evalAcceleration() { if(updAcc) updateAccelerations(); return WaP; }
90 
91  const fmatvec::Vec3& getAngularAcceleration(bool check=true) const { assert((not check) or (not updAcc)); return WpsiP; }
92  fmatvec::Vec3& getAngularAcceleration(bool check=true) { assert((not check) or (not updAcc)); return WpsiP; }
93  void setAngularAcceleration(const fmatvec::Vec3 &psi) { WpsiP = psi; }
94  const fmatvec::Vec3& evalAngularAcceleration() { if(updAcc) updateAccelerations(); return WpsiP; }
95 
96  const fmatvec::Mat3xV& getJacobianOfTranslation(int j=0, bool check=true) const { assert((not check) or (not updJac[j])); return WJP[j]; }
97  fmatvec::Mat3xV& getJacobianOfTranslation(int j=0, bool check=true) { assert((not check) or (not updJac[j])); return WJP[j]; }
98  void setJacobianOfTranslation(const fmatvec::Mat3xV &WJP_, int j=0) { WJP[j] = WJP_; }
99  const fmatvec::Mat3xV& evalJacobianOfTranslation(int j=0) { if(updJac[j]) updateJacobians(j); return WJP[j]; }
100 
101  const fmatvec::Mat3xV& getJacobianOfRotation(int j=0, bool check=true) const { assert((not check) or (not updJac[j])); return WJR[j]; }
102  fmatvec::Mat3xV& getJacobianOfRotation(int j=0, bool check=true) { assert((not check) or (not updJac[j])); return WJR[j]; }
103  void setJacobianOfRotation(const fmatvec::Mat3xV &WJR_, int j=0) { WJR[j] = WJR_; }
104  const fmatvec::Mat3xV& evalJacobianOfRotation(int j=0) { if(updJac[j]) updateJacobians(j); return WJR[j]; }
105 
106  const fmatvec::Vec3& getGyroscopicAccelerationOfTranslation(bool check=true) const { assert((not check) or (not updGA)); return WjP; }
107  fmatvec::Vec3& getGyroscopicAccelerationOfTranslation(bool check=true) { assert((not check) or (not updGA)); return WjP; }
108  void setGyroscopicAccelerationOfTranslation(const fmatvec::Vec3 &WjP_) { WjP = WjP_; }
109  const fmatvec::Vec3& evalGyroscopicAccelerationOfTranslation() { if(updGA) updateGyroscopicAccelerations(); return WjP; }
110 
111  const fmatvec::Vec3& getGyroscopicAccelerationOfRotation(bool check=true) const { assert((not check) or (not updGA)); return WjR; }
112  fmatvec::Vec3& getGyroscopicAccelerationOfRotation(bool check=true) { assert((not check) or (not updGA)); return WjR; }
113  void setGyroscopicAccelerationOfRotation(const fmatvec::Vec3 &WjR_) { WjR = WjR_; }
114  const fmatvec::Vec3& evalGyroscopicAccelerationOfRotation() { if(updGA) updateGyroscopicAccelerations(); return WjR; }
115 
116  virtual void initializeUsingXML(xercesc::DOMElement *element);
117 
118  BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBV, tag, (optional (size,(double),1)(offset,(double),1)(transparency,(double),0))) {
119  OpenMBVFrame ombv(size,offset,"[-1;1;1]",transparency);
120  openMBVFrame=ombv.createOpenMBV();
121  }
122  void setOpenMBVFrame(const std::shared_ptr<OpenMBV::Frame> &frame) { openMBVFrame = frame; }
123  std::shared_ptr<OpenMBV::Frame> &getOpenMBVFrame() {return openMBVFrame; }
124 
125  void resetUpToDate();
126  virtual void resetPositionsUpToDate();
127  virtual void resetVelocitiesUpToDate();
128  virtual void resetJacobiansUpToDate();
129  virtual void resetGyroscopicAccelerationsUpToDate();
130  virtual void updatePositions() { parent->updatePositions(this); updPos = false; }
131  virtual void updateVelocities() { parent->updateVelocities(this); updVel = false; }
132  virtual void updateAccelerations() { parent->updateAccelerations(this); updAcc = false; }
133  virtual void updateJacobians(int j=0) { parent->updateJacobians(this,j); updJac[j] = false; }
134  virtual void updateGyroscopicAccelerations() { parent->updateGyroscopicAccelerations(this); updGA = false; }
135 
136  protected:
140  int hSize[2], hInd[2];
141 
145  fmatvec::Vec3 WrOP;
146 
150  fmatvec::SqrMat3 AWP;
151 
155  fmatvec::Vec3 WvP, WomegaP;
156 
160  fmatvec::Mat3xV WJP[3], WJR[3];
161 
165  fmatvec::Vec3 WjP, WjR;
166 
170  fmatvec::Vec3 WaP, WpsiP;
171 
172  std::shared_ptr<OpenMBV::Frame> openMBVFrame;
173 
174  bool updJac[3], updGA, updPos, updVel, updAcc;
175  };
176 
177 }
178 
179 #endif /* _FRAME_H_ */
fmatvec::Mat3xV WJP[3]
Jacobians of translation and rotation from coordinate system to inertial frame.
Definition: frame.h:160
fmatvec::Vec3 WaP
acceleration and angular acceleration of coordinate system in inertial frame of reference ...
Definition: frame.h:170
virtual void closePlot()
closes plot file
Definition: frame.cc:91
int hSize[2]
size and index of right hand side
Definition: frame.h:140
basic class of MBSim mainly for plotting
Definition: element.h:58
std::string getType() const
Definition: frame.h:52
fmatvec::Vec3 WrOP
position of coordinate system in inertial frame of reference
Definition: frame.h:145
virtual ~Frame()
destructor
Definition: frame.h:48
void init(InitStage stage)
plots time series header
Definition: frame.cc:97
InitStage
The stages of the initialization.
Definition: element.h:97
fmatvec::Vec3 WjP
Definition: frame.h:165
fmatvec::SqrMat3 AWP
transformation matrix in inertial frame of reference
Definition: frame.h:150
std::string name
name of element
Definition: element.h:298
fmatvec::Vec3 WvP
velocity and angular velocity of coordinate system in inertial frame of reference ...
Definition: frame.h:155
cartesian frame on bodies used for application of e.g. links and loads
Definition: frame.h:37
virtual void plot()
plots time dependent data
Definition: frame.cc:47
Frame(const std::string &name="dummy")
constructor
Definition: frame.cc:36

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML