Directory: | ./ |
---|---|
File: | unittest/test_problem.cpp |
Date: | 2025-01-16 08:47:40 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 314 | 314 | 100.0% |
Branches: | 818 | 1582 | 51.7% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | ||
2 | // BSD 3-Clause License | ||
3 | // | ||
4 | // Copyright (C) 2020-2021, University of Edinburgh | ||
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 "crocoddyl/core/integrator/euler.hpp" | ||
13 | #include "crocoddyl/core/optctrl/shooting.hpp" | ||
14 | #include "factory/action.hpp" | ||
15 | #include "factory/diff_action.hpp" | ||
16 | #include "factory/integrator.hpp" | ||
17 | #include "unittest_common.hpp" | ||
18 | |||
19 | using namespace boost::unit_test; | ||
20 | using namespace crocoddyl::unittest; | ||
21 | |||
22 | //----------------------------------------------------------------------------// | ||
23 | |||
24 | 7 | void test_calc(ActionModelTypes::Type action_model_type) { | |
25 | // create the model | ||
26 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | ActionModelFactory factory; |
27 | const boost::shared_ptr<crocoddyl::ActionModelAbstract>& model = | ||
28 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | factory.create(action_model_type); |
29 | |||
30 | // create two shooting problems (with and without data allocation) | ||
31 | 7 | std::size_t T = 20; | |
32 |
1/2✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | const Eigen::VectorXd& x0 = model->get_state()->rand(); |
33 | std::vector<boost::shared_ptr<crocoddyl::ActionModelAbstract> > models(T, | ||
34 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | model); |
35 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | std::vector<boost::shared_ptr<crocoddyl::ActionDataAbstract> > datas(T); |
36 |
2/2✓ Branch 0 taken 140 times.
✓ Branch 1 taken 7 times.
|
147 | for (std::size_t i = 0; i < T; ++i) { |
37 |
1/2✓ Branch 2 taken 140 times.
✗ Branch 3 not taken.
|
140 | datas[i] = model->createData(); |
38 | } | ||
39 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | crocoddyl::ShootingProblem problem1(x0, models, model); |
40 | crocoddyl::ShootingProblem problem2(x0, models, model, datas, | ||
41 |
2/4✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
|
14 | model->createData()); |
42 | |||
43 | // Run the print function | ||
44 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | std::ostringstream tmp; |
45 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | tmp << problem1; |
46 | |||
47 | // create random trajectory | ||
48 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | std::vector<Eigen::VectorXd> xs(T + 1); |
49 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | std::vector<Eigen::VectorXd> us(T); |
50 |
2/2✓ Branch 0 taken 140 times.
✓ Branch 1 taken 7 times.
|
147 | for (std::size_t i = 0; i < T; ++i) { |
51 |
1/2✓ Branch 4 taken 140 times.
✗ Branch 5 not taken.
|
140 | xs[i] = model->get_state()->rand(); |
52 |
2/4✓ Branch 3 taken 140 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 140 times.
✗ Branch 8 not taken.
|
140 | us[i] = Eigen::VectorXd::Random(model->get_nu()); |
53 | } | ||
54 |
1/2✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | xs.back() = model->get_state()->rand(); |
55 | |||
56 | // check the state and cost in each node | ||
57 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | problem1.calc(xs, us); |
58 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | problem2.calc(xs, us); |
59 |
2/2✓ Branch 0 taken 140 times.
✓ Branch 1 taken 7 times.
|
147 | for (std::size_t i = 0; i < T; ++i) { |
60 | const boost::shared_ptr<crocoddyl::ActionDataAbstract>& data = | ||
61 |
1/2✓ Branch 2 taken 140 times.
✗ Branch 3 not taken.
|
140 | model->createData(); |
62 |
3/6✓ Branch 3 taken 140 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 140 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 140 times.
✗ Branch 11 not taken.
|
140 | model->calc(data, xs[i], us[i]); |
63 |
6/12✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 140 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 140 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 140 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 140 times.
✗ Branch 22 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 140 times.
|
140 | BOOST_CHECK(problem1.get_runningDatas()[i]->cost == data->cost); |
64 |
6/12✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 140 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 140 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 140 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 140 times.
✗ Branch 22 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 140 times.
|
140 | BOOST_CHECK(problem2.get_runningDatas()[i]->cost == data->cost); |
65 |
8/16✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 140 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 140 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 140 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 140 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 140 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 140 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 140 times.
|
140 | BOOST_CHECK( |
66 | (problem1.get_runningDatas()[i]->xnext - data->xnext).isZero(1e-9)); | ||
67 |
8/16✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 140 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 140 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 140 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 140 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 140 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 140 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 140 times.
|
140 | BOOST_CHECK( |
68 | (problem2.get_runningDatas()[i]->xnext - data->xnext).isZero(1e-9)); | ||
69 | 140 | } | |
70 | const boost::shared_ptr<crocoddyl::ActionDataAbstract>& data = | ||
71 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | model->createData(); |
72 |
2/4✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
|
7 | model->calc(data, xs.back()); |
73 |
6/12✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 7 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 7 times.
✗ Branch 21 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 7 times.
|
7 | BOOST_CHECK(problem1.get_terminalData()->cost == data->cost); |
74 |
6/12✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 7 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 7 times.
✗ Branch 21 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 7 times.
|
7 | BOOST_CHECK(problem2.get_terminalData()->cost == data->cost); |
75 |
8/16✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 7 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 7 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 7 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 7 times.
|
7 | BOOST_CHECK((problem1.get_terminalData()->xnext - data->xnext).isZero(1e-9)); |
76 |
8/16✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 7 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 7 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 7 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 7 times.
|
7 | BOOST_CHECK((problem2.get_terminalData()->xnext - data->xnext).isZero(1e-9)); |
77 | 7 | } | |
78 | |||
79 | 92 | void test_calc_diffAction(DifferentialActionModelTypes::Type action_model_type, | |
80 | IntegratorTypes::Type integrator_type) { | ||
81 | // create the model | ||
82 |
1/2✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
|
92 | DifferentialActionModelFactory factory; |
83 | const boost::shared_ptr<crocoddyl::DifferentialActionModelAbstract>& | ||
84 |
1/2✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
|
92 | diffModel = factory.create(action_model_type); |
85 |
1/2✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
|
92 | IntegratorFactory factory_int; |
86 | const boost::shared_ptr<crocoddyl::ActionModelAbstract>& model = | ||
87 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | factory_int.create(integrator_type, diffModel); |
88 | |||
89 | // create two shooting problems (with and without data allocation) | ||
90 | 92 | std::size_t T = 20; | |
91 |
1/2✓ Branch 4 taken 92 times.
✗ Branch 5 not taken.
|
92 | const Eigen::VectorXd& x0 = model->get_state()->rand(); |
92 | std::vector<boost::shared_ptr<crocoddyl::ActionModelAbstract> > models(T, | ||
93 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | model); |
94 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | std::vector<boost::shared_ptr<crocoddyl::ActionDataAbstract> > datas(T); |
95 |
2/2✓ Branch 0 taken 1840 times.
✓ Branch 1 taken 92 times.
|
1932 | for (std::size_t i = 0; i < T; ++i) { |
96 |
1/2✓ Branch 2 taken 1840 times.
✗ Branch 3 not taken.
|
1840 | datas[i] = model->createData(); |
97 | } | ||
98 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | crocoddyl::ShootingProblem problem1(x0, models, model); |
99 | crocoddyl::ShootingProblem problem2(x0, models, model, datas, | ||
100 |
2/4✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 92 times.
✗ Branch 7 not taken.
|
184 | model->createData()); |
101 | |||
102 | // create random trajectory | ||
103 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | std::vector<Eigen::VectorXd> xs(T + 1); |
104 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | std::vector<Eigen::VectorXd> us(T); |
105 |
2/2✓ Branch 0 taken 1840 times.
✓ Branch 1 taken 92 times.
|
1932 | for (std::size_t i = 0; i < T; ++i) { |
106 |
1/2✓ Branch 4 taken 1840 times.
✗ Branch 5 not taken.
|
1840 | xs[i] = model->get_state()->rand(); |
107 |
2/4✓ Branch 3 taken 1840 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 1840 times.
✗ Branch 8 not taken.
|
1840 | us[i] = Eigen::VectorXd::Random(model->get_nu()); |
108 | } | ||
109 |
1/2✓ Branch 4 taken 92 times.
✗ Branch 5 not taken.
|
92 | xs.back() = model->get_state()->rand(); |
110 | |||
111 | // check the state and cost in each node | ||
112 |
1/2✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
|
92 | problem1.calc(xs, us); |
113 |
1/2✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
|
92 | problem2.calc(xs, us); |
114 |
2/2✓ Branch 0 taken 1840 times.
✓ Branch 1 taken 92 times.
|
1932 | for (std::size_t i = 0; i < T; ++i) { |
115 | const boost::shared_ptr<crocoddyl::ActionDataAbstract>& data = | ||
116 |
1/2✓ Branch 2 taken 1840 times.
✗ Branch 3 not taken.
|
1840 | model->createData(); |
117 |
3/6✓ Branch 3 taken 1840 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 1840 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1840 times.
✗ Branch 11 not taken.
|
1840 | model->calc(data, xs[i], us[i]); |
118 |
6/12✓ Branch 1 taken 1840 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1840 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1840 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 1840 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1840 times.
✗ Branch 22 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 1840 times.
|
1840 | BOOST_CHECK(problem1.get_runningDatas()[i]->cost == data->cost); |
119 |
6/12✓ Branch 1 taken 1840 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1840 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1840 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 1840 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1840 times.
✗ Branch 22 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 1840 times.
|
1840 | BOOST_CHECK(problem2.get_runningDatas()[i]->cost == data->cost); |
120 |
8/16✓ Branch 1 taken 1840 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1840 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1840 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 1840 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1840 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1840 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 1840 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 1840 times.
|
1840 | BOOST_CHECK( |
121 | (problem1.get_runningDatas()[i]->xnext - data->xnext).isZero(1e-9)); | ||
122 |
8/16✓ Branch 1 taken 1840 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1840 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1840 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 1840 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1840 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1840 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 1840 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 1840 times.
|
1840 | BOOST_CHECK( |
123 | (problem2.get_runningDatas()[i]->xnext - data->xnext).isZero(1e-9)); | ||
124 | 1840 | } | |
125 | const boost::shared_ptr<crocoddyl::ActionDataAbstract>& data = | ||
126 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | model->createData(); |
127 |
2/4✓ Branch 3 taken 92 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 92 times.
✗ Branch 7 not taken.
|
92 | model->calc(data, xs.back()); |
128 |
6/12✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 92 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 92 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 92 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 92 times.
✗ Branch 21 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 92 times.
|
92 | BOOST_CHECK(problem1.get_terminalData()->cost == data->cost); |
129 |
6/12✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 92 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 92 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 92 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 92 times.
✗ Branch 21 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 92 times.
|
92 | BOOST_CHECK(problem2.get_terminalData()->cost == data->cost); |
130 |
8/16✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 92 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 92 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 92 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 92 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 92 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 92 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 92 times.
|
92 | BOOST_CHECK((problem1.get_terminalData()->xnext - data->xnext).isZero(1e-9)); |
131 |
8/16✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 92 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 92 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 92 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 92 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 92 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 92 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 92 times.
|
92 | BOOST_CHECK((problem2.get_terminalData()->xnext - data->xnext).isZero(1e-9)); |
132 | 92 | } | |
133 | |||
134 | 7 | void test_calcDiff(ActionModelTypes::Type action_model_type) { | |
135 | // create the model | ||
136 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | ActionModelFactory factory; |
137 | const boost::shared_ptr<crocoddyl::ActionModelAbstract>& model = | ||
138 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | factory.create(action_model_type); |
139 | |||
140 | // create two shooting problems (with and without data allocation) | ||
141 | 7 | std::size_t T = 20; | |
142 |
1/2✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | const Eigen::VectorXd& x0 = model->get_state()->rand(); |
143 | std::vector<boost::shared_ptr<crocoddyl::ActionModelAbstract> > models(T, | ||
144 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | model); |
145 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | std::vector<boost::shared_ptr<crocoddyl::ActionDataAbstract> > datas(T); |
146 |
2/2✓ Branch 0 taken 140 times.
✓ Branch 1 taken 7 times.
|
147 | for (std::size_t i = 0; i < T; ++i) { |
147 |
1/2✓ Branch 2 taken 140 times.
✗ Branch 3 not taken.
|
140 | datas[i] = model->createData(); |
148 | } | ||
149 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | crocoddyl::ShootingProblem problem1(x0, models, model); |
150 | crocoddyl::ShootingProblem problem2(x0, models, model, datas, | ||
151 |
2/4✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
|
14 | model->createData()); |
152 | |||
153 | // create random trajectory | ||
154 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | std::vector<Eigen::VectorXd> xs(T + 1); |
155 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | std::vector<Eigen::VectorXd> us(T); |
156 |
2/2✓ Branch 0 taken 140 times.
✓ Branch 1 taken 7 times.
|
147 | for (std::size_t i = 0; i < T; ++i) { |
157 |
1/2✓ Branch 4 taken 140 times.
✗ Branch 5 not taken.
|
140 | xs[i] = model->get_state()->rand(); |
158 |
2/4✓ Branch 3 taken 140 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 140 times.
✗ Branch 8 not taken.
|
140 | us[i] = Eigen::VectorXd::Random(model->get_nu()); |
159 | } | ||
160 |
1/2✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | xs.back() = model->get_state()->rand(); |
161 | |||
162 | // check the state and cost in each node | ||
163 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | problem1.calc(xs, us); |
164 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | problem2.calc(xs, us); |
165 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | problem1.calcDiff(xs, us); |
166 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | problem2.calcDiff(xs, us); |
167 |
2/2✓ Branch 0 taken 140 times.
✓ Branch 1 taken 7 times.
|
147 | for (std::size_t i = 0; i < T; ++i) { |
168 | const boost::shared_ptr<crocoddyl::ActionDataAbstract>& data = | ||
169 |
1/2✓ Branch 2 taken 140 times.
✗ Branch 3 not taken.
|
140 | model->createData(); |
170 |
3/6✓ Branch 3 taken 140 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 140 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 140 times.
✗ Branch 11 not taken.
|
140 | model->calc(data, xs[i], us[i]); |
171 |
3/6✓ Branch 3 taken 140 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 140 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 140 times.
✗ Branch 11 not taken.
|
140 | model->calcDiff(data, xs[i], us[i]); |
172 |
8/16✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 140 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 140 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 140 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 140 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 140 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 140 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 140 times.
|
140 | BOOST_CHECK((problem1.get_runningDatas()[i]->Fx - data->Fx).isZero(1e-9)); |
173 |
8/16✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 140 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 140 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 140 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 140 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 140 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 140 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 140 times.
|
140 | BOOST_CHECK((problem2.get_runningDatas()[i]->Fx - data->Fx).isZero(1e-9)); |
174 |
8/16✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 140 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 140 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 140 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 140 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 140 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 140 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 140 times.
|
140 | BOOST_CHECK((problem1.get_runningDatas()[i]->Fu - data->Fu).isZero(1e-9)); |
175 |
8/16✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 140 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 140 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 140 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 140 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 140 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 140 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 140 times.
|
140 | BOOST_CHECK((problem2.get_runningDatas()[i]->Fu - data->Fu).isZero(1e-9)); |
176 |
8/16✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 140 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 140 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 140 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 140 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 140 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 140 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 140 times.
|
140 | BOOST_CHECK((problem1.get_runningDatas()[i]->Lx - data->Lx).isZero(1e-9)); |
177 |
8/16✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 140 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 140 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 140 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 140 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 140 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 140 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 140 times.
|
140 | BOOST_CHECK((problem2.get_runningDatas()[i]->Lx - data->Lx).isZero(1e-9)); |
178 |
8/16✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 140 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 140 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 140 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 140 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 140 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 140 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 140 times.
|
140 | BOOST_CHECK((problem1.get_runningDatas()[i]->Lu - data->Lu).isZero(1e-9)); |
179 |
8/16✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 140 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 140 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 140 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 140 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 140 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 140 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 140 times.
|
140 | BOOST_CHECK((problem2.get_runningDatas()[i]->Lu - data->Lu).isZero(1e-9)); |
180 |
8/16✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 140 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 140 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 140 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 140 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 140 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 140 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 140 times.
|
140 | BOOST_CHECK((problem1.get_runningDatas()[i]->Lxx - data->Lxx).isZero(1e-9)); |
181 |
8/16✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 140 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 140 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 140 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 140 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 140 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 140 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 140 times.
|
140 | BOOST_CHECK((problem2.get_runningDatas()[i]->Lxx - data->Lxx).isZero(1e-9)); |
182 |
8/16✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 140 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 140 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 140 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 140 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 140 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 140 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 140 times.
|
140 | BOOST_CHECK((problem1.get_runningDatas()[i]->Lxu - data->Lxu).isZero(1e-9)); |
183 |
8/16✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 140 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 140 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 140 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 140 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 140 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 140 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 140 times.
|
140 | BOOST_CHECK((problem2.get_runningDatas()[i]->Lxu - data->Lxu).isZero(1e-9)); |
184 |
8/16✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 140 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 140 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 140 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 140 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 140 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 140 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 140 times.
|
140 | BOOST_CHECK((problem1.get_runningDatas()[i]->Luu - data->Luu).isZero(1e-9)); |
185 |
8/16✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 140 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 140 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 140 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 140 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 140 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 140 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 140 times.
|
140 | BOOST_CHECK((problem2.get_runningDatas()[i]->Luu - data->Luu).isZero(1e-9)); |
186 | 140 | } | |
187 | const boost::shared_ptr<crocoddyl::ActionDataAbstract>& data = | ||
188 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | model->createData(); |
189 |
2/4✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
|
7 | model->calc(data, xs.back()); |
190 |
2/4✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
|
7 | model->calcDiff(data, xs.back()); |
191 |
8/16✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 7 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 7 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 7 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 7 times.
|
7 | BOOST_CHECK((problem1.get_terminalData()->Fx - data->Fx).isZero(1e-9)); |
192 |
8/16✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 7 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 7 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 7 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 7 times.
|
7 | BOOST_CHECK((problem2.get_terminalData()->Fx - data->Fx).isZero(1e-9)); |
193 |
8/16✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 7 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 7 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 7 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 7 times.
|
7 | BOOST_CHECK((problem1.get_terminalData()->Lx - data->Lx).isZero(1e-9)); |
194 |
8/16✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 7 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 7 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 7 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 7 times.
|
7 | BOOST_CHECK((problem2.get_terminalData()->Lx - data->Lx).isZero(1e-9)); |
195 |
8/16✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 7 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 7 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 7 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 7 times.
|
7 | BOOST_CHECK((problem1.get_terminalData()->Lxx - data->Lxx).isZero(1e-9)); |
196 |
8/16✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 7 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 7 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 7 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 7 times.
|
7 | BOOST_CHECK((problem2.get_terminalData()->Lxx - data->Lxx).isZero(1e-9)); |
197 | 7 | } | |
198 | |||
199 | 92 | void test_calcDiff_diffAction( | |
200 | DifferentialActionModelTypes::Type action_model_type, | ||
201 | IntegratorTypes::Type integrator_type) { | ||
202 | // create the model | ||
203 |
1/2✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
|
92 | DifferentialActionModelFactory factory; |
204 | const boost::shared_ptr<crocoddyl::DifferentialActionModelAbstract>& | ||
205 |
1/2✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
|
92 | diffModel = factory.create(action_model_type); |
206 |
1/2✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
|
92 | IntegratorFactory factory_int; |
207 | const boost::shared_ptr<crocoddyl::ActionModelAbstract>& model = | ||
208 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | factory_int.create(integrator_type, diffModel); |
209 | |||
210 | // create two shooting problems (with and without data allocation) | ||
211 | 92 | std::size_t T = 20; | |
212 |
1/2✓ Branch 4 taken 92 times.
✗ Branch 5 not taken.
|
92 | const Eigen::VectorXd& x0 = model->get_state()->rand(); |
213 | std::vector<boost::shared_ptr<crocoddyl::ActionModelAbstract> > models(T, | ||
214 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | model); |
215 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | std::vector<boost::shared_ptr<crocoddyl::ActionDataAbstract> > datas(T); |
216 |
2/2✓ Branch 0 taken 1840 times.
✓ Branch 1 taken 92 times.
|
1932 | for (std::size_t i = 0; i < T; ++i) { |
217 |
1/2✓ Branch 2 taken 1840 times.
✗ Branch 3 not taken.
|
1840 | datas[i] = model->createData(); |
218 | } | ||
219 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | crocoddyl::ShootingProblem problem1(x0, models, model); |
220 | crocoddyl::ShootingProblem problem2(x0, models, model, datas, | ||
221 |
2/4✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 92 times.
✗ Branch 7 not taken.
|
184 | model->createData()); |
222 | |||
223 | // create random trajectory | ||
224 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | std::vector<Eigen::VectorXd> xs(T + 1); |
225 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | std::vector<Eigen::VectorXd> us(T); |
226 |
2/2✓ Branch 0 taken 1840 times.
✓ Branch 1 taken 92 times.
|
1932 | for (std::size_t i = 0; i < T; ++i) { |
227 |
1/2✓ Branch 4 taken 1840 times.
✗ Branch 5 not taken.
|
1840 | xs[i] = model->get_state()->rand(); |
228 |
2/4✓ Branch 3 taken 1840 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 1840 times.
✗ Branch 8 not taken.
|
1840 | us[i] = Eigen::VectorXd::Random(model->get_nu()); |
229 | } | ||
230 |
1/2✓ Branch 4 taken 92 times.
✗ Branch 5 not taken.
|
92 | xs.back() = model->get_state()->rand(); |
231 | |||
232 | // check the state and cost in each node | ||
233 |
1/2✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
|
92 | problem1.calc(xs, us); |
234 |
1/2✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
|
92 | problem2.calc(xs, us); |
235 |
1/2✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
|
92 | problem1.calcDiff(xs, us); |
236 |
1/2✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
|
92 | problem2.calcDiff(xs, us); |
237 |
2/2✓ Branch 0 taken 1840 times.
✓ Branch 1 taken 92 times.
|
1932 | for (std::size_t i = 0; i < T; ++i) { |
238 | const boost::shared_ptr<crocoddyl::ActionDataAbstract>& data = | ||
239 |
1/2✓ Branch 2 taken 1840 times.
✗ Branch 3 not taken.
|
1840 | model->createData(); |
240 |
3/6✓ Branch 3 taken 1840 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 1840 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1840 times.
✗ Branch 11 not taken.
|
1840 | model->calc(data, xs[i], us[i]); |
241 |
3/6✓ Branch 3 taken 1840 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 1840 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1840 times.
✗ Branch 11 not taken.
|
1840 | model->calcDiff(data, xs[i], us[i]); |
242 |
8/16✓ Branch 1 taken 1840 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1840 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1840 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 1840 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1840 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1840 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 1840 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 1840 times.
|
1840 | BOOST_CHECK((problem1.get_runningDatas()[i]->Fx - data->Fx).isZero(1e-7)); |
243 |
8/16✓ Branch 1 taken 1840 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1840 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1840 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 1840 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1840 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1840 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 1840 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 1840 times.
|
1840 | BOOST_CHECK((problem2.get_runningDatas()[i]->Fx - data->Fx).isZero(1e-7)); |
244 |
8/16✓ Branch 1 taken 1840 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1840 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1840 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 1840 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1840 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1840 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 1840 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 1840 times.
|
1840 | BOOST_CHECK((problem1.get_runningDatas()[i]->Fu - data->Fu).isZero(1e-7)); |
245 |
8/16✓ Branch 1 taken 1840 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1840 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1840 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 1840 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1840 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1840 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 1840 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 1840 times.
|
1840 | BOOST_CHECK((problem2.get_runningDatas()[i]->Fu - data->Fu).isZero(1e-7)); |
246 |
8/16✓ Branch 1 taken 1840 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1840 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1840 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 1840 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1840 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1840 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 1840 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 1840 times.
|
1840 | BOOST_CHECK((problem1.get_runningDatas()[i]->Lx - data->Lx).isZero(1e-7)); |
247 |
8/16✓ Branch 1 taken 1840 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1840 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1840 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 1840 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1840 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1840 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 1840 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 1840 times.
|
1840 | BOOST_CHECK((problem2.get_runningDatas()[i]->Lx - data->Lx).isZero(1e-7)); |
248 |
8/16✓ Branch 1 taken 1840 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1840 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1840 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 1840 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1840 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1840 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 1840 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 1840 times.
|
1840 | BOOST_CHECK((problem1.get_runningDatas()[i]->Lu - data->Lu).isZero(1e-7)); |
249 |
8/16✓ Branch 1 taken 1840 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1840 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1840 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 1840 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1840 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1840 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 1840 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 1840 times.
|
1840 | BOOST_CHECK((problem2.get_runningDatas()[i]->Lu - data->Lu).isZero(1e-7)); |
250 |
8/16✓ Branch 1 taken 1840 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1840 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1840 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 1840 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1840 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1840 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 1840 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 1840 times.
|
1840 | BOOST_CHECK((problem1.get_runningDatas()[i]->Lxx - data->Lxx).isZero(1e-7)); |
251 |
8/16✓ Branch 1 taken 1840 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1840 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1840 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 1840 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1840 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1840 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 1840 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 1840 times.
|
1840 | BOOST_CHECK((problem2.get_runningDatas()[i]->Lxx - data->Lxx).isZero(1e-7)); |
252 |
8/16✓ Branch 1 taken 1840 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1840 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1840 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 1840 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1840 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1840 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 1840 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 1840 times.
|
1840 | BOOST_CHECK((problem1.get_runningDatas()[i]->Lxu - data->Lxu).isZero(1e-7)); |
253 |
8/16✓ Branch 1 taken 1840 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1840 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1840 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 1840 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1840 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1840 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 1840 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 1840 times.
|
1840 | BOOST_CHECK((problem2.get_runningDatas()[i]->Lxu - data->Lxu).isZero(1e-7)); |
254 |
8/16✓ Branch 1 taken 1840 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1840 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1840 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 1840 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1840 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1840 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 1840 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 1840 times.
|
1840 | BOOST_CHECK((problem1.get_runningDatas()[i]->Luu - data->Luu).isZero(1e-7)); |
255 |
8/16✓ Branch 1 taken 1840 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1840 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1840 times.
✗ Branch 12 not taken.
✓ Branch 18 taken 1840 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1840 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1840 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 1840 times.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 1840 times.
|
1840 | BOOST_CHECK((problem2.get_runningDatas()[i]->Luu - data->Luu).isZero(1e-7)); |
256 | 1840 | } | |
257 | const boost::shared_ptr<crocoddyl::ActionDataAbstract>& data = | ||
258 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | model->createData(); |
259 |
2/4✓ Branch 3 taken 92 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 92 times.
✗ Branch 7 not taken.
|
92 | model->calc(data, xs.back()); |
260 |
2/4✓ Branch 3 taken 92 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 92 times.
✗ Branch 7 not taken.
|
92 | model->calcDiff(data, xs.back()); |
261 |
8/16✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 92 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 92 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 92 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 92 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 92 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 92 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 92 times.
|
92 | BOOST_CHECK((problem1.get_terminalData()->Fx - data->Fx).isZero(1e-7)); |
262 |
8/16✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 92 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 92 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 92 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 92 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 92 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 92 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 92 times.
|
92 | BOOST_CHECK((problem2.get_terminalData()->Fx - data->Fx).isZero(1e-7)); |
263 |
8/16✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 92 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 92 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 92 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 92 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 92 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 92 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 92 times.
|
92 | BOOST_CHECK((problem1.get_terminalData()->Lx - data->Lx).isZero(1e-7)); |
264 |
8/16✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 92 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 92 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 92 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 92 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 92 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 92 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 92 times.
|
92 | BOOST_CHECK((problem2.get_terminalData()->Lx - data->Lx).isZero(1e-7)); |
265 |
8/16✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 92 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 92 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 92 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 92 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 92 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 92 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 92 times.
|
92 | BOOST_CHECK((problem1.get_terminalData()->Lxx - data->Lxx).isZero(1e-7)); |
266 |
8/16✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 92 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 92 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 92 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 92 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 92 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 92 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 92 times.
|
92 | BOOST_CHECK((problem2.get_terminalData()->Lxx - data->Lxx).isZero(1e-7)); |
267 | 92 | } | |
268 | |||
269 | 7 | void test_rollout(ActionModelTypes::Type action_model_type) { | |
270 | // create the model | ||
271 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | ActionModelFactory factory; |
272 | const boost::shared_ptr<crocoddyl::ActionModelAbstract>& model = | ||
273 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | factory.create(action_model_type); |
274 | |||
275 | // create the shooting problem | ||
276 | 7 | std::size_t T = 20; | |
277 |
1/2✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | const Eigen::VectorXd& x0 = model->get_state()->rand(); |
278 | std::vector<boost::shared_ptr<crocoddyl::ActionModelAbstract> > models(T, | ||
279 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | model); |
280 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | crocoddyl::ShootingProblem problem(x0, models, model); |
281 | |||
282 | // create random trajectory | ||
283 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | std::vector<Eigen::VectorXd> xs(T + 1); |
284 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | std::vector<Eigen::VectorXd> us(T); |
285 |
2/2✓ Branch 0 taken 140 times.
✓ Branch 1 taken 7 times.
|
147 | for (std::size_t i = 0; i < T; ++i) { |
286 |
1/2✓ Branch 4 taken 140 times.
✗ Branch 5 not taken.
|
140 | xs[i] = model->get_state()->zero(); |
287 |
2/4✓ Branch 3 taken 140 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 140 times.
✗ Branch 8 not taken.
|
140 | us[i] = Eigen::VectorXd::Random(model->get_nu()); |
288 | } | ||
289 |
1/2✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | xs.back() = model->get_state()->zero(); |
290 | |||
291 | // check the state and cost in each node | ||
292 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | problem.rollout(us, xs); |
293 |
2/2✓ Branch 0 taken 140 times.
✓ Branch 1 taken 7 times.
|
147 | for (std::size_t i = 0; i < T; ++i) { |
294 | const boost::shared_ptr<crocoddyl::ActionDataAbstract>& data = | ||
295 |
1/2✓ Branch 2 taken 140 times.
✗ Branch 3 not taken.
|
140 | model->createData(); |
296 |
3/6✓ Branch 3 taken 140 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 140 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 140 times.
✗ Branch 11 not taken.
|
140 | model->calc(data, xs[i], us[i]); |
297 |
8/16✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 140 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 140 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 140 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 140 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 140 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 140 times.
✗ Branch 26 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 140 times.
|
140 | BOOST_CHECK((xs[i + 1] - data->xnext).isZero(1e-7)); |
298 | 140 | } | |
299 | 7 | } | |
300 | |||
301 | 92 | void test_rollout_diffAction( | |
302 | DifferentialActionModelTypes::Type action_model_type, | ||
303 | IntegratorTypes::Type integrator_type) { | ||
304 | // create the model | ||
305 |
1/2✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
|
92 | DifferentialActionModelFactory factory; |
306 | const boost::shared_ptr<crocoddyl::DifferentialActionModelAbstract>& | ||
307 |
1/2✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
|
92 | diffModel = factory.create(action_model_type); |
308 |
1/2✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
|
92 | IntegratorFactory factory_int; |
309 | const boost::shared_ptr<crocoddyl::ActionModelAbstract>& model = | ||
310 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | factory_int.create(integrator_type, diffModel); |
311 | |||
312 | // create the shooting problem | ||
313 | 92 | std::size_t T = 20; | |
314 |
1/2✓ Branch 4 taken 92 times.
✗ Branch 5 not taken.
|
92 | const Eigen::VectorXd& x0 = model->get_state()->rand(); |
315 | std::vector<boost::shared_ptr<crocoddyl::ActionModelAbstract> > models(T, | ||
316 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | model); |
317 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | crocoddyl::ShootingProblem problem(x0, models, model); |
318 | |||
319 | // create random trajectory | ||
320 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | std::vector<Eigen::VectorXd> xs(T + 1); |
321 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | std::vector<Eigen::VectorXd> us(T); |
322 |
2/2✓ Branch 0 taken 1840 times.
✓ Branch 1 taken 92 times.
|
1932 | for (std::size_t i = 0; i < T; ++i) { |
323 |
1/2✓ Branch 4 taken 1840 times.
✗ Branch 5 not taken.
|
1840 | xs[i] = model->get_state()->zero(); |
324 |
2/4✓ Branch 3 taken 1840 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 1840 times.
✗ Branch 8 not taken.
|
1840 | us[i] = Eigen::VectorXd::Random(model->get_nu()); |
325 | } | ||
326 |
1/2✓ Branch 4 taken 92 times.
✗ Branch 5 not taken.
|
92 | xs.back() = model->get_state()->zero(); |
327 | |||
328 | // check the state and cost in each node | ||
329 |
1/2✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
|
92 | problem.rollout(us, xs); |
330 |
2/2✓ Branch 0 taken 1840 times.
✓ Branch 1 taken 92 times.
|
1932 | for (std::size_t i = 0; i < T; ++i) { |
331 | const boost::shared_ptr<crocoddyl::ActionDataAbstract>& data = | ||
332 |
1/2✓ Branch 2 taken 1840 times.
✗ Branch 3 not taken.
|
1840 | model->createData(); |
333 |
3/6✓ Branch 3 taken 1840 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 1840 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1840 times.
✗ Branch 11 not taken.
|
1840 | model->calc(data, xs[i], us[i]); |
334 |
8/16✓ Branch 1 taken 1840 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1840 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1840 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 1840 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1840 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1840 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1840 times.
✗ Branch 26 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 1840 times.
|
1840 | BOOST_CHECK((xs[i + 1] - data->xnext).isZero(1e-7)); |
335 | 1840 | } | |
336 | 92 | } | |
337 | |||
338 | 7 | void test_quasiStatic(ActionModelTypes::Type action_model_type) { | |
339 | // create the model | ||
340 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | ActionModelFactory factory; |
341 | const boost::shared_ptr<crocoddyl::ActionModelAbstract>& model = | ||
342 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | factory.create(action_model_type); |
343 | |||
344 | // create two shooting problems (with and without data allocation) | ||
345 | 7 | std::size_t T = 20; | |
346 |
1/2✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | const Eigen::VectorXd& x0 = model->get_state()->rand(); |
347 | std::vector<boost::shared_ptr<crocoddyl::ActionModelAbstract> > models(T, | ||
348 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | model); |
349 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | std::vector<boost::shared_ptr<crocoddyl::ActionDataAbstract> > datas(T); |
350 |
2/2✓ Branch 0 taken 140 times.
✓ Branch 1 taken 7 times.
|
147 | for (std::size_t i = 0; i < T; ++i) { |
351 |
1/2✓ Branch 2 taken 140 times.
✗ Branch 3 not taken.
|
140 | datas[i] = model->createData(); |
352 | } | ||
353 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | crocoddyl::ShootingProblem problem1(x0, models, model); |
354 | crocoddyl::ShootingProblem problem2(x0, models, model, datas, | ||
355 |
2/4✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
|
14 | model->createData()); |
356 | |||
357 | // create random trajectory | ||
358 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | std::vector<Eigen::VectorXd> xs(T); |
359 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | std::vector<Eigen::VectorXd> us(T); |
360 |
2/2✓ Branch 0 taken 140 times.
✓ Branch 1 taken 7 times.
|
147 | for (std::size_t i = 0; i < T; ++i) { |
361 |
1/2✓ Branch 4 taken 140 times.
✗ Branch 5 not taken.
|
140 | xs[i] = model->get_state()->rand(); |
362 |
2/4✓ Branch 6 taken 140 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 140 times.
✗ Branch 10 not taken.
|
140 | xs[i].tail(model->get_state()->get_nv()) *= 0; |
363 |
2/4✓ Branch 3 taken 140 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 140 times.
✗ Branch 8 not taken.
|
140 | us[i] = Eigen::VectorXd::Zero(model->get_nu()); |
364 | } | ||
365 | |||
366 | // check the state and cost in each node | ||
367 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | problem1.quasiStatic(us, xs); |
368 |
2/2✓ Branch 0 taken 140 times.
✓ Branch 1 taken 7 times.
|
147 | for (std::size_t i = 0; i < T; ++i) { |
369 | const boost::shared_ptr<crocoddyl::ActionDataAbstract>& data = | ||
370 |
1/2✓ Branch 2 taken 140 times.
✗ Branch 3 not taken.
|
140 | model->createData(); |
371 |
2/4✓ Branch 3 taken 140 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 140 times.
✗ Branch 7 not taken.
|
140 | Eigen::VectorXd u = Eigen::VectorXd::Zero(model->get_nu()); |
372 |
3/6✓ Branch 3 taken 140 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 140 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 140 times.
✗ Branch 10 not taken.
|
140 | model->quasiStatic(data, u, xs[i]); |
373 |
8/16✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 140 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 140 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 140 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 140 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 140 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 140 times.
✗ Branch 25 not taken.
✗ Branch 29 not taken.
✓ Branch 30 taken 140 times.
|
140 | BOOST_CHECK((u - us[i]).isZero(1e-7)); |
374 | 140 | } | |
375 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | problem2.quasiStatic(us, xs); |
376 |
2/2✓ Branch 0 taken 140 times.
✓ Branch 1 taken 7 times.
|
147 | for (std::size_t i = 0; i < T; ++i) { |
377 | const boost::shared_ptr<crocoddyl::ActionDataAbstract>& data = | ||
378 |
1/2✓ Branch 2 taken 140 times.
✗ Branch 3 not taken.
|
140 | model->createData(); |
379 |
2/4✓ Branch 3 taken 140 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 140 times.
✗ Branch 7 not taken.
|
140 | Eigen::VectorXd u = Eigen::VectorXd::Zero(model->get_nu()); |
380 |
3/6✓ Branch 3 taken 140 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 140 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 140 times.
✗ Branch 10 not taken.
|
140 | model->quasiStatic(data, u, xs[i]); |
381 |
8/16✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 140 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 140 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 140 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 140 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 140 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 140 times.
✗ Branch 25 not taken.
✗ Branch 29 not taken.
✓ Branch 30 taken 140 times.
|
140 | BOOST_CHECK((u - us[i]).isZero(1e-7)); |
382 | 140 | } | |
383 | 7 | } | |
384 | |||
385 | 92 | void test_quasiStatic_diffAction( | |
386 | DifferentialActionModelTypes::Type action_model_type, | ||
387 | IntegratorTypes::Type integrator_type) { | ||
388 | // create the model | ||
389 |
1/2✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
|
92 | DifferentialActionModelFactory factory; |
390 | const boost::shared_ptr<crocoddyl::DifferentialActionModelAbstract>& | ||
391 |
1/2✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
|
92 | diffModel = factory.create(action_model_type); |
392 |
1/2✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
|
92 | IntegratorFactory factory_int; |
393 | const boost::shared_ptr<crocoddyl::ActionModelAbstract>& model = | ||
394 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | factory_int.create(integrator_type, diffModel); |
395 | |||
396 | // create two shooting problems (with and without data allocation) | ||
397 | 92 | std::size_t T = 20; | |
398 |
1/2✓ Branch 4 taken 92 times.
✗ Branch 5 not taken.
|
92 | const Eigen::VectorXd& x0 = model->get_state()->rand(); |
399 | std::vector<boost::shared_ptr<crocoddyl::ActionModelAbstract> > models(T, | ||
400 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | model); |
401 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | std::vector<boost::shared_ptr<crocoddyl::ActionDataAbstract> > datas(T); |
402 |
2/2✓ Branch 0 taken 1840 times.
✓ Branch 1 taken 92 times.
|
1932 | for (std::size_t i = 0; i < T; ++i) { |
403 |
1/2✓ Branch 2 taken 1840 times.
✗ Branch 3 not taken.
|
1840 | datas[i] = model->createData(); |
404 | } | ||
405 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | crocoddyl::ShootingProblem problem1(x0, models, model); |
406 | crocoddyl::ShootingProblem problem2(x0, models, model, datas, | ||
407 |
2/4✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 92 times.
✗ Branch 7 not taken.
|
184 | model->createData()); |
408 | |||
409 | // create random trajectory | ||
410 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | std::vector<Eigen::VectorXd> xs(T); |
411 |
1/2✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
|
92 | std::vector<Eigen::VectorXd> us(T); |
412 |
2/2✓ Branch 0 taken 1840 times.
✓ Branch 1 taken 92 times.
|
1932 | for (std::size_t i = 0; i < T; ++i) { |
413 |
1/2✓ Branch 4 taken 1840 times.
✗ Branch 5 not taken.
|
1840 | xs[i] = model->get_state()->rand(); |
414 |
2/4✓ Branch 6 taken 1840 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1840 times.
✗ Branch 10 not taken.
|
1840 | xs[i].tail(model->get_state()->get_nv()) *= 0; |
415 |
2/4✓ Branch 3 taken 1840 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 1840 times.
✗ Branch 8 not taken.
|
1840 | us[i] = Eigen::VectorXd::Zero(model->get_nu()); |
416 | } | ||
417 | |||
418 | // check the state and cost in each node | ||
419 |
1/2✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
|
92 | problem1.quasiStatic(us, xs); |
420 |
2/2✓ Branch 0 taken 1840 times.
✓ Branch 1 taken 92 times.
|
1932 | for (std::size_t i = 0; i < T; ++i) { |
421 | const boost::shared_ptr<crocoddyl::ActionDataAbstract>& data = | ||
422 |
1/2✓ Branch 2 taken 1840 times.
✗ Branch 3 not taken.
|
1840 | model->createData(); |
423 |
2/4✓ Branch 3 taken 1840 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1840 times.
✗ Branch 7 not taken.
|
1840 | Eigen::VectorXd u = Eigen::VectorXd::Zero(model->get_nu()); |
424 |
3/6✓ Branch 3 taken 1840 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1840 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1840 times.
✗ Branch 10 not taken.
|
1840 | model->quasiStatic(data, u, xs[i]); |
425 |
8/16✓ Branch 1 taken 1840 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1840 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1840 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 1840 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 1840 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1840 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1840 times.
✗ Branch 25 not taken.
✗ Branch 29 not taken.
✓ Branch 30 taken 1840 times.
|
1840 | BOOST_CHECK((u - us[i]).isZero(1e-7)); |
426 | 1840 | } | |
427 |
1/2✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
|
92 | problem2.quasiStatic(us, xs); |
428 |
2/2✓ Branch 0 taken 1840 times.
✓ Branch 1 taken 92 times.
|
1932 | for (std::size_t i = 0; i < T; ++i) { |
429 | const boost::shared_ptr<crocoddyl::ActionDataAbstract>& data = | ||
430 |
1/2✓ Branch 2 taken 1840 times.
✗ Branch 3 not taken.
|
1840 | model->createData(); |
431 |
2/4✓ Branch 3 taken 1840 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1840 times.
✗ Branch 7 not taken.
|
1840 | Eigen::VectorXd u = Eigen::VectorXd::Zero(model->get_nu()); |
432 |
3/6✓ Branch 3 taken 1840 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1840 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1840 times.
✗ Branch 10 not taken.
|
1840 | model->quasiStatic(data, u, xs[i]); |
433 |
8/16✓ Branch 1 taken 1840 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1840 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1840 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 1840 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 1840 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1840 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1840 times.
✗ Branch 25 not taken.
✗ Branch 29 not taken.
✓ Branch 30 taken 1840 times.
|
1840 | BOOST_CHECK((u - us[i]).isZero(1e-7)); |
434 | 1840 | } | |
435 | 92 | } | |
436 | |||
437 | //----------------------------------------------------------------------------// | ||
438 | |||
439 | 7 | void register_action_model_unit_tests( | |
440 | ActionModelTypes::Type action_model_type) { | ||
441 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | boost::test_tools::output_test_stream test_name; |
442 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | test_name << "test_" << action_model_type; |
443 |
4/8✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 7 times.
✗ Branch 11 not taken.
|
7 | std::cout << "Running " << test_name.str() << std::endl; |
444 |
4/8✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 7 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 12 not taken.
|
7 | test_suite* ts = BOOST_TEST_SUITE(test_name.str()); |
445 |
5/10✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 7 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 7 times.
✗ Branch 15 not taken.
|
7 | ts->add(BOOST_TEST_CASE(boost::bind(&test_calc, action_model_type))); |
446 |
5/10✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 7 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 7 times.
✗ Branch 15 not taken.
|
7 | ts->add(BOOST_TEST_CASE(boost::bind(&test_calcDiff, action_model_type))); |
447 |
5/10✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 7 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 7 times.
✗ Branch 15 not taken.
|
7 | ts->add(BOOST_TEST_CASE(boost::bind(&test_quasiStatic, action_model_type))); |
448 |
5/10✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 7 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 7 times.
✗ Branch 15 not taken.
|
7 | ts->add(BOOST_TEST_CASE(boost::bind(&test_rollout, action_model_type))); |
449 |
3/6✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
|
7 | framework::master_test_suite().add(ts); |
450 | 7 | } | |
451 | |||
452 | 92 | void register_diff_action_model_unit_tests( | |
453 | DifferentialActionModelTypes::Type action_model_type, | ||
454 | IntegratorTypes::Type integrator_type) { | ||
455 |
2/4✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 92 times.
✗ Branch 5 not taken.
|
92 | boost::test_tools::output_test_stream test_name; |
456 |
4/8✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 92 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 92 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 92 times.
✗ Branch 11 not taken.
|
92 | test_name << "test_" << action_model_type << "_" << integrator_type; |
457 |
4/8✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 92 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 92 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 92 times.
✗ Branch 11 not taken.
|
92 | std::cout << "Running " << test_name.str() << std::endl; |
458 |
4/8✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 92 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 92 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 92 times.
✗ Branch 12 not taken.
|
92 | test_suite* ts = BOOST_TEST_SUITE(test_name.str()); |
459 |
5/10✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 92 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 92 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 92 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 92 times.
✗ Branch 15 not taken.
|
92 | ts->add(BOOST_TEST_CASE( |
460 | boost::bind(&test_calc_diffAction, action_model_type, integrator_type))); | ||
461 |
5/10✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 92 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 92 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 92 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 92 times.
✗ Branch 15 not taken.
|
92 | ts->add(BOOST_TEST_CASE(boost::bind(&test_calcDiff_diffAction, |
462 | action_model_type, integrator_type))); | ||
463 |
5/10✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 92 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 92 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 92 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 92 times.
✗ Branch 15 not taken.
|
92 | ts->add(BOOST_TEST_CASE(boost::bind(&test_quasiStatic_diffAction, |
464 | action_model_type, integrator_type))); | ||
465 |
5/10✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 92 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 92 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 92 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 92 times.
✗ Branch 15 not taken.
|
92 | ts->add(BOOST_TEST_CASE(boost::bind(&test_rollout_diffAction, |
466 | action_model_type, integrator_type))); | ||
467 |
3/6✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 92 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 92 times.
✗ Branch 7 not taken.
|
92 | framework::master_test_suite().add(ts); |
468 | 92 | } | |
469 | |||
470 | 1 | bool init_function() { | |
471 |
2/2✓ Branch 1 taken 7 times.
✓ Branch 2 taken 1 times.
|
8 | for (size_t i = 0; i < ActionModelTypes::all.size(); ++i) { |
472 | 7 | register_action_model_unit_tests(ActionModelTypes::all[i]); | |
473 | } | ||
474 |
2/2✓ Branch 1 taken 23 times.
✓ Branch 2 taken 1 times.
|
24 | for (size_t i = 0; i < DifferentialActionModelTypes::all.size(); ++i) { |
475 |
2/2✓ Branch 1 taken 92 times.
✓ Branch 2 taken 23 times.
|
115 | for (size_t j = 0; j < IntegratorTypes::all.size(); ++j) { |
476 | 92 | register_diff_action_model_unit_tests( | |
477 | 92 | DifferentialActionModelTypes::all[i], IntegratorTypes::all[j]); | |
478 | } | ||
479 | } | ||
480 | 1 | return true; | |
481 | } | ||
482 | |||
483 | 1 | int main(int argc, char** argv) { | |
484 | 1 | return ::boost::unit_test::unit_test_main(&init_function, argc, argv); | |
485 | } | ||
486 |