GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/core/residuals/joint-effort-float.cpp
Date: 2025-04-18 16:41:15
Exec Total Coverage
Lines: 0 15 0.0%
Branches: 0 52 0.0%

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