MBSim

Project Page
frame.h
1 /* Copyright (C) 2004-2009 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 #ifdef HAVE_OPENMBVCPPINTERFACE
26 namespace OpenMBV {
27  class Frame;
28  class Arrow;
29 }
30 #endif
31 
32 namespace MBSim {
33 
37  enum FrameFeature {
38  position, firstTangent, normal, secondTangent, cosy, position_cosy, velocity, angularVelocity, velocity_cosy, velocities, velocities_cosy, all
39  };
40 
48  class Frame : public Element {
49  public:
54  Frame(const std::string &name = "dummy");
55 
59  virtual ~Frame() {}
60 
61  /* INHERITED INTERFACE ELEMENT */
62  std::string getType() const { return "Frame"; }
63  virtual void plot(double t, double dt = 1);
64  virtual void closePlot();
65  /***************************************************/
66 
67  /* INTERFACE FOR DERIVED CLASSES */
68  virtual int gethSize(int i=0) const { return hSize[i]; }
69  virtual int gethInd(int i=0) const { return hInd[i]; }
70  //virtual ObjectInterface* getParent() { return parent; }
71  //virtual void setParent(ObjectInterface* parent_) { parent = parent_; }
72  virtual const fmatvec::Vec& getPosition() const { return WrOP; }
73  virtual const fmatvec::SqrMat& getOrientation() const { return AWP; }
74  virtual fmatvec::Vec& getPosition() { return WrOP; }
75  virtual fmatvec::SqrMat& getOrientation() { return AWP; }
76  virtual void setPosition(const fmatvec::Vec &v) { WrOP = v; }
77  virtual void setOrientation(const fmatvec::SqrMat &AWP_) { AWP = AWP_; }
78  virtual const fmatvec::Vec& getVelocity() const { return WvP; }
79  virtual const fmatvec::Vec& getAngularVelocity() const { return WomegaP; }
80  virtual const fmatvec::Mat& getJacobianOfTranslation(int j=0) const { return WJP[j]; }
81  virtual const fmatvec::Mat& getJacobianOfRotation(int j=0) const { return WJR[j]; }
82  virtual const fmatvec::Vec& getGyroscopicAccelerationOfTranslation(int j=0) const { return WjP[j]; }
83  virtual const fmatvec::Vec& getGyroscopicAccelerationOfRotation(int j=0) const { return WjR[j]; }
84  virtual const fmatvec::Vec& getAcceleration() const { return WaP; }
85  virtual const fmatvec::Vec& getAngularAcceleration() const { return WpsiP; }
86  virtual void init(InitStage stage);
87 #ifdef HAVE_OPENMBVCPPINTERFACE
88  virtual void enableOpenMBV(double size=1, double offset=1);
89 #endif
90  /***************************************************/
91 
92  /* GETTER / SETTER */
93  void sethSize(int size, int i=0) { hSize[i] = size; }
94  void sethInd(int ind, int i=0) { hInd[i] = ind; }
95 
96  fmatvec::Vec& getVelocity() { return WvP; }
97  fmatvec::Vec& getAngularVelocity() { return WomegaP; }
98  void setVelocity(const fmatvec::Vec &v) { WvP = v; }
99  void setAngularVelocity(const fmatvec::Vec &omega) { WomegaP = omega; }
100 
101  void setJacobianOfTranslation(const fmatvec::Mat &WJP_, int j=0) { WJP[j]=WJP_; }
102  void setGyroscopicAccelerationOfTranslation(const fmatvec::Vec &WjP_, int j=0) { WjP[j]=WjP_; }
103  void setJacobianOfRotation(const fmatvec::Mat &WJR_, int j=0) { WJR[j]=WJR_; }
104  void setGyroscopicAccelerationOfRotation(const fmatvec::Vec &WjR_, int j=0) { WjR[j]=WjR_; }
105  fmatvec::Mat& getJacobianOfTranslation(int j=0) { return WJP[j]; }
106  fmatvec::Mat& getJacobianOfRotation(int j=0) { return WJR[j]; }
107  fmatvec::Vec& getGyroscopicAccelerationOfTranslation(int j=0) { return WjP[j]; }
108  fmatvec::Vec& getGyroscopicAccelerationOfRotation(int j=0) { return WjR[j]; }
109  fmatvec::Vec& getAcceleration() { return WaP; }
110  fmatvec::Vec& getAngularAcceleration() { return WpsiP; }
111  void setAcceleration(const fmatvec::Vec &a) { WaP = a; }
112  void setAngularAcceleration(const fmatvec::Vec &psi) { WpsiP = psi; }
113  /***************************************************/
114 
115  protected:
117  // * \brief parent object for plot invocation
118  // */
119  //ObjectInterface* parent;
120 
124  int hSize[2], hInd[2];
125 
129  fmatvec::Vec WrOP;
130 
134  fmatvec::SqrMat AWP;
135 
139  fmatvec::Vec WvP, WomegaP;
140 
144  fmatvec::Mat WJP[2], WJR[2];
145 
149  fmatvec::Vec WjP[2], WjR[2];
150 
154  fmatvec::Vec WaP, WpsiP;
155 
156 #ifdef HAVE_OPENMBVCPPINTERFACE
157  OpenMBV::Frame* openMBVFrame;
158 #endif
159  };
160 
161 }
162 
163 #endif /* _FRAME_H_ */
164