joints-models.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2015-2021 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 
15 
16 namespace pinocchio
17 {
18  namespace python
19  {
20  namespace bp = boost::python;
21 
22 
23  // generic expose_joint_model : do nothing special
24  template <class T>
25  inline bp::class_<T>& expose_joint_model(bp::class_<T>& cl)
26  {
27  return cl;
28  }
29 
30  // specialization for JointModelRevoluteUnaligned
31  template<>
32  inline bp::class_<JointModelRevoluteUnaligned>& expose_joint_model<JointModelRevoluteUnaligned> (bp::class_<JointModelRevoluteUnaligned> & cl)
33  {
34  return cl
35  .def(bp::init<double, double, double> (bp::args("self","x", "y", "z"),
36  "Init JointModelRevoluteUnaligned from the components x, y, z of the axis"))
37  .def(bp::init<Eigen::Vector3d> (bp::args("self","axis"),
38  "Init JointModelRevoluteUnaligned from an axis with x-y-z components"))
39  .def_readwrite("axis",&JointModelRevoluteUnaligned::axis,
40  "Rotation axis of the JointModelRevoluteUnaligned.")
41  ;
42  }
43 
44  // specialization for JointModelPrismaticUnaligned
45  template<>
46  inline bp::class_<JointModelPrismaticUnaligned>& expose_joint_model<JointModelPrismaticUnaligned> (bp::class_<JointModelPrismaticUnaligned> & cl)
47  {
48  return cl
49  .def(bp::init<double, double, double> (bp::args("self","x", "y", "z"),
50  "Init JointModelPrismaticUnaligned from the components x, y, z of the axis"))
51  .def(bp::init<Eigen::Vector3d> (bp::args("self","axis"),
52  "Init JointModelPrismaticUnaligned from an axis with x-y-z components"))
53  .def_readwrite("axis",&JointModelPrismaticUnaligned::axis,
54  "Translation axis of the JointModelPrismaticUnaligned.")
55  ;
56  }
57 
58  // specialization for JointModelComposite
59 
60  struct JointModelCompositeAddJointVisitor : public boost::static_visitor<JointModelComposite &>
61  {
64 
66  const SE3 & joint_placement)
67  : m_joint_composite(joint_composite)
68  , m_joint_placement(joint_placement)
69  {}
70 
71  template <typename JointModelDerived>
72  JointModelComposite & operator()(JointModelDerived & jmodel) const
73  {
74  return m_joint_composite.addJoint(jmodel,m_joint_placement);
75  }
76  }; // struct JointModelCompositeAddJointVisitor
77 
79  const JointModel & jmodel,
80  const SE3 & joint_placement = SE3::Identity())
81  {
82  return boost::apply_visitor(JointModelCompositeAddJointVisitor(joint_composite,joint_placement),
83  jmodel.toVariant());
84  }
85 
86  BOOST_PYTHON_FUNCTION_OVERLOADS(addJoint_proxy_overloads,addJoint_proxy,2,3)
87 
89  {
91 
93  : m_joint_placement(joint_placement)
94  {}
95 
96  template <typename JointModelDerived>
97  JointModelComposite* operator()(JointModelDerived & jmodel) const
98  {
99  return new JointModelComposite(jmodel,m_joint_placement);
100  }
101  }; // struct JointModelCompositeConstructorVisitor
102 
104  {
105  return boost::apply_visitor(JointModelCompositeConstructorVisitor(SE3::Identity()),
106  jmodel);
107  }
108 
110  const SE3 & joint_placement)
111  {
112  return boost::apply_visitor(JointModelCompositeConstructorVisitor(joint_placement),
113  jmodel);
114  }
115 
116  template<>
117  bp::class_<JointModelComposite> & expose_joint_model<JointModelComposite>(bp::class_<JointModelComposite> & cl)
118  {
119  return cl
120  .def(bp::init<const size_t> (bp::args("self","size"),
121  "Init JointModelComposite with a defined size"))
122  .def("__init__",
123  bp::make_constructor(init_proxy1,
124  bp::default_call_policies(),
125  bp::args("joint_model")
126  ),
127  "Init JointModelComposite from a joint"
128  )
129  .def("__init__",
130  bp::make_constructor(init_proxy2,
131  bp::default_call_policies(),
132  bp::args("joint_model","joint_placement")
133  ),
134  "Init JointModelComposite from a joint and a placement"
135  )
136  .add_property("joints",&JointModelComposite::joints)
137  .add_property("jointPlacements",&JointModelComposite::jointPlacements)
138  .add_property("njoints",&JointModelComposite::njoints)
139  .def("addJoint",
141  addJoint_proxy_overloads(bp::args("self","joint_model","joint_placement"),
142  "Add a joint to the vector of joints."
143  )[bp::return_internal_reference<>()]
144  )
145 
146  .def(bp::self == bp::self)
147  .def(bp::self != bp::self)
148 
149  ;
150  }
151  } // namespace python
152 } // namespace pinocchio
153 
154 #endif // ifndef __pinocchio_python_joint_models_hpp__
JointModelCompositeConstructorVisitor(const SE3 &joint_placement)
JointModelCompositeAddJointVisitor(JointModelComposite &joint_composite, const SE3 &joint_placement)
JointModelDerived & addJoint(const JointModelBase< JointModel > &jmodel, const SE3 &placement=SE3::Identity())
Add a joint to the vector of joints.
JointModelCompositeTpl< double > JointModelComposite
BOOST_PYTHON_FUNCTION_OVERLOADS(computeKKTContactDynamicMatrixInverse_overload, computeKKTContactDynamicMatrixInverse_proxy, 4, 5) static const Eigen
JointModelVector joints
Vector of joints contained in the joint composite.
static JointModelComposite * init_proxy2(const JointModel &jmodel, const SE3 &joint_placement)
static JointModelComposite & addJoint_proxy(JointModelComposite &joint_composite, const JointModel &jmodel, const SE3 &joint_placement=SE3::Identity())
bp::class_< JointModelRevoluteUnaligned > & expose_joint_model< JointModelRevoluteUnaligned >(bp::class_< JointModelRevoluteUnaligned > &cl)
JointModelComposite & operator()(JointModelDerived &jmodel) const
int njoints
Number of joints contained in the JointModelComposite.
JointModelComposite * operator()(JointModelDerived &jmodel) const
Main pinocchio namespace.
Definition: timings.cpp:28
cl
static JointModelComposite * init_proxy1(const JointModel &jmodel)
JointModelVariant & toVariant()
bp::class_< JointModelComposite > & expose_joint_model< JointModelComposite >(bp::class_< JointModelComposite > &cl)
bp::class_< JointModelPrismaticUnaligned > & expose_joint_model< JointModelPrismaticUnaligned >(bp::class_< JointModelPrismaticUnaligned > &cl)
bp::class_< T > & expose_joint_model(bp::class_< T > &cl)


pinocchio
Author(s):
autogenerated on Fri Jun 23 2023 02:38:31