All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
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/link_mechanics.h"
24 #include "mbsim/frame.h"
25 
26 #ifdef HAVE_OPENMBVCPPINTERFACE
27 #include "mbsim/utils/boost_parameters.h"
28 #include "mbsim/utils/openmbv_utils.h"
29 #endif
30 
31 namespace MBSim {
32 
33  class GeneralizedForceLaw;
34  class GeneralizedImpactLaw;
35  class FrictionForceLaw;
36  class FrictionImpactLaw;
37  class Body;
38 
48  class Joint : public LinkMechanics {
49  public:
54  Joint(const std::string &name = "");
55 
59  virtual ~Joint();
60 
61  /* INHERITED INTERFACE OF LINKINTERFACE */
62  virtual void updatewb(double t, int i = 0);
63  virtual void updateW(double t, int i = 0);
64  virtual void updateh(double t, int i = 0);
65  virtual void updateg(double t);
66  virtual void updategd(double t);
67  virtual void updateJacobians(double t, int j = 0);
68  /***************************************************/
69 
70  /* INHERITED INTERFACE OF EXTRADYNAMICINTERFACE */
71  virtual void updatexd(double t);
72  virtual void updatedx(double t, double dt);
73  virtual void calcxSize();
74  virtual void init(InitStage stage);
75  /***************************************************/
76 
77  /* INHERITED INTERFACE OF LINK */
78  virtual void calclaSize(int j);
79  virtual void calcgSize(int j);
80  virtual void calcgdSize(int j);
81  virtual void calcrFactorSize(int j);
82  virtual void calccorrSize(int j);
83  virtual bool isSetValued() const;
84  virtual bool isSingleValued() const;
85  virtual bool isActive() const {
86  return true;
87  }
88  virtual bool gActiveChanged() {
89  return false;
90  }
91  virtual void solveImpactsFixpointSingle(double dt);
92  virtual void solveConstraintsFixpointSingle();
93  virtual void solveImpactsGaussSeidel(double dt);
94  virtual void solveConstraintsGaussSeidel();
95  virtual void solveImpactsRootFinding(double dt);
96  virtual void solveConstraintsRootFinding();
97  virtual void jacobianConstraints();
98  virtual void jacobianImpacts();
99  virtual void updaterFactors();
100  virtual void checkImpactsForTermination(double dt);
101  virtual void checkConstraintsForTermination();
102  /***************************************************/
103 
104  /* INHERITED INTERFACE OF ELEMENT */
105  virtual void plot(double t, double dt = 1);
106  /***************************************************/
107 
108  /* INTERFACE FOR DERIVED CLASSES */
113  virtual void connect(Frame *frame1, Frame* frame2);
114  /***************************************************/
115 
116  /* GETTER / SETTER */
117  void setForceLaw(GeneralizedForceLaw * rc);
118  void setMomentLaw(GeneralizedForceLaw * rc);
119  /***************************************************/
120 
124  void setForceDirection(const fmatvec::Mat3xV& fd);
125 
129  void setMomentDirection(const fmatvec::Mat3xV& md);
130 
134  void setFrameOfReferenceID(int ID) {
135  refFrameID = ID;
136  }
137 
138  virtual void initializeUsingXML(xercesc::DOMElement *element);
139  virtual xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *element);
140 
141  virtual std::string getType() const {
142  return "Joint";
143  }
144 
145 #ifdef HAVE_OPENMBVCPPINTERFACE
146 
147  BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVForce, tag, (optional (scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(OpenMBV::Arrow::ReferencePoint),OpenMBV::Arrow::toPoint)(diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0))) {
148  OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toHead,referencePoint,scaleLength,scaleSize);
149  setOpenMBVForce(ombv.createOpenMBV());
150  }
151  void setOpenMBVForce(const boost::shared_ptr<OpenMBV::Arrow> &arrow) {
152  std::vector<bool> which; which.resize(2, false);
153  which[1]=true;
154  LinkMechanics::setOpenMBVForceArrow(arrow, which);
155  }
156 
158  BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVMoment, tag, (optional (scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(OpenMBV::Arrow::ReferencePoint),OpenMBV::Arrow::toPoint)(diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0))) {
159  OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toDoubleHead,referencePoint,scaleLength,scaleSize);
160  setOpenMBVMoment(ombv.createOpenMBV());
161  }
162  void setOpenMBVMoment(const boost::shared_ptr<OpenMBV::Arrow> &arrow) {
163  std::vector<bool> which; which.resize(2, false);
164  which[1]=true;
165  LinkMechanics::setOpenMBVMomentArrow(arrow, which);
166  }
167 #endif
168 
169  protected:
174  int refFrameID;
175 
180 
184  fmatvec::Mat3xV forceDir, momentDir;
185 
189  fmatvec::Mat3xV Wf, Wm;
190 
194  fmatvec::Mat3xV JT;
195 
199  fmatvec::Vec3 WrP0P1, WvP0P1, WomP0P1;
200 
205 
210 
215 
220 
225 
230 
231  private:
232  std::string saved_ref1, saved_ref2;
233  };
234 
235  class InverseKineticsJoint : public Joint {
236  public:
237  InverseKineticsJoint(const std::string &name);
238  virtual void updateb(double t);
239  void calcbSize();
240  void setBody(Body* body_) {
241  body = body_;
242  }
243  virtual void init(InitStage stage);
244  virtual bool isSetValued() const {
245  return true;
246  }
247 
248  protected:
249  Body* body;
250  };
251 
252 }
253 
254 #endif
255 
virtual void solveConstraintsFixpointSingle()
Definition: joint.cc:306
basic force law on acceleration level for constraint description
Definition: constitutive_laws.h:41
Joint(const std::string &name="")
constructor
Definition: joint.cc:39
virtual void updaterFactors()
update relaxation factors for contact equations
Definition: joint.cc:483
void setForceDirection(const fmatvec::Mat3xV &fd)
Definition: joint.cc:576
virtual void checkImpactsForTermination(double dt)
verify underlying force laws on velocity level concerning given tolerances
Definition: joint.cc:506
virtual ~Joint()
destructor
Definition: joint.cc:43
virtual void solveConstraintsGaussSeidel()
Definition: joint.cc:354
fmatvec::Mat3xV Wf
global force and moment direction
Definition: joint.h:189
virtual void jacobianConstraints()
computes JACOBIAN and mass action matrix of nonlinear contact equations
Definition: joint.cc:426
virtual void init(InitStage stage)
plots time series header
Definition: joint.cc:153
fmatvec::Mat3xV JT
translational JACOBIAN (not empty for e.g. prismatic joints)
Definition: joint.h:194
fmatvec::Vec3 WrP0P1
difference vector of position, velocity and angular velocity
Definition: joint.h:199
void setMomentDirection(const fmatvec::Mat3xV &md)
Definition: joint.cc:584
virtual bool gActiveChanged()
Definition: joint.h:88
fmatvec::Index IT
indices of forces and torques
Definition: joint.h:179
GeneralizedForceLaw * ffl
Definition: joint.h:204
virtual void init(InitStage stage)
plots time series header
Definition: joint.cc:692
class for connections: constraints on frames
Definition: joint.h:48
virtual void solveImpactsGaussSeidel(double dt)
Definition: joint.cc:330
GeneralizedForceLaw * fml
Definition: joint.h:209
fmatvec::Mat3xV forceDir
local force and moment direction
Definition: joint.h:184
virtual void connect(Frame *frame1, Frame *frame2)
second frame to connect
Definition: joint.cc:62
virtual void jacobianImpacts()
computes JACOBIAN and mass action matrix of nonlinear contact equations on velocity level ...
Definition: joint.cc:455
virtual void plot(double t, double dt=1)
plots time dependent data
Definition: joint.cc:592
void setFrameOfReferenceID(int ID)
The frame of reference ID for the force/moment direction vectors. If ID=0 (default) the first frame...
Definition: joint.h:134
InitStage
The stages of the initialization.
Definition: element.h:97
void calcbSize()
calculates size of rfactors
Definition: joint.cc:681
virtual bool isSetValued() const
asks the link if it contains force laws that contribute to the lagrange multiplier and is therefore s...
Definition: joint.h:244
Frame C
own frame located in second partner with same orientation as first partner
Definition: joint.h:229
virtual std::string getType() const
Definition: joint.h:141
virtual void solveImpactsRootFinding(double dt)
Definition: joint.cc:378
GeneralizedImpactLaw * fiml
Definition: joint.h:219
virtual bool isSetValued() const
asks the link if it contains force laws that contribute to the lagrange multiplier and is therefore s...
Definition: joint.cc:260
basic force law on velocity level for constraint description
Definition: constitutive_laws.h:213
GeneralizedImpactLaw * fifl
Definition: joint.h:214
virtual void solveImpactsFixpointSingle(double dt)
Definition: joint.cc:282
std::string name
name of element
Definition: element.h:290
Frame * refFrame
frame of reference the force is defined in
Definition: joint.h:173
cartesian frame on bodies used for application of e.g. links and loads
Definition: frame.h:39
general link to one or more objects
Definition: link_mechanics.h:48
virtual void calcgdSize(int j)
calculates size of gap velocities
Definition: joint.cc:245
virtual void calclaSize(int j)
calculates size of contact force parameters
Definition: joint.cc:235
virtual void solveConstraintsRootFinding()
Definition: joint.cc:402
virtual bool isActive() const
Definition: joint.h:85
virtual void calcrFactorSize(int j)
calculates size of rfactors
Definition: joint.cc:250
virtual void calcgSize(int j)
calculates size of relative distances
Definition: joint.cc:240
virtual bool isSingleValued() const
asks the link if it contains single valued force laws that contribute to the right-hand side vector h...
Definition: joint.cc:270
fmatvec::Vec gdn
relative velocity and acceleration after an impact for event driven scheme summarizing all possible c...
Definition: joint.h:224
virtual void checkConstraintsForTermination()
verify underlying force laws concerning given tolerances
Definition: joint.cc:536
base class for all mechanical bodies with mass and generalised coordinates
Definition: body.h:52
Definition: joint.h:235

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML