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

Use btGImpactMeshShape instead of btConvexTriangleMeshShape #764

Merged
merged 8 commits into from
Aug 27, 2016
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
51 changes: 38 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ project(dart)

set(DART_MAJOR_VERSION "5")
set(DART_MINOR_VERSION "1")
set(DART_PATCH_VERSION "2")
set(DART_PATCH_VERSION "3")
set(DART_VERSION "${DART_MAJOR_VERSION}.${DART_MINOR_VERSION}.${DART_PATCH_VERSION}")
set(DART_PKG_DESC "Dynamic Animation and Robotics Toolkit.")
set(DART_PKG_EXTERNAL_DEPS "flann, ccd, fcl")
Expand Down Expand Up @@ -251,12 +251,14 @@ if(NOT BUILD_CORE_ONLY)
find_package(FLANN 1.8.4 QUIET)
if(FLANN_FOUND)
message(STATUS "Looking for FLANN - ${FLANN_VERSION} found")
set(HAVE_FLANN TRUE)
else()
if(FLANN_VERSION)
message(SEND_ERROR "Looking for FLANN - ${FLANN_VERSION} found, ${PROJECT_NAME} requires 1.8.4 or greater.")
else()
message(SEND_ERROR "Looking for FLANN - NOT found, please install libflann-dev")
endif()
set(HAVE_FLANN FALSE)
endif()

# TINYXML
Expand Down Expand Up @@ -355,21 +357,43 @@ else()
set(HAVE_SHARK FALSE)
endif()

# BulletCollision
if(UNIX)
pkg_check_modules(BULLET bullet>=2.82 QUIET)
if(NOT BULLET_FOUND)
pkg_check_modules(BULLET bullet2.82>=2.82 QUIET)
endif()
else()
find_package(Bullet COMPONENTS BulletMath BulletCollision QUIET)
endif()
# Bullet. Force MODULE mode to use the FindBullet.cmake file distributed with
# CMake. Otherwise, we may end up using the BulletConfig.cmake file distributed
# with Bullet, which uses relative paths and may break transitive dependencies.
find_package(Bullet COMPONENTS BulletMath BulletCollision MODULE QUIET)

if(BULLET_FOUND)
message(STATUS "Looking for BulletCollision - ${BULLET_VERSION} found")
# Test whether Bullet was built with double precision. If so, we need to
# define the BT_USE_DOUBLE_PRECISION pre-processor directive before including
# any Bullet headers. This is a workaround for the fact that Bullet does not
# add the definition to BULLET_DEFINITIONS or generate a #cmakedefine header.
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_FLAGS "")
set(CMAKE_REQUIRED_DEFINITIONS "-DBT_USE_DOUBLE_PRECISION")
set(CMAKE_REQUIRED_INCLUDES "${BULLET_INCLUDE_DIRS}")
set(CMAKE_REQUIRED_LIBRARIES "${BULLET_LIBRARIES}")
check_cxx_source_compiles(
"
#include <btBulletCollisionCommon.h>
int main()
{
btVector3 v(0., 0., 1.);
btStaticPlaneShape planeShape(v, 0.);
return 0;
}
"
BT_USE_DOUBLE_PRECISION
)

if(BT_USE_DOUBLE_PRECISION)
message(STATUS "Looking for Bullet - found (double precision)")
else()
message(STATUS "Looking for Bullet - found (single precision)")
endif()

set(HAVE_BULLET_COLLISION TRUE)
add_definitions(-DHAVE_BULLET_COLLISION)
else()
message(STATUS "Looking for BulletCollision - NOT found, please install libbullet-dev")
message(STATUS "Looking for Bullet - NOT found, to use BulletCollisionDetector, please install libbullet-dev")
set(HAVE_BULLET_COLLISION FALSE)
endif()

Expand Down Expand Up @@ -406,6 +430,7 @@ endif()

if(NOT BUILD_CORE_ONLY)
set(DART_DEPENDENCIES ${urdfdom_LIBRARIES}
${FLANN_LIBRARIES}
${TINYXML_LIBRARIES}
${TINYXML2_LIBRARIES}
)
Expand Down
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
### Version 5.1.3 (201X-XX-XX)

