GCC Code Coverage Report


Directory: ./
File: unittest/test_multiple_contacts.cpp
Date: 2025-03-26 19:23:43
Exec Total Coverage
Lines: 332 389 85.3%
Branches: 742 1620 45.8%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2019-2025, University of Edinburgh, Heriot-Watt University
5 // Copyright note valid unless otherwise stated in individual files.
6 // All rights reserved.
7 ///////////////////////////////////////////////////////////////////////////////
8
9 #define BOOST_TEST_NO_MAIN
10 #define BOOST_TEST_ALTERNATIVE_INIT_API
11
12 #include <pinocchio/algorithm/frames.hpp>
13 #include <pinocchio/algorithm/kinematics-derivatives.hpp>
14
15 #include "factory/contact.hpp"
16 #include "unittest_common.hpp"
17
18 using namespace boost::unit_test;
19 using namespace crocoddyl::unittest;
20
21 //----------------------------------------------------------------------------//
22
23 /**
24 * These methods modify the return type of the model function in
25 * order to use the boost::execution_monitor::execute method which catch the
26 * assert signal
27 */
28 int calc(crocoddyl::ContactModelMultiple& model,
29 std::shared_ptr<crocoddyl::ContactDataMultiple> data,
30 Eigen::VectorXd& dx) {
31 model.calc(data, dx);
32 return 0;
33 }
34
35 int calcDiff(crocoddyl::ContactModelMultiple& model,
36 std::shared_ptr<crocoddyl::ContactDataMultiple> data,
37 Eigen::VectorXd& dx) {
38 model.calcDiff(data, dx);
39 return 0;
40 }
41
42 int updateForce(crocoddyl::ContactModelMultiple& model,
43 std::shared_ptr<crocoddyl::ContactDataMultiple> data,
44 Eigen::VectorXd& dx) {
45 model.updateForce(data, dx);
46 return 0;
47 }
48
49 int updateAccelerationDiff(crocoddyl::ContactModelMultiple& model,
50 std::shared_ptr<crocoddyl::ContactDataMultiple> data,
51 const Eigen::MatrixXd& ddv_dx) {
52 model.updateAccelerationDiff(data, ddv_dx);
53 return 0;
54 }
55
56 int updateForceDiff(crocoddyl::ContactModelMultiple& model,
57 std::shared_ptr<crocoddyl::ContactDataMultiple> data,
58 const Eigen::MatrixXd& df_dx,
59 const Eigen::MatrixXd& df_du) {
60 model.updateForceDiff(data, df_dx, df_du);
61 return 0;
62 }
63
64 //----------------------------------------------------------------------------//
65
66 1 void test_constructor() {
67 // Setup the test
68
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelFactory state_factory;
69 crocoddyl::ContactModelMultiple model(
70
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::static_pointer_cast<crocoddyl::StateMultibody>(state_factory.create(
71
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelTypes::StateMultibody_RandomHumanoid)));
72
73 // Run the print function
74
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 std::ostringstream tmp;
75
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tmp << model;
76
77 // Test the initial size of the map
78
7/14
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 1 times.
1 BOOST_CHECK(model.get_contacts().size() == 0);
79
80 // Checking that casted computation is the same
81 #ifdef NDEBUG // Run only in release mode
82 crocoddyl::ContactModelMultipleTpl<float> casted_model = model.cast<float>();
83 BOOST_CHECK(casted_model.get_contacts().size() == 0);
84 #endif
85 1 }
86
87 1 void test_addContact() {
88 // Setup the test
89
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelFactory state_factory;
90 crocoddyl::ContactModelMultiple model(
91
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::static_pointer_cast<crocoddyl::StateMultibody>(state_factory.create(
92
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelTypes::StateMultibody_RandomHumanoid)));
93
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 crocoddyl::ContactModelMultipleTpl<float> casted_model = model.cast<float>();
94
95 // add an active contact
96 std::shared_ptr<crocoddyl::ContactModelAbstract> rand_contact_1 =
97
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 create_random_contact();
98
2/4
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
1 model.addContact("random_contact_1", rand_contact_1);
99
8/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1 times.
✗ Branch 25 not taken.
✗ Branch 29 not taken.
✓ Branch 30 taken 1 times.
1 BOOST_CHECK(model.get_nc() == rand_contact_1->get_nc());
100
8/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1 times.
✗ Branch 25 not taken.
✗ Branch 29 not taken.
✓ Branch 30 taken 1 times.
1 BOOST_CHECK(model.get_nc_total() == rand_contact_1->get_nc());
101
102 // add an inactive contact
103 std::shared_ptr<crocoddyl::ContactModelAbstract> rand_contact_2 =
104
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 create_random_contact();
105
2/4
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
1 model.addContact("random_contact_2", rand_contact_2, false);
106
8/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1 times.
✗ Branch 25 not taken.
✗ Branch 29 not taken.
✓ Branch 30 taken 1 times.
1 BOOST_CHECK(model.get_nc() == rand_contact_1->get_nc());
107
9/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✗ Branch 33 not taken.
✓ Branch 34 taken 1 times.
1 BOOST_CHECK(model.get_nc_total() ==
108 rand_contact_1->get_nc() + rand_contact_2->get_nc());
109
110 // change the random contact 2 status
111
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 model.changeContactStatus("random_contact_2", true);
112
9/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✗ Branch 33 not taken.
✓ Branch 34 taken 1 times.
1 BOOST_CHECK(model.get_nc() ==
113 rand_contact_1->get_nc() + rand_contact_2->get_nc());
114
9/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✗ Branch 33 not taken.
✓ Branch 34 taken 1 times.
1 BOOST_CHECK(model.get_nc_total() ==
115 rand_contact_1->get_nc() + rand_contact_2->get_nc());
116
117 // change the random contact 1 status
118
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 model.changeContactStatus("random_contact_1", false);
119
8/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1 times.
✗ Branch 25 not taken.
✗ Branch 29 not taken.
✓ Branch 30 taken 1 times.
1 BOOST_CHECK(model.get_nc() == rand_contact_2->get_nc());
120
9/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✗ Branch 33 not taken.
✓ Branch 34 taken 1 times.
1 BOOST_CHECK(model.get_nc_total() ==
121 rand_contact_1->get_nc() + rand_contact_2->get_nc());
122
123 // Checking that casted computation is the same
124 #ifdef NDEBUG // Run only in release mode
125 std::shared_ptr<crocoddyl::ContactModelAbstractTpl<float>>
126 casted_rand_contact_1 = rand_contact_1->cast<float>();
127 casted_model.addContact("random_contact_1", casted_rand_contact_1);
128 BOOST_CHECK(casted_model.get_nc() == casted_rand_contact_1->get_nc());
129 BOOST_CHECK(casted_model.get_nc_total() == casted_rand_contact_1->get_nc());
130 std::shared_ptr<crocoddyl::ContactModelAbstractTpl<float>>
131 casted_rand_contact_2 = rand_contact_2->cast<float>();
132 casted_model.addContact("random_contact_2", casted_rand_contact_2, false);
133 BOOST_CHECK(casted_model.get_nc() == casted_rand_contact_1->get_nc());
134 BOOST_CHECK(casted_model.get_nc_total() ==
135 casted_rand_contact_1->get_nc() +
136 casted_rand_contact_2->get_nc());
137 casted_model.changeContactStatus("random_contact_2", true);
138 BOOST_CHECK(casted_model.get_nc() == casted_rand_contact_1->get_nc() +
139 casted_rand_contact_2->get_nc());
140 BOOST_CHECK(casted_model.get_nc_total() ==
141 casted_rand_contact_1->get_nc() +
142 casted_rand_contact_2->get_nc());
143 casted_model.changeContactStatus("random_contact_1", false);
144 BOOST_CHECK(casted_model.get_nc() == casted_rand_contact_2->get_nc());
145 BOOST_CHECK(casted_model.get_nc_total() ==
146 casted_rand_contact_1->get_nc() +
147 casted_rand_contact_2->get_nc());
148 #endif
149 1 }
150
151 1 void test_addContact_error_message() {
152 // Setup the test
153
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelFactory state_factory;
154 crocoddyl::ContactModelMultiple model(
155
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::static_pointer_cast<crocoddyl::StateMultibody>(state_factory.create(
156
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelTypes::StateMultibody_RandomHumanoid)));
157
158 // create an contact object
159 std::shared_ptr<crocoddyl::ContactModelAbstract> rand_contact =
160
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 create_random_contact();
161
162 // add twice the same contact object to the container
163
2/4
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
1 model.addContact("random_contact", rand_contact);
164
165 // test error message when we add a duplicate contact
166
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 CaptureIOStream capture_ios;
167
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 capture_ios.beginCapture();
168
2/4
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
1 model.addContact("random_contact", rand_contact);
169
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 capture_ios.endCapture();
170
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 std::stringstream expected_buffer;
171 expected_buffer << "Warning: we couldn't add the random_contact contact "
172
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 "item, it already existed."
173
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 << std::endl;
174
8/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1 times.
✗ Branch 25 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 1 times.
1 BOOST_CHECK(capture_ios.str() == expected_buffer.str());
175
176 // test error message when we change the contact status of an inexistent
177 // contact
178
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 capture_ios.beginCapture();
179
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 model.changeContactStatus("no_exist_contact", true);
180
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 capture_ios.endCapture();
181
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 expected_buffer.clear();
182 expected_buffer << "Warning: we couldn't change the status of the "
183
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 "no_exist_contact contact item, it doesn't exist."
184
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 << std::endl;
185
8/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1 times.
✗ Branch 25 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 1 times.
1 BOOST_CHECK(capture_ios.str() == expected_buffer.str());
186 1 }
187
188 1 void test_removeContact() {
189 // Setup the test
190
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelFactory state_factory;
191 crocoddyl::ContactModelMultiple model(
192
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::static_pointer_cast<crocoddyl::StateMultibody>(state_factory.create(
193
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelTypes::StateMultibody_RandomHumanoid)));
194
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 crocoddyl::ContactModelMultipleTpl<float> casted_model = model.cast<float>();
195
196 // add an active contact
197 std::shared_ptr<crocoddyl::ContactModelAbstract> rand_contact =
198
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 create_random_contact();
199
2/4
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
1 model.addContact("random_contact", rand_contact);
200
8/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1 times.
✗ Branch 25 not taken.
✗ Branch 29 not taken.
✓ Branch 30 taken 1 times.
1 BOOST_CHECK(model.get_nc() == rand_contact->get_nc());
201
8/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1 times.
✗ Branch 25 not taken.
✗ Branch 29 not taken.
✓ Branch 30 taken 1 times.
1 BOOST_CHECK(model.get_nc_total() == rand_contact->get_nc());
202
203 // remove the contact
204
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 model.removeContact("random_contact");
205
7/14
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 1 times.
✗ Branch 21 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 1 times.
1 BOOST_CHECK(model.get_nc() == 0);
206
7/14
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 1 times.
✗ Branch 21 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 1 times.
1 BOOST_CHECK(model.get_nc_total() == 0);
207
208 // Checking that casted computation is the same
209 #ifdef NDEBUG // Run only in release mode
210 std::shared_ptr<crocoddyl::ContactModelAbstractTpl<float>>
211 casted_rand_contact = rand_contact->cast<float>();
212 casted_model.addContact("random_contact", casted_rand_contact);
213 BOOST_CHECK(casted_model.get_nc() == casted_rand_contact->get_nc());
214 BOOST_CHECK(casted_model.get_nc_total() == casted_rand_contact->get_nc());
215 casted_model.removeContact("random_contact");
216 BOOST_CHECK(casted_model.get_nc() == 0);
217 BOOST_CHECK(casted_model.get_nc_total() == 0);
218 #endif
219 1 }
220
221 1 void test_removeContact_error_message() {
222 // Setup the test
223
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelFactory state_factory;
224 crocoddyl::ContactModelMultiple model(
225
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::static_pointer_cast<crocoddyl::StateMultibody>(state_factory.create(
226
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelTypes::StateMultibody_RandomHumanoid)));
227
228 // remove a none existing contact form the container, we expect a cout message
229 // here
230
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 CaptureIOStream capture_ios;
231
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 capture_ios.beginCapture();
232
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 model.removeContact("random_contact");
233
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 capture_ios.endCapture();
234
235 // Test that the error message is sent.
236
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 std::stringstream expected_buffer;
237 expected_buffer << "Warning: we couldn't remove the random_contact contact "
238
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 "item, it doesn't exist."
239
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 << std::endl;
240
8/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1 times.
✗ Branch 25 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 1 times.
1 BOOST_CHECK(capture_ios.str() == expected_buffer.str());
241 1 }
242
243 1 void test_calc() {
244 // Setup the test
245
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelFactory state_factory;
246 crocoddyl::ContactModelMultiple model(
247
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::static_pointer_cast<crocoddyl::StateMultibody>(state_factory.create(
248
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelTypes::StateMultibody_RandomHumanoid)));
249
250 // create the corresponding data object
251
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 pinocchio::Model& pinocchio_model = *model.get_state()->get_pinocchio().get();
252
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
1 pinocchio::Data pinocchio_data(*model.get_state()->get_pinocchio().get());
253
254 // create and add some contact objects
255 1 std::vector<std::shared_ptr<crocoddyl::ContactModelAbstract>> models;
256 1 std::vector<std::shared_ptr<crocoddyl::ContactDataAbstract>> datas;
257
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for (std::size_t i = 0; i < 5; ++i) {
258
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 std::ostringstream os;
259
2/4
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 os << "random_contact_" << i;
260 const std::shared_ptr<crocoddyl::ContactModelAbstract>& m =
261
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 create_random_contact();
262
2/4
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
5 model.addContact(os.str(), m);
263
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 models.push_back(m);
264
2/4
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
5 datas.push_back(m->createData(&pinocchio_data));
265 5 }
266
267 // create the data of the multiple-contacts
268 std::shared_ptr<crocoddyl::ContactDataMultiple> data =
269
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 model.createData(&pinocchio_data);
270
271 // compute the multiple contact data for the case when all contacts are
272 // defined as active
273
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 Eigen::VectorXd x1 = model.get_state()->rand();
274
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 crocoddyl::unittest::updateAllPinocchio(&pinocchio_model, &pinocchio_data,
275 x1);
276
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 model.calc(data, x1);
277
278 // check that only the Jacobian has been filled
279
7/14
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 1 times.
1 BOOST_CHECK(!data->Jc.isZero());
280
7/14
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 1 times.
1 BOOST_CHECK(!data->a0.isZero());
281
7/14
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 1 times.
1 BOOST_CHECK(data->da0_dx.isZero());
282
283 // check Jc and a0 against single contact computations
284 1 std::size_t nc = 0;
285
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 std::size_t nv = model.get_state()->get_nv();
286
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for (std::size_t i = 0; i < 5; ++i) {
287
1/2
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
5 const std::size_t nc_i = models[i]->get_nc();
288
2/4
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
5 models[i]->calc(datas[i], x1);
289
8/16
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 5 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 5 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 5 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 5 times.
5 BOOST_CHECK(data->Jc.block(nc, 0, nc_i, nv) == datas[i]->Jc);
290
8/16
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 5 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 5 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 5 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 5 times.
5 BOOST_CHECK(data->a0.segment(nc, nc_i) == datas[i]->a0);
291 5 nc += nc_i;
292 }
293 1 nc = 0;
294
295 // compute the multiple contact data for the case when the first three
296 // contacts are defined as active
297
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 model.changeContactStatus("random_contact_3", false);
298
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 model.changeContactStatus("random_contact_4", false);
299
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 Eigen::VectorXd x2 = model.get_state()->rand();
300
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 crocoddyl::unittest::updateAllPinocchio(&pinocchio_model, &pinocchio_data,
301 x2);
302
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 model.calc(data, x2);
303
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for (std::size_t i = 0; i < 5; ++i) {
304
1/2
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
5 const std::size_t nc_i = models[i]->get_nc();
305
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if (i < 3) { // we need to update data because this contacts are active
306
2/4
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
3 models[i]->calc(datas[i], x2);
307 }
308
8/16
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 5 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 5 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 5 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 5 times.
5 BOOST_CHECK(data->Jc.block(nc, 0, nc_i, nv) == datas[i]->Jc);
309
8/16
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 5 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 5 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 5 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 5 times.
5 BOOST_CHECK(data->a0.segment(nc, nc_i) == datas[i]->a0);
310 5 nc += nc_i;
311 }
312
313 // Checking that casted computation is the same
314 #ifdef NDEBUG // Run only in release mode
315 model.changeContactStatus("random_contact_3", true);
316 model.changeContactStatus("random_contact_4", true);
317 crocoddyl::ContactModelMultipleTpl<float> casted_model = model.cast<float>();
318 pinocchio::ModelTpl<float>& casted_pinocchio_model =
319 *casted_model.get_state()->get_pinocchio().get();
320 pinocchio::DataTpl<float> casted_pinocchio_data(
321 *casted_model.get_state()->get_pinocchio().get());
322 std::vector<std::shared_ptr<crocoddyl::ContactModelAbstractTpl<float>>>
323 casted_models;
324 std::vector<std::shared_ptr<crocoddyl::ContactDataAbstractTpl<float>>>
325 casted_datas;
326 for (std::size_t i = 0; i < 5; ++i) {
327 casted_models.push_back(models[i]->cast<float>());
328 casted_datas.push_back(
329 casted_models[i]->createData(&casted_pinocchio_data));
330 }
331 std::shared_ptr<crocoddyl::ContactDataMultipleTpl<float>> casted_data =
332 casted_model.createData(&casted_pinocchio_data);
333 const Eigen::VectorXf x1_f = x1.cast<float>();
334 crocoddyl::unittest::updateAllPinocchio(&pinocchio_model, &pinocchio_data,
335 x1);
336 crocoddyl::unittest::updateAllPinocchio(&casted_pinocchio_model,
337 &casted_pinocchio_data, x1_f);
338 model.calc(data, x1);
339 casted_model.calc(casted_data, x1_f);
340 BOOST_CHECK(!casted_data->Jc.isZero());
341 BOOST_CHECK(!casted_data->a0.isZero());
342 float tol_f = std::sqrt(2.0f * std::numeric_limits<float>::epsilon());
343 BOOST_CHECK((data->Jc.cast<float>() - casted_data->Jc).isZero(tol_f));
344 BOOST_CHECK((data->a0.cast<float>() - casted_data->a0).isZero(tol_f));
345 BOOST_CHECK(casted_data->da0_dx.isZero());
346 nc = 0;
347 nv = casted_model.get_state()->get_nv();
348 for (std::size_t i = 0; i < 5; ++i) {
349 const std::size_t nc_i = casted_models[i]->get_nc();
350 casted_models[i]->calc(casted_datas[i], x1_f);
351 BOOST_CHECK(casted_data->Jc.block(nc, 0, nc_i, nv) == casted_datas[i]->Jc);
352 BOOST_CHECK(casted_data->a0.segment(nc, nc_i) == casted_datas[i]->a0);
353 nc += nc_i;
354 }
355 nc = 0;
356 #endif
357 1 }
358
359 1 void test_calc_diff() {
360 // Setup the test
361
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelFactory state_factory;
362 crocoddyl::ContactModelMultiple model(
363
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::static_pointer_cast<crocoddyl::StateMultibody>(state_factory.create(
364
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelTypes::StateMultibody_RandomHumanoid)));
365 // create the corresponding data object
366
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 pinocchio::Model& pinocchio_model = *model.get_state()->get_pinocchio().get();
367
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
1 pinocchio::Data pinocchio_data(*model.get_state()->get_pinocchio().get());
368
369 // create and add some contact objects
370 1 std::vector<std::shared_ptr<crocoddyl::ContactModelAbstract>> models;
371 1 std::vector<std::shared_ptr<crocoddyl::ContactDataAbstract>> datas;
372
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for (std::size_t i = 0; i < 5; ++i) {
373
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 std::ostringstream os;
374
2/4
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 os << "random_contact_" << i;
375 const std::shared_ptr<crocoddyl::ContactModelAbstract>& m =
376
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 create_random_contact();
377
2/4
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
5 model.addContact(os.str(), m);
378
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 models.push_back(m);
379
2/4
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
5 datas.push_back(m->createData(&pinocchio_data));
380 5 }
381
382 // create the data of the multiple-contacts
383 std::shared_ptr<crocoddyl::ContactDataMultiple> data =
384
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 model.createData(&pinocchio_data);
385
386 // compute the multiple contact data for the case when all contacts are
387 // defined as active
388
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 Eigen::VectorXd x1 = model.get_state()->rand();
389
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 crocoddyl::unittest::updateAllPinocchio(&pinocchio_model, &pinocchio_data,
390 x1);
391
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 model.calc(data, x1);
392
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 model.calcDiff(data, x1);
393
394 // check that nothing has been computed and that all value are initialized to
395 // 0
396
7/14
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 1 times.
1 BOOST_CHECK(!data->Jc.isZero());
397
7/14
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 1 times.
1 BOOST_CHECK(!data->a0.isZero());
398
7/14
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 1 times.
1 BOOST_CHECK(!data->da0_dx.isZero());
399
400 // check Jc and a0 against single contact computations
401 1 std::size_t nc = 0;
402
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 std::size_t nv = model.get_state()->get_nv();
403
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 std::size_t ndx = model.get_state()->get_ndx();
404
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for (std::size_t i = 0; i < 5; ++i) {
405
1/2
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
5 const std::size_t nc_i = models[i]->get_nc();
406
2/4
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
5 models[i]->calc(datas[i], x1);
407
2/4
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
5 models[i]->calcDiff(datas[i], x1);
408
8/16
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 5 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 5 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 5 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 5 times.
5 BOOST_CHECK(data->Jc.block(nc, 0, nc_i, nv) == datas[i]->Jc);
409
8/16
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 5 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 5 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 5 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 5 times.
5 BOOST_CHECK(data->a0.segment(nc, nc_i) == datas[i]->a0);
410
8/16
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 5 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 5 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 5 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 5 times.
5 BOOST_CHECK(data->da0_dx.block(nc, 0, nc_i, ndx) == datas[i]->da0_dx);
411 5 nc += nc_i;
412 }
413 1 nc = 0;
414
415 // compute the multiple contact data for the case when the first three
416 // contacts are defined as active
417
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 model.changeContactStatus("random_contact_3", false);
418
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 model.changeContactStatus("random_contact_4", false);
419
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 Eigen::VectorXd x2 = model.get_state()->rand();
420
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 crocoddyl::unittest::updateAllPinocchio(&pinocchio_model, &pinocchio_data,
421 x2);
422
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 model.calc(data, x2);
423
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 model.calcDiff(data, x2);
424
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for (std::size_t i = 0; i < 5; ++i) {
425
1/2
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
5 const std::size_t nc_i = models[i]->get_nc();
426
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if (i < 3) { // we need to update data because this contacts are active
427
2/4
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
3 models[i]->calc(datas[i], x2);
428
2/4
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
3 models[i]->calcDiff(datas[i], x2);
429 }
430
8/16
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 5 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 5 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 5 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 5 times.
5 BOOST_CHECK(data->Jc.block(nc, 0, nc_i, nv) == datas[i]->Jc);
431
8/16
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 5 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 5 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 5 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 5 times.
5 BOOST_CHECK(data->a0.segment(nc, nc_i) == datas[i]->a0);
432
8/16
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 5 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 5 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 5 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 5 times.
5 BOOST_CHECK(data->da0_dx.block(nc, 0, nc_i, ndx) == datas[i]->da0_dx);
433 5 nc += nc_i;
434 }
435
436 // Checking that casted computation is the same
437 #ifdef NDEBUG // Run only in release mode
438 model.changeContactStatus("random_contact_3", true);
439 model.changeContactStatus("random_contact_4", true);
440 crocoddyl::ContactModelMultipleTpl<float> casted_model = model.cast<float>();
441 pinocchio::ModelTpl<float>& casted_pinocchio_model =
442 *casted_model.get_state()->get_pinocchio().get();
443 pinocchio::DataTpl<float> casted_pinocchio_data(
444 *casted_model.get_state()->get_pinocchio().get());
445 std::vector<std::shared_ptr<crocoddyl::ContactModelAbstractTpl<float>>>
446 casted_models;
447 std::vector<std::shared_ptr<crocoddyl::ContactDataAbstractTpl<float>>>
448 casted_datas;
449 for (std::size_t i = 0; i < 5; ++i) {
450 casted_models.push_back(models[i]->cast<float>());
451 casted_datas.push_back(
452 casted_models[i]->createData(&casted_pinocchio_data));
453 }
454 std::shared_ptr<crocoddyl::ContactDataMultipleTpl<float>> casted_data =
455 casted_model.createData(&casted_pinocchio_data);
456 const Eigen::VectorXf x1_f = x1.cast<float>();
457 crocoddyl::unittest::updateAllPinocchio(&pinocchio_model, &pinocchio_data,
458 x1);
459 crocoddyl::unittest::updateAllPinocchio(&casted_pinocchio_model,
460 &casted_pinocchio_data, x1_f);
461 model.calc(data, x1);
462 model.calcDiff(data, x1);
463 casted_model.calc(casted_data, x1_f);
464 casted_model.calcDiff(casted_data, x1_f);
465 BOOST_CHECK(!casted_data->Jc.isZero());
466 BOOST_CHECK(!casted_data->a0.isZero());
467 float tol_f = std::sqrt(2.0f * std::numeric_limits<float>::epsilon());
468 BOOST_CHECK((data->Jc.cast<float>() - casted_data->Jc).isZero(tol_f));
469 BOOST_CHECK((data->a0.cast<float>() - casted_data->a0).isZero(tol_f));
470 BOOST_CHECK((data->da0_dx.cast<float>() - casted_data->da0_dx).isZero(tol_f));
471 nc = 0;
472 nv = casted_model.get_state()->get_nv();
473 ndx = casted_model.get_state()->get_ndx();
474 for (std::size_t i = 0; i < 5; ++i) {
475 const std::size_t nc_i = casted_models[i]->get_nc();
476 casted_models[i]->calc(casted_datas[i], x1_f);
477 casted_models[i]->calcDiff(casted_datas[i], x1_f);
478 BOOST_CHECK(casted_data->Jc.block(nc, 0, nc_i, nv) == casted_datas[i]->Jc);
479 BOOST_CHECK(casted_data->a0.segment(nc, nc_i) == casted_datas[i]->a0);
480 BOOST_CHECK(casted_data->da0_dx.block(nc, 0, nc_i, ndx) ==
481 casted_datas[i]->da0_dx);
482 nc += nc_i;
483 }
484 nc = 0;
485 #endif
486 1 }
487
488 1 void test_calc_diff_no_recalc() {
489 // Setup the test
490
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelFactory state_factory;
491 crocoddyl::ContactModelMultiple model(
492
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::static_pointer_cast<crocoddyl::StateMultibody>(state_factory.create(
493
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelTypes::StateMultibody_RandomHumanoid)));
494 // create the corresponding data object
495
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 pinocchio::Model& pinocchio_model = *model.get_state()->get_pinocchio().get();
496
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
1 pinocchio::Data pinocchio_data(*model.get_state()->get_pinocchio().get());
497
498 // create and add some contact objects
499 1 std::vector<std::shared_ptr<crocoddyl::ContactModelAbstract>> models;
500 1 std::vector<std::shared_ptr<crocoddyl::ContactDataAbstract>> datas;
501
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for (std::size_t i = 0; i < 5; ++i) {
502
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 std::ostringstream os;
503
2/4
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 os << "random_contact_" << i;
504 const std::shared_ptr<crocoddyl::ContactModelAbstract>& m =
505
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 create_random_contact();
506
2/4
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
5 model.addContact(os.str(), m);
507
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 models.push_back(m);
508
2/4
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
5 datas.push_back(m->createData(&pinocchio_data));
509 5 }
510
511 // create the data of the multiple-contacts
512 std::shared_ptr<crocoddyl::ContactDataMultiple> data =
513
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 model.createData(&pinocchio_data);
514
515 // compute the multiple contact data for the case when all contacts are
516 // defined as active
517
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 Eigen::VectorXd x1 = model.get_state()->rand();
518
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 crocoddyl::unittest::updateAllPinocchio(&pinocchio_model, &pinocchio_data,
519 x1);
520
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 model.calcDiff(data, x1);
521
522 // check that nothing has been computed and that all value are initialized to
523 // 0
524
7/14
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 1 times.
1 BOOST_CHECK(data->Jc.isZero());
525
7/14
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 1 times.
1 BOOST_CHECK(data->a0.isZero());
526
7/14
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 1 times.
1 BOOST_CHECK(!data->da0_dx.isZero());
527
528 // check Jc and a0 against single contact computations
529 1 std::size_t nc = 0;
530
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 const std::size_t nv = model.get_state()->get_nv();
531
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 const std::size_t ndx = model.get_state()->get_ndx();
532
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for (std::size_t i = 0; i < 5; ++i) {
533
1/2
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
5 const std::size_t nc_i = models[i]->get_nc();
534
2/4
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
5 models[i]->calcDiff(datas[i], x1);
535
8/16
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 5 times.
✗ Branch 16 not taken.
✓ Branch 19 taken 5 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 5 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 5 times.
✗ Branch 26 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 5 times.
5 BOOST_CHECK(data->Jc.block(nc, 0, nc_i, nv).isZero());
536
8/16
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 5 times.
✗ Branch 16 not taken.
✓ Branch 19 taken 5 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 5 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 5 times.
✗ Branch 26 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 5 times.
5 BOOST_CHECK(data->a0.segment(nc, nc_i).isZero());
537
8/16
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 5 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 5 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 5 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 5 times.
5 BOOST_CHECK(data->da0_dx.block(nc, 0, nc_i, ndx) == datas[i]->da0_dx);
538 5 nc += nc_i;
539 }
540 1 nc = 0;
541
542 // compute the multiple contact data for the case when the first three
543 // contacts are defined as active
544
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 model.changeContactStatus("random_contact_3", false);
545
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 model.changeContactStatus("random_contact_4", false);
546
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 Eigen::VectorXd x2 = model.get_state()->rand();
547
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 crocoddyl::unittest::updateAllPinocchio(&pinocchio_model, &pinocchio_data,
548 x2);
549
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 model.calcDiff(data, x2);
550
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for (std::size_t i = 0; i < 5; ++i) {
551
1/2
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
5 const std::size_t nc_i = models[i]->get_nc();
552
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if (i < 3) { // we need to update data because this contacts are active
553
2/4
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
3 models[i]->calcDiff(datas[i], x2);
554 }
555
8/16
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 5 times.
✗ Branch 16 not taken.
✓ Branch 19 taken 5 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 5 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 5 times.
✗ Branch 26 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 5 times.
5 BOOST_CHECK(data->Jc.block(nc, 0, nc_i, nv).isZero());
556
8/16
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 5 times.
✗ Branch 16 not taken.
✓ Branch 19 taken 5 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 5 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 5 times.
✗ Branch 26 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 5 times.
5 BOOST_CHECK(data->a0.segment(nc, nc_i).isZero());
557
8/16
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 5 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 5 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 5 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 5 times.
5 BOOST_CHECK(data->da0_dx.block(nc, 0, nc_i, ndx) == datas[i]->da0_dx);
558 5 nc += nc_i;
559 }
560 1 }
561
562 1 void test_updateForce() {
563 // Setup the test
564
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelFactory state_factory;
565 crocoddyl::ContactModelMultiple model(
566
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::static_pointer_cast<crocoddyl::StateMultibody>(state_factory.create(
567
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelTypes::StateMultibody_RandomHumanoid)));
568
569 // create the corresponding data object
570 const pinocchio::Model& pinocchio_model =
571
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 *model.get_state()->get_pinocchio().get();
572
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
1 pinocchio::Data pinocchio_data(*model.get_state()->get_pinocchio().get());
573
574 // create and add some contact objects
575
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for (unsigned i = 0; i < 5; ++i) {
576
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 std::ostringstream os;
577
2/4
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 os << "random_contact_" << i;
578
3/6
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
5 model.addContact(os.str(), create_random_contact());
579 5 }
580
581 // create the data of the multiple-contacts
582 std::shared_ptr<crocoddyl::ContactDataMultiple> data =
583
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 model.createData(&pinocchio_data);
584
585 // Compute the jacobian and check that the contact model fetch it.
586 Eigen::VectorXd q =
587
6/12
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
1 model.get_state()->rand().segment(0, model.get_state()->get_nq());
588
4/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
1 Eigen::VectorXd v = Eigen::VectorXd::Random(model.get_state()->get_nv());
589
4/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
1 Eigen::VectorXd a = Eigen::VectorXd::Random(model.get_state()->get_nv());
590
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 pinocchio::computeJointJacobians(pinocchio_model, pinocchio_data, q);
591
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 pinocchio::updateFramePlacements(pinocchio_model, pinocchio_data);
592
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 pinocchio::computeForwardKinematicsDerivatives(pinocchio_model,
593 pinocchio_data, q, v, a);
594
595 // create random forces
596
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
1 Eigen::VectorXd forces = Eigen::VectorXd::Random(model.get_nc());
597
598 // update forces
599
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 model.updateForce(data, forces);
600
601 // Check that nothing has been computed and that all value are initialized to
602 // 0
603
7/14
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 1 times.
1 BOOST_CHECK(data->Jc.isZero());
604
7/14
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 1 times.
1 BOOST_CHECK(data->a0.isZero());
605
7/14
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 1 times.
1 BOOST_CHECK(data->da0_dx.isZero());
606 1 crocoddyl::ContactModelMultiple::ContactDataContainer::iterator it_d, end_d;
607 1 for (it_d = data->contacts.begin(), end_d = data->contacts.end();
608
2/2
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 1 times.
6 it_d != end_d; ++it_d) {
609
8/16
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 5 times.
✗ Branch 17 not taken.
✓ Branch 20 taken 5 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 5 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 5 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 5 times.
5 BOOST_CHECK(!it_d->second->f.toVector().isZero());
610 }
611
612 // Checking that casted computation is the same
613 #ifdef NDEBUG // Run only in release mode
614 crocoddyl::ContactModelMultipleTpl<float> casted_model = model.cast<float>();
615 pinocchio::ModelTpl<float>& casted_pinocchio_model =
616 *casted_model.get_state()->get_pinocchio().get();
617 pinocchio::DataTpl<float> casted_pinocchio_data(
618 *casted_model.get_state()->get_pinocchio().get());
619 std::shared_ptr<crocoddyl::ContactDataMultipleTpl<float>> casted_data =
620 casted_model.createData(&casted_pinocchio_data);
621 const Eigen::VectorXf q_f = casted_model.get_state()->rand().segment(
622 0, casted_model.get_state()->get_nq());
623 const Eigen::VectorXf v_f =
624 Eigen::VectorXf::Random(casted_model.get_state()->get_nv());
625 const Eigen::VectorXf a_f =
626 Eigen::VectorXf::Random(casted_model.get_state()->get_nv());
627 pinocchio::computeJointJacobians(casted_pinocchio_model,
628 casted_pinocchio_data, q_f);
629 pinocchio::updateFramePlacements(casted_pinocchio_model,
630 casted_pinocchio_data);
631 pinocchio::computeForwardKinematicsDerivatives(
632 casted_pinocchio_model, casted_pinocchio_data, q_f, v_f, a_f);
633 const Eigen::VectorXf forces_f = forces.cast<float>();
634 casted_model.updateForce(casted_data, forces_f);
635 BOOST_CHECK(casted_data->Jc.isZero());
636 BOOST_CHECK(casted_data->a0.isZero());
637 BOOST_CHECK(casted_data->da0_dx.isZero());
638 float tol_f = std::sqrt(2.0f * std::numeric_limits<float>::epsilon());
639 crocoddyl::ContactModelMultipleTpl<float>::ContactDataContainer::iterator
640 it_d_f,
641 end_d_f;
642 for (it_d_f = casted_data->contacts.begin(),
643 end_d_f = casted_data->contacts.end(), it_d = data->contacts.begin(),
644 end_d = data->contacts.end();
645 it_d_f != end_d_f || it_d != end_d; ++it_d_f, ++it_d) {
646 BOOST_CHECK(!it_d_f->second->f.toVector().isZero());
647 BOOST_CHECK((it_d->second->f.toVector().cast<float>() -
648 it_d_f->second->f.toVector())
649 .isZero(tol_f));
650 }
651 #endif
652 1 }
653
654 1 void test_updateAccelerationDiff() {
655 // Setup the test
656
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelFactory state_factory;
657 crocoddyl::ContactModelMultiple model(
658
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::static_pointer_cast<crocoddyl::StateMultibody>(state_factory.create(
659
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelTypes::StateMultibody_RandomHumanoid)));
660 // create the corresponding data object
661
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
1 pinocchio::Data pinocchio_data(*model.get_state()->get_pinocchio().get());
662
663 // create and add some contact objects
664
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for (unsigned i = 0; i < 5; ++i) {
665
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 std::ostringstream os;
666
2/4
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 os << "random_contact_" << i;
667
3/6
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
5 model.addContact(os.str(), create_random_contact());
668 5 }
669
670 // create the data of the multiple-contacts
671 std::shared_ptr<crocoddyl::ContactDataMultiple> data =
672
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 model.createData(&pinocchio_data);
673
674 // create the velocity diff
675 Eigen::MatrixXd ddv_dx = Eigen::MatrixXd::Random(
676
6/12
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
1 model.get_state()->get_nv(), model.get_state()->get_ndx());
677
678 // call the update
679
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 model.updateAccelerationDiff(data, ddv_dx);
680
681 // Test
682
8/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1 times.
✗ Branch 25 not taken.
✗ Branch 29 not taken.
✓ Branch 30 taken 1 times.
1 BOOST_CHECK((data->ddv_dx - ddv_dx).isZero(1e-9));
683
684 // Checking that casted computation is the same
685 #ifdef NDEBUG // Run only in release mode
686 crocoddyl::ContactModelMultipleTpl<float> casted_model = model.cast<float>();
687 pinocchio::DataTpl<float> casted_pinocchio_data(
688 *casted_model.get_state()->get_pinocchio().get());
689 std::shared_ptr<crocoddyl::ContactDataMultipleTpl<float>> casted_data =
690 casted_model.createData(&casted_pinocchio_data);
691 const Eigen::MatrixXf ddv_dx_f = ddv_dx.cast<float>();
692 casted_model.updateAccelerationDiff(casted_data, ddv_dx_f);
693 BOOST_CHECK((casted_data->ddv_dx - ddv_dx_f).isZero(1e-9f));
694 #endif
695 1 }
696
697 void test_updateForceDiff() {
698 // Setup the test
699 StateModelFactory state_factory;
700 crocoddyl::ContactModelMultiple model(
701 std::static_pointer_cast<crocoddyl::StateMultibody>(state_factory.create(
702 StateModelTypes::StateMultibody_RandomHumanoid)));
703 // create the corresponding data object
704 pinocchio::Data pinocchio_data(*model.get_state()->get_pinocchio().get());
705
706 // create and add some contact objects
707 for (unsigned i = 0; i < 5; ++i) {
708 std::ostringstream os;
709 os << "random_contact_" << i;
710 model.addContact(os.str(), create_random_contact());
711 }
712
713 // create the data of the multiple-contacts
714 std::shared_ptr<crocoddyl::ContactDataMultiple> data =
715 model.createData(&pinocchio_data);
716
717 // create force diff
718 Eigen::MatrixXd df_dx =
719 Eigen::MatrixXd::Random(model.get_nc(), model.get_state()->get_nv());
720 Eigen::MatrixXd df_du =
721 Eigen::MatrixXd::Random(model.get_nc(), model.get_state()->get_nv());
722
723 // call update force diff
724 model.updateForceDiff(data, df_dx, df_du);
725
726 // Test
727 crocoddyl::ContactModelMultiple::ContactDataContainer::iterator it_d, end_d;
728 for (it_d = data->contacts.begin(), end_d = data->contacts.end();
729 it_d != end_d; ++it_d) {
730 BOOST_CHECK(!it_d->second->df_dx.isZero());
731 }
732
733 // Checking that casted computation is the same
734 #ifdef NDEBUG // Run only in release mode
735 crocoddyl::ContactModelMultipleTpl<float> casted_model = model.cast<float>();
736 pinocchio::DataTpl<float> casted_pinocchio_data(
737 *casted_model.get_state()->get_pinocchio().get());
738 std::shared_ptr<crocoddyl::ContactDataMultipleTpl<float>> casted_data =
739 casted_model.createData(&casted_pinocchio_data);
740 const Eigen::MatrixXf df_dx_f = df_dx.cast<float>();
741 const Eigen::MatrixXf df_du_f = df_du.cast<float>();
742 casted_model.updateForceDiff(casted_data, df_dx_f, df_du_f);
743 float tol_f = std::sqrt(2.0f * std::numeric_limits<float>::epsilon());
744 crocoddyl::ContactModelMultipleTpl<float>::ContactDataContainer::iterator
745 it_d_f,
746 end_d_f;
747 for (it_d_f = casted_data->contacts.begin(),
748 end_d_f = casted_data->contacts.end(), it_d = data->contacts.begin(),
749 end_d = data->contacts.end();
750 it_d_f != end_d_f || it_d != end_d; ++it_d_f, ++it_d) {
751 BOOST_CHECK(!it_d_f->second->df_dx.isZero());
752 BOOST_CHECK((it_d->second->df_dx.cast<float>() - it_d_f->second->df_dx)
753 .isZero(tol_f));
754 }
755 #endif
756 }
757
758 void test_assert_updateForceDiff_assert_mismatch_model_data() {
759 // Setup the test
760 StateModelFactory state_factory;
761 crocoddyl::ContactModelMultiple model1(
762 std::static_pointer_cast<crocoddyl::StateMultibody>(state_factory.create(
763 StateModelTypes::StateMultibody_RandomHumanoid)));
764 crocoddyl::ContactModelMultiple model2(
765 std::static_pointer_cast<crocoddyl::StateMultibody>(state_factory.create(
766 StateModelTypes::StateMultibody_RandomHumanoid)));
767 // create the corresponding data object
768 pinocchio::Data pinocchio_data(*model1.get_state()->get_pinocchio().get());
769
770 // create and add some contact objects
771 for (unsigned i = 0; i < 5; ++i) {
772 std::shared_ptr<crocoddyl::ContactModelAbstract> rand_contact =
773 create_random_contact();
774 {
775 std::ostringstream os;
776 os << "random_contact1_" << i;
777 model1.addContact(os.str(), rand_contact);
778 }
779 {
780 std::ostringstream os;
781 os << "random_contact2_" << i;
782 model2.addContact(os.str(), rand_contact);
783 }
784 }
785
786 // create the data of the multiple-contacts
787 std::shared_ptr<crocoddyl::ContactDataMultiple> data1 =
788 model1.createData(&pinocchio_data);
789 std::shared_ptr<crocoddyl::ContactDataMultiple> data2 =
790 model2.createData(&pinocchio_data);
791
792 // create force diff
793 Eigen::MatrixXd df_dx =
794 Eigen::MatrixXd::Random(model1.get_nc(), model1.get_state()->get_nv());
795 Eigen::MatrixXd df_du =
796 Eigen::MatrixXd::Random(model1.get_nc(), model1.get_state()->get_nv());
797
798 // call that trigger assert
799 std::string error_message = GetErrorMessages(
800 boost::bind(&updateForceDiff, model1, data2, df_dx, df_du));
801
802 // expected error message content
803 std::string function_name =
804 "void crocoddyl::ContactModelMultiple::updateForceDiff("
805 "const std::shared_ptr<crocoddyl::ContactDataMultiple>&,"
806 " const MatrixXd&) const";
807 std::string assert_argument =
808 "it_m->first == it_d->first && \"it doesn't match"
809 " the contact name between data and model\"";
810
811 // Perform the checks
812 #ifndef __APPLE__
813 BOOST_CHECK(error_message.find(function_name) != std::string::npos);
814 #endif
815 BOOST_CHECK(error_message.find(assert_argument) != std::string::npos);
816 }
817
818 1 void test_get_contacts() {
819 // Setup the test
820
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelFactory state_factory;
821 crocoddyl::ContactModelMultiple model(
822
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::static_pointer_cast<crocoddyl::StateMultibody>(state_factory.create(
823
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelTypes::StateMultibody_RandomHumanoid)));
824 // create the corresponding data object
825
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
1 pinocchio::Data pinocchio_data(*model.get_state()->get_pinocchio().get());
826
827 // create and add some contact objects
828
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for (unsigned i = 0; i < 5; ++i) {
829
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 std::ostringstream os;
830
2/4
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 os << "random_contact_" << i;
831
3/6
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
5 model.addContact(os.str(), create_random_contact());
832 5 }
833
834 // get the contacts
835 const crocoddyl::ContactModelMultiple::ContactModelContainer& contacts =
836
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 model.get_contacts();
837
838 // test
839 1 crocoddyl::ContactModelMultiple::ContactModelContainer::const_iterator it_m,
840 1 end_m;
841 unsigned i;
842
2/2
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 1 times.
6 for (i = 0, it_m = contacts.begin(), end_m = contacts.end(); it_m != end_m;
843 5 ++it_m, ++i) {
844
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 std::ostringstream os;
845
2/4
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 os << "random_contact_" << i;
846
7/14
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 5 times.
✗ Branch 15 not taken.
✓ Branch 19 taken 5 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 5 times.
✗ Branch 23 not taken.
✗ Branch 28 not taken.
✓ Branch 29 taken 5 times.
5 BOOST_CHECK(it_m->first == os.str());
847 5 }
848 1 }
849
850 1 void test_get_nc() {
851 // Setup the test
852
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelFactory state_factory;
853 crocoddyl::ContactModelMultiple model(
854
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::static_pointer_cast<crocoddyl::StateMultibody>(state_factory.create(
855
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StateModelTypes::StateMultibody_RandomHumanoid)));
856
857 // create the corresponding data object
858
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
1 pinocchio::Data pinocchio_data(*model.get_state()->get_pinocchio().get());
859
860 // create and add some contact objects
861
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for (unsigned i = 0; i < 5; ++i) {
862
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 std::ostringstream os;
863
2/4
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 os << "random_contact_" << i;
864
3/6
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
5 model.addContact(os.str(), create_random_contact());
865 5 }
866
867 // compute ni
868 1 std::size_t ni = 0;
869 1 crocoddyl::ContactModelMultiple::ContactModelContainer::const_iterator it_m,
870 1 end_m;
871
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 for (it_m = model.get_contacts().begin(), end_m = model.get_contacts().end();
872
2/2
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 1 times.
6 it_m != end_m; ++it_m) {
873
1/2
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 ni += it_m->second->contact->get_nc();
874 }
875
876
7/14
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 1 times.
✗ Branch 21 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 1 times.
1 BOOST_CHECK(ni == model.get_nc());
877 1 }
878
879 //----------------------------------------------------------------------------//
880
881 1 void register_unit_tests() {
882 1 framework::master_test_suite().add(
883
4/8
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
1 BOOST_TEST_CASE(boost::bind(&test_constructor)));
884 1 framework::master_test_suite().add(
885
4/8
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
1 BOOST_TEST_CASE(boost::bind(&test_addContact)));
886 1 framework::master_test_suite().add(
887
4/8
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
1 BOOST_TEST_CASE(boost::bind(&test_addContact_error_message)));
888 1 framework::master_test_suite().add(
889
4/8
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
1 BOOST_TEST_CASE(boost::bind(&test_removeContact)));
890 1 framework::master_test_suite().add(
891
4/8
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
1 BOOST_TEST_CASE(boost::bind(&test_removeContact_error_message)));
892
4/8
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
1 framework::master_test_suite().add(BOOST_TEST_CASE(boost::bind(&test_calc)));
893 1 framework::master_test_suite().add(
894
4/8
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
1 BOOST_TEST_CASE(boost::bind(&test_calc_diff)));
895 1 framework::master_test_suite().add(
896
4/8
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
1 BOOST_TEST_CASE(boost::bind(&test_calc_diff_no_recalc)));
897 1 framework::master_test_suite().add(
898
4/8
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
1 BOOST_TEST_CASE(boost::bind(&test_updateForce)));
899 1 framework::master_test_suite().add(
900
4/8
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
1 BOOST_TEST_CASE(boost::bind(&test_updateAccelerationDiff)));
901 1 framework::master_test_suite().add(
902
4/8
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
1 BOOST_TEST_CASE(boost::bind(&test_get_contacts)));
903 1 framework::master_test_suite().add(
904
4/8
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
1 BOOST_TEST_CASE(boost::bind(&test_get_nc)));
905 1 }
906
907 1 bool init_function() {
908 1 register_unit_tests();
909 1 return true;
910 }
911
912 1 int main(int argc, char** argv) {
913 1 return ::boost::unit_test::unit_test_main(&init_function, argc, argv);
914 }
915