Unverified Commit 3852a0f8 authored by Justin Carpentier's avatar Justin Carpentier Committed by GitHub
Browse files

Merge pull request #116 from jcarpent/topic/python

Improve bindings + remove borring warnings + fix
parents f46b141f 0fef5b66
...@@ -41,6 +41,9 @@ set(PROJECT_DESCRIPTION ...@@ -41,6 +41,9 @@ set(PROJECT_DESCRIPTION
) )
SET(PROJECT_USE_CMAKE_EXPORT TRUE) SET(PROJECT_USE_CMAKE_EXPORT TRUE)
SET(CMAKE_C_STANDARD 99)
SET(CMAKE_CXX_STANDARD 98)
# Do not support CMake older than 2.8.12 # Do not support CMake older than 2.8.12
CMAKE_POLICY(SET CMP0022 NEW) CMAKE_POLICY(SET CMP0022 NEW)
SET(PROJECT_USE_KEYWORD_LINK_LIBRARIES TRUE) SET(PROJECT_USE_KEYWORD_LINK_LIBRARIES TRUE)
...@@ -55,6 +58,7 @@ include(cmake/boost.cmake) ...@@ -55,6 +58,7 @@ include(cmake/boost.cmake)
include(cmake/python.cmake) include(cmake/python.cmake)
include(cmake/hpp.cmake) include(cmake/hpp.cmake)
include(cmake/apple.cmake) include(cmake/apple.cmake)
include(cmake/ide.cmake)
# If needed, fix CMake policy for APPLE systems # If needed, fix CMake policy for APPLE systems
APPLY_DEFAULT_APPLE_CONFIGURATION() APPLY_DEFAULT_APPLE_CONFIGURATION()
......
Subproject commit 308d3c947a3e276b06c5fa79894119346635de4d Subproject commit a99dc925bde7b976ae1ed286d0ab38906c73dff5
...@@ -38,14 +38,15 @@ ...@@ -38,14 +38,15 @@
#ifndef HPP_FCL_AABB_H #ifndef HPP_FCL_AABB_H
#define HPP_FCL_AABB_H #define HPP_FCL_AABB_H
#include <stdexcept>
#include <hpp/fcl/data_types.h> #include <hpp/fcl/data_types.h>
namespace hpp namespace hpp
{ {
namespace fcl namespace fcl
{ {
class CollisionRequest;
struct CollisionRequest;
/// @defgroup Bounding_Volume /// @defgroup Bounding_Volume
/// regroup class of differents types of bounding volume. /// regroup class of differents types of bounding volume.
/// @{ /// @{
......
...@@ -62,7 +62,7 @@ template<typename BV1, typename BV2> ...@@ -62,7 +62,7 @@ template<typename BV1, typename BV2>
class Converter class Converter
{ {
private: private:
static void convert(const BV1& bv1, const Transform3f& tf1, BV2& bv2) static void convert(const BV1& /*bv1*/, const Transform3f& /*tf1*/, BV2& /*bv2*/)
{ {
// should only use the specialized version, so it is private. // should only use the specialized version, so it is private.
} }
......
...@@ -107,11 +107,15 @@ struct BVNode : public BVNodeBase ...@@ -107,11 +107,15 @@ struct BVNode : public BVNodeBase
return bv.distance(other.bv, P1, P2); return bv.distance(other.bv, P1, P2);
} }
/// @brief Access the center of the BV /// @brief Access to the center of the BV
Vec3f getCenter() const { return bv.center(); } Vec3f getCenter() const { return bv.center(); }
/// @brief Access the orientation of the BV /// @brief Access to the orientation of the BV
const Matrix3f& getOrientation() const { return Matrix3f::Identity(); } const Matrix3f& getOrientation() const
{
static const Matrix3f id3 = Matrix3f::Identity();
return id3;
}
}; };
template<> template<>
......
...@@ -44,7 +44,8 @@ namespace hpp ...@@ -44,7 +44,8 @@ namespace hpp
{ {
namespace fcl namespace fcl
{ {
class CollisionRequest;
struct CollisionRequest;
/// @addtogroup Bounding_Volume /// @addtogroup Bounding_Volume
/// @{ /// @{
......
...@@ -46,7 +46,8 @@ namespace hpp ...@@ -46,7 +46,8 @@ namespace hpp
{ {
namespace fcl namespace fcl
{ {
class CollisionRequest;
struct CollisionRequest;
/// @addtogroup Bounding_Volume /// @addtogroup Bounding_Volume
/// @{ /// @{
......
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#ifndef HPP_FCL_RSS_H #ifndef HPP_FCL_RSS_H
#define HPP_FCL_RSS_H #define HPP_FCL_RSS_H
#include <stdexcept>
#include <hpp/fcl/data_types.h> #include <hpp/fcl/data_types.h>
#include <boost/math/constants/constants.hpp> #include <boost/math/constants/constants.hpp>
...@@ -47,7 +46,8 @@ namespace hpp ...@@ -47,7 +46,8 @@ namespace hpp
namespace fcl namespace fcl
{ {
class CollisionRequest; struct CollisionRequest;
/// @addtogroup Bounding_Volume /// @addtogroup Bounding_Volume
/// @{ /// @{
......
...@@ -46,7 +46,7 @@ namespace hpp ...@@ -46,7 +46,7 @@ namespace hpp
namespace fcl namespace fcl
{ {
class CollisionRequest; struct CollisionRequest;
/// @addtogroup Bounding_Volume /// @addtogroup Bounding_Volume
/// @{ /// @{
......
...@@ -45,7 +45,8 @@ namespace hpp ...@@ -45,7 +45,8 @@ namespace hpp
{ {
namespace fcl namespace fcl
{ {
class CollisionRequest;
struct CollisionRequest;
/// @addtogroup Bounding_Volume /// @addtogroup Bounding_Volume
/// @{ /// @{
......
...@@ -129,6 +129,11 @@ struct Contact ...@@ -129,6 +129,11 @@ struct Contact
&& pos == other.pos && pos == other.pos
&& penetration_depth == other.penetration_depth; && penetration_depth == other.penetration_depth;
} }
bool operator != (const Contact& other) const
{
return !(*this == other);
}
}; };
struct CollisionResult; struct CollisionResult;
......
...@@ -207,3 +207,4 @@ bool isEqual(const Eigen::MatrixBase<Derived>& lhs, const Eigen::MatrixBase<Othe ...@@ -207,3 +207,4 @@ bool isEqual(const Eigen::MatrixBase<Derived>& lhs, const Eigen::MatrixBase<Othe
} // namespace hpp } // namespace hpp
#endif #endif
...@@ -182,3 +182,4 @@ public: ...@@ -182,3 +182,4 @@ public:
/// @endcond /// @endcond
#endif #endif
...@@ -55,17 +55,6 @@ static inline std::ostream& operator << (std::ostream& o, const Quaternion3f& q) ...@@ -55,17 +55,6 @@ static inline std::ostream& operator << (std::ostream& o, const Quaternion3f& q)
return o; return o;
} }
inline bool isQuatIdentity (const Quaternion3f& q)
{
return (q.w() == 1 || q.w() == -1) && q.x() == 0 && q.y() == 0 && q.z() == 0;
}
inline bool areQuatEquals (const Quaternion3f& q1, const Quaternion3f& q2)
{
return (q1.w() == q2.w() && q1.x() == q2.x() && q1.y() == q2.y() && q1.z() == q2.z())
|| (q1.w() == -q2.w() && q1.x() == -q2.x() && q1.y() == -q2.y() && q1.z() == -q2.z());
}
/// @brief Simple transform class used locally by InterpMotion /// @brief Simple transform class used locally by InterpMotion
class Transform3f class Transform3f
{ {
...@@ -140,8 +129,9 @@ public: ...@@ -140,8 +129,9 @@ public:
} }
/// @brief set transform from rotation and translation /// @brief set transform from rotation and translation
template <typename Matrixx3Like, typename Vector3Like> template <typename Matrix3Like, typename Vector3Like>
inline void setTransform(const Eigen::MatrixBase<Matrixx3Like>& R_, const Eigen::MatrixBase<Vector3Like>& T_) inline void setTransform(const Eigen::MatrixBase<Matrix3Like>& R_,
const Eigen::MatrixBase<Vector3Like>& T_)
{ {
R.noalias() = R_; R.noalias() = R_;
T.noalias() = T_; T.noalias() = T_;
...@@ -242,7 +232,7 @@ public: ...@@ -242,7 +232,7 @@ public:
template<typename Derived> template<typename Derived>
inline Quaternion3f fromAxisAngle(const Eigen::MatrixBase<Derived>& axis, FCL_REAL angle) inline Quaternion3f fromAxisAngle(const Eigen::MatrixBase<Derived>& axis, FCL_REAL angle)
{ {
return Quaternion3f (Eigen::AngleAxis<double>(angle, axis)); return Quaternion3f (Eigen::AngleAxis<FCL_REAL>(angle, axis));
} }
} }
......
...@@ -39,13 +39,22 @@ SET(LIBRARY_NAME hppfcl) ...@@ -39,13 +39,22 @@ SET(LIBRARY_NAME hppfcl)
INCLUDE_DIRECTORIES("${Boost_INCLUDE_DIRS}" ${PYTHON_INCLUDE_DIRS}) INCLUDE_DIRECTORIES("${Boost_INCLUDE_DIRS}" ${PYTHON_INCLUDE_DIRS})
ADD_LIBRARY(${LIBRARY_NAME} SHARED SET(${LIBRARY_NAME}_HEADERS
fcl.hh
)
SET(${LIBRARY_NAME}_SOURCES
version.cc version.cc
math.cc math.cc
collision-geometries.cc collision-geometries.cc
collision.cc collision.cc
distance.cc distance.cc
fcl.cc) fcl.cc
)
ADD_LIBRARY(${LIBRARY_NAME} SHARED ${${LIBRARY_NAME}_SOURCES} ${${LIBRARY_NAME}_HEADERS})
ADD_HEADER_GROUP(${LIBRARY_NAME}_HEADER)
ADD_SOURCE_GROUP(${LIBRARY_NAME}_SOURCES)
TARGET_LINK_BOOST_PYTHON(${LIBRARY_NAME} PUBLIC) TARGET_LINK_BOOST_PYTHON(${LIBRARY_NAME} PUBLIC)
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} PUBLIC ${PROJECT_NAME} ${BOOST_system_LIBRARY}) TARGET_LINK_LIBRARIES(${LIBRARY_NAME} PUBLIC ${PROJECT_NAME} ${BOOST_system_LIBRARY})
......
// //
// Software License Agreement (BSD License) // Software License Agreement (BSD License)
// //
// Copyright (c) 2019 CNRS-LAAS // Copyright (c) 2019 CNRS-LAAS INRIA
// Author: Joseph Mirabel // Author: Joseph Mirabel
// All rights reserved. // All rights reserved.
// //
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#include <boost/python.hpp> #include <boost/python.hpp>
#include <eigenpy/registration.hpp>
#include "fcl.hh" #include "fcl.hh"
#include <hpp/fcl/fwd.hh> #include <hpp/fcl/fwd.hh>
...@@ -183,12 +185,19 @@ void exposeShapes () ...@@ -183,12 +185,19 @@ void exposeShapes ()
void exposeCollisionGeometries () void exposeCollisionGeometries ()
{ {
if(!eigenpy::register_symbolic_link_to_registered_type<OBJECT_TYPE>())
{
enum_<OBJECT_TYPE>("OBJECT_TYPE") enum_<OBJECT_TYPE>("OBJECT_TYPE")
.value ("OT_UNKNOWN", OT_UNKNOWN) .value ("OT_UNKNOWN", OT_UNKNOWN)
.value ("OT_BVH" , OT_BVH) .value ("OT_BVH" , OT_BVH)
.value ("OT_GEOM" , OT_GEOM) .value ("OT_GEOM" , OT_GEOM)
.value ("OT_OCTREE" , OT_OCTREE) .value ("OT_OCTREE" , OT_OCTREE)
; ;
}
if(!eigenpy::register_symbolic_link_to_registered_type<NODE_TYPE>())
{
enum_<NODE_TYPE>("NODE_TYPE") enum_<NODE_TYPE>("NODE_TYPE")
.value ("BV_UNKNOWN", BV_UNKNOWN) .value ("BV_UNKNOWN", BV_UNKNOWN)
.value ("BV_AABB" , BV_AABB) .value ("BV_AABB" , BV_AABB)
...@@ -210,7 +219,10 @@ void exposeCollisionGeometries () ...@@ -210,7 +219,10 @@ void exposeCollisionGeometries ()
.value ("GEOM_TRIANGLE" , GEOM_TRIANGLE) .value ("GEOM_TRIANGLE" , GEOM_TRIANGLE)
.value ("GEOM_OCTREE" , GEOM_OCTREE) .value ("GEOM_OCTREE" , GEOM_OCTREE)
; ;
}
if(!eigenpy::register_symbolic_link_to_registered_type<CollisionGeometry>())
{
class_ <CollisionGeometry, CollisionGeometryPtr_t, noncopyable> class_ <CollisionGeometry, CollisionGeometryPtr_t, noncopyable>
("CollisionGeometry", no_init) ("CollisionGeometry", no_init)
.def ("getObjectType", &CollisionGeometry::getObjectType) .def ("getObjectType", &CollisionGeometry::getObjectType)
...@@ -225,6 +237,7 @@ void exposeCollisionGeometries () ...@@ -225,6 +237,7 @@ void exposeCollisionGeometries ()
.def_readwrite("aabb_radius",&CollisionGeometry::aabb_radius,"AABB radius") .def_readwrite("aabb_radius",&CollisionGeometry::aabb_radius,"AABB radius")
; ;
}
exposeShapes(); exposeShapes();
......
// //
// Software License Agreement (BSD License) // Software License Agreement (BSD License)
// //
// Copyright (c) 2019 CNRS-LAAS // Copyright (c) 2019 CNRS-LAAS INRIA
// Author: Joseph Mirabel // Author: Joseph Mirabel
// All rights reserved. // All rights reserved.
// //
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp> #include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include <eigenpy/registration.hpp>
#include "fcl.hh" #include "fcl.hh"
#include <hpp/fcl/fwd.hh> #include <hpp/fcl/fwd.hh>
...@@ -43,17 +45,20 @@ ...@@ -43,17 +45,20 @@
using namespace boost::python; using namespace boost::python;
using namespace hpp::fcl; using namespace hpp::fcl;
using boost::shared_ptr;
using boost::noncopyable;
void exposeCollisionAPI () void exposeCollisionAPI ()
{ {
if(!eigenpy::register_symbolic_link_to_registered_type<CollisionRequestFlag>())
{
enum_ <CollisionRequestFlag> ("CollisionRequestFlag") enum_ <CollisionRequestFlag> ("CollisionRequestFlag")
.value ("CONTACT", CONTACT) .value ("CONTACT", CONTACT)
.value ("DISTANCE_LOWER_BOUND", DISTANCE_LOWER_BOUND) .value ("DISTANCE_LOWER_BOUND", DISTANCE_LOWER_BOUND)
.value ("NO_REQUEST", NO_REQUEST) .value ("NO_REQUEST", NO_REQUEST)
; ;
}
if(!eigenpy::register_symbolic_link_to_registered_type<CollisionRequest>())
{
class_ <CollisionRequest> ("CollisionRequest", init<>()) class_ <CollisionRequest> ("CollisionRequest", init<>())
.def (init<CollisionRequestFlag, size_t>()) .def (init<CollisionRequestFlag, size_t>())
...@@ -65,7 +70,10 @@ void exposeCollisionAPI () ...@@ -65,7 +70,10 @@ void exposeCollisionAPI ()
.def_readwrite ("security_margin" , &CollisionRequest::security_margin) .def_readwrite ("security_margin" , &CollisionRequest::security_margin)
.def_readwrite ("break_distance" , &CollisionRequest::break_distance) .def_readwrite ("break_distance" , &CollisionRequest::break_distance)
; ;
}
if(!eigenpy::register_symbolic_link_to_registered_type<Contact>())
{
class_ <Contact> ("Contact", init<>()) class_ <Contact> ("Contact", init<>())
//.def(init<CollisionGeometryPtr_t, CollisionGeometryPtr_t, int, int>()) //.def(init<CollisionGeometryPtr_t, CollisionGeometryPtr_t, int, int>())
//.def(init<CollisionGeometryPtr_t, CollisionGeometryPtr_t, int, int, Vec3f, Vec3f, FCL_REAL>()) //.def(init<CollisionGeometryPtr_t, CollisionGeometryPtr_t, int, int, Vec3f, Vec3f, FCL_REAL>())
...@@ -77,12 +85,19 @@ void exposeCollisionAPI () ...@@ -77,12 +85,19 @@ void exposeCollisionAPI ()
.def_readwrite ("pos", &Contact::pos) .def_readwrite ("pos", &Contact::pos)
.def_readwrite ("penetration_depth", &Contact::penetration_depth) .def_readwrite ("penetration_depth", &Contact::penetration_depth)
.def (self == self) .def (self == self)
.def (self != self)
; ;
}
if(!eigenpy::register_symbolic_link_to_registered_type< std::vector<Contact> >())
{
class_< std::vector<Contact> >("StdVec_Contact") class_< std::vector<Contact> >("StdVec_Contact")
.def(vector_indexing_suite< std::vector<Contact> >()) .def(vector_indexing_suite< std::vector<Contact> >())
; ;
}
if(!eigenpy::register_symbolic_link_to_registered_type< std::vector<CollisionResult> >())
{
class_ <CollisionResult> ("CollisionResult", init<>()) class_ <CollisionResult> ("CollisionResult", init<>())
.def ("isCollision", &CollisionResult::isCollision) .def ("isCollision", &CollisionResult::isCollision)
.def ("numContacts", &CollisionResult::numContacts) .def ("numContacts", &CollisionResult::numContacts)
...@@ -91,10 +106,14 @@ void exposeCollisionAPI () ...@@ -91,10 +106,14 @@ void exposeCollisionAPI ()
.def ("addContact" , &CollisionResult::addContact ) .def ("addContact" , &CollisionResult::addContact )
.def ("clear", &CollisionResult::clear) .def ("clear", &CollisionResult::clear)
; ;
}
if(!eigenpy::register_symbolic_link_to_registered_type< std::vector<CollisionResult> >())
{
class_< std::vector<CollisionResult> >("CollisionResult") class_< std::vector<CollisionResult> >("CollisionResult")
.def(vector_indexing_suite< std::vector<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));
......
// //
// Software License Agreement (BSD License) // Software License Agreement (BSD License)
// //
// Copyright (c) 2019 CNRS-LAAS // Copyright (c) 2019 CNRS-LAAS INRIA
// Author: Joseph Mirabel // Author: Joseph Mirabel
// All rights reserved. // All rights reserved.
// //
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp> #include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include <eigenpy/registration.hpp>
#include "fcl.hh" #include "fcl.hh"
#include <hpp/fcl/fwd.hh> #include <hpp/fcl/fwd.hh>
...@@ -43,8 +45,6 @@ ...@@ -43,8 +45,6 @@
using namespace boost::python; using namespace boost::python;
using namespace hpp::fcl; using namespace hpp::fcl;
using boost::shared_ptr;
using boost::noncopyable;
struct DistanceRequestWrapper struct DistanceRequestWrapper
{ {
...@@ -54,12 +54,17 @@ struct DistanceRequestWrapper ...@@ -54,12 +54,17 @@ struct DistanceRequestWrapper
void exposeDistanceAPI () void exposeDistanceAPI ()
{ {
if(!eigenpy::register_symbolic_link_to_registered_type<DistanceRequest>())
{
class_ <DistanceRequest> ("DistanceRequest", init<optional<bool,FCL_REAL,FCL_REAL> >()) class_ <DistanceRequest> ("DistanceRequest", init<optional<bool,FCL_REAL,FCL_REAL> >())
.def_readwrite ("enable_nearest_points", &DistanceRequest::enable_nearest_points) .def_readwrite ("enable_nearest_points", &DistanceRequest::enable_nearest_points)
.def_readwrite ("rel_err" , &DistanceRequest::rel_err) .def_readwrite ("rel_err" , &DistanceRequest::rel_err)
.def_readwrite ("abs_err" , &DistanceRequest::abs_err) .def_readwrite ("abs_err" , &DistanceRequest::abs_err)
; ;
}
if(!eigenpy::register_symbolic_link_to_registered_type<DistanceResult>())
{
class_ <DistanceResult> ("DistanceResult", init<>()) class_ <DistanceResult> ("DistanceResult", init<>())
.def_readwrite ("min_distance", &DistanceResult::min_distance) .def_readwrite ("min_distance", &DistanceResult::min_distance)
.def_readwrite ("normal", &DistanceResult::normal) .def_readwrite ("normal", &DistanceResult::normal)
...@@ -73,10 +78,14 @@ void exposeDistanceAPI () ...@@ -73,10 +78,14 @@ void exposeDistanceAPI ()
.def ("clear", &DistanceResult::clear) .def ("clear", &DistanceResult::clear)
; ;
}
if(!eigenpy::register_symbolic_link_to_registered_type< std::vector<DistanceResult> >())
{
class_< std::vector<DistanceResult> >("StdVec_DistanceResult") class_< std::vector<DistanceResult> >("StdVec_DistanceResult")
.def(vector_indexing_suite< std::vector<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));
......
// //
// Software License Agreement (BSD License) // Software License Agreement (BSD License)
// //