GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/core/controls/poly-two-rk-double.cpp
Date: 2025-04-18 16:41:15
Exec Total Coverage
Lines: 0 14 0.0%
Branches: 0 52 0.0%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2021-2025, University of Edinburgh, University of Trento
5 // Heriot-Watt University
6 // Copyright note valid unless otherwise stated in individual files.
7 // All rights reserved.
8 ///////////////////////////////////////////////////////////////////////////////
9
10 // Auto-generated file for double
11 #include "crocoddyl/core/controls/poly-two-rk.hpp"
12
13 #include "python/crocoddyl/core/control-base.hpp"
14 #include "python/crocoddyl/core/core.hpp"
15 #include "python/crocoddyl/utils/copyable.hpp"
16
17 namespace crocoddyl {
18 namespace python {
19
20 template <typename Model>
21 struct ControlParametrizationModelPolyTwoRKVisitor
22 : public bp::def_visitor<
23 ControlParametrizationModelPolyTwoRKVisitor<Model>> {
24 typedef typename Model::Scalar Scalar;
25 typedef typename Model::ControlParametrizationDataAbstract Data;
26 typedef typename Model::VectorXs VectorXs;
27 template <class PyClass>
28 void visit(PyClass& cl) const {
29 cl.def("calc",
30 static_cast<void (Model::*)(
31 const std::shared_ptr<Data>&, const Scalar,
32 const Eigen::Ref<const VectorXs>&) const>(&Model::calc),
33 bp::args("self", "data", "t", "u"),
34 bp::args("self", "data", "t", "u"),
35 "Compute the control value.\n\n"
36 ":param data: poly-two-rk data\n"
37 ":param t: normalized time in [0, 1]\n"
38 ":param u: control parameters (dim control.nu)")
39 .def("calcDiff",
40 static_cast<void (Model::*)(
41 const std::shared_ptr<Data>&, const Scalar,
42 const Eigen::Ref<const VectorXs>&) const>(&Model::calcDiff),
43 bp::args("self", "data", "t", "u"),
44 "Compute the Jacobian of the control value with respect to the "
45 "control parameters.\n\n"
46 "It assumes that calc has been run first.\n"
47 ":param data: poly-two-rk data\n"
48 ":param t: normalized time in [0, 1]\n"
49 ":param u: control parameters (dim control.nu)")
50 .def("createData", &Model::createData, bp::args("self"),
51 "Create the poly-two-rk data.")
52 .def("params",
53 static_cast<void (Model::*)(
54 const std::shared_ptr<Data>&, const Scalar,
55 const Eigen::Ref<const VectorXs>&) const>(&Model::params),
56 bp::args("self", "data", "t", "w"),
57 "Compute the control parameters.\n\n"
58 ":param data: poly-two-rk data\n"
59 ":param t: normalized time in [0, 1]\n"
60 ":param w: control value (dim control.nw)")
61 .def("convertBounds", &Model::convertBounds,
62 bp::args("self", "w_lb", "w_ub"),
63 "Convert the bounds on the control to bounds on the control "
64 "parameters.\n\n"
65 ":param w_lb: lower bounds on w (dim control.nw)\n"
66 ":param w_ub: upper bounds on w (dim control.nw)\n"
67 ":return u_lb, u_ub: lower and upper bounds on the control "
68 "parameters (dim control.nu)")
69 .def("multiplyByJacobian", &Model::multiplyByJacobian_J,
70 bp::args("self", "data", "A"),
71 "Compute the product between the given matrix A and the "
72 "derivative of the control with respect to the parameters.\n\n"
73 "It assumes that calc has been run first.\n"
74 ":param data: poly-two-rk data\n"
75 ":param A: matrix to multiply (dim na x control.nw)\n"
76 ":return Product between A and the partial derivative of the "
77 "control (dim na x control.nu)")
78 .def("multiplyJacobianTransposeBy",
79 &Model::multiplyJacobianTransposeBy_J,
80 bp::args("self", "data", "A"),
81 "Compute the product between the transpose of the derivative of "
82 "the control with respect to the parameters and a given matrix "
83 "A.\n\n"
84 "It assumes that calc has been run first.\n"
85 ":param data: poly-two-rk data\n"
86 ":param A: matrix to multiply (dim control.nw x na)\n"
87 ":return Product between the partial derivative of the control "
88 "(transposed) and A (dim control.nu x "
89 "na)");
90 }
91 };
92
93 template <typename Data>
94 struct ControlParametrizationDataPolyTwoRKVisitor
95 : public bp::def_visitor<ControlParametrizationDataPolyTwoRKVisitor<Data>> {
96 template <class PyClass>
97 void visit(PyClass& cl) const {
98 cl.add_property(
99 "c", bp::make_getter(&Data::c, bp::return_internal_reference<>()),
100 "polynomial coefficients of the second-order control model");
101 }
102 };
103
104 #define CROCODDYL_CONTROL_PARAMETRIZATION_MODEL_POLYTWORK_PYTHON_BINDINGS( \
105 Scalar) \
106 typedef ControlParametrizationModelPolyTwoRKTpl<Scalar> Model; \
107 typedef ControlParametrizationModelAbstractTpl<Scalar> ModelBase; \
108 bp::register_ptr_to_python<std::shared_ptr<Model>>(); \
109 bp::class_<Model, bp::bases<ModelBase>>( \
110 "ControlParametrizationModelPolyTwoRK", \
111 "Second-order polynomial control for RK integrators.\n\n" \
112 "This control is a quadratic function of time (normalized in [0,1]). " \
113 "It comes in two versions, one specialized for RK3 integration, " \
114 "another for RK4 integration. The first third of the parameter vector " \
115 "contains the initial value of the differential control w, the second " \
116 "third contains the value of w at t=0.5 (for RK4) or 1/3 (for RK3), " \
117 "and the last third is the final value\n of w at time t=1 (for RK4) or " \
118 "2/3 (for RK3).", \
119 bp::init<std::size_t, RKType>( \
120 bp::args("self", "nw", "rktype"), \
121 "Initialize the control dimensions.\n\n" \
122 ":param nw: dimension of differential control space\n" \
123 ":param rktype: type of RK parametrization")) \
124 .def(ControlParametrizationModelPolyTwoRKVisitor<Model>()) \
125 .def(CastVisitor<Model>()) \
126 .def(PrintableVisitor<Model>()) \
127 .def(CopyableVisitor<Model>());
128
129 #define CROCODDYL_CONTROL_PARAMETRIZATION_DATA_POLYTWORK_PYTHON_BINDINGS( \
130 Scalar) \
131 typedef ControlParametrizationDataPolyTwoRKTpl<Scalar> Data; \
132 typedef ControlParametrizationDataAbstractTpl<Scalar> DataBase; \
133 typedef ControlParametrizationModelPolyTwoRKTpl<Scalar> Model; \
134 bp::register_ptr_to_python<std::shared_ptr<Data>>(); \
135 bp::class_<Data, bp::bases<DataBase>>( \
136 "ControlParametrizationDataPolyTwoRK", \
137 "Control-parametrization data for the second-order polynomial control.", \
138 bp::init<Model*>(bp::args("self", "model"), \
139 "Create control-parametrization data.\n\n" \
140 ":param model: second-order polynomial control model")) \
141 .def(ControlParametrizationDataPolyTwoRKVisitor<Data>()) \
142 .def(CopyableVisitor<Data>());
143
144 void exposeControlParametrizationPolyTwoRK() {
145 CROCODDYL_CONTROL_PARAMETRIZATION_MODEL_POLYTWORK_PYTHON_BINDINGS(double)
146 CROCODDYL_CONTROL_PARAMETRIZATION_DATA_POLYTWORK_PYTHON_BINDINGS(double)
147 }
148
149 } // namespace python
150 } // namespace crocoddyl
151