algorithm/utils/motion.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 INRIA
3 //
4 
5 #ifndef __pinocchio_algorithm_utils_motion_hpp__
6 #define __pinocchio_algorithm_utils_motion_hpp__
7 
11 
12 namespace pinocchio
13 {
14 
19  template<typename Scalar, int Options, typename MotionIn, typename MotionOut>
22  const MotionDense<MotionIn> & m_in,
23  const ReferenceFrame rf_in,
24  const ReferenceFrame rf_out,
25  MotionDense<MotionOut> & m_out)
26  {
27  if (rf_in == rf_out)
28  {
29  m_out = m_in;
30  return;
31  }
32 
33  // case: LOCAL/WORLD and WORLD/LOCAL
34  if (rf_in == LOCAL && rf_out == WORLD)
35  {
36  m_out = placement.act(m_in);
37  return;
38  }
39  if (rf_in == WORLD && rf_out == LOCAL)
40  {
41  m_out = placement.actInv(m_in);
42  return;
43  }
44 
45  // case: LOCAL/LOCAL_WORLD_ALIGNED and LOCAL_WORLD_ALIGNED/LOCAL
46  if (rf_in == LOCAL && rf_out == LOCAL_WORLD_ALIGNED)
47  {
48  m_out.linear().noalias() = placement.rotation() * m_in.linear();
49  m_out.angular().noalias() = placement.rotation() * m_in.angular();
50  return;
51  }
52  if (rf_in == LOCAL_WORLD_ALIGNED && rf_out == LOCAL)
53  {
54  m_out.linear().noalias() = placement.rotation().transpose() * m_in.linear();
55  m_out.angular().noalias() = placement.rotation().transpose() * m_in.angular();
56  return;
57  }
58 
59  // case: WORLD/LOCAL_WORLD_ALIGNED and LOCAL_WORLD_ALIGNED/WORLD
60  if (rf_in == WORLD && rf_out == LOCAL_WORLD_ALIGNED)
61  {
62  m_out.angular() = m_in.angular();
63  m_out.linear().noalias() = m_in.linear() + m_in.angular().cross(placement.translation());
64  return;
65  }
66  if (rf_in == LOCAL_WORLD_ALIGNED && rf_out == WORLD)
67  {
68  m_out.angular() = m_in.angular();
69  m_out.linear().noalias() = m_in.linear() - m_in.angular().cross(placement.translation());
70  return;
71  }
72 
73  assert(false && "This must never happened.");
74  }
75 
90  template<typename Scalar, int Options, typename MotionIn>
91  typename MotionIn::MotionPlain changeReferenceFrame(
93  const MotionDense<MotionIn> & m_in,
94  const ReferenceFrame rf_in,
95  const ReferenceFrame rf_out)
96  {
97  typedef typename MotionIn::MotionPlain ReturnType;
98  ReturnType res;
99 
100  changeReferenceFrame(placement, m_in, rf_in, rf_out, res);
101 
102  return res;
103  }
104 
105 } // namespace pinocchio
106 
107 #endif // #ifndef __pinocchio_multibody_fwd_hpp__
pinocchio::WORLD
@ WORLD
Definition: multibody/fwd.hpp:48
pinocchio::changeReferenceFrame
void changeReferenceFrame(const SE3Tpl< Scalar, Options > &placement, const ForceDense< ForceIn > &f_in, const ReferenceFrame rf_in, const ReferenceFrame rf_out, ForceDense< ForceOut > &f_out)
Definition: algorithm/utils/force.hpp:19
pinocchio::ReferenceFrame
ReferenceFrame
Various conventions to express the velocity of a moving frame.
Definition: multibody/fwd.hpp:46
pinocchio::SE3Tpl< Scalar, Options >
pinocchio::MotionDense
Definition: context/casadi.hpp:36
pinocchio::res
ReturnType res
Definition: spatial/classic-acceleration.hpp:57
motion.hpp
pinocchio::MotionDense::linear
ConstLinearType linear() const
Definition: motion-base.hpp:36
pinocchio::LOCAL_WORLD_ALIGNED
@ LOCAL_WORLD_ALIGNED
Definition: multibody/fwd.hpp:52
pinocchio::placement
const MotionDense< Motion2 > const SE3Tpl< SE3Scalar, SE3Options > & placement
Definition: spatial/classic-acceleration.hpp:122
se3.hpp
fwd.hpp
pinocchio::MotionDense::angular
ConstAngularType angular() const
Definition: motion-base.hpp:32
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27
pinocchio::LOCAL
@ LOCAL
Definition: multibody/fwd.hpp:50


pinocchio
Author(s):
autogenerated on Mon Dec 16 2024 03:41:04