- 3.0.2 rigid body dynamics module.
RobCoGenContainer.h
Go to the documentation of this file.
1 /**********************************************************************************************************************
2 This file is part of the Control Toolbox (https://github.com/ethz-adrl/control-toolbox), copyright by ETH Zurich.
3 Licensed under the BSD-2 license (see LICENSE file in main directory)
4 **********************************************************************************************************************/
5 
6 #pragma once
7 
8 #pragma GCC diagnostic push
9 #pragma GCC diagnostic ignored "-Wunused-parameter"
10 #pragma GCC diagnostic ignored "-Wunused-value"
11 #include <kindr/Core>
12 #pragma GCC diagnostic pop
13 
15 
16 namespace ct {
17 namespace rbd {
18 
22 template <class RBDTrait, template <typename> class LinkDataMapT, class U>
24 {
25 public:
26  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
27 
29  : homogeneousTransforms_(),
30  motionTransforms_(),
31  forceTransforms_(),
32  jacobians_(),
33  inertiaProperties_(),
34  jSim_(inertiaProperties_, forceTransforms_),
35  forwardDynamics_(inertiaProperties_, motionTransforms_),
36  inverseDynamics_(inertiaProperties_, motionTransforms_){};
37 
38  typedef typename RBDTrait::S SCALAR;
39 
40  typedef RBDTrait TRAIT;
41 
42  typedef U UTILS;
43 
44  static const size_t NJOINTS = RBDTrait::joints_count;
45  static const size_t NLINKS = RBDTrait::links_count;
46 
48  typedef std::shared_ptr<specialized_t> Ptr_t;
49 
50  typedef typename RBDTrait::HomogeneousTransforms HomogeneousTransforms;
51  typedef typename RBDTrait::MotionTransforms MotionTransforms;
52  typedef typename RBDTrait::ForceTransforms ForceTransforms;
53  typedef typename RBDTrait::Jacobians Jacobians;
55  typedef typename RBDTrait::JSIM JSIM;
56  typedef typename RBDTrait::FwdDynEngine ForwardDynamics;
57  typedef typename RBDTrait::InvDynEngine InverseDynamics;
58  typedef typename RBDTrait::LinkID LinkIdentifiers;
59 
60  typedef LinkDataMapT<Eigen::Matrix<SCALAR, 6, 1>> LinkForceMap;
61 
62  typedef Eigen::Matrix<SCALAR, 4, 4> HomogeneousTransform;
63  typedef Eigen::Matrix<SCALAR, 6, 6> ForceTransform;
64  typedef Eigen::Matrix<SCALAR, 6, NJOINTS> Jacobian;
65  typedef Eigen::Matrix<SCALAR, 3, 3> Matrix3Tpl;
66 
67  typedef kindr::Position<SCALAR, 3> Position3Tpl;
68  typedef Eigen::Matrix<SCALAR, 3, 1> Vector3Tpl;
69 
71 
72 
73  HomogeneousTransforms& homogeneousTransforms() { return homogeneousTransforms_; };
74  const HomogeneousTransforms& homogeneousTransforms() const { return homogeneousTransforms_; };
75  MotionTransforms& motionTransforms() { return motionTransforms_; };
76  const MotionTransforms& motionTransforms() const { return motionTransforms_; };
77  ForceTransforms& forceTransforms() { return forceTransforms_; };
78  const ForceTransforms& forceTransforms() const { return forceTransforms_; };
79  Jacobians& jacobians() { return jacobians_; };
80  const Jacobians& jacobians() const { return jacobians_; };
81  InertiaProperties& inertiaProperties() { return inertiaProperties_; };
82  const InertiaProperties& inertiaProperties() const { return inertiaProperties_; };
83  JSIM& jSim() { return jSim_; }
84  const JSIM& jSim() const { return jSim_; }
85  ForwardDynamics& forwardDynamics() { return forwardDynamics_; };
86  const ForwardDynamics& forwardDynamics() const { return forwardDynamics_; };
87  InverseDynamics& inverseDynamics() { return inverseDynamics_; };
88  const InverseDynamics& inverseDynamics() const { return inverseDynamics_; };
100  HomogeneousTransform getHomogeneousTransformBaseLinkById(size_t linkId,
101  const typename JointState<NJOINTS, SCALAR>::Position& jointPosition)
102  {
103  return UTILS::getTransformBaseLinkById(homogeneousTransforms(), linkId, jointPosition);
104  }
105 
117  ForceTransform getForceTransformLinkBaseById(size_t linkId,
118  const typename JointState<NJOINTS, SCALAR>::Position& jointPosition)
119  {
120  return UTILS::getTransformLinkBaseById(forceTransforms(), linkId, jointPosition);
121  }
122 
134  HomogeneousTransform getHomogeneousTransformBaseEEById(size_t eeId,
135  const typename JointState<NJOINTS, SCALAR>::Position& jointPosition)
136  {
137  return UTILS::getTransformBaseEEById(homogeneousTransforms(), eeId, jointPosition);
138  }
139 
140 
147  Jacobian getJacobianBaseEEbyId(size_t eeId, const typename JointState<NJOINTS, SCALAR>::Position& jointPosition)
148  {
149  return UTILS::getJacobianBaseEEbyId(jacobians(), eeId, jointPosition);
150  }
151 
152  // /**
153  // * \brief Get a force transformation from base to an endeffector provided an endeffector id
154  // *
155  // * The force transform converts a torque-force vector expressed in the base and converts it to the end-effector frame, i.e.
156  // * \f$ {_EEx} = T_{EE-B} {_Bx} \f$
157  // * The endeffector frame corresponds to the convention used when creating the RobCoGen code.
158  // *
159  // * @param eeId End-effector ID
160  // * @param jointPosition Joint angles/positions
161  // * @return Homogeneous transformation from base to endeffector \f$ T_{EE-B} \f$
162  // */
163  // ForceTransform getForceTransformEEBaseById(size_t eeId, const typename JointState<NJOINTS>::Position& jointPosition);
164 
172  Position3Tpl getEEPositionInBase(size_t eeId, const typename JointState<NJOINTS, SCALAR>::Position& jointPosition)
173  {
174  return Position3Tpl(getHomogeneousTransformBaseEEById(eeId, jointPosition).template topRightCorner<3, 1>());
175  }
176 
186  const typename JointState<NJOINTS, SCALAR>::Position& jointPosition,
188  {
189  // construct the rigid body pose from a homogeneous transformation matrix
190  RigidBodyPoseTpl pose(getHomogeneousTransformBaseEEById(eeId, jointPosition), storage);
191  return pose;
192  }
193 
197  Matrix3Tpl getEERotInBase(size_t eeId, const typename JointState<NJOINTS, SCALAR>::Position& jointPosition)
198  {
199  return getHomogeneousTransformBaseEEById(eeId, jointPosition).template topLeftCorner<3, 3>();
200  }
201 
202 
203 private:
204  HomogeneousTransforms homogeneousTransforms_;
205  MotionTransforms motionTransforms_;
206  ForceTransforms forceTransforms_;
207  Jacobians jacobians_;
208  InertiaProperties inertiaProperties_;
209  JSIM jSim_;
210  ForwardDynamics forwardDynamics_;
211  InverseDynamics inverseDynamics_;
212 };
213 
214 
215 } // namespace rbd
216 } // namespace ct
RBDTrait::Jacobians Jacobians
Definition: RobCoGenContainer.h:53
RBDTrait::MotionTransforms MotionTransforms
Definition: RobCoGenContainer.h:51
static const size_t NJOINTS
Definition: RobCoGenContainer.h:44
STORAGE_TYPE
the orientation can either be stored as EulerAngles or as quaternion.
Definition: RigidBodyPose.h:38
RobCoGenContainer< RBDTrait, LinkDataMapT, UTILS > specialized_t
Definition: RobCoGenContainer.h:47
ForwardDynamics & forwardDynamics()
Definition: RobCoGenContainer.h:85
RBDTrait::HomogeneousTransforms HomogeneousTransforms
Definition: RobCoGenContainer.h:50
Eigen::Matrix< SCALAR, 4, 4 > HomogeneousTransform
Definition: RobCoGenContainer.h:62
Matrix3Tpl getEERotInBase(size_t eeId, const typename JointState< NJOINTS, SCALAR >::Position &jointPosition)
Definition: RobCoGenContainer.h:197
size_t eeId
Definition: rbdJITtests.h:24
const InverseDynamics & inverseDynamics() const
Definition: RobCoGenContainer.h:88
MotionTransforms & motionTransforms()
Definition: RobCoGenContainer.h:75
Pose of a single rigid body.
Definition: RigidBodyPose.h:29
JSIM & jSim()
Definition: RobCoGenContainer.h:83
tpl::JSIM< rbd::DoubleTrait > JSIM
Definition: jsim.h:154
joint state and joint velocity
Definition: JointState.h:21
tpl::InertiaProperties< rbd::DoubleTrait > InertiaProperties
Definition: inertia_properties.h:273
EIGEN_MAKE_ALIGNED_OPERATOR_NEW RobCoGenContainer()
Definition: RobCoGenContainer.h:28
InverseDynamics & inverseDynamics()
Definition: RobCoGenContainer.h:87
const JSIM & jSim() const
Definition: RobCoGenContainer.h:84
RBDTrait::JSIM JSIM
Definition: RobCoGenContainer.h:55
Position3Tpl getEEPositionInBase(size_t eeId, const typename JointState< NJOINTS, SCALAR >::Position &jointPosition)
Get a force transformation from base to an endeffector provided an endeffector id.
Definition: RobCoGenContainer.h:172
std::shared_ptr< specialized_t > Ptr_t
Definition: RobCoGenContainer.h:48
U UTILS
Definition: RobCoGenContainer.h:42
Eigen::Matrix< SCALAR, 3, 3 > Matrix3Tpl
Definition: RobCoGenContainer.h:65
RBDTrait::LinkID LinkIdentifiers
Definition: RobCoGenContainer.h:58
ForceTransform getForceTransformLinkBaseById(size_t linkId, const typename JointState< NJOINTS, SCALAR >::Position &jointPosition)
Get a force transformation from link to base provided a link id.
Definition: RobCoGenContainer.h:117
Eigen::Matrix< SCALAR, 3, 1 > Vector3Tpl
Definition: RobCoGenContainer.h:68
HomogeneousTransform getHomogeneousTransformBaseLinkById(size_t linkId, const typename JointState< NJOINTS, SCALAR >::Position &jointPosition)
Get a homogeneous transformation from link to base provided a link id.
Definition: RobCoGenContainer.h:100
LinkDataMapT< Eigen::Matrix< SCALAR, 6, 1 > > LinkForceMap
Definition: RobCoGenContainer.h:60
InertiaProperties & inertiaProperties()
Definition: RobCoGenContainer.h:81
RBDTrait::FwdDynEngine ForwardDynamics
Definition: RobCoGenContainer.h:56
const Jacobians & jacobians() const
Definition: RobCoGenContainer.h:80
Container class containing all robcogen classes.
Definition: RobCoGenContainer.h:23
Definition: RigidBodyPose.h:41
Jacobian getJacobianBaseEEbyId(size_t eeId, const typename JointState< NJOINTS, SCALAR >::Position &jointPosition)
Get the end-effector Jacobian expressed in the base frame.
Definition: RobCoGenContainer.h:147
Jacobians & jacobians()
Definition: RobCoGenContainer.h:79
static const size_t NLINKS
Definition: RobCoGenContainer.h:45
RBDTrait::ForceTransforms ForceTransforms
Definition: RobCoGenContainer.h:52
RBDTrait::InvDynEngine InverseDynamics
Definition: RobCoGenContainer.h:57
kindr::Position< SCALAR, 3 > Position3Tpl
Definition: RobCoGenContainer.h:67
Eigen::Matrix< SCALAR, 6, NJOINTS > Jacobian
Definition: RobCoGenContainer.h:64
RBDTrait::S SCALAR
Definition: RobCoGenContainer.h:36
RBDTrait TRAIT
Definition: RobCoGenContainer.h:40
const HomogeneousTransforms & homogeneousTransforms() const
Definition: RobCoGenContainer.h:74
HomogeneousTransforms & homogeneousTransforms()
Definition: RobCoGenContainer.h:73
RigidBodyPoseTpl getEEPoseInBase(size_t eeId, const typename JointState< NJOINTS, SCALAR >::Position &jointPosition, typename RigidBodyPoseTpl::STORAGE_TYPE storage=RigidBodyPoseTpl::EULER)
Get the endeffector pose expressed in the base frame.
Definition: RobCoGenContainer.h:185
const ForceTransforms & forceTransforms() const
Definition: RobCoGenContainer.h:78
const ForwardDynamics & forwardDynamics() const
Definition: RobCoGenContainer.h:86
HomogeneousTransform getHomogeneousTransformBaseEEById(size_t eeId, const typename JointState< NJOINTS, SCALAR >::Position &jointPosition)
Get a homogeneous transformation from base to an endeffector provided an endeffector id...
Definition: RobCoGenContainer.h:134
Eigen::Matrix< SCALAR, 6, 6 > ForceTransform
Definition: RobCoGenContainer.h:63
RBDTrait::InertiaProperties InertiaProperties
Definition: RobCoGenContainer.h:54
const MotionTransforms & motionTransforms() const
Definition: RobCoGenContainer.h:76
ForceTransforms & forceTransforms()
Definition: RobCoGenContainer.h:77
const InertiaProperties & inertiaProperties() const
Definition: RobCoGenContainer.h:82