Directory: | ./ |
---|---|
File: | bindings/python/crocoddyl/multibody/data/multibody.cpp |
Date: | 2025-03-26 19:23:43 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 9 | 9 | 100.0% |
Branches: | 43 | 86 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | ||
2 | // BSD 3-Clause License | ||
3 | // | ||
4 | // Copyright (C) 2019-2025, University of Edinburgh, Heriot-Watt University | ||
5 | // Copyright note valid unless otherwise stated in individual files. | ||
6 | // All rights reserved. | ||
7 | /////////////////////////////////////////////////////////////////////////////// | ||
8 | |||
9 | #include "python/crocoddyl/multibody/multibody.hpp" | ||
10 | |||
11 | #include "crocoddyl/multibody/data/multibody.hpp" | ||
12 | |||
13 | namespace crocoddyl { | ||
14 | namespace python { | ||
15 | |||
16 | template <typename Data> | ||
17 | struct DataCollectorMultibodyVisitor | ||
18 | : public bp::def_visitor<DataCollectorMultibodyVisitor<Data>> { | ||
19 | template <class PyClass> | ||
20 | 40 | void visit(PyClass& cl) const { | |
21 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | cl.add_property( |
22 | "pinocchio", | ||
23 | 40 | bp::make_getter(&Data::pinocchio, bp::return_internal_reference<>()), | |
24 | "pinocchio data"); | ||
25 | 40 | } | |
26 | }; | ||
27 | |||
28 | #define CROCODDYL_DATA_COLLECTOR_MULTIBODY_PYTHON_BINDINGS(Scalar) \ | ||
29 | typedef DataCollectorMultibodyTpl<Scalar> Data; \ | ||
30 | typedef DataCollectorAbstractTpl<Scalar> DataBase; \ | ||
31 | typedef pinocchio::DataTpl<Scalar> PinocchioData; \ | ||
32 | bp::register_ptr_to_python<std::shared_ptr<Data>>(); \ | ||
33 | bp::class_<Data, bp::bases<DataBase>>( \ | ||
34 | "DataCollectorMultibody", "Data collector for multibody systems.\n\n", \ | ||
35 | bp::init<PinocchioData*>( \ | ||
36 | bp::args("self", "pinocchio"), \ | ||
37 | "Create multibody data collection.\n\n" \ | ||
38 | ":param data: Pinocchio data")[bp::with_custodian_and_ward<1, 2>()]) \ | ||
39 | .def(DataCollectorMultibodyVisitor<Data>()) \ | ||
40 | .def(CopyableVisitor<Data>()); | ||
41 | |||
42 | #define CROCODDYL_DATA_COLLECTOR_ACTMULTIBODY_PYTHON_BINDINGS(Scalar) \ | ||
43 | typedef DataCollectorActMultibodyTpl<Scalar> Data; \ | ||
44 | typedef DataCollectorMultibodyTpl<Scalar> DataBase1; \ | ||
45 | typedef DataCollectorActuationTpl<Scalar> DataBase2; \ | ||
46 | typedef pinocchio::DataTpl<Scalar> PinocchioData; \ | ||
47 | typedef ActuationDataAbstractTpl<Scalar> ActuationData; \ | ||
48 | bp::register_ptr_to_python<std::shared_ptr<Data>>(); \ | ||
49 | bp::class_<Data, bp::bases<DataBase1, DataBase2>>( \ | ||
50 | "DataCollectorActMultibody", \ | ||
51 | "Data collector for actuated multibody systems.\n\n", \ | ||
52 | bp::init<PinocchioData*, std::shared_ptr<ActuationData>>( \ | ||
53 | bp::args("self", "pinocchio", "actuation"), \ | ||
54 | "Create multibody data collection.\n\n" \ | ||
55 | ":param pinocchio: Pinocchio data\n" \ | ||
56 | ":param actuation: actuation data") \ | ||
57 | [bp::with_custodian_and_ward<1, 2>()]) \ | ||
58 | .def(CopyableVisitor<Data>()); | ||
59 | |||
60 | #define CROCODDYL_DATA_COLLECTOR_JOINT_ACTMULTIBODY_PYTHON_BINDINGS(Scalar) \ | ||
61 | typedef DataCollectorJointActMultibodyTpl<Scalar> Data; \ | ||
62 | typedef DataCollectorActMultibodyTpl<Scalar> DataBase1; \ | ||
63 | typedef DataCollectorJointTpl<Scalar> DataBase2; \ | ||
64 | typedef pinocchio::DataTpl<Scalar> PinocchioData; \ | ||
65 | typedef ActuationDataAbstractTpl<Scalar> ActuationData; \ | ||
66 | typedef JointDataAbstractTpl<Scalar> JointData; \ | ||
67 | bp::register_ptr_to_python<std::shared_ptr<Data>>(); \ | ||
68 | bp::class_<Data, bp::bases<DataBase1, DataBase2>>( \ | ||
69 | "DataCollectorJointActMultibody", \ | ||
70 | "Data collector for actuated-joint multibody systems.\n\n", \ | ||
71 | bp::init<PinocchioData*, std::shared_ptr<ActuationData>, \ | ||
72 | std::shared_ptr<JointData>>( \ | ||
73 | bp::args("self", "pinocchio", "actuation", "joint"), \ | ||
74 | "Create multibody data collection.\n\n" \ | ||
75 | ":param pinocchio: Pinocchio data\n" \ | ||
76 | ":param actuation: actuation data\n" \ | ||
77 | ":param joint: joint data")[bp::with_custodian_and_ward<1, 2>()]) \ | ||
78 | .def(CopyableVisitor<Data>()); | ||
79 | |||
80 | 10 | void exposeDataCollectorMultibody() { | |
81 |
15/30✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 10 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 10 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 10 times.
✗ Branch 16 not taken.
✓ Branch 21 taken 10 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 10 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 10 times.
✗ Branch 28 not taken.
✓ Branch 32 taken 10 times.
✗ Branch 33 not taken.
✓ Branch 35 taken 10 times.
✗ Branch 36 not taken.
✓ Branch 38 taken 10 times.
✗ Branch 39 not taken.
✓ Branch 41 taken 10 times.
✗ Branch 42 not taken.
✓ Branch 44 taken 10 times.
✗ Branch 45 not taken.
✓ Branch 47 taken 10 times.
✗ Branch 48 not taken.
✓ Branch 50 taken 10 times.
✗ Branch 51 not taken.
|
20 | CROCODDYL_PYTHON_SCALARS(CROCODDYL_DATA_COLLECTOR_MULTIBODY_PYTHON_BINDINGS) |
82 |
13/26✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 10 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 10 times.
✗ Branch 13 not taken.
✓ Branch 18 taken 10 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 10 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 10 times.
✗ Branch 25 not taken.
✓ Branch 29 taken 10 times.
✗ Branch 30 not taken.
✓ Branch 32 taken 10 times.
✗ Branch 33 not taken.
✓ Branch 35 taken 10 times.
✗ Branch 36 not taken.
✓ Branch 38 taken 10 times.
✗ Branch 39 not taken.
✓ Branch 41 taken 10 times.
✗ Branch 42 not taken.
✓ Branch 44 taken 10 times.
✗ Branch 45 not taken.
|
20 | CROCODDYL_PYTHON_SCALARS( |
83 | CROCODDYL_DATA_COLLECTOR_ACTMULTIBODY_PYTHON_BINDINGS) | ||
84 |
13/26✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 10 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 10 times.
✗ Branch 13 not taken.
✓ Branch 18 taken 10 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 10 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 10 times.
✗ Branch 25 not taken.
✓ Branch 29 taken 10 times.
✗ Branch 30 not taken.
✓ Branch 32 taken 10 times.
✗ Branch 33 not taken.
✓ Branch 35 taken 10 times.
✗ Branch 36 not taken.
✓ Branch 38 taken 10 times.
✗ Branch 39 not taken.
✓ Branch 41 taken 10 times.
✗ Branch 42 not taken.
✓ Branch 44 taken 10 times.
✗ Branch 45 not taken.
|
20 | CROCODDYL_PYTHON_SCALARS( |
85 | CROCODDYL_DATA_COLLECTOR_JOINT_ACTMULTIBODY_PYTHON_BINDINGS) | ||
86 | 10 | } | |
87 | |||
88 | } // namespace python | ||
89 | } // namespace crocoddyl | ||
90 |