1. Switched to use btGImpactMeshShape instead of btConvexTriangleMeshShape for mesh
* [Pull request #764](https://github.com/dartsim/dart/pull/764)

1. Backported [#749](https://github.com/dartsim/dart/pull/749) to DART 5.1
* [Pull request #759](https://github.com/dartsim/dart/pull/759)

Expand Down
19 changes: 15 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,24 @@ install:

# scripts to run before build
before_build:
- cmd: if "%platform%"=="Win32" set CMAKE_GENERATOR_NAME=Visual Studio 14 2015
- cmd: if "%platform%"=="x64" set CMAKE_GENERATOR_NAME=Visual Studio 14 2015 Win64
- cmd: if "%platform%"=="Win32" set PROGRAM_FILES_PATH=Program Files (x86)
- cmd: if "%platform%"=="x64" set PROGRAM_FILES_PATH=Program Files
- cmd: if not exist "C:\%PROGRAM_FILES_PATH%\flann\include\flann\flann.hpp" (
curl -L -o flann-1.9.1.tar.gz https://github.com/mariusmuja/flann/archive/1.9.1.tar.gz &&
cmake -E tar zxf flann-1.9.1.tar.gz &&
cd flann-1.9.1 &&
md build &&
cd build &&
cmake -G "%CMAKE_GENERATOR_NAME%" -DCMAKE_BUILD_TYPE=%Configuration% .. &&
cmake --build . --target install --config %Configuration% &&
cd ..\..
) else (echo Using cached flann)
- cmd: cd C:\projects\dart
- cmd: md build
- cmd: cd build
# We generate project files for Visual Studio 12 because the boost binaries installed on the test server are for Visual Studio 12.
- cmd: if "%platform%"=="Win32" set CMAKE_GENERATOR_NAME=Visual Studio 14 2015
- cmd: if "%platform%"=="x64" set CMAKE_GENERATOR_NAME=Visual Studio 14 2015 Win64
- cmd: cmake -G "%CMAKE_GENERATOR_NAME%" -DCMAKE_BUILD_TYPE=%configuration% -DBUILD_CORE_ONLY="%BUILD_CORE_ONLY%" -DDART_BUILD_EXAMPLES="%BUILD_EXAMPLES%" -DDART_BUILD_TUTORIALS="%BUILD_TUTORIALS%" -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_LIBRARYDIR%" -DBoost_USE_STATIC_LIBS="ON" -Durdfdom_DIR="%urdfdom_DIR%" -Durdfdom_headers_DIR="%urdfdom_headers_DIR%" -DDART_MSVC_DEFAULT_OPTIONS="%MSVC_DEFAULT_OPTIONS%" ..
- cmd: cmake -G "%CMAKE_GENERATOR_NAME%" -DCMAKE_BUILD_TYPE=%configuration% -DBUILD_CORE_ONLY="%BUILD_CORE_ONLY%" -DDART_BUILD_EXAMPLES="%BUILD_EXAMPLES%" -DDART_BUILD_TUTORIALS="%BUILD_TUTORIALS%" -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_LIBRARYDIR%" -DBoost_USE_STATIC_LIBS="ON" -Durdfdom_DIR="%urdfdom_DIR%" -Durdfdom_headers_DIR="%urdfdom_headers_DIR%" -DDART_MSVC_DEFAULT_OPTIONS="%MSVC_DEFAULT_OPTIONS%" -DFLANN_INCLUDE_DIRS="C:\%PROGRAM_FILES_PATH%\flann\include" -DFLANN_LIBRARIES="C:\%PROGRAM_FILES_PATH%\flann\lib\flann_cpp_s.lib" ..

build:
project: C:\projects\dart\build\dart.sln # path to Visual Studio solution or project
Expand Down
7 changes: 6 additions & 1 deletion cmake/FindFLANN.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# This sets the following variables:
# FLANN_FOUND
# FLANN_INCLUDE_DIRS
# FLANN_LIBRARIES
# FLANN_VERSION

find_package(PkgConfig QUIET)
Expand All @@ -19,13 +20,17 @@ find_path(FLANN_INCLUDE_DIRS
HINTS ${PC_FLANN_INCLUDEDIR}
PATHS "${CMAKE_INSTALL_PREFIX}/include")

# Libraries
find_library(FLANN_LIBRARIES flann_cpp
HINTS ${PC_FLANN_LIBDIR})

# Version
set(FLANN_VERSION ${PC_FLANN_VERSION})

# Set (NAME)_FOUND if all the variables and the version are satisfied.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FLANN
FAIL_MESSAGE DEFAULT_MSG
REQUIRED_VARS FLANN_INCLUDE_DIRS
REQUIRED_VARS FLANN_INCLUDE_DIRS FLANN_LIBRARIES
VERSION_VAR FLANN_VERSION)

10 changes: 5 additions & 5 deletions dart/collision/bullet/BulletCollisionNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ BulletCollisionNode::BulletCollisionNode(dynamics::BodyNode* _bodyNode)
{
const dynamics::MeshShape* shapeMesh
= static_cast<const dynamics::MeshShape*>(shape.get());
btConvexTriangleMeshShape* btMesh = _createMesh(shapeMesh->getScale(),
shapeMesh->getMesh());
btGImpactMeshShape* btMesh = _createMesh(shapeMesh->getScale(),
shapeMesh->getMesh());
btCollisionObject* btCollObj = new btCollisionObject();

// Add user data
Expand Down Expand Up @@ -208,7 +208,7 @@ btCollisionObject*BulletCollisionNode::getBulletCollisionObject(int _i)
}

//==============================================================================
btConvexTriangleMeshShape* _createMesh(const Eigen::Vector3d& _scale,
btGImpactMeshShape* _createMesh(const Eigen::Vector3d& _scale,
const aiScene* _mesh)
{
btTriangleMesh* btMesh = new btTriangleMesh();
Expand All @@ -230,8 +230,8 @@ btConvexTriangleMeshShape* _createMesh(const Eigen::Vector3d& _scale,
}
}

btConvexTriangleMeshShape* btMeshShape =
new btConvexTriangleMeshShape(btMesh);
btGImpactMeshShape* btMeshShape = new btGImpactMeshShape(btMesh);
btMeshShape->updateBound();

return btMeshShape;
}
Expand Down
5 changes: 3 additions & 2 deletions dart/collision/bullet/BulletCollisionNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

#include <assimp/scene.h>
#include <btBulletCollisionCommon.h>
#include <bullet/BulletCollision/Gimpact/btGImpactShape.h>
#include <Eigen/Dense>

#include "dart/dynamics/SmartPointer.h"
Expand Down Expand Up @@ -91,8 +92,8 @@ class BulletCollisionNode : public CollisionNode
};

/// @brief Create Bullet mesh from assimp3 mesh
btConvexTriangleMeshShape* _createMesh(const Eigen::Vector3d& _scale,
const aiScene* _mesh);
btGImpactMeshShape* _createMesh(
const Eigen::Vector3d& _scale, const aiScene* _mesh);

} // namespace collision
} // namespace dart
Expand Down
5 changes: 5 additions & 0 deletions dart/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#cmakedefine HAVE_IPOPT 1
#cmakedefine HAVE_SNOPT 1
#cmakedefine HAVE_BULLET_COLLISION 1
#cmakedefine HAVE_FLANN 1

