5#ifndef __pinocchio_python_joints_models_hpp__
6#define __pinocchio_python_joints_models_hpp__
8#include <boost/python.hpp>
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"
15#include <eigenpy/eigen-to-python.hpp>
21 namespace bp = boost::python;
25 bp::class_<T> & expose_joint_model(bp::class_<T> & cl)
32 bp::class_<context::JointModelRX> &
33 expose_joint_model<context::JointModelRX>(bp::class_<context::JointModelRX> & cl)
37 bp::args(
"self"),
"Init JointModelRX with the X axis ([1, 0, 0]) as rotation axis."))
39 "getMotionAxis", &context::JointModelRX::getMotionAxis,
40 "Rotation axis of the JointModelRX.");
44 bp::class_<context::JointModelRY> &
45 expose_joint_model<context::JointModelRY>(bp::class_<context::JointModelRY> & cl)
49 bp::args(
"self"),
"Init JointModelRY with the Y axis ([0, 1, 0]) as rotation axis."))
51 "getMotionAxis", &context::JointModelRY::getMotionAxis,
52 "Rotation axis of the JointModelRY.");
56 bp::class_<context::JointModelRZ> &
57 expose_joint_model<context::JointModelRZ>(bp::class_<context::JointModelRZ> & cl)
61 bp::args(
"self"),
"Init JointModelRZ with the Z axis ([0, 0, 1]) as rotation axis"))
63 "getMotionAxis", &context::JointModelRZ::getMotionAxis,
64 "Rotation axis of the JointModelRZ.");
69 bp::class_<context::JointModelRevoluteUnaligned> &
70 expose_joint_model<context::JointModelRevoluteUnaligned>(
71 bp::class_<context::JointModelRevoluteUnaligned> & cl)
74 .def(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"))
77 .def(bp::init<const context::Vector3s &>(
78 bp::args(
"self",
"axis"),
79 "Init JointModelRevoluteUnaligned from an axis with x-y-z components"))
81 "axis", &context::JointModelRevoluteUnaligned::axis,
82 "Rotation axis of the JointModelRevoluteUnaligned.");
87 bp::class_<context::JointModelRUBX> &
88 expose_joint_model<context::JointModelRUBX>(bp::class_<context::JointModelRUBX> & cl)
92 bp::args(
"self"),
"Init JointModelRUBX with the X axis ([1, 0, 0]) as rotation axis"))
94 "getMotionAxis", &context::JointModelRUBX::getMotionAxis,
95 "Rotation axis of the JointModelRUBX.");
99 bp::class_<context::JointModelRUBY> &
100 expose_joint_model<context::JointModelRUBY>(bp::class_<context::JointModelRUBY> & cl)
104 bp::args(
"self"),
"Init JointModelRUBY with the Y axis ([0, 1, 0]) as rotation axis"))
106 "getMotionAxis", &context::JointModelRUBY::getMotionAxis,
107 "Rotation axis of the JointModelRUBY.");
111 bp::class_<context::JointModelRUBZ> &
112 expose_joint_model<context::JointModelRUBZ>(bp::class_<context::JointModelRUBZ> & cl)
116 bp::args(
"self"),
"Init JointModelRUBZ with the Z axis ([0, 0, 1]) as rotation axis"))
118 "getMotionAxis", &context::JointModelRUBZ::getMotionAxis,
119 "Rotation axis of the JointModelRUBZ.");
124 bp::class_<context::JointModelPX> &
125 expose_joint_model<context::JointModelPX>(bp::class_<context::JointModelPX> & cl)
129 bp::args(
"self"),
"Init JointModelPX with the X axis ([1, 0, 0]) as rotation axis"))
131 "getMotionAxis", &context::JointModelPX::getMotionAxis,
132 "Rotation axis of the JointModelPX.");
136 bp::class_<context::JointModelPY> &
137 expose_joint_model<context::JointModelPY>(bp::class_<context::JointModelPY> & cl)
141 bp::args(
"self"),
"Init JointModelPY with the Y axis ([0, 1, 0]) as rotation axis"))
143 "getMotionAxis", &context::JointModelPY::getMotionAxis,
144 "Rotation axis of the JointModelPY.");
148 bp::class_<context::JointModelPZ> &
149 expose_joint_model<context::JointModelPZ>(bp::class_<context::JointModelPZ> & cl)
153 bp::args(
"self"),
"Init JointModelPZ with the Z axis ([0, 0, 1]) as rotation axis"))
155 "getMotionAxis", &context::JointModelPZ::getMotionAxis,
156 "Rotation axis of the JointModelPZ.");
161 bp::class_<context::JointModelPrismaticUnaligned> &
162 expose_joint_model<context::JointModelPrismaticUnaligned>(
163 bp::class_<context::JointModelPrismaticUnaligned> & cl)
166 .def(bp::init<context::Scalar, context::Scalar, context::Scalar>(
167 bp::args(
"self",
"x",
"y",
"z"),
168 "Init JointModelPrismaticUnaligned from the components x, y, z of the axis"))
169 .def(bp::init<const context::Vector3s &>(
170 bp::args(
"self",
"axis"),
171 "Init JointModelPrismaticUnaligned from an axis with x-y-z components"))
173 "axis", &context::JointModelPrismaticUnaligned::axis,
174 "Translation axis of the JointModelPrismaticUnaligned.");
179 bp::class_<context::JointModelHelicalUnaligned> &
180 expose_joint_model<context::JointModelHelicalUnaligned>(
181 bp::class_<context::JointModelHelicalUnaligned> & cl)
184 .def(bp::init<context::Scalar, context::Scalar, context::Scalar, context::Scalar>(
185 bp::args(
"self",
"x",
"y",
"z",
"pitch"),
186 "Init JointModelHelicalUnaligned from the components x, y, z of the axis and the pitch"))
187 .def(bp::init<const context::Vector3s &, context::Scalar>(
188 bp::args(
"self",
"axis",
"pitch"),
189 "Init JointModelHelicalUnaligned from an axis with x-y-z components and the pitch"))
191 "axis", &context::JointModelHelicalUnaligned::axis,
192 "Translation axis of the JointModelHelicalUnaligned.")
194 "pitch", &context::JointModelHelicalUnaligned::m_pitch,
195 "Pitch h of the JointModelHelicalUnaligned.");
200 bp::class_<context::JointModelHX> &
201 expose_joint_model<context::JointModelHX>(bp::class_<context::JointModelHX> & cl)
204 .def(bp::init<context::Scalar>(
205 bp::args(
"self",
"pitch"),
206 "Init JointModelHX with pitch value and the X axis ([1, 0, 0]) as a rotation axis."))
209 "Init JointModelHX with pitch 0.0 and the X axis ([1, 0, 0]) as a rotation axis."))
211 "getMotionAxis", &context::JointModelHX::getMotionAxis,
212 "Rotation axis of the JointModelHX.")
213 .def_readwrite(
"pitch", &context::JointModelHX::m_pitch,
"Pitch h of the JointModelHX.");
217 bp::class_<context::JointModelHY> &
218 expose_joint_model<context::JointModelHY>(bp::class_<context::JointModelHY> & cl)
221 .def(bp::init<context::Scalar>(
222 bp::args(
"self",
"pitch"),
223 "Init JointModelHY with pitch value and the Y axis ([0, 1, 0]) as a rotation axis."))
226 "Init JointModelHY with pitch 0.0 and the Y axis ([0, 1, 0]) as a rotation axis."))
228 "getMotionAxis", &context::JointModelHY::getMotionAxis,
229 "Rotation axis of the JointModelHY.")
230 .def_readwrite(
"pitch", &context::JointModelHY::m_pitch,
"Pitch h of the JointModelHY.");
234 bp::class_<context::JointModelHZ> &
235 expose_joint_model<context::JointModelHZ>(bp::class_<context::JointModelHZ> & cl)
238 .def(bp::init<context::Scalar>(
239 bp::args(
"self",
"pitch"),
240 "Init JointModelHZ with pitch value and the Z axis ([0, 0, 1]) as a rotation axis."))
243 "Init JointModelHZ with pitch 0.0 and the Z axis ([0, 0, 1]) as a rotation axis."))
245 "getMotionAxis", &context::JointModelHZ::getMotionAxis,
246 "Rotation axis of the JointModelHZ.")
247 .def_readwrite(
"pitch", &context::JointModelHZ::m_pitch,
"Pitch h of the JointModelHZ.");
252 bp::class_<context::JointModelUniversal> &
253 expose_joint_model<context::JointModelUniversal>(bp::class_<context::JointModelUniversal> & cl)
257 context::Scalar, context::Scalar, context::Scalar, context::Scalar, context::Scalar,
259 bp::args(
"self",
"x1",
"y1",
"z1",
"x2",
"y2",
"z2"),
260 "Init JointModelUniversal from the components x, y, z of the axes"))
261 .def(bp::init<const context::Vector3s &, const context::Vector3s &>(
262 bp::args(
"self",
"axis1",
"axis2"),
263 "Init JointModelUniversal from two axes with x-y-z components"))
265 "axis1", &context::JointModelUniversal::axis1,
266 "First rotation axis of the JointModelUniversal.")
268 "axis2", &context::JointModelUniversal::axis2,
269 "Second rotation axis of the JointModelUniversal.");
274 struct JointModelCompositeAddJointVisitor
275 :
public boost::static_visitor<context::JointModelComposite &>
277 context::JointModelComposite & m_joint_composite;
278 const context::SE3 & m_joint_placement;
280 JointModelCompositeAddJointVisitor(
281 context::JointModelComposite & joint_composite,
const context::SE3 & joint_placement)
282 : m_joint_composite(joint_composite)
283 , m_joint_placement(joint_placement)
287 template<
typename Jo
intModelDerived>
288 context::JointModelComposite & operator()(JointModelDerived & jmodel)
const
290 return m_joint_composite.addJoint(jmodel, m_joint_placement);
294 static context::JointModelComposite & addJoint_proxy(
295 context::JointModelComposite & joint_composite,
296 const context::JointModel & jmodel,
297 const context::SE3 & joint_placement = context::SE3::Identity())
299 return boost::apply_visitor(
300 JointModelCompositeAddJointVisitor(joint_composite, joint_placement), jmodel.toVariant());
303 struct JointModelCompositeConstructorVisitor
304 :
public boost::static_visitor<context::JointModelComposite *>
306 const context::SE3 & m_joint_placement;
308 JointModelCompositeConstructorVisitor(
const context::SE3 & joint_placement)
309 : m_joint_placement(joint_placement)
313 template<
typename Jo
intModelDerived>
314 context::JointModelComposite * operator()(JointModelDerived & jmodel)
const
316 return new context::JointModelComposite(jmodel, m_joint_placement);
320 static context::JointModelComposite * init_proxy1(
const context::JointModel & jmodel)
322 return boost::apply_visitor(
323 JointModelCompositeConstructorVisitor(context::SE3::Identity()), jmodel);
326 static context::JointModelComposite *
327 init_proxy2(
const context::JointModel & jmodel,
const context::SE3 & joint_placement)
329 return boost::apply_visitor(JointModelCompositeConstructorVisitor(joint_placement), jmodel);
333 bp::class_<context::JointModelComposite> &
334 expose_joint_model<context::JointModelComposite>(bp::class_<context::JointModelComposite> & cl)
337 .def(bp::init<const size_t>(
338 bp::args(
"self",
"size"),
"Init JointModelComposite with a defined size"))
341 bp::make_constructor(init_proxy1, bp::default_call_policies(), bp::args(
"joint_model")),
342 "Init JointModelComposite from a joint")
345 bp::make_constructor(
346 init_proxy2, bp::default_call_policies(), bp::args(
"joint_model",
"joint_placement")),
347 "Init JointModelComposite from a joint and a placement")
348 .add_property(
"joints", &context::JointModelComposite::joints)
349 .add_property(
"jointPlacements", &context::JointModelComposite::jointPlacements)
350 .add_property(
"njoints", &context::JointModelComposite::njoints)
352 "addJoint", &addJoint_proxy,
353 (bp::arg(
"self"), bp::arg(
"joint_model"),
354 bp::arg(
"joint_placement") = context::SE3::Identity()),
355 "Add a joint to the vector of joints.", bp::return_internal_reference<>())
357#ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS
358 .def(bp::self == bp::self)
359 .def(bp::self != bp::self)
365 struct JointModelMimicConstructorVisitor
366 :
public boost::static_visitor<context::JointModelMimic *>
368 const context::Scalar & m_scaling;
369 const context::Scalar & m_offset;
371 JointModelMimicConstructorVisitor(
372 const context::Scalar & scaling,
const context::Scalar & offset)
378 template<
typename Jo
intModelDerived>
379 context::JointModelMimic * operator()(
const JointModelDerived & jmodel)
const
382 return new context::JointModelMimic(jmodel, m_scaling, m_offset);
387 static context::JointModelMimic * init_proxy(
388 const context::JointModel & jmodel,
389 const context::Scalar & scaling,
390 const context::Scalar & offset)
392 return boost::apply_visitor(JointModelMimicConstructorVisitor(scaling, offset), jmodel);
395 static context::Scalar get_scaling(context::JointModelMimic & jmodel)
397 return jmodel.scaling();
400 static context::Scalar get_offset(context::JointModelMimic & jmodel)
402 return jmodel.offset();
406 bp::class_<context::JointModelMimic> &
407 expose_joint_model<context::JointModelMimic>(bp::class_<context::JointModelMimic> & cl)
412 bp::make_constructor(
413 init_proxy, bp::default_call_policies(), bp::args(
"joint_model",
"scaling",
"offset")),
414 "Init JointModelMimic from an existing joint with scaling and offset.")
415 .add_property(
"scaling", &get_scaling)
416 .add_property(
"offset", &get_offset);
Main pinocchio namespace.