Line |
Branch |
Exec |
Source |
1 |
|
|
// |
2 |
|
|
// Copyright (c) 2019-2020 INRIA |
3 |
|
|
// |
4 |
|
|
|
5 |
|
|
#include "pinocchio/multibody/data.hpp" |
6 |
|
|
#include "pinocchio/multibody/model.hpp" |
7 |
|
|
#include "pinocchio/multibody/sample-models.hpp" |
8 |
|
|
|
9 |
|
|
#include "pinocchio/algorithm/check.hpp" |
10 |
|
|
|
11 |
|
|
#include <boost/test/unit_test.hpp> |
12 |
|
|
#include <boost/utility/binary.hpp> |
13 |
|
|
|
14 |
|
|
using namespace pinocchio; |
15 |
|
|
|
16 |
|
|
BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE) |
17 |
|
|
|
18 |
|
✗ |
BOOST_AUTO_TEST_CASE(test_empty_model) |
19 |
|
|
{ |
20 |
|
✗ |
Model empty_model; |
21 |
|
✗ |
Data empty_data(empty_model); |
22 |
|
|
|
23 |
|
✗ |
BOOST_CHECK(empty_model.check(empty_data)); |
24 |
|
|
} |
25 |
|
|
|
26 |
|
✗ |
BOOST_AUTO_TEST_CASE(test_data_start_idx_v_fromRow) |
27 |
|
|
{ |
28 |
|
✗ |
Model model; |
29 |
|
✗ |
buildModels::humanoidRandom(model); |
30 |
|
|
|
31 |
|
✗ |
Data data(model); |
32 |
|
|
|
33 |
|
✗ |
for (Model::JointIndex joint_id = 1; joint_id < (Model::JointIndex)model.njoints; ++joint_id) |
34 |
|
|
{ |
35 |
|
✗ |
const int nv_joint = model.joints[joint_id].nv(); |
36 |
|
✗ |
const int idx_joint = model.joints[joint_id].idx_v(); |
37 |
|
|
|
38 |
|
✗ |
for (int k = 0; k < nv_joint; ++k) |
39 |
|
|
{ |
40 |
|
✗ |
BOOST_CHECK(data.start_idx_v_fromRow[(size_t)(idx_joint + k)] == idx_joint); |
41 |
|
✗ |
BOOST_CHECK(data.end_idx_v_fromRow[(size_t)(idx_joint + k)] == idx_joint + nv_joint - 1); |
42 |
|
|
} |
43 |
|
|
} |
44 |
|
|
} |
45 |
|
|
|
46 |
|
✗ |
BOOST_AUTO_TEST_CASE(test_data_supports_fromRow) |
47 |
|
|
{ |
48 |
|
✗ |
Model model; |
49 |
|
✗ |
buildModels::humanoidRandom(model); |
50 |
|
|
|
51 |
|
✗ |
Data data(model); |
52 |
|
|
|
53 |
|
✗ |
for (size_t k = 0; k < (size_t)model.nv; ++k) |
54 |
|
|
{ |
55 |
|
✗ |
const std::vector<int> & support = data.supports_fromRow[k]; |
56 |
|
✗ |
const int parent_id = data.parents_fromRow[k]; |
57 |
|
|
|
58 |
|
✗ |
if (parent_id >= 0) |
59 |
|
|
{ |
60 |
|
✗ |
const std::vector<int> & support_parent = data.supports_fromRow[(size_t)parent_id]; |
61 |
|
✗ |
BOOST_CHECK(support.size() == support_parent.size() + 1); |
62 |
|
✗ |
for (size_t j = 0; j < support_parent.size(); ++j) |
63 |
|
|
{ |
64 |
|
✗ |
BOOST_CHECK(support[j] == support_parent[j]); |
65 |
|
|
} |
66 |
|
|
} |
67 |
|
|
|
68 |
|
✗ |
BOOST_CHECK(support.back() == (int)k); |
69 |
|
|
} |
70 |
|
|
} |
71 |
|
|
|
72 |
|
✗ |
BOOST_AUTO_TEST_CASE(test_copy_and_equal_op) |
73 |
|
|
{ |
74 |
|
✗ |
Model model; |
75 |
|
✗ |
buildModels::humanoidRandom(model); |
76 |
|
|
|
77 |
|
✗ |
Data data(model); |
78 |
|
✗ |
Data data_copy = data; |
79 |
|
|
|
80 |
|
✗ |
BOOST_CHECK(data == data); |
81 |
|
✗ |
BOOST_CHECK(data == data_copy); |
82 |
|
|
|
83 |
|
✗ |
data_copy.oMi[0].setRandom(); |
84 |
|
✗ |
BOOST_CHECK(data != data_copy); |
85 |
|
|
} |
86 |
|
|
|
87 |
|
✗ |
BOOST_AUTO_TEST_CASE(test_container_aligned_vector) |
88 |
|
|
{ |
89 |
|
✗ |
Model model; |
90 |
|
✗ |
buildModels::humanoidRandom(model); |
91 |
|
|
|
92 |
|
✗ |
Data data(model); |
93 |
|
|
|
94 |
|
✗ |
container::aligned_vector<Data::Force> & f = data.f; |
95 |
|
✗ |
data.f[0].setRandom(); |
96 |
|
|
|
97 |
|
✗ |
BOOST_CHECK(data.f[0] == f[0]); |
98 |
|
|
} |
99 |
|
|
|
100 |
|
✗ |
BOOST_AUTO_TEST_CASE(test_std_vector_of_Data) |
101 |
|
|
{ |
102 |
|
✗ |
Model model; |
103 |
|
✗ |
buildModels::humanoidRandom(model); |
104 |
|
|
|
105 |
|
✗ |
PINOCCHIO_ALIGNED_STD_VECTOR(Data) datas; |
106 |
|
✗ |
for (size_t k = 0; k < 20; ++k) |
107 |
|
✗ |
datas.push_back(Data(model)); |
108 |
|
|
} |
109 |
|
|
|
110 |
|
|
BOOST_AUTO_TEST_SUITE_END() |
111 |
|
|
|