- 3.0.2 models module.
inverse_dynamics.impl.h
Go to the documentation of this file.
1 // Initialization of static-const data
2 template <typename TRAIT>
5 
6 template <typename TRAIT>
8  inertiaProps( & inertia ),
9  xm( & transforms ),
10  Link1_I(inertiaProps->getTensor_Link1() ),
11  Link2_I(inertiaProps->getTensor_Link2() )
12  {
13 #ifndef EIGEN_NO_DEBUG
14  std::cout << "Robot ct_DoubleInvertedPendulum, InverseDynamics<TRAIT>::InverseDynamics()" << std::endl;
15  std::cout << "Compiled with Eigen debug active" << std::endl;
16 #endif
17  Link1_v.setZero();
18  Link2_v.setZero();
19 
20  vcross.setZero();
21 }
22 
23 template <typename TRAIT>
25  JointState& jForces,
26  const JointState& qd, const JointState& qdd,
27  const ExtForces& fext)
28 {
29  firstPass(qd, qdd, fext);
30  secondPass(jForces);
31 }
32 
33 template <typename TRAIT>
35 {
36  // Link 'Link1'
37  Link1_a = (xm->fr_Link1_X_fr_DoubleInvertedPendulumBase).col(iit::rbd::LZ) * Scalar(iit::rbd::g);
38  Link1_f = Link1_I * Link1_a;
39  // Link 'Link2'
40  Link2_a = (xm->fr_Link2_X_fr_Link1) * Link1_a;
41  Link2_f = Link2_I * Link2_a;
42 
43  secondPass(jForces);
44 }
45 
46 template <typename TRAIT>
48 {
49  // Link 'Link1'
50  Link1_v(iit::rbd::AZ) = qd(JOINT1); // Link1_v = vJ, for the first link of a fixed base robot
51 
52  Link1_f = iit::rbd::vxIv(qd(JOINT1), Link1_I);
53 
54  // Link 'Link2'
55  Link2_v = ((xm->fr_Link2_X_fr_Link1) * Link1_v);
56  Link2_v(iit::rbd::AZ) += qd(JOINT2);
57 
58  iit::rbd::motionCrossProductMx<Scalar>(Link2_v, vcross);
59 
60  Link2_a = (vcross.col(iit::rbd::AZ) * qd(JOINT2));
61 
62  Link2_f = Link2_I * Link2_a + iit::rbd::vxIv(Link2_v, Link2_I);
63 
64 
65  secondPass(jForces);
66 }
67 
68 template <typename TRAIT>
70 {
71  // First pass, link 'Link1'
72  Link1_a = (xm->fr_Link1_X_fr_DoubleInvertedPendulumBase).col(iit::rbd::LZ) * Scalar(iit::rbd::g);
73  Link1_a(iit::rbd::AZ) += qdd(JOINT1);
74  Link1_v(iit::rbd::AZ) = qd(JOINT1); // Link1_v = vJ, for the first link of a fixed base robot
75 
76  Link1_f = Link1_I * Link1_a + iit::rbd::vxIv(qd(JOINT1), Link1_I) - fext[LINK1];
77 
78  // First pass, link 'Link2'
79  Link2_v = ((xm->fr_Link2_X_fr_Link1) * Link1_v);
80  Link2_v(iit::rbd::AZ) += qd(JOINT2);
81 
82  iit::rbd::motionCrossProductMx<Scalar>(Link2_v, vcross);
83 
84  Link2_a = (xm->fr_Link2_X_fr_Link1) * Link1_a + vcross.col(iit::rbd::AZ) * qd(JOINT2);
85  Link2_a(iit::rbd::AZ) += qdd(JOINT2);
86 
87  Link2_f = Link2_I * Link2_a + iit::rbd::vxIv(Link2_v, Link2_I) - fext[LINK2];
88 
89 }
90 
91 template <typename TRAIT>
93 {
94  // Link 'Link2'
95  jForces(JOINT2) = Link2_f(iit::rbd::AZ);
96  Link1_f += xm->fr_Link2_X_fr_Link1.transpose() * Link2_f;
97  // Link 'Link1'
98  jForces(JOINT1) = Link1_f(iit::rbd::AZ);
99 }
Definition: link_data_map.h:12
void secondPass(JointState &jForces)
Definition: inverse_dynamics.impl.h:92
void id(JointState &jForces, const JointState &q, const JointState &qd, const JointState &qdd, const ExtForces &fext=zeroExtForces)
Definition: inverse_dynamics.h:182
iit::ct_DoubleInvertedPendulum::tpl::JointState< Scalar > JointState
Definition: inverse_dynamics.h:54
Definition: declarations.h:27
void firstPass(const JointState &qd, const JointState &qdd, const ExtForces &fext)
Definition: inverse_dynamics.impl.h:69
Definition: declarations.h:26
void G_terms(JointState &jForces, const JointState &q)
Definition: inverse_dynamics.h:168
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef TRAIT::Scalar Scalar
Definition: inverse_dynamics.h:45
Force< DScalar > vxIv(const Velocity< DScalar > &v, const MatrixBase< Derived > &I)
Definition: declarations.h:32
InverseDynamics(IProperties &in, MTransforms &tr)
Definition: inverse_dynamics.impl.h:7
void C_terms(JointState &jForces, const JointState &q, const JointState &qd)
Definition: inverse_dynamics.h:175
iit::ct_DoubleInvertedPendulum::tpl::MotionTransforms< TRAIT > MTransforms
Definition: inverse_dynamics.h:56
Definition: declarations.h:33