mbsim 4.0.0 MBSim Kernel

joint.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 _JOINT_H_
21 #define _JOINT_H_
22
23 #include "mbsim/links/floating_frame_link.h"
24
25 namespace MBSim {
26
27 class GeneralizedForceLaw;
28 class GeneralizedImpactLaw;
29 class FrictionForceLaw;
30 class FrictionImpactLaw;
31 class Body;
32
42 class Joint : public FloatingFrameLink {
43 public:
48 Joint(const std::string &name = "") : FloatingFrameLink(name), iFM(0,-1), iMM(0,-1) { }
49
53 ~Joint() override;
54
55 void updatelaF() override { (this->*updatelaF_)(); updlaF = false; }
56 void updatelaM() override { (this->*updatelaM_)(); updlaM = false; }
57 void updatelaF0() { }
58 void updatelaFS();
59 void updatelaFM();
60 void updatelaM0() { }
61 void updatelaMS();
62 void updatelaMM();
63 void (Joint::*updatelaF_)();
64 void (Joint::*updatelaM_)();
65 void updateh(int i=0) override;
66 void updateW(int i=0) override;
67 void updateg() override;
68 void updategd() override;
69 void updatewb() override;
70 void updatexd() override;
71
72 void calclaSize(int j) override;
73 void calcgSize(int j) override;
74 void calcgdSize(int j) override;
75 void calcrFactorSize(int j) override;
76 void calccorrSize(int j) override;
77 void calcxSize() override { if(integrateGeneralizedRelativeVelocityOfRotation) xSize = momentDir.cols(); }
78 void init(InitStage stage, const InitConfigSet &config) override;
79
80 bool isSetValued() const override;
81 bool isSingleValued() const override;
82 bool isActive() const override { return true; }
83 bool gActiveChanged() override { return false; }
84 void solveImpactsFixpointSingle() override;
85 void solveConstraintsFixpointSingle() override;
86 void solveImpactsGaussSeidel() override;
87 void solveConstraintsGaussSeidel() override;
88 void solveImpactsRootFinding() override;
89 void solveConstraintsRootFinding() override;
90 void jacobianConstraints() override;
91 void jacobianImpacts() override;
92 void updaterFactors() override;
93 void checkImpactsForTermination() override;
94 void checkConstraintsForTermination() override;
95
96 void setForceLaw(GeneralizedForceLaw * rc);
97 void setMomentLaw(GeneralizedForceLaw * rc);
98
102 void setForceDirection(const fmatvec::Mat3xV& fd) { forceDir <<= fd; }
103
107 void setMomentDirection(const fmatvec::Mat3xV& md) { momentDir <<= md; }
108
109 void setIntegrateGeneralizedRelativeVelocityOfRotation(bool integrateGeneralizedRelativeVelocityOfRotation_) { integrateGeneralizedRelativeVelocityOfRotation = integrateGeneralizedRelativeVelocityOfRotation_; }
110
111 enum class AngleMode {
112 smallAngles,
113 cardan,
114 };
115 void setAngleMode(AngleMode angleMode_) { angleMode = angleMode_; }
116
117 fmatvec::VecV evalGeneralizedRelativePositionOfRotation() override;
118
119 void initializeUsingXML(xercesc::DOMElement *element) override;
120
121 protected:
125 GeneralizedForceLaw *ffl{nullptr};
126
130 GeneralizedForceLaw * fml{nullptr};
131
135 GeneralizedImpactLaw *fifl{nullptr};
136
140 GeneralizedImpactLaw * fiml{nullptr};
141
145 fmatvec::Vec gdn, gdd;
146
147 bool integrateGeneralizedRelativeVelocityOfRotation{false};
148
149 AngleMode angleMode { AngleMode::smallAngles };
150
151 bool disableAngleWarning { false };
152
153 fmatvec::Mat3xV RF, RM;
154 fmatvec::RangeV iFM, iMM;
155 };
156
157 class InverseKineticsJoint : public Joint {
158 friend class JointConstraint;
159 public:
160 InverseKineticsJoint(const std::string &name) : Joint(name) { }
161 void updateb() override;
162 void calcbSize() override;
163 void setBody(Body* body_) { body = body_; }
164 void init(InitStage stage, const InitConfigSet &config) override;
165 bool isSetValued() const override { return true; }
166
167 protected:
168 Body* body{nullptr};
169 };
170
171 }
172
173 #endif
MBSim::Joint::jacobianConstraints
void jacobianConstraints() override
computes JACOBIAN and mass action matrix of nonlinear contact equations
Definition: joint.cc:361
MBSim::GeneralizedForceLaw
basic force law on acceleration level for constraint description
Definition: generalized_force_law.h:34
MBSim::FloatingFrameLink
floating frame link
Definition: floating_frame_link.h:32
MBSim::Joint::calclaSize
void calclaSize(int j) override
calculates size of contact force parameters
Definition: joint.cc:103
MBSim::Joint::Joint
Joint(const std::string &name="")
constructor
Definition: joint.h:48
MBSim::Joint::setForceDirection
void setForceDirection(const fmatvec::Mat3xV &fd)
Definition: joint.h:102
MBSim::Joint::solveConstraintsFixpointSingle
void solveConstraintsFixpointSingle() override
Definition: joint.cc:241
MBSim::Joint::updaterFactors
void updaterFactors() override
update relaxation factors for contact equations
Definition: joint.cc:420
MBSim::Link::xSize
int xSize
size and local index of order one parameters
Definition: link.h:479
MBSim::Joint::~Joint
~Joint() override
destructor
Definition: joint.cc:40
MBSim::InverseKineticsJoint::init
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: joint.cc:563
MBSim::Joint::setMomentDirection
void setMomentDirection(const fmatvec::Mat3xV &md)
Definition: joint.h:107
MBSim::Joint::checkConstraintsForTermination
void checkConstraintsForTermination() override
verify underlying force laws concerning given tolerances
Definition: joint.cc:473
MBSim::Joint::checkImpactsForTermination
void checkImpactsForTermination() override
verify underlying force laws on velocity level concerning given tolerances
Definition: joint.cc:443
MBSim::Joint::ffl
GeneralizedForceLaw * ffl
Definition: joint.h:125
MBSim::Joint::isSingleValued
bool isSingleValued() const override
asks the link if it contains single valued force laws that contribute to the right-hand side vector h
Definition: joint.cc:213
MBSim::Joint::calcgSize
void calcgSize(int j) override
calculates size of relative distances
Definition: joint.cc:107
MBSim::Joint
class for connections: constraints on frames
Definition: joint.h:42
MBSim::Joint::fml
GeneralizedForceLaw * fml
Definition: joint.h:130
MBSim::Joint::solveImpactsRootFinding
void solveImpactsRootFinding() override
Definition: joint.cc:313
MBSim::JointConstraint
Joint contraint.
Definition: joint_constraint.h:37
MBSim::Joint::calcrFactorSize
void calcrFactorSize(int j) override
calculates size of rfactors
Definition: joint.cc:115
MBSim::FloatingFrameLink::forceDir
fmatvec::Mat3xV forceDir
directions of force and moment in frame of reference
Definition: floating_frame_link.h:80
MBSim::Element::InitStage
InitStage
The stages of the initialization.
Definition: element.h:62
MBSim::Joint::isActive
bool isActive() const override
Definition: joint.h:82
MBSim::Joint::gActiveChanged
bool gActiveChanged() override
Definition: joint.h:83
MBSim::Joint::fiml
GeneralizedImpactLaw * fiml
Definition: joint.h:140
MBSim::GeneralizedImpactLaw
basic force law on velocity level for constraint description
Definition: generalized_impact_law.h:32
MBSim::Joint::fifl
GeneralizedImpactLaw * fifl
Definition: joint.h:135
MBSim::Joint::init
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: joint.cc:123
MBSim::Element::name
std::string name
name of element
Definition: element.h:260
MBSim::InverseKineticsJoint::isSetValued
bool isSetValued() const override
asks the link if it contains force laws that contribute to the lagrange multiplier and is therefore s...
Definition: joint.h:165
MBSim::Joint::solveImpactsGaussSeidel
void solveImpactsGaussSeidel() override
Definition: joint.cc:265
MBSim::Joint::isSetValued
bool isSetValued() const override
asks the link if it contains force laws that contribute to the lagrange multiplier and is therefore s...
Definition: joint.cc:209
MBSim::Joint::gdn
fmatvec::Vec gdn
relative velocity and acceleration after an impact for event driven scheme summarizing all possible c...
Definition: joint.h:145
MBSim::Joint::solveConstraintsGaussSeidel
void solveConstraintsGaussSeidel() override
Definition: joint.cc:289
MBSim::Joint::solveConstraintsRootFinding
void solveConstraintsRootFinding() override
Definition: joint.cc:337
MBSim::Joint::solveImpactsFixpointSingle
void solveImpactsFixpointSingle() override
Definition: joint.cc:217
MBSim::Body
base class for all mechanical bodies with mass and generalised coordinates
Definition: body.h:49
MBSim::InverseKineticsJoint::calcbSize
void calcbSize() override
calculates size of rfactors
Definition: joint.cc:552
MBSim::InverseKineticsJoint
Definition: joint.h:157
MBSim
namespace MBSim
Definition: bilateral_constraint.cc:30
MBSim::Joint::calcgdSize
void calcgdSize(int j) override
calculates size of gap velocities
Definition: joint.cc:111
MBSim::Joint::jacobianImpacts
void jacobianImpacts() override
computes JACOBIAN and mass action matrix of nonlinear contact equations on velocity level
Definition: joint.cc:391