GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/core/actions/unicycle.cpp
Date: 2025-01-16 08:47:40
Exec Total Coverage
Lines: 24 25 96.0%
Branches: 22 44 50.0%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2019-2023, LAAS-CNRS, University of Edinburgh
5 // Heriot-Watt University
6 // Copyright note valid unless otherwise stated in individual files.
7 // All rights reserved.
8 ///////////////////////////////////////////////////////////////////////////////
9
10 #include "crocoddyl/core/actions/unicycle.hpp"
11
12 #include "python/crocoddyl/core/action-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 exposeActionUnicycle() {
20 10 bp::register_ptr_to_python<boost::shared_ptr<ActionModelUnicycle> >();
21
22
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<ActionModelUnicycle, bp::bases<ActionModelAbstract> >(
23 "ActionModelUnicycle",
24 "Unicycle action model.\n\n"
25 "The transition model of an unicycle system is described as\n"
26 " xnext = [v*cos(theta); v*sin(theta); w],\n"
27 "where the position is defined by (x, y, theta) and the control input\n"
28 "by (v,w). Note that the state is defined only with the position. On "
29 "the\n"
30 "other hand, we define the quadratic cost functions for the state and\n"
31 "control.",
32
1/2
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
20 bp::init<>(bp::args("self"), "Initialize the unicycle action model."))
33 .def<void (ActionModelUnicycle::*)(
34 const boost::shared_ptr<ActionDataAbstract>&,
35 const Eigen::Ref<const Eigen::VectorXd>&,
36 20 const Eigen::Ref<const Eigen::VectorXd>&)>(
37 "calc", &ActionModelUnicycle::calc,
38
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "x", "u"),
39 "Compute the next state and cost value.\n\n"
40 "It describes the time-discrete evolution of the unicycle system.\n"
41 "Additionally it computes the cost value associated to this "
42 "discrete\n"
43 "state and control pair.\n"
44 ":param data: action data\n"
45 ":param x: state point (dim. state.nx)\n"
46 ":param u: control input (dim. nu)")
47 .def<void (ActionModelUnicycle::*)(
48 const boost::shared_ptr<ActionDataAbstract>&,
49
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 const Eigen::Ref<const Eigen::VectorXd>&)>(
50
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 "calc", &ActionModelAbstract::calc, bp::args("self", "data", "x"))
51 .def<void (ActionModelUnicycle::*)(
52 const boost::shared_ptr<ActionDataAbstract>&,
53 const Eigen::Ref<const Eigen::VectorXd>&,
54
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 const Eigen::Ref<const Eigen::VectorXd>&)>(
55 "calcDiff", &ActionModelUnicycle::calcDiff,
56
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "x", "u"),
57 "Compute the derivatives of the unicycle dynamics and cost "
58 "functions.\n\n"
59 "It computes the partial derivatives of the unicycle system and the\n"
60 "cost function. It assumes that calc has been run first.\n"
61 "This function builds a quadratic approximation of the\n"
62 "action model (i.e. dynamical system and cost function).\n"
63 ":param data: action data\n"
64 ":param x: state point (dim. state.nx)\n"
65 ":param u: control input (dim. nu)")
66 .def<void (ActionModelUnicycle::*)(
67 const boost::shared_ptr<ActionDataAbstract>&,
68
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 const Eigen::Ref<const Eigen::VectorXd>&)>(
69 "calcDiff", &ActionModelAbstract::calcDiff,
70
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "x"))
71
3/6
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 10 times.
✗ Branch 8 not taken.
20 .def("createData", &ActionModelUnicycle::createData, bp::args("self"),
72 "Create the unicycle action data.")
73
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 .add_property("dt", bp::make_function(&ActionModelUnicycle::get_dt),
74
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::make_function(&ActionModelUnicycle::set_dt),
75 "integration time")
76
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("costWeights",
77
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_function(&ActionModelUnicycle::get_cost_weights,
78 bp::return_internal_reference<>()),
79
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::make_function(&ActionModelUnicycle::set_cost_weights),
80 "cost weights")
81
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<ActionModelUnicycle>());
82
83 10 bp::register_ptr_to_python<boost::shared_ptr<ActionDataUnicycle> >();
84
85
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<ActionDataUnicycle, bp::bases<ActionDataAbstract> >(
86 "ActionDataUnicycle",
87 "Action data for the Unicycle system.\n\n"
88 "The unicycle data, apart of common one, contains the cost residuals "
89 "used\n"
90 "for the computation of calc and calcDiff.",
91
1/2
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
20 bp::init<ActionModelUnicycle*>(bp::args("self", "model"),
92 "Create unicycle data.\n\n"
93 ":param model: unicycle action model"))
94
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<ActionDataUnicycle>());
95 10 }
96
97 } // namespace python
98 } // namespace crocoddyl
99