- 3.0.2 models module.
forward_dynamics.impl.h
Go to the documentation of this file.
1 
2 // Initialization of static-const data
3 template <typename TRAIT>
6 
7 template <typename TRAIT>
9  inertiaProps( & inertia ),
10  motionTransforms( & transforms )
11 {
12  Link1_v.setZero();
13  Link1_c.setZero();
14  Link2_v.setZero();
15  Link2_c.setZero();
16 
17  vcross.setZero();
18  Ia_r.setZero();
19 
20 }
21 
22 template <typename TRAIT>
24  JointState& qdd,
25  const JointState& qd,
26  const JointState& tau,
27  const ExtForces& fext/* = zeroExtForces */)
28 {
29 
30  Link1_AI = inertiaProps->getTensor_Link1();
31  Link1_p = - fext[LINK1];
32  Link2_AI = inertiaProps->getTensor_Link2();
33  Link2_p = - fext[LINK2];
34  // ---------------------- FIRST PASS ---------------------- //
35  // Note that, during the first pass, the articulated inertias are really
36  // just the spatial inertia of the links (see assignments above).
37  // Afterwards things change, and articulated inertias shall not be used
38  // in functions which work specifically with spatial inertias.
39 
40  // + Link Link1
41  // - The spatial velocity:
42  Link1_v(iit::rbd::AZ) = qd(JOINT1);
43 
44  // - The bias force term:
45  Link1_p += iit::rbd::vxIv(qd(JOINT1), Link1_AI);
46 
47  // + Link Link2
48  // - The spatial velocity:
49  Link2_v = (motionTransforms-> fr_Link2_X_fr_Link1) * Link1_v;
50  Link2_v(iit::rbd::AZ) += qd(JOINT2);
51 
52  // - The velocity-product acceleration term:
53  iit::rbd::motionCrossProductMx<Scalar>(Link2_v, vcross);
54  Link2_c = vcross.col(iit::rbd::AZ) * qd(JOINT2);
55 
56  // - The bias force term:
57  Link2_p += iit::rbd::vxIv(Link2_v, Link2_AI);
58 
59 
60  // ---------------------- SECOND PASS ---------------------- //
61  Matrix66S IaB;
62  Force pa;
63 
64  // + Link Link2
65  Link2_u = tau(JOINT2) - Link2_p(iit::rbd::AZ);
66  Link2_U = Link2_AI.col(iit::rbd::AZ);
67  Link2_D = Link2_U(iit::rbd::AZ);
68 
69  iit::rbd::compute_Ia_revolute(Link2_AI, Link2_U, Link2_D, Ia_r); // same as: Ia_r = Link2_AI - Link2_U/Link2_D * Link2_U.transpose();
70  pa = Link2_p + Ia_r * Link2_c + Link2_U * Link2_u/Link2_D;
71  ctransform_Ia_revolute(Ia_r, motionTransforms-> fr_Link2_X_fr_Link1, IaB);
72  Link1_AI += IaB;
73  Link1_p += (motionTransforms-> fr_Link2_X_fr_Link1).transpose() * pa;
74 
75  // + Link Link1
76  Link1_u = tau(JOINT1) - Link1_p(iit::rbd::AZ);
77  Link1_U = Link1_AI.col(iit::rbd::AZ);
78  Link1_D = Link1_U(iit::rbd::AZ);
79 
80 
81 
82  // ---------------------- THIRD PASS ---------------------- //
83  Link1_a = (motionTransforms-> fr_Link1_X_fr_DoubleInvertedPendulumBase).col(iit::rbd::LZ) * Scalar(iit::rbd::g);
84  qdd(JOINT1) = (Link1_u - Link1_U.dot(Link1_a)) / Link1_D;
85  Link1_a(iit::rbd::AZ) += qdd(JOINT1);
86 
87  Link2_a = (motionTransforms-> fr_Link2_X_fr_Link1) * Link1_a + Link2_c;
88  qdd(JOINT2) = (Link2_u - Link2_U.dot(Link2_a)) / Link2_D;
89  Link2_a(iit::rbd::AZ) += qdd(JOINT2);
90 
91 
92 }
Definition: link_data_map.h:12
ForwardDynamics(InertiaProperties< TRAIT > &in, MTransforms &tr)
Definition: forward_dynamics.impl.h:8
Definition: declarations.h:27
void compute_Ia_revolute(const MatrixBase< D1 > &IA, const Vec6< typename D1::Scalar > &U, const typename D1::Scalar &D, const MatrixBase< D2 > &Ia_const)
CoreS::ForceVector Force
Definition: forward_dynamics.h:41
Definition: declarations.h:26
void fd(JointState &qdd, const JointState &q, const JointState &qd, const JointState &tau, const ExtForces &fext=zeroExtForces)
Definition: forward_dynamics.h:120
Force< DScalar > vxIv(const Velocity< DScalar > &v, const MatrixBase< Derived > &I)
iit::ct_DoubleInvertedPendulum::tpl::MotionTransforms< TRAIT > MTransforms
Definition: forward_dynamics.h:48
iit::ct_DoubleInvertedPendulum::tpl::JointState< Scalar > JointState
Definition: forward_dynamics.h:47
Definition: declarations.h:32
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef TRAIT::Scalar Scalar
Definition: forward_dynamics.h:37
CoreS::Matrix66 Matrix66S
Definition: forward_dynamics.h:45
void ctransform_Ia_revolute(const MatrixBase< D1 > &Ia_A, const MatrixBase< D2 > &XM, const MatrixBase< D3 > &Ia_B_const)
Definition: declarations.h:33