Cheetah Software  1.0
FloatingBaseModel< T > Class Template Reference

#include <FloatingBaseModel.h>

+ Inheritance diagram for FloatingBaseModel< T >:
+ Collaboration diagram for FloatingBaseModel< T >:

Public Member Functions

 FloatingBaseModel ()
 
 ~FloatingBaseModel ()
 
void addBase (const SpatialInertia< T > &inertia)
 
void addBase (T mass, const Vec3< T > &com, const Mat3< T > &I)
 
int addGroundContactPoint (int bodyID, const Vec3< T > &location, bool isFoot=false)
 
void addGroundContactBoxPoints (int bodyId, const Vec3< T > &dims)
 
int addBody (const SpatialInertia< T > &inertia, const SpatialInertia< T > &rotorInertia, T gearRatio, int parent, JointType jointType, CoordinateAxis jointAxis, const Mat6< T > &Xtree, const Mat6< T > &Xrot)
 
int addBody (const MassProperties< T > &inertia, const MassProperties< T > &rotorInertia, T gearRatio, int parent, JointType jointType, CoordinateAxis jointAxis, const Mat6< T > &Xtree, const Mat6< T > &Xrot)
 
void check ()
 
totalRotorMass ()
 
totalNonRotorMass ()
 
const std::vector< int > & getParentVector ()
 
const std::vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > & getBodyInertiaVector ()
 
const std::vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > & getRotorInertiaVector ()
 
void setGravity (Vec3< T > &g)
 
void setContactComputeFlag (size_t gc_index, bool flag)
 
DMat< T > invContactInertia (const int gc_index, const D6Mat< T > &force_directions)
 
invContactInertia (const int gc_index, const Vec3< T > &force_ics_at_contact)
 
applyTestForce (const int gc_index, const Vec3< T > &force_ics_at_contact, FBModelStateDerivative< T > &dstate_out)
 
applyTestForce (const int gc_index, const Vec3< T > &force_ics_at_contact, DVec< T > &dstate_out)
 
void addDynamicsVars (int count)
 
void resizeSystemMatricies ()
 
void setState (const FBModelState< T > &state)
 
void resetCalculationFlags ()
 
void setDState (const FBModelStateDerivative< T > &dState)
 
Vec3< T > getPosition (const int link_idx, const Vec3< T > &local_pos)
 
Vec3< T > getPosition (const int link_idx)
 
Mat3< T > getOrientation (const int link_idx)
 
Vec3< T > getLinearVelocity (const int link_idx, const Vec3< T > &point)
 
Vec3< T > getLinearVelocity (const int link_idx)
 
Vec3< T > getLinearAcceleration (const int link_idx, const Vec3< T > &point)
 
Vec3< T > getLinearAcceleration (const int link_idx)
 
Vec3< T > getAngularVelocity (const int link_idx)
 
Vec3< T > getAngularAcceleration (const int link_idx)
 
void forwardKinematics ()
 
void biasAccelerations ()
 
void compositeInertias ()
 
void forwardAccelerationKinematics ()
 
void contactJacobians ()
 
DVec< T > generalizedGravityForce ()
 
DVec< T > generalizedCoriolisForce ()
 
DMat< T > massMatrix ()
 
DVec< T > inverseDynamics (const FBModelStateDerivative< T > &dState)
 
void runABA (const DVec< T > &tau, FBModelStateDerivative< T > &dstate)
 
const DMat< T > & getMassMatrix () const
 
const DVec< T > & getGravityForce () const
 
const DVec< T > & getCoriolisForce () const
 
void updateArticulatedBodies ()
 
void updateForcePropagators ()
 
void udpateQddEffects ()
 
void resetExternalForces ()
 

Public Attributes

size_t _nDof = 0
 
Vec3< T > _gravity
 
vector< int > _parents
 
vector< T > _gearRatios
 
vector< T > _d
 
vector< T > _u
 
vector< JointType_jointTypes
 
vector< CoordinateAxis_jointAxes
 
vector< Mat6< T >, Eigen::aligned_allocator< Mat6< T > > > _Xtree
 
vector< Mat6< T >, Eigen::aligned_allocator< Mat6< T > > > _Xrot
 
vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > _Ibody
 
vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > _Irot
 
vector< std::string > _bodyNames
 
size_t _nGroundContact = 0
 
vector< size_t > _gcParent
 
vector< Vec3< T > > _gcLocation
 
vector< uint64_t > _footIndicesGC
 
vector< Vec3< T > > _pGC
 
vector< Vec3< T > > _vGC
 
vector< bool > _compute_contact_info
 
FBModelState< T > _state
 BEGIN ALGORITHM SUPPORT VARIABLES. More...
 
FBModelStateDerivative< T > _dState
 
vectorAligned< SVec< T > > _v
 
vectorAligned< SVec< T > > _vrot
 
vectorAligned< SVec< T > > _a
 
vectorAligned< SVec< T > > _arot
 
vectorAligned< SVec< T > > _avp
 
vectorAligned< SVec< T > > _avprot
 
vectorAligned< SVec< T > > _c
 
vectorAligned< SVec< T > > _crot
 
vectorAligned< SVec< T > > _S
 
vectorAligned< SVec< T > > _Srot
 
vectorAligned< SVec< T > > _fvp
 
vectorAligned< SVec< T > > _fvprot
 
vectorAligned< SVec< T > > _ag
 
vectorAligned< SVec< T > > _agrot
 
vectorAligned< SVec< T > > _f
 
vectorAligned< SVec< T > > _frot
 
vectorAligned< SVec< T > > _U
 
vectorAligned< SVec< T > > _Urot
 
vectorAligned< SVec< T > > _Utot
 
vectorAligned< SVec< T > > _pA
 
vectorAligned< SVec< T > > _pArot
 
vectorAligned< SVec< T > > _externalForces
 
vectorAligned< SpatialInertia< T > > _IC
 
vectorAligned< Mat6< T > > _Xup
 
vectorAligned< Mat6< T > > _Xa
 
vectorAligned< Mat6< T > > _Xuprot
 
vectorAligned< Mat6< T > > _IA
 
vectorAligned< Mat6< T > > _ChiUp
 
DMat< T > _H
 
DMat< T > _C
 
DVec< T > _Cqd
 
DVec< T > _G
 
vectorAligned< D6Mat< T > > _J
 
vectorAligned< SVec< T > > _Jdqd
 
vectorAligned< D3Mat< T > > _Jc
 
vectorAligned< Vec3< T > > _Jcdqd
 
bool _kinematicsUpToDate = false
 
bool _biasAccelerationsUpToDate = false
 
bool _accelerationsUpToDate = false
 
bool _compositeInertiasUpToDate = false
 
bool _articulatedBodiesUpToDate = false
 
bool _forcePropagatorsUpToDate = false
 
bool _qddEffectsUpToDate = false
 
DMat< T > _qdd_from_base_accel
 
DMat< T > _qdd_from_subqdd
 
Eigen::ColPivHouseholderQR< Mat6< T > > _invIA5
 

Detailed Description

template<typename T>
class FloatingBaseModel< T >

Class to represent a floating base rigid body model with rotors and ground contacts. No concept of state.

Definition at line 69 of file FloatingBaseModel.h.

Constructor & Destructor Documentation

template<typename T>
FloatingBaseModel< T >::FloatingBaseModel ( )
inline

Initialize a floating base model with default gravity

Definition at line 74 of file FloatingBaseModel.h.

74 : _gravity(0, 0, -9.81) {}
template<typename T>
FloatingBaseModel< T >::~FloatingBaseModel ( )
inline

Definition at line 75 of file FloatingBaseModel.h.

75 {}

Member Function Documentation

template<typename T>
void FloatingBaseModel< T >::addBase ( const SpatialInertia< T > &  inertia)

Add floating base. Must be the first body added, and there can only be one

Create the floating body

Parameters
inertiaSpatial inertia of the floating body

Definition at line 267 of file FloatingBaseModel.cpp.

References ori::X.

267  {
268  if (_nDof) {
269  throw std::runtime_error("Cannot add base multiple times!\n");
270  }
271 
272  Mat6<T> eye6 = Mat6<T>::Identity();
273  Mat6<T> zero6 = Mat6<T>::Zero();
274  SpatialInertia<T> zeroInertia(zero6);
275  // the floating base has 6 DOFs
276 
277  _nDof = 6;
278  for (size_t i = 0; i < 6; i++) {
279  _parents.push_back(0);
280  _gearRatios.push_back(0);
281  _jointTypes.push_back(JointType::Nothing); // doesn't actually matter
282  _jointAxes.push_back(CoordinateAxis::X); // doesn't actually matter
283  _Xtree.push_back(eye6);
284  _Ibody.push_back(zeroInertia);
285  _Xrot.push_back(eye6);
286  _Irot.push_back(zeroInertia);
287  _bodyNames.push_back("N/A");
288  }
289 
290  _jointTypes[5] = JointType::FloatingBase;
291  _Ibody[5] = inertia;
292  _gearRatios[5] = 1;
293  _bodyNames[5] = "Floating Base";
294 
295  addDynamicsVars(6);
296 }
vector< std::string > _bodyNames
vector< Mat6< T >, Eigen::aligned_allocator< Mat6< T > > > _Xrot
vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > _Ibody
vector< CoordinateAxis > _jointAxes
typename Eigen::Matrix< T, 6, 6 > Mat6
Definition: cppTypes.h:70
vector< Mat6< T >, Eigen::aligned_allocator< Mat6< T > > > _Xtree
vector< int > _parents
vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > _Irot
void addDynamicsVars(int count)
vector< JointType > _jointTypes

+ Here is the caller graph for this function:

template<typename T>
void FloatingBaseModel< T >::addBase ( mass,
const Vec3< T > &  com,
const Mat3< T > &  I 
)

Add floating base. Must be the first body added, and there can only be one

Create the floating body

Parameters
massMass of the floating body
comCenter of mass of the floating body
IRotational inertia of the floating body

Definition at line 305 of file FloatingBaseModel.cpp.

306  {
307  SpatialInertia<T> IS(mass, com, I);
308  addBase(IS);
309 }
void addBase(const SpatialInertia< T > &inertia)
template<typename T>
int FloatingBaseModel< T >::addBody ( const SpatialInertia< T > &  inertia,
const SpatialInertia< T > &  rotorInertia,
gearRatio,
int  parent,
JointType  jointType,
CoordinateAxis  jointAxis,
const Mat6< T > &  Xtree,
const Mat6< T > &  Xrot 
)

Add a body to the tree

Parameters
inertia: Inertia of body (body coords)
rotorInertia: Inertia of rotor (rotor coords)
gearRatio: Gear ratio. >1 for a gear reduction
parent: Body ID of the link that the body is connected to
jointType: Type of joint
jointAxis: Axis of joint
Xtree: Location of joint
Xrot: Location of rotor
Returns
: bodyID

Add a body

