- 3.0.2 models module.
jsim.impl.h
Go to the documentation of this file.
1 
2  //Implementation of default constructor
3  template<typename TRAIT>
5  linkInertias(inertiaProperties),
6  frcTransf( &forceTransforms ),
7  link2_Ic(linkInertias.getTensor_link2())
8  {
9  //Initialize the matrix itself
10  this->setZero();
11  }
12 
13  #define DATA tpl::JSIM<TRAIT>::operator()
14  #define Fcol(j) (tpl::JSIM<TRAIT>:: template block<6,1>(0,(j)+6))
15  #define F(i,j) DATA((i),(j)+6)
16 
17  template <typename TRAIT>
19 
20  // Precomputes only once the coordinate transforms:
21  frcTransf -> fr_link1_X_fr_link2(state);
22  frcTransf -> fr_body_X_fr_link1(state);
23 
24  // Initializes the composite inertia tensors
25  body_Ic = linkInertias.getTensor_body();
26  link1_Ic = linkInertias.getTensor_link1();
27 
28  // "Bottom-up" loop to update the inertia-composite property of each link, for the current configuration
29 
30  // Link link2:
31  iit::rbd::transformInertia(link2_Ic, frcTransf -> fr_link1_X_fr_link2, Ic_spare);
32  link1_Ic += Ic_spare;
33 
34  Fcol(JB) = link2_Ic.col(iit::rbd::AZ);
35  DATA(JB+6, JB+6) = Fcol(JB)(iit::rbd::AZ);
36 
37  Fcol(JB) = frcTransf -> fr_link1_X_fr_link2 * Fcol(JB);
38  DATA(JB+6, JA+6) = F(iit::rbd::AZ,JB);
39  DATA(JA+6, JB+6) = DATA(JB+6, JA+6);
40  Fcol(JB) = frcTransf -> fr_body_X_fr_link1 * Fcol(JB);
41 
42  // Link link1:
43  iit::rbd::transformInertia(link1_Ic, frcTransf -> fr_body_X_fr_link1, Ic_spare);
44  body_Ic += Ic_spare;
45 
46  Fcol(JA) = link1_Ic.col(iit::rbd::AZ);
47  DATA(JA+6, JA+6) = Fcol(JA)(iit::rbd::AZ);
48 
49  Fcol(JA) = frcTransf -> fr_body_X_fr_link1 * Fcol(JA);
50 
51  // Copies the upper-right block into the lower-left block, after transposing
52  JSIM<TRAIT>:: template block<2, 6>(6,0) = (JSIM<TRAIT>:: template block<6, 2>(0,6)).transpose();
53  // The composite-inertia of the whole robot is the upper-left quadrant of the JSIM
54  JSIM<TRAIT>:: template block<6,6>(0,0) = body_Ic;
55  return *this;
56  }
57 
58  #undef DATA
59  #undef F
60 
61  template <typename TRAIT>
63  L = this -> template triangularView<Eigen::Lower>();
64  // Joint jB, index 1 :
65  L(1, 1) = std::sqrt(L(1, 1));
66  L(1, 0) = L(1, 0) / L(1, 1);
67  L(0, 0) = L(0, 0) - L(1, 0) * L(1, 0);
68 
69  // Joint jA, index 0 :
70  L(0, 0) = std::sqrt(L(0, 0));
71 
72  }
73 
74  template <typename TRAIT>
77 
78  inverse(0, 0) = + (Linv(0, 0) * Linv(0, 0));
79  inverse(1, 1) = + (Linv(1, 0) * Linv(1, 0)) + (Linv(1, 1) * Linv(1, 1));
80  inverse(1, 0) = + (Linv(1, 0) * Linv(0, 0));
81  inverse(0, 1) = inverse(1, 0);
82  }
83 
84  template <typename TRAIT>
86  //assumes L has been computed already
87  Linv(0, 0) = 1 / L(0, 0);
88  Linv(1, 1) = 1 / L(1, 1);
89  Linv(1, 0) = - Linv(0, 0) * ((Linv(1, 1) * L(1, 0)) + 0);
90  }
91 
92 
void computeL()
Definition: jsim.impl.h:62
Column2d JointState
Definition: declarations.h:23
JSIM(IProperties &, FTransforms &)
Definition: jsim.impl.h:4
Definition: declarations.h:27
#define Fcol(j)
Definition: jsim.impl.h:14
iit::ct_quadrotor::tpl::ForceTransforms< TRAIT > FTransforms
Definition: jsim.h:39
Definition: inertia_properties.h:25
void transformInertia(const InertiaMat< Scalar > &I_A, const Mat66< Scalar > &XF, InertiaMat< Scalar > &I_B)
const IMatrix & getTensor_body() const
Definition: inertia_properties.h:61
void computeLInverse()
Definition: jsim.impl.h:85
void computeInverse()
Definition: jsim.impl.h:75
const IMatrix & getTensor_link1() const
Definition: inertia_properties.h:65
#define DATA
Definition: jsim.impl.h:13
const JSIM & update(const iit::ct_quadrotor::JointState &)
Definition: jsim.impl.h:18
#define F(i, j)
Definition: jsim.impl.h:15
Definition: declarations.h:26