GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/multibody/actuations/full.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/full.hpp"
11
12 #include "python/crocoddyl/multibody/multibody.hpp"
13
14 namespace crocoddyl {
15 namespace python {
16
17 template <typename Model>
18 struct ActuationModelFullBaseVisitor
19 : public bp::def_visitor<ActuationModelFullBaseVisitor<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 actuation signal and actuation set from the joint "
24 "torque input u.\n\n"
25 ":param data: full actuation data\n"
26 ":param x: state point (dim. state.nx)\n"
27 ":param u: joint torque input (dim. nu)")
28
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"),
29 "Compute the derivatives of the actuation model.\n\n"
30 "It computes the partial derivatives of the full actuation. It "
31 "assumes that calc has been run first. The reason is that the "
32 "derivatives are constant and defined in createData. The Hessian "
33 "is constant, so we don't write again this value.\n"
34 ":param data: full actuation data\n"
35 ":param x: state point (dim. state.nx)\n"
36 ":param u: joint torque input (dim. nu)")
37
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"),
38 "Compute the joint torque commands from the generalized "
39 "torques.\n\n"
40 "It stores the results in data.u.\n"
41 ":param data: actuation data\n"
42 ":param x: state point (dim. state.nx)\n"
43 ":param tau: generalized torques (dim state.nv)")
44
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,
45 bp::args("self", "data", "x", "tau"),
46 "Compute the torque transform from generalized torques to joint "
47 "torque inputs.\n\n"
48 "It stores the results in data.Mtau.\n"
49 ":param data: actuation data\n"
50 ":param x: state point (dim. state.nx)\n"
51 ":param tau: generalized torques (dim state.nv)")
52
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"),
53 "Create the full actuation data.\n\n"
54 "Each actuation model (AM) has its own data that needs to be "
55 "allocated.\n"
56 "This function returns the allocated data for a predefined AM.\n"
57 ":return AM data.");
58 40 }
59 };
60
61 #define CROCODDYL_ACTUATION_MODEL_FULL_PYTHON_BINDINGS(Scalar) \
62 typedef ActuationModelFullTpl<Scalar> Model; \
63 typedef ActuationModelAbstractTpl<Scalar> ModelBase; \
64 typedef StateAbstractTpl<Scalar> StateAbstract; \
65 bp::register_ptr_to_python<std::shared_ptr<Model>>(); \
66 bp::class_<Model, bp::bases<ModelBase>>( \
67 "ActuationModelFull", "Full actuation models.", \
68 bp::init<std::shared_ptr<StateAbstract>>( \
69 bp::args("self", "state"), \
70 "Initialize the full actuation model.\n\n" \
71 ":param state: state of dynamical system")) \
72 .def(ActuationModelFullBaseVisitor<Model>()) \
73 .def(CastVisitor<Model>()) \
74 .def(PrintableVisitor<Model>()) \
75 .def(CopyableVisitor<Model>());
76
77 10 void exposeActuationFull() {
78
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(CROCODDYL_ACTUATION_MODEL_FULL_PYTHON_BINDINGS)
79 10 }
80
81 } // namespace python
82 } // namespace crocoddyl
83