GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/core/controls/poly-one.cpp
Date: 2025-01-30 11:01:55
Exec Total Coverage
Lines: 29 29 100.0%
Branches: 22 44 50.0%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2021-2023, 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 #include "crocoddyl/core/controls/poly-one.hpp"
11
12 #include "python/crocoddyl/core/control-base.hpp"
13 #include "python/crocoddyl/core/core.hpp"
14 #include "python/crocoddyl/utils/copyable.hpp"
15
16 namespace crocoddyl {
17 namespace python {
18
19 10 void exposeControlParametrizationPolyOne() {
20 bp::register_ptr_to_python<
21 10 std::shared_ptr<ControlParametrizationModelPolyOne> >();
22
23
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<ControlParametrizationModelPolyOne,
24 bp::bases<ControlParametrizationModelAbstract> >(
25 "ControlParametrizationModelPolyOne",
26 "Linear polynomial control.\n\n"
27 "This control is a linear function of time (normalized in [0,1])."
28 "The first half of the parameter vector contains the initial value of "
29 "the differential control w, "
30 "whereas the second half contains the value of w at t=0.5.",
31
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::init<std::size_t>(
32 20 bp::args("self", "nw"),
33 "Initialize the control dimensions.\n\n"
34 ":param nw: dimension of differential control space"))
35 .def<void (ControlParametrizationModelPolyOne::*)(
36 const std::shared_ptr<ControlParametrizationDataAbstract>&, double,
37
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 const Eigen::Ref<const Eigen::VectorXd>&) const>(
38 "calc", &ControlParametrizationModelPolyOne::calc,
39
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "t", "u"),
40 "Compute the control value.\n\n"
41 ":param data: control-parametrization data\n"
42 ":param t: normalized time in [0, 1]\n"
43 ":param u: control parameters (dim control.nu)")
44 .def<void (ControlParametrizationModelPolyOne::*)(
45 const std::shared_ptr<ControlParametrizationDataAbstract>&, double,
46
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 const Eigen::Ref<const Eigen::VectorXd>&) const>(
47 "calcDiff", &ControlParametrizationModelPolyOne::calcDiff,
48
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "t", "u"),
49 "Compute the Jacobian of the control value with respect to the "
50 "control parameters.\n"
51 "It assumes that calc has been run first.\n\n"
52 ":param data: control-parametrization data\n"
53 ":param t: normalized time in [0, 1]\n"
54 ":param u: control parameters (dim control.nu)")
55
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("createData", &ControlParametrizationModelPolyOne::createData,
56
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self"), "Create the poly-one data.")
57 .def<void (ControlParametrizationModelPolyOne::*)(
58 const std::shared_ptr<ControlParametrizationDataAbstract>&, double,
59
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 const Eigen::Ref<const Eigen::VectorXd>&) const>(
60 "params", &ControlParametrizationModelPolyOne::params,
61
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "t", "w"),
62 "Compute the control parameters.\n\n"
63 ":param data: control-parametrization data\n"
64 ":param t: normalized time in [0, 1]\n"
65 ":param w: control value (dim control.nw)")
66
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("convertBounds", &ControlParametrizationModelPolyOne::convertBounds,
67
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "w_lb", "w_ub"),
68 "Convert the bounds on the control to bounds on the control "
69 "parameters.\n\n"
70 ":param w_lb: lower bounds on u (dim control.nw).\n"
71 ":param w_ub: upper bounds on u (dim control.nw).\n"
72 ":return p_lb, p_ub: lower and upper bounds on the control "
73 "parameters (dim control.nu).")
74
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("multiplyByJacobian",
75 &ControlParametrizationModelPolyOne::multiplyByJacobian_J,
76
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "A"),
77 "Compute the product between the given matrix A and the derivative "
78 "of the control with respect to the "
79 "parameters.\n\n"
80 "It assumes that calc has been run first.\n"
81 ":param data: control-parametrization data\n"
82 ":param A: matrix to multiply (dim na x control.nw)\n"
83 ":return Product between A and the partial derivative of the value "
84 "function (dim na x control.nu)")
85
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("multiplyJacobianTransposeBy",
86 &ControlParametrizationModelPolyOne::multiplyJacobianTransposeBy_J,
87
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "A"),
88 "Compute the product between the transpose of the derivative of the "
89 "control with respect to the parameters\n"
90 "and a given matrix A.\n\n"
91 "It assumes that calc has been run first.\n"
92 ":param data: control-parametrization data\n"
93 ":param A: matrix to multiply (dim control.nw x na)\n"
94 ":return Product between the partial derivative of the value "
95 "function (transposed) and A (dim control.nu x "
96 "na)")
97
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<ControlParametrizationModelPolyOne>());
98
99 boost::python::register_ptr_to_python<
100 10 std::shared_ptr<ControlParametrizationDataPolyOne> >();
101
102
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<ControlParametrizationDataPolyOne,
103 bp::bases<ControlParametrizationDataAbstract> >(
104 "ControlParametrizationDataPolyOne",
105 "Control-parametrization data for the linear polynomial control.",
106
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::init<ControlParametrizationModelPolyOne*>(
107 20 bp::args("self", "model"),
108 "Create control-parametrization data.\n\n"
109 ":param model: linear polynomial control model"))
110
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("c",
111
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&ControlParametrizationDataPolyOne::c,
112 10 bp::return_internal_reference<>()),
113 "polynomial coefficients of the linear control model that "
114 "depends on time")
115
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<ControlParametrizationDataPolyOne>());
116 10 }
117
118 } // namespace python
119 } // namespace crocoddyl
120