Parameters
inertiaThe inertia of the body
rotorInertiaThe inertia of the rotor the body is connected to
gearRatioThe gear ratio between the body and the rotor
parentThe parent body, which is also assumed to be the body the rotor is connected to
jointTypeThe type of joint (prismatic or revolute)
jointAxisThe joint axis (X,Y,Z), in the parent's frame
XtreeThe coordinate transformation from parent to this body
XrotThe coordinate transformation from parent to this body's rotor
Returns
The body's ID (can be used as the parent)

Definition at line 392 of file FloatingBaseModel.cpp.

396  {
397  if ((size_t)parent >= _nDof) {
398  throw std::runtime_error(
399  "addBody got invalid parent: " + std::to_string(parent) +
400  " nDofs: " + std::to_string(_nDof) + "\n");
401  }
402 
403  _parents.push_back(parent);
404  _gearRatios.push_back(gearRatio);
405  _jointTypes.push_back(jointType);
406  _jointAxes.push_back(jointAxis);
407  _Xtree.push_back(Xtree);
408  _Xrot.push_back(Xrot);
409  _Ibody.push_back(inertia);
410  _Irot.push_back(rotorInertia);
411  _nDof++;
412 
413  addDynamicsVars(1);
414 
415  return _nDof;
416 }
vector< Mat6< T >, Eigen::aligned_allocator< Mat6< T > > > _Xrot
vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > _Ibody
vector< CoordinateAxis > _jointAxes
vector< Mat6< T >, Eigen::aligned_allocator< Mat6< T > > > _Xtree
vector< int > _parents
vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > _Irot
void addDynamicsVars(int count)
vector< JointType > _jointTypes

+ Here is the caller graph for this function:

template<typename T>
int FloatingBaseModel< T >::addBody ( const MassProperties< T > &  inertia,
const MassProperties< T > &  rotorInertia,
gearRatio,
int  parent,
JointType  jointType,
CoordinateAxis  jointAxis,
const Mat6< T > &  Xtree,
const Mat6< T > &  Xrot 
)

Add a body to the tree

Parameters
inertia: Inertia of body (body coords)
rotorInertia: Inertia of rotor (rotor coords)
gearRatio: Gear ratio. >1 for a gear reduction
parent: Body ID of the link that the body is connected to
jointType: Type of joint
jointAxis: Axis of joint
Xtree: Location of joint
Xrot: Location of rotor
Returns
: bodyID

Add a body

Parameters
inertiaThe inertia of the body
rotorInertiaThe inertia of the rotor the body is connected to
gearRatioThe gear ratio between the body and the rotor
parentThe parent body, which is also assumed to be the body the rotor is connected to
jointTypeThe type of joint (prismatic or revolute)
jointAxisThe joint axis (X,Y,Z), in the parent's frame
XtreeThe coordinate transformation from parent to this body
XrotThe coordinate transformation from parent to this body's rotor
Returns
The body's ID (can be used as the parent)

Definition at line 432 of file FloatingBaseModel.cpp.

436  {
437  return addBody(SpatialInertia<T>(inertia), SpatialInertia<T>(rotorInertia),
438  gearRatio, parent, jointType, jointAxis, Xtree, Xrot);
439 }
int addBody(const SpatialInertia< T > &inertia, const SpatialInertia< T > &rotorInertia, T gearRatio, int parent, JointType jointType, CoordinateAxis jointAxis, const Mat6< T > &Xtree, const Mat6< T > &Xrot)
template<typename T >
void FloatingBaseModel< T >::addDynamicsVars ( int  count)

Populate member variables when bodies are added

Parameters
count(6 for fb, 1 for joint)

Definition at line 185 of file FloatingBaseModel.cpp.

185  {
186  if (count != 1 && count != 6) {
187  throw std::runtime_error(
188  "addDynamicsVars must be called with count=1 (joint) or count=6 "
189  "(base).\n");
190  }
191 
192  Mat6<T> eye6 = Mat6<T>::Identity();
193  SVec<T> zero6 = SVec<T>::Zero();
194  Mat6<T> zero66 = Mat6<T>::Zero();
195 
196  SpatialInertia<T> zeroInertia(zero66);
197  for (int i = 0; i < count; i++) {
198  _v.push_back(zero6);
199  _vrot.push_back(zero6);
200  _a.push_back(zero6);
201  _arot.push_back(zero6);
202  _avp.push_back(zero6);
203  _avprot.push_back(zero6);
204  _c.push_back(zero6);
205  _crot.push_back(zero6);
206  _S.push_back(zero6);
207  _Srot.push_back(zero6);
208  _f.push_back(zero6);
209  _frot.push_back(zero6);
210  _fvp.push_back(zero6);
211  _fvprot.push_back(zero6);
212  _ag.push_back(zero6);
213  _agrot.push_back(zero6);
214  _IC.push_back(zeroInertia);
215  _Xup.push_back(eye6);
216  _Xuprot.push_back(eye6);
217  _Xa.push_back(eye6);
218 
219  _ChiUp.push_back(eye6);
220  _d.push_back(0.);
221  _u.push_back(0.);
222  _IA.push_back(eye6);
223 
224  _U.push_back(zero6);
225  _Urot.push_back(zero6);
226  _Utot.push_back(zero6);
227  _pA.push_back(zero6);
228  _pArot.push_back(zero6);
229  _externalForces.push_back(zero6);
230  }
231 
232  _J.push_back(D6Mat<T>::Zero(6, _nDof));
233  _Jdqd.push_back(SVec<T>::Zero());
234 
236 }
vectorAligned< Mat6< T > > _Xa
typename Eigen::Matrix< T, 6, Eigen::Dynamic > D6Mat
Definition: cppTypes.h:110
typename Eigen::Matrix< T, 6, 6 > Mat6
Definition: cppTypes.h:70
vectorAligned< SVec< T > > _ag
vectorAligned< SVec< T > > _c
vectorAligned< SpatialInertia< T > > _IC
vectorAligned< SVec< T > > _externalForces
vectorAligned< SVec< T > > _fvp
vectorAligned< Mat6< T > > _ChiUp
typename Eigen::Matrix< T, 6, 1 > SVec
Definition: cppTypes.h:62
vectorAligned< SVec< T > > _f
vectorAligned< SVec< T > > _Utot
vectorAligned< SVec< T > > _a
vectorAligned< SVec< T > > _Srot
vectorAligned< SVec< T > > _fvprot
vectorAligned< SVec< T > > _avprot
vectorAligned< Mat6< T > > _Xuprot
vectorAligned< SVec< T > > _S
vectorAligned< SVec< T > > _vrot
vectorAligned< Mat6< T > > _Xup
vectorAligned< SVec< T > > _crot
vectorAligned< SVec< T > > _frot
vectorAligned< D6Mat< T > > _J
vectorAligned< SVec< T > > _Urot
vectorAligned< SVec< T > > _avp
vectorAligned< SVec< T > > _Jdqd
vectorAligned< SVec< T > > _U
vectorAligned< SVec< T > > _pA
vectorAligned< SVec< T > > _v
vectorAligned< SVec< T > > _agrot
vectorAligned< SVec< T > > _pArot
vectorAligned< SVec< T > > _arot
vectorAligned< Mat6< T > > _IA
template<typename T>
void FloatingBaseModel< T >::addGroundContactBoxPoints ( int  bodyId,
const Vec3< T > &  dims 
)

Add bounding box collision points around a body.

Parameters
bodyId: Body to add
dims: Dimension of points

Add the bounding points of a box to the contact model. Assumes the box is centered around the origin of the body coordinate system and is axis aligned.

Definition at line 360 of file FloatingBaseModel.cpp.

361  {
362  // addGroundContactPoint(bodyId, Vec3<T>( dims(0), dims(1), dims(2))/2);
363  // addGroundContactPoint(bodyId, Vec3<T>(-dims(0), dims(1), dims(2))/2);
364  // addGroundContactPoint(bodyId, Vec3<T>( dims(0), -dims(1), dims(2))/2);
365  // addGroundContactPoint(bodyId, Vec3<T>(-dims(0), -dims(1), dims(2))/2);
366 
367  addGroundContactPoint(bodyId, Vec3<T>(dims(0), dims(1), 0.) / 2);
368  addGroundContactPoint(bodyId, Vec3<T>(-dims(0), dims(1), 0.) / 2);
369  addGroundContactPoint(bodyId, Vec3<T>(dims(0), -dims(1), 0.) / 2);
370  addGroundContactPoint(bodyId, Vec3<T>(-dims(0), -dims(1), 0.) / 2);
371 
372  addGroundContactPoint(bodyId, Vec3<T>(dims(0), dims(1), -dims(2)) / 2);
373  addGroundContactPoint(bodyId, Vec3<T>(-dims(0), dims(1), -dims(2)) / 2);
374  addGroundContactPoint(bodyId, Vec3<T>(dims(0), -dims(1), -dims(2)) / 2);
375  addGroundContactPoint(bodyId, Vec3<T>(-dims(0), -dims(1), -dims(2)) / 2);
376 }
int addGroundContactPoint(int bodyID, const Vec3< T > &location, bool isFoot=false)
typename Eigen::Matrix< T, 3, 1 > Vec3
Definition: cppTypes.h:26

+ Here is the caller graph for this function:

template<typename T>
int FloatingBaseModel< T >::addGroundContactPoint ( int  bodyID,
const Vec3< T > &  location,
bool  isFoot = false 
)

Add a point for collisions

Parameters
bodyID: body that the point belongs to (body 5 for floating base)
location: location of point in body coordinates
isFoot: if the point is a foot or not. Only feet have their Jacobian calculated on the robot
Returns
collisionPointID of the new point

Add a ground contact point to a model

Parameters
bodyIDThe ID of the body containing the contact point
locationThe location (in body coordinate) of the contact point
isFootTrue if foot or not.
Returns
The ID of the ground contact point

Definition at line 319 of file FloatingBaseModel.cpp.

321  {
322  if ((size_t)bodyID >= _nDof) {
323  throw std::runtime_error(
324  "addGroundContactPoint got invalid bodyID: " + std::to_string(bodyID) +
325  " nDofs: " + std::to_string(_nDof) + "\n");
326  }
327 
328  // std::cout << "pt-add: " << location.transpose() << "\n";
329  _gcParent.push_back(bodyID);
330  _gcLocation.push_back(location);
331 
332  Vec3<T> zero3 = Vec3<T>::Zero();
333 
334  _pGC.push_back(zero3);
335  _vGC.push_back(zero3);
336 
337  D3Mat<T> J(3, _nDof);
338  J.setZero();
339 
340  _Jc.push_back(J);
341  _Jcdqd.push_back(zero3);
342  //_compute_contact_info.push_back(false);
343  _compute_contact_info.push_back(true);
344 
345  // add foot to foot list
346  if (isFoot) {
347  _footIndicesGC.push_back(_nGroundContact);
349  }
350 
352  return _nGroundContact++;
353 }
vector< bool > _compute_contact_info
vectorAligned< Vec3< T > > _Jcdqd
typename Eigen::Matrix< T, 3, 1 > Vec3
Definition: cppTypes.h:26
vector< Vec3< T > > _vGC
typename Eigen::Matrix< T, 3, Eigen::Dynamic > D3Mat
Definition: cppTypes.h:114
vector< Vec3< T > > _gcLocation
vector< size_t > _gcParent
vector< Vec3< T > > _pGC
vector< uint64_t > _footIndicesGC
vectorAligned< D3Mat< T > > _Jc

+ Here is the caller graph for this function:

template<typename T>
T FloatingBaseModel< T >::applyTestForce ( const int  gc_index,
const Vec3< T > &  force_ics_at_contact,
FBModelStateDerivative< T > &  dstate_out 
)

Apply a unit test force at a contact. Returns the inv contact inertia in that direction and computes the resultant qdd

Parameters
gc_indexindex of the contact
force_ics_at_contactunit test forcoe dstate - Output paramter of resulting accelerations
Returns
the 1x1 inverse contact inertia J H^{-1} J^T

Definition at line 962 of file FloatingBaseModel.cpp.

References spatial::createSXform(), FBModelStateDerivative< T >::dBodyVelocity, and FBModelStateDerivative< T >::qdd.

964  {
969 
970  size_t i_opsp = _gcParent.at(gc_index);
971  size_t i = i_opsp;
972 
973  dstate_out.qdd.setZero();
974 
975  // Rotation to absolute coords
976  Mat3<T> Rai = _Xa[i].template block<3, 3>(0, 0).transpose();
977  Mat6<T> Xc = createSXform(Rai, _gcLocation.at(gc_index));
978 
979  // D is one column of an extended force propagator matrix (See Wensing, 2012
980  // ICRA)
981  SVec<T> F = Xc.transpose().template rightCols<3>() * force_ics_at_contact;
982 
983  double LambdaInv = 0;
984  double tmp = 0;
985 
986  // from tips to base
987  while (i > 5) {
988  tmp = F.dot(_S[i]);
989  LambdaInv += tmp * tmp / _d[i];
990  dstate_out.qdd += _qdd_from_subqdd.col(i - 6) * tmp / _d[i];
991 
992  // Apply force propagator (see Pat's ICRA 2012 paper)
993  // essentially, since the joint is articulated, only a portion of the force
994  // is felt on the predecessor. So, while Xup^T sends a force backwards as if
995  // the joint was locked, ChiUp^T sends the force backward as if the joint
996  // were free
997  F = _ChiUp[i].transpose() * F;
998  i = _parents[i];
999  }
1000 
1001  // TODO: Only carry out the QR once within update Aritculated Bodies
1002  dstate_out.dBodyVelocity = _invIA5.solve(F);
1003  LambdaInv += F.dot(dstate_out.dBodyVelocity);
1004  dstate_out.qdd += _qdd_from_base_accel * dstate_out.dBodyVelocity;
1005 
1006  return LambdaInv;
1007 }
vectorAligned< Mat6< T > > _Xa
Eigen::ColPivHouseholderQR< Mat6< T > > _invIA5
typename Eigen::Matrix< T, 6, 6 > Mat6
Definition: cppTypes.h:70
typename Eigen::Matrix< T, 3, 3 > Mat3
Definition: cppTypes.h:54
vectorAligned< Mat6< T > > _ChiUp
typename Eigen::Matrix< T, 6, 1 > SVec
Definition: cppTypes.h:62
vector< Vec3< T > > _gcLocation
vector< int > _parents
auto createSXform(const Eigen::MatrixBase< T > &R, const Eigen::MatrixBase< T2 > &r)
Definition: spatial.h:140
vector< size_t > _gcParent
vectorAligned< SVec< T > > _S
DMat< T > _qdd_from_base_accel

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T>
T FloatingBaseModel< T >::applyTestForce ( const int  gc_index,
const Vec3< T > &  force_ics_at_contact,
DVec< T > &  dstate_out 
)

Apply a unit test force at a contact. Returns the inv contact inertia in that direction and computes the resultant qdd

Parameters
gc_indexindex of the contact
force_ics_at_contactunit test force expressed in inertial coordinates dstate - Output paramter of resulting accelerations
Returns
the 1x1 inverse contact inertia J H^{-1} J^T

Definition at line 40 of file FloatingBaseModel.cpp.

References spatial::createSXform().

42  {
47 
48  size_t i_opsp = _gcParent.at(gc_index);
49  size_t i = i_opsp;
50 
51  dstate_out = DVec<T>::Zero(_nDof);
52 
53  // Rotation to absolute coords
54  Mat3<T> Rai = _Xa[i].template block<3, 3>(0, 0).transpose();
55  Mat6<T> Xc = createSXform(Rai, _gcLocation.at(gc_index));
56 
57  // D is one column of an extended force propagator matrix (See Wensing, 2012
58  // ICRA)
59  SVec<T> F = Xc.transpose().template rightCols<3>() * force_ics_at_contact;
60 
61  T LambdaInv = 0;
62  T tmp = 0;
63 
64  // from tips to base
65  while (i > 5) {
66  tmp = F.dot(_S[i]);
67  LambdaInv += tmp * tmp / _d[i];
68  dstate_out.tail(_nDof - 6) += _qdd_from_subqdd.col(i - 6) * tmp / _d[i];
69 
70  // Apply force propagator (see Pat's ICRA 2012 paper)
71  // essentially, since the joint is articulated, only a portion of the force
72  // is felt on the predecessor. So, while Xup^T sends a force backwards as if
73  // the joint was locked, ChiUp^T sends the force backward as if the joint
74  // were free
75  F = _ChiUp[i].transpose() * F;
76  i = _parents[i];
77  }
78 
79  dstate_out.head(6) = _invIA5.solve(F);
80  LambdaInv += F.dot(dstate_out.head(6));
81  dstate_out.tail(_nDof - 6) += _qdd_from_base_accel * dstate_out.head(6);
82 
83  return LambdaInv;
84 }
vectorAligned< Mat6< T > > _Xa
Eigen::ColPivHouseholderQR< Mat6< T > > _invIA5
typename Eigen::Matrix< T, 6, 6 > Mat6
Definition: cppTypes.h:70
typename Eigen::Matrix< T, 3, 3 > Mat3
Definition: cppTypes.h:54
vectorAligned< Mat6< T > > _ChiUp
typename Eigen::Matrix< T, 6, 1 > SVec
Definition: cppTypes.h:62
vector< Vec3< T > > _gcLocation
vector< int > _parents
auto createSXform(const Eigen::MatrixBase< T > &R, const Eigen::MatrixBase< T2 > &r)
Definition: spatial.h:140
vector< size_t > _gcParent
vectorAligned< SVec< T > > _S
typename Eigen::Matrix< T, Eigen::Dynamic, 1 > DVec
Definition: cppTypes.h:102
DMat< T > _qdd_from_base_accel

+ Here is the call graph for this function:

template<typename T >
void FloatingBaseModel< T >::biasAccelerations ( )

(Support Function) Computes velocity product accelerations of each link and rotor _avp, and _avprot

Definition at line 590 of file FloatingBaseModel.cpp.

590  {
591  if (_biasAccelerationsUpToDate) return;
593  // velocity product acceelration of base
594  _avp[5] << 0, 0, 0, 0, 0, 0;
595 
596  // from base to tips
597  for (size_t i = 6; i < _nDof; i++) {
598  // Outward kinamtic propagtion
599  _avp[i] = _Xup[i] * _avp[_parents[i]] + _c[i];
600  _avprot[i] = _Xuprot[i] * _avp[_parents[i]] + _crot[i];
601  }
603 }
vectorAligned< SVec< T > > _c
vector< int > _parents
vectorAligned< SVec< T > > _avprot
vectorAligned< Mat6< T > > _Xuprot
vectorAligned< Mat6< T > > _Xup
vectorAligned< SVec< T > > _crot
vectorAligned< SVec< T > > _avp
template<typename T >
void FloatingBaseModel< T >::check ( )

Very simple to check to make sure the dimensions are correct

Definition at line 442 of file FloatingBaseModel.cpp.

442  {
443  if (_nDof != _parents.size())
444  throw std::runtime_error("Invalid dof and parents length");
445 }
vector< int > _parents

+ Here is the caller graph for this function:

template<typename T >
void FloatingBaseModel< T >::compositeInertias ( )

(Support Function) Computes the composite rigid body inertia of each subtree _IC[i] contains body i, and the body/rotor inertias of all successors of body i. (key note: _IC[i] does not contain rotor i)

Definition at line 753 of file FloatingBaseModel.cpp.

753  {
754  if (_compositeInertiasUpToDate) return;
755 
757  // initialize
758  for (size_t i = 5; i < _nDof; i++) {
759  _IC[i].setMatrix(_Ibody[i].getMatrix());
760  }
761 
762  // backward loop
763  for (size_t i = _nDof - 1; i > 5; i--) {
764  // Propagate inertia down the tree
765  _IC[_parents[i]].addMatrix(_Xup[i].transpose() * _IC[i].getMatrix() *
766  _Xup[i]);
767  _IC[_parents[i]].addMatrix(_Xuprot[i].transpose() * _Irot[i].getMatrix() *
768  _Xuprot[i]);
769  }
771 }
vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > _Ibody
vectorAligned< SpatialInertia< T > > _IC
vector< int > _parents
vectorAligned< Mat6< T > > _Xuprot
vectorAligned< Mat6< T > > _Xup
vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > _Irot
template<typename T >
void FloatingBaseModel< T >::contactJacobians ( )

Compute the contact Jacobians (3xn matrices) for the velocity of each contact point expressed in absolute coordinates

Definition at line 548 of file FloatingBaseModel.cpp.

References spatial::createSXform(), and spatial::spatialToLinearAcceleration().

548  {
551 
552  for (size_t k = 0; k < _nGroundContact; k++) {
553  _Jc[k].setZero();
554  _Jcdqd[k].setZero();
555 
556  // Skip it if we don't care about it
557  if (!_compute_contact_info[k]) continue;
558 
559  size_t i = _gcParent.at(k);
560 
561  // Rotation to absolute coords
562  Mat3<T> Rai = _Xa[i].template block<3, 3>(0, 0).transpose();
563  Mat6<T> Xc = createSXform(Rai, _gcLocation.at(k));
564 
565  // Bias acceleration
566  SVec<T> ac = Xc * _avp[i];
567  SVec<T> vc = Xc * _v[i];
568 
569  // Correct to classical
570  _Jcdqd[k] = spatialToLinearAcceleration(ac, vc);
571 
572  // rows for linear velcoity in the world
573  D3Mat<T> Xout = Xc.template bottomRows<3>();
574 
575  // from tips to base
576  while (i > 5) {
577  _Jc[k].col(i) = Xout * _S[i];
578  Xout = Xout * _Xup[i];
579  i = _parents[i];
580  }
581  _Jc[k].template leftCols<6>() = Xout;
582  }
583 }
vector< bool > _compute_contact_info
vectorAligned< Mat6< T > > _Xa
typename Eigen::Matrix< T, 6, 6 > Mat6
Definition: cppTypes.h:70
typename Eigen::Matrix< T, 3, 3 > Mat3
Definition: cppTypes.h:54
vectorAligned< Vec3< T > > _Jcdqd
auto spatialToLinearAcceleration(const Eigen::MatrixBase< T > &a, const Eigen::MatrixBase< T2 > &v)
Definition: spatial.h:289
typename Eigen::Matrix< T, 3, Eigen::Dynamic > D3Mat
Definition: cppTypes.h:114
typename Eigen::Matrix< T, 6, 1 > SVec
Definition: cppTypes.h:62
vector< Vec3< T > > _gcLocation
vector< int > _parents
auto createSXform(const Eigen::MatrixBase< T > &R, const Eigen::MatrixBase< T2 > &r)
Definition: spatial.h:140
vector< size_t > _gcParent
vectorAligned< SVec< T > > _S
vectorAligned< Mat6< T > > _Xup
vectorAligned< SVec< T > > _avp
vectorAligned< D3Mat< T > > _Jc
vectorAligned< SVec< T > > _v

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T >
void FloatingBaseModel< T >::forwardAccelerationKinematics ( )

