- 3.0.2 rigid body dynamics module.
RBDAcceleration.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 #include "JointAcceleration.h"
9 #include "RBDState.h"
10 #include "RigidBodyAcceleration.h"
11 
12 namespace ct {
13 namespace rbd {
14 
22 template <size_t NJOINTS, typename SCALAR = double>
24 {
25 public:
26  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
27 
28  enum DIMS
29  {
30  NDOF = NJOINTS + 6,
31  NSTATE = 2 * NDOF
32 
33  };
34 
35  typedef Eigen::Matrix<SCALAR, NDOF, 1> coordinate_vector_t;
36 
38 
39 
41  RBDAcceleration(const RigidBodyAcceleration_t& baseStateDerivative,
42  const JointAcceleration<NJOINTS, SCALAR>& jointStateDerivative)
43  : baseStateDerivative_(baseStateDerivative), jointStateDerivative_(jointStateDerivative)
44  {
45  }
46 
48  RigidBodyAcceleration_t& base() { return baseStateDerivative_; }
50  const RigidBodyAcceleration_t& base() const { return baseStateDerivative_; }
56  const RBDState<NJOINTS, SCALAR>& state) const
57  {
58  typename RBDState<NJOINTS, SCALAR>::state_vector_quat_t stateDerivative;
59 
60  kindr::RotationQuaternionDiff<SCALAR> rotationQuaternionDiff(
61  state.basePose().getRotationQuaternion(), state.baseLocalAngularVelocity());
62 
63  stateDerivative << rotationQuaternionDiff.w(), rotationQuaternionDiff.x(), rotationQuaternionDiff.y(),
64  rotationQuaternionDiff.z(), state.base().computeTranslationalVelocityW().toImplementation(),
65  state.joints().getVelocities(), base().getAngularAcceleration().toImplementation(),
66  base().getTranslationalAcceleration().toImplementation(), joints().getAcceleration();
67 
68  return stateDerivative;
69  }
70 
72  const RBDState<NJOINTS, SCALAR>& state) const
73  {
74  typename RBDState<NJOINTS, SCALAR>::state_vector_euler_t stateDerivative;
75 
76  kindr::EulerAnglesXyzDiff<SCALAR> eulerAnglesXyzDiff(
77  state.basePose().getEulerAnglesXyz(), state.baseLocalAngularVelocity());
78 
79  stateDerivative << eulerAnglesXyzDiff.toImplementation(),
80  state.base().computeTranslationalVelocityW().toImplementation(), state.joints().getVelocities(),
81  base().getAngularAcceleration().toImplementation(),
82  base().getTranslationalAcceleration().toImplementation(), joints().getAcceleration();
83 
84  return stateDerivative;
85  }
86 
87  coordinate_vector_t toCoordinateAcceleration() const
88  {
89  coordinate_vector_t ddq;
90  ddq << base().getAngularAcceleration().toImplementation(),
91  base().getTranslationalAcceleration().toImplementation(), joints().getAcceleration();
92  return ddq;
93  }
94 
95  void setZero()
96  {
98  jointStateDerivative_.setZero();
99  }
100 
102  {
105  }
106 
107 protected:
108  RigidBodyAcceleration_t baseStateDerivative_;
110 };
111 
112 } // namespace rbd
113 } // namespace ct
position/velocity of (joints + base)
Definition: RBDAcceleration.h:31
static JointAcceleration< NJOINTS, SCALAR > Zero()
Definition: JointAcceleration.h:43
RBDAcceleration(const RigidBodyAcceleration_t &baseStateDerivative, const JointAcceleration< NJOINTS, SCALAR > &jointStateDerivative)
Definition: RBDAcceleration.h:41
RigidBodyPose_t & basePose()
get base pose
Definition: RBDState.h:67
void setZero()
set acceleration to zero
Definition: RigidBodyAcceleration.h:69
RigidBodyState_t & base()
get base states
Definition: RBDState.h:63
coordinate_vector_t toCoordinateAcceleration() const
Definition: RBDAcceleration.h:87
AngularAcceleration & getAngularAcceleration()
get angular acceleration
Definition: RigidBodyAcceleration.h:53
const JointAcceleration< NJOINTS, SCALAR > & joints() const
get constant joint acceleration
Definition: RBDAcceleration.h:54
JointAcceleration< NJOINTS, SCALAR > & joints()
get joint acceleration
Definition: RBDAcceleration.h:52
joint states and base states
Definition: RBDState.h:27
static RigidBodyAcceleration Zero()
Definition: RigidBodyAcceleration.h:76
joint acceleration
Definition: JointAcceleration.h:17
Eigen::Matrix< SCALAR, NDOF, 1 > coordinate_vector_t
Definition: RBDAcceleration.h:35
RigidBodyAcceleration_t baseStateDerivative_
Definition: RBDAcceleration.h:108
const RigidBodyAcceleration_t & base() const
get constant base acceleration
Definition: RBDAcceleration.h:50
JointAcceleration< NJOINTS, SCALAR > jointStateDerivative_
Definition: RBDAcceleration.h:109
RBDAcceleration()
Definition: RBDAcceleration.h:40
Definition: RBDAcceleration.h:30
joint acceleration and base acceleration
Definition: RBDAcceleration.h:23
acceleration of a rigid body
Definition: RigidBodyAcceleration.h:20
LinearAcceleration & getTranslationalAcceleration()
get translatory acceleration
Definition: RigidBodyAcceleration.h:49
kindr::LocalAngularVelocity< SCALAR > & baseLocalAngularVelocity()
get base local angular velocity
Definition: RBDState.h:75
RBDState< NJOINTS, SCALAR >::state_vector_euler_t toStateUpdateVectorEulerXyz(const RBDState< NJOINTS, SCALAR > &state) const
Definition: RBDAcceleration.h:71
void setZero()
Definition: RBDAcceleration.h:95
static RBDAcceleration< NJOINTS, SCALAR > Zero()
Definition: RBDAcceleration.h:101
DIMS
Definition: RBDAcceleration.h:28
JointState< NJOINTS, SCALAR > & joints()
get joint states
Definition: RBDState.h:94
RigidBodyAcceleration_t & base()
get base acceleration
Definition: RBDAcceleration.h:48
tpl::RigidBodyAcceleration< SCALAR > RigidBodyAcceleration_t
Definition: RBDAcceleration.h:37
RBDState< NJOINTS, SCALAR >::state_vector_quat_t toStateUpdateVectorQuaternion(const RBDState< NJOINTS, SCALAR > &state) const
Definition: RBDAcceleration.h:55