Line |
Branch |
Exec |
Source |
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 |
|
|
|
10 |
|
|
#include "pinocchio/algorithm/utils/motion.hpp" |
11 |
|
|
|
12 |
|
|
using namespace pinocchio; |
13 |
|
|
|
14 |
|
|
BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE) |
15 |
|
|
|
16 |
|
✗ |
BOOST_AUTO_TEST_CASE(test_motion) |
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( |
28 |
|
|
changeReferenceFrame(placement, m_in, LOCAL_WORLD_ALIGNED, LOCAL_WORLD_ALIGNED) == m_in); |
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( |
50 |
|
|
changeReferenceFrame(placement, m_sol_lwa, LOCAL_WORLD_ALIGNED, LOCAL).isApprox(m_in)); |
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( |
58 |
|
|
changeReferenceFrame(placement, m_in, LOCAL_WORLD_ALIGNED, WORLD).isApprox(m_sol_w)); |
59 |
|
✗ |
BOOST_CHECK( |
60 |
|
|
changeReferenceFrame(placement, m_sol_w, WORLD, LOCAL_WORLD_ALIGNED).isApprox(m_in)); |
61 |
|
|
} |
62 |
|
|
} |
63 |
|
|
|
64 |
|
|
BOOST_AUTO_TEST_SUITE_END() |
65 |
|
|
|