joints-models.hpp
Go to the documentation of this file.
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 
13 
15 
16 namespace pinocchio
17 {
18  namespace python
19  {
20  namespace bp = boost::python;
21 
22  // generic expose_joint_model : do nothing special
23  template<class T>
24  bp::class_<T> & expose_joint_model(bp::class_<T> & cl)
25  {
26  return cl;
27  }
28 
29  // specialization for JointModelRevolute
30  template<>
31  bp::class_<context::JointModelRX> &
32  expose_joint_model<context::JointModelRX>(bp::class_<context::JointModelRX> & cl)
33  {
34  return cl
35  .def(bp::init<>(
36  bp::args("self"), "Init JointModelRX with the X axis ([1, 0, 0]) as rotation axis."))
37  .def(
38  "getMotionAxis", &context::JointModelRX::getMotionAxis,
39  "Rotation axis of the JointModelRX.");
40  }
41 
42  template<>
43  bp::class_<context::JointModelRY> &
44  expose_joint_model<context::JointModelRY>(bp::class_<context::JointModelRY> & cl)
45  {
46  return cl
47  .def(bp::init<>(
48  bp::args("self"), "Init JointModelRY with the Y axis ([0, 1, 0]) as rotation axis."))
49  .def(
50  "getMotionAxis", &context::JointModelRY::getMotionAxis,
51  "Rotation axis of the JointModelRY.");
52  }
53 
54  template<>
55  bp::class_<context::JointModelRZ> &
56  expose_joint_model<context::JointModelRZ>(bp::class_<context::JointModelRZ> & cl)
57  {
58  return cl
59  .def(bp::init<>(
60  bp::args("self"), "Init JointModelRZ with the Z axis ([0, 0, 1]) as rotation axis"))
61  .def(
62  "getMotionAxis", &context::JointModelRZ::getMotionAxis,
63  "Rotation axis of the JointModelRZ.");
64  }
65 
66  // specialization for JointModelRevoluteUnaligned
67  template<>
68  bp::class_<context::JointModelRevoluteUnaligned> &
69  expose_joint_model<context::JointModelRevoluteUnaligned>(
70  bp::class_<context::JointModelRevoluteUnaligned> & cl)
71  {
72  return cl
73  .def(bp::init<context::Scalar, context::Scalar, context::Scalar>(
74  bp::args("self", "x", "y", "z"),
75  "Init JointModelRevoluteUnaligned from the components x, y, z of the axis"))
76  .def(bp::init<const context::Vector3s &>(
77  bp::args("self", "axis"),
78  "Init JointModelRevoluteUnaligned from an axis with x-y-z components"))
79  .def_readwrite(
81  "Rotation axis of the JointModelRevoluteUnaligned.");
82  }
83 
84  // specialization for JointModelRevoluteUnbounded
85  template<>
86  bp::class_<context::JointModelRUBX> &
87  expose_joint_model<context::JointModelRUBX>(bp::class_<context::JointModelRUBX> & cl)
88  {
89  return cl
90  .def(bp::init<>(
91  bp::args("self"), "Init JointModelRUBX with the X axis ([1, 0, 0]) as rotation axis"))
92  .def(
94  "Rotation axis of the JointModelRUBX.");
95  }
96 
97  template<>
98  bp::class_<context::JointModelRUBY> &
99  expose_joint_model<context::JointModelRUBY>(bp::class_<context::JointModelRUBY> & cl)
100  {
101  return cl
102  .def(bp::init<>(
103  bp::args("self"), "Init JointModelRUBY with the Y axis ([0, 1, 0]) as rotation axis"))
104  .def(
105  "getMotionAxis", &context::JointModelRUBY::getMotionAxis,
106  "Rotation axis of the JointModelRUBY.");
107  }
108 
109  template<>
110  bp::class_<context::JointModelRUBZ> &
111  expose_joint_model<context::JointModelRUBZ>(bp::class_<context::JointModelRUBZ> & cl)
112  {
113  return cl
114  .def(bp::init<>(
115  bp::args("self"), "Init JointModelRUBZ with the Z axis ([0, 0, 1]) as rotation axis"))
116  .def(
117  "getMotionAxis", &context::JointModelRUBZ::getMotionAxis,
118  "Rotation axis of the JointModelRUBZ.");
119  }
120 
121  // specialization for JointModelPrismatic
122  template<>
123  bp::class_<context::JointModelPX> &
124  expose_joint_model<context::JointModelPX>(bp::class_<context::JointModelPX> & cl)
125  {
126  return cl
127  .def(bp::init<>(
128  bp::args("self"), "Init JointModelPX with the X axis ([1, 0, 0]) as rotation axis"))
129  .def(
130  "getMotionAxis", &context::JointModelPX::getMotionAxis,
131  "Rotation axis of the JointModelPX.");
132  }
133 
134  template<>
135  bp::class_<context::JointModelPY> &
136  expose_joint_model<context::JointModelPY>(bp::class_<context::JointModelPY> & cl)
137  {
138  return cl
139  .def(bp::init<>(
140  bp::args("self"), "Init JointModelPY with the Y axis ([0, 1, 0]) as rotation axis"))
141  .def(
142  "getMotionAxis", &context::JointModelPY::getMotionAxis,
143  "Rotation axis of the JointModelPY.");
144  }
145 
146  template<>
147  bp::class_<context::JointModelPZ> &
148  expose_joint_model<context::JointModelPZ>(bp::class_<context::JointModelPZ> & cl)
149  {
150  return cl
151  .def(bp::init<>(
152  bp::args("self"), "Init JointModelPZ with the Z axis ([0, 0, 1]) as rotation axis"))
153  .def(
154  "getMotionAxis", &context::JointModelPZ::getMotionAxis,
155  "Rotation axis of the JointModelPZ.");
156  }
157 
158  // specialization for JointModelPrismaticUnaligned
159  template<>
160  bp::class_<context::JointModelPrismaticUnaligned> &
161  expose_joint_model<context::JointModelPrismaticUnaligned>(
162  bp::class_<context::JointModelPrismaticUnaligned> & cl)
163  {
164  return cl
165  .def(bp::init<context::Scalar, context::Scalar, context::Scalar>(
166  bp::args("self", "x", "y", "z"),
167  "Init JointModelPrismaticUnaligned from the components x, y, z of the axis"))
168  .def(bp::init<const context::Vector3s &>(
169  bp::args("self", "axis"),
170  "Init JointModelPrismaticUnaligned from an axis with x-y-z components"))
171  .def_readwrite(
173  "Translation axis of the JointModelPrismaticUnaligned.");
174  }
175 
176  // specialization for JointModelHelicalUnaligned
177  template<>
178  bp::class_<context::JointModelHelicalUnaligned> &
179  expose_joint_model<context::JointModelHelicalUnaligned>(
180  bp::class_<context::JointModelHelicalUnaligned> & cl)
181  {
182  return cl
183  .def(bp::init<context::Scalar, context::Scalar, context::Scalar, context::Scalar>(
184  bp::args("self", "x", "y", "z", "pitch"),
185  "Init JointModelHelicalUnaligned from the components x, y, z of the axis and the pitch"))
186  .def(bp::init<const context::Vector3s &, context::Scalar>(
187  bp::args("self", "axis", "pitch"),
188  "Init JointModelHelicalUnaligned from an axis with x-y-z components and the pitch"))
189  .def_readwrite(
191  "Translation axis of the JointModelHelicalUnaligned.")
192  .def_readwrite(
194  "Pitch h of the JointModelHelicalUnaligned.");
195  }
196 
197  // specialization for JointModelHelical
198  template<>
199  bp::class_<context::JointModelHX> &
200  expose_joint_model<context::JointModelHX>(bp::class_<context::JointModelHX> & cl)
201  {
202  return cl
203  .def(bp::init<context::Scalar>(
204  bp::args("self", "pitch"),
205  "Init JointModelHX with pitch value and the X axis ([1, 0, 0]) as a rotation axis."))
206  .def(bp::init<>(
207  bp::args("self"),
208  "Init JointModelHX with pitch 0.0 and the X axis ([1, 0, 0]) as a rotation axis."))
209  .def(
210  "getMotionAxis", &context::JointModelHX::getMotionAxis,
211  "Rotation axis of the JointModelHX.")
212  .def_readwrite("pitch", &context::JointModelHX::m_pitch, "Pitch h of the JointModelHX.");
213  }
214 
215  template<>
216  bp::class_<context::JointModelHY> &
217  expose_joint_model<context::JointModelHY>(bp::class_<context::JointModelHY> & cl)
218  {
219  return cl
220  .def(bp::init<context::Scalar>(
221  bp::args("self", "pitch"),
222  "Init JointModelHY with pitch value and the Y axis ([0, 1, 0]) as a rotation axis."))
223  .def(bp::init<>(
224  bp::args("self"),
225  "Init JointModelHY with pitch 0.0 and the Y axis ([0, 1, 0]) as a rotation axis."))
226  .def(
227  "getMotionAxis", &context::JointModelHY::getMotionAxis,
228  "Rotation axis of the JointModelHY.")
229  .def_readwrite("pitch", &context::JointModelHY::m_pitch, "Pitch h of the JointModelHY.");
230  }
231 
232  template<>
233  bp::class_<context::JointModelHZ> &
234  expose_joint_model<context::JointModelHZ>(bp::class_<context::JointModelHZ> & cl)
235  {
236  return cl
237  .def(bp::init<context::Scalar>(
238  bp::args("self", "pitch"),
239  "Init JointModelHZ with pitch value and the Z axis ([0, 0, 1]) as a rotation axis."))
240  .def(bp::init<>(
241  bp::args("self"),
242  "Init JointModelHZ with pitch 0.0 and the Z axis ([0, 0, 1]) as a rotation axis."))
243  .def(
244  "getMotionAxis", &context::JointModelHZ::getMotionAxis,
245  "Rotation axis of the JointModelHZ.")
246  .def_readwrite("pitch", &context::JointModelHZ::m_pitch, "Pitch h of the JointModelHZ.");
247  }
248 
249  // specialization for JointModelUniversal
250  template<>
251  bp::class_<context::JointModelUniversal> &
252  expose_joint_model<context::JointModelUniversal>(bp::class_<context::JointModelUniversal> & cl)
253  {
254  return cl
255  .def(bp::init<
258  bp::args("self", "x1", "y1", "z1", "x2", "y2", "z2"),
259  "Init JointModelUniversal from the components x, y, z of the axes"))
260  .def(bp::init<const context::Vector3s &, const context::Vector3s &>(
261  bp::args("self", "axis1", "axis2"),
262  "Init JointModelUniversal from two axes with x-y-z components"))
263  .def_readwrite(
265  "First rotation axis of the JointModelUniversal.")
266  .def_readwrite(
268  "Second rotation axis of the JointModelUniversal.");
269  }
270 
271  // specialization for JointModelComposite
272 
274  : public boost::static_visitor<context::JointModelComposite &>
275  {
278 
280  context::JointModelComposite & joint_composite, const context::SE3 & joint_placement)
281  : m_joint_composite(joint_composite)
283  {
284  }
285 
286  template<typename JointModelDerived>
287  context::JointModelComposite & operator()(JointModelDerived & jmodel) const
288  {
290  }
291  }; // struct JointModelCompositeAddJointVisitor
292 
294  context::JointModelComposite & joint_composite,
295  const context::JointModel & jmodel,
297  {
298  return boost::apply_visitor(
299  JointModelCompositeAddJointVisitor(joint_composite, joint_placement), jmodel.toVariant());
300  }
301 
303  : public boost::static_visitor<context::JointModelComposite *>
304  {
306 
309  {
310  }
311 
312  template<typename JointModelDerived>
313  context::JointModelComposite * operator()(JointModelDerived & jmodel) const
314  {
316  }
317  }; // struct JointModelCompositeConstructorVisitor
318 
320  {
321  return boost::apply_visitor(
323  }
324 
327  {
328  return boost::apply_visitor(JointModelCompositeConstructorVisitor(joint_placement), jmodel);
329  }
330 
331  template<>
332  bp::class_<context::JointModelComposite> &
333  expose_joint_model<context::JointModelComposite>(bp::class_<context::JointModelComposite> & cl)
334  {
335  return cl
336  .def(bp::init<const size_t>(
337  bp::args("self", "size"), "Init JointModelComposite with a defined size"))
338  .def(
339  "__init__",
340  bp::make_constructor(init_proxy1, bp::default_call_policies(), bp::args("joint_model")),
341  "Init JointModelComposite from a joint")
342  .def(
343  "__init__",
344  bp::make_constructor(
345  init_proxy2, bp::default_call_policies(), bp::args("joint_model", "joint_placement")),
346  "Init JointModelComposite from a joint and a placement")
347  .add_property("joints", &context::JointModelComposite::joints)
348  .add_property("jointPlacements", &context::JointModelComposite::jointPlacements)
349  .add_property("njoints", &context::JointModelComposite::njoints)
350  .def(
351  "addJoint", &addJoint_proxy,
352  (bp::arg("self"), bp::arg("joint_model"),
353  bp::arg("joint_placement") = context::SE3::Identity()),
354  "Add a joint to the vector of joints.", bp::return_internal_reference<>())
355 
356 #ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS
357  .def(bp::self == bp::self)
358  .def(bp::self != bp::self)
359 #endif
360 
361  ;
362  }
363  } // namespace python
364 } // namespace pinocchio
365 
366 #endif // ifndef __pinocchio_python_joint_models_hpp__
init
void init(bool compute_local_aabb=true)
boost::python
pinocchio::python::expose_joint_model
bp::class_< T > & expose_joint_model(bp::class_< T > &cl)
Definition: joints-models.hpp:24
pinocchio::python::JointModelCompositeAddJointVisitor::JointModelCompositeAddJointVisitor
JointModelCompositeAddJointVisitor(context::JointModelComposite &joint_composite, const context::SE3 &joint_placement)
Definition: joints-models.hpp:279
pinocchio::JointModelRevoluteUnboundedTpl::getMotionAxis
Vector3 getMotionAxis() const
Definition: joint-revolute-unbounded.hpp:205
pinocchio::JointModelUniversalTpl::axis2
Vector3 axis2
Definition: joint-universal.hpp:610
pinocchio::python::JointModelCompositeAddJointVisitor::operator()
context::JointModelComposite & operator()(JointModelDerived &jmodel) const
Definition: joints-models.hpp:287
pinocchio::python::JointModelCompositeAddJointVisitor::m_joint_composite
context::JointModelComposite & m_joint_composite
Definition: joints-models.hpp:276
pinocchio::SE3Tpl< Scalar, Options >
pinocchio::python::JointModelCompositeAddJointVisitor
Definition: joints-models.hpp:273
pinocchio::JointModelPrismaticTpl::getMotionAxis
Vector3 getMotionAxis() const
Definition: joint-prismatic.hpp:747
eigen-to-python.hpp
pinocchio::python::JointModelCompositeAddJointVisitor::m_joint_placement
const context::SE3 & m_joint_placement
Definition: joints-models.hpp:277
pinocchio::JointModelTpl::toVariant
JointModelVariant & toVariant()
Definition: joint-generic.hpp:307
pinocchio::JointModelHelicalTpl::getMotionAxis
Vector3 getMotionAxis() const
Definition: joint-helical.hpp:928
pinocchio::JointModelHelicalUnalignedTpl::axis
Vector3 axis
Definition: joint-helical-unaligned.hpp:765
pinocchio::JointModelRevoluteTpl::getMotionAxis
Vector3 getMotionAxis() const
Definition: joint-revolute.hpp:843
pinocchio::JointModelCompositeTpl::addJoint
JointModelDerived & addJoint(const JointModelBase< JointModel > &jmodel, const SE3 &placement=SE3::Identity())
Add a joint to the vector of joints.
Definition: joint-composite.hpp:278
joint-composite.hpp
joint-collection.hpp
pinocchio::JointModelCompositeTpl::joints
JointModelVector joints
Vector of joints contained in the joint composite.
Definition: joint-composite.hpp:446
pinocchio::python::init_proxy2
static context::JointModelComposite * init_proxy2(const context::JointModel &jmodel, const context::SE3 &joint_placement)
Definition: joints-models.hpp:326
joint-generic.hpp
python
pinocchio::python::JointModelCompositeConstructorVisitor::operator()
context::JointModelComposite * operator()(JointModelDerived &jmodel) const
Definition: joints-models.hpp:313
pinocchio::JointModelTpl
Definition: multibody/joint/fwd.hpp:155
pinocchio::python::init_proxy1
static context::JointModelComposite * init_proxy1(const context::JointModel &jmodel)
Definition: joints-models.hpp:319
pinocchio::JointModelCompositeTpl::njoints
int njoints
Number of joints contained in the JointModelComposite.
Definition: joint-composite.hpp:575
pinocchio::python::JointModelCompositeConstructorVisitor::m_joint_placement
const context::SE3 & m_joint_placement
Definition: joints-models.hpp:305
pinocchio::python::context::JointModelComposite
JointModelCompositeTpl< Scalar > JointModelComposite
Definition: bindings/python/context/generic.hpp:138
pinocchio::python::JointModelCompositeConstructorVisitor
Definition: joints-models.hpp:302
pinocchio::JointModelCompositeTpl
Definition: multibody/joint/fwd.hpp:141
append-urdf-model-with-another-model.joint_placement
joint_placement
Definition: append-urdf-model-with-another-model.py:29
pinocchio::JointModelHelicalUnalignedTpl::m_pitch
Scalar m_pitch
Definition: joint-helical-unaligned.hpp:766
pinocchio::python::JointModelCompositeConstructorVisitor::JointModelCompositeConstructorVisitor
JointModelCompositeConstructorVisitor(const context::SE3 &joint_placement)
Definition: joints-models.hpp:307
pinocchio::JointModelHelicalTpl::m_pitch
Scalar m_pitch
Definition: joint-helical.hpp:954
pinocchio::SE3Tpl< Scalar, Options >::Identity
static SE3Tpl Identity()
Definition: spatial/se3-tpl.hpp:136
cl
cl
pinocchio::JointModelPrismaticUnalignedTpl::axis
Vector3 axis
3d main axis of the joint.
Definition: joint-prismatic-unaligned.hpp:706
pinocchio::JointModelRevoluteUnalignedTpl::axis
Vector3 axis
3d main axis of the joint.
Definition: joint-revolute-unaligned.hpp:730
pinocchio::python::addJoint_proxy
static context::JointModelComposite & addJoint_proxy(context::JointModelComposite &joint_composite, const context::JointModel &jmodel, const context::SE3 &joint_placement=context::SE3::Identity())
Definition: joints-models.hpp:293
pinocchio::python::context::Scalar
PINOCCHIO_PYTHON_SCALAR_TYPE Scalar
Definition: bindings/python/context/generic.hpp:37
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27
pinocchio::JointModelUniversalTpl::axis1
Vector3 axis1
3d main axii of the joint.
Definition: joint-universal.hpp:609


pinocchio
Author(s):
autogenerated on Sun Dec 22 2024 03:41:11