GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/multibody/impulses/impulse-6d-double.cpp
Date: 2025-04-18 16:41:15
Exec Total Coverage
Lines: 0 18 0.0%
Branches: 0 54 0.0%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2019-2025, 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 // Auto-generated file for double
11 #include "crocoddyl/multibody/impulses/impulse-6d.hpp"
12
13 #include "python/crocoddyl/multibody/multibody.hpp"
14
15 namespace crocoddyl {
16 namespace python {
17
18 template <typename Model>
19 struct ImpulseModel6DVisitor
20 : public bp::def_visitor<ImpulseModel6DVisitor<Model>> {
21 template <class PyClass>
22 void visit(PyClass& cl) const {
23 cl.def("calc", &Model::calc, bp::args("self", "data", "x"),
24 "Compute the 6D impulse Jacobian and drift.\n\n"
25 "The rigid impulse model throught acceleration-base holonomic "
26 "constraint\n"
27 "of the impulse frame placement.\n"
28 ":param data: impulse data\n"
29 ":param x: state point (dim. state.nx)")
30 .def("calcDiff", &Model::calcDiff, bp::args("self", "data", "x"),
31 "Compute the derivatives of the 6D impulse holonomic "
32 "constraint.\n\n"
33 "The rigid impulse model throught acceleration-base holonomic "
34 "constraint\n"
35 "of the impulse frame placement.\n"
36 "It assumes that calc has been run first.\n"
37 ":param data: cost data\n"
38 ":param x: state point (dim. state.nx)")
39 .def("updateForce", &Model::updateForce,
40 bp::args("self", "data", "force"),
41 "Convert the force into a stack of spatial forces.\n\n"
42 ":param data: cost data\n"
43 ":param lambda: force vector (dimension 6)")
44 .def("createData", &Model::createData,
45 bp::with_custodian_and_ward_postcall<0, 2>(),
46 bp::args("self", "data"),
47 "Create the 6D impulse data.\n\n"
48 "Each impulse model has its own data that needs to be allocated. "
49 "This function\n"
50 "returns the allocated data for a predefined cost.\n"
51 ":param data: Pinocchio data\n"
52 ":return impulse data.");
53 }
54 };
55
56 template <typename Data>
57 struct ImpulseData6DVisitor
58 : public bp::def_visitor<ImpulseData6DVisitor<Data>> {
59 template <class PyClass>
60 void visit(PyClass& cl) const {
61 cl.add_property("dv0_local_dq",
62 bp::make_getter(&Data::dv0_local_dq,
63 bp::return_internal_reference<>()),
64 bp::make_setter(&Data::dv0_local_dq),
65 "Jacobian of the desired local contact velocity")
66 .add_property(
67 "fJf",
68 bp::make_getter(&Data::fJf, bp::return_internal_reference<>()),
69 "local Jacobian of the impulse frame")
70 .add_property("v_partial_dq",
71 bp::make_getter(&Data::v_partial_dq,
72 bp::return_internal_reference<>()),
73 "Jacobian of the spatial body velocity")
74 .add_property("v_partial_dv",
75 bp::make_getter(&Data::v_partial_dv,
76 bp::return_internal_reference<>()),
77 "Jacobian of the spatial body velocity");
78 }
79 };
80
81 #define CROCODDYL_IMPULSE_MODEL_6D_PYTHON_BINDINGS(Scalar) \
82 typedef ImpulseModel6DTpl<Scalar> Model; \
83 typedef ImpulseModelAbstractTpl<Scalar> ModelBase; \
84 typedef Model::StateMultibody State; \
85 bp::register_ptr_to_python<std::shared_ptr<Model>>(); \
86 bp::class_<Model, bp::bases<ModelBase>>( \
87 "ImpulseModel6D", \
88 "Rigid 6D impulse model.\n\n" \
89 "It defines a rigid 6D impulse models based on acceleration-based " \
90 "holonomic constraints. The calc and calcDiff functions compute the " \
91 "impulse Jacobian and drift (holonomic constraint) or the derivatives " \
92 "of the holonomic constraint, respectively.", \
93 bp::init<std::shared_ptr<State>, std::size_t, \
94 bp::optional<pinocchio::ReferenceFrame>>( \
95 bp::args("self", "state", "frame", "type"), \
96 "Initialize the impulse model.\n\n" \
97 ":param state: state of the multibody system\n" \
98 ":param type: type of impulse\n" \
99 ":param frame: reference frame id")) \
100 .def(ImpulseModel6DVisitor<Model>()) \
101 .def(CastVisitor<Model>()) \
102 .def(PrintableVisitor<Model>()) \
103 .def(CopyableVisitor<Model>());
104
105 #define CROCODDYL_IMPULSE_DATA_6D_PYTHON_BINDINGS(Scalar) \
106 typedef ImpulseData6DTpl<Scalar> Data; \
107 typedef ImpulseDataAbstractTpl<Scalar> DataBase; \
108 typedef ImpulseModel6DTpl<Scalar> Model; \
109 typedef pinocchio::DataTpl<Scalar> PinocchioData; \
110 bp::register_ptr_to_python<std::shared_ptr<Data>>(); \
111 bp::class_<Data, bp::bases<DataBase>>( \
112 "ImpulseData6D", "Data for 6D impulse.\n\n", \
113 bp::init<Model*, PinocchioData*>( \
114 bp::args("self", "model", "data"), \
115 "Create 6D impulse data.\n\n" \
116 ":param model: 6D impulse model\n" \
117 ":param data: Pinocchio data")[bp::with_custodian_and_ward< \
118 1, 2, bp::with_custodian_and_ward<1, 3>>()]) \
119 .def(ImpulseData6DVisitor<Data>()) \
120 .def(CopyableVisitor<Data>());
121
122 void exposeImpulse6D() {
123 CROCODDYL_IMPULSE_MODEL_6D_PYTHON_BINDINGS(double)
124 CROCODDYL_IMPULSE_DATA_6D_PYTHON_BINDINGS(double)
125 }
126
127 } // namespace python
128 } // namespace crocoddyl
129