Robot Dynamics Library
SpatialMomentum.hpp
Go to the documentation of this file.
1 // Copyright (c) 2017 Jordan Lack <jlack1987@gmail.com>
2 // RDL - Robot Dynamics Library
3 // Licensed under the zlib license. See LICENSE for more details.
4 
5 #ifndef __RDL_SPATIAL_MOMENTUM_HP__
6 #define __RDL_SPATIAL_MOMENTUM_HP__
7 
18 
19 namespace RobotDynamics
20 {
21 namespace Math
22 {
29 class SpatialMomentum : public Momentum, public FrameObject
30 {
31  public:
36  {
37  }
38 
49  SpatialMomentum(ReferenceFramePtr referenceFrame, const double kx, const double ky, const double kz, const double lx, const double ly, const double lz)
51  {
52  }
53 
61  : Momentum(k.x(), k.y(), k.z(), l.x(), l.y(), l.z()), FrameObject(referenceFrame)
62  {
63  }
64 
70  {
71  }
72 
79  {
80  }
81 
87  {
88  }
89 
96  SpatialMomentum(const SpatialInertia& inertia, const SpatialMotion& vector) : Momentum(inertia, vector), FrameObject(inertia.getReferenceFrame())
97  {
98  inertia.getReferenceFrame()->checkReferenceFramesMatch(vector.getReferenceFrame());
99  }
100 
105  : Momentum(inertia, vector), FrameObject(referenceFrame)
106  {
107  }
108 
110  {
111  this->referenceFrame = m.getReferenceFrame();
113  return *this;
114  }
115 
125  {
126  this->referenceFrame = referenceFrame;
127  SpatialVector::operator=(computeMomentum(inertia, vector));
128  }
129 
136  {
137  this->referenceFrame = referenceFrame;
138  ForceVector::set(f);
139  }
140 
146  inline double operator*(const SpatialMotion& vector)
147  {
148  this->checkReferenceFramesMatch(&vector);
149  return Momentum::operator*(vector);
150  }
151 
152  protected:
154  {
155  return this;
156  }
157 };
158 
166 inline SpatialMomentum operator*(const SpatialInertia& inertia, const SpatialMotion& vector)
167 {
168  return SpatialMomentum(inertia, vector);
169 }
170 typedef std::vector<SpatialMomentum, Eigen::aligned_allocator<SpatialMomentum>> SpatialMomentumV;
171 } // namespace Math
172 } // namespace RobotDynamics
173 
174 #endif //__RDL_SPATIAL_MOMENTUM_HP__
An interface that objects with a ReferenceFrame extend to inherit the FrameObject::changeFrame method...
Definition: FrameObject.hpp:26
void checkReferenceFramesMatch(const FrameObject *frameObject) const
Check if two FrameObjects hold the same ReferenceFrame.
Definition: FrameObject.hpp:67
ReferenceFramePtr getReferenceFrame() const
Get a pointer to the reference frame this FrameObject is expressed in.
Definition: FrameObject.hpp:49
ReferenceFramePtr referenceFrame
Definition: FrameObject.hpp:78
A ForceVector is a SpatialVector containing 3 moments and 3 linear forces.
Definition: ForceVector.hpp:23
EIGEN_STRONG_INLINE void set(const ForceVector &f)
Setter.
Definition: ForceVector.hpp:82
Momentum is mass/inertia multiplied by velocity.
Definition: Momentum.hpp:25
EIGEN_STRONG_INLINE double & kz()
Definition: Momentum.hpp:86
EIGEN_STRONG_INLINE double & lz()
Definition: Momentum.hpp:116
static Momentum computeMomentum(const RigidBodyInertia &I, const MotionVector &v)
Computes momentum from inertia and velocity.
Definition: Momentum.hpp:172
EIGEN_STRONG_INLINE double operator*(const MotionVector &vector)
Operator for computing kinetic energy. With momentum, and Math::MotionVector, this performs perform...
Definition: Momentum.hpp:162
EIGEN_STRONG_INLINE double & lx()
Definition: Momentum.hpp:106
EIGEN_STRONG_INLINE double & kx()
Definition: Momentum.hpp:76
EIGEN_STRONG_INLINE double & ky()
Definition: Momentum.hpp:81
EIGEN_STRONG_INLINE double & ly()
Definition: Momentum.hpp:111
Definition: MotionVector.hpp:21
This class stores a bodies mass, center of mass, and inertia information. The inertia elements are st...
Definition: RigidBodyInertia.hpp:42
A Math::SpatialInertia is a RigidBodyInertia explicitly expressed in a RobotDynamics::ReferenceFrame....
Definition: SpatialRigidBodyInertia.hpp:31
A SpatialMomentum is a Momentum expressed in a RobotDynamics::ReferenceFrame. The angular portion of ...
Definition: SpatialMomentum.hpp:30
SpatialMomentum & operator=(const SpatialMomentum &m)
Definition: SpatialMomentum.hpp:109
SpatialMomentum(ReferenceFramePtr referenceFrame)
Constructor.
Definition: SpatialMomentum.hpp:86
SpatialMomentum(ReferenceFramePtr referenceFrame, const Vector3d &k, const Vector3d l)
Constructor.
Definition: SpatialMomentum.hpp:60
double operator*(const SpatialMotion &vector)
Operator that returns the kinetic energy. Given a momentum, and motion vector , the resulting kineti...
Definition: SpatialMomentum.hpp:146
void setIncludingFrame(ReferenceFramePtr referenceFrame, const RigidBodyInertia &inertia, const MotionVector &vector)
Set a momentum by multiplying the supplied motion vector by the supplied inertia. Set the stored Robo...
Definition: SpatialMomentum.hpp:124
void setIncludingFrame(ReferenceFramePtr referenceFrame, const ForceVector &f)
Constructor.
Definition: SpatialMomentum.hpp:135
SpatialMomentum(const SpatialInertia &inertia, const SpatialMotion &vector)
Constructor. Momentum is computed from SpatialInertia and SpatialMotion by . Frame checks are perform...
Definition: SpatialMomentum.hpp:96
SpatialMomentum()
Constructor. RobotDynamics::ReferenceFrame is initialized to nullptr.
Definition: SpatialMomentum.hpp:35
SpatialMomentum(ReferenceFramePtr referenceFrame, const ForceVector &forceVector)
Constructor.
Definition: SpatialMomentum.hpp:78
SpatialMomentum(const SpatialMomentum &SpatialMomentum)
Copy constructor.
Definition: SpatialMomentum.hpp:69
SpatialMomentum(ReferenceFramePtr referenceFrame, const RigidBodyInertia &inertia, const MotionVector &vector)
Construct from a reference frame and the product of inertia and motion vector.
Definition: SpatialMomentum.hpp:104
SpatialMomentum(ReferenceFramePtr referenceFrame, const double kx, const double ky, const double kz, const double lx, const double ly, const double lz)
Costructor.
Definition: SpatialMomentum.hpp:49
TransformableGeometricObject * getTransformableGeometricObject()
Pure virtual method that FrameObjects are required to implement so the FrameObject::changeFrame metho...
Definition: SpatialMomentum.hpp:153
A SpatialMotion vector is a MotionVector with a RobotDynamics::ReferenceFrame it is expressed in....
Definition: SpatialMotion.hpp:33
SpatialVector & operator=(const Eigen::MatrixBase< OtherDerived > &other)
Definition: rdl_eigenmath.hpp:198
The TransformableGeometricObject class is an essential interface because it forces all geometric obje...
Definition: rdl_eigenmath.hpp:43
Definition: rdl_eigenmath.hpp:54
std::shared_ptr< ReferenceFrame > ReferenceFramePtr
Definition: ReferenceFrame.hpp:68
ForceVector operator*(const SpatialTransform &X, ForceVector f)
Operator for transforming a ForceVector. Calls the ForceVector::transform method.
Definition: ForceVector.hpp:248
std::vector< SpatialMomentum, Eigen::aligned_allocator< SpatialMomentum > > SpatialMomentumV
Definition: SpatialMomentum.hpp:170
Namespace for all structures of the RobotDynamics library.
Definition: examples.hpp:19