geometry-object.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2017-2021 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_python_geometry_object_hpp__
6 #define __pinocchio_python_geometry_object_hpp__
7 
8 #include <boost/python.hpp>
9 #include <eigenpy/memory.hpp>
11 
12 #include "pinocchio/multibody/geometry.hpp"
13 
15 
16 namespace pinocchio
17 {
18  namespace python
19  {
20  namespace bp = boost::python;
21 
23  : public boost::python::def_visitor< GeometryObjectPythonVisitor >
24  {
25  typedef GeometryObject::CollisionGeometryPtr CollisionGeometryPtr;
26 
27  template<class PyClass>
28  void visit(PyClass& cl) const
29  {
30  cl
31  .def(bp::init<std::string,FrameIndex,JointIndex,CollisionGeometryPtr,SE3,
32  bp::optional<std::string,Eigen::Vector3d,bool,Eigen::Vector4d,std::string> >
33  (
34  bp::args("self","name","parent_frame","parent_joint","collision_geometry",
35  "placement", "mesh_path", "mesh_scale", "override_material", "mesh_color", "mesh_texture_path"),
36  "Full constructor of a GeometryObject."))
37  .def(bp::init<std::string,JointIndex,CollisionGeometryPtr,SE3,
38  bp::optional<std::string,Eigen::Vector3d,bool,Eigen::Vector4d,std::string> >
39  (
40  bp::args("self","name","parent_joint","collision_geometry",
41  "placement", "mesh_path", "mesh_scale", "override_material", "mesh_color", "mesh_texture_path"),
42  "Reduced constructor of a GeometryObject. This constructor does not require to specify the parent frame index."
43  ))
44  .def(bp::init<const GeometryObject&>
45  (
46  bp::args("self","otherGeometryObject"),
47  "Copy constructor"
48  ))
49  .add_property("meshScale",
50  bp::make_getter(&GeometryObject::meshScale,
51  bp::return_internal_reference<>()),
52  bp::make_setter(&GeometryObject::meshScale),
53  "Scaling parameter of the mesh.")
54  .add_property("meshColor",
55  bp::make_getter(&GeometryObject::meshColor,
56  bp::return_internal_reference<>()),
57  bp::make_setter(&GeometryObject::meshColor),
58  "Color rgba of the mesh.")
59  .def_readwrite("geometry", &GeometryObject::geometry,
60  "The FCL CollisionGeometry associated to the given GeometryObject.")
61  .def_readwrite("name", &GeometryObject::name,
62  "Name associated to the given GeometryObject.")
63  .def_readwrite("parentJoint", &GeometryObject::parentJoint,
64  "Index of the parent joint.")
65  .def_readwrite("parentFrame", &GeometryObject::parentFrame,
66  "Index of the parent frame.")
67  .def_readwrite("placement",&GeometryObject::placement,
68  "Position of geometry object in parent joint's frame.")
69  .def_readwrite("meshPath", &GeometryObject::meshPath,
70  "Path to the mesh file.")
71  .def_readwrite("overrideMaterial", &GeometryObject::overrideMaterial,
72  "Boolean that tells whether material information is stored inside the given GeometryObject.")
73  .def_readwrite("meshTexturePath", &GeometryObject::meshTexturePath,
74  "Path to the mesh texture file.")
75  .def_readwrite("disableCollision", &GeometryObject::disableCollision,
76  "If true, no collision or distance check will be done between the Geometry and any other geometry.")
77 
78  .def(bp::self == bp::self)
79  .def(bp::self != bp::self)
80 
81 #ifdef PINOCCHIO_WITH_HPP_FCL
82  .def("CreateCapsule", &GeometryObjectPythonVisitor::maker_capsule)
83  .staticmethod("CreateCapsule")
84 #endif // PINOCCHIO_WITH_HPP_FCL
85  ;
86 
87  // Check registration
88  {
89  const bp::type_info info = bp::type_id<CollisionGeometryPtr>();
90  const bp::converter::registration* reg = bp::converter::registry::query(info);
91  // We just need to check if the type shared_ptr<CollisionGeometry> exist in the registry
92  if(!reg)
93  bp::register_ptr_to_python<CollisionGeometryPtr>();
94  }
95  }
96 
97 #ifdef PINOCCHIO_WITH_HPP_FCL
98  static GeometryObject maker_capsule(const double radius, const double length)
99  {
100  return GeometryObject("",FrameIndex(0),JointIndex(0),
101  pinocchio::shared_ptr<fcl::CollisionGeometry>(new fcl::Capsule(radius, length)),
102  SE3::Identity());
103 
104  }
105 #endif // PINOCCHIO_WITH_HPP_FCL
106 
107  static void expose()
108  {
109  bp::class_<GeometryObject>("GeometryObject",
110  "A wrapper on a collision geometry including its parent joint, parent frame, placement in parent joint's frame.\n\n",
111  bp::no_init
112  )
114  ;
115 
116  bp::enum_<GeometryType>("GeometryType")
117  .value("VISUAL",VISUAL)
118  .value("COLLISION",COLLISION)
119  .export_values()
120  ;
121  }
122 
123  };
124 
125 
126  } // namespace python
127 } // namespace pinocchio
128 
129 #endif // ifndef __pinocchio_python_geometry_object_hpp__
void def(const char *name, Func func)
Capsule()
float value
GeometryObject::CollisionGeometryPtr CollisionGeometryPtr
FCL_REAL radius
void init(bool compute_local_aabb=true)
Main pinocchio namespace.
Definition: timings.cpp:28
FCL_REAL length[2]
#define EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(...)
info
Definition: ocp.py:61


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