mbsim 4.0.0 MBSim Kernel

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
30 extern const PlotFeatureEnum position, angle, velocity, angularVelocity, acceleration, angularAcceleration;
31
39 class Frame : public Element {
40 public:
45 Frame(const std::string &name = "dummy");
46
50 ~Frame() override = default;
51
52 /* INHERITED INTERFACE ELEMENT */
53 void init(InitStage stage, const InitConfigSet &config) override;
54 void plot() override;
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 void initializeUsingXML(xercesc::DOMElement *element) override;
117
118 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBV, tag, (optional (size,(double),1)(offset,(double),1)(transparency,(double),0)(pointSize,(double),0)(lineWidth,(double),0))) {
119 OpenMBVFrame ombv(size,offset,fmatvec::Vec3(std::vector<double>{-1,1,1}),transparency,pointSize,lineWidth);
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() override;
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 void createPlotGroup() override;
137
138 protected:
142 int hSize[2], hInd[2];
143
147 fmatvec::Vec3 WrOP;
148
152 fmatvec::SqrMat3 AWP;
153
157 fmatvec::Vec3 WvP, WomegaP;
158
162 fmatvec::Mat3xV WJP[3], WJR[3];
163
167 fmatvec::Vec3 WjP, WjR;
168
172 fmatvec::Vec3 WaP, WpsiP;
173
174 std::shared_ptr<OpenMBV::Frame> openMBVFrame;
175
176 bool updJac[3];
177 bool updGA{true};
178 bool updPos{true};
179 bool updVel{true};
180 bool updAcc{true};
181 };
182
183 }
184
185 #endif /* _FRAME_H_ */
MBSim::Frame::WJP
fmatvec::Mat3xV WJP[3]
Jacobians of translation and rotation from coordinate system to inertial frame.
Definition: frame.h:162
MBSim::Frame::WaP
fmatvec::Vec3 WaP
acceleration and angular acceleration of coordinate system in inertial frame of reference
Definition: frame.h:172
MBSim::Frame::plot
void plot() override
plots time dependent data
Definition: frame.cc:59
MBSim::Frame::hSize
int hSize[2]
size and index of right hand side
Definition: frame.h:142
MBSim::Element
basic class of MBSim mainly for plotting
Definition: element.h:56
MBSim::OpenMBVFrame
Definition: openmbv_utils.h:139
MBSim::Frame::WrOP
fmatvec::Vec3 WrOP
position of coordinate system in inertial frame of reference
Definition: frame.h:147
MBSim::Frame::~Frame
~Frame() override=default
destructor
MBSim::Element::InitStage
InitStage
The stages of the initialization.
Definition: element.h:62
MBSim::Frame::WjP
fmatvec::Vec3 WjP
Definition: frame.h:167
MBSim::Frame::AWP
fmatvec::SqrMat3 AWP
transformation matrix in inertial frame of reference
Definition: frame.h:152
MBSim::Element::name
std::string name
name of element
Definition: element.h:260
MBSim::Frame::WvP
fmatvec::Vec3 WvP
velocity and angular velocity of coordinate system in inertial frame of reference
Definition: frame.h:157
MBSim::Frame
cartesian frame on bodies used for application of e.g. links and loads
Definition: frame.h:39
MBSim::Frame::createPlotGroup
void createPlotGroup() override
creates the plotGroup for H5-output
Definition: frame.cc:159
MBSim::Frame::init
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: frame.cc:90
MBSim::Frame::Frame
Frame(const std::string &name="dummy")
constructor
Definition: frame.cc:48
MBSim
namespace MBSim
Definition: bilateral_constraint.cc:30