| Directory: | ./ |
|---|---|
| File: | include/pinocchio/bindings/python/multibody/joint/joints-models.hpp |
| Date: | 2025-04-30 16:14:33 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 146 | 157 | 93.0% |
| Branches: | 103 | 210 | 49.0% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2015-2022 CNRS INRIA | ||
| 3 | // | ||
| 4 | |||
| 5 | #ifndef __pinocchio_python_joints_models_hpp__ | ||
| 6 | #define __pinocchio_python_joints_models_hpp__ | ||
| 7 | |||
| 8 | #include <boost/python.hpp> | ||
| 9 | |||
| 10 | #include "pinocchio/multibody/joint/joint-collection.hpp" | ||
| 11 | #include "pinocchio/multibody/joint/joint-composite.hpp" | ||
| 12 | #include "pinocchio/multibody/joint/joint-generic.hpp" | ||
| 13 | #include "pinocchio/multibody/joint/joint-mimic.hpp" | ||
| 14 | |||
| 15 | #include <eigenpy/eigen-to-python.hpp> | ||
| 16 | |||
| 17 | namespace pinocchio | ||
| 18 | { | ||
| 19 | namespace python | ||
| 20 | { | ||
| 21 | namespace bp = boost::python; | ||
| 22 | |||
| 23 | // generic expose_joint_model : do nothing special | ||
| 24 | template<class T> | ||
| 25 | 864 | bp::class_<T> & expose_joint_model(bp::class_<T> & cl) | |
| 26 | { | ||
| 27 | 864 | return cl; | |
| 28 | } | ||
| 29 | |||
| 30 | // specialization for JointModelRevolute | ||
| 31 | template<> | ||
| 32 | bp::class_<context::JointModelRX> & | ||
| 33 | 72 | expose_joint_model<context::JointModelRX>(bp::class_<context::JointModelRX> & cl) | |
| 34 | { | ||
| 35 | return cl | ||
| 36 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init<>( |
| 37 | 144 | bp::args("self"), "Init JointModelRX with the X axis ([1, 0, 0]) as rotation axis.")) | |
| 38 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | .def( |
| 39 | "getMotionAxis", &context::JointModelRX::getMotionAxis, | ||
| 40 | 144 | "Rotation axis of the JointModelRX."); | |
| 41 | } | ||
| 42 | |||
| 43 | template<> | ||
| 44 | bp::class_<context::JointModelRY> & | ||
| 45 | 72 | expose_joint_model<context::JointModelRY>(bp::class_<context::JointModelRY> & cl) | |
| 46 | { | ||
| 47 | return cl | ||
| 48 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init<>( |
| 49 | 144 | bp::args("self"), "Init JointModelRY with the Y axis ([0, 1, 0]) as rotation axis.")) | |
| 50 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | .def( |
| 51 | "getMotionAxis", &context::JointModelRY::getMotionAxis, | ||
| 52 | 144 | "Rotation axis of the JointModelRY."); | |
| 53 | } | ||
| 54 | |||
| 55 | template<> | ||
| 56 | bp::class_<context::JointModelRZ> & | ||
| 57 | 72 | expose_joint_model<context::JointModelRZ>(bp::class_<context::JointModelRZ> & cl) | |
| 58 | { | ||
| 59 | return cl | ||
| 60 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init<>( |
| 61 | 144 | bp::args("self"), "Init JointModelRZ with the Z axis ([0, 0, 1]) as rotation axis")) | |
| 62 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | .def( |
| 63 | "getMotionAxis", &context::JointModelRZ::getMotionAxis, | ||
| 64 | 144 | "Rotation axis of the JointModelRZ."); | |
| 65 | } | ||
| 66 | |||
| 67 | // specialization for JointModelRevoluteUnaligned | ||
| 68 | template<> | ||
| 69 | bp::class_<context::JointModelRevoluteUnaligned> & | ||
| 70 | 72 | expose_joint_model<context::JointModelRevoluteUnaligned>( | |
| 71 | bp::class_<context::JointModelRevoluteUnaligned> & cl) | ||
| 72 | { | ||
| 73 | return cl | ||
| 74 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init<context::Scalar, context::Scalar, context::Scalar>( |
| 75 | 144 | bp::args("self", "x", "y", "z"), | |
| 76 | "Init JointModelRevoluteUnaligned from the components x, y, z of the axis")) | ||
| 77 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init<const context::Vector3s &>( |
| 78 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
144 | bp::args("self", "axis"), |
| 79 | "Init JointModelRevoluteUnaligned from an axis with x-y-z components")) | ||
| 80 | 144 | .def_readwrite( | |
| 81 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
144 | "axis", &context::JointModelRevoluteUnaligned::axis, |
| 82 | 144 | "Rotation axis of the JointModelRevoluteUnaligned."); | |
| 83 | } | ||
| 84 | |||
| 85 | // specialization for JointModelRevoluteUnbounded | ||
| 86 | template<> | ||
| 87 | bp::class_<context::JointModelRUBX> & | ||
| 88 | 72 | expose_joint_model<context::JointModelRUBX>(bp::class_<context::JointModelRUBX> & cl) | |
| 89 | { | ||
| 90 | return cl | ||
| 91 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init<>( |
| 92 | 144 | bp::args("self"), "Init JointModelRUBX with the X axis ([1, 0, 0]) as rotation axis")) | |
| 93 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | .def( |
| 94 | "getMotionAxis", &context::JointModelRUBX::getMotionAxis, | ||
| 95 | 144 | "Rotation axis of the JointModelRUBX."); | |
| 96 | } | ||
| 97 | |||
| 98 | template<> | ||
| 99 | bp::class_<context::JointModelRUBY> & | ||
| 100 | 72 | expose_joint_model<context::JointModelRUBY>(bp::class_<context::JointModelRUBY> & cl) | |
| 101 | { | ||
| 102 | return cl | ||
| 103 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init<>( |
| 104 | 144 | bp::args("self"), "Init JointModelRUBY with the Y axis ([0, 1, 0]) as rotation axis")) | |
| 105 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | .def( |
| 106 | "getMotionAxis", &context::JointModelRUBY::getMotionAxis, | ||
| 107 | 144 | "Rotation axis of the JointModelRUBY."); | |
| 108 | } | ||
| 109 | |||
| 110 | template<> | ||
| 111 | bp::class_<context::JointModelRUBZ> & | ||
| 112 | 72 | expose_joint_model<context::JointModelRUBZ>(bp::class_<context::JointModelRUBZ> & cl) | |
| 113 | { | ||
| 114 | return cl | ||
| 115 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init<>( |
| 116 | 144 | bp::args("self"), "Init JointModelRUBZ with the Z axis ([0, 0, 1]) as rotation axis")) | |
| 117 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | .def( |
| 118 | "getMotionAxis", &context::JointModelRUBZ::getMotionAxis, | ||
| 119 | 144 | "Rotation axis of the JointModelRUBZ."); | |
| 120 | } | ||
| 121 | |||
| 122 | // specialization for JointModelPrismatic | ||
| 123 | template<> | ||
| 124 | bp::class_<context::JointModelPX> & | ||
| 125 | 72 | expose_joint_model<context::JointModelPX>(bp::class_<context::JointModelPX> & cl) | |
| 126 | { | ||
| 127 | return cl | ||
| 128 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init<>( |
| 129 | 144 | bp::args("self"), "Init JointModelPX with the X axis ([1, 0, 0]) as rotation axis")) | |
| 130 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | .def( |
| 131 | "getMotionAxis", &context::JointModelPX::getMotionAxis, | ||
| 132 | 144 | "Rotation axis of the JointModelPX."); | |
| 133 | } | ||
| 134 | |||
| 135 | template<> | ||
| 136 | bp::class_<context::JointModelPY> & | ||
| 137 | 72 | expose_joint_model<context::JointModelPY>(bp::class_<context::JointModelPY> & cl) | |
| 138 | { | ||
| 139 | return cl | ||
| 140 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init<>( |
| 141 | 144 | bp::args("self"), "Init JointModelPY with the Y axis ([0, 1, 0]) as rotation axis")) | |
| 142 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | .def( |
| 143 | "getMotionAxis", &context::JointModelPY::getMotionAxis, | ||
| 144 | 144 | "Rotation axis of the JointModelPY."); | |
| 145 | } | ||
| 146 | |||
| 147 | template<> | ||
| 148 | bp::class_<context::JointModelPZ> & | ||
| 149 | 72 | expose_joint_model<context::JointModelPZ>(bp::class_<context::JointModelPZ> & cl) | |
| 150 | { | ||
| 151 | return cl | ||
| 152 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init<>( |
| 153 | 144 | bp::args("self"), "Init JointModelPZ with the Z axis ([0, 0, 1]) as rotation axis")) | |
| 154 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | .def( |
| 155 | "getMotionAxis", &context::JointModelPZ::getMotionAxis, | ||
| 156 | 144 | "Rotation axis of the JointModelPZ."); | |
| 157 | } | ||
| 158 | |||
| 159 | // specialization for JointModelPrismaticUnaligned | ||
| 160 | template<> | ||
| 161 | bp::class_<context::JointModelPrismaticUnaligned> & | ||
| 162 | 72 | expose_joint_model<context::JointModelPrismaticUnaligned>( | |
| 163 | bp::class_<context::JointModelPrismaticUnaligned> & cl) | ||
| 164 | { | ||
| 165 | return cl | ||
| 166 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init<context::Scalar, context::Scalar, context::Scalar>( |
| 167 | 144 | bp::args("self", "x", "y", "z"), | |
| 168 | "Init JointModelPrismaticUnaligned from the components x, y, z of the axis")) | ||
| 169 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init<const context::Vector3s &>( |
| 170 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
144 | bp::args("self", "axis"), |
| 171 | "Init JointModelPrismaticUnaligned from an axis with x-y-z components")) | ||
| 172 | 144 | .def_readwrite( | |
| 173 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
144 | "axis", &context::JointModelPrismaticUnaligned::axis, |
| 174 | 144 | "Translation axis of the JointModelPrismaticUnaligned."); | |
| 175 | } | ||
| 176 | |||
| 177 | // specialization for JointModelHelicalUnaligned | ||
| 178 | template<> | ||
| 179 | bp::class_<context::JointModelHelicalUnaligned> & | ||
| 180 | 72 | expose_joint_model<context::JointModelHelicalUnaligned>( | |
| 181 | bp::class_<context::JointModelHelicalUnaligned> & cl) | ||
| 182 | { | ||
| 183 | return cl | ||
| 184 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init<context::Scalar, context::Scalar, context::Scalar, context::Scalar>( |
| 185 | 144 | bp::args("self", "x", "y", "z", "pitch"), | |
| 186 | "Init JointModelHelicalUnaligned from the components x, y, z of the axis and the pitch")) | ||
| 187 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init<const context::Vector3s &, context::Scalar>( |
| 188 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
144 | bp::args("self", "axis", "pitch"), |
| 189 | "Init JointModelHelicalUnaligned from an axis with x-y-z components and the pitch")) | ||
| 190 | 144 | .def_readwrite( | |
| 191 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | "axis", &context::JointModelHelicalUnaligned::axis, |
| 192 | "Translation axis of the JointModelHelicalUnaligned.") | ||
| 193 | 144 | .def_readwrite( | |
| 194 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
144 | "pitch", &context::JointModelHelicalUnaligned::m_pitch, |
| 195 | 144 | "Pitch h of the JointModelHelicalUnaligned."); | |
| 196 | } | ||
| 197 | |||
| 198 | // specialization for JointModelHelical | ||
| 199 | template<> | ||
| 200 | bp::class_<context::JointModelHX> & | ||
| 201 | 72 | expose_joint_model<context::JointModelHX>(bp::class_<context::JointModelHX> & cl) | |
| 202 | { | ||
| 203 | return cl | ||
| 204 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init<context::Scalar>( |
| 205 | 144 | bp::args("self", "pitch"), | |
| 206 | "Init JointModelHX with pitch value and the X axis ([1, 0, 0]) as a rotation axis.")) | ||
| 207 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init<>( |
| 208 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
144 | bp::args("self"), |
| 209 | "Init JointModelHX with pitch 0.0 and the X axis ([1, 0, 0]) as a rotation axis.")) | ||
| 210 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | .def( |
| 211 | "getMotionAxis", &context::JointModelHX::getMotionAxis, | ||
| 212 | "Rotation axis of the JointModelHX.") | ||
| 213 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
144 | .def_readwrite("pitch", &context::JointModelHX::m_pitch, "Pitch h of the JointModelHX."); |
| 214 | } | ||
| 215 | |||
| 216 | template<> | ||
| 217 | bp::class_<context::JointModelHY> & | ||
| 218 | 72 | expose_joint_model<context::JointModelHY>(bp::class_<context::JointModelHY> & cl) | |
| 219 | { | ||
| 220 | return cl | ||
| 221 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init<context::Scalar>( |
| 222 | 144 | bp::args("self", "pitch"), | |
| 223 | "Init JointModelHY with pitch value and the Y axis ([0, 1, 0]) as a rotation axis.")) | ||
| 224 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init<>( |
| 225 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
144 | bp::args("self"), |
| 226 | "Init JointModelHY with pitch 0.0 and the Y axis ([0, 1, 0]) as a rotation axis.")) | ||
| 227 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | .def( |
| 228 | "getMotionAxis", &context::JointModelHY::getMotionAxis, | ||
| 229 | "Rotation axis of the JointModelHY.") | ||
| 230 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
144 | .def_readwrite("pitch", &context::JointModelHY::m_pitch, "Pitch h of the JointModelHY."); |
| 231 | } | ||
| 232 | |||
| 233 | template<> | ||
| 234 | bp::class_<context::JointModelHZ> & | ||
| 235 | 72 | expose_joint_model<context::JointModelHZ>(bp::class_<context::JointModelHZ> & cl) | |
| 236 | { | ||
| 237 | return cl | ||
| 238 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init<context::Scalar>( |
| 239 | 144 | bp::args("self", "pitch"), | |
| 240 | "Init JointModelHZ with pitch value and the Z axis ([0, 0, 1]) as a rotation axis.")) | ||
| 241 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init<>( |
| 242 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
144 | bp::args("self"), |
| 243 | "Init JointModelHZ with pitch 0.0 and the Z axis ([0, 0, 1]) as a rotation axis.")) | ||
| 244 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | .def( |
| 245 | "getMotionAxis", &context::JointModelHZ::getMotionAxis, | ||
| 246 | "Rotation axis of the JointModelHZ.") | ||
| 247 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
144 | .def_readwrite("pitch", &context::JointModelHZ::m_pitch, "Pitch h of the JointModelHZ."); |
| 248 | } | ||
| 249 | |||
| 250 | // specialization for JointModelUniversal | ||
| 251 | template<> | ||
| 252 | bp::class_<context::JointModelUniversal> & | ||
| 253 | 72 | expose_joint_model<context::JointModelUniversal>(bp::class_<context::JointModelUniversal> & cl) | |
| 254 | { | ||
| 255 | return cl | ||
| 256 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init< |
| 257 | context::Scalar, context::Scalar, context::Scalar, context::Scalar, context::Scalar, | ||
| 258 | context::Scalar>( | ||
| 259 | 144 | bp::args("self", "x1", "y1", "z1", "x2", "y2", "z2"), | |
| 260 | "Init JointModelUniversal from the components x, y, z of the axes")) | ||
| 261 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init<const context::Vector3s &, const context::Vector3s &>( |
| 262 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
144 | bp::args("self", "axis1", "axis2"), |
| 263 | "Init JointModelUniversal from two axes with x-y-z components")) | ||
| 264 | 144 | .def_readwrite( | |
| 265 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | "axis1", &context::JointModelUniversal::axis1, |
| 266 | "First rotation axis of the JointModelUniversal.") | ||
| 267 | 144 | .def_readwrite( | |
| 268 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
144 | "axis2", &context::JointModelUniversal::axis2, |
| 269 | 144 | "Second rotation axis of the JointModelUniversal."); | |
| 270 | } | ||
| 271 | |||
| 272 | // specialization for JointModelComposite | ||
| 273 | |||
| 274 | struct JointModelCompositeAddJointVisitor | ||
| 275 | : public boost::static_visitor<context::JointModelComposite &> | ||
| 276 | { | ||
| 277 | context::JointModelComposite & m_joint_composite; | ||
| 278 | const context::SE3 & m_joint_placement; | ||
| 279 | |||
| 280 | 8 | JointModelCompositeAddJointVisitor( | |
| 281 | context::JointModelComposite & joint_composite, const context::SE3 & joint_placement) | ||
| 282 | 8 | : m_joint_composite(joint_composite) | |
| 283 | 8 | , m_joint_placement(joint_placement) | |
| 284 | { | ||
| 285 | 8 | } | |
| 286 | |||
| 287 | template<typename JointModelDerived> | ||
| 288 | 16 | context::JointModelComposite & operator()(JointModelDerived & jmodel) const | |
| 289 | { | ||
| 290 | 16 | return m_joint_composite.addJoint(jmodel, m_joint_placement); | |
| 291 | } | ||
| 292 | }; // struct JointModelCompositeAddJointVisitor | ||
| 293 | |||
| 294 | 8 | static context::JointModelComposite & addJoint_proxy( | |
| 295 | context::JointModelComposite & joint_composite, | ||
| 296 | const context::JointModel & jmodel, | ||
| 297 | const context::SE3 & joint_placement = context::SE3::Identity()) | ||
| 298 | { | ||
| 299 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | return boost::apply_visitor( |
| 300 | 16 | JointModelCompositeAddJointVisitor(joint_composite, joint_placement), jmodel.toVariant()); | |
| 301 | } | ||
| 302 | |||
| 303 | struct JointModelCompositeConstructorVisitor | ||
| 304 | : public boost::static_visitor<context::JointModelComposite *> | ||
| 305 | { | ||
| 306 | const context::SE3 & m_joint_placement; | ||
| 307 | |||
| 308 | 3 | JointModelCompositeConstructorVisitor(const context::SE3 & joint_placement) | |
| 309 | 3 | : m_joint_placement(joint_placement) | |
| 310 | { | ||
| 311 | 3 | } | |
| 312 | |||
| 313 | template<typename JointModelDerived> | ||
| 314 | 6 | context::JointModelComposite * operator()(JointModelDerived & jmodel) const | |
| 315 | { | ||
| 316 |
1/2✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
|
6 | return new context::JointModelComposite(jmodel, m_joint_placement); |
| 317 | } | ||
| 318 | }; // struct JointModelCompositeConstructorVisitor | ||
| 319 | |||
| 320 | 2 | static context::JointModelComposite * init_proxy1(const context::JointModel & jmodel) | |
| 321 | { | ||
| 322 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | return boost::apply_visitor( |
| 323 | 4 | JointModelCompositeConstructorVisitor(context::SE3::Identity()), jmodel); | |
| 324 | } | ||
| 325 | |||
| 326 | static context::JointModelComposite * | ||
| 327 | 1 | init_proxy2(const context::JointModel & jmodel, const context::SE3 & joint_placement) | |
| 328 | { | ||
| 329 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | return boost::apply_visitor(JointModelCompositeConstructorVisitor(joint_placement), jmodel); |
| 330 | } | ||
| 331 | |||
| 332 | template<> | ||
| 333 | bp::class_<context::JointModelComposite> & | ||
| 334 | 72 | expose_joint_model<context::JointModelComposite>(bp::class_<context::JointModelComposite> & cl) | |
| 335 | { | ||
| 336 | return cl | ||
| 337 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | .def(bp::init<const size_t>( |
| 338 | 144 | bp::args("self", "size"), "Init JointModelComposite with a defined size")) | |
| 339 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | .def( |
| 340 | "__init__", | ||
| 341 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
144 | bp::make_constructor(init_proxy1, bp::default_call_policies(), bp::args("joint_model")), |
| 342 | "Init JointModelComposite from a joint") | ||
| 343 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | .def( |
| 344 | "__init__", | ||
| 345 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | bp::make_constructor( |
| 346 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
144 | init_proxy2, bp::default_call_policies(), bp::args("joint_model", "joint_placement")), |
| 347 | "Init JointModelComposite from a joint and a placement") | ||
| 348 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | .add_property("joints", &context::JointModelComposite::joints) |
| 349 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | .add_property("jointPlacements", &context::JointModelComposite::jointPlacements) |
| 350 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | .add_property("njoints", &context::JointModelComposite::njoints) |
| 351 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | .def( |
| 352 | "addJoint", &addJoint_proxy, | ||
| 353 |
3/6✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 72 times.
✗ Branch 8 not taken.
|
148 | (bp::arg("self"), bp::arg("joint_model"), |
| 354 |
4/8✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 72 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 72 times.
✗ Branch 11 not taken.
|
144 | bp::arg("joint_placement") = context::SE3::Identity()), |
| 355 | 80 | "Add a joint to the vector of joints.", bp::return_internal_reference<>()) | |
| 356 | |||
| 357 | #ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS | ||
| 358 |
1/2✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
|
68 | .def(bp::self == bp::self) |
| 359 |
1/2✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
|
136 | .def(bp::self != bp::self) |
| 360 | #endif | ||
| 361 | ; | ||
| 362 | } | ||
| 363 | |||
| 364 | // Specialization for JointModelMimic | ||
| 365 | struct JointModelMimicConstructorVisitor | ||
| 366 | : public boost::static_visitor<context::JointModelMimic *> | ||
| 367 | { | ||
| 368 | const context::Scalar & m_scaling; | ||
| 369 | const context::Scalar & m_offset; | ||
| 370 | |||
| 371 | ✗ | JointModelMimicConstructorVisitor( | |
| 372 | const context::Scalar & scaling, const context::Scalar & offset) | ||
| 373 | ✗ | : m_scaling(scaling) | |
| 374 | ✗ | , m_offset(offset) | |
| 375 | { | ||
| 376 | } | ||
| 377 | |||
| 378 | template<typename JointModelDerived> | ||
| 379 | ✗ | context::JointModelMimic * operator()(const JointModelDerived & jmodel) const | |
| 380 | { | ||
| 381 | |||
| 382 | ✗ | return new context::JointModelMimic(jmodel, m_scaling, m_offset); | |
| 383 | } | ||
| 384 | |||
| 385 | }; // struct JointModelMimicConstructorVisitor | ||
| 386 | |||
| 387 | ✗ | static context::JointModelMimic * init_proxy( | |
| 388 | const context::JointModel & jmodel, | ||
| 389 | const context::Scalar & scaling, | ||
| 390 | const context::Scalar & offset) | ||
| 391 | { | ||
| 392 | ✗ | return boost::apply_visitor(JointModelMimicConstructorVisitor(scaling, offset), jmodel); | |
| 393 | } | ||
| 394 | |||
| 395 | ✗ | static context::Scalar get_scaling(context::JointModelMimic & jmodel) | |
| 396 | { | ||
| 397 | ✗ | return jmodel.scaling(); | |
| 398 | } | ||
| 399 | |||
| 400 | ✗ | static context::Scalar get_offset(context::JointModelMimic & jmodel) | |
| 401 | { | ||
| 402 | ✗ | return jmodel.offset(); | |
| 403 | } | ||
| 404 | |||
| 405 | template<> | ||
| 406 | bp::class_<context::JointModelMimic> & | ||
| 407 | 72 | expose_joint_model<context::JointModelMimic>(bp::class_<context::JointModelMimic> & cl) | |
| 408 | { | ||
| 409 | return cl | ||
| 410 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | .def( |
| 411 | "__init__", | ||
| 412 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
144 | bp::make_constructor( |
| 413 | 144 | init_proxy, bp::default_call_policies(), bp::args("joint_model", "scaling", "offset")), | |
| 414 | "Init JointModelMimic from an existing joint with scaling and offset.") | ||
| 415 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | .add_property("scaling", &get_scaling) |
| 416 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
144 | .add_property("offset", &get_offset); |
| 417 | } | ||
| 418 | |||
| 419 | } // namespace python | ||
| 420 | } // namespace pinocchio | ||
| 421 | |||
| 422 | #endif // ifndef __pinocchio_python_joint_models_hpp__ | ||
| 423 |