- 3.0.2 rigid body dynamics module.
RigidBodyState.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 "RigidBodyPose.h"
9 #include "RigidBodyVelocities.h"
10 
11 namespace ct {
12 namespace rbd {
13 namespace tpl {
14 
21 template <typename SCALAR = double>
23 {
24 public:
25  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
26 
28  : pose_(storage), velocities_()
29  {
30  }
31 
33  RigidBodyState(const RigidBodyState<SCALAR>& arg) : pose_(arg.pose_), velocities_(arg.velocities_) {}
35  virtual ~RigidBodyState(){};
36 
38  RigidBodyPose<SCALAR>& pose() { return pose_; }
40  const RigidBodyPose<SCALAR>& pose() const { return pose_; }
42  RigidBodyVelocities<SCALAR>& velocities() { return velocities_; }
44  const RigidBodyVelocities<SCALAR>& velocities() const { return velocities_; }
46  bool isApprox(const RigidBodyState& rhs, const double& tol = 1e-10)
47  {
48  return pose().isNear(rhs.pose(), tol) && velocities().getVector().isApprox(rhs.velocities().getVector(), tol);
49  }
50 
52  const kindr::Velocity<SCALAR, 3> computeTranslationalVelocityW() const
53  {
54  return pose().rotateBaseToInertia(velocities().getTranslationalVelocity());
55  }
56  kindr::Velocity<SCALAR, 3> computeTranslationalVelocityW()
57  {
58  return pose().rotateBaseToInertia(velocities().getTranslationalVelocity());
59  }
60 
61  void setIdentity()
62  {
63  pose().setIdentity();
64  velocities().setZero();
65  }
66 
67  void setRandom()
68  {
69  pose().setRandom();
70  velocities().getTranslationalVelocity().toImplementation().setRandom();
71  velocities().getRotationalVelocity().toImplementation().setRandom();
72  }
73 
74 private:
76  RigidBodyVelocities<SCALAR> velocities_;
77 };
78 
79 } // namespace tpl
80 
81 // convenience typedef (required)
83 
84 } /* namespace rbd */
85 } /* namespace ct */
void setRandom()
Definition: RigidBodyState.h:67
STORAGE_TYPE
the orientation can either be stored as EulerAngles or as quaternion.
Definition: RigidBodyPose.h:38
virtual ~RigidBodyState()
destructor
Definition: RigidBodyState.h:35
Pose of a single rigid body.
Definition: RigidBodyPose.h:29
RigidBodyPose< SCALAR > & pose()
return the rigid body pose
Definition: RigidBodyState.h:38
const RigidBodyPose< SCALAR > & pose() const
return the rigid body pose (const)
Definition: RigidBodyState.h:40
EIGEN_MAKE_ALIGNED_OPERATOR_NEW RigidBodyState(typename RigidBodyPose< SCALAR >::STORAGE_TYPE storage=RigidBodyPose< SCALAR >::EULER)
Definition: RigidBodyState.h:27
RigidBodyVelocities< SCALAR > & velocities()
return the rigid body velocities
Definition: RigidBodyState.h:42
Representation of Rigid Body Velocities, currently just a typedef.
Definition: RigidBodyVelocities.h:20
const kindr::Velocity< SCALAR, 3 > computeTranslationalVelocityW() const
get translational velocity
Definition: RigidBodyState.h:52
kindr::Velocity< SCALAR, 3 > computeTranslationalVelocityW()
Definition: RigidBodyState.h:56
void setIdentity()
Definition: RigidBodyState.h:61
State (pose and velocities) of a single rigid body.
Definition: RigidBodyState.h:22
RigidBodyState(const RigidBodyState< SCALAR > &arg)
copy constructor
Definition: RigidBodyState.h:33
bool isApprox(const RigidBodyState &rhs, const double &tol=1e-10)
numerically comparing two rigid body states
Definition: RigidBodyState.h:46
const RigidBodyVelocities< SCALAR > & velocities() const
return the rigid body velocities (const)
Definition: RigidBodyState.h:44