Directory: | ./ |
---|---|
File: | unittest/factory/action.hpp |
Date: | 2025-01-16 08:47:40 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 6 | 6 | 100.0% |
Branches: | 4 | 6 | 66.7% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | ||
2 | // BSD 3-Clause License | ||
3 | // | ||
4 | // Copyright (C) 2019-2024, LAAS-CNRS, University of Edinburgh, | ||
5 | // Heriot-Watt University | ||
6 | // Copyright note valid unless otherwise stated in individual files. | ||
7 | // All rights reserved. | ||
8 | /////////////////////////////////////////////////////////////////////////////// | ||
9 | |||
10 | #ifndef CROCODDYL_ACTION_FACTORY_HPP_ | ||
11 | #define CROCODDYL_ACTION_FACTORY_HPP_ | ||
12 | |||
13 | #include <iterator> | ||
14 | |||
15 | #include "crocoddyl/core/action-base.hpp" | ||
16 | #include "crocoddyl/core/numdiff/action.hpp" | ||
17 | #include "crocoddyl/multibody/actions/impulse-fwddyn.hpp" | ||
18 | #include "state.hpp" | ||
19 | |||
20 | namespace crocoddyl { | ||
21 | namespace unittest { | ||
22 | |||
23 | struct ActionModelTypes { | ||
24 | enum Type { | ||
25 | ActionModelUnicycle, | ||
26 | ActionModelLQRDriftFree, | ||
27 | ActionModelLQR, | ||
28 | ActionModelRandomLQR, | ||
29 | ActionModelRandomLQRwithTerminalConstraint, | ||
30 | ActionModelImpulseFwdDynamics_HyQ, | ||
31 | ActionModelImpulseFwdDynamics_Talos, | ||
32 | NbActionModelTypes | ||
33 | }; | ||
34 | 23 | static std::vector<Type> init_all() { | |
35 | 23 | std::vector<Type> v; | |
36 |
1/2✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
|
23 | v.reserve(NbActionModelTypes); |
37 |
2/2✓ Branch 0 taken 161 times.
✓ Branch 1 taken 23 times.
|
184 | for (int i = 0; i < NbActionModelTypes; ++i) { |
38 |
1/2✓ Branch 1 taken 161 times.
✗ Branch 2 not taken.
|
161 | v.push_back((Type)i); |
39 | } | ||
40 | 23 | return v; | |
41 | } | ||
42 | static const std::vector<Type> all; | ||
43 | }; | ||
44 | |||
45 | std::ostream& operator<<(std::ostream& os, ActionModelTypes::Type type); | ||
46 | |||
47 | class ActionModelFactory { | ||
48 | public: | ||
49 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW | ||
50 | |||
51 | explicit ActionModelFactory(); | ||
52 | ~ActionModelFactory(); | ||
53 | |||
54 | enum Instance { First, Second, Terminal }; | ||
55 | |||
56 | boost::shared_ptr<crocoddyl::ActionModelAbstract> create( | ||
57 | ActionModelTypes::Type type, Instance instance = Instance::First) const; | ||
58 | |||
59 | boost::shared_ptr<crocoddyl::ActionModelImpulseFwdDynamics> | ||
60 | create_impulseFwdDynamics(StateModelTypes::Type state_type) const; | ||
61 | }; | ||
62 | |||
63 | } // namespace unittest | ||
64 | } // namespace crocoddyl | ||
65 | |||
66 | #endif // CROCODDYL_ACTION_FACTORY_HPP_ | ||
67 |