Choreonoid  1.8
ForwardDynamicsCBM.h
Go to the documentation of this file.
1 
6 #ifndef CNOID_BODY_FORWARD_DYNAMICS_CBM_H
7 #define CNOID_BODY_FORWARD_DYNAMICS_CBM_H
8 
9 #include "ForwardDynamics.h"
10 #include "exportdecl.h"
11 
12 namespace cnoid
13 {
14 class DyLink;
15 class ForceSensorDevice;
16 
24 class CNOID_EXPORT ForwardDynamicsCBM : public ForwardDynamics
25 {
26 public:
28 
29  ForwardDynamicsCBM(DySubBody* subBody);
31 
32  virtual void initialize();
33  virtual void calcNextState();
34  virtual void refreshState();
35 
36  void complementHighGainModeCommandValues();
37 
38  void initializeAccelSolver();
39  void sumExternalForces();
40  void solveUnknownAccels();
41  void solveUnknownAccels(const Vector3& fext, const Vector3& tauext);
42  bool solveUnknownAccels(DyLink* link, const Vector3& fext, const Vector3& tauext, const Vector3& rootfext, const Vector3& roottauext);
43 
44 private:
45 
46  /*
47  Elements of the motion equation
48 
49  | | | | dv | | b1 | | 0 | | totalfext |
50  | M11 | M12 | | dw | | | | 0 | | totaltauext |
51  | | | * |ddq (unkown)| + | | + | d1 | = | u (known) |
52  |-----+-----| |------------| |----| |----| |----------------|
53  | M21 | M22 | | given ddq | | b2 | | d2 | | u2 |
54 
55  |fext |
56  d1 = trans(s)| |
57  |tauext|
58 
59  */
60 
61  MatrixXd M11;
62  MatrixXd M12;
63  MatrixXd b1;
64  VectorXd d1;
65  VectorXd c1;
66 
67  std::vector<DyLink*> torqueModeJoints;
68  std::vector<DyLink*> highGainModeJoints;
69 
70  //int rootDof; // dof of dv and dw (0 or 6)
71  int unknown_rootDof;
72  int given_rootDof;
73 
74  bool isNoUnknownAccelMode;
75 
76  VectorXd qGiven;
77  VectorXd dqGiven;
78  VectorXd ddqGiven;
79  Vector3 pGiven;
80  Matrix3 RGiven;
81  Vector3 voGiven;
82  Vector3 wGiven;
83 
84  bool accelSolverInitialized;
85  bool ddqGivenCopied;
86 
87  VectorXd qGivenPrev;
88  VectorXd dqGivenPrev;
89  Vector3 pGivenPrev;
90  Matrix3 RGivenPrev;
91  Vector3 voGivenPrev;
92  Vector3 wGivenPrev;
93 
94  Vector3 fextTotal;
95  Vector3 tauextTotal;
96 
97  Vector3 root_w_x_v;
98 
99  // buffers for the unit vector method
100  VectorXd ddqorg;
101  VectorXd uorg;
102  Vector3 dvoorg;
103  Vector3 dworg;
104 
105  // Buffers for the Runge Kutta Method
106  Isometry3 T0;
107  Vector3 vo0;
108  Vector3 w0;
109  std::vector<double> q0;
110  std::vector<double> dq0;
111 
112  Vector3 vo;
113  Vector3 w;
114  Vector3 dvo;
115  Vector3 dw;
116  std::vector<double> dq;
117  std::vector<double> ddq;
118 
119  virtual void initializeSensors();
120 
121  void calcMotionWithEulerMethod();
122  void calcMotionWithRungeKuttaMethod();
123  void integrateRungeKuttaOneStep(double r, double dt);
124  void preserveHighGainModeJointState();
125  void calcPositionAndVelocityFK();
126  void calcMassMatrix();
127  void setColumnOfMassMatrix(MatrixXd& M, int column);
128  void calcInverseDynamics(DyLink* link, Vector3& out_f, Vector3& out_tau, bool isSubBodyRoot);
129  void calcd1(DyLink* link, Vector3& out_f, Vector3& out_tau, bool isSubBodyRoot);
130  inline void calcAccelFKandForceSensorValues();
131  void calcAccelFKandForceSensorValues(DyLink* link, Vector3& out_f, Vector3& out_tau, bool isSubBodyRoot);
132  void updateForceSensors();
133 };
134 
135 }
136 
137 #endif
cnoid::Vector3
Eigen::Vector3d Vector3
Definition: EigenTypes.h:57
cnoid::ForwardDynamicsCBM::EIGEN_MAKE_ALIGNED_OPERATOR_NEW
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
Definition: ForwardDynamicsCBM.h:27
cnoid::Isometry3
Eigen::Isometry3d Isometry3
Definition: EigenTypes.h:73
cnoid::Matrix3
Eigen::Matrix3d Matrix3
Definition: EigenTypes.h:56
cnoid::DySubBody
Definition: DyBody.h:23
cnoid::ForwardDynamicsCBM
Definition: ForwardDynamicsCBM.h:24
cnoid::calcInverseDynamics
Vector6 calcInverseDynamics(Link *link)
Definition: InverseDynamics.cpp:75
cnoid
Definition: AbstractSceneLoader.h:11
ForwardDynamics.h
cnoid::ForwardDynamics
Definition: ForwardDynamics.h:22
cnoid::calcMassMatrix
void calcMassMatrix(Body *body, const Vector3 &g, Eigen::MatrixXd &out_M, VectorXd &out_b)
Definition: MassMatrix.cpp:43