5#ifndef __pinocchio_python_geometry_object_hpp__
6#define __pinocchio_python_geometry_object_hpp__
8#include <eigenpy/memory.hpp>
9#include <eigenpy/eigen-from-python.hpp>
10#include <eigenpy/eigen-to-python.hpp>
11#include <eigenpy/variant.hpp>
13#include "pinocchio/bindings/python/utils/address.hpp"
14#include "pinocchio/bindings/python/utils/copyable.hpp"
15#include "pinocchio/bindings/python/utils/registration.hpp"
16#include "pinocchio/bindings/python/utils/deprecation.hpp"
17#include "pinocchio/bindings/python/utils/pickle.hpp"
18#include "pinocchio/bindings/python/serialization/serializable.hpp"
20#include "pinocchio/multibody/geometry.hpp"
22#if EIGENPY_VERSION_AT_MOST(2, 8, 1)
30 namespace bp = boost::python;
32 struct GeometryObjectPythonVisitor
33 :
public boost::python::def_visitor<GeometryObjectPythonVisitor>
36 typedef GeometryObject::CollisionGeometryPtr CollisionGeometryPtr;
38 template<
class PyClass>
39 void visit(PyClass & cl)
const
41 typedef eigenpy::VariantConverter<GeometryMaterial> Converter;
42 Converter::registration();
45 std::string, JointIndex, FrameIndex,
const SE3 &, CollisionGeometryPtr,
47 std::string,
const Eigen::Vector3d &,
bool,
const Eigen::Vector4d &, std::string,
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."))
55 std::string, JointIndex,
const SE3 &, CollisionGeometryPtr,
57 std::string,
const Eigen::Vector3d &,
bool,
const Eigen::Vector4d &, std::string,
60 "self",
"name",
"parent_joint",
"placement",
"collision_geometry",
"mesh_path",
61 "mesh_scale",
"override_material",
"mesh_color",
"mesh_texture_path",
63 "Reduced constructor of a GeometryObject. This constructor does not require to specify "
64 "the parent frame index."))
66 std::string, FrameIndex, JointIndex, CollisionGeometryPtr,
const SE3 &,
68 std::string,
const Eigen::Vector3d &,
bool,
const Eigen::Vector4d &, std::string,
71 "self",
"name",
"parent_frame",
"parent_joint",
"collision_geometry",
"placement",
72 "mesh_path",
"mesh_scale",
"override_material",
"mesh_color",
75 "Deprecated. Full constructor of a GeometryObject.")[deprecated_function<>()])
77 std::string, JointIndex, CollisionGeometryPtr,
const SE3 &,
79 std::string,
const Eigen::Vector3d &,
bool,
const Eigen::Vector4d &, std::string,
82 "self",
"name",
"parent_joint",
"collision_geometry",
"placement",
"mesh_path",
83 "mesh_scale",
"override_material",
"mesh_color",
"mesh_texture_path",
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"))
99 "The FCL CollisionGeometry associated to the given GeometryObject.")
106 "Position of geometry object in parent joint's frame.")
110 "Boolean that tells whether material information is stored inside the "
111 "given GeometryObject.")
116 "If true, no collision or distance check will be done between the "
117 "Geometry and any other geometry.")
120 "Perform a deep copy of this. It will create a copy of the underlying FCL geometry.")
125 "Material associated to the mesh (applied only if overrideMaterial is True)")
127 .def(bp::self == bp::self)
128 .def(bp::self != bp::self)
130#ifdef PINOCCHIO_WITH_HPP_FCL
131 .def(
"CreateCapsule", &GeometryObjectPythonVisitor::maker_capsule)
132 .staticmethod(
"CreateCapsule")
138 const bp::type_info info = bp::type_id<CollisionGeometryPtr>();
139 const bp::converter::registration * reg = bp::converter::registry::query(info);
142 bp::register_ptr_to_python<CollisionGeometryPtr>();
146#ifdef PINOCCHIO_WITH_HPP_FCL
147 static GeometryObject maker_capsule(
const double radius,
const double length)
149 return GeometryObject(
150 "", JointIndex(0), FrameIndex(0), SE3::Identity(),
151 std::shared_ptr<fcl::CollisionGeometry>(
new fcl::Capsule(radius, length)));
157 if (!register_symbolic_link_to_registered_type<GeometryObject>())
159 bp::class_<GeometryObject>(
161 "A wrapper on a collision geometry including its parent "
162 "joint, parent frame, placement in parent joint's frame.\n\n",
164 .def(GeometryObjectPythonVisitor())
165 .def(CopyableVisitor<GeometryObject>())
166 .def(AddressVisitor<GeometryObject>())
167 .def(SerializableVisitor<GeometryObject>())
168#ifndef PINOCCHIO_PYTHON_NO_SERIALIZATION
169 .def_pickle(PickleFromStringSerialization<GeometryObject>())
174#ifdef PINOCCHIO_WITH_HPP_FCL
175 if (!register_symbolic_link_to_registered_type<CollisionObject>())
177 bp::class_<CollisionObject, bp::bases<::hpp::fcl::CollisionObject>>(
178 "CollisionObject",
"A Pinocchio collision object derived from FCL CollisionObject.",
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),
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),
197 if (!register_symbolic_link_to_registered_type<GeometryNoMaterial>())
200 bp::class_<GeometryNoMaterial>(
"GeometryNoMaterial", bp::init<>())
201 .def(bp::init<GeometryNoMaterial>());
204 if (!register_symbolic_link_to_registered_type<GeometryPhongMaterial>())
206 bp::class_<GeometryPhongMaterial>(
"GeometryPhongMaterial", bp::init<>())
207 .def(bp::init<GeometryPhongMaterial>())
208 .def(bp::init<Eigen::Vector4d, Eigen::Vector4d, double>())
214 "RGBA emission (ambient) color value of the mesh")
220 "RGBA specular value of the mesh")
223 "Shininess associated to the specular lighting model (between 0 and 1)");
225 if (!register_symbolic_link_to_registered_type<GeometryType>())
227 bp::enum_<GeometryType>(
"GeometryType")
228 .value(
"VISUAL", VISUAL)
229 .value(
"COLLISION", COLLISION)
Main pinocchio namespace.
Eigen::Vector4d meshColor
RGBA color value of the GeometryObject::geometry object.
GeometryMaterial meshMaterial
Material associated to the mesh. This material should be used only if overrideMaterial is set to true...
std::string meshPath
Absolute path to the mesh file (if the geometry pointee is also a Mesh)
bool overrideMaterial
Decide whether to override the Material.
bool disableCollision
If true, no collision or distance check will be done between the Geometry and any other geometry.
Eigen::Vector3d meshScale
Scaling vector applied to the GeometryObject::geometry object.
GeometryObject clone() const
Perform a deep copy of this. It will create a copy of the underlying FCL geometry.
std::string meshTexturePath
Absolute path to the mesh texture file.
CollisionGeometryPtr geometry
The FCL CollisionGeometry (might be a Mesh, a Geometry Primitive, etc.)
Eigen::Vector4d meshSpecularColor
RGBA specular color value of the GeometryObject::geometry object.
double meshShininess
Shininess associated to the specular lighting model.
Eigen::Vector4d meshEmissionColor
RGBA emission (ambient) color value of the GeometryObject::geometry object.
FrameIndex parentFrame
Index of the parent frame.
JointIndex parentJoint
Index of the parent joint.
std::string name
Name of the kinematic element.
SE3 placement
Position of kinematic element in parent joint frame.