Line |
Branch |
Exec |
Source |
1 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
2 |
|
|
// BSD 3-Clause License |
3 |
|
|
// |
4 |
|
|
// Copyright (C) 2021-2025, University of Edinburgh, LAAS-CNRS, |
5 |
|
|
// University of Trento, Heriot-Watt University |
6 |
|
|
// Copyright note valid unless otherwise stated in individual files. |
7 |
|
|
// All rights reserved. |
8 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
9 |
|
|
|
10 |
|
|
#include "integrator.hpp" |
11 |
|
|
|
12 |
|
|
#include "crocoddyl/core/integrator/euler.hpp" |
13 |
|
|
#include "crocoddyl/core/integrator/rk.hpp" |
14 |
|
|
|
15 |
|
|
namespace crocoddyl { |
16 |
|
|
namespace unittest { |
17 |
|
|
|
18 |
|
|
const std::vector<IntegratorTypes::Type> IntegratorTypes::all( |
19 |
|
|
IntegratorTypes::init_all()); |
20 |
|
|
|
21 |
|
✗ |
std::ostream& operator<<(std::ostream& os, IntegratorTypes::Type type) { |
22 |
|
✗ |
switch (type) { |
23 |
|
✗ |
case IntegratorTypes::IntegratorEuler: |
24 |
|
✗ |
os << "IntegratorEuler"; |
25 |
|
✗ |
break; |
26 |
|
✗ |
case IntegratorTypes::IntegratorRK2: |
27 |
|
✗ |
os << "IntegratorRK2"; |
28 |
|
✗ |
break; |
29 |
|
✗ |
case IntegratorTypes::IntegratorRK3: |
30 |
|
✗ |
os << "IntegratorRK3"; |
31 |
|
✗ |
break; |
32 |
|
✗ |
case IntegratorTypes::IntegratorRK4: |
33 |
|
✗ |
os << "IntegratorRK4"; |
34 |
|
✗ |
break; |
35 |
|
✗ |
case IntegratorTypes::NbIntegratorTypes: |
36 |
|
✗ |
os << "NbIntegratorTypes"; |
37 |
|
✗ |
break; |
38 |
|
✗ |
default: |
39 |
|
✗ |
break; |
40 |
|
|
} |
41 |
|
✗ |
return os; |
42 |
|
|
} |
43 |
|
|
|
44 |
|
✗ |
IntegratorFactory::IntegratorFactory() {} |
45 |
|
✗ |
IntegratorFactory::~IntegratorFactory() {} |
46 |
|
|
|
47 |
|
|
std::shared_ptr<crocoddyl::IntegratedActionModelAbstract> |
48 |
|
✗ |
IntegratorFactory::create( |
49 |
|
|
IntegratorTypes::Type type, |
50 |
|
|
std::shared_ptr<DifferentialActionModelAbstract> model) const { |
51 |
|
✗ |
std::shared_ptr<crocoddyl::IntegratedActionModelAbstract> action; |
52 |
|
✗ |
switch (type) { |
53 |
|
✗ |
case IntegratorTypes::IntegratorEuler: |
54 |
|
✗ |
action = std::make_shared<crocoddyl::IntegratedActionModelEuler>(model); |
55 |
|
✗ |
break; |
56 |
|
✗ |
case IntegratorTypes::IntegratorRK2: |
57 |
|
✗ |
action = std::make_shared<crocoddyl::IntegratedActionModelRK>( |
58 |
|
✗ |
model, RKType::two); |
59 |
|
✗ |
break; |
60 |
|
✗ |
case IntegratorTypes::IntegratorRK3: |
61 |
|
✗ |
action = std::make_shared<crocoddyl::IntegratedActionModelRK>( |
62 |
|
✗ |
model, RKType::three); |
63 |
|
✗ |
break; |
64 |
|
✗ |
case IntegratorTypes::IntegratorRK4: |
65 |
|
✗ |
action = std::make_shared<crocoddyl::IntegratedActionModelRK>( |
66 |
|
✗ |
model, RKType::four); |
67 |
|
✗ |
break; |
68 |
|
✗ |
default: |
69 |
|
✗ |
throw_pretty(__FILE__ ": Wrong IntegratorTypes::Type given"); |
70 |
|
|
break; |
71 |
|
|
} |
72 |
|
✗ |
return action; |
73 |
|
|
} |
74 |
|
|
|
75 |
|
|
std::shared_ptr<crocoddyl::IntegratedActionModelAbstract> |
76 |
|
✗ |
IntegratorFactory::create( |
77 |
|
|
IntegratorTypes::Type type, |
78 |
|
|
std::shared_ptr<DifferentialActionModelAbstract> model, |
79 |
|
|
std::shared_ptr<ControlParametrizationModelAbstract> control) const { |
80 |
|
✗ |
std::shared_ptr<crocoddyl::IntegratedActionModelAbstract> action; |
81 |
|
✗ |
switch (type) { |
82 |
|
✗ |
case IntegratorTypes::IntegratorEuler: |
83 |
|
✗ |
action = std::make_shared<crocoddyl::IntegratedActionModelEuler>(model, |
84 |
|
✗ |
control); |
85 |
|
✗ |
break; |
86 |
|
✗ |
case IntegratorTypes::IntegratorRK2: |
87 |
|
✗ |
action = std::make_shared<crocoddyl::IntegratedActionModelRK>( |
88 |
|
✗ |
model, control, RKType::two); |
89 |
|
✗ |
break; |
90 |
|
✗ |
case IntegratorTypes::IntegratorRK3: |
91 |
|
✗ |
action = std::make_shared<crocoddyl::IntegratedActionModelRK>( |
92 |
|
✗ |
model, control, RKType::three); |
93 |
|
✗ |
break; |
94 |
|
✗ |
case IntegratorTypes::IntegratorRK4: |
95 |
|
✗ |
action = std::make_shared<crocoddyl::IntegratedActionModelRK>( |
96 |
|
✗ |
model, control, RKType::four); |
97 |
|
✗ |
break; |
98 |
|
✗ |
default: |
99 |
|
✗ |
throw_pretty(__FILE__ ": Wrong IntegratorTypes::Type given"); |
100 |
|
|
break; |
101 |
|
|
} |
102 |
|
✗ |
return action; |
103 |
|
|
} |
104 |
|
|
|
105 |
|
|
} // namespace unittest |
106 |
|
|
} // namespace crocoddyl |
107 |
|
|
|