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 |
|
290 |
std::ostream& operator<<(std::ostream& os, ControlTypes::Type type) { |
23 |
✓✓✓✓ ✗✗ |
290 |
switch (type) { |
24 |
|
111 |
case ControlTypes::PolyZero: |
25 |
|
111 |
os << "PolyZero"; |
26 |
|
111 |
break; |
27 |
|
111 |
case ControlTypes::PolyOne: |
28 |
|
111 |
os << "PolyOne"; |
29 |
|
111 |
break; |
30 |
|
23 |
case ControlTypes::PolyTwoRK3: |
31 |
|
23 |
os << "PolyTwoRK3"; |
32 |
|
23 |
break; |
33 |
|
45 |
case ControlTypes::PolyTwoRK4: |
34 |
|
45 |
os << "PolyTwoRK4"; |
35 |
|
45 |
break; |
36 |
|
|
case ControlTypes::NbControlTypes: |
37 |
|
|
os << "NbControlTypes"; |
38 |
|
|
break; |
39 |
|
|
default: |
40 |
|
|
break; |
41 |
|
|
} |
42 |
|
290 |
return os; |
43 |
|
|
} |
44 |
|
|
|
45 |
|
650 |
ControlFactory::ControlFactory() {} |
46 |
|
650 |
ControlFactory::~ControlFactory() {} |
47 |
|
|
|
48 |
|
|
boost::shared_ptr<crocoddyl::ControlParametrizationModelAbstract> |
49 |
|
694 |
ControlFactory::create(ControlTypes::Type control_type, |
50 |
|
|
const std::size_t nu) const { |
51 |
|
694 |
boost::shared_ptr<crocoddyl::ControlParametrizationModelAbstract> control; |
52 |
✓✓✓✓ ✗ |
694 |
switch (control_type) { |
53 |
|
289 |
case ControlTypes::PolyZero: |
54 |
|
|
control = |
55 |
✓✗ |
578 |
boost::make_shared<crocoddyl::ControlParametrizationModelPolyZero>( |
56 |
|
289 |
nu); |
57 |
|
289 |
break; |
58 |
|
245 |
case ControlTypes::PolyOne: |
59 |
|
|
control = |
60 |
✓✗ |
245 |
boost::make_shared<crocoddyl::ControlParametrizationModelPolyOne>(nu); |
61 |
|
245 |
break; |
62 |
|
69 |
case ControlTypes::PolyTwoRK3: |
63 |
|
|
control = |
64 |
|
69 |
boost::make_shared<crocoddyl::ControlParametrizationModelPolyTwoRK>( |
65 |
✓✗ |
69 |
nu, RKType::three); |
66 |
|
69 |
break; |
67 |
|
91 |
case ControlTypes::PolyTwoRK4: |
68 |
|
|
control = |
69 |
|
91 |
boost::make_shared<crocoddyl::ControlParametrizationModelPolyTwoRK>( |
70 |
✓✗ |
91 |
nu, RKType::four); |
71 |
|
91 |
break; |
72 |
|
|
default: |
73 |
|
|
throw_pretty(__FILE__ ": Wrong ControlTypes::Type given"); |
74 |
|
|
break; |
75 |
|
|
} |
76 |
|
694 |
return control; |
77 |
|
|
} |
78 |
|
|
|
79 |
|
|
} // namespace unittest |
80 |
|
|
} // namespace crocoddyl |