Commit 30647ad0 authored by Valenza Florian's avatar Valenza Florian
Browse files

[C++][CMake] Merged fake-fcl with fcl.hpp (splitted in .hpp and .hxx file)....

[C++][CMake] Merged fake-fcl with fcl.hpp (splitted in .hpp and .hxx file). Propagated flag -DWITH_HPP_FCL to all binaries
parent 1210ef60
......@@ -249,6 +249,7 @@ ENDIF(URDFDOM_FOUND)
LIST(APPEND ${PROJECT_NAME}_MULTIBODY_HEADERS
multibody/fcl.hpp
multibody/fcl.hxx
multibody/geometry.hpp
multibody/geometry.hxx
)
......@@ -260,9 +261,6 @@ IF(HPP_FCL_FOUND)
LIST(APPEND ${PROJECT_NAME}_SPATIAL_HEADERS
spatial/fcl-pinocchio-conversions.hpp
)
ELSE(HPP_FCL_FOUND)
LIST(APPEND ${PROJECT_NAME}_MULTIBODY_HEADERS
multibody/fake-fcl.hpp)
ENDIF(HPP_FCL_FOUND)
IF(LUA5_1_FOUND)
......
......@@ -37,6 +37,10 @@ ENDIF(BUILD_PYTHON_INTERFACE)
IF(${URDFDOM_FOUND})
PKG_CONFIG_USE_DEPENDENCY(timings urdfdom)
ENDIF(${URDFDOM_FOUND})
IF(HPP_FCL_FOUND)
PKG_CONFIG_USE_DEPENDENCY(timings hpp-fcl)
ADD_TEST_CFLAGS(timings "-DWITH_HPP_FCL")
ENDIF(HPP_FCL_FOUND)
SET_TARGET_PROPERTIES (timings PROPERTIES COMPILE_DEFINITIONS PINOCCHIO_SOURCE_DIR="${${PROJECT_NAME}_SOURCE_DIR}")
# timings-eigen
......@@ -48,6 +52,7 @@ ELSE(BUILD_BENCHMARK)
ENDIF(BUILD_BENCHMARK)
PKG_CONFIG_USE_DEPENDENCY(timings-eigen eigen3)
# geomTimings
#
IF(URDFDOM_FOUND AND HPP_FCL_FOUND)
......
......@@ -62,11 +62,9 @@ IF(URDFDOM_FOUND)
parsers/urdf/model.cpp
)
IF(HPP_FCL_FOUND)
LIST(APPEND ${PROJECT_NAME}_PARSERS_SOURCES
parsers/urdf/geometry.cpp
)
ENDIF(HPP_FCL_FOUND)
ENDIF(URDFDOM_FOUND)
IF(LUA5_1_FOUND)
......
//
// Copyright (c) 2016 CNRS
//
// This file is part of Pinocchio
// Pinocchio is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// Pinocchio is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// Pinocchio If not, see
// <http://www.gnu.org/licenses/>.
#ifndef __se3_fake_fcl_hpp__
#define __se3_fake_fcl_hpp__
namespace se3
{
namespace fcl
{
struct FakeCollisionGeometry
{
FakeCollisionGeometry(){};
};
struct AABB
{
AABB(): min_(0), max_(1){};
int min_;
int max_;
};
typedef FakeCollisionGeometry CollisionGeometry;
}
}
#endif // __se3_fake_fcl_hpp__
......@@ -19,15 +19,13 @@
#define __se3_fcl_hpp__
#include "pinocchio/multibody/fwd.hpp"
#include "pinocchio/spatial/fcl-pinocchio-conversions.hpp"
#ifdef WITH_HPP_FCL
#include <hpp/fcl/collision_object.h>
#include <hpp/fcl/collision.h>
#include <hpp/fcl/distance.h>
#include <hpp/fcl/shape/geometric_shapes.h>
#else
#include "pinocchio/multibody/fake-fcl.hpp"
#include "pinocchio/spatial/fcl-pinocchio-conversions.hpp"
#endif
#include <iostream>
......@@ -37,6 +35,7 @@
#include <assert.h>
#include <boost/foreach.hpp>
#include <boost/shared_ptr.hpp>
namespace se3
{
......@@ -64,10 +63,8 @@ namespace se3
}
void disp(std::ostream & os) const { os << "collision pair (" << first << "," << second << ")\n"; }
friend std::ostream & operator << (std::ostream & os, const CollisionPair & X)
{
X.disp(os); return os;
}
friend std::ostream & operator << (std::ostream & os, const CollisionPair & X);
}; // struct CollisionPair
typedef std::vector<CollisionPair> CollisionPairsVector_t;
......@@ -87,17 +84,17 @@ namespace se3
///
/// @brief Return the minimal distance between two geometry objects
///
double distance () const { return fcl_distance_result.min_distance; }
double distance () const;
///
/// \brief Return the witness point on the inner object expressed in global frame.
///
Eigen::Vector3d closestPointInner () const { return toVector3d(fcl_distance_result.nearest_points [0]); }
Eigen::Vector3d closestPointInner () const;
///
/// \brief Return the witness point on the outer object expressed in global frame.
///
Eigen::Vector3d closestPointOuter () const { return toVector3d(fcl_distance_result.nearest_points [1]); }
Eigen::Vector3d closestPointOuter () const;
bool operator == (const DistanceResult & other) const
{
......@@ -156,14 +153,29 @@ namespace se3
}; // struct CollisionResult
/// \brief Return true if the intrinsic geometry of the two CollisionObject is the same
inline bool operator == (const fcl::CollisionObject & lhs, const fcl::CollisionObject & rhs)
{
return lhs.collisionGeometry() == rhs.collisionGeometry()
&& lhs.getAABB().min_ == rhs.getAABB().min_
&& lhs.getAABB().max_ == rhs.getAABB().max_;
}
#else
namespace fcl
{
struct FakeCollisionGeometry
{
FakeCollisionGeometry(){};
};
struct AABB
{
AABB(): min_(0), max_(1){};
int min_;
int max_;
};
typedef FakeCollisionGeometry CollisionGeometry;
}
#endif // WITH_HPP_FCL
enum GeometryType
{
VISUAL,
......@@ -209,28 +221,10 @@ struct GeometryObject
return *this;
}
friend std::ostream & operator<< (std::ostream & os, const GeometryObject & geom_object);
};
inline bool operator==(const GeometryObject & lhs, const GeometryObject & rhs)
{
return ( lhs.name == rhs.name
&& lhs.parent == rhs.parent
&& lhs.collision_geometry == rhs.collision_geometry
&& lhs.placement == rhs.placement
&& lhs.mesh_path == rhs.mesh_path
);
}
inline std::ostream & operator<< (std::ostream & os, const GeometryObject & geom_object)
{
os << "Name: \t \n" << geom_object.name << "\n"
<< "Parent ID: \t \n" << geom_object.parent << "\n"
// << "collision object: \t \n" << geom_object.collision_geometry << "\n"
<< "Position in parent frame: \t \n" << geom_object.placement << "\n"
<< "Absolute path to mesh file: \t \n" << geom_object.mesh_path << "\n"
<< std::endl;
return os;
}
} // namespace se3
......@@ -238,6 +232,7 @@ struct GeometryObject
/* --- Details -------------------------------------------------------------- */
/* --- Details -------------------------------------------------------------- */
/* --- Details -------------------------------------------------------------- */
#include "pinocchio/multibody/fcl.hxx"
#endif // ifndef __se3_fcl_hpp__
//
// Copyright (c) 2015-2016 CNRS
//
// This file is part of Pinocchio
// Pinocchio is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// Pinocchio is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// Pinocchio If not, see
// <http://www.gnu.org/licenses/>.
#ifndef __se3_fcl_hxx__
#define __se3_fcl_hxx__
#include <iostream>
namespace se3
{
inline std::ostream & operator << (std::ostream & os, const CollisionPair & X)
{
X.disp(os); return os;
}
#ifdef WITH_HPP_FCL
inline double DistanceResult::distance () const
{
return fcl_distance_result.min_distance;
}
inline Eigen::Vector3d DistanceResult::closestPointInner () const
{
return toVector3d(fcl_distance_result.nearest_points [0]);
}
inline Eigen::Vector3d DistanceResult::closestPointOuter () const
{
return toVector3d(fcl_distance_result.nearest_points [1]);
}
inline bool operator == (const fcl::CollisionObject & lhs, const fcl::CollisionObject & rhs)
{
return lhs.collisionGeometry() == rhs.collisionGeometry()
&& lhs.getAABB().min_ == rhs.getAABB().min_
&& lhs.getAABB().max_ == rhs.getAABB().max_;
}
#endif // WITH_HPP_FCL
inline bool operator==(const GeometryObject & lhs, const GeometryObject & rhs)
{
return ( lhs.name == rhs.name
&& lhs.parent == rhs.parent
&& lhs.collision_geometry == rhs.collision_geometry
&& lhs.placement == rhs.placement
&& lhs.mesh_path == rhs.mesh_path
);
}
inline std::ostream & operator<< (std::ostream & os, const GeometryObject & geom_object)
{
os << "Name: \t \n" << geom_object.name << "\n"
<< "Parent ID: \t \n" << geom_object.parent << "\n"
// << "collision object: \t \n" << geom_object.collision_geometry << "\n"
<< "Position in parent frame: \t \n" << geom_object.placement << "\n"
<< "Absolute path to mesh file: \t \n" << geom_object.mesh_path << "\n"
<< std::endl;
return os;
}
} // namespace se3
#endif // ifndef __se3_fcl_hxx__
......@@ -28,7 +28,9 @@
#include <iomanip>
#include <boost/foreach.hpp>
#ifdef WITH_HPP_FCL
#include <hpp/fcl/mesh_loader/assimp.h>
#endif // WITH_HPP_FCL
namespace se3
{
......
......@@ -32,11 +32,9 @@
#include "pinocchio/python/parsers.hpp"
#include "pinocchio/python/explog.hpp"
#ifdef WITH_HPP_FCL
#include "pinocchio/python/geometry-object.hpp"
#include "pinocchio/python/geometry-model.hpp"
#include "pinocchio/python/geometry-data.hpp"
#endif
namespace se3
{
......@@ -74,12 +72,10 @@ namespace se3
FramePythonVisitor::expose();
ModelPythonVisitor::expose();
DataPythonVisitor::expose();
#ifdef WITH_HPP_FCL
GeometryObjectPythonVisitor::expose();
CollisionPairPythonVisitor::expose();
GeometryModelPythonVisitor::expose();
GeometryDataPythonVisitor::expose();
#endif
}
void exposeAlgorithms()
{
......
......@@ -28,8 +28,15 @@ MACRO(ADD_UNIT_TEST NAME PKGS)
PKG_CONFIG_USE_DEPENDENCY(${NAME} ${PKG})
ENDFOREACH(PKG)
IF(HPP_FCL_FOUND)
PKG_CONFIG_USE_DEPENDENCY(${NAME} hpp-fcl)
ADD_TEST_CFLAGS(${NAME} "-DWITH_HPP_FCL")
ENDIF(HPP_FCL_FOUND)
TARGET_LINK_LIBRARIES(${NAME} ${PROJECT_NAME})
IF(BUILD_PYTHON_INTERFACE)
TARGET_LINK_BOOST_PYTHON(${NAME})
TARGET_LINK_LIBRARIES(${NAME} ${PYTHON_LIBRARIES})
ENDIF(BUILD_PYTHON_INTERFACE)
......@@ -68,9 +75,8 @@ IF(URDFDOM_FOUND)
ADD_UNIT_TEST(value "eigen3;urdfdom")
ADD_TEST_CFLAGS(value '-DPINOCCHIO_SOURCE_DIR=\\\"${${PROJECT_NAME}_SOURCE_DIR}\\\"')
IF(HPP_FCL_FOUND)
ADD_UNIT_TEST(geom "eigen3;urdfdom;hpp-fcl")
ADD_UNIT_TEST(geom "eigen3;urdfdom")
ADD_TEST_CFLAGS(geom '-DPINOCCHIO_SOURCE_DIR=\\\"${${PROJECT_NAME}_SOURCE_DIR}\\\"')
ADD_TEST_CFLAGS(geom "-DWITH_HPP_FCL")
IF(BUILD_TESTS_WITH_HPP)
ADD_OPTIONAL_DEPENDENCY("hpp-model-urdf")
IF(HPP_MODEL_URDF_FOUND)
......
......@@ -38,7 +38,8 @@ MACRO(ADD_UTIL NAME UTIL_SRC PKGS)
IF(BUILD_UTILS)
INSTALL(TARGETS ${NAME} DESTINATION bin)
ENDIF(BUILD_UTILS)
ENDIF(BUILD_UTILS)
ENDMACRO(ADD_UTIL)
......
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