#define DART_ROOT_PATH "@CMAKE_SOURCE_DIR@/"
#define DART_DATA_PATH "@CMAKE_SOURCE_DIR@/data/"
Expand All @@ -54,4 +55,8 @@
#cmakedefine ASSIMP_AISCENE_CTOR_DTOR_DEFINED 1
#cmakedefine ASSIMP_AIMATERIAL_CTOR_DTOR_DEFINED 1

// Workaround for the fact that Bullet does not add the definition to
// BULLET_DEFINITIONS or generate a #cmakedefine header.
#cmakedefine BT_USE_DOUBLE_PRECISION

#endif // #ifndef DART_CONFIG_H_
2 changes: 1 addition & 1 deletion data/skel/shapes.skel
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<color>0.95 0.95 0.95</color>
</visualization_shape>
<collision_shape>
<transformation>0 0 0 0 0 0</transformation>
<transformation>0 -0.005 0 0 0 0</transformation>
<geometry>
<box>
<size>10 0.01 10</size>
Expand Down
4 changes: 2 additions & 2 deletions unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ foreach(test ${tests})
endforeach(test)

if(HAVE_IPOPT)
target_link_libraries(testOptimizer dart-optimizer-ipopt ${IPOPT_LIBRARIES})
target_link_libraries(testOptimizer dart-optimizer-ipopt)
endif(HAVE_IPOPT)

if(HAVE_NLOPT)
target_link_libraries(testOptimizer dart-optimizer-nlopt ${NLOPT_LIBRARIES})
target_link_libraries(testOptimizer dart-optimizer-nlopt)
endif(HAVE_NLOPT)

if(HAVE_SNOPT)
Expand Down
7 changes: 6 additions & 1 deletion unittests/testNearestNeighbor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@

#include <iostream>
#include <gtest/gtest.h>
#include <flann/flann.hpp>
#include <Eigen/Core>
#include <dart/dart.h>
#if HAVE_FLANN
#include <flann/flann.hpp>
#endif // HAVE_FLANN
#include "TestHelpers.h"

/* ********************************************************************************************* */
#if HAVE_FLANN
TEST(NEAREST_NEIGHBOR, 2D) {

// Build the index with the first node
Expand Down Expand Up @@ -44,6 +48,7 @@ TEST(NEAREST_NEIGHBOR, 2D) {
bool equality = equals(Vector2d(point[0], point[1]), p3, 1e-3);
EXPECT_TRUE(equality);
}
#endif // HAVE_FLANN

/* ********************************************************************************************* */
int main(int argc, char* argv[]) {
Expand Down