Definition at line 813 of file FloatingBaseModel.cpp.

813  {
815  return;
816  }
817 
820 
821  // Initialize gravity with model info
822  SVec<T> aGravity = SVec<T>::Zero();
823  aGravity.template tail<3>() = _gravity;
824 
825  // Spatial force for floating base
826  _a[5] = -_Xup[5] * aGravity + _dState.dBodyVelocity;
827 
828  // loop through joints
829  for (size_t i = 6; i < _nDof; i++) {
830  // spatial acceleration
831  _a[i] = _Xup[i] * _a[_parents[i]] + _S[i] * _dState.qdd[i - 6] + _c[i];
832  _arot[i] =
833  _Xuprot[i] * _a[_parents[i]] + _Srot[i] * _dState.qdd[i - 6] + _crot[i];
834  }
835  _accelerationsUpToDate = true;
836 }
vectorAligned< SVec< T > > _c
FBModelStateDerivative< T > _dState
typename Eigen::Matrix< T, 6, 1 > SVec
Definition: cppTypes.h:62
vector< int > _parents
vectorAligned< SVec< T > > _a
vectorAligned< SVec< T > > _Srot
vectorAligned< Mat6< T > > _Xuprot
vectorAligned< SVec< T > > _S
vectorAligned< Mat6< T > > _Xup
vectorAligned< SVec< T > > _crot
vectorAligned< SVec< T > > _arot
template<typename T >
void FloatingBaseModel< T >::forwardKinematics ( )

Forward kinematics of all bodies. Computes _Xup (from up the tree) and _Xa (from absolute) Also computes _S (motion subspace), _v (spatial velocity in link coordinates), and _c (coriolis acceleration in link coordinates)

Definition at line 479 of file FloatingBaseModel.cpp.

References spatial::createSXform(), spatial::invertSXform(), spatial::jointXform(), spatial::motionCrossProduct(), ori::quaternionToRotationMatrix(), spatial::spatialToLinearVelocity(), and spatial::sXFormPoint().

479  {
480  if (_kinematicsUpToDate) return;
481 
482  // calculate joint transformations
483  _Xup[5] = createSXform(quaternionToRotationMatrix(_state.bodyOrientation),
484  _state.bodyPosition);
485  _v[5] = _state.bodyVelocity;
486  for (size_t i = 6; i < _nDof; i++) {
487  // joint xform
488  Mat6<T> XJ = jointXform(_jointTypes[i], _jointAxes[i], _state.q[i - 6]);
489  _Xup[i] = XJ * _Xtree[i];
490  _S[i] = jointMotionSubspace<T>(_jointTypes[i], _jointAxes[i]);
491  SVec<T> vJ = _S[i] * _state.qd[i - 6];
492  // total velocity of body i
493  _v[i] = _Xup[i] * _v[_parents[i]] + vJ;
494 
495  // Same for rotors
496  Mat6<T> XJrot = jointXform(_jointTypes[i], _jointAxes[i],
497  _state.q[i - 6] * _gearRatios[i]);
498  _Srot[i] = _S[i] * _gearRatios[i];
499  SVec<T> vJrot = _Srot[i] * _state.qd[i - 6];
500  _Xuprot[i] = XJrot * _Xrot[i];
501  _vrot[i] = _Xuprot[i] * _v[_parents[i]] + vJrot;
502 
503  // Coriolis accelerations
504  _c[i] = motionCrossProduct(_v[i], vJ);
505  _crot[i] = motionCrossProduct(_vrot[i], vJrot);
506  }
507 
508  // calculate from absolute transformations
509  for (size_t i = 5; i < _nDof; i++) {
510  if (_parents[i] == 0) {
511  _Xa[i] = _Xup[i]; // float base
512  } else {
513  _Xa[i] = _Xup[i] * _Xa[_parents[i]];
514  }
515  }
516 
517  // ground contact points
518  // // TODO : we end up inverting the same Xa a few times (like for the 8
519  // points on the body). this isn't super efficient.
520  for (size_t j = 0; j < _nGroundContact; j++) {
521  if (!_compute_contact_info[j]) continue;
522  size_t i = _gcParent.at(j);
523  Mat6<T> Xai = invertSXform(_Xa[i]); // from link to absolute
524  SVec<T> vSpatial = Xai * _v[i];
525 
526  // foot position in world
527  _pGC.at(j) = sXFormPoint(Xai, _gcLocation.at(j));
528  _vGC.at(j) = spatialToLinearVelocity(vSpatial, _pGC.at(j));
529  }
530  _kinematicsUpToDate = true;
531 }
vector< Mat6< T >, Eigen::aligned_allocator< Mat6< T > > > _Xrot
auto spatialToLinearVelocity(const Eigen::MatrixBase< T > &v, const Eigen::MatrixBase< T2 > &x)
Definition: spatial.h:261
vector< bool > _compute_contact_info
vectorAligned< Mat6< T > > _Xa
vector< CoordinateAxis > _jointAxes
typename Eigen::Matrix< T, 6, 6 > Mat6
Definition: cppTypes.h:70
Mat6< T > jointXform(JointType joint, CoordinateAxis axis, T q)
Definition: spatial.h:219
vectorAligned< SVec< T > > _c
vector< Mat6< T >, Eigen::aligned_allocator< Mat6< T > > > _Xtree
auto sXFormPoint(const Eigen::MatrixBase< T > &X, const Eigen::MatrixBase< T2 > &p)
Definition: spatial.h:329
vector< Vec3< T > > _vGC
typename Eigen::Matrix< T, 6, 1 > SVec
Definition: cppTypes.h:62
vector< Vec3< T > > _gcLocation
vector< int > _parents
auto createSXform(const Eigen::MatrixBase< T > &R, const Eigen::MatrixBase< T2 > &r)
Definition: spatial.h:140
vector< size_t > _gcParent
vectorAligned< SVec< T > > _Srot
vectorAligned< Mat6< T > > _Xuprot
auto motionCrossProduct(const Eigen::MatrixBase< T > &a, const Eigen::MatrixBase< T > &b)
Definition: spatial.h:73
vectorAligned< SVec< T > > _S
vectorAligned< SVec< T > > _vrot
vectorAligned< Mat6< T > > _Xup
vectorAligned< SVec< T > > _crot
vector< Vec3< T > > _pGC
Mat3< typename T::Scalar > quaternionToRotationMatrix(const Eigen::MatrixBase< T > &q)
vectorAligned< SVec< T > > _v
FBModelState< T > _state
BEGIN ALGORITHM SUPPORT VARIABLES.
auto invertSXform(const Eigen::MatrixBase< T > &X)
Definition: spatial.h:181
vector< JointType > _jointTypes

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T >
DVec< T > FloatingBaseModel< T >::generalizedCoriolisForce ( )

Computes the generalized coriolis forces (Cqd) in the inverse dynamics

Returns
Cqd (_nDof x 1 vector)

Definition at line 636 of file FloatingBaseModel.cpp.

References spatial::forceCrossProduct().

636  {
638 
639  // Floating base force
640  Mat6<T> Ifb = _Ibody[5].getMatrix();
641  SVec<T> hfb = Ifb * _v[5];
642  _fvp[5] = Ifb * _avp[5] + forceCrossProduct(_v[5], hfb);
643 
644  for (size_t i = 6; i < _nDof; i++) {
645  // Force on body i
646  Mat6<T> Ii = _Ibody[i].getMatrix();
647  SVec<T> hi = Ii * _v[i];
648  _fvp[i] = Ii * _avp[i] + forceCrossProduct(_v[i], hi);
649 
650  // Force on rotor i
651  Mat6<T> Ir = _Irot[i].getMatrix();
652  SVec<T> hr = Ir * _vrot[i];
653  _fvprot[i] = Ir * _avprot[i] + forceCrossProduct(_vrot[i], hr);
654  }
655 
656  for (size_t i = _nDof - 1; i > 5; i--) {
657  // Extract force along the joints
658  _Cqd[i] = _S[i].dot(_fvp[i]) + _Srot[i].dot(_fvprot[i]);
659 
660  // Propage force down the tree
661  _fvp[_parents[i]] += _Xup[i].transpose() * _fvp[i];
662  _fvp[_parents[i]] += _Xuprot[i].transpose() * _fvprot[i];
663  }
664 
665  // Force on floating base
666  _Cqd.template topRows<6>() = _fvp[5];
667  return _Cqd;
668 }
vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > _Ibody
auto forceCrossProduct(const Eigen::MatrixBase< T > &a, const Eigen::MatrixBase< T > &b)
Definition: spatial.h:91
typename Eigen::Matrix< T, 6, 6 > Mat6
Definition: cppTypes.h:70
vectorAligned< SVec< T > > _fvp
typename Eigen::Matrix< T, 6, 1 > SVec
Definition: cppTypes.h:62
vector< int > _parents
vectorAligned< SVec< T > > _Srot
vectorAligned< SVec< T > > _fvprot
vectorAligned< SVec< T > > _avprot
vectorAligned< Mat6< T > > _Xuprot
vectorAligned< SVec< T > > _S
vectorAligned< SVec< T > > _vrot
vectorAligned< Mat6< T > > _Xup
vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > _Irot
vectorAligned< SVec< T > > _avp
vectorAligned< SVec< T > > _v

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T >
DVec< T > FloatingBaseModel< T >::generalizedGravityForce ( )

Computes the generalized gravitational force (G) in the inverse dynamics

Returns
G (_nDof x 1 vector)

Definition at line 610 of file FloatingBaseModel.cpp.

