GCC Code Coverage Report


Directory: ./
File: unittest/factory/diff_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, University of Edinburgh, CTU, INRIA,
5 // Heriot-Watt University
6 // Copyright note valid unless otherwise stated in individual files.
7 // All rights reserved.
8 ///////////////////////////////////////////////////////////////////////////////
9
10 #ifndef CROCODDYL_DIFF_ACTION_FACTORY_HPP_
11 #define CROCODDYL_DIFF_ACTION_FACTORY_HPP_
12
13 #include "actuation.hpp"
14 #include "constraint.hpp"
15 #include "contact.hpp"
16 #include "cost.hpp"
17 #include "crocoddyl/core/diff-action-base.hpp"
18 #include "crocoddyl/core/numdiff/diff-action.hpp"
19 #include "crocoddyl/multibody/actions/contact-fwddyn.hpp"
20 #include "crocoddyl/multibody/actions/contact-invdyn.hpp"
21 #include "crocoddyl/multibody/actions/free-fwddyn.hpp"
22 #include "crocoddyl/multibody/actions/free-invdyn.hpp"
23 #include "state.hpp"
24
25 namespace crocoddyl {
26 namespace unittest {
27
28 struct DifferentialActionModelTypes {
29 enum Type {
30 DifferentialActionModelLQR,
31 DifferentialActionModelLQRDriftFree,
32 DifferentialActionModelRandomLQR,
33 DifferentialActionModelFreeFwdDynamics_Hector,
34 DifferentialActionModelFreeFwdDynamics_TalosArm,
35 DifferentialActionModelFreeFwdDynamics_TalosArm_Squashed,
36 DifferentialActionModelFreeInvDynamics_Hector,
37 DifferentialActionModelFreeInvDynamics_TalosArm,
38 DifferentialActionModelFreeInvDynamics_TalosArm_Squashed,
39 DifferentialActionModelContactFwdDynamics_TalosArm,
40 DifferentialActionModelContact2DFwdDynamics_TalosArm,
41 DifferentialActionModelContactFwdDynamics_HyQ,
42 DifferentialActionModelContactFwdDynamics_Talos,
43 DifferentialActionModelContactFwdDynamicsWithFriction_TalosArm,
44 DifferentialActionModelContact2DFwdDynamicsWithFriction_TalosArm,
45 DifferentialActionModelContactFwdDynamicsWithFriction_HyQ,
46 DifferentialActionModelContactFwdDynamicsWithFriction_Talos,
47 DifferentialActionModelContactInvDynamics_TalosArm,
48 DifferentialActionModelContactInvDynamics_HyQ,
49 DifferentialActionModelContactInvDynamics_Talos,
50 DifferentialActionModelContactInvDynamicsWithFriction_TalosArm,
51 DifferentialActionModelContactInvDynamicsWithFriction_HyQ,
52 DifferentialActionModelContactInvDynamicsWithFriction_Talos,
53 NbDifferentialActionModelTypes
54 };
55 23 static std::vector<Type> init_all() {
56 23 std::vector<Type> v;
57
1/2
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
23 v.reserve(NbDifferentialActionModelTypes);
58
2/2
✓ Branch 0 taken 529 times.
✓ Branch 1 taken 23 times.
552 for (int i = 0; i < NbDifferentialActionModelTypes; ++i) {
59
1/2
✓ Branch 1 taken 529 times.
✗ Branch 2 not taken.
529 v.push_back((Type)i);
60 }
61 23 return v;
62 }
63 static const std::vector<Type> all;
64 };
65
66 std::ostream& operator<<(std::ostream& os,
67 DifferentialActionModelTypes::Type type);
68
69 class DifferentialActionModelFactory {
70 public:
71 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
72
73 explicit DifferentialActionModelFactory();
74 ~DifferentialActionModelFactory();
75
76 boost::shared_ptr<crocoddyl::DifferentialActionModelAbstract> create(
77 DifferentialActionModelTypes::Type type,
78 bool with_baumgarte = true) const;
79
80 boost::shared_ptr<crocoddyl::DifferentialActionModelFreeFwdDynamics>
81 create_freeFwdDynamics(StateModelTypes::Type state_type,
82 ActuationModelTypes::Type actuation_type,
83 bool constraints = true) const;
84
85 boost::shared_ptr<crocoddyl::DifferentialActionModelFreeInvDynamics>
86 create_freeInvDynamics(StateModelTypes::Type state_type,
87 ActuationModelTypes::Type actuation_type,
88 bool constraints = true) const;
89
90 boost::shared_ptr<crocoddyl::DifferentialActionModelContactFwdDynamics>
91 create_contactFwdDynamics(StateModelTypes::Type state_type,
92 ActuationModelTypes::Type actuation_type,
93 bool with_friction = true,
94 bool with_baumgarte = true) const;
95
96 boost::shared_ptr<crocoddyl::DifferentialActionModelContactInvDynamics>
97 create_contactInvDynamics(StateModelTypes::Type state_type,
98 ActuationModelTypes::Type actuation_type,
99 bool with_friction = true,
100 bool with_baumgarte = true) const;
101 };
102
103 } // namespace unittest
104 } // namespace crocoddyl
105
106 #endif // CROCODDYL_DIFF_ACTION_FACTORY_HPP_
107