19#ifndef _JOINT_CONSTRAINT_H
20#define _JOINT_CONSTRAINT_H
22#include "mechanical_constraint.h"
23#include "mbsim/functions/function.h"
24#include "mbsim/frames/floating_relative_frame.h"
25#include "mbsim/utils/nonlinear_algebra.h"
39 enum FrameOfReference {
47 void calcisSize()
override;
49 void init(
InitStage stage,
const InitConfigSet &config)
override;
51 void resetUpToDate()
override;
53 void connect(
Frame* frame0,
Frame* frame1) { frame[0] = frame0; frame[1] = frame1; }
54 void addDependentRigidBodyOnFirstSide(
RigidBody* bd) { bd1.push_back(bd); }
55 void addDependentRigidBodyOnSecondSide(
RigidBody* bd) { bd2.push_back(bd); }
56 void setIndependentRigidBody(
RigidBody* bi_) { bi.resize(1); bi[0] = bi_; }
57 void addIndependentRigidBody(
RigidBody* bi_) { bi.push_back(bi_); }
59 void setUpInverseKinetics()
override;
60 void setForceDirection(
const fmatvec::Mat3xV& fd) { forceDir <<= fd; }
61 void setMomentDirection(
const fmatvec::Mat3xV& md) { momentDir <<= md; }
68 void updatePositions(
Frame *frame)
override;
69 void updateGeneralizedCoordinates()
override;
70 void updateGeneralizedJacobians(
int jj=0)
override;
71 void updateForceDirections();
74 const fmatvec::Mat3xV& evalGlobalForceDirection() {
if(updDF) updateForceDirections();
return DF; }
75 const fmatvec::Mat3xV& evalGlobalMomentDirection() {
if(updDF) updateForceDirections();
return DM; }
76 const fmatvec::SqrMat& evalA() {
if(updA) updateA();
return A; }
78 fmatvec::Mat3xV& getGlobalForceDirection(
bool check=
true) { assert((not check) or (not updDF));
return DF; }
79 fmatvec::Mat3xV& getGlobalMomentDirection(
bool check=
true) { assert((not check) or (not updDF));
return DM; }
80 fmatvec::SqrMat& getA(
bool check=
true) { assert((not check) or (not updA));
return A; }
82 void setInitialGuess(
const fmatvec::VecV &q0_) { q0 <<= q0_; }
84 void initializeUsingXML(xercesc::DOMElement *element)
override;
89 std::vector<RigidBody*> body1, body2;
90 fmatvec::Mat3xV forceDir, momentDir;
91 std::vector<Frame*> frame;
92 FrameOfReference refFrame;
94 Residuum(std::vector<RigidBody*> body1_, std::vector<RigidBody*> body2_,
const fmatvec::Mat3xV &forceDir_,
const fmatvec::Mat3xV &momentDir_,
const std::vector<Frame*> frame_, FrameOfReference refFrame_);
96 fmatvec::Vec operator()(
const fmatvec::Vec &
x)
override;
98 std::unique_ptr<Residuum> residuum;
99 std::unique_ptr<MultiDimNewtonMethod> newton;
101 std::vector<RigidBody*> bd1, bd2, bi;
103 std::vector<Frame*> frame;
112 fmatvec::Mat3xV DF, DM, forceDir, momentDir;
114 fmatvec::RangeV iF, iM;
115 std::vector<fmatvec::RangeV> Iq1, Iq2, Iu1, Iu2, Ih1, Ih2;
126 std::string saved_ref1, saved_ref2;
127 std::vector<std::string> saved_RigidBodyFirstSide, saved_RigidBodySecondSide, saved_IndependentBody;
fmatvec::Vec x
order one parameters
Definition: constraint.h:78
InitStage
The stages of the initialization.
Definition: element.h:62
std::string name
name of element
Definition: element.h:260
cartesian frame on rigid bodies
Definition: floating_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
Definition: joint_constraint.h:87
Joint contraint.
Definition: joint_constraint.h:37
void setFrameOfReference(FrameOfReference refFrame_)
The frame of reference for the force/moment direction vectors. If firstFrame (default) the first fram...
Definition: joint_constraint.h:66
FrameOfReference refFrame
frame of reference the force is defined in
Definition: joint_constraint.h:108
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: joint_constraint.cc:83
Class for mechanical constraints.
Definition: mechanical_constraint.h:32
rigid bodies with arbitrary kinematics
Definition: rigid_body.h:50
namespace MBSim
Definition: bilateral_constraint.cc:30