Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue #590 #618

Merged
merged 3 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Optimize EPA: ignore useless faces in EPA's polytope; warm-start support computation for `Convex`; fix edge-cases witness points computation.
- Add `Serializable` trait to transform, collision data, collision geometries, bounding volumes, bvh models, hfields. Collision problems can now be serialized from C++ and sent to python and vice versa.
- CMake: allow use of installed jrl-cmakemodules ([#564](https://github.com/humanoid-path-planner/hpp-fcl/pull/564))
- Python: add id() support for geometries ([#618](https://github.com/humanoid-path-planner/hpp-fcl/pull/618)).

### Fixed

Expand Down
82 changes: 68 additions & 14 deletions python/collision-geometries.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@

#include <eigenpy/eigenpy.hpp>
#include <eigenpy/eigen-to-python.hpp>

#if EIGENPY_VERSION_AT_LEAST(3, 8, 0)
#include <eigenpy/id.hpp>
#endif
#include "fcl.hh"
#include "deprecation.hh"

Expand Down Expand Up @@ -116,7 +118,11 @@ void exposeBVHModel(const std::string& bvname) {
.def("clone", &BVH::clone, doxygen::member_func_doc(&BVH::clone),
return_value_policy<manage_new_object>())
.def_pickle(PickleObject<BVH>())
.def(SerializableVisitor<BVH>());
.def(SerializableVisitor<BVH>())
#if EIGENPY_VERSION_AT_LEAST(3, 8, 0)
.def(eigenpy::IdVisitor<BVH>())
#endif
;
}

template <typename BV>
Expand Down Expand Up @@ -157,7 +163,11 @@ void exposeHeightField(const std::string& bvname) {
Geometry::getBV),
bp::return_internal_reference<>())
.def_pickle(PickleObject<Geometry>())
.def(SerializableVisitor<Geometry>());
.def(SerializableVisitor<Geometry>())
#if EIGENPY_VERSION_AT_LEAST(3, 8, 0)
.def(eigenpy::IdVisitor<Geometry>())
#endif
;
}

struct ConvexBaseWrapper {
Expand Down Expand Up @@ -284,7 +294,11 @@ void exposeShapes() {
.def("clone", &Box::clone, doxygen::member_func_doc(&Box::clone),
return_value_policy<manage_new_object>())
.def_pickle(PickleObject<Box>())
.def(SerializableVisitor<Box>());
.def(SerializableVisitor<Box>())
#if EIGENPY_VERSION_AT_LEAST(3, 8, 0)
.def(eigenpy::IdVisitor<Box>())
#endif
;

class_<Capsule, bases<ShapeBase>, shared_ptr<Capsule>>(
"Capsule", doxygen::class_doc<Capsule>(), no_init)
Expand All @@ -296,7 +310,11 @@ void exposeShapes() {
.def("clone", &Capsule::clone, doxygen::member_func_doc(&Capsule::clone),
return_value_policy<manage_new_object>())
.def_pickle(PickleObject<Capsule>())
.def(SerializableVisitor<Capsule>());
.def(SerializableVisitor<Capsule>())
#if EIGENPY_VERSION_AT_LEAST(3, 8, 0)
.def(eigenpy::IdVisitor<Capsule>())
#endif
;

class_<Cone, bases<ShapeBase>, shared_ptr<Cone>>(
"Cone", doxygen::class_doc<Cone>(), no_init)
Expand All @@ -308,7 +326,11 @@ void exposeShapes() {
.def("clone", &Cone::clone, doxygen::member_func_doc(&Cone::clone),
return_value_policy<manage_new_object>())
.def_pickle(PickleObject<Cone>())
.def(SerializableVisitor<Cone>());
.def(SerializableVisitor<Cone>())
#if EIGENPY_VERSION_AT_LEAST(3, 8, 0)
.def(eigenpy::IdVisitor<Cone>())
#endif
;

class_<ConvexBase, bases<ShapeBase>, shared_ptr<ConvexBase>, noncopyable>(
"ConvexBase", doxygen::class_doc<ConvexBase>(), no_init)
Expand Down Expand Up @@ -356,7 +378,11 @@ void exposeShapes() {
.DEF_RO_CLASS_ATTRIB(Convex<Triangle>, num_polygons)
.def("polygons", &ConvexWrapper<Triangle>::polygons)
.def_pickle(PickleObject<Convex<Triangle>>())
.def(SerializableVisitor<Convex<Triangle>>());
.def(SerializableVisitor<Convex<Triangle>>())
#if EIGENPY_VERSION_AT_LEAST(3, 8, 0)
.def(eigenpy::IdVisitor<Convex<Triangle>>())
#endif
;

class_<Cylinder, bases<ShapeBase>, shared_ptr<Cylinder>>(
"Cylinder", doxygen::class_doc<Cylinder>(), no_init)
Expand All @@ -369,7 +395,11 @@ void exposeShapes() {
doxygen::member_func_doc(&Cylinder::clone),
return_value_policy<manage_new_object>())
.def_pickle(PickleObject<Cylinder>())
.def(SerializableVisitor<Cylinder>());
.def(SerializableVisitor<Cylinder>())
#if EIGENPY_VERSION_AT_LEAST(3, 8, 0)
.def(eigenpy::IdVisitor<Cylinder>())
#endif
;

class_<Halfspace, bases<ShapeBase>, shared_ptr<Halfspace>>(
"Halfspace", doxygen::class_doc<Halfspace>(), no_init)
Expand All @@ -383,7 +413,11 @@ void exposeShapes() {
doxygen::member_func_doc(&Halfspace::clone),
return_value_policy<manage_new_object>())
.def_pickle(PickleObject<Halfspace>())
.def(SerializableVisitor<Halfspace>());
.def(SerializableVisitor<Halfspace>())
#if EIGENPY_VERSION_AT_LEAST(3, 8, 0)
.def(eigenpy::IdVisitor<Halfspace>())
#endif
;

class_<Plane, bases<ShapeBase>, shared_ptr<Plane>>(
"Plane", doxygen::class_doc<Plane>(), no_init)
Expand All @@ -396,7 +430,11 @@ void exposeShapes() {
.def("clone", &Plane::clone, doxygen::member_func_doc(&Plane::clone),
return_value_policy<manage_new_object>())
.def_pickle(PickleObject<Plane>())
.def(SerializableVisitor<Plane>());
.def(SerializableVisitor<Plane>())
#if EIGENPY_VERSION_AT_LEAST(3, 8, 0)
.def(eigenpy::IdVisitor<Plane>())
#endif
;

class_<Sphere, bases<ShapeBase>, shared_ptr<Sphere>>(
"Sphere", doxygen::class_doc<Sphere>(), no_init)
Expand All @@ -407,7 +445,11 @@ void exposeShapes() {
.def("clone", &Sphere::clone, doxygen::member_func_doc(&Sphere::clone),
return_value_policy<manage_new_object>())
.def_pickle(PickleObject<Sphere>())
.def(SerializableVisitor<Sphere>());
.def(SerializableVisitor<Sphere>())
#if EIGENPY_VERSION_AT_LEAST(3, 8, 0)
.def(eigenpy::IdVisitor<Sphere>())
#endif
;

class_<Ellipsoid, bases<ShapeBase>, shared_ptr<Ellipsoid>>(
"Ellipsoid", doxygen::class_doc<Ellipsoid>(), no_init)
Expand All @@ -420,7 +462,11 @@ void exposeShapes() {
doxygen::member_func_doc(&Ellipsoid::clone),
return_value_policy<manage_new_object>())
.def_pickle(PickleObject<Ellipsoid>())
.def(SerializableVisitor<Ellipsoid>());
.def(SerializableVisitor<Ellipsoid>())
#if EIGENPY_VERSION_AT_LEAST(3, 8, 0)
.def(eigenpy::IdVisitor<Ellipsoid>())
#endif
;

class_<TriangleP, bases<ShapeBase>, shared_ptr<TriangleP>>(
"TriangleP", doxygen::class_doc<TriangleP>(), no_init)
Expand All @@ -434,7 +480,11 @@ void exposeShapes() {
doxygen::member_func_doc(&TriangleP::clone),
return_value_policy<manage_new_object>())
.def_pickle(PickleObject<TriangleP>())
.def(SerializableVisitor<TriangleP>());
.def(SerializableVisitor<TriangleP>())
#if EIGENPY_VERSION_AT_LEAST(3, 8, 0)
.def(eigenpy::IdVisitor<TriangleP>())
#endif
;
}

boost::python::tuple AABB_distance_proxy(const AABB& self, const AABB& other) {
Expand Down Expand Up @@ -584,7 +634,11 @@ void exposeCollisionGeometries() {
// (AABB::*)(const Vec3f &)>(&AABB::expand)),
bp::return_internal_reference<>())
.def_pickle(PickleObject<AABB>())
.def(SerializableVisitor<AABB>());
.def(SerializableVisitor<AABB>())
#if EIGENPY_VERSION_AT_LEAST(3, 8, 0)
.def(eigenpy::IdVisitor<AABB>())
#endif
;

def("translate", (AABB(*)(const AABB&, const Vec3f&)) & translate,
bp::args("aabb", "t"), "Translate the center of AABB by t");
Expand Down
Loading