- 3.0.2 rigid body dynamics module.
RigidBodyAcceleration.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 namespace ct {
9 namespace rbd {
10 namespace tpl {
11 
19 template <typename SCALAR>
21 {
22 public:
23  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
24 
25  typedef kindr::Acceleration<SCALAR, 3> LinearAcceleration;
26  typedef kindr::AngularAcceleration<SCALAR, 3> AngularAcceleration;
27 
29  RigidBodyAcceleration(LinearAcceleration& transAcceleration, AngularAcceleration& anglAcceleration)
30  : anglAcceleration_(anglAcceleration), transAcceleration_(transAcceleration)
31  {
32  }
33 
34  RigidBodyAcceleration(const Eigen::Matrix<SCALAR, 6, 1>& in) { fromVector6d(in); }
35  void fromVector6d(const Eigen::Matrix<SCALAR, 6, 1>& in)
36  {
37  anglAcceleration_ << in.template head<3>();
38  transAcceleration_ << in.template tail<3>();
39  }
40 
41  const Eigen::Matrix<SCALAR, 6, 1> getVector6d() const
42  {
43  Eigen::Matrix<SCALAR, 6, 1> vector6;
44  vector6 << anglAcceleration_.toImplementation(), transAcceleration_.toImplementation();
45  return vector6;
46  }
47 
49  LinearAcceleration& getTranslationalAcceleration() { return transAcceleration_; }
51  const LinearAcceleration& getTranslationalAcceleration() const { return transAcceleration_; }
53  AngularAcceleration& getAngularAcceleration() { return anglAcceleration_; }
55  const AngularAcceleration& getAngularAcceleration() const { return anglAcceleration_; }
57  Eigen::Matrix<SCALAR, 6, 1> accelerations()
58  {
59  Eigen::Matrix<SCALAR, 6, 1> out;
60  out << anglAcceleration_.toImplementation(), transAcceleration_.toImplementation();
61  return out;
62  }
63 
65  void setTranslatoryAcceleration(LinearAcceleration& transAcceleration) { transAcceleration_ = transAcceleration; }
67  void setAngularAcceleration(AngularAcceleration& anglAcceleration) { anglAcceleration_ = anglAcceleration; }
69  void setZero()
70  {
71  // cannot use .setZero() from members here due to codegen
74  }
75 
77  {
79  state.setZero();
80  return state;
81  }
82 
83 protected:
84  AngularAcceleration anglAcceleration_;
85  LinearAcceleration transAcceleration_;
86 };
87 
88 } // namespace tpl
89 
90 // convenience typedef (required)
92 
93 } // namespace rbd
94 } // namespace ct
RigidBodyAcceleration()
Definition: RigidBodyAcceleration.h:28
void setZero()
set acceleration to zero
Definition: RigidBodyAcceleration.h:69
AngularAcceleration & getAngularAcceleration()
get angular acceleration
Definition: RigidBodyAcceleration.h:53
LinearAcceleration transAcceleration_
Definition: RigidBodyAcceleration.h:85
void setAngularAcceleration(AngularAcceleration &anglAcceleration)
set angular acceleration
Definition: RigidBodyAcceleration.h:67
static RigidBodyAcceleration Zero()
Definition: RigidBodyAcceleration.h:76
const AngularAcceleration & getAngularAcceleration() const
get constant angular acceleration
Definition: RigidBodyAcceleration.h:55
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef kindr::Acceleration< SCALAR, 3 > LinearAcceleration
Definition: RigidBodyAcceleration.h:25
CppAD::AD< CppAD::cg::CG< double > > SCALAR
kindr::AngularAcceleration< SCALAR, 3 > AngularAcceleration
Definition: RigidBodyAcceleration.h:26
Eigen::Matrix< SCALAR, 6, 1 > accelerations()
get accelerations as a "Twist"
Definition: RigidBodyAcceleration.h:57
AngularAcceleration anglAcceleration_
Definition: RigidBodyAcceleration.h:84
RigidBodyAcceleration(const Eigen::Matrix< SCALAR, 6, 1 > &in)
Definition: RigidBodyAcceleration.h:34
acceleration of a rigid body
Definition: RigidBodyAcceleration.h:20
LinearAcceleration & getTranslationalAcceleration()
get translatory acceleration
Definition: RigidBodyAcceleration.h:49
RigidBodyAcceleration(LinearAcceleration &transAcceleration, AngularAcceleration &anglAcceleration)
Definition: RigidBodyAcceleration.h:29
const LinearAcceleration & getTranslationalAcceleration() const
get constant translatory acceleration
Definition: RigidBodyAcceleration.h:51
void setTranslatoryAcceleration(LinearAcceleration &transAcceleration)
set translatory acceleration
Definition: RigidBodyAcceleration.h:65
const Eigen::Matrix< SCALAR, 6, 1 > getVector6d() const
Definition: RigidBodyAcceleration.h:41
void fromVector6d(const Eigen::Matrix< SCALAR, 6, 1 > &in)
Definition: RigidBodyAcceleration.h:35