Directory: | ./ |
---|---|
File: | include/pinocchio/bindings/python/multibody/joint/joint-data.hpp |
Date: | 2025-02-12 21:03:38 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 10 | 15 | 66.7% |
Branches: | 7 | 18 | 38.9% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // Copyright (c) 2020 INRIA | ||
3 | // | ||
4 | |||
5 | #ifndef __pinocchio_python_multibody_joint_joint_data_hpp__ | ||
6 | #define __pinocchio_python_multibody_joint_joint_data_hpp__ | ||
7 | |||
8 | #include "pinocchio/multibody/joint/joint-generic.hpp" | ||
9 | #include "pinocchio/bindings/python/multibody/joint/joint-derived.hpp" | ||
10 | #include "pinocchio/bindings/python/utils/printable.hpp" | ||
11 | |||
12 | namespace pinocchio | ||
13 | { | ||
14 | namespace python | ||
15 | { | ||
16 | namespace bp = boost::python; | ||
17 | |||
18 | template<typename JointData> | ||
19 | struct ExtractJointDataVariantTypeVisitor | ||
20 | { | ||
21 | typedef typename JointData::JointCollection JointCollection; | ||
22 | typedef bp::object result_type; | ||
23 | |||
24 | template<typename JointDataDerived> | ||
25 | ✗ | result_type operator()(const JointDataBase<JointDataDerived> & jdata) const | |
26 | { | ||
27 | ✗ | bp::object obj(boost::ref(jdata.derived())); | |
28 | ✗ | return obj; | |
29 | } | ||
30 | |||
31 | ✗ | static result_type extract(const JointData & jdata) | |
32 | { | ||
33 | ✗ | return boost::apply_visitor(ExtractJointDataVariantTypeVisitor(), jdata); | |
34 | } | ||
35 | }; | ||
36 | |||
37 | template<typename JointData> | ||
38 | struct JointDataPythonVisitor | ||
39 | { | ||
40 | |||
41 | 69 | static void expose() | |
42 | { | ||
43 | 69 | bp::class_<JointData>("JointData", "Generic Joint Data", bp::no_init) | |
44 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def( |
45 |
2/4✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
|
138 | bp::init<const typename JointData::JointDataVariant &>(bp::args("self", "joint_data"))) |
46 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def(JointDataBasePythonVisitor<JointData>()) |
47 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def(PrintableVisitor<JointData>()) |
48 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | .def( |
49 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
138 | "extract", ExtractJointDataVariantTypeVisitor<JointData>::extract, bp::arg("self"), |
50 | "Returns a reference of the internal joint managed by the JointData", | ||
51 | 69 | bp::with_custodian_and_ward_postcall<0, 1>()); | |
52 | 69 | } | |
53 | }; | ||
54 | |||
55 | } // namespace python | ||
56 | } // namespace pinocchio | ||
57 | |||
58 | #endif // ifndef __pinocchio_python_multibody_joint_joint_data_hpp__ | ||
59 |