pinocchio  3.7.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
 
Loading...
Searching...
No Matches
joint.hpp
1//
2// Copyright (c) 2015-2021 CNRS INRIA
3//
4
5#ifndef __pinocchio_python_multibody_joint_joint_hpp__
6#define __pinocchio_python_multibody_joint_joint_hpp__
7
8#include <boost/python.hpp>
9
10#include "pinocchio/multibody/joint/joint-generic.hpp"
11#include "pinocchio/bindings/python/utils/printable.hpp"
12
13namespace pinocchio
14{
15 namespace python
16 {
17 namespace bp = boost::python;
18
19 struct JointModelPythonVisitor : public boost::python::def_visitor<JointModelPythonVisitor>
20 {
21
22 template<class PyClass>
23 void visit(PyClass & cl) const
24 {
25 cl.def(bp::init<>(bp::arg("self")))
26 // All are add_properties cause ReadOnly
27 .add_property("id", &getId)
28 .add_property("idx_q", &getIdx_q)
29 .add_property("idx_v", &getIdx_v)
30 .add_property("idx_vExtended", &getIdx_vExtended)
31 .add_property("nq", &getNq)
32 .add_property("nv", &getNv)
33 .add_property("nvExtended", &getNvExtended)
34 .def(
35 "hasConfigurationLimit", &JointModel::hasConfigurationLimit,
36 "Return vector of boolean if joint has configuration limits.")
37 .def(
38 "hasConfigurationLimitInTangent", &JointModel::hasConfigurationLimitInTangent,
39 "Return vector of boolean if joint has configuration limits in tangent space.")
40 .def("setIndexes", setIndexes0, bp::args("self", "id", "idx_q", "idx_v"))
41 .def("setIndexes", setIndexes1, bp::args("self", "id", "idx_q", "idx_v", "idx_vExtended"))
42 .def(
43 "hasSameIndexes", &JointModel::hasSameIndexes<JointModel>, bp::args("self", "other"),
44 "Check if this has same indexes than other.")
45 .def(
46 "shortname", &JointModel::shortname, bp::arg("self"),
47 "Returns string indicating the joint type (class name):"
48 "\n\t- JointModelR[*]: Revolute Joint, with rotation axis [*] ∈ [X,Y,Z]"
49 "\n\t- JointModelRevoluteUnaligned: Revolute Joint, with rotation axis not aligned "
50 "with X, Y, nor Z"
51 "\n\t- JointModelRUB[*]: Unbounded revolute Joint (without position limits), with "
52 "rotation axis [*] ∈ [X,Y,Z]"
53 "\n\t- JointModelRevoluteUnboundedUnaligned: Unbounded revolute Joint, with "
54 "rotation axis not aligned with X, Y, nor Z"
55 "\n\t- JointModelP[*]: Prismatic Joint, with rotation axis [*] ∈ [X,Y,Z]"
56 "\n\t- JointModelPlanar: Planar joint"
57 "\n\t- JointModelPrismaticUnaligned: Prismatic joint, with translation axis not "
58 "aligned with X, Y, nor Z"
59 "\n\t- JointModelSphericalZYX: Spherical joint (3D rotation)"
60 "\n\t- JointModelTranslation: Translation joint (3D translation)"
61 "\n\t- JointModelFreeFlyer: Joint enabling 3D rotation and translations.")
62
63 .def(bp::self == bp::self)
64 .def(bp::self != bp::self);
65 }
66
67 static JointIndex getId(const JointModel & self)
68 {
69 return self.id();
70 }
71 static int getIdx_q(const JointModel & self)
72 {
73 return self.idx_q();
74 }
75 static int getIdx_v(const JointModel & self)
76 {
77 return self.idx_v();
78 }
79 static int getIdx_vExtended(const JointModel & self)
80 {
81 return self.idx_vExtended();
82 }
83 static int getNq(const JointModel & self)
84 {
85 return self.nq();
86 }
87 static int getNv(const JointModel & self)
88 {
89 return self.nv();
90 }
91 static int getNvExtended(const JointModel & self)
92 {
93 return self.nvExtended();
94 }
95
96 static void
97 setIndexes0(JointModelDerived & self, const int & id, const int & idx_q, const int & idx_v)
98 {
99 self.setIndexes(id, idx_q, idx_v);
100 }
101
102 static void setIndexes1(
103 JointModelDerived & self,
104 const int & id,
105 const int & idx_q,
106 const int & idx_v,
107 const int & idx_vExtended)
108 {
109 self.setIndexes(id, idx_q, idx_v, idx_vExtended);
110 }
111
112 static void expose()
113 {
114 bp::class_<JointModel>("JointModel", "Generic Joint Model", bp::no_init)
115 .def(bp::init<JointModel>(bp::args("self", "other")))
116 .def(JointModelPythonVisitor())
117 .def(PrintableVisitor<JointModel>());
118 }
119 };
120
121 } // namespace python
122} // namespace pinocchio
123
124#endif // ifndef __pinocchio_python_multibody_joint_joint_hpp__
Main pinocchio namespace.
Definition treeview.dox:11
int idx_v(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointIdxVVisitor to get the index in the model tangent space correspond...
int idx_q(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointIdxQVisitor to get the index in the full model configuration space...
int idx_vExtended(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointIdvExtendedVisitor to get the index in the model extended tangent ...