610  {
612 
613  SVec<T> aGravity;
614  aGravity << 0, 0, 0, _gravity[0], _gravity[1], _gravity[2];
615  _ag[5] = _Xup[5] * aGravity;
616 
617  // Gravity comp force is the same as force required to accelerate
618  // oppostite gravity
619  _G.template topRows<6>() = -_IC[5].getMatrix() * _ag[5];
620  for (size_t i = 6; i < _nDof; i++) {
621  _ag[i] = _Xup[i] * _ag[_parents[i]];
622  _agrot[i] = _Xuprot[i] * _ag[_parents[i]];
623 
624  // body and rotor
625  _G[i] = -_S[i].dot(_IC[i].getMatrix() * _ag[i]) -
626  _Srot[i].dot(_Irot[i].getMatrix() * _agrot[i]);
627  }
628  return _G;
629 }
vectorAligned< SVec< T > > _ag
vectorAligned< SpatialInertia< T > > _IC
typename Eigen::Matrix< T, 6, 1 > SVec
Definition: cppTypes.h:62
vector< int > _parents
vectorAligned< SVec< T > > _Srot
vectorAligned< Mat6< T > > _Xuprot
vectorAligned< SVec< T > > _S
vectorAligned< Mat6< T > > _Xup
vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > _Irot
vectorAligned< SVec< T > > _agrot

+ Here is the caller graph for this function:

template<typename T >
Vec3< T > FloatingBaseModel< T >::getAngularAcceleration ( const int  link_idx)

Definition at line 740 of file FloatingBaseModel.cpp.

740  {
742  Mat3<T> Rai = getOrientation(link_idx);
743  return Rai * _a[link_idx].template head<3>();
744 }
Mat3< T > getOrientation(const int link_idx)
typename Eigen::Matrix< T, 3, 3 > Mat3
Definition: cppTypes.h:54
vectorAligned< SVec< T > > _a
template<typename T >
Vec3< T > FloatingBaseModel< T >::getAngularVelocity ( const int  link_idx)

Definition at line 731 of file FloatingBaseModel.cpp.

731  {
733  Mat3<T> Rai = getOrientation(link_idx);
734  // Vec3<T> v3 =
735  return Rai * _v[link_idx].template head<3>();
736  ;
737 }
Mat3< T > getOrientation(const int link_idx)
typename Eigen::Matrix< T, 3, 3 > Mat3
Definition: cppTypes.h:54
vectorAligned< SVec< T > > _v
template<typename T>
const std::vector<SpatialInertia<T>, Eigen::aligned_allocator<SpatialInertia<T> > >& FloatingBaseModel< T >::getBodyInertiaVector ( )
inline

Definition at line 158 of file FloatingBaseModel.h.

158  {
159  return _Ibody;
160  }
vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > _Ibody

+ Here is the caller graph for this function:

template<typename T>
const DVec<T>& FloatingBaseModel< T >::getCoriolisForce ( ) const
inline

Definition at line 263 of file FloatingBaseModel.h.

263 { return _Cqd; }
template<typename T>
const DVec<T>& FloatingBaseModel< T >::getGravityForce ( ) const
inline

Definition at line 262 of file FloatingBaseModel.h.

262 { return _G; }
template<typename T>
Vec3< T > FloatingBaseModel< T >::getLinearAcceleration ( const int  link_idx,
const Vec3< T > &  point 
)

Definition at line 698 of file FloatingBaseModel.cpp.

References spatial::spatialToLinearAcceleration().

699  {
701  Mat3<T> R = getOrientation(link_idx);
702  return R * spatialToLinearAcceleration(_a[link_idx], _v[link_idx], point);
703 }
Mat3< T > getOrientation(const int link_idx)
typename Eigen::Matrix< T, 3, 3 > Mat3
Definition: cppTypes.h:54
auto spatialToLinearAcceleration(const Eigen::MatrixBase< T > &a, const Eigen::MatrixBase< T2 > &v)
Definition: spatial.h:289
vectorAligned< SVec< T > > _a
vectorAligned< SVec< T > > _v

+ Here is the call graph for this function:

template<typename T>
Vec3< T > FloatingBaseModel< T >::getLinearAcceleration ( const int  link_idx)

Definition at line 706 of file FloatingBaseModel.cpp.

References spatial::spatialToLinearAcceleration().

706  {
708  Mat3<T> R = getOrientation(link_idx);
709  return R * spatialToLinearAcceleration(_a[link_idx], _v[link_idx], Vec3<T>::Zero());
710 }
Mat3< T > getOrientation(const int link_idx)
typename Eigen::Matrix< T, 3, 3 > Mat3
Definition: cppTypes.h:54
typename Eigen::Matrix< T, 3, 1 > Vec3
Definition: cppTypes.h:26
auto spatialToLinearAcceleration(const Eigen::MatrixBase< T > &a, const Eigen::MatrixBase< T2 > &v)
Definition: spatial.h:289
vectorAligned< SVec< T > > _a
vectorAligned< SVec< T > > _v

+ Here is the call graph for this function:

template<typename T>
Vec3< T > FloatingBaseModel< T >::getLinearVelocity ( const int  link_idx,
const Vec3< T > &  point 
)

Definition at line 714 of file FloatingBaseModel.cpp.

References spatial::spatialToLinearVelocity().

715  {
717  Mat3<T> Rai = getOrientation(link_idx);
718  return Rai * spatialToLinearVelocity(_v[link_idx], point);
719 }
Mat3< T > getOrientation(const int link_idx)
auto spatialToLinearVelocity(const Eigen::MatrixBase< T > &v, const Eigen::MatrixBase< T2 > &x)
Definition: spatial.h:261
typename Eigen::Matrix< T, 3, 3 > Mat3
Definition: cppTypes.h:54
vectorAligned< SVec< T > > _v

+ Here is the call graph for this function:

template<typename T>
Vec3< T > FloatingBaseModel< T >::getLinearVelocity ( const int  link_idx)

Definition at line 722 of file FloatingBaseModel.cpp.

References spatial::spatialToLinearVelocity().

722  {
724  Mat3<T> Rai = getOrientation(link_idx);
725  return Rai * spatialToLinearVelocity(_v[link_idx], Vec3<T>::Zero());
726 }
Mat3< T > getOrientation(const int link_idx)
auto spatialToLinearVelocity(const Eigen::MatrixBase< T > &v, const Eigen::MatrixBase< T2 > &x)
Definition: spatial.h:261
typename Eigen::Matrix< T, 3, 3 > Mat3
Definition: cppTypes.h:54
typename Eigen::Matrix< T, 3, 1 > Vec3
Definition: cppTypes.h:26
vectorAligned< SVec< T > > _v

+ Here is the call graph for this function:

template<typename T>
const DMat<T>& FloatingBaseModel< T >::getMassMatrix ( ) const
inline

Definition at line 261 of file FloatingBaseModel.h.

261 { return _H; }

+ Here is the caller graph for this function:

template<typename T >
Mat3< T > FloatingBaseModel< T >::getOrientation ( const int  link_idx)

Definition at line 671 of file FloatingBaseModel.cpp.

671  {
673  Mat3<T> Rai = _Xa[link_idx].template block<3, 3>(0, 0);
674  Rai.transposeInPlace();
675  return Rai;
676 }
vectorAligned< Mat6< T > > _Xa
typename Eigen::Matrix< T, 3, 3 > Mat3
Definition: cppTypes.h:54
template<typename T>
const std::vector<int>& FloatingBaseModel< T >::getParentVector ( )
inline

Definition at line 154 of file FloatingBaseModel.h.

154 { return _parents; }
vector< int > _parents

+ Here is the caller graph for this function:

template<typename T>
Vec3< T > FloatingBaseModel< T >::getPosition ( const int  link_idx,
const Vec3< T > &  local_pos 
)

Definition at line 689 of file FloatingBaseModel.cpp.

References spatial::invertSXform(), and spatial::sXFormPoint().

690 {
692  Mat6<T> Xai = invertSXform(_Xa[link_idx]); // from link to absolute
693  Vec3<T> link_pos = sXFormPoint(Xai, local_pos);
694  return link_pos;
695 }
vectorAligned< Mat6< T > > _Xa
typename Eigen::Matrix< T, 6, 6 > Mat6
Definition: cppTypes.h:70
typename Eigen::Matrix< T, 3, 1 > Vec3
Definition: cppTypes.h:26
auto sXFormPoint(const Eigen::MatrixBase< T > &X, const Eigen::MatrixBase< T2 > &p)
Definition: spatial.h:329
auto invertSXform(const Eigen::MatrixBase< T > &X)
Definition: spatial.h:181

+ Here is the call graph for this function:

template<typename T>
Vec3< T > FloatingBaseModel< T >::getPosition ( const int  link_idx)

Definition at line 680 of file FloatingBaseModel.cpp.

References spatial::invertSXform(), and spatial::sXFormPoint().

681 {
683  Mat6<T> Xai = invertSXform(_Xa[link_idx]); // from link to absolute
684  Vec3<T> link_pos = sXFormPoint(Xai, Vec3<T>::Zero());
685  return link_pos;
686 }
vectorAligned< Mat6< T > > _Xa
typename Eigen::Matrix< T, 6, 6 > Mat6
Definition: cppTypes.h:70
typename Eigen::Matrix< T, 3, 1 > Vec3
Definition: cppTypes.h:26
auto sXFormPoint(const Eigen::MatrixBase< T > &X, const Eigen::MatrixBase< T2 > &p)
Definition: spatial.h:329
auto invertSXform(const Eigen::MatrixBase< T > &X)
Definition: spatial.h:181

+ Here is the call graph for this function:

template<typename T>
const std::vector<SpatialInertia<T>, Eigen::aligned_allocator<SpatialInertia<T> > >& FloatingBaseModel< T >::getRotorInertiaVector ( )
inline

Definition at line 164 of file FloatingBaseModel.h.

164  {
165  return _Irot;
166  }
vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > _Irot

+ Here is the caller graph for this function:

template<typename T>
DMat< T > FloatingBaseModel< T >::invContactInertia ( const int  gc_index,
const D6Mat< T > &  force_directions 
)

Compute the inverse of the contact inertia matrix (mxm)

Parameters
force_directions(6xm) each column denotes a direction of interest col = [ moment in i.c.s., force in i.c.s.] e.g. if you want the cartesian inv. contact inertia force_directions = [ 0_{3x3} I_{3x3}]^T if you only want the cartesian inv. contact inertia in one direction then use the overloaded version.
Returns
the mxm inverse contact inertia J H^{-1} J^T

Definition at line 1065 of file FloatingBaseModel.cpp.

References spatial::createSXform().

1066  {
1070 
1071  size_t i_opsp = _gcParent.at(gc_index);
1072  size_t i = i_opsp;
1073 
1074  // Rotation to absolute coords
1075  Mat3<T> Rai = _Xa[i].template block<3, 3>(0, 0).transpose();
1076  Mat6<T> Xc = createSXform(Rai, _gcLocation.at(gc_index));
1077 
1078  // D is a subslice of an extended force propagator matrix (See Wensing, 2012
1079  // ICRA)
1080  D6Mat<T> D = Xc.transpose() * force_directions;
1081 
1082  size_t m = force_directions.cols();
1083 
1084  DMat<T> LambdaInv = DMat<T>::Zero(m, m);
1085  DVec<T> tmp = DVec<T>::Zero(m);
1086 
1087  // from tips to base
1088  while (i > 5) {
1089  tmp = D.transpose() * _S[i];
1090  LambdaInv += tmp * tmp.transpose() / _d[i];
1091 
1092  // Apply force propagator (see Pat's ICRA 2012 paper)
1093  // essentially, since the joint is articulated, only a portion of the force
1094  // is felt on the predecessor. So, while Xup^T sends a force backwards as if
1095  // the joint was locked, ChiUp^T sends the force backward as if the joint
1096  // were free
1097  D = _ChiUp[i].transpose() * D;
1098  i = _parents[i];
1099  }
1100 
1101  // TODO: Only carry out the QR once within update Aritculated Bodies
1102  LambdaInv += D.transpose() * _invIA5.solve(D);
1103 
1104  return LambdaInv;
1105 }
vectorAligned< Mat6< T > > _Xa
typename Eigen::Matrix< T, 6, Eigen::Dynamic > D6Mat
Definition: cppTypes.h:110
Eigen::ColPivHouseholderQR< Mat6< T > > _invIA5
typename Eigen::Matrix< T, 6, 6 > Mat6
Definition: cppTypes.h:70
typename Eigen::Matrix< T, 3, 3 > Mat3
Definition: cppTypes.h:54
typename Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > DMat
Definition: cppTypes.h:106
vectorAligned< Mat6< T > > _ChiUp
vector< Vec3< T > > _gcLocation
vector< int > _parents
auto createSXform(const Eigen::MatrixBase< T > &R, const Eigen::MatrixBase< T2 > &r)
Definition: spatial.h:140
vector< size_t > _gcParent
vectorAligned< SVec< T > > _S
typename Eigen::Matrix< T, Eigen::Dynamic, 1 > DVec
Definition: cppTypes.h:102

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T>
T FloatingBaseModel< T >::invContactInertia ( const int  gc_index,
const Vec3< T > &  force_ics_at_contact 
)

Compute the inverse of the contact inertia matrix (mxm)

Parameters
force_ics_at_contact(3x1) e.g. if you want the cartesian inv. contact inertia in the z_ics force_ics_at_contact = [0 0 1]^T
Returns
the 1x1 inverse contact inertia J H^{-1} J^T

Definition at line 1017 of file FloatingBaseModel.cpp.

References spatial::createSXform().

1018  {
1022 
1023  size_t i_opsp = _gcParent.at(gc_index);
1024  size_t i = i_opsp;
1025 
1026  // Rotation to absolute coords
1027  Mat3<T> Rai = _Xa[i].template block<3, 3>(0, 0).transpose();
1028  Mat6<T> Xc = createSXform(Rai, _gcLocation.at(gc_index));
1029 
1030  // D is one column of an extended force propagator matrix (See Wensing, 2012
1031  // ICRA)
1032  SVec<T> F = Xc.transpose().template rightCols<3>() * force_ics_at_contact;
1033 
1034  double LambdaInv = 0;
1035  double tmp = 0;
1036 
1037  // from tips to base
1038  while (i > 5) {
1039  tmp = F.dot(_S[i]);
1040  LambdaInv += tmp * tmp / _d[i];
1041 
1042  // Apply force propagator (see Pat's ICRA 2012 paper)
1043  // essentially, since the joint is articulated, only a portion of the force
1044  // is felt on the predecessor. So, while Xup^T sends a force backwards as if
1045  // the joint was locked, ChiUp^T sends the force backward as if the joint
1046  // were free
1047  F = _ChiUp[i].transpose() * F;
1048  i = _parents[i];
1049  }
1050  LambdaInv += F.dot(_invIA5.solve(F));
1051  return LambdaInv;
1052 }
vectorAligned< Mat6< T > > _Xa
Eigen::ColPivHouseholderQR< Mat6< T > > _invIA5
typename Eigen::Matrix< T, 6, 6 > Mat6
Definition: cppTypes.h:70
typename Eigen::Matrix< T, 3, 3 > Mat3
Definition: cppTypes.h:54
vectorAligned< Mat6< T > > _ChiUp
typename Eigen::Matrix< T, 6, 1 > SVec
Definition: cppTypes.h:62
vector< Vec3< T > > _gcLocation
vector< int > _parents
auto createSXform(const Eigen::MatrixBase< T > &R, const Eigen::MatrixBase< T2 > &r)
Definition: spatial.h:140
vector< size_t > _gcParent
vectorAligned< SVec< T > > _S

+ Here is the call graph for this function:

template<typename T>
DVec< T > FloatingBaseModel< T >::inverseDynamics ( const FBModelStateDerivative< T > &  dState)

Computes the inverse dynamics of the system

Returns
an _nDof x 1 vector. The first six entries give the external wrengh on the base, with the remaining giving the joint torques

Definition at line 845 of file FloatingBaseModel.cpp.

References spatial::forceCrossProduct().

846  {
847  setDState(dState);
849 
850  // Spatial force for floating base
851  SVec<T> hb = _Ibody[5].getMatrix() * _v[5];
852  _f[5] = _Ibody[5].getMatrix() * _a[5] + forceCrossProduct(_v[5], hb);
853 
854  // loop through joints
855  for (size_t i = 6; i < _nDof; i++) {
856  // spatial momentum
857  SVec<T> hi = _Ibody[i].getMatrix() * _v[i];
858  SVec<T> hr = _Irot[i].getMatrix() * _vrot[i];
859 
860  // spatial force
861  _f[i] = _Ibody[i].getMatrix() * _a[i] + forceCrossProduct(_v[i], hi);
862  _frot[i] =
863  _Irot[i].getMatrix() * _arot[i] + forceCrossProduct(_vrot[i], hr);
864  }
865 
866  DVec<T> genForce(_nDof);
867  for (size_t i = _nDof - 1; i > 5; i--) {
868  // Pull off compoents of force along the joint
869  genForce[i] = _S[i].dot(_f[i]) + _Srot[i].dot(_frot[i]);
870 
871  // Propagate down the tree
872  _f[_parents[i]] += _Xup[i].transpose() * _f[i];
873  _f[_parents[i]] += _Xuprot[i].transpose() * _frot[i];
874  }
875  genForce.template head<6>() = _f[5];
876  return genForce;
877 }
void setDState(const FBModelStateDerivative< T > &dState)
vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > _Ibody
auto forceCrossProduct(const Eigen::MatrixBase< T > &a, const Eigen::MatrixBase< T > &b)
Definition: spatial.h:91
typename Eigen::Matrix< T, 6, 1 > SVec
Definition: cppTypes.h:62
vectorAligned< SVec< T > > _f
vector< int > _parents
vectorAligned< SVec< T > > _a
vectorAligned< SVec< T > > _Srot
vectorAligned< Mat6< T > > _Xuprot
vectorAligned< SVec< T > > _S
vectorAligned< SVec< T > > _vrot
vectorAligned< Mat6< T > > _Xup
vectorAligned< SVec< T > > _frot
vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > _Irot
typename Eigen::Matrix< T, Eigen::Dynamic, 1 > DVec
Definition: cppTypes.h:102
vectorAligned< SVec< T > > _v
vectorAligned< SVec< T > > _arot

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T >
DMat< T > FloatingBaseModel< T >::massMatrix ( )

Computes the Mass Matrix (H) in the inverse dynamics formulation

Returns
H (_nDof x _nDof matrix)

Definition at line 778 of file FloatingBaseModel.cpp.

References f().

778  {
780  _H.setZero();
781 
782  // Top left corner is the locked inertia of the whole system
783  _H.template topLeftCorner<6, 6>() = _IC[5].getMatrix();
784 
785  for (size_t j = 6; j < _nDof; j++) {
786  // f = spatial force required for a unit qdd_j
787  SVec<T> f = _IC[j].getMatrix() * _S[j];
788  SVec<T> frot = _Irot[j].getMatrix() * _Srot[j];
789 
790  _H(j, j) = _S[j].dot(f) + _Srot[j].dot(frot);
791 
792  // Propagate down the tree
793  f = _Xup[j].transpose() * f + _Xuprot[j].transpose() * frot;
794  size_t i = _parents[j];
795  while (i > 5) {
796  // in here f is expressed in frame {i}
797  _H(i, j) = _S[i].dot(f);
798  _H(j, i) = _H(i, j);
799 
800  // Propagate down the tree
801  f = _Xup[i].transpose() * f;
802  i = _parents[i];
803  }
804 
805  // Force on floating base
806  _H.template block<6, 1>(0, j) = f;
807  _H.template block<1, 6>(j, 0) = f.adjoint();
808  }
809  return _H;
810 }
vectorAligned< SpatialInertia< T > > _IC
typename Eigen::Matrix< T, 6, 1 > SVec
Definition: cppTypes.h:62
vector< int > _parents
vectorAligned< SVec< T > > _Srot
vectorAligned< Mat6< T > > _Xuprot
vectorAligned< SVec< T > > _S
vectorAligned< Mat6< T > > _Xup
vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > _Irot
MX f(const MX &x, const MX &u)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T>
void FloatingBaseModel< T >::resetCalculationFlags ( )
inline

Definition at line 199 of file FloatingBaseModel.h.

199  {
201  _kinematicsUpToDate = false;
203  _qddEffectsUpToDate = false;
204  _accelerationsUpToDate = false;
205  }
template<typename T>
void FloatingBaseModel< T >::resetExternalForces ( )
inline

Definition at line 301 of file FloatingBaseModel.h.

301  {
302  for (size_t i = 0; i < _nDof; i++) {
304  }
305  }
vectorAligned< SVec< T > > _externalForces
typename Eigen::Matrix< T, 6, 1 > SVec
Definition: cppTypes.h:62
template<typename T >
void FloatingBaseModel< T >::resizeSystemMatricies ( )

Updates the size of H, C, Cqd, G, and Js when bodies are added

Definition at line 242 of file FloatingBaseModel.cpp.

242  {
243  _H.setZero(_nDof, _nDof);
244  _C.setZero(_nDof, _nDof);
245  _Cqd.setZero(_nDof);
246  _G.setZero(_nDof);
247  for (size_t i = 0; i < _J.size(); i++) {
248  _J[i].setZero(6, _nDof);
249  _Jdqd[i].setZero();
250  }
251 
252  for (size_t i = 0; i < _Jc.size(); i++) {
253  _Jc[i].setZero(3, _nDof);
254  _Jcdqd[i].setZero();
255  }
256  _qdd_from_subqdd.resize(_nDof - 6, _nDof - 6);
257  _qdd_from_base_accel.resize(_nDof - 6, 6);
258  _state.q = DVec<T>::Zero(_nDof - 6);
259  _state.qd = DVec<T>::Zero(_nDof - 6);
260 }
vectorAligned< Vec3< T > > _Jcdqd
vectorAligned< D6Mat< T > > _J
vectorAligned< SVec< T > > _Jdqd
typename Eigen::Matrix< T, Eigen::Dynamic, 1 > DVec
Definition: cppTypes.h:102
vectorAligned< D3Mat< T > > _Jc
FBModelState< T > _state
BEGIN ALGORITHM SUPPORT VARIABLES.
DMat< T > _qdd_from_base_accel
template<typename T>
void FloatingBaseModel< T >::runABA ( const DVec< T > &  tau,
FBModelStateDerivative< T > &  dstate 
)

