GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/core/residuals/joint-effort.cpp
Date: 2025-01-16 08:47:40
Exec Total Coverage
Lines: 26 27 96.3%
Branches: 24 48 50.0%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2022-2023, Heriot-Watt University, University of Edinburgh
5 // Copyright note valid unless otherwise stated in individual files.
6 // All rights reserved.
7 ///////////////////////////////////////////////////////////////////////////////
8
9 #include "crocoddyl/core/residuals/joint-effort.hpp"
10
11 #include "python/crocoddyl/core/core.hpp"
12 #include "python/crocoddyl/utils/copyable.hpp"
13
14 namespace crocoddyl {
15 namespace python {
16
17 10 void exposeResidualJointEffort() {
18 10 bp::register_ptr_to_python<boost::shared_ptr<ResidualModelJointEffort> >();
19
20
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<ResidualModelJointEffort, bp::bases<ResidualModelAbstract> >(
21 "ResidualModelJointEffort",
22 "This residual function defines a residual vector as r = u - uref, with "
23 "u and uref as the current and\n"
24 "reference joint efforts, respectively.",
25
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::init<boost::shared_ptr<StateAbstract>,
26 boost::shared_ptr<ActuationModelAbstract>, Eigen::VectorXd,
27 std::size_t, bp::optional<bool> >(
28 20 bp::args("self", "state", "actuation", "uref", "nu", "fwddyn"),
29 "Initialize the joint-effort residual model.\n\n"
30 ":param state: state description\n"
31 ":param actuation: actuation model\n"
32 ":param uref: reference joint effort\n"
33 ":param nu: dimension of the control vector\n"
34 ":param fwddyn: indicate if we have a forward dynamics problem "
35 "(True) or inverse "
36 "dynamics problem (False) (default False)"))
37
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<StateAbstract>,
38 boost::shared_ptr<ActuationModelAbstract>, Eigen::VectorXd>(
39
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "state", "actuation", "uref"),
40 "Initialize the joint-effort residual model.\n\n"
41 "The default nu value is obtained from state.nv.\n"
42 ":param state: state description\n"
43 ":param actuation: actuation model\n"
44 ":param uref: reference joint effort"))
45
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<StateAbstract>,
46 boost::shared_ptr<ActuationModelAbstract>, std::size_t>(
47
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "state", "actuation", "nu"),
48 "Initialize the joint-effort residual model.\n\n"
49 "The default reference joint-effort is obtained from "
50 "np.zero(actuation.nu).\n"
51 ":param state: state description\n"
52 ":param actuation: actuation model\n"
53 ":param nu: dimension of the control vector"))
54
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<StateAbstract>,
55 boost::shared_ptr<ActuationModelAbstract> >(
56
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "state", "actuation"),
57 "Initialize the joint-effort residual model.\n\n"
58 "The default reference joint-effort is obtained from "
59 "np.zero(actuation.nu).\n"
60 "The default nu value is obtained from state.nv.\n"
61 ":param state: state description\n"
62 ":param actuation: actuation model"))
63 .def<void (ResidualModelJointEffort::*)(
64 const boost::shared_ptr<ResidualDataAbstract>&,
65 const Eigen::Ref<const Eigen::VectorXd>&,
66 20 const Eigen::Ref<const Eigen::VectorXd>&)>(
67 "calc", &ResidualModelJointEffort::calc,
68
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "x", "u"),
69 "Compute the joint-effort residual.\n\n"
70 ":param data: residual data\n"
71 ":param x: state point (dim. state.nx)\n"
72 ":param u: control input (dim. nu)")
73 .def<void (ResidualModelJointEffort::*)(
74 const boost::shared_ptr<ResidualDataAbstract>&,
75
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 const Eigen::Ref<const Eigen::VectorXd>&)>(
76
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 "calc", &ResidualModelAbstract::calc, bp::args("self", "data", "x"))
77 .def<void (ResidualModelJointEffort::*)(
78 const boost::shared_ptr<ResidualDataAbstract>&,
79 const Eigen::Ref<const Eigen::VectorXd>&,
80
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 const Eigen::Ref<const Eigen::VectorXd>&)>(
81 "calcDiff", &ResidualModelJointEffort::calcDiff,
82
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "x", "u"),
83 "Compute the Jacobians of the joint-effort residual.\n\n"
84 "It assumes that calc has been run first.\n"
85 ":param data: residual data\n"
86 ":param x: state point (dim. state.nx)\n"
87 ":param u: control input (dim. nu)")
88 .def<void (ResidualModelJointEffort::*)(
89 const boost::shared_ptr<ResidualDataAbstract>&,
90
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 const Eigen::Ref<const Eigen::VectorXd>&)>(
91 "calcDiff", &ResidualModelAbstract::calcDiff,
92
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "x"))
93
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
20 .def("createData", &ResidualModelJointEffort::createData,
94 bp::with_custodian_and_ward_postcall<0, 2>(),
95
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data"),
96 "Create the joint-effort residual data.\n\n"
97 "Each residual model has its own data that needs to be allocated. "
98 "This function\n"
99 "returns the allocated data for the joint-effort residual.\n"
100 ":param data: shared data\n"
101 ":return residual data.")
102
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("reference",
103
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_function(&ResidualModelJointEffort::get_reference,
104 10 bp::return_internal_reference<>()),
105 &ResidualModelJointEffort::set_reference,
106 "reference joint effort")
107
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<ResidualModelJointEffort>());
108 10 }
109
110 } // namespace python
111 } // namespace crocoddyl
112