Directory: | ./ |
---|---|
File: | bindings/python/crocoddyl/multibody/data/impulses.cpp |
Date: | 2025-03-26 19:23:43 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 8 | 8 | 100.0% |
Branches: | 28 | 56 | 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 "crocoddyl/multibody/data/impulses.hpp" | ||
10 | |||
11 | #include "python/crocoddyl/multibody/multibody.hpp" | ||
12 | |||
13 | namespace crocoddyl { | ||
14 | namespace python { | ||
15 | |||
16 | template <typename Data> | ||
17 | struct DataCollectorImpulseVisitor | ||
18 | : public bp::def_visitor<DataCollectorImpulseVisitor<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 | "impulses", | ||
23 | bp::make_getter(&Data::impulses, | ||
24 | 40 | bp::return_value_policy<bp::return_by_value>()), | |
25 | "impulses data"); | ||
26 | 40 | } | |
27 | }; | ||
28 | |||
29 | #define CROCODDYL_DATA_COLLECTOR_IMPULSE_PYTHON_BINDINGS(Scalar) \ | ||
30 | typedef DataCollectorImpulseTpl<Scalar> Data; \ | ||
31 | typedef DataCollectorAbstractTpl<Scalar> DataBase; \ | ||
32 | typedef ImpulseDataMultipleTpl<Scalar> ImpulseData; \ | ||
33 | bp::register_ptr_to_python<std::shared_ptr<Data>>(); \ | ||
34 | bp::class_<Data, bp::bases<DataBase>>( \ | ||
35 | "DataCollectorImpulse", "Impulse data collector.\n\n", \ | ||
36 | bp::init<std::shared_ptr<ImpulseData>>( \ | ||
37 | bp::args("self", "impulses"), \ | ||
38 | "Create impulse data collection.\n\n" \ | ||
39 | ":param impulses: impulses data")) \ | ||
40 | .def(DataCollectorImpulseVisitor<Data>()) \ | ||
41 | .def(CopyableVisitor<Data>()); | ||
42 | |||
43 | #define CROCODDYL_DATA_COLLECTOR_MULTIBODY_IMPULSE_PYTHON_BINDINGS(Scalar) \ | ||
44 | typedef DataCollectorMultibodyInImpulseTpl<Scalar> Data; \ | ||
45 | typedef DataCollectorMultibodyTpl<Scalar> DataBase1; \ | ||
46 | typedef DataCollectorImpulseTpl<Scalar> DataBase2; \ | ||
47 | typedef pinocchio::DataTpl<Scalar> PinocchioData; \ | ||
48 | typedef ImpulseDataMultipleTpl<Scalar> ImpulseData; \ | ||
49 | bp::register_ptr_to_python<std::shared_ptr<Data>>(); \ | ||
50 | bp::class_<Data, bp::bases<DataBase1, DataBase2>>( \ | ||
51 | "DataCollectorMultibodyInImpulse", \ | ||
52 | "Data collector for multibody systems in impulse.\n\n", \ | ||
53 | bp::init<PinocchioData*, std::shared_ptr<ImpulseData>>( \ | ||
54 | bp::args("self", "pinocchio", "impulses"), \ | ||
55 | "Create multibody data collection.\n\n" \ | ||
56 | ":param pinocchio: Pinocchio data\n" \ | ||
57 | ":param impulses: impulses data")[bp::with_custodian_and_ward<1, \ | ||
58 | 2>()]) \ | ||
59 | .def(CopyableVisitor<Data>()); | ||
60 | |||
61 | 10 | void exposeDataCollectorImpulses() { | |
62 |
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(CROCODDYL_DATA_COLLECTOR_IMPULSE_PYTHON_BINDINGS) |
63 |
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( |
64 | CROCODDYL_DATA_COLLECTOR_MULTIBODY_IMPULSE_PYTHON_BINDINGS) | ||
65 | 10 | } | |
66 | |||
67 | } // namespace python | ||
68 | } // namespace crocoddyl | ||
69 |