- 3.0.2 rigid body dynamics module.
SpatialForceVector.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 #ifndef INCLUDE_CT_RBD_ROBOT_KINEMATICS_EEFORCE_H_
7 #define INCLUDE_CT_RBD_ROBOT_KINEMATICS_EEFORCE_H_
8 
9 namespace ct {
10 namespace rbd {
11 
17 template <typename SCALAR = double>
18 class SpatialForceVector : public Eigen::Matrix<SCALAR, 6, 1>
19 {
20 public:
21  typedef Eigen::Matrix<SCALAR, 6, 1> spatial_force_vector_t;
22  typedef Eigen::VectorBlock<spatial_force_vector_t, 3>
24  typedef Eigen::VectorBlock<const spatial_force_vector_t, 3>
26 
34  SpatialForceVector(const spatial_force_vector_t& vector6) : spatial_force_vector_t(vector6) {}
38  spatial_force_vector_t& toImplementation() { return *this; }
42  const spatial_force_vector_t& toImplementation() const { return *this; }
47  {
48  // for auto diff compatability
49  SCALAR zero(0.0);
50  this->setConstant(zero);
51  return *this;
52  }
53 
57  inline bool operator==(const spatial_force_vector_t& rhs) const { return Base::operator==(rhs); }
61  inline bool operator!=(const spatial_force_vector_t& rhs) const { return Base::operator!=(rhs); }
65  inline spatial_force_vector_t operator+(const spatial_force_vector_t& rhs) const
66  {
67  return spatial_force_vector_t(Base::operator+(rhs));
68  }
72  inline spatial_force_vector_t operator-(const spatial_force_vector_t& rhs) const
73  {
74  return spatial_force_vector_t(Base::operator-(rhs));
75  }
76 
80  inline spatial_force_vector_t operator*(const SCALAR& scalar) const
81  {
82  return spatial_force_vector_t(Base::operator*(scalar));
83  }
84 
88  inline spatial_force_vector_t operator/(const SCALAR& scalar) const
89  {
90  return spatial_force_vector_t(Base::operator/(scalar));
91  }
92 
96  ForceTorqueBlock torque() { return this->template head<3>(); }
100  const ForceTorqueBlockConst torque() const { return this->template head<3>(); }
104  ForceTorqueBlock force() { return this->template tail<3>(); }
108  const ForceTorqueBlockConst force() const { return this->template tail<3>(); }
109 private:
110  typedef Eigen::Matrix<SCALAR, 6, 1> Base;
111 };
112 }
113 }
114 
115 
116 #endif /* INCLUDE_CT_RBD_ROBOT_KINEMATICS_EEFORCE_H_ */
spatial_force_vector_t operator+(const spatial_force_vector_t &rhs) const
Sums two spatial forces component-wise.
Definition: SpatialForceVector.h:65
Eigen::Matrix< SCALAR, 6, 1 > spatial_force_vector_t
special vector type
Definition: SpatialForceVector.h:21
spatial_force_vector_t operator*(const SCALAR &scalar) const
Scales a spatial forces component-wise.
Definition: SpatialForceVector.h:80
spatial_force_vector_t operator/(const SCALAR &scalar) const
Divides a spatial forces component-wise.
Definition: SpatialForceVector.h:88
const ForceTorqueBlockConst force() const
Get the force block (lower 3D block)
Definition: SpatialForceVector.h:108
bool operator!=(const spatial_force_vector_t &rhs) const
Comparison operator (exact, subject to floating point rounding)
Definition: SpatialForceVector.h:61
SpatialForceVector & setZero()
Sets all entries to zero.
Definition: SpatialForceVector.h:46
Eigen::VectorBlock< const spatial_force_vector_t, 3 > ForceTorqueBlockConst
const 3D force or torque block inside of the spacial vector
Definition: SpatialForceVector.h:25
CppAD::AD< CppAD::cg::CG< double > > SCALAR
A spatial force vector This vector contains a torque (angular) in the upper three rows and a linear f...
Definition: SpatialForceVector.h:18
SpatialForceVector()
Default constructor.
Definition: SpatialForceVector.h:30
const ForceTorqueBlockConst torque() const
Get the torque block (upper 3D block)
Definition: SpatialForceVector.h:100
Eigen::VectorBlock< spatial_force_vector_t, 3 > ForceTorqueBlock
3D force or torque block inside of the spacial vector
Definition: SpatialForceVector.h:23
spatial_force_vector_t & toImplementation()
Returns the Eigen implementation.
Definition: SpatialForceVector.h:38
ForceTorqueBlock torque()
Get the torque block (upper 3D block)
Definition: SpatialForceVector.h:96
bool operator==(const spatial_force_vector_t &rhs) const
Comparison operator (exact, subject to floating point rounding)
Definition: SpatialForceVector.h:57
spatial_force_vector_t operator-(const spatial_force_vector_t &rhs) const
Substracts two spatial forces component-wise.
Definition: SpatialForceVector.h:72
ForceTorqueBlock force()
Get the force block (lower 3D block)
Definition: SpatialForceVector.h:104
SpatialForceVector(const spatial_force_vector_t &vector6)
Copy constructor.
Definition: SpatialForceVector.h:34
const spatial_force_vector_t & toImplementation() const
Returns the Eigen implementation.
Definition: SpatialForceVector.h:42