GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/multibody/actuations/floating-base-propellers.cpp
Date: 2025-01-16 08:47:40
Exec Total Coverage
Lines: 46 47 97.9%
Branches: 41 82 50.0%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2024-2024, Heriot-Watt University
5 // Copyright note valid unless otherwise stated in individual files.
6 // All rights reserved.
7 ///////////////////////////////////////////////////////////////////////////////
8
9 #include "crocoddyl/multibody/actuations/floating-base-thrusters.hpp"
10 #include "python/crocoddyl/multibody/multibody.hpp"
11 #include "python/crocoddyl/utils/copyable.hpp"
12 #include "python/crocoddyl/utils/printable.hpp"
13 #include "python/crocoddyl/utils/vector-converter.hpp"
14
15 namespace crocoddyl {
16
17 namespace python {
18
19 10 void exposeActuationFloatingBaseThruster() {
20 20 bp::enum_<ThrusterType>("ThrusterType")
21
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .value("CW", CW)
22
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .value("CCW", CCW)
23
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .export_values();
24
25
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<Thruster>(
26 "Thruster", "Model for thrusters",
27
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::init<pinocchio::SE3, double,
28 bp::optional<ThrusterType, double, double>>(
29 20 bp::args("self", "M", "ctorque", "type", "min_thrust", "max_thrust"),
30 "Initialize the thruster in a give pose from the root joint.\n\n"
31 ":param M: pose from root joint\n"
32 ":param ctorque: coefficient of generated torque per thrust\n"
33 ":param type: type of thruster (clockwise or counterclockwise, "
34 "default clockwise)\n"
35 ":param min_thrust: minimum thrust (default 0.)\n"
36 ":param max_thrust: maximum thrust (default np.inf)"))
37
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 .def(bp::init<double, bp::optional<ThrusterType, double, double>>(
38
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "ctorque", "type", "min_thrust", "max_thrust"),
39 "Initialize the thruster in a give pose from the root joint.\n\n"
40 ":param ctorque: coefficient of generated torque per thrust\n"
41 ":param type: type of thruster (clockwise or counterclockwise, "
42 "default clockwise)\n"
43 ":param min_thrust: minimum thrust (default 0.)\n"
44 ":param max_thrust: maximum thrust (default np.inf)"))
45
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def_readwrite("pose", &Thruster::pose,
46 "thruster pose (traslation, rotation)")
47
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def_readwrite("ctorque", &Thruster::ctorque,
48 "coefficient of generated torque per thrust")
49
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def_readwrite("type", &Thruster::type,
50 "type of thruster (clockwise or counterclockwise)")
51
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def_readwrite("min_thrust", &Thruster::min_thrust, "minimum thrust")
52
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def_readwrite("max_thrust", &Thruster::min_thrust, "maximum thrust")
53
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(PrintableVisitor<Thruster>())
54
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<Thruster>());
55
56
3/6
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 10 times.
✗ Branch 10 not taken.
10 StdVectorPythonVisitor<std::vector<Thruster>, true>::expose(
57 "StdVec_Thruster");
58
59 bp::register_ptr_to_python<
60 10 boost::shared_ptr<crocoddyl::ActuationModelFloatingBaseThrusters>>();
61
62
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<ActuationModelFloatingBaseThrusters,
63 bp::bases<ActuationModelAbstract>>(
64 "ActuationModelFloatingBaseThrusters",
65 "Actuation models for floating base systems actuated with thrusters "
66 "(e.g. aerial "
67 "manipulators).",
68
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::init<boost::shared_ptr<StateMultibody>, std::vector<Thruster>>(
69 20 bp::args("self", "state", "thrusters"),
70 "Initialize the floating base actuation model equipped with "
71 "thrusters.\n\n"
72 ":param state: state of multibody system\n"
73 ":param thrusters: vector of thrusters"))
74 .def<void (ActuationModelFloatingBaseThrusters::*)(
75 const boost::shared_ptr<ActuationDataAbstract>&,
76 const Eigen::Ref<const Eigen::VectorXd>&,
77
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 const Eigen::Ref<const Eigen::VectorXd>&)>(
78 "calc", &ActuationModelFloatingBaseThrusters::calc,
79
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "x", "u"),
80 "Compute the actuation signal and actuation set from the thrust\n"
81 "forces and joint torque inputs u.\n\n"
82 ":param data: floating base thrusters actuation data\n"
83 ":param x: state point (dim. state.nx)\n"
84 ":param u: joint torque input (dim. nu)")
85
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("calcDiff", &ActuationModelFloatingBaseThrusters::calcDiff,
86
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "x", "u"),
87 "Compute the derivatives of the actuation model.\n\n"
88 "It computes the partial derivatives of the thruster actuation. It\n"
89 "assumes that calc has been run first. The reason is that the\n"
90 "derivatives are constant and defined in createData. The Hessian\n"
91 "is constant, so we don't write again this value.\n"
92 ":param data: floating base thrusters actuation data\n"
93 ":param x: state point (dim. state.nx)\n"
94 ":param u: joint torque input (dim. nu)")
95
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("commands", &ActuationModelFloatingBaseThrusters::commands,
96
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "x", "tau"),
97 "Compute the thrust and joint torque commands from the generalized "
98 "torques.\n\n"
99 "It stores the results in data.u.\n"
100 ":param data: actuation data\n"
101 ":param x: state point (dim. state.nx)\n"
102 ":param tau: generalized torques (dim state.nv)")
103
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("torqueTransform",
104 &ActuationModelFloatingBaseThrusters::torqueTransform,
105
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "x", "tau"),
106 "Compute the torque transform from generalized torques to thrust "
107 "and joint torque inputs.\n\n"
108 "It stores the results in data.Mtau.\n"
109 ":param data: floating base thrusters actuation data\n"
110 ":param x: state point (dim. state.nx)\n"
111 ":param tau: generalized torques (dim state.nv)")
112
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("createData", &ActuationModelFloatingBaseThrusters::createData,
113
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self"),
114 "Create the floating base thrusters actuation data.")
115
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property(
116 "thrusters",
117
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_function(&ActuationModelFloatingBaseThrusters::get_thrusters,
118 bp::return_value_policy<bp::return_by_value>()),
119
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::make_function(
120 &ActuationModelFloatingBaseThrusters::set_thrusters),
121 "vector of thrusters")
122
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("nthrusters",
123
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::make_function(
124 &ActuationModelFloatingBaseThrusters::get_nthrusters),
125 "number of thrusters")
126
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property(
127 "Wthrust",
128
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_function(&ActuationModelFloatingBaseThrusters::get_Wthrust,
129 10 bp::return_value_policy<bp::return_by_value>()),
130 "matrix mapping from thrusts to thruster wrenches")
131
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property(
132 "S",
133
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_function(&ActuationModelFloatingBaseThrusters::get_S,
134 10 bp::return_value_policy<bp::return_by_value>()),
135 "selection matrix for under-actuation part")
136
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(PrintableVisitor<ActuationModelFloatingBaseThrusters>())
137
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<ActuationModelFloatingBaseThrusters>());
138 10 }
139
140 } // namespace python
141 } // namespace crocoddyl
142