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