pinocchio  3.2.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
classic-acceleration.hpp
1 //
2 // Copyright (c) 2019 INRIA
3 //
4 
5 #ifndef __pinocchio_spatial_classic_acceleration_hpp__
6 #define __pinocchio_spatial_classic_acceleration_hpp__
7 
8 #include "pinocchio/spatial/se3.hpp"
9 #include "pinocchio/spatial/motion.hpp"
10 
11 namespace pinocchio
12 {
28  template<typename Motion1, typename Motion2, typename Vector3Like>
29  inline void classicAcceleration(
30  const MotionDense<Motion1> & spatial_velocity,
31  const MotionDense<Motion2> & spatial_acceleration,
32  const Eigen::MatrixBase<Vector3Like> & res)
33  {
34  PINOCCHIO_EIGEN_CONST_CAST(Vector3Like, res).noalias() =
35  spatial_acceleration.linear() + spatial_velocity.angular().cross(spatial_velocity.linear());
36  }
37 
51  template<typename Motion1, typename Motion2>
52  inline typename PINOCCHIO_EIGEN_PLAIN_TYPE(typename Motion2::Vector3) classicAcceleration(
53  const MotionDense<Motion1> & spatial_velocity,
54  const MotionDense<Motion2> & spatial_acceleration)
55  {
56  typedef typename PINOCCHIO_EIGEN_PLAIN_TYPE(typename Motion2::Vector3) ReturnType;
57  ReturnType res;
58  classicAcceleration(spatial_velocity, spatial_acceleration, res);
59  return res;
60  }
61 
78  template<
79  typename Motion1,
80  typename Motion2,
81  typename SE3Scalar,
82  int SE3Options,
83  typename Vector3Like>
84  inline void classicAcceleration(
85  const MotionDense<Motion1> & spatial_velocity,
86  const MotionDense<Motion2> & spatial_acceleration,
87  const SE3Tpl<SE3Scalar, SE3Options> & placement,
88  const Eigen::MatrixBase<Vector3Like> & res)
89  {
90  typedef typename PINOCCHIO_EIGEN_PLAIN_TYPE(typename Motion1::LinearType) Vector3;
91 
92  const Vector3 linear_velocity_frame_B =
93  spatial_velocity.linear() + spatial_velocity.angular().cross(placement.translation());
94 
95  const Vector3 linear_acceleration_frame_B // expressed in the coordinate frame A
96  = spatial_acceleration.linear() + spatial_velocity.angular().cross(linear_velocity_frame_B);
97 
98  PINOCCHIO_EIGEN_CONST_CAST(Vector3Like, res).noalias() =
99  placement.rotation().transpose()
100  * (linear_acceleration_frame_B - placement.translation().cross(spatial_acceleration.angular()));
101  }
102 
117  template<typename Motion1, typename Motion2, typename SE3Scalar, int SE3Options>
118  inline typename PINOCCHIO_EIGEN_PLAIN_TYPE(typename Motion2::Vector3) classicAcceleration(
119  const MotionDense<Motion1> & spatial_velocity,
120  const MotionDense<Motion2> & spatial_acceleration,
121  const SE3Tpl<SE3Scalar, SE3Options> & placement)
122  {
123  typedef typename PINOCCHIO_EIGEN_PLAIN_TYPE(typename Motion2::Vector3) ReturnType;
124  ReturnType res;
125  classicAcceleration(spatial_velocity, spatial_acceleration, placement, res);
126  return res;
127  }
128 } // namespace pinocchio
129 
130 #endif // ifndef __pinocchio_spatial_classic_acceleration_hpp__
Main pinocchio namespace.
Definition: treeview.dox:11
void classicAcceleration(const MotionDense< Motion1 > &spatial_velocity, const MotionDense< Motion2 > &spatial_acceleration, const Eigen::MatrixBase< Vector3Like > &res)
Computes the classic acceleration from a given spatial velocity and spatial acceleration.