data.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2019-2020 INRIA
3 //
4 
5 #include "pinocchio/multibody/data.hpp"
6 #include "pinocchio/multibody/model.hpp"
7 #include "pinocchio/parsers/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;
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()
typedef PINOCCHIO_ALIGNED_STD_VECTOR(JointData) JointDataVector
JointModelVector joints
Model of joint i, encapsulated in a JointModelAccessor.
std::vector< std::vector< int > > supports_fromRow
Each element of this vector corresponds to the ordered list of indexes belonging to the supporting tr...
int njoints
Number of joints.
std::vector< int > end_idx_v_fromRow
End index of the Joint motion subspace.
Specialization of an std::vector with an aligned allocator. This specialization might be used when th...
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...
pinocchio::JointIndex JointIndex
Main pinocchio namespace.
Definition: timings.cpp:28
std::vector< int > start_idx_v_fromRow
Starting index of the Joint motion subspace.
int nv
Dimension of the velocity vector space.
std::vector< int > parents_fromRow
First previous non-zero row in M (used in Cholesky Decomposition).
BOOST_AUTO_TEST_CASE(test_empty_model)
Definition: data.cpp:18
void humanoidRandom(ModelTpl< Scalar, Options, JointCollectionTpl > &model, bool usingFF=true)
Create a humanoid kinematic tree with 6-DOF limbs and random joint placements.
JointCollectionTpl & model


pinocchio
Author(s):
autogenerated on Fri Jun 23 2023 02:38:29