Definition at line 880 of file FloatingBaseModel.cpp.

References spatial::createSXform(), FBModelStateDerivative< T >::dBodyPosition, FBModelStateDerivative< T >::dBodyVelocity, spatial::forceCrossProduct(), spatial::motionCrossProduct(), FBModelStateDerivative< T >::qdd, spatial::rotationFromSXform(), and spatial::translationFromSXform().

881  {
882  (void)tau;
885 
886  // create spatial vector for gravity
887  SVec<T> aGravity;
888  aGravity << 0, 0, 0, _gravity[0], _gravity[1], _gravity[2];
889 
890  // float-base articulated inertia
891  SVec<T> ivProduct = _Ibody[5].getMatrix() * _v[5];
892  _pA[5] = forceCrossProduct(_v[5], ivProduct);
893 
894  // loop 1, down the tree
895  for (size_t i = 6; i < _nDof; i++) {
896  ivProduct = _Ibody[i].getMatrix() * _v[i];
897  _pA[i] = forceCrossProduct(_v[i], ivProduct);
898 
899  // same for rotors
900  SVec<T> vJrot = _Srot[i] * _state.qd[i - 6];
901  _vrot[i] = _Xuprot[i] * _v[_parents[i]] + vJrot;
902  _crot[i] = motionCrossProduct(_vrot[i], vJrot);
903  ivProduct = _Irot[i].getMatrix() * _vrot[i];
904  _pArot[i] = forceCrossProduct(_vrot[i], ivProduct);
905  }
906 
907  // adjust pA for external forces
908  for (size_t i = 5; i < _nDof; i++) {
909  // TODO add if statement (avoid these calculations if the force is zero)
912  Mat6<T> iX = createSXform(R.transpose(), -R * p);
913  _pA[i] = _pA[i] - iX.transpose() * _externalForces.at(i);
914  }
915 
916  // Pat's magic principle of least constraint
917  for (size_t i = _nDof - 1; i >= 6; i--) {
918  _u[i] = tau[i - 6] - _S[i].transpose() * _pA[i] -
919  _Srot[i].transpose() * _pArot[i] - _U[i].transpose() * _c[i] -
920  _Urot[i].transpose() * _crot[i];
921 
922  // articulated inertia recursion
923  SVec<T> pa =
924  _Xup[i].transpose() * (_pA[i] + _IA[i] * _c[i]) +
925  _Xuprot[i].transpose() * (_pArot[i] + _Irot[i].getMatrix() * _crot[i]) +
926  _Utot[i] * _u[i] / _d[i];
927  _pA[_parents[i]] += pa;
928  }
929 
930  // include gravity and compute acceleration of floating base
931  SVec<T> a0 = -aGravity;
932  SVec<T> ub = -_pA[5];
933  _a[5] = _Xup[5] * a0;
934  SVec<T> afb = _invIA5.solve(ub - _IA[5].transpose() * _a[5]);
935  _a[5] += afb;
936 
937  // joint accelerations
938  dstate.qdd = DVec<T>(_nDof - 6);
939  for (size_t i = 6; i < _nDof; i++) {
940  dstate.qdd[i - 6] =
941  (_u[i] - _Utot[i].transpose() * _a[_parents[i]]) / _d[i];
942  _a[i] = _Xup[i] * _a[_parents[i]] + _S[i] * dstate.qdd[i - 6] + _c[i];
943  }
944 
945  // output
947  dstate.dBodyPosition =
948  Rup.transpose() * _state.bodyVelocity.template block<3, 1>(3, 0);
949  dstate.dBodyVelocity = afb;
950  // qdd is set in the for loop above
951 }
vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > _Ibody
vectorAligned< Mat6< T > > _Xa
auto forceCrossProduct(const Eigen::MatrixBase< T > &a, const Eigen::MatrixBase< T > &b)
Definition: spatial.h:91
Eigen::ColPivHouseholderQR< Mat6< T > > _invIA5
typename Eigen::Matrix< T, 6, 6 > Mat6
Definition: cppTypes.h:70
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Vec3< T > dBodyPosition
vectorAligned< SVec< T > > _c
typename Eigen::Matrix< T, 3, 3 > Mat3
Definition: cppTypes.h:54
vectorAligned< SVec< T > > _externalForces
typename Eigen::Matrix< T, 3, 1 > Vec3
Definition: cppTypes.h:26
auto translationFromSXform(const Eigen::MatrixBase< T > &X)
Definition: spatial.h:168
typename Eigen::Matrix< T, 6, 1 > SVec
Definition: cppTypes.h:62
vector< int > _parents
vectorAligned< SVec< T > > _Utot
vectorAligned< SVec< T > > _a
auto createSXform(const Eigen::MatrixBase< T > &R, const Eigen::MatrixBase< T2 > &r)
Definition: spatial.h:140
vectorAligned< SVec< T > > _Srot
vectorAligned< Mat6< T > > _Xuprot
auto motionCrossProduct(const Eigen::MatrixBase< T > &a, const Eigen::MatrixBase< T > &b)
Definition: spatial.h:73
vectorAligned< SVec< T > > _S
vectorAligned< SVec< T > > _vrot
vectorAligned< Mat6< T > > _Xup
vectorAligned< SVec< T > > _crot
vectorAligned< SVec< T > > _Urot
vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > _Irot
typename Eigen::Matrix< T, Eigen::Dynamic, 1 > DVec
Definition: cppTypes.h:102
vectorAligned< SVec< T > > _U
vectorAligned< SVec< T > > _pA
vectorAligned< SVec< T > > _v
vectorAligned< SVec< T > > _pArot
FBModelState< T > _state
BEGIN ALGORITHM SUPPORT VARIABLES.
typename Eigen::Matrix< T, 3, 3 > RotMat
Definition: cppTypes.h:18
auto rotationFromSXform(const Eigen::MatrixBase< T > &X)
Definition: spatial.h:157
vectorAligned< Mat6< T > > _IA

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T>
void FloatingBaseModel< T >::setContactComputeFlag ( size_t  gc_index,
bool  flag 
)
inline

Definition at line 173 of file FloatingBaseModel.h.

173  {
174  _compute_contact_info[gc_index] = flag;
175  }
vector< bool > _compute_contact_info
template<typename T>
void FloatingBaseModel< T >::setDState ( const FBModelStateDerivative< T > &  dState)
inline

Definition at line 207 of file FloatingBaseModel.h.

207  {
208  _dState = dState;
209  _accelerationsUpToDate = false;
210  }
FBModelStateDerivative< T > _dState
template<typename T>
void FloatingBaseModel< T >::setGravity ( Vec3< T > &  g)
inline

Set the gravity

Definition at line 171 of file FloatingBaseModel.h.

171 { _gravity = g; }

+ Here is the caller graph for this function:

template<typename T>
void FloatingBaseModel< T >::setState ( const FBModelState< T > &  state)
inline

Definition at line 191 of file FloatingBaseModel.h.

191  {
192  _state = state;
193 
196 
198  }
FBModelState< T > _state
BEGIN ALGORITHM SUPPORT VARIABLES.

+ Here is the caller graph for this function:

template<typename T >
T FloatingBaseModel< T >::totalNonRotorMass ( )

Total mass of all bodies which are not rotors

Compute the total mass of bodies which are not rotors.

Returns

Definition at line 452 of file FloatingBaseModel.cpp.

452  {
453  T totalMass = 0;
454  for (size_t i = 0; i < _nDof; i++) {
455  totalMass += _Ibody[i].getMass();
456  }
457  return totalMass;
458 }
vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > _Ibody

+ Here is the caller graph for this function:

template<typename T >
T FloatingBaseModel< T >::totalRotorMass ( )

Total mass of all rotors

Compute the total mass of bodies which are not rotors

Returns

Definition at line 465 of file FloatingBaseModel.cpp.

465  {
466  T totalMass = 0;
467  for (size_t i = 0; i < _nDof; i++) {
468  totalMass += _Irot[i].getMass();
469  }
470  return totalMass;
471 }
vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > _Irot

+ Here is the caller graph for this function:

template<typename T >
void FloatingBaseModel< T >::udpateQddEffects ( )

Support function for contact inertia algorithms Computes the qdd arising from "subqdd" components If you are familiar with Featherstone's sparse Op sp or jain's innovations factorization: H = L * D * L^T These subqdd components represnt the space in the middle i.e. if H^{-1} = L^{-T} * D^{-1} * L^{1} then what I am calling subqdd = L^{-1} * tau This is an awful explanation. It needs latex.

Definition at line 98 of file FloatingBaseModel.cpp.

98  {
99  if (_qddEffectsUpToDate) return;
101  _qdd_from_base_accel.setZero();
102  _qdd_from_subqdd.setZero();
103 
104  // Pass for force props
105  // This loop is semi-equivalent to a cholesky factorization on H
106  // akin to Featherstone's sparse operational space algo
107  // These computations are for treating the joint rates like a task space
108  // To do so, F computes the dynamic effect of torues onto bodies down the tree
109  //
110  for (size_t i = 6; i < _nDof; i++) {
111  _qdd_from_subqdd(i - 6, i - 6) = 1;
112  SVec<T> F = (_ChiUp[i].transpose() - _Xup[i].transpose()) * _S[i];
113  size_t j = _parents[i];
114  while (j > 5) {
115  _qdd_from_subqdd(i - 6, j - 6) = _S[j].dot(F);
116  F = _ChiUp[j].transpose() * F;
117  j = _parents[j];
118  }
119  _qdd_from_base_accel.row(i - 6) = F.transpose();
120  }
121  _qddEffectsUpToDate = true;
122 }
vectorAligned< Mat6< T > > _ChiUp
typename Eigen::Matrix< T, 6, 1 > SVec
Definition: cppTypes.h:62
vector< int > _parents
vectorAligned< SVec< T > > _S
vectorAligned< Mat6< T > > _Xup
DMat< T > _qdd_from_base_accel
template<typename T >
void FloatingBaseModel< T >::updateArticulatedBodies ( )

Support function for the ABA

Definition at line 142 of file FloatingBaseModel.cpp.

References spatial::jointXform().

