GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/core/controls/poly-zero.cpp
Date: 2025-01-16 08:47:40
Exec Total Coverage
Lines: 21 21 100.0%
Branches: 17 34 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-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 boost::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 boost::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 boost::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 boost::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.
20 bp::args("self", "data", "A"),
76 "Compute the product between the given matrix A and the derivative "
77 "of the control with respect to the "
78 "parameters.\n\n"
79 "It assumes that calc has been run first.\n"
80 ":param data: control-parametrization data\n"
81 ":param A: matrix to multiply (dim na x control.nw)\n"
82 ":return Product between A and the partial derivative of the value "
83 "function (dim na x control.nu)")
84
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("multiplyJacobianTransposeBy",
85 &ControlParametrizationModelPolyZero::multiplyJacobianTransposeBy_J,
86
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "A"),
87 "Compute the product between the transpose of the derivative of the "
88 "control with respect to the parameters\n"
89 "and a given matrix A.\n\n"
90 "It assumes that calc has been run first.\n"
91 ":param data: control-parametrization data\n"
92 ":param A: matrix to multiply (dim control.nw x na)\n"
93 ":return Product between the partial derivative of the value "
94 "function (transposed) and A (dim control.nu x "
95 "na)")
96
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<ControlParametrizationModelPolyZero>());
97 10 }
98
99 } // namespace python
100 } // namespace crocoddyl
101