Unverified Commit a2493c1e authored by Joseph Mirabel's avatar Joseph Mirabel Committed by GitHub
Browse files

Merge pull request #99 from jmirabel/python

[Python] Update bindings with requirements from Pinocchio.
parents 3351029d cd09b6ec
...@@ -147,8 +147,6 @@ SET(${PROJECT_NAME}_HEADERS ...@@ -147,8 +147,6 @@ SET(${PROJECT_NAME}_HEADERS
include/hpp/fcl/mesh_loader/loader.h include/hpp/fcl/mesh_loader/loader.h
include/hpp/fcl/internal/BV_fitter.h include/hpp/fcl/internal/BV_fitter.h
include/hpp/fcl/internal/BV_splitter.h include/hpp/fcl/internal/BV_splitter.h
include/hpp/fcl/internal/collision_node.h
include/hpp/fcl/internal/geometric_shapes_utility.h
include/hpp/fcl/internal/intersect.h include/hpp/fcl/internal/intersect.h
include/hpp/fcl/internal/tools.h include/hpp/fcl/internal/tools.h
include/hpp/fcl/internal/traversal_node_base.h include/hpp/fcl/internal/traversal_node_base.h
...@@ -159,7 +157,6 @@ SET(${PROJECT_NAME}_HEADERS ...@@ -159,7 +157,6 @@ SET(${PROJECT_NAME}_HEADERS
include/hpp/fcl/internal/traversal_node_shapes.h include/hpp/fcl/internal/traversal_node_shapes.h
include/hpp/fcl/internal/traversal_recurse.h include/hpp/fcl/internal/traversal_recurse.h
include/hpp/fcl/internal/traversal.h include/hpp/fcl/internal/traversal.h
include/hpp/fcl/internal/traits_traversal.h
) )
add_subdirectory(src) add_subdirectory(src)
......
...@@ -222,6 +222,8 @@ void exposeCollisionGeometries () ...@@ -222,6 +222,8 @@ void exposeCollisionGeometries ()
.def ("computeMomentofInertia", &CollisionGeometry::computeMomentofInertia) .def ("computeMomentofInertia", &CollisionGeometry::computeMomentofInertia)
.def ("computeVolume", &CollisionGeometry::computeVolume) .def ("computeVolume", &CollisionGeometry::computeVolume)
.def ("computeMomentofInertiaRelatedToCOM", &CollisionGeometry::computeMomentofInertiaRelatedToCOM) .def ("computeMomentofInertiaRelatedToCOM", &CollisionGeometry::computeMomentofInertiaRelatedToCOM)
.def_readwrite("aabb_radius",&CollisionGeometry::aabb_radius,"AABB radius")
; ;
exposeShapes(); exposeShapes();
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
// POSSIBILITY OF SUCH DAMAGE. // POSSIBILITY OF SUCH DAMAGE.
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include "fcl.hh" #include "fcl.hh"
...@@ -65,7 +66,9 @@ void exposeCollisionAPI () ...@@ -65,7 +66,9 @@ void exposeCollisionAPI ()
.def_readwrite ("break_distance" , &CollisionRequest::break_distance) .def_readwrite ("break_distance" , &CollisionRequest::break_distance)
; ;
class_ <Contact> ("Contact", no_init) class_ <Contact> ("Contact", init<>())
//.def(init<CollisionGeometryPtr_t, CollisionGeometryPtr_t, int, int>())
//.def(init<CollisionGeometryPtr_t, CollisionGeometryPtr_t, int, int, Vec3f, Vec3f, FCL_REAL>())
.def_readonly ("o1", &Contact::o1) .def_readonly ("o1", &Contact::o1)
.def_readonly ("o2", &Contact::o2) .def_readonly ("o2", &Contact::o2)
.def_readwrite ("b1", &Contact::b1) .def_readwrite ("b1", &Contact::b1)
...@@ -76,12 +79,23 @@ void exposeCollisionAPI () ...@@ -76,12 +79,23 @@ void exposeCollisionAPI ()
.def (self == self) .def (self == self)
; ;
class_< std::vector<Contact> >("StdVec_Contact")
.def(vector_indexing_suite< std::vector<Contact> >())
;
class_ <CollisionResult> ("CollisionResult", init<>()) class_ <CollisionResult> ("CollisionResult", init<>())
.def ("isCollision", &CollisionResult::isCollision) .def ("isCollision", &CollisionResult::isCollision)
.def ("numContacts", &CollisionResult::numContacts) .def ("numContacts", &CollisionResult::numContacts)
.def ("getContact" , &CollisionResult::getContact , return_value_policy<copy_const_reference>())
.def ("getContacts", &CollisionResult::getContacts, return_internal_reference<>())
.def ("addContact" , &CollisionResult::addContact )
.def ("clear", &CollisionResult::clear) .def ("clear", &CollisionResult::clear)
; ;
class_< std::vector<CollisionResult> >("CollisionResult")
.def(vector_indexing_suite< std::vector<CollisionResult> >())
;
def ("collide", static_cast< std::size_t (*)(const CollisionObject*, const CollisionObject*, def ("collide", static_cast< std::size_t (*)(const CollisionObject*, const CollisionObject*,
const CollisionRequest&, CollisionResult&) > (&collide)); const CollisionRequest&, CollisionResult&) > (&collide));
def ("collide", static_cast< std::size_t (*)( def ("collide", static_cast< std::size_t (*)(
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
// POSSIBILITY OF SUCH DAMAGE. // POSSIBILITY OF SUCH DAMAGE.
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include "fcl.hh" #include "fcl.hh"
...@@ -45,6 +46,12 @@ using namespace hpp::fcl; ...@@ -45,6 +46,12 @@ using namespace hpp::fcl;
using boost::shared_ptr; using boost::shared_ptr;
using boost::noncopyable; using boost::noncopyable;
struct DistanceRequestWrapper
{
static Vec3f getNearestPoint1(const DistanceResult & res) { return res.nearest_points[0]; }
static Vec3f getNearestPoint2(const DistanceResult & res) { return res.nearest_points[1]; }
};
void exposeDistanceAPI () void exposeDistanceAPI ()
{ {
class_ <DistanceRequest> ("DistanceRequest", init<optional<bool,FCL_REAL,FCL_REAL> >()) class_ <DistanceRequest> ("DistanceRequest", init<optional<bool,FCL_REAL,FCL_REAL> >())
...@@ -57,6 +64,8 @@ void exposeDistanceAPI () ...@@ -57,6 +64,8 @@ void exposeDistanceAPI ()
.def_readwrite ("min_distance", &DistanceResult::min_distance) .def_readwrite ("min_distance", &DistanceResult::min_distance)
.def_readwrite ("normal", &DistanceResult::normal) .def_readwrite ("normal", &DistanceResult::normal)
//.def_readwrite ("nearest_points", &DistanceResult::nearest_points) //.def_readwrite ("nearest_points", &DistanceResult::nearest_points)
.def("getNearestPoint1",&DistanceRequestWrapper::getNearestPoint1)
.def("getNearestPoint2",&DistanceRequestWrapper::getNearestPoint2)
.def_readonly ("o1", &DistanceResult::o1) .def_readonly ("o1", &DistanceResult::o1)
.def_readonly ("o2", &DistanceResult::o2) .def_readonly ("o2", &DistanceResult::o2)
.def_readwrite ("b1", &DistanceResult::b1) .def_readwrite ("b1", &DistanceResult::b1)
...@@ -65,6 +74,10 @@ void exposeDistanceAPI () ...@@ -65,6 +74,10 @@ void exposeDistanceAPI ()
.def ("clear", &DistanceResult::clear) .def ("clear", &DistanceResult::clear)
; ;
class_< std::vector<DistanceResult> >("StdVec_DistanceResult")
.def(vector_indexing_suite< std::vector<DistanceResult> >())
;
def ("distance", static_cast< FCL_REAL (*)(const CollisionObject*, const CollisionObject*, def ("distance", static_cast< FCL_REAL (*)(const CollisionObject*, const CollisionObject*,
const DistanceRequest&, DistanceResult&) > (&distance)); const DistanceRequest&, DistanceResult&) > (&distance));
def ("distance", static_cast< FCL_REAL (*)( def ("distance", static_cast< FCL_REAL (*)(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment