GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/multibody/actuations/floating-base.cpp
Date: 2025-03-26 19:23:43
Exec Total Coverage
Lines: 10 10 100.0%
Branches: 26 52 50.0%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2019-2025, 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 #include "crocoddyl/multibody/actuations/floating-base.hpp"
11
12 #include "python/crocoddyl/multibody/multibody.hpp"
13
14 namespace crocoddyl {
15 namespace python {
16
17 template <typename Model>
18 struct ActuationModelFloatingBaseVisitor
19 : public bp::def_visitor<ActuationModelFloatingBaseVisitor<Model>> {
20 template <class PyClass>
21 40 void visit(PyClass& cl) const {
22 40 cl.def("calc", &Model::calc, bp::args("self", "data", "x", "u"),
23 "Compute the floating-base actuation signal and actuation set from "
24 "the joint torque input u.\n\n"
25 "It describes the time-continuos evolution of the floating-base "
26 "actuation model.\n"
27 ":param data: floating-base actuation data\n"
28 ":param x: state point (dim. state.nx)\n"
29 ":param u: joint-torque input (dim. nu)")
30
2/4
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
80 .def("calcDiff", &Model::calcDiff, bp::args("self", "data", "x", "u"),
31 "Compute the Jacobians of the floating-base actuation model.\n\n"
32 "It computes the partial derivatives of the floating-base "
33 "actuation. It assumes that calc\n"
34 "has been run first. The reason is that the derivatives are "
35 "constant and defined in createData. The derivatives are "
36 "constant, so we don't write again these values.\n"
37 ":param data: floating-base actuation data\n"
38 ":param x: state point (dim. state.nx)\n"
39 ":param u: joint-torque input (dim. nu)")
40
2/4
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
80 .def("commands", &Model::commands, bp::args("self", "data", "x", "tau"),
41 "Compute the joint-torque commands from the generalized "
42 "torques.\n\n"
43 "It stores the results in data.u.\n"
44 ":param data: actuation data\n"
45 ":param x: state point (dim. state.nx)\n"
46 ":param tau: generalized torques (dim state.nv)")
47
2/4
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
80 .def("torqueTransform", &Model::torqueTransform,
48 bp::args("self", "data", "x", "tau"),
49 "Compute the torque transform from generalized torques to "
50 "joint-torque inputs.\n\n"
51 "It stores the results in data.Mtau.\n"
52 ":param data: actuation data\n"
53 ":param x: state point (dim. state.nx)\n"
54 ":param tau: generalized torques (dim state.nv)")
55
3/6
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
40 .def("createData", &Model::createData, bp::args("self"),
56 "Create the floating-base actuation data.\n\n"
57 "Each actuation model (AM) has its own data that needs to be "
58 "allocated.\n"
59 "This function returns the allocated data for a predefined AM.\n"
60 ":return AM data.");
61 40 }
62 };
63
64 #define CROCODDYL_ACTUATION_MODEL_FLOATINGBASE_PYTHON_BINDINGS(Scalar) \
65 typedef ActuationModelFloatingBaseTpl<Scalar> Model; \
66 typedef ActuationModelAbstractTpl<Scalar> ModelBase; \
67 typedef StateMultibodyTpl<Scalar> StateMultibody; \
68 bp::register_ptr_to_python<std::shared_ptr<Model>>(); \
69 bp::class_<Model, bp::bases<ModelBase>>( \
70 "ActuationModelFloatingBase", \
71 "Floating-base actuation models.\n\n" \
72 "It considers the first joint, defined in the Pinocchio model, as the " \
73 "floating-base joints. Then, this joint (that might have various DoFs) " \
74 "is unactuated.", \
75 bp::init<std::shared_ptr<StateMultibody>>( \
76 bp::args("self", "state"), \
77 "Initialize the floating-base actuation model.\n\n" \
78 ":param state: state of multibody system")) \
79 .def(ActuationModelFloatingBaseVisitor<Model>()) \
80 .def(CastVisitor<Model>()) \
81 .def(PrintableVisitor<Model>()) \
82 .def(CopyableVisitor<Model>());
83
84 10 void exposeActuationFloatingBase() {
85
17/34
✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 10 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 10 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 10 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 10 times.
✗ Branch 19 not taken.
✓ Branch 24 taken 10 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 10 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 10 times.
✗ Branch 31 not taken.
✓ Branch 35 taken 10 times.
✗ Branch 36 not taken.
✓ Branch 38 taken 10 times.
✗ Branch 39 not taken.
✓ Branch 41 taken 10 times.
✗ Branch 42 not taken.
✓ Branch 44 taken 10 times.
✗ Branch 45 not taken.
✓ Branch 47 taken 10 times.
✗ Branch 48 not taken.
✓ Branch 50 taken 10 times.
✗ Branch 51 not taken.
✓ Branch 53 taken 10 times.
✗ Branch 54 not taken.
✓ Branch 56 taken 10 times.
✗ Branch 57 not taken.
20 CROCODDYL_PYTHON_SCALARS(
86 CROCODDYL_ACTUATION_MODEL_FLOATINGBASE_PYTHON_BINDINGS)
87 10 }
88
89 } // namespace python
90 } // namespace crocoddyl
91