GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/core/integrator/euler.cpp
Date: 2025-01-16 08:47:40
Exec Total Coverage
Lines: 36 36 100.0%
Branches: 27 54 50.0%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2019-2023, LAAS-CNRS, University of Edinburgh, University of
5 // Oxford,
6 // University of Trento, Heriot-Watt University
7 // Copyright note valid unless otherwise stated in individual files.
8 // All rights reserved.
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #include "crocoddyl/core/integrator/euler.hpp"
12
13 #include "python/crocoddyl/core/core.hpp"
14 #include "python/crocoddyl/core/integ-action-base.hpp"
15 #include "python/crocoddyl/utils/copyable.hpp"
16
17 namespace crocoddyl {
18 namespace python {
19
20 10 void exposeIntegratedActionEuler() {
21 10 bp::register_ptr_to_python<boost::shared_ptr<IntegratedActionModelEuler> >();
22
23
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<IntegratedActionModelEuler,
24 bp::bases<IntegratedActionModelAbstract, ActionModelAbstract> >(
25 "IntegratedActionModelEuler",
26 "Sympletic Euler integrator for differential action models.\n\n"
27 "This class implements a sympletic Euler integrator (a.k.a "
28 "semi-implicit\n"
29 "integrator) give a differential action model, i.e.:\n"
30 " [q+, v+] = State.integrate([q, v], [v + a * dt, a * dt] * dt).",
31
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::init<boost::shared_ptr<DifferentialActionModelAbstract>,
32 bp::optional<double, bool> >(
33 20 bp::args("self", "diffModel", "stepTime", "withCostResidual"),
34 "Initialize the sympletic Euler integrator.\n\n"
35 ":param diffModel: differential action model\n"
36 ":param stepTime: step time (default 1e-3)\n"
37 ":param withCostResidual: includes the cost residuals and "
38 "derivatives (default True)."))
39
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 .def(bp::init<boost::shared_ptr<DifferentialActionModelAbstract>,
40 boost::shared_ptr<ControlParametrizationModelAbstract>,
41 bp::optional<double, bool> >(
42
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "diffModel", "control", "stepTime",
43 "withCostResidual"),
44 "Initialize the Euler integrator.\n\n"
45 ":param diffModel: differential action model\n"
46 ":param control: the control parametrization\n"
47 ":param stepTime: step time (default 1e-3)\n"
48 ":param withCostResidual: includes the cost residuals and "
49 "derivatives (default True)."))
50 .def<void (IntegratedActionModelEuler::*)(
51 const boost::shared_ptr<ActionDataAbstract>&,
52 const Eigen::Ref<const Eigen::VectorXd>&,
53 20 const Eigen::Ref<const Eigen::VectorXd>&)>(
54 "calc", &IntegratedActionModelEuler::calc,
55
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "x", "u"),
56 "Compute the time-discrete evolution of a differential action "
57 "model.\n\n"
58 "It describes the time-discrete evolution of action model.\n"
59 ":param data: action data\n"
60 ":param x: state point (dim. state.nx)\n"
61 ":param u: control input (dim. nu)")
62 .def<void (IntegratedActionModelEuler::*)(
63 const boost::shared_ptr<ActionDataAbstract>&,
64
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 const Eigen::Ref<const Eigen::VectorXd>&)>(
65
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 "calc", &ActionModelAbstract::calc, bp::args("self", "data", "x"))
66 .def<void (IntegratedActionModelEuler::*)(
67 const boost::shared_ptr<ActionDataAbstract>&,
68 const Eigen::Ref<const Eigen::VectorXd>&,
69
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 const Eigen::Ref<const Eigen::VectorXd>&)>(
70 "calcDiff", &IntegratedActionModelEuler::calcDiff,
71
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "x", "u"),
72 "Computes the derivatives of the integrated action model wrt state "
73 "and control. \n\n"
74 "This function builds a quadratic approximation of the\n"
75 "action model (i.e. dynamical system and cost function).\n"
76 "It assumes that calc has been run first.\n"
77 ":param data: action data\n"
78 ":param x: state point (dim. state.nx)\n"
79 ":param u: control input (dim. nu)")
80 .def<void (IntegratedActionModelEuler::*)(
81 const boost::shared_ptr<ActionDataAbstract>&,
82
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 const Eigen::Ref<const Eigen::VectorXd>&)>(
83 "calcDiff", &ActionModelAbstract::calcDiff,
84
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "x"))
85
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
20 .def("createData", &IntegratedActionModelEuler::createData,
86
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self"), "Create the Euler integrator data.")
87
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<IntegratedActionModelEuler>());
88
89 10 bp::register_ptr_to_python<boost::shared_ptr<IntegratedActionDataEuler> >();
90
91
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<IntegratedActionDataEuler,
92 bp::bases<IntegratedActionDataAbstract> >(
93 "IntegratedActionDataEuler", "Sympletic Euler integrator data.",
94
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::init<IntegratedActionModelEuler*>(
95 20 bp::args("self", "model"),
96 "Create sympletic Euler integrator data.\n\n"
97 ":param model: sympletic Euler integrator model"))
98
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property(
99 "differential",
100
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&IntegratedActionDataEuler::differential,
101 10 bp::return_value_policy<bp::return_by_value>()),
102 "differential action data")
103
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property(
104 "control",
105
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&IntegratedActionDataEuler::control,
106 10 bp::return_value_policy<bp::return_by_value>()),
107 "control parametrization data")
108
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("dx",
109
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&IntegratedActionDataEuler::dx,
110 10 bp::return_internal_reference<>()),
111 "state rate.")
112
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("Lwu",
113
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&IntegratedActionDataEuler::Lwu,
114 10 bp::return_internal_reference<>()),
115 "Hessian of the cost wrt the differential control (w) and "
116 "the control parameters (u).")
117
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<IntegratedActionDataEuler>());
118 10 }
119
120 } // namespace python
121 } // namespace crocoddyl
122