Line |
Branch |
Exec |
Source |
1 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
2 |
|
|
// BSD 3-Clause License |
3 |
|
|
// |
4 |
|
|
// Copyright (C) 2021-2025, University of Edinburgh, Heriot-Watt University |
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/multibody/force-base.hpp" |
11 |
|
|
|
12 |
|
|
#include "python/crocoddyl/multibody/contact-base.hpp" |
13 |
|
|
#include "python/crocoddyl/multibody/impulse-base.hpp" |
14 |
|
|
#include "python/crocoddyl/multibody/multibody.hpp" |
15 |
|
|
|
16 |
|
|
namespace crocoddyl { |
17 |
|
|
namespace python { |
18 |
|
|
|
19 |
|
|
template <typename Data> |
20 |
|
|
struct ForceDataAbstractVisitor |
21 |
|
|
: public bp::def_visitor<ForceDataAbstractVisitor<Data>> { |
22 |
|
|
typedef typename Data::Scalar Scalar; |
23 |
|
|
typedef ImpulseModelAbstractTpl<Scalar> ImpulseModel; |
24 |
|
|
typedef pinocchio::DataTpl<Scalar> PinocchioData; |
25 |
|
|
template <class PyClass> |
26 |
|
✗ |
void visit(PyClass& cl) const { |
27 |
|
✗ |
cl.def( |
28 |
|
✗ |
bp::init<ImpulseModel*, PinocchioData*>()[bp::with_custodian_and_ward< |
29 |
|
|
1, 2, bp::with_custodian_and_ward<1, 3>>()]) |
30 |
|
✗ |
.add_property("pinocchio", |
31 |
|
|
bp::make_getter(&Data::pinocchio, |
32 |
|
✗ |
bp::return_internal_reference<>()), |
33 |
|
|
"pinocchio data") |
34 |
|
✗ |
.def_readwrite("frame", &Data::frame, "frame id of the contact") |
35 |
|
✗ |
.def_readwrite("type", &Data::type, "type of contact") |
36 |
|
✗ |
.add_property( |
37 |
|
|
"jMf", |
38 |
|
|
bp::make_getter(&Data::jMf, |
39 |
|
✗ |
bp::return_value_policy<bp::return_by_value>()), |
40 |
|
|
bp::make_setter(&Data::jMf), |
41 |
|
|
"local frame placement of the contact frame") |
42 |
|
✗ |
.add_property( |
43 |
|
✗ |
"Jc", bp::make_getter(&Data::Jc, bp::return_internal_reference<>()), |
44 |
|
|
bp::make_setter(&Data::Jc), "contact Jacobian") |
45 |
|
✗ |
.def_readwrite( |
46 |
|
|
"f", &Data::f, |
47 |
|
|
"contact force expressed in the coordinate defined by type") |
48 |
|
✗ |
.def_readwrite( |
49 |
|
|
"fext", &Data::fext, |
50 |
|
|
"external spatial force at the parent joint level. Note " |
51 |
|
|
"that we could compute the force at the " |
52 |
|
|
"contact frame by using jMf (i.e. data.jMf.actInv(data.f)") |
53 |
|
✗ |
.add_property( |
54 |
|
|
"df_dx", |
55 |
|
✗ |
bp::make_getter(&Data::df_dx, bp::return_internal_reference<>()), |
56 |
|
|
bp::make_setter(&Data::df_dx), |
57 |
|
|
"Jacobian of the contact forces expressed in the " |
58 |
|
|
"coordinate defined by type") |
59 |
|
✗ |
.add_property( |
60 |
|
|
"df_du", |
61 |
|
✗ |
bp::make_getter(&Data::df_du, bp::return_internal_reference<>()), |
62 |
|
|
bp::make_setter(&Data::df_du), |
63 |
|
|
"Jacobian of the contact forces expressed in the " |
64 |
|
|
"coordinate defined by type"); |
65 |
|
|
} |
66 |
|
|
}; |
67 |
|
|
|
68 |
|
|
#define CROCODDYL_FORCE_DATA_ABSTRACT_PYTHON_BINDINGS(Scalar) \ |
69 |
|
|
typedef ForceDataAbstractTpl<Scalar> Data; \ |
70 |
|
|
typedef ContactModelAbstractTpl<Scalar> ContactModel; \ |
71 |
|
|
typedef pinocchio::DataTpl<Scalar> PinocchioData; \ |
72 |
|
|
bp::register_ptr_to_python<std::shared_ptr<Data>>(); \ |
73 |
|
|
bp::class_<Data>( \ |
74 |
|
|
"ForceDataAbstract", "Abstract class for force datas.\n\n", \ |
75 |
|
|
bp::init<ContactModel*, PinocchioData*>( \ |
76 |
|
|
bp::args("self", "model", "data"), \ |
77 |
|
|
"Create common data shared between force models.\n\n" \ |
78 |
|
|
":param model: force/impulse model\n" \ |
79 |
|
|
":param data: Pinocchio data")[bp::with_custodian_and_ward< \ |
80 |
|
|
1, 2, bp::with_custodian_and_ward<1, 3>>()]) \ |
81 |
|
|
.def(ForceDataAbstractVisitor<Data>()) \ |
82 |
|
|
.def(CopyableVisitor<Data>()); |
83 |
|
|
|
84 |
|
✗ |
void exposeForceAbstract() { |
85 |
|
✗ |
CROCODDYL_FORCE_DATA_ABSTRACT_PYTHON_BINDINGS(float) |
86 |
|
|
} |
87 |
|
|
|
88 |
|
|
} // namespace python |
89 |
|
|
} // namespace crocoddyl |
90 |
|
|
|