Directory: | ./ |
---|---|
File: | unittest/factory/control.cpp |
Date: | 2025-01-16 08:47:40 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 36 | 43 | 83.7% |
Branches: | 12 | 27 | 44.4% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | ||
2 | // BSD 3-Clause License | ||
3 | // | ||
4 | // Copyright (C) 2021, University of Edinburgh, University of Trento | ||
5 | // Copyright note valid unless otherwise stated in individual files. | ||
6 | // All rights reserved. | ||
7 | /////////////////////////////////////////////////////////////////////////////// | ||
8 | |||
9 | #include "control.hpp" | ||
10 | |||
11 | #include "crocoddyl/core/controls/poly-one.hpp" | ||
12 | #include "crocoddyl/core/controls/poly-two-rk.hpp" | ||
13 | #include "crocoddyl/core/controls/poly-zero.hpp" | ||
14 | #include "crocoddyl/core/utils/exception.hpp" | ||
15 | |||
16 | namespace crocoddyl { | ||
17 | namespace unittest { | ||
18 | |||
19 | const std::vector<ControlTypes::Type> ControlTypes::all( | ||
20 | ControlTypes::init_all()); | ||
21 | |||
22 | 303 | std::ostream& operator<<(std::ostream& os, ControlTypes::Type type) { | |
23 |
4/6✓ Branch 0 taken 116 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 47 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
303 | switch (type) { |
24 | 116 | case ControlTypes::PolyZero: | |
25 | 116 | os << "PolyZero"; | |
26 | 116 | break; | |
27 | 116 | case ControlTypes::PolyOne: | |
28 | 116 | os << "PolyOne"; | |
29 | 116 | break; | |
30 | 24 | case ControlTypes::PolyTwoRK3: | |
31 | 24 | os << "PolyTwoRK3"; | |
32 | 24 | break; | |
33 | 47 | case ControlTypes::PolyTwoRK4: | |
34 | 47 | os << "PolyTwoRK4"; | |
35 | 47 | break; | |
36 | ✗ | case ControlTypes::NbControlTypes: | |
37 | ✗ | os << "NbControlTypes"; | |
38 | ✗ | break; | |
39 | ✗ | default: | |
40 | ✗ | break; | |
41 | } | ||
42 | 303 | return os; | |
43 | } | ||
44 | |||
45 | 679 | ControlFactory::ControlFactory() {} | |
46 | 679 | ControlFactory::~ControlFactory() {} | |
47 | |||
48 | boost::shared_ptr<crocoddyl::ControlParametrizationModelAbstract> | ||
49 | 725 | ControlFactory::create(ControlTypes::Type control_type, | |
50 | const std::size_t nu) const { | ||
51 | 725 | boost::shared_ptr<crocoddyl::ControlParametrizationModelAbstract> control; | |
52 |
4/5✓ Branch 0 taken 302 times.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 95 times.
✗ Branch 4 not taken.
|
725 | switch (control_type) { |
53 | 302 | case ControlTypes::PolyZero: | |
54 | control = | ||
55 |
1/2✓ Branch 1 taken 302 times.
✗ Branch 2 not taken.
|
604 | boost::make_shared<crocoddyl::ControlParametrizationModelPolyZero>( |
56 | 302 | nu); | |
57 | 302 | break; | |
58 | 256 | case ControlTypes::PolyOne: | |
59 | control = | ||
60 |
1/2✓ Branch 1 taken 256 times.
✗ Branch 2 not taken.
|
256 | boost::make_shared<crocoddyl::ControlParametrizationModelPolyOne>(nu); |
61 | 256 | break; | |
62 | 72 | case ControlTypes::PolyTwoRK3: | |
63 | control = | ||
64 | 72 | boost::make_shared<crocoddyl::ControlParametrizationModelPolyTwoRK>( | |
65 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | nu, RKType::three); |
66 | 72 | break; | |
67 | 95 | case ControlTypes::PolyTwoRK4: | |
68 | control = | ||
69 | 95 | boost::make_shared<crocoddyl::ControlParametrizationModelPolyTwoRK>( | |
70 |
1/2✓ Branch 1 taken 95 times.
✗ Branch 2 not taken.
|
95 | nu, RKType::four); |
71 | 95 | break; | |
72 | ✗ | default: | |
73 | ✗ | throw_pretty(__FILE__ ": Wrong ControlTypes::Type given"); | |
74 | break; | ||
75 | } | ||
76 | 725 | return control; | |
77 | } | ||
78 | |||
79 | } // namespace unittest | ||
80 | } // namespace crocoddyl | ||
81 |