Directory: | ./ |
---|---|
File: | unittest/factory/state.cpp |
Date: | 2025-01-16 08:47:40 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 59 | 66 | 89.4% |
Branches: | 33 | 63 | 52.4% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | ||
2 | // BSD 3-Clause License | ||
3 | // | ||
4 | // Copyright (C) 2019-2020, LAAS-CNRS, University of Edinburgh | ||
5 | // Copyright note valid unless otherwise stated in individual files. | ||
6 | // All rights reserved. | ||
7 | /////////////////////////////////////////////////////////////////////////////// | ||
8 | |||
9 | #include "state.hpp" | ||
10 | |||
11 | #include <pinocchio/fwd.hpp> | ||
12 | #include <pinocchio/parsers/sample-models.hpp> | ||
13 | #include <pinocchio/parsers/urdf.hpp> | ||
14 | |||
15 | #include "crocoddyl/core/states/euclidean.hpp" | ||
16 | #include "crocoddyl/core/utils/exception.hpp" | ||
17 | #include "crocoddyl/multibody/states/multibody.hpp" | ||
18 | |||
19 | namespace crocoddyl { | ||
20 | namespace unittest { | ||
21 | |||
22 | const std::vector<StateModelTypes::Type> StateModelTypes::all( | ||
23 | StateModelTypes::init_all()); | ||
24 | |||
25 | 598 | std::ostream& operator<<(std::ostream& os, StateModelTypes::Type type) { | |
26 |
7/9✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 111 times.
✓ Branch 4 taken 124 times.
✓ Branch 5 taken 123 times.
✓ Branch 6 taken 122 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
|
598 | switch (type) { |
27 | 2 | case StateModelTypes::StateVector: | |
28 | 2 | os << "StateVector"; | |
29 | 2 | break; | |
30 | 3 | case StateModelTypes::StateMultibody_Hector: | |
31 | 3 | os << "StateMultibody_Hector"; | |
32 | 3 | break; | |
33 | 113 | case StateModelTypes::StateMultibody_TalosArm: | |
34 | 113 | os << "StateMultibody_TalosArm"; | |
35 | 113 | break; | |
36 | 111 | case StateModelTypes::StateMultibodyContact2D_TalosArm: | |
37 | 111 | os << "StateMultibodyContact2D_TalosArm"; | |
38 | 111 | break; | |
39 | 124 | case StateModelTypes::StateMultibody_HyQ: | |
40 | 124 | os << "StateMultibody_HyQ"; | |
41 | 124 | break; | |
42 | 123 | case StateModelTypes::StateMultibody_Talos: | |
43 | 123 | os << "StateMultibody_Talos"; | |
44 | 123 | break; | |
45 | 122 | case StateModelTypes::StateMultibody_RandomHumanoid: | |
46 | 122 | os << "StateMultibody_RandomHumanoid"; | |
47 | 122 | break; | |
48 | ✗ | case StateModelTypes::NbStateModelTypes: | |
49 | ✗ | os << "NbStateModelTypes"; | |
50 | ✗ | break; | |
51 | ✗ | default: | |
52 | ✗ | break; | |
53 | } | ||
54 | 598 | return os; | |
55 | } | ||
56 | |||
57 | 8661 | StateModelFactory::StateModelFactory() {} | |
58 | 8661 | StateModelFactory::~StateModelFactory() {} | |
59 | |||
60 | 8661 | boost::shared_ptr<crocoddyl::StateAbstract> StateModelFactory::create( | |
61 | StateModelTypes::Type state_type) const { | ||
62 | 8661 | boost::shared_ptr<pinocchio::Model> model; | |
63 | 8661 | boost::shared_ptr<crocoddyl::StateAbstract> state; | |
64 |
7/8✓ Branch 0 taken 18 times.
✓ Branch 1 taken 624 times.
✓ Branch 2 taken 2895 times.
✓ Branch 3 taken 995 times.
✓ Branch 4 taken 1660 times.
✓ Branch 5 taken 1755 times.
✓ Branch 6 taken 714 times.
✗ Branch 7 not taken.
|
8661 | switch (state_type) { |
65 | 18 | case StateModelTypes::StateVector: | |
66 |
1/2✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
|
18 | state = boost::make_shared<crocoddyl::StateVector>(80); |
67 | 18 | break; | |
68 | 624 | case StateModelTypes::StateMultibody_Hector: | |
69 |
2/4✓ Branch 1 taken 624 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 624 times.
✗ Branch 5 not taken.
|
624 | model = PinocchioModelFactory(PinocchioModelTypes::Hector).create(); |
70 |
1/2✓ Branch 1 taken 624 times.
✗ Branch 2 not taken.
|
624 | state = boost::make_shared<crocoddyl::StateMultibody>(model); |
71 | 624 | break; | |
72 | 2895 | case StateModelTypes::StateMultibody_TalosArm: | |
73 |
2/4✓ Branch 1 taken 2895 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2895 times.
✗ Branch 5 not taken.
|
2895 | model = PinocchioModelFactory(PinocchioModelTypes::TalosArm).create(); |
74 |
1/2✓ Branch 1 taken 2895 times.
✗ Branch 2 not taken.
|
2895 | state = boost::make_shared<crocoddyl::StateMultibody>(model); |
75 | 2895 | break; | |
76 | 995 | case StateModelTypes::StateMultibodyContact2D_TalosArm: | |
77 |
2/4✓ Branch 1 taken 995 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 995 times.
✗ Branch 5 not taken.
|
995 | model = PinocchioModelFactory(PinocchioModelTypes::TalosArm).create(); |
78 |
1/2✓ Branch 1 taken 995 times.
✗ Branch 2 not taken.
|
995 | state = boost::make_shared<crocoddyl::StateMultibody>(model); |
79 | 995 | break; | |
80 | 1660 | case StateModelTypes::StateMultibody_HyQ: | |
81 |
2/4✓ Branch 1 taken 1660 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1660 times.
✗ Branch 5 not taken.
|
1660 | model = PinocchioModelFactory(PinocchioModelTypes::HyQ).create(); |
82 |
1/2✓ Branch 1 taken 1660 times.
✗ Branch 2 not taken.
|
1660 | state = boost::make_shared<crocoddyl::StateMultibody>(model); |
83 | 1660 | break; | |
84 | 1755 | case StateModelTypes::StateMultibody_Talos: | |
85 |
2/4✓ Branch 1 taken 1755 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1755 times.
✗ Branch 5 not taken.
|
1755 | model = PinocchioModelFactory(PinocchioModelTypes::Talos).create(); |
86 |
1/2✓ Branch 1 taken 1755 times.
✗ Branch 2 not taken.
|
1755 | state = boost::make_shared<crocoddyl::StateMultibody>(model); |
87 | 1755 | break; | |
88 | 714 | case StateModelTypes::StateMultibody_RandomHumanoid: | |
89 | model = | ||
90 |
2/4✓ Branch 1 taken 714 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 714 times.
✗ Branch 5 not taken.
|
714 | PinocchioModelFactory(PinocchioModelTypes::RandomHumanoid).create(); |
91 |
1/2✓ Branch 1 taken 714 times.
✗ Branch 2 not taken.
|
714 | state = boost::make_shared<crocoddyl::StateMultibody>(model); |
92 | 714 | break; | |
93 | ✗ | default: | |
94 | ✗ | throw_pretty(__FILE__ ": Wrong StateModelTypes::Type given"); | |
95 | break; | ||
96 | } | ||
97 | 17322 | return state; | |
98 | 8661 | } | |
99 | |||
100 | } // namespace unittest | ||
101 | } // namespace crocoddyl | ||
102 |