bindings/python/multibody/geometry-object.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2017-2023 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_python_geometry_object_hpp__
6 #define __pinocchio_python_geometry_object_hpp__
7 
8 #include <eigenpy/memory.hpp>
11 #include <eigenpy/variant.hpp>
12 
19 
21 
22 #if EIGENPY_VERSION_AT_MOST(2, 8, 1)
24 #endif
25 
26 namespace pinocchio
27 {
28  namespace python
29  {
30  namespace bp = boost::python;
31 
33  : public boost::python::def_visitor<GeometryObjectPythonVisitor>
34  {
35 
37 
38  template<class PyClass>
39  void visit(PyClass & cl) const
40  {
42  Converter::registration();
43 
44  cl.def(bp::init<
45  std::string, JointIndex, FrameIndex, const SE3 &, CollisionGeometryPtr,
46  bp::optional<
47  std::string, const Eigen::Vector3d &, bool, const Eigen::Vector4d &, std::string,
49  bp::args(
50  "self", "name", "parent_joint", "parent_frame", "placement",
51  "collision_geometry", "mesh_path", "mesh_scale", "override_material",
52  "mesh_color", "mesh_texture_path", "mesh_material"),
53  "Full constructor of a GeometryObject."))
54  .def(bp::init<
55  std::string, JointIndex, const SE3 &, CollisionGeometryPtr,
56  bp::optional<
57  std::string, const Eigen::Vector3d &, bool, const Eigen::Vector4d &, std::string,
59  bp::args(
60  "self", "name", "parent_joint", "placement", "collision_geometry", "mesh_path",
61  "mesh_scale", "override_material", "mesh_color", "mesh_texture_path",
62  "mesh_material"),
63  "Reduced constructor of a GeometryObject. This constructor does not require to specify "
64  "the parent frame index."))
65  .def(bp::init<
66  std::string, FrameIndex, JointIndex, CollisionGeometryPtr, const SE3 &,
67  bp::optional<
68  std::string, const Eigen::Vector3d &, bool, const Eigen::Vector4d &, std::string,
70  bp::args(
71  "self", "name", "parent_frame", "parent_joint", "collision_geometry", "placement",
72  "mesh_path", "mesh_scale", "override_material", "mesh_color",
73  "mesh_texture_path"
74  "mesh_material"),
75  "Deprecated. Full constructor of a GeometryObject.")[deprecated_function<>()])
76  .def(bp::init<
77  std::string, JointIndex, CollisionGeometryPtr, const SE3 &,
78  bp::optional<
79  std::string, const Eigen::Vector3d &, bool, const Eigen::Vector4d &, std::string,
81  bp::args(
82  "self", "name", "parent_joint", "collision_geometry", "placement", "mesh_path",
83  "mesh_scale", "override_material", "mesh_color", "mesh_texture_path",
84  "mesh_material"),
85  "Deprecated. Reduced constructor of a GeometryObject. This constructor does not "
86  "require to specify the parent frame index.")[deprecated_function<>()])
87  .def(bp::init<const GeometryObject &>(
88  bp::args("self", "otherGeometryObject"), "Copy constructor"))
89  .add_property(
90  "meshScale",
91  bp::make_getter(&GeometryObject::meshScale, bp::return_internal_reference<>()),
92  bp::make_setter(&GeometryObject::meshScale), "Scaling parameter of the mesh.")
93  .add_property(
94  "meshColor",
95  bp::make_getter(&GeometryObject::meshColor, bp::return_internal_reference<>()),
96  bp::make_setter(&GeometryObject::meshColor), "Color rgba of the mesh.")
97  .def_readwrite(
98  "geometry", &GeometryObject::geometry,
99  "The FCL CollisionGeometry associated to the given GeometryObject.")
100  .def_readwrite(
101  "name", &GeometryObject::name, "Name associated to the given GeometryObject.")
102  .def_readwrite("parentJoint", &GeometryObject::parentJoint, "Index of the parent joint.")
103  .def_readwrite("parentFrame", &GeometryObject::parentFrame, "Index of the parent frame.")
104  .def_readwrite(
105  "placement", &GeometryObject::placement,
106  "Position of geometry object in parent joint's frame.")
107  .def_readwrite("meshPath", &GeometryObject::meshPath, "Path to the mesh file.")
108  .def_readwrite(
109  "overrideMaterial", &GeometryObject::overrideMaterial,
110  "Boolean that tells whether material information is stored inside the "
111  "given GeometryObject.")
112  .def_readwrite(
113  "meshTexturePath", &GeometryObject::meshTexturePath, "Path to the mesh texture file.")
114  .def_readwrite(
115  "disableCollision", &GeometryObject::disableCollision,
116  "If true, no collision or distance check will be done between the "
117  "Geometry and any other geometry.")
118  .def(
119  "clone", &GeometryObject::clone, bp::arg("self"),
120  "Perform a deep copy of this. It will create a copy of the underlying FCL geometry.")
121  .add_property(
122  "meshMaterial",
123  bp::make_getter(&GeometryObject::meshMaterial, Converter::return_internal_reference()),
124  bp::make_setter(&GeometryObject::meshMaterial),
125  "Material associated to the mesh (applied only if overrideMaterial is True)")
126 
127  .def(bp::self == bp::self)
128  .def(bp::self != bp::self)
129 
130 #ifdef PINOCCHIO_WITH_HPP_FCL
131  .def("CreateCapsule", &GeometryObjectPythonVisitor::maker_capsule)
132  .staticmethod("CreateCapsule")
133 #endif // PINOCCHIO_WITH_HPP_FCL
134  ;
135 
136  // Check registration
137  {
138  const bp::type_info info = bp::type_id<CollisionGeometryPtr>();
139  const bp::converter::registration * reg = bp::converter::registry::query(info);
140  // We just need to check if the type shared_ptr<CollisionGeometry> exist in the registry
141  if (!reg)
142  bp::register_ptr_to_python<CollisionGeometryPtr>();
143  }
144  }
145 
146 #ifdef PINOCCHIO_WITH_HPP_FCL
147  static GeometryObject maker_capsule(const double radius, const double length)
148  {
149  return GeometryObject(
150  "", JointIndex(0), FrameIndex(0), SE3::Identity(),
151  std::shared_ptr<fcl::CollisionGeometry>(new fcl::Capsule(radius, length)));
152  }
153 #endif // PINOCCHIO_WITH_HPP_FCL
154 
155  static void expose()
156  {
157  if (!register_symbolic_link_to_registered_type<GeometryObject>())
158  {
159  bp::class_<GeometryObject>(
160  "GeometryObject",
161  "A wrapper on a collision geometry including its parent "
162  "joint, parent frame, placement in parent joint's frame.\n\n",
163  bp::no_init)
168 #ifndef PINOCCHIO_PYTHON_NO_SERIALIZATION
170 #endif
171  ;
172  }
173 
174 #ifdef PINOCCHIO_WITH_HPP_FCL
175  if (!register_symbolic_link_to_registered_type<CollisionObject>())
176  {
177  bp::class_<CollisionObject, bp::bases<::hpp::fcl::CollisionObject>>(
178  "CollisionObject", "A Pinocchio collision object derived from FCL CollisionObject.",
179  bp::no_init)
180  .def(bp::init<
181  const std::shared_ptr<::hpp::fcl::CollisionGeometry> &,
182  bp::optional<const size_t, bool>>(
183  (bp::arg("self"), bp::arg("collision_geometry"),
184  bp::arg("geometryObjectIndex") = (std::numeric_limits<size_t>::max)(),
185  bp::arg("compute_local_aabb") = true),
186  "Constructor"))
187  .def(bp::init<
188  const std::shared_ptr<::hpp::fcl::CollisionGeometry> &, SE3,
189  bp::optional<const size_t, bool>>(
190  (bp::arg("self"), bp::arg("collision_geometry"), bp::arg("placement"),
191  bp::arg("geometryObjectIndex") = (std::numeric_limits<size_t>::max)(),
192  bp::arg("compute_local_aabb") = true),
193  "Constructor"));
194  }
195 #endif
196 
197  if (!register_symbolic_link_to_registered_type<GeometryNoMaterial>())
198  {
200  bp::class_<GeometryNoMaterial>("GeometryNoMaterial", bp::init<>())
201  .def(bp::init<GeometryNoMaterial>());
202  }
203 
204  if (!register_symbolic_link_to_registered_type<GeometryPhongMaterial>())
205  {
206  bp::class_<GeometryPhongMaterial>("GeometryPhongMaterial", bp::init<>())
207  .def(bp::init<GeometryPhongMaterial>())
208  .def(bp::init<Eigen::Vector4d, Eigen::Vector4d, double>())
209  .add_property(
210  "meshEmissionColor",
211  bp::make_getter(
212  &GeometryPhongMaterial::meshEmissionColor, bp::return_internal_reference<>()),
214  "RGBA emission (ambient) color value of the mesh")
215  .add_property(
216  "meshSpecularColor",
217  bp::make_getter(
218  &GeometryPhongMaterial::meshSpecularColor, bp::return_internal_reference<>()),
220  "RGBA specular value of the mesh")
221  .def_readwrite(
222  "meshShininess", &GeometryPhongMaterial::meshShininess,
223  "Shininess associated to the specular lighting model (between 0 and 1)");
224  }
225  if (!register_symbolic_link_to_registered_type<GeometryType>())
226  {
227  bp::enum_<GeometryType>("GeometryType")
228  .value("VISUAL", VISUAL)
229  .value("COLLISION", COLLISION)
230  .export_values();
231  }
232  }
233  };
234 
235  } // namespace python
236 } // namespace pinocchio
237 
238 #endif // ifndef __pinocchio_python_geometry_object_hpp__
pinocchio::python::GeometryObjectPythonVisitor::CollisionGeometryPtr
GeometryObject::CollisionGeometryPtr CollisionGeometryPtr
Definition: bindings/python/multibody/geometry-object.hpp:36
init
void init(bool compute_local_aabb=true)
pinocchio::FrameIndex
Index FrameIndex
Definition: multibody/fwd.hpp:28
pinocchio::GeometryObject::overrideMaterial
bool overrideMaterial
Decide whether to override the Material.
Definition: multibody/geometry-object.hpp:119
boost::python
pinocchio::ModelItem< GeometryObject >::parentJoint
JointIndex parentJoint
Index of the parent joint.
Definition: model-item.hpp:28
eigenpy::VariantConverter
pinocchio::GeometryObject::meshScale
Eigen::Vector3d meshScale
Scaling vector applied to the GeometryObject::geometry object.
Definition: multibody/geometry-object.hpp:116
pinocchio::python::PickleFromStringSerialization
Definition: pickle.hpp:17
registration.hpp
pinocchio::python::GeometryObjectPythonVisitor::expose
static void expose()
Definition: bindings/python/multibody/geometry-object.hpp:155
pinocchio::GeometryPhongMaterial::meshSpecularColor
Eigen::Vector4d meshSpecularColor
RGBA specular color value of the GeometryObject::geometry object.
Definition: multibody/geometry-object.hpp:65
eigen-from-python.hpp
pinocchio::SE3Tpl< context::Scalar, context::Options >
pinocchio::GeometryObject::meshColor
Eigen::Vector4d meshColor
RGBA color value of the GeometryObject::geometry object.
Definition: multibody/geometry-object.hpp:122
eigen-to-python.hpp
pinocchio::GeometryObject
Definition: multibody/geometry-object.hpp:87
pinocchio::python::deprecated_function
Definition: bindings/python/utils/deprecation.hpp:51
def
void def(const char *name, Func func)
pinocchio::VISUAL
@ VISUAL
Definition: multibody/geometry-object.hpp:26
pinocchio::GeometryPhongMaterial::meshShininess
double meshShininess
Shininess associated to the specular lighting model.
Definition: multibody/geometry-object.hpp:70
pinocchio::ModelItem< GeometryObject >::placement
SE3 placement
Position of kinematic element in parent joint frame.
Definition: model-item.hpp:39
pickle.hpp
deprecation.hpp
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION
#define EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(...)
pinocchio::python::GeometryObjectPythonVisitor
Definition: bindings/python/multibody/geometry-object.hpp:32
pinocchio::ModelItem< GeometryObject >::parentFrame
FrameIndex parentFrame
Index of the parent frame.
Definition: model-item.hpp:36
pinocchio::GeometryObject::meshMaterial
GeometryMaterial meshMaterial
Material associated to the mesh. This material should be used only if overrideMaterial is set to true...
Definition: multibody/geometry-object.hpp:127
serializable.hpp
pinocchio::python::GeometryObjectPythonVisitor::visit
void visit(PyClass &cl) const
Definition: bindings/python/multibody/geometry-object.hpp:39
ocp.info
info
Definition: ocp.py:80
python
pinocchio::python::CopyableVisitor
Add the Python method copy to allow a copy of this by calling the copy constructor.
Definition: copyable.hpp:21
geometry.hpp
address.hpp
pinocchio::GeometryObject::meshPath
std::string meshPath
Absolute path to the mesh file (if the geometry pointee is also a Mesh)
Definition: multibody/geometry-object.hpp:113
pinocchio::GeometryMaterial
boost::variant< GeometryNoMaterial, GeometryPhongMaterial > GeometryMaterial
Definition: multibody/geometry-object.hpp:73
pinocchio::GeometryObject::meshTexturePath
std::string meshTexturePath
Absolute path to the mesh texture file.
Definition: multibody/geometry-object.hpp:130
pinocchio::GeometryObject::geometry
CollisionGeometryPtr geometry
The FCL CollisionGeometry (might be a Mesh, a Geometry Primitive, etc.)
Definition: multibody/geometry-object.hpp:110
copyable.hpp
pinocchio::GeometryObject::clone
GeometryObject clone() const
Perform a deep copy of this. It will create a copy of the underlying FCL geometry.
Definition: multibody/geometry-object.hpp:302
pinocchio::python::SerializableVisitor
Definition: bindings/python/serialization/serializable.hpp:19
Capsule
Capsule()
pinocchio::python::AddressVisitor
Add the Python method to extract the address of the underlying C++ object.
Definition: address.hpp:21
pinocchio::GeometryObject::disableCollision
bool disableCollision
If true, no collision or distance check will be done between the Geometry and any other geometry.
Definition: multibody/geometry-object.hpp:134
pinocchio::SE3Tpl::Identity
static SE3Tpl Identity()
Definition: spatial/se3-tpl.hpp:136
cl
cl
memory.hpp
pinocchio::JointIndex
Index JointIndex
Definition: multibody/fwd.hpp:26
pinocchio::COLLISION
@ COLLISION
Definition: multibody/geometry-object.hpp:27
pinocchio::GeometryObject::CollisionGeometryPtr
std::shared_ptr< fcl::CollisionGeometry > CollisionGeometryPtr
Definition: multibody/geometry-object.hpp:102
CppAD::max
AD< Scalar > max(const AD< Scalar > &x, const AD< Scalar > &y)
Definition: autodiff/cppad.hpp:181
length
FCL_REAL length[2]
pinocchio::ModelItem< GeometryObject >::name
std::string name
Name of the kinematic element.
Definition: model-item.hpp:25
variant.hpp
radius
FCL_REAL radius
pinocchio::GeometryPhongMaterial::meshEmissionColor
Eigen::Vector4d meshEmissionColor
RGBA emission (ambient) color value of the GeometryObject::geometry object.
Definition: multibody/geometry-object.hpp:62
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27


pinocchio
Author(s):
autogenerated on Thu Dec 19 2024 03:41:29