142  {
143  if (_articulatedBodiesUpToDate) return;
144 
146 
147  _IA[5] = _Ibody[5].getMatrix();
148 
149  // loop 1, down the tree
150  for (size_t i = 6; i < _nDof; i++) {
151  _IA[i] = _Ibody[i].getMatrix(); // initialize
152  Mat6<T> XJrot = jointXform(_jointTypes[i], _jointAxes[i],
153  _state.q[i - 6] * _gearRatios[i]);
154  _Xuprot[i] = XJrot * _Xrot[i];
155  _Srot[i] = _S[i] * _gearRatios[i];
156  }
157 
158  // Pat's magic principle of least constraint (Guass too!)
159  for (size_t i = _nDof - 1; i >= 6; i--) {
160  _U[i] = _IA[i] * _S[i];
161  _Urot[i] = _Irot[i].getMatrix() * _Srot[i];
162  _Utot[i] = _Xup[i].transpose() * _U[i] + _Xuprot[i].transpose() * _Urot[i];
163 
164  _d[i] = _Srot[i].transpose() * _Urot[i];
165  _d[i] += _S[i].transpose() * _U[i];
166 
167  // articulated inertia recursion
168  Mat6<T> Ia = _Xup[i].transpose() * _IA[i] * _Xup[i] +
169  _Xuprot[i].transpose() * _Irot[i].getMatrix() * _Xuprot[i] -
170  _Utot[i] * _Utot[i].transpose() / _d[i];
171  _IA[_parents[i]] += Ia;
172  }
173 
174  _invIA5.compute(_IA[5]);
176 }
vector< Mat6< T >, Eigen::aligned_allocator< Mat6< T > > > _Xrot
vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > _Ibody
vector< CoordinateAxis > _jointAxes
Eigen::ColPivHouseholderQR< Mat6< T > > _invIA5
typename Eigen::Matrix< T, 6, 6 > Mat6
Definition: cppTypes.h:70
Mat6< T > jointXform(JointType joint, CoordinateAxis axis, T q)
Definition: spatial.h:219
vector< int > _parents
vectorAligned< SVec< T > > _Utot
vectorAligned< SVec< T > > _Srot
vectorAligned< Mat6< T > > _Xuprot
vectorAligned< SVec< T > > _S
vectorAligned< Mat6< T > > _Xup
vectorAligned< SVec< T > > _Urot
vector< SpatialInertia< T >, Eigen::aligned_allocator< SpatialInertia< T > > > _Irot
vectorAligned< SVec< T > > _U
FBModelState< T > _state
BEGIN ALGORITHM SUPPORT VARIABLES.
vectorAligned< Mat6< T > > _IA
vector< JointType > _jointTypes

+ Here is the call graph for this function:

template<typename T >
void FloatingBaseModel< T >::updateForcePropagators ( )

Support function for contact inertia algorithms Comptues force propagators across each joint

Definition at line 129 of file FloatingBaseModel.cpp.

129  {
130  if (_forcePropagatorsUpToDate) return;
132  for (size_t i = 6; i < _nDof; i++) {
133  _ChiUp[i] = _Xup[i] - _S[i] * _Utot[i].transpose() / _d[i];
134  }
136 }
vectorAligned< Mat6< T > > _ChiUp
vectorAligned< SVec< T > > _Utot
vectorAligned< SVec< T > > _S
vectorAligned< Mat6< T > > _Xup

Member Data Documentation

template<typename T>
vectorAligned<SVec<T> > FloatingBaseModel< T >::_a

Definition at line 273 of file FloatingBaseModel.h.

template<typename T>
bool FloatingBaseModel< T >::_accelerationsUpToDate = false

Definition at line 293 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<SVec<T> > FloatingBaseModel< T >::_ag

Definition at line 273 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<SVec<T> > FloatingBaseModel< T >::_agrot

Definition at line 273 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<SVec<T> > FloatingBaseModel< T >::_arot

Definition at line 273 of file FloatingBaseModel.h.

template<typename T>
bool FloatingBaseModel< T >::_articulatedBodiesUpToDate = false

Definition at line 307 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<SVec<T> > FloatingBaseModel< T >::_avp

Definition at line 273 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<SVec<T> > FloatingBaseModel< T >::_avprot

Definition at line 273 of file FloatingBaseModel.h.

template<typename T>
bool FloatingBaseModel< T >::_biasAccelerationsUpToDate = false

Definition at line 292 of file FloatingBaseModel.h.

template<typename T>
vector<std::string> FloatingBaseModel< T >::_bodyNames

Definition at line 249 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<SVec<T> > FloatingBaseModel< T >::_c

Definition at line 273 of file FloatingBaseModel.h.

template<typename T>
DMat<T> FloatingBaseModel< T >::_C

Definition at line 282 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<Mat6<T> > FloatingBaseModel< T >::_ChiUp

Definition at line 280 of file FloatingBaseModel.h.

template<typename T>
bool FloatingBaseModel< T >::_compositeInertiasUpToDate = false

Definition at line 295 of file FloatingBaseModel.h.

template<typename T>
vector<bool> FloatingBaseModel< T >::_compute_contact_info

Definition at line 259 of file FloatingBaseModel.h.

template<typename T>
DVec<T> FloatingBaseModel< T >::_Cqd

Definition at line 283 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<SVec<T> > FloatingBaseModel< T >::_crot

Definition at line 273 of file FloatingBaseModel.h.

template<typename T>
vector<T> FloatingBaseModel< T >::_d

Definition at line 242 of file FloatingBaseModel.h.

template<typename T>
FBModelStateDerivative<T> FloatingBaseModel< T >::_dState

Definition at line 271 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<SVec<T> > FloatingBaseModel< T >::_externalForces

Definition at line 277 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<SVec<T> > FloatingBaseModel< T >::_f

Definition at line 273 of file FloatingBaseModel.h.

template<typename T>
vector<uint64_t> FloatingBaseModel< T >::_footIndicesGC

Definition at line 254 of file FloatingBaseModel.h.

template<typename T>
bool FloatingBaseModel< T >::_forcePropagatorsUpToDate = false

Definition at line 308 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<SVec<T> > FloatingBaseModel< T >::_frot

Definition at line 273 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<SVec<T> > FloatingBaseModel< T >::_fvp

Definition at line 273 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<SVec<T> > FloatingBaseModel< T >::_fvprot

Definition at line 273 of file FloatingBaseModel.h.

template<typename T>
DVec<T> FloatingBaseModel< T >::_G

Definition at line 283 of file FloatingBaseModel.h.

template<typename T>
vector<Vec3<T> > FloatingBaseModel< T >::_gcLocation

Definition at line 253 of file FloatingBaseModel.h.

template<typename T>
vector<size_t> FloatingBaseModel< T >::_gcParent

Definition at line 252 of file FloatingBaseModel.h.

template<typename T>
vector<T> FloatingBaseModel< T >::_gearRatios

Definition at line 241 of file FloatingBaseModel.h.

template<typename T>
Vec3<T> FloatingBaseModel< T >::_gravity

Definition at line 239 of file FloatingBaseModel.h.

template<typename T>
DMat<T> FloatingBaseModel< T >::_H

Definition at line 282 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<Mat6<T> > FloatingBaseModel< T >::_IA

Definition at line 280 of file FloatingBaseModel.h.

template<typename T>
vector<SpatialInertia<T>, Eigen::aligned_allocator<SpatialInertia<T> > > FloatingBaseModel< T >::_Ibody

Definition at line 247 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<SpatialInertia<T> > FloatingBaseModel< T >::_IC

Definition at line 279 of file FloatingBaseModel.h.

template<typename T>
Eigen::ColPivHouseholderQR<Mat6<T> > FloatingBaseModel< T >::_invIA5

Definition at line 313 of file FloatingBaseModel.h.

template<typename T>
vector<SpatialInertia<T>, Eigen::aligned_allocator<SpatialInertia<T> > > FloatingBaseModel< T >::_Irot

Definition at line 247 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<D6Mat<T> > FloatingBaseModel< T >::_J

Definition at line 285 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<D3Mat<T> > FloatingBaseModel< T >::_Jc

Definition at line 288 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<Vec3<T> > FloatingBaseModel< T >::_Jcdqd

Definition at line 289 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<SVec<T> > FloatingBaseModel< T >::_Jdqd

Definition at line 286 of file FloatingBaseModel.h.

template<typename T>
vector<CoordinateAxis> FloatingBaseModel< T >::_jointAxes

Definition at line 245 of file FloatingBaseModel.h.

template<typename T>
vector<JointType> FloatingBaseModel< T >::_jointTypes

Definition at line 244 of file FloatingBaseModel.h.

template<typename T>
bool FloatingBaseModel< T >::_kinematicsUpToDate = false

Definition at line 291 of file FloatingBaseModel.h.

template<typename T>
size_t FloatingBaseModel< T >::_nDof = 0

Definition at line 238 of file FloatingBaseModel.h.

template<typename T>
size_t FloatingBaseModel< T >::_nGroundContact = 0

Definition at line 251 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<SVec<T> > FloatingBaseModel< T >::_pA

Definition at line 276 of file FloatingBaseModel.h.

template<typename T>
vector<int> FloatingBaseModel< T >::_parents

Definition at line 240 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<SVec<T> > FloatingBaseModel< T >::_pArot

Definition at line 276 of file FloatingBaseModel.h.

template<typename T>
vector<Vec3<T> > FloatingBaseModel< T >::_pGC

Definition at line 256 of file FloatingBaseModel.h.

template<typename T>
DMat<T> FloatingBaseModel< T >::_qdd_from_base_accel

Definition at line 311 of file FloatingBaseModel.h.

template<typename T>
DMat<T> FloatingBaseModel< T >::_qdd_from_subqdd

Definition at line 312 of file FloatingBaseModel.h.

template<typename T>
bool FloatingBaseModel< T >::_qddEffectsUpToDate = false

Definition at line 309 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<SVec<T> > FloatingBaseModel< T >::_S

Definition at line 273 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<SVec<T> > FloatingBaseModel< T >::_Srot

Definition at line 273 of file FloatingBaseModel.h.

template<typename T>
FBModelState<T> FloatingBaseModel< T >::_state

BEGIN ALGORITHM SUPPORT VARIABLES.

Definition at line 270 of file FloatingBaseModel.h.

template<typename T>
vector<T> FloatingBaseModel< T >::_u

Definition at line 242 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<SVec<T> > FloatingBaseModel< T >::_U

Definition at line 276 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<SVec<T> > FloatingBaseModel< T >::_Urot

Definition at line 276 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<SVec<T> > FloatingBaseModel< T >::_Utot

Definition at line 276 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<SVec<T> > FloatingBaseModel< T >::_v

Definition at line 273 of file FloatingBaseModel.h.

template<typename T>
vector<Vec3<T> > FloatingBaseModel< T >::_vGC

Definition at line 257 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<SVec<T> > FloatingBaseModel< T >::_vrot

Definition at line 273 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<Mat6<T> > FloatingBaseModel< T >::_Xa

Definition at line 280 of file FloatingBaseModel.h.

template<typename T>
vector<Mat6<T>, Eigen::aligned_allocator<Mat6<T> > > FloatingBaseModel< T >::_Xrot

Definition at line 246 of file FloatingBaseModel.h.

template<typename T>
vector<Mat6<T>, Eigen::aligned_allocator<Mat6<T> > > FloatingBaseModel< T >::_Xtree

Definition at line 246 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<Mat6<T> > FloatingBaseModel< T >::_Xup

Definition at line 280 of file FloatingBaseModel.h.

template<typename T>
vectorAligned<Mat6<T> > FloatingBaseModel< T >::_Xuprot

Definition at line 280 of file FloatingBaseModel.h.


The documentation for this class was generated from the following files: