GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/multibody/residuals/contact-cop-position-float.cpp
Date: 2025-04-18 16:41:15
Exec Total Coverage
Lines: 0 20 0.0%
Branches: 0 70 0.0%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2020-2025, University of Duisburg-Essen, University of
5 // Edinburgh,
6 // Heriot-Watt University
7 // Copyright note valid unless otherwise stated in individual files.
8 // All rights reserved.
9 ///////////////////////////////////////////////////////////////////////////////
10
11 // Auto-generated file for float
12 #include "crocoddyl/multibody/residuals/contact-cop-position.hpp"
13
14 #include "python/crocoddyl/multibody/multibody.hpp"
15 #include "python/crocoddyl/utils/deprecate.hpp"
16
17 namespace crocoddyl {
18 namespace python {
19
20 template <typename Model>
21 struct ResidualModelContactCoPPositionVisitor
22 : public bp::def_visitor<ResidualModelContactCoPPositionVisitor<Model>> {
23 typedef typename Model::ResidualDataAbstract Data;
24 typedef typename Model::StateMultibody State;
25 typedef typename Model::VectorXs VectorXs;
26 typedef typename Model::CoPSupport Support;
27 template <class PyClass>
28 void visit(PyClass& cl) const {
29 cl.def(bp::init<std::shared_ptr<State>, pinocchio::FrameIndex, Support>(
30 bp::args("self", "state", "id", "cref"),
31 "Initialize the contact CoP position residual model.\n\n"
32 "The default nu is obtained from state.nv. Note that this "
33 "constructor can be used for forward-dynamics\n"
34 "cases only.\n"
35 ":param state: state of the multibody system\n"
36 ":param id: reference frame id\n"
37 ":param cref: support region of the CoP"))
38 .def(
39 "calc",
40 static_cast<void (Model::*)(
41 const std::shared_ptr<Data>&, const Eigen::Ref<const VectorXs>&,
42 const Eigen::Ref<const VectorXs>&)>(&Model::calc),
43 bp::args("self", "data", "x", "u"),
44 "Compute the contact CoP position residual.\n\n"
45 ":param data: residual data\n"
46 ":param x: state point (dim. state.nx)\n"
47 ":param u: control input (dim. nu)")
48 .def("calc",
49 static_cast<void (Model::*)(const std::shared_ptr<Data>&,
50 const Eigen::Ref<const VectorXs>&)>(
51 &Model::calc),
52 bp::args("self", "data", "x"))
53 .def(
54 "calcDiff",
55 static_cast<void (Model::*)(
56 const std::shared_ptr<Data>&, const Eigen::Ref<const VectorXs>&,
57 const Eigen::Ref<const VectorXs>&)>(&Model::calcDiff),
58 bp::args("self", "data", "x", "u"),
59 "Compute the derivatives of the contact CoP position residual.\n\n"
60 "It assumes that calc has been run first.\n"
61 ":param data: action data\n"
62 ":param x: state point (dim. state.nx)\n"
63 ":param u: control input (dim. nu)\n")
64 .def("calcDiff",
65 static_cast<void (Model::*)(const std::shared_ptr<Data>&,
66 const Eigen::Ref<const VectorXs>&)>(
67 &Model::calcDiff),
68 bp::args("self", "data", "x"))
69 .def("createData", &Model::createData,
70 bp::with_custodian_and_ward_postcall<0, 2>(),
71 bp::args("self", "data"),
72 "Create the contact CoP position residual data.\n\n"
73 "Each residual model has its own data that needs to be allocated. "
74 "This function\n"
75 "returns the allocated data for the CoP position residual.\n"
76 ":param data: shared data\n"
77 ":return residual data.")
78 .add_property(
79 "id", bp::make_function(&Model::get_id),
80 bp::make_function(&Model::set_id,
81 deprecated<>("Deprecated. Do not use set_id, "
82 "instead create a new model")),
83 "reference frame id")
84 .add_property("reference",
85 bp::make_function(
86 &Model::get_reference,
87 bp::return_value_policy<bp::copy_const_reference>()),
88 &Model::set_reference,
89 "reference support region of the CoP");
90 }
91 };
92
93 template <typename Data>
94 struct ResidualDataContactCoPPositionVisitor
95 : public bp::def_visitor<ResidualDataContactCoPPositionVisitor<Data>> {
96 template <class PyClass>
97 void visit(PyClass& cl) const {
98 cl.add_property(
99 "pinocchio",
100 bp::make_getter(&Data::pinocchio, bp::return_internal_reference<>()),
101 "pinocchio data")
102 .add_property(
103 "contact",
104 bp::make_getter(&Data::contact,
105 bp::return_value_policy<bp::return_by_value>()),
106 bp::make_setter(&Data::contact),
107 "contact data associated with the current residual");
108 }
109 };
110
111 #define CROCODDYL_RESIDUAL_MODEL_CONTACT_COP_POSITION_PYTHON_BINDINGS(Scalar) \
112 typedef ResidualModelContactCoPPositionTpl<Scalar> Model; \
113 typedef ResidualModelAbstractTpl<Scalar> ModelBase; \
114 typedef typename Model::StateMultibody State; \
115 typedef typename Model::CoPSupport Support; \
116 bp::register_ptr_to_python<std::shared_ptr<Model>>(); \
117 bp::class_<Model, bp::bases<ModelBase>>( \
118 "ResidualModelContactCoPPosition", \
119 bp::init<std::shared_ptr<State>, pinocchio::FrameIndex, Support, \
120 std::size_t, bp::optional<bool>>( \
121 bp::args("self", "state", "id", "cref", "nu", "fwddyn"), \
122 "Initialize the contact CoP position residual model.\n\n" \
123 ":param state: state of the multibody system\n" \
124 ":param id: reference frame id\n" \
125 ":param cref: support region of the CoP\n" \
126 ":param nu: dimension of control vector\n" \
127 ":param fwddyn: indicate if we have a forward dynamics problem " \
128 "(True) or inverse dynamics problem (False) (default True)")) \
129 .def(ResidualModelContactCoPPositionVisitor<Model>()) \
130 .def(CastVisitor<Model>()) \
131 .def(PrintableVisitor<Model>()) \
132 .def(CopyableVisitor<Model>());
133
134 #define CROCODDYL_RESIDUAL_DATA_CONTACT_COP_POSITION_PYTHON_BINDINGS(Scalar) \
135 typedef ResidualDataContactCoPPositionTpl<Scalar> Data; \
136 typedef ResidualDataAbstractTpl<Scalar> DataBase; \
137 typedef ResidualModelContactCoPPositionTpl<Scalar> Model; \
138 typedef Model::DataCollectorAbstract DataCollector; \
139 bp::register_ptr_to_python<std::shared_ptr<Data>>(); \
140 bp::class_<Data, bp::bases<DataBase>>( \
141 "ResidualDataContactCoPPosition", \
142 "Data for contact CoP position residual.\n\n", \
143 bp::init<Model*, DataCollector*>( \
144 bp::args("self", "model", "data"), \
145 "Create contact CoP position residual data.\n\n" \
146 ":param model: contact CoP position residual model\n" \
147 ":param data: shared data")[bp::with_custodian_and_ward< \
148 1, 2, bp::with_custodian_and_ward<1, 3>>()]) \
149 .def(ResidualDataContactCoPPositionVisitor<Data>()) \
150 .def(CopyableVisitor<Data>());
151
152 void exposeResidualContactCoPPosition() {
153 CROCODDYL_RESIDUAL_MODEL_CONTACT_COP_POSITION_PYTHON_BINDINGS(float)
154 CROCODDYL_RESIDUAL_DATA_CONTACT_COP_POSITION_PYTHON_BINDINGS(float)
155 }
156
157 } // namespace python
158 } // namespace crocoddyl
159