7#include <boost/python.hpp> 9#include "pinocchio/multibody/joint.hpp" 11#include <eigenpy/eigen-to-python.hpp> 17 namespace bp = boost::python;
21 bp::class_<T> & expose_joint_model(bp::class_<T> & cl)
28 bp::class_<context::JointModelRX> &
29 expose_joint_model<context::JointModelRX>(bp::class_<context::JointModelRX> & cl)
34 bp::args(
"self"),
"Init JointModelRX with the X axis ([1, 0, 0]) as rotation axis."))
36 "getMotionAxis", &context::JointModelRX::getMotionAxis,
37 "Rotation axis of the JointModelRX.");
41 bp::class_<context::JointModelRY> &
42 expose_joint_model<context::JointModelRY>(bp::class_<context::JointModelRY> & cl)
47 bp::args(
"self"),
"Init JointModelRY with the Y axis ([0, 1, 0]) as rotation axis."))
49 "getMotionAxis", &context::JointModelRY::getMotionAxis,
50 "Rotation axis of the JointModelRY.");
54 bp::class_<context::JointModelRZ> &
55 expose_joint_model<context::JointModelRZ>(bp::class_<context::JointModelRZ> & cl)
60 bp::args(
"self"),
"Init JointModelRZ with the Z axis ([0, 0, 1]) as rotation axis"))
62 "getMotionAxis", &context::JointModelRZ::getMotionAxis,
63 "Rotation axis of the JointModelRZ.");
68 bp::class_<context::JointModelRevoluteUnaligned> &
69 expose_joint_model<context::JointModelRevoluteUnaligned>(
70 bp::class_<context::JointModelRevoluteUnaligned> & cl)
74 bp::init<context::Scalar, context::Scalar, context::Scalar>(
75 bp::args(
"self",
"x",
"y",
"z"),
76 "Init JointModelRevoluteUnaligned from the components x, y, z of the axis"))
78 bp::init<const context::Vector3s &>(
79 bp::args(
"self",
"axis"),
80 "Init JointModelRevoluteUnaligned from an axis with x-y-z components"))
82 "axis", &context::JointModelRevoluteUnaligned::axis,
83 "Rotation axis of the JointModelRevoluteUnaligned.");
88 bp::class_<context::JointModelRUBX> &
89 expose_joint_model<context::JointModelRUBX>(bp::class_<context::JointModelRUBX> & cl)
94 bp::args(
"self"),
"Init JointModelRUBX with the X axis ([1, 0, 0]) as rotation axis"))
96 "getMotionAxis", &context::JointModelRUBX::getMotionAxis,
97 "Rotation axis of the JointModelRUBX.");
101 bp::class_<context::JointModelRUBY> &
102 expose_joint_model<context::JointModelRUBY>(bp::class_<context::JointModelRUBY> & cl)
107 bp::args(
"self"),
"Init JointModelRUBY with the Y axis ([0, 1, 0]) as rotation axis"))
109 "getMotionAxis", &context::JointModelRUBY::getMotionAxis,
110 "Rotation axis of the JointModelRUBY.");
114 bp::class_<context::JointModelRUBZ> &
115 expose_joint_model<context::JointModelRUBZ>(bp::class_<context::JointModelRUBZ> & cl)
120 bp::args(
"self"),
"Init JointModelRUBZ with the Z axis ([0, 0, 1]) as rotation axis"))
122 "getMotionAxis", &context::JointModelRUBZ::getMotionAxis,
123 "Rotation axis of the JointModelRUBZ.");
128 bp::class_<context::JointModelPX> &
129 expose_joint_model<context::JointModelPX>(bp::class_<context::JointModelPX> & cl)
134 bp::args(
"self"),
"Init JointModelPX with the X axis ([1, 0, 0]) as rotation axis"))
136 "getMotionAxis", &context::JointModelPX::getMotionAxis,
137 "Rotation axis of the JointModelPX.");
141 bp::class_<context::JointModelPY> &
142 expose_joint_model<context::JointModelPY>(bp::class_<context::JointModelPY> & cl)
147 bp::args(
"self"),
"Init JointModelPY with the Y axis ([0, 1, 0]) as rotation axis"))
149 "getMotionAxis", &context::JointModelPY::getMotionAxis,
150 "Rotation axis of the JointModelPY.");
154 bp::class_<context::JointModelPZ> &
155 expose_joint_model<context::JointModelPZ>(bp::class_<context::JointModelPZ> & cl)
160 bp::args(
"self"),
"Init JointModelPZ with the Z axis ([0, 0, 1]) as rotation axis"))
162 "getMotionAxis", &context::JointModelPZ::getMotionAxis,
163 "Rotation axis of the JointModelPZ.");
168 bp::class_<context::JointModelPrismaticUnaligned> &
169 expose_joint_model<context::JointModelPrismaticUnaligned>(
170 bp::class_<context::JointModelPrismaticUnaligned> & cl)
174 bp::init<context::Scalar, context::Scalar, context::Scalar>(
175 bp::args(
"self",
"x",
"y",
"z"),
176 "Init JointModelPrismaticUnaligned from the components x, y, z of the axis"))
178 bp::init<const context::Vector3s &>(
179 bp::args(
"self",
"axis"),
180 "Init JointModelPrismaticUnaligned from an axis with x-y-z components"))
182 "axis", &context::JointModelPrismaticUnaligned::axis,
183 "Translation axis of the JointModelPrismaticUnaligned.");
188 bp::class_<context::JointModelHelicalUnaligned> &
189 expose_joint_model<context::JointModelHelicalUnaligned>(
190 bp::class_<context::JointModelHelicalUnaligned> & cl)
194 bp::init<context::Scalar, context::Scalar, context::Scalar, context::Scalar>(
195 bp::args(
"self",
"x",
"y",
"z",
"pitch"),
196 "Init JointModelHelicalUnaligned from the components x, y, z of the axis and the " 199 bp::init<const context::Vector3s &, context::Scalar>(
200 bp::args(
"self",
"axis",
"pitch"),
201 "Init JointModelHelicalUnaligned from an axis with x-y-z components and the pitch"))
203 "axis", &context::JointModelHelicalUnaligned::axis,
204 "Translation axis of the JointModelHelicalUnaligned.")
206 "pitch", &context::JointModelHelicalUnaligned::m_pitch,
207 "Pitch h of the JointModelHelicalUnaligned.");
212 bp::class_<context::JointModelHX> &
213 expose_joint_model<context::JointModelHX>(bp::class_<context::JointModelHX> & cl)
217 bp::init<context::Scalar>(
218 bp::args(
"self",
"pitch"),
219 "Init JointModelHX with pitch value and the X axis ([1, 0, 0]) as a rotation axis."))
223 "Init JointModelHX with pitch 0.0 and the X axis ([1, 0, 0]) as a rotation axis."))
225 "getMotionAxis", &context::JointModelHX::getMotionAxis,
226 "Rotation axis of the JointModelHX.")
227 .def_readwrite(
"pitch", &context::JointModelHX::m_pitch,
"Pitch h of the JointModelHX.");
231 bp::class_<context::JointModelHY> &
232 expose_joint_model<context::JointModelHY>(bp::class_<context::JointModelHY> & cl)
236 bp::init<context::Scalar>(
237 bp::args(
"self",
"pitch"),
238 "Init JointModelHY with pitch value and the Y axis ([0, 1, 0]) as a rotation axis."))
242 "Init JointModelHY with pitch 0.0 and the Y axis ([0, 1, 0]) as a rotation axis."))
244 "getMotionAxis", &context::JointModelHY::getMotionAxis,
245 "Rotation axis of the JointModelHY.")
246 .def_readwrite(
"pitch", &context::JointModelHY::m_pitch,
"Pitch h of the JointModelHY.");
250 bp::class_<context::JointModelHZ> &
251 expose_joint_model<context::JointModelHZ>(bp::class_<context::JointModelHZ> & cl)
255 bp::init<context::Scalar>(
256 bp::args(
"self",
"pitch"),
257 "Init JointModelHZ with pitch value and the Z axis ([0, 0, 1]) as a rotation axis."))
261 "Init JointModelHZ with pitch 0.0 and the Z axis ([0, 0, 1]) as a rotation axis."))
263 "getMotionAxis", &context::JointModelHZ::getMotionAxis,
264 "Rotation axis of the JointModelHZ.")
265 .def_readwrite(
"pitch", &context::JointModelHZ::m_pitch,
"Pitch h of the JointModelHZ.");
270 bp::class_<context::JointModelEllipsoid> &
271 expose_joint_model<context::JointModelEllipsoid>(bp::class_<context::JointModelEllipsoid> & cl)
275 bp::init<context::Scalar, context::Scalar, context::Scalar>(
276 bp::args(
"self",
"radius_x",
"radius_y",
"radius_z"),
277 "Init JointModelEllipsoid with radii along x, y, z axes."))
278 .def(bp::init<>(bp::args(
"self"),
"Init JointModelEllipsoid with default radii equal to 0"))
280 "radius_x", &context::JointModelEllipsoid::radius_x,
281 "Radius of the JointModelEllipsoid along X axis.")
283 "radius_y", &context::JointModelEllipsoid::radius_y,
284 "Radius of the JointModelEllipsoid along Y axis.")
286 "radius_z", &context::JointModelEllipsoid::radius_z,
287 "Radius of the JointModelEllipsoid along Z axis.");
292 bp::class_<context::JointModelUniversal> &
293 expose_joint_model<context::JointModelUniversal>(bp::class_<context::JointModelUniversal> & cl)
298 context::Scalar, context::Scalar, context::Scalar, context::Scalar, context::Scalar,
300 bp::args(
"self",
"x1",
"y1",
"z1",
"x2",
"y2",
"z2"),
301 "Init JointModelUniversal from the components x, y, z of the axes"))
303 bp::init<const context::Vector3s &, const context::Vector3s &>(
304 bp::args(
"self",
"axis1",
"axis2"),
305 "Init JointModelUniversal from two axes with x-y-z components"))
307 "axis1", &context::JointModelUniversal::axis1,
308 "First rotation axis of the JointModelUniversal.")
310 "axis2", &context::JointModelUniversal::axis2,
311 "Second rotation axis of the JointModelUniversal.");
316 struct JointModelCompositeAddJointVisitor
317 :
public boost::static_visitor<context::JointModelComposite &>
319 context::JointModelComposite & m_joint_composite;
320 const context::SE3 & m_joint_placement;
321 const std::string & m_name;
323 JointModelCompositeAddJointVisitor(
324 context::JointModelComposite & joint_composite,
325 const context::SE3 & joint_placement,
326 const std::string & name)
327 : m_joint_composite(joint_composite)
328 , m_joint_placement(joint_placement)
333 template<
typename Jo
intModelDerived>
334 context::JointModelComposite & operator()(JointModelDerived & jmodel)
const 336 return m_joint_composite.addJoint(jmodel, m_joint_placement, m_name);
340 static context::JointModelComposite & addJoint_proxy(
341 context::JointModelComposite & joint_composite,
342 const context::JointModel & jmodel,
343 const context::SE3 & joint_placement = context::SE3::Identity(),
344 const std::string & name =
"")
346 return boost::apply_visitor(
351 struct JointModelCompositeConstructorVisitor
352 :
public boost::static_visitor<context::JointModelComposite *>
354 const context::SE3 & m_joint_placement;
355 const std::string & m_name;
357 JointModelCompositeConstructorVisitor(
358 const context::SE3 & joint_placement,
const std::string & name)
359 : m_joint_placement(joint_placement)
364 template<
typename Jo
intModelDerived>
365 context::JointModelComposite * operator()(JointModelDerived & jmodel)
const 367 return new context::JointModelComposite(jmodel, m_joint_placement, m_name);
371 static context::JointModelComposite * init_proxy1(
const context::JointModel & jmodel)
373 return boost::apply_visitor(
377 static context::JointModelComposite *
378 init_proxy2(
const context::JointModel & jmodel,
const context::SE3 & joint_placement)
380 return boost::apply_visitor(
381 JointModelCompositeConstructorVisitor(joint_placement,
"joint_1"), jmodel);
384 static context::JointModelComposite * init_proxy3(
385 const context::JointModel & jmodel,
386 const context::SE3 & joint_placement,
387 const std::string & name)
389 return boost::apply_visitor(
390 JointModelCompositeConstructorVisitor(joint_placement, name), jmodel);
394 bp::class_<context::JointModelComposite> &
395 expose_joint_model<context::JointModelComposite>(bp::class_<context::JointModelComposite> & cl)
399 bp::init<const size_t>(
400 bp::args(
"self",
"size"),
"Init JointModelComposite with a defined size"))
403 bp::make_constructor(init_proxy1, bp::default_call_policies(), bp::args(
"joint_model")),
404 "Init JointModelComposite from a joint")
407 bp::make_constructor(
408 init_proxy2, bp::default_call_policies(), bp::args(
"joint_model",
"joint_placement")),
409 "Init JointModelComposite from a joint and a placement")
412 bp::make_constructor(
413 init_proxy3, bp::default_call_policies(),
414 bp::args(
"joint_model",
"joint_placement",
"name")),
415 "Init JointModelComposite from a joint, a placement and a name")
416 .add_property(
"joints", &context::JointModelComposite::joints)
417 .add_property(
"jointPlacements", &context::JointModelComposite::jointPlacements)
418 .add_property(
"njoints", &context::JointModelComposite::njoints)
420 "addJoint", &addJoint_proxy,
421 (bp::arg(
"self"), bp::arg(
"joint_model"),
422 bp::arg(
"joint_placement") = context::SE3::Identity(), bp::arg(
"name") =
"joint_1"),
423 "Add a joint to the vector of joints.", bp::return_internal_reference<>())
425 "getJointId", &context::JointModelComposite::getJointId, bp::args(
"joint_name"),
426 "Find the index of a joint inside a joint composite based on its name.")
428#ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS 429 .def(bp::self == bp::self)
430 .def(bp::self != bp::self)
436 struct JointModelMimicConstructorVisitor
437 :
public boost::static_visitor<context::JointModelMimic *>
439 const context::Scalar & m_scaling;
440 const context::Scalar & m_offset;
442 JointModelMimicConstructorVisitor(
443 const context::Scalar & scaling,
const context::Scalar & offset)
449 template<
typename Jo
intModelDerived>
450 context::JointModelMimic * operator()(
const JointModelDerived & jmodel)
const 453 return new context::JointModelMimic(jmodel, m_scaling, m_offset);
458 static context::JointModelMimic * init_proxy(
459 const context::JointModel & jmodel,
460 const context::Scalar & scaling,
461 const context::Scalar & offset)
466 static context::Scalar get_scaling(context::JointModelMimic & jmodel)
468 return jmodel.scaling();
471 static context::Scalar get_offset(context::JointModelMimic & jmodel)
473 return jmodel.offset();
477 bp::class_<context::JointModelMimic> &
478 expose_joint_model<context::JointModelMimic>(bp::class_<context::JointModelMimic> & cl)
483 bp::make_constructor(
484 init_proxy, bp::default_call_policies(), bp::args(
"joint_model",
"scaling",
"offset")),
485 "Init JointModelMimic from an existing joint with scaling and offset.")
486 .add_property(
"scaling", &get_scaling)
487 .add_property(
"offset", &get_offset);
Main pinocchio namespace.