23#include "mbsim/objects/body.h"
24#include "mbsim/frames/frame.h"
25#include "mbsim/functions/time_dependent_function.h"
26#include "mbsim/functions/state_dependent_function.h"
32 class FixedRelativeFrame;
34 class InverseKineticsJoint;
52 enum GeneralizedVelocityOfRotation {
53 derivativeOfGeneralizedPositionOfRotation=0,
54 coordinatesOfAngularVelocityWrtFrameOfReference,
55 coordinatesOfAngularVelocityWrtFrameForKinematics,
72 void updateqd()
override;
73 void updateT()
override;
74 void updateh(
int j=0)
override;
75 void updateM()
override;
76 void updateInertiaTensor();
77 void updateGeneralizedPositions()
override;
78 void updateGeneralizedVelocities()
override;
79 void updateDerivativeOfGeneralizedPositions()
override;
80 void updateGeneralizedAccelerations()
override;
81 void updateGeneralizedJacobians(
int j=0);
82 void updatePositions();
83 void updateVelocities();
84 void updateJacobians()
override;
85 void updateGyroscopicAccelerations();
88 void updateAccelerations(
Frame *
frame)
override;
89 void updateJacobians(
Frame *
frame,
int j=0)
override { (this->*updateJacobians_[j])(
frame); }
90 void updateGyroscopicAccelerations(
Frame *
frame)
override;
95 void calcSize()
override;
96 void calcqSize()
override;
97 void calcuSize(
int j=0)
override;
98 void sethSize(
int hSize_,
int i=0)
override;
99 void sethInd(
int hInd_,
int i=0)
override;
102 void init(
InitStage stage,
const InitConfigSet &config)
override;
107 void plot()
override;
119 fPrPK->setParent(
this);
147 fAPK->setParent(
this);
164 void setTranslationDependentRotation(
bool dep) { translationDependentRotation = dep; }
165 void setGeneralizedVelocityOfRotation(GeneralizedVelocityOfRotation generalizedVelocityOfRotation_) { generalizedVelocityOfRotation = generalizedVelocityOfRotation_; }
178 void setMass(
double m_) {
m = m_; }
179 double getMass()
const {
return m; }
180 Frame* getFrameForKinematics() {
return &Z; };
181 FixedRelativeFrame* getFrameC() {
return C; };
183 const fmatvec::Vec3& evalGlobalRelativePosition() {
if(updPos) updatePositions();
return WrPK; }
184 const fmatvec::Vec3& evalGlobalRelativeVelocity() {
if(updVel) updateVelocities();
return WvPKrel; }
185 const fmatvec::Vec3& evalGlobalRelativeAngularVelocity() {
if(updVel) updateVelocities();
return WomPK; }
186 const fmatvec::SymMat3& evalGlobalInertiaTensor() {
if(updWTS) updateInertiaTensor();
return WThetaS; }
187 const fmatvec::Mat3xV& evalPJTT() {
if(updPJ) updateJacobians();
return PJTT; }
188 const fmatvec::Mat3xV& evalPJRR() {
if(updPJ) updateJacobians();
return PJRR; }
189 const fmatvec::Vec3& evalPjhT() {
if(updPJ) updateJacobians();
return PjhT; }
190 const fmatvec::Vec3& evalPjhR() {
if(updPJ) updateJacobians();
return PjhR; }
191 const fmatvec::Vec3& evalPjbT() {
if(updPjb) updateGyroscopicAccelerations();
return PjbT; }
192 const fmatvec::Vec3& evalPjbR() {
if(updPjb) updateGyroscopicAccelerations();
return PjbR; }
194 fmatvec::SymMat3& getGlobalInertiaTensor(
bool check=
true) { assert((not check) or (not updWTS));
return WThetaS; }
195 fmatvec::Vec3& getGlobalRelativeVelocity(
bool check=
true) { assert((not check) or (not updVel));
return WvPKrel; }
196 fmatvec::SqrMat3& getRelativeOrientation(
bool check=
true) { assert((not check) or (not updPos));
return APK; }
197 fmatvec::Vec3& getPjbT(
bool check=
true) { assert((not check) or (not updPjb));
return PjbT; }
198 fmatvec::Vec3& getPjbR(
bool check=
true) { assert((not check) or (not updPjb));
return PjbR; }
206 const fmatvec::SymMat3& getInertiaTensor()
const {
return SThetaS;}
207 fmatvec::SymMat3& getInertiaTensor() {
return SThetaS;}
214 void setFrameForInertiaTensor(Frame *
frame);
216 void setOpenMBVRigidBody(
const std::shared_ptr<OpenMBV::RigidBody> &body);
218 const Frame* getOpenMBVFrameOfReference()
const {
return openMBVFrame; }
220 void initializeUsingXML(xercesc::DOMElement *element)
override;
222 fmatvec::MatV& getJRel(
int i=0,
bool check=
true) { assert((not check) or (not updGJ));
return JRel[i]; }
223 fmatvec::VecV& getjRel(
bool check=
true) { assert((not check) or (not updGJ));
return jRel; }
224 void setqRel(
const fmatvec::VecV &
q);
225 void setuRel(
const fmatvec::VecV &u);
226 void setJRel(
const fmatvec::MatV &J);
227 void setjRel(
const fmatvec::VecV &j);
229 bool transformCoordinates()
const {
return fTR!=
nullptr; }
231 void resetUpToDate()
override;
232 void resetPositionsUpToDate()
override;
233 void resetVelocitiesUpToDate()
override;
234 void resetJacobiansUpToDate()
override;
235 void resetGyroscopicAccelerationsUpToDate()
override;
236 const fmatvec::VecV& evalqTRel() {
if(updq) updateGeneralizedPositions();
return qTRel; }
237 const fmatvec::VecV& evalqRRel() {
if(updq) updateGeneralizedPositions();
return qRRel; }
238 const fmatvec::VecV& evaluTRel() {
if(updu) updateGeneralizedVelocities();
return uTRel; }
239 const fmatvec::VecV& evaluRRel() {
if(updu) updateGeneralizedVelocities();
return uRRel; }
240 const fmatvec::VecV& evalqdTRel() {
if(updqd) updateDerivativeOfGeneralizedPositions();
return qdTRel; }
241 const fmatvec::VecV& evalqdRRel() {
if(updqd) updateDerivativeOfGeneralizedPositions();
return qdRRel; }
242 const fmatvec::MatV& evalJRel(
int j=0) {
if(updGJ) updateGeneralizedJacobians();
return JRel[j]; }
243 const fmatvec::VecV& evaljRel() {
if(updGJ) updateGeneralizedJacobians();
return jRel; }
245 fmatvec::VecV& getqTRel(
bool check=
true) { assert((not check) or (not updq));
return qTRel; }
246 fmatvec::VecV& getqRRel(
bool check=
true) { assert((not check) or (not updq));
return qRRel; }
247 fmatvec::VecV& getuTRel(
bool check=
true) { assert((not check) or (not updu));
return uTRel; }
248 fmatvec::VecV& getuRRel(
bool check=
true) { assert((not check) or (not updu));
return uRRel; }
249 fmatvec::VecV& getqdTRel(
bool check=
true) { assert((not check) or (not updqd));
return qdTRel; }
250 fmatvec::VecV& getqdRRel(
bool check=
true) { assert((not check) or (not updqd));
return qdRRel; }
252 void setUpdateByReference(
bool updateByReference_) { updateByReference = updateByReference_; }
254 InverseKineticsJoint* getJoint() {
return joint; }
271 fmatvec::Vec3 PjhT, PjhR, PjbT, PjbR;
288 Function<fmatvec::MatV(fmatvec::VecV)> *fTR{
nullptr};
307 fmatvec::MatV JRel[2];
310 fmatvec::VecV qTRel, qRRel, uTRel, uRRel, qdTRel, qdRRel;
311 fmatvec::Mat3xV PJTT, PJRR;
315 Frame *frameForJacobianOfRotation{
nullptr};
317 Frame *frameForInertiaTensor{
nullptr};
319 fmatvec::Range<fmatvec::Var,fmatvec::Var> iqT, iqR, iuT, iuR;
321 bool translationDependentRotation{
false};
330 bool updateByReference{
true};
334 GeneralizedVelocityOfRotation generalizedVelocityOfRotation{derivativeOfGeneralizedPositionOfRotation};
336 InverseKineticsJoint *joint;
base class for all mechanical bodies with mass and generalised coordinates
Definition: body.h:49
std::vector< Frame * > frame
vector of frames and contours
Definition: body.h:169
Class for constraints between generalized coordinates of objects.
Definition: constraint.h:30
InitStage
The stages of the initialization.
Definition: element.h:62
std::string name
name of element
Definition: element.h:260
void setName(const std::string &str)
Definition: element.h:115
cartesian frame on rigid bodies
Definition: fixed_relative_frame.h:31
cartesian frame on bodies used for application of e.g. links and loads
Definition: frame.h:39
Definition: function.h:53
fmatvec::Vec q
positions, velocities
Definition: object.h:304
rigid bodies with arbitrary kinematics
Definition: rigid_body.h:50
void setTimeDependentRotation(Function< fmatvec::RotMat3(double)> *fAPK_)
set Kinematic for only time dependent rotational motion
Definition: rigid_body.h:154
Function< fmatvec::RotMat3(fmatvec::VecV, double)> * getRotation()
get Kinematic for rotational motion
Definition: rigid_body.h:176
void setFrameForKinematics(Frame *frame)
Definition: rigid_body.cc:77
fmatvec::SqrMat3 APK
rotation matrix from kinematic Frame to parent Frame
Definition: rigid_body.h:276
Function< fmatvec::Vec3(fmatvec::VecV, double)> * fPrPK
translation from parent Frame to kinematic Frame in parent system
Definition: rigid_body.h:293
void setGeneralTranslation(Function< fmatvec::Vec3(fmatvec::VecV, double)> *fPrPK_)
set Kinematic for genral translational motion
Definition: rigid_body.h:117
double m
mass
Definition: rigid_body.h:262
~RigidBody() override
destructor
Definition: rigid_body.cc:71
FixedRelativeFrame * C
Definition: rigid_body.h:305
void setUpInverseKinetics() override
TODO.
Definition: rigid_body.cc:288
RigidBody(const std::string &name="")
constructor
Definition: rigid_body.cc:56
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: rigid_body.cc:149
void setGeneralRotation(Function< fmatvec::RotMat3(fmatvec::VecV, double)> *fAPK_)
set Kinematic for general rotational motion
Definition: rigid_body.h:145
fmatvec::SymMat3 SThetaS
inertia tensor with respect to centre of gravity in centre of gravity and world Frame
Definition: rigid_body.h:267
Frame * openMBVFrame
Frame of reference for drawing openMBVBody.
Definition: rigid_body.h:342
void setStateDependentTranslation(Function< fmatvec::Vec3(fmatvec::VecV)> *fPrPK_)
set Kinematic for only state dependent translational motion
Definition: rigid_body.h:133
void setTimeDependentTranslation(Function< fmatvec::Vec3(double)> *fPrPK_)
set Kinematic for only time dependent translational motion
Definition: rigid_body.h:126
fmatvec::Vec3 WvPKrel
translational and angular velocity from parent to kinematic Frame in world system
Definition: rigid_body.h:286
fmatvec::Vec3 PrPK
translation from parent to kinematic Frame in parent and world system
Definition: rigid_body.h:281
void plot() override
plots time dependent data
Definition: rigid_body.cc:301
void setInertiaTensor(const fmatvec::SymMat3 &RThetaR)
Definition: rigid_body.h:204
Function< fmatvec::Vec3(fmatvec::VecV, double)> * getTranslation()
get Kinematic for translational motion
Definition: rigid_body.h:171
void setStateDependentRotation(Function< fmatvec::RotMat3(fmatvec::VecV)> *fAPK_)
set Kinematic for only state dependent rotational motion
Definition: rigid_body.h:159
Function< fmatvec::RotMat3(fmatvec::VecV, double)> * fAPK
rotation from kinematic Frame to parent Frame
Definition: rigid_body.h:298
void setDynamicSystemSolver(DynamicSystemSolver *sys) override
sets the used dynamics system solver to the element
Definition: rigid_body.cc:646
Definition: state_dependent_function.h:28
Definition: time_dependent_function.h:28
namespace MBSim
Definition: bilateral_constraint.cc:30