GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/core/controls/poly-zero.cpp
Date: 2025-02-24 23:41:29
Exec Total Coverage
Lines: 23 23 100.0%
Branches: 19 38 50.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 #include "crocoddyl/core/controls/poly-zero.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 exposeControlParametrizationPolyZero() {
20 bp::register_ptr_to_python<
21 10 std::shared_ptr<ControlParametrizationModelPolyZero> >();
22
23
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<ControlParametrizationModelPolyZero,
24 bp::bases<ControlParametrizationModelAbstract> >(
25 "ControlParametrizationModelPolyZero",
26 "Constant control.\n\n"
27 "This control is a constant."
28 "The parameter vector corresponds to the constant value of the "
29 "differential control w, that is w=p.",
30
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::init<std::size_t>(
31 20 bp::args("self", "nw"),
32 "Initialize the control dimensions.\n\n"
33 ":param nw: dimension of differential control space"))
34 .def<void (ControlParametrizationModelPolyZero::*)(
35 const std::shared_ptr<ControlParametrizationDataAbstract>&, double,
36
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 const Eigen::Ref<const Eigen::VectorXd>&) const>(
37 "calc", &ControlParametrizationModelPolyZero::calc,
38
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "t", "u"),
39 "Compute the control value.\n\n"
40 ":param data: control-parametrization data\n"
41 ":param t: normalized time in [0, 1]\n"
42 ":param u: control parameters (dim control.nu)")
43 .def<void (ControlParametrizationModelPolyZero::*)(
44 const std::shared_ptr<ControlParametrizationDataAbstract>&, double,
45
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 const Eigen::Ref<const Eigen::VectorXd>&) const>(
46 "calcDiff", &ControlParametrizationModelPolyZero::calcDiff,
47
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "t", "u"),
48 "Compute the Jacobian of the control value with respect to the "
49 "control parameters.\n"
50 "It assumes that calc has been run first.\n\n"
51 ":param data: control-parametrization data\n"
52 ":param t: normalized time in [0, 1]\n"
53 ":param u: control parameters (dim control.nu)")
54
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("createData", &ControlParametrizationModelPolyZero::createData,
55
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self"), "Create the poly-zero data.")
56 .def<void (ControlParametrizationModelPolyZero::*)(
57 const std::shared_ptr<ControlParametrizationDataAbstract>&, double,
58
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 const Eigen::Ref<const Eigen::VectorXd>&) const>(
59 "params", &ControlParametrizationModelPolyZero::params,
60
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "t", "u"),
61 "Compute the control parameters.\n\n"
62 ":param data: control-parametrization data\n"
63 ":param t: normalized time in [0, 1]\n"
64 ":param w: control value (dim control.nw)")
65
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("convertBounds", &ControlParametrizationModelPolyZero::convertBounds,
66
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "u_lb", "u_ub"),
67 "Convert the bounds on the control to bounds on the control "
68 "parameters.\n\n"
69 ":param w_lb: lower bounds on w (dim control.nw)\n"
70 ":param w_ub: upper bounds on w (dim control.nw)\n"
71 ":return p_lb, p_ub: lower and upper bounds on the control "
72 "parameters (dim control.nu)")
73
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("multiplyByJacobian",
74 &ControlParametrizationModelPolyZero::multiplyByJacobian_J,
75
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 ControlParametrizationModelAbstract_multiplyByJacobian_J_wrap(
76
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "A", "op"),
77 "Compute the product between the given matrix A and the "
78 "derivative "
79 "of the control with respect to the "
80 "parameters.\n\n"
81 "It assumes that calc has been run first.\n"
82 ":param data: control-parametrization data\n"
83 ":param A: matrix to multiply (dim na x control.nw)\n"
84 ":op assignment operator which sets, adds, or removes the given "
85 "results\n"
86 ":return Product between A and the partial derivative of the "
87 "value "
88 "function (dim na x control.nu)"))
89
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(
90 "multiplyJacobianTransposeBy",
91 &ControlParametrizationModelPolyZero::multiplyJacobianTransposeBy_J,
92
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 ControlParametrizationModelAbstract_multiplyJacobianTransposeBy_J_wrap(
93
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "A", "op"),
94 "Compute the product between the transpose of the derivative of "
95 "the "
96 "control with respect to the parameters\n"
97 "and a given matrix A.\n\n"
98 "It assumes that calc has been run first.\n"
99 ":param data: control-parametrization data\n"
100 ":param A: matrix to multiply (dim control.nw x na)\n"
101 ":op assignment operator which sets, adds, or removes the given "
102 "results\n"
103 ":return Product between the partial derivative of the value "
104 "function (transposed) and A (dim control.nu x "
105 "na)"))
106
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<ControlParametrizationModelPolyZero>());
107 10 }
108
109 } // namespace python
110 } // namespace crocoddyl
111