spatial-axis.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2017-2019 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_spatial_axis_hpp__
6 #define __pinocchio_spatial_axis_hpp__
7 
12 
13 namespace pinocchio
14 {
15  template<int axis>
16  struct SpatialAxis;
17 
18  template<int axis, typename MotionDerived>
19  struct MotionAlgebraAction<SpatialAxis<axis>, MotionDerived>
20  {
21  typedef typename MotionDerived::MotionPlain ReturnType;
22  };
23 
24  template<int _axis>
25  struct SpatialAxis //: MotionBase< SpatialAxis<_axis> >
26  {
27  enum
28  {
29  axis = _axis,
30  dim = 6
31  };
33 
34  enum
35  {
36  LINEAR = 0,
37  ANGULAR = 3
38  };
39 
40  template<typename Derived1, typename Derived2>
41  inline static void cross(const MotionDense<Derived1> & min, const MotionDense<Derived2> & mout);
42 
43  template<typename Derived>
45  {
47  cross(min, res);
48  return res;
49  }
50 
51  template<typename Derived1, typename Derived2>
52  inline static void cross(const ForceDense<Derived1> & fin, const ForceDense<Derived2> & fout);
53 
54  template<typename Derived>
56  {
57  typename ForceDense<Derived>::ForcePlain fout;
58  cross(fin, fout);
59  return fout;
60  }
61 
62  template<typename Scalar>
64  {
65  typedef MotionTpl<Scalar> ReturnType;
66  ReturnType res;
67  for (Eigen::DenseIndex i = 0; i < dim; ++i)
68  res.toVector()[i] = i == axis ? s : Scalar(0);
69 
70  return res;
71  }
72 
73  template<typename Scalar>
74  friend inline MotionTpl<Scalar> operator*(const Scalar & s, const SpatialAxis &)
75  {
76  return SpatialAxis() * s;
77  }
78 
79  template<typename Derived>
80  friend Derived & operator<<(MotionDense<Derived> & min, const SpatialAxis &)
81  {
82  typedef typename traits<Derived>::Scalar Scalar;
83  min.setZero();
84  min.toVector()[axis] = Scalar(1);
85  return min.derived();
86  }
87 
88  template<typename MotionDerived>
89  typename MotionDerived::MotionPlain motionAction(const MotionDense<MotionDerived> & m) const
90  {
91  typename MotionDerived::MotionPlain res;
92  if ((LINEAR == 0 && axis < 3) || (LINEAR == 3 && axis >= 3))
93  {
94  res.angular().setZero();
95  CartesianAxis3::cross(-m.angular(), res.linear());
96  }
97  else
98  {
99  CartesianAxis3::cross(-m.linear(), res.linear());
100  CartesianAxis3::cross(-m.angular(), res.angular());
101  }
102 
103  return res;
104  }
105 
106  }; // struct SpatialAxis
107 
108  template<int axis>
109  template<typename Derived1, typename Derived2>
110  inline void
112  {
113  Derived2 & mout_ = PINOCCHIO_EIGEN_CONST_CAST(Derived2, mout);
114 
115  if ((LINEAR == 0 && axis < 3) || (LINEAR == 3 && axis >= 3))
116  {
117  mout_.angular().setZero();
118  CartesianAxis3::cross(min.angular(), mout_.linear());
119  }
120  else
121  {
122  CartesianAxis3::cross(min.linear(), mout_.linear());
123  CartesianAxis3::cross(min.angular(), mout_.angular());
124  }
125  }
126 
127  template<int axis>
128  template<typename Derived1, typename Derived2>
129  inline void
131  {
132  Derived2 & fout_ = PINOCCHIO_EIGEN_CONST_CAST(Derived2, fout);
133 
134  if ((LINEAR == 0 && axis < 3) || (LINEAR == 3 && axis >= 3))
135  {
136  fout_.linear().setZero();
137  CartesianAxis3::cross(fin.linear(), fout_.angular());
138  }
139  else
140  {
141  CartesianAxis3::cross(fin.linear(), fout_.linear());
142  CartesianAxis3::cross(fin.angular(), fout_.angular());
143  }
144  }
145 
149 
153 } // namespace pinocchio
154 
155 #endif // __pinocchio_spatial_axis_hpp__
pinocchio::ForceDense::linear
ConstLinearType linear() const
Return the linear part of the force vector.
Definition: force-base.hpp:57
fwd.hpp
test-cpp2pybind11.m
m
Definition: test-cpp2pybind11.py:25
pinocchio::CartesianAxis::cross
static void cross(const Eigen::MatrixBase< V3_in > &vin, const Eigen::MatrixBase< V3_out > &vout)
pinocchio::AxisWY
SpatialAxis< 4 > AxisWY
Definition: spatial-axis.hpp:151
pinocchio::AxisVX
SpatialAxis< 0 > AxisVX
Definition: spatial-axis.hpp:146
pinocchio::SpatialAxis::LINEAR
@ LINEAR
Definition: spatial-axis.hpp:36
PINOCCHIO_EIGEN_CONST_CAST
#define PINOCCHIO_EIGEN_CONST_CAST(TYPE, OBJ)
Macro for an automatic const_cast.
Definition: eigen-macros.hpp:51
pinocchio::SpatialAxis::cross
static traits< Derived >::ForcePlain cross(const ForceDense< Derived > &fin)
Definition: spatial-axis.hpp:55
inverse-kinematics.i
int i
Definition: inverse-kinematics.py:17
pinocchio::MotionDense
Definition: context/casadi.hpp:36
pinocchio::python::Scalar
context::Scalar Scalar
Definition: admm-solver.cpp:29
pinocchio::AxisVY
SpatialAxis< 1 > AxisVY
Definition: spatial-axis.hpp:147
pinocchio::res
ReturnType res
Definition: spatial/classic-acceleration.hpp:57
pinocchio::MotionAlgebraAction
Return type of the ation of a Motion onto an object of type D.
Definition: spatial/motion.hpp:45
motion.hpp
pinocchio::SpatialAxis::dim
@ dim
Definition: spatial-axis.hpp:30
pinocchio::SpatialAxis::CartesianAxis3
CartesianAxis< _axis % 3 > CartesianAxis3
Definition: spatial-axis.hpp:32
pinocchio::AxisWZ
SpatialAxis< 5 > AxisWZ
Definition: spatial-axis.hpp:152
pinocchio::cholesky::min
JointCollectionTpl const DataTpl< Scalar, Options, JointCollectionTpl > const Eigen::MatrixBase< Mat > & min
Definition: cholesky.hpp:89
pinocchio::SpatialAxis::operator*
friend MotionTpl< Scalar > operator*(const Scalar &s, const SpatialAxis &)
Definition: spatial-axis.hpp:74
cartesian-axis.hpp
pinocchio::SpatialAxis::operator<<
friend Derived & operator<<(MotionDense< Derived > &min, const SpatialAxis &)
Definition: spatial-axis.hpp:80
axis
axis
pinocchio::SpatialAxis::cross
static void cross(const MotionDense< Derived1 > &min, const MotionDense< Derived2 > &mout)
Definition: spatial-axis.hpp:111
pinocchio::MotionAlgebraAction< SpatialAxis< axis >, MotionDerived >::ReturnType
MotionDerived::MotionPlain ReturnType
Definition: spatial-axis.hpp:21
pinocchio::SpatialAxis::operator*
MotionTpl< Scalar > operator*(const Scalar &s) const
Definition: spatial-axis.hpp:63
pinocchio::SpatialAxis::axis
@ axis
Definition: spatial-axis.hpp:29
pinocchio::ForceDense
Definition: context/casadi.hpp:34
pinocchio::SpatialAxis::cross
static traits< Derived >::MotionPlain cross(const MotionDense< Derived > &min)
Definition: spatial-axis.hpp:44
pinocchio::cross
void cross(const Eigen::MatrixBase< Vector3 > &v, const Eigen::MatrixBase< Matrix3xIn > &Min, const Eigen::MatrixBase< Matrix3xOut > &Mout)
Applies the cross product onto the columns of M.
Definition: skew.hpp:228
pinocchio::AxisWX
SpatialAxis< 3 > AxisWX
Definition: spatial-axis.hpp:150
pinocchio::traits
Common traits structure to fully define base classes for CRTP.
Definition: fwd.hpp:71
pinocchio::MotionTpl
Definition: context/casadi.hpp:27
pinocchio::SpatialAxis::ANGULAR
@ ANGULAR
Definition: spatial-axis.hpp:37
pinocchio::AxisVZ
SpatialAxis< 2 > AxisVZ
Definition: spatial-axis.hpp:148
force.hpp
pinocchio::SpatialAxis
Definition: spatial-axis.hpp:16
pinocchio::SpatialAxis::motionAction
MotionDerived::MotionPlain motionAction(const MotionDense< MotionDerived > &m) const
Definition: spatial-axis.hpp:89
pinocchio::ForceDense::angular
ConstAngularType angular() const
Return the angular part of the force vector.
Definition: force-base.hpp:47
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27
pinocchio::CartesianAxis
Definition: cartesian-axis.hpp:14


pinocchio
Author(s):
autogenerated on Sun Dec 22 2024 03:41:12