bindings/python/multibody/frame.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2016-2021 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_python_frame_hpp__
6 #define __pinocchio_python_frame_hpp__
7 
8 #include "pinocchio/multibody/fwd.hpp"
9 #include "pinocchio/multibody/frame.hpp"
12 
13 namespace pinocchio
14 {
15  namespace python
16  {
17  namespace bp = boost::python;
18 
20  : public bp::def_visitor< FramePythonVisitor >
21  {
22  template<class PyClass>
23  void visit(PyClass& cl) const
24  {
25  cl
26  .def(bp::init<>(bp::arg("self"),"Default constructor"))
27  .def(bp::init<const Frame &>(bp::args("self","other"),"Copy constructor"))
28  .def(bp::init< const std::string&,const JointIndex, const FrameIndex, const SE3&, FrameType, bp::optional<const Inertia&> > ((bp::arg("name"),bp::arg("parent_joint"), bp::args("parent_frame"), bp::arg("placement"), bp::arg("type"), bp::arg("inertia")),
29  "Initialize from a given name, type, parent joint index, parent frame index and placement wrt parent joint and an spatial inertia object."))
30 
31  .def_readwrite("name", &Frame::name, "name of the frame")
32  .def_readwrite("parent", &Frame::parent, "id of the parent joint")
33  .def_readwrite("previousFrame", &Frame::previousFrame, "id of the previous frame")
34  .def_readwrite("placement",
36  "placement in the parent joint local frame")
37  .def_readwrite("type", &Frame::type, "Type of the frame")
38  .def_readwrite("inertia", &Frame::inertia,"Inertia information attached to the frame.")
39 
40  .def(bp::self == bp::self)
41  .def(bp::self != bp::self)
42  ;
43  }
44 
45  static void expose()
46  {
47  bp::enum_<FrameType>("FrameType")
48  .value("OP_FRAME",OP_FRAME)
49  .value("JOINT",JOINT)
50  .value("FIXED_JOINT",FIXED_JOINT)
51  .value("BODY",BODY)
52  .value("SENSOR",SENSOR)
53  .export_values()
54  ;
55 
56  bp::class_<Frame>("Frame",
57  "A Plucker coordinate frame related to a parent joint inside a kinematic tree.\n\n",
58  bp::no_init
59  )
63  .def_pickle(Pickle())
64  ;
65  }
66 
67  private:
68  struct Pickle : bp::pickle_suite
69  {
70  static bp::tuple getinitargs(const Frame &)
71  {
72  return bp::make_tuple();
73  }
74 
75  static bp::tuple getstate(const Frame & f)
76  {
77  return bp::make_tuple(f.name, f.parent, f.previousFrame, f.placement, (int)f.type, f.inertia);
78  }
79 
80  static void setstate(Frame & f, bp::tuple tup)
81  {
82  f.name = bp::extract<std::string>(tup[0]);
83  f.parent = bp::extract<JointIndex>(tup[1]);
84  f.previousFrame = bp::extract<JointIndex>(tup[2]);
85  f.placement = bp::extract<SE3&>(tup[3]);
86  f.type = (FrameType)(int)bp::extract<int>(tup[4]);
87  if(bp::len(tup) > 5)
88  f.inertia = bp::extract<Inertia&>(tup[5]);
89  }
90 
91  static bool getstate_manages_dict() { return true; }
92  };
93  };
94 
95 
96  } // namespace python
97 } // namespace pinocchio
98 
99 #endif // ifndef __pinocchio_python_frame_hpp__
joint frame: attached to the child body of a joint (a.k.a. child frame)
A Plucker coordinate frame attached to a parent joint inside a kinematic tree.
JointIndex parent
Index of the parent joint.
Set the Python method str and repr to use the overloading operator<<.
Definition: printable.hpp:21
void def(const char *name, Func func)
fixed joint frame: joint frame but for a fixed joint
operational frame: user-defined frames that are defined at runtime
FrameType type
Type of the frame.
FrameType
Enum on the possible types of frames.
float value
body frame: attached to the collision, inertial or visual properties of a link
Add the Python method copy to allow a copy of this by calling the copy constructor.
Definition: copyable.hpp:21
void init(bool compute_local_aabb=true)
SE3 placement
Placement of the frame wrt the parent joint.
Main pinocchio namespace.
Definition: timings.cpp:28
Inertia inertia
Inertia information attached to the frame. This inertia will be appended to the inertia supported by ...
std::string name
Name of the frame.
sensor frame: defined in a sensor element
FrameIndex previousFrame
Index of the previous frame.


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