motion.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 INRIA
3 //
4 
5 #include <iostream>
6 
7 #include <boost/test/unit_test.hpp>
8 #include <boost/utility/binary.hpp>
9 
11 
12 using namespace pinocchio;
13 
14 BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
15 
17 {
18  using namespace pinocchio;
19 
20  const SE3 placement = SE3::Random();
21  const Motion m_in = Motion::Random();
22 
23  // test case 1-2-3
24  {
25  BOOST_CHECK(changeReferenceFrame(placement, m_in, LOCAL, LOCAL) == m_in);
26  BOOST_CHECK(changeReferenceFrame(placement, m_in, WORLD, WORLD) == m_in);
27  BOOST_CHECK(
29  }
30 
31  const ReferenceFrame all_choices[3] = {LOCAL, WORLD, LOCAL_WORLD_ALIGNED};
32  for (int i = 0; i < 3; ++i)
33  for (int j = 0; j < 3; ++j)
34  BOOST_CHECK(
35  changeReferenceFrame(SE3::Identity(), m_in, all_choices[i], all_choices[j]) == m_in);
36 
37  // LOCAL/WORLD and WORLD/LOCAL
38  {
39  Motion m_sol_w = placement.act(m_in);
40  BOOST_CHECK(changeReferenceFrame(placement, m_in, LOCAL, WORLD) == m_sol_w);
41  BOOST_CHECK(changeReferenceFrame(placement, m_sol_w, WORLD, LOCAL).isApprox(m_in));
42  }
43 
44  // LOCAL/LOCAL_WORLD_ALIGNED and LOCAL_WORLD_ALIGNED/LOCAL
45  {
46  const SE3 placement_LWA(placement.rotation(), SE3::Vector3::Zero());
47  Motion m_sol_lwa = placement_LWA.act(m_in);
48  BOOST_CHECK(changeReferenceFrame(placement, m_in, LOCAL, LOCAL_WORLD_ALIGNED) == m_sol_lwa);
49  BOOST_CHECK(
51  }
52 
53  // WORLD/LOCAL_WORLD_ALIGNED and LOCAL_WORLD_ALIGNED/WORLD
54  {
55  const SE3 placement_W(SE3::Matrix3::Identity(), placement.translation());
56  Motion m_sol_w = placement_W.act(m_in);
57  BOOST_CHECK(
59  BOOST_CHECK(
61  }
62 }
63 
64 BOOST_AUTO_TEST_SUITE_END()
pinocchio::WORLD
@ WORLD
Definition: multibody/fwd.hpp:48
motion.hpp
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< context::Scalar, context::Options >
inverse-kinematics.i
int i
Definition: inverse-kinematics.py:17
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
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(test_motion)
Definition: motion.cpp:16
pinocchio::MotionTpl::Random
static MotionTpl Random()
Definition: motion-tpl.hpp:140
pinocchio::SE3Tpl::Random
static SE3Tpl Random()
Definition: spatial/se3-tpl.hpp:154
pinocchio::SE3Tpl::Identity
static SE3Tpl Identity()
Definition: spatial/se3-tpl.hpp:136
pinocchio::MotionTpl
Definition: context/casadi.hpp:27
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27
isApprox
bool isApprox(const Box &s1, const Box &s2, const FCL_REAL tol)
pinocchio::LOCAL
@ LOCAL
Definition: multibody/fwd.hpp:50


pinocchio
Author(s):
autogenerated on Thu Dec 19 2024 03:41:32