unittest/data.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2019-2020 INRIA
3 //
4 
8 
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;
30 
31  Data data(model);
32 
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;
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;
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;
91 
92  Data data(model);
93 
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;
104 
106  for (size_t k = 0; k < 20; ++k)
107  datas.push_back(Data(model));
108 }
109 
110 BOOST_AUTO_TEST_SUITE_END()
pinocchio::DataTpl
Definition: context/generic.hpp:25
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(test_empty_model)
Definition: unittest/data.cpp:18
model.hpp
setup.data
data
Definition: cmake/cython/setup.in.py:48
pinocchio::buildModels::humanoidRandom
void humanoidRandom(ModelTpl< Scalar, Options, JointCollectionTpl > &model, bool usingFF=true)
Create a humanoid kinematic tree with 6-DOF limbs and random joint placements.
autodiff-rnea.f
f
Definition: autodiff-rnea.py:24
pinocchio::ModelTpl::check
bool check(const AlgorithmCheckerBase< D > &checker=AlgorithmCheckerBase< D >()) const
Check the validity of the attributes of Model with respect to the specification of some algorithms.
Definition: multibody/model.hpp:461
pinocchio::ModelTpl::JointIndex
pinocchio::JointIndex JointIndex
Definition: multibody/model.hpp:67
append-urdf-model-with-another-model.parent_id
int parent_id
Definition: append-urdf-model-with-another-model.py:28
data.hpp
check.hpp
pinocchio::container::aligned_vector
std::vector< T, Eigen::aligned_allocator< T > > aligned_vector
Definition: container/aligned-vector.hpp:21
sample-models.hpp
append-urdf-model-with-another-model.joint_id
joint_id
Definition: append-urdf-model-with-another-model.py:34
pinocchio::ModelTpl
Definition: context/generic.hpp:20
pinocchio::PINOCCHIO_ALIGNED_STD_VECTOR
typedef PINOCCHIO_ALIGNED_STD_VECTOR(JointData) JointDataVector
pinocchio::model
JointCollectionTpl & model
Definition: joint-configuration.hpp:1082
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27


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