GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: include/pinocchio/bindings/python/multibody/joint/joint.hpp Lines: 22 26 84.6 %
Date: 2024-01-23 21:41:47 Branches: 22 44 50.0 %

Line Branch Exec Source
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
13
namespace pinocchio
14
{
15
  namespace python
16
  {
17
    namespace bp = boost::python;
18
19
    struct JointModelPythonVisitor
20
    : public boost::python::def_visitor< JointModelPythonVisitor >
21
    {
22
23
      template<class PyClass>
24
19
      void visit(PyClass& cl) const
25
      {
26
19
        cl
27
        .def(bp::init<>(bp::arg("self")))
28
        // All are add_properties cause ReadOnly
29

19
        .add_property("id",&getId)
30
19
        .add_property("idx_q",&getIdx_q)
31
19
        .add_property("idx_v",&getIdx_v)
32
19
        .add_property("nq",&getNq)
33
19
        .add_property("nv",&getNv)
34
19
        .def("hasConfigurationLimit", &JointModel::hasConfigurationLimit,
35
             "Return vector of boolean if joint has configuration limits.")
36
38
        .def("hasConfigurationLimitInTangent", &JointModel::hasConfigurationLimitInTangent,
37
             "Return vector of boolean if joint has configuration limits in tangent space.")
38
19
        .def("setIndexes",
39
             &JointModel::setIndexes,
40
             bp::args("self","id","idx_q","idx_v"))
41

38
        .def("hasSameIndexes",
42
             &JointModel::hasSameIndexes<JointModel>,
43
             bp::args("self","other"),
44
             "Check if this has same indexes than other.")
45

38
        .def("shortname",
46
             &JointModel::shortname,
47
             bp::arg("self"),
48
             "Returns string indicating the joint type (class name):"
49
                "\n\t- JointModelR[*]: Revolute Joint, with rotation axis [*] ∈ [X,Y,Z]"
50
                "\n\t- JointModelRevoluteUnaligned: Revolute Joint, with rotation axis not aligned with X, Y, nor Z"
51
                "\n\t- JointModelRUB[*]: Unbounded revolute Joint (without position limits), with rotation axis [*] ∈ [X,Y,Z]"
52
                "\n\t- JointModelRevoluteUnboundedUnaligned: Unbounded revolute Joint, with rotation axis not aligned with X, Y, nor Z"
53
                "\n\t- JointModelP[*]: Prismatic Joint, with rotation axis [*] ∈ [X,Y,Z]"
54
                "\n\t- JointModelPlanar: Planar joint"
55
                "\n\t- JointModelPrismaticUnaligned: Prismatic joint, with translation axis not aligned with X, Y, nor Z"
56
                "\n\t- JointModelSphericalZYX: Spherical joint (3D rotation)"
57
                "\n\t- JointModelTranslation: Translation joint (3D translation)"
58
                "\n\t- JointModelFreeFlyer: Joint enabling 3D rotation and translations."
59
                )
60
61

57
        .def(bp::self == bp::self)
62

57
        .def(bp::self != bp::self)
63
        ;
64
19
      }
65
66
22
      static JointIndex getId( const JointModel & self ) { return self.id(); }
67
      static int getIdx_q(const JointModel & self) {return self.idx_q();}
68
      static int getIdx_v(const JointModel & self) {return self.idx_v();}
69
      static int getNq(const JointModel & self) {return self.nq();}
70
      static int getNv(const JointModel & self) {return self.nv();}
71
72
19
      static void expose()
73
      {
74
19
        bp::class_<JointModel>("JointModel",
75
                               "Generic Joint Model",
76
                               bp::no_init)
77

38
        .def(bp::init<JointModel>(bp::args("self","other")))
78
19
        .def(JointModelPythonVisitor())
79
19
        .def(PrintableVisitor<JointModel>())
80
        ;
81
19
      }
82
83
    };
84
85
}} // namespace pinocchio::python
86
87
#endif // ifndef __pinocchio_python_multibody_joint_joint_hpp__