mbsim  4.0.0
MBSim Kernel
elastic_joint.h
1 /* Copyright (C) 2004-2016 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 _ELASTIC_JOINT_H_
21 #define _ELASTIC_JOINT_H_
22 
23 #include "mbsim/links/floating_frame_link.h"
24 #include "mbsim/functions/function.h"
25 
26 namespace MBSim {
27 
33  public:
38  ElasticJoint(const std::string &name = "");
39 
43  ~ElasticJoint() override;
44 
45  void updateGeneralizedForces() override;
46  void updatexd() override;
47 
48  void calcxSize() override { if(integrateGeneralizedRelativeVelocityOfRotation) xSize = momentDir.cols(); }
49  void init(InitStage stage, const InitConfigSet &config) override;
50 
51  bool isSingleValued() const override { return true; }
52  bool isActive() const override { return true; }
53  bool gActiveChanged() override { return false; }
54 
55  void setGeneralizedForceFunction(Function<fmatvec::VecV(fmatvec::VecV,fmatvec::VecV)> *func_) {
56  func=func_;
57  func->setParent(this);
58  func->setName("GeneralizedForce");
59  }
60 
64  void setForceDirection(const fmatvec::Mat3xV& fd) { forceDir <<= fd; }
65 
69  void setMomentDirection(const fmatvec::Mat3xV& md) { momentDir <<= md; }
70 
71  void setIntegrateGeneralizedRelativeVelocityOfRotation(bool integrateGeneralizedRelativeVelocityOfRotation_) { integrateGeneralizedRelativeVelocityOfRotation = integrateGeneralizedRelativeVelocityOfRotation_; }
72 
73  fmatvec::VecV evalGeneralizedRelativePositionOfRotation() override;
74  fmatvec::Vec3 evalGlobalRelativeAngle();
75 
76  void initializeUsingXML(xercesc::DOMElement *element) override;
77 
78  protected:
79  Function<fmatvec::VecV(fmatvec::VecV,fmatvec::VecV)> *func{nullptr};
80 
84  fmatvec::Mat3xV JT;
85 
86  fmatvec::Vec3 WphiK0K1, eR;
87 
88  size_t iR{2};
89 
90  bool integrateGeneralizedRelativeVelocityOfRotation{false};
91  };
92 
93 }
94 
95 #endif
void setMomentDirection(const fmatvec::Mat3xV &md)
Definition: elastic_joint.h:69
class for elastic joints
Definition: elastic_joint.h:32
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: elastic_joint.cc:51
bool gActiveChanged() override
Definition: elastic_joint.h:53
fmatvec::Mat3xV JT
translational JACOBIAN (not empty for e.g. prismatic joints)
Definition: elastic_joint.h:84
ElasticJoint(const std::string &name="")
constructor
Definition: elastic_joint.cc:34
bool isActive() const override
Definition: elastic_joint.h:52
InitStage
The stages of the initialization.
Definition: element.h:62
Definition: contact_kinematics.h:32
std::string name
name of element
Definition: element.h:249
~ElasticJoint() override
destructor
Definition: elastic_joint.cc:37
void setName(const std::string &str)
Definition: element.h:115
bool isSingleValued() const override
asks the link if it contains single valued force laws that contribute to the right-hand side vector h
Definition: elastic_joint.h:51
void setForceDirection(const fmatvec::Mat3xV &fd)
Definition: elastic_joint.h:64
namespace MBSim
Definition: eigenanalyzer.cc:47