@@ -276,57 +276,76 @@ namespace pinocchio
276276 {
277277 context::JointModelComposite & m_joint_composite;
278278 const context::SE3 & m_joint_placement;
279+ const std::string & m_name;
279280
280281 JointModelCompositeAddJointVisitor (
281- context::JointModelComposite & joint_composite, const context::SE3 & joint_placement)
282+ context::JointModelComposite & joint_composite,
283+ const context::SE3 & joint_placement,
284+ const std::string & name)
282285 : m_joint_composite(joint_composite)
283286 , m_joint_placement(joint_placement)
287+ , m_name(name)
284288 {
285289 }
286290
287291 template <typename JointModelDerived>
288292 context::JointModelComposite & operator ()(JointModelDerived & jmodel) const
289293 {
290- return m_joint_composite.addJoint (jmodel, m_joint_placement);
294+ return m_joint_composite.addJoint (jmodel, m_joint_placement, m_name );
291295 }
292296 }; // struct JointModelCompositeAddJointVisitor
293297
294298 static context::JointModelComposite & addJoint_proxy (
295299 context::JointModelComposite & joint_composite,
296300 const context::JointModel & jmodel,
297- const context::SE3 & joint_placement = context::SE3::Identity())
301+ const context::SE3 & joint_placement = context::SE3::Identity(),
302+ const std::string & name = "")
298303 {
299304 return boost::apply_visitor (
300- JointModelCompositeAddJointVisitor (joint_composite, joint_placement), jmodel.toVariant ());
305+ JointModelCompositeAddJointVisitor (joint_composite, joint_placement, name),
306+ jmodel.toVariant ());
301307 }
302308
303309 struct JointModelCompositeConstructorVisitor
304310 : public boost::static_visitor<context::JointModelComposite *>
305311 {
306312 const context::SE3 & m_joint_placement;
313+ const std::string & m_name;
307314
308- JointModelCompositeConstructorVisitor (const context::SE3 & joint_placement)
315+ JointModelCompositeConstructorVisitor (
316+ const context::SE3 & joint_placement, const std::string & name)
309317 : m_joint_placement(joint_placement)
318+ , m_name(name)
310319 {
311320 }
312321
313322 template <typename JointModelDerived>
314323 context::JointModelComposite * operator ()(JointModelDerived & jmodel) const
315324 {
316- return new context::JointModelComposite (jmodel, m_joint_placement);
325+ return new context::JointModelComposite (jmodel, m_joint_placement, m_name );
317326 }
318327 }; // struct JointModelCompositeConstructorVisitor
319328
320329 static context::JointModelComposite * init_proxy1 (const context::JointModel & jmodel)
321330 {
322331 return boost::apply_visitor (
323- JointModelCompositeConstructorVisitor (context::SE3::Identity ()), jmodel);
332+ JointModelCompositeConstructorVisitor (context::SE3::Identity (), " joint_1 " ), jmodel);
324333 }
325334
326335 static context::JointModelComposite *
327336 init_proxy2 (const context::JointModel & jmodel, const context::SE3 & joint_placement)
328337 {
329- return boost::apply_visitor (JointModelCompositeConstructorVisitor (joint_placement), jmodel);
338+ return boost::apply_visitor (
339+ JointModelCompositeConstructorVisitor (joint_placement, " joint_1" ), jmodel);
340+ }
341+
342+ static context::JointModelComposite * init_proxy3 (
343+ const context::JointModel & jmodel,
344+ const context::SE3 & joint_placement,
345+ const std::string & name)
346+ {
347+ return boost::apply_visitor (
348+ JointModelCompositeConstructorVisitor (joint_placement, name), jmodel);
330349 }
331350
332351 template <>
@@ -345,14 +364,23 @@ namespace pinocchio
345364 bp::make_constructor (
346365 init_proxy2, bp::default_call_policies (), bp::args (" joint_model" , " joint_placement" )),
347366 " Init JointModelComposite from a joint and a placement" )
367+ .def (
368+ " __init__" ,
369+ bp::make_constructor (
370+ init_proxy3, bp::default_call_policies (),
371+ bp::args (" joint_model" , " joint_placement" , " name" )),
372+ " Init JointModelComposite from a joint, a placement and a name" )
348373 .add_property (" joints" , &context::JointModelComposite::joints)
349374 .add_property (" jointPlacements" , &context::JointModelComposite::jointPlacements)
350375 .add_property (" njoints" , &context::JointModelComposite::njoints)
351376 .def (
352377 " addJoint" , &addJoint_proxy,
353378 (bp::arg (" self" ), bp::arg (" joint_model" ),
354- bp::arg (" joint_placement" ) = context::SE3::Identity ()),
379+ bp::arg (" joint_placement" ) = context::SE3::Identity (), bp::arg ( " name " ) = " joint_1 " ),
355380 " Add a joint to the vector of joints." , bp::return_internal_reference<>())
381+ .def (
382+ " getJointId" , &context::JointModelComposite::getJointId, bp::args (" joint_name" ),
383+ " Find the index of a joint inside a joint composite based on its name." )
356384
357385#ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS
358386 .def (bp::self == bp::self)
0 commit comments