diff --git a/examples/boxes/CMakeLists.txt b/examples/boxes/CMakeLists.txt index 444b2dfbfee04..ca226d839c86c 100644 --- a/examples/boxes/CMakeLists.txt +++ b/examples/boxes/CMakeLists.txt @@ -4,8 +4,8 @@ get_filename_component(example_name ${CMAKE_CURRENT_LIST_DIR} NAME) project(${example_name}) -set(required_components utils-urdf gui-osg) -set(required_libraries dart dart-utils-urdf dart-gui-osg) +set(required_components collision-bullet utils-urdf gui-osg) +set(required_libraries dart dart-collision-bullet dart-utils-urdf dart-gui-osg) if(DART_IN_SOURCE_BUILD) dart_build_example_in_source(${example_name} LINK_LIBRARIES ${required_libraries}) diff --git a/examples/boxes/main.cpp b/examples/boxes/main.cpp index 7acfa1dd2cd62..13c8b6bb02931 100644 --- a/examples/boxes/main.cpp +++ b/examples/boxes/main.cpp @@ -32,6 +32,8 @@ #include +#include + #include #include @@ -60,6 +62,7 @@ using namespace dart; dynamics::CollisionAspect, dynamics::DynamicsAspect>(boxShape); shapeNode->getVisualAspect()->setColor(color); + shapeNode->getDynamicsAspect()->setRestitutionCoeff(0.9); // Put the body into position Eigen::Isometry3d tf = Eigen::Isometry3d::Identity(); @@ -74,6 +77,10 @@ int main() // Create an empty world auto world = simulation::World::create(); + // Set collision detector type + world->getConstraintSolver()->setCollisionDetector( + collision::BulletCollisionDetector::create()); + // Create dim x dim x dim boxes auto dim = 5; for (auto i = 0; i < dim; ++i) { @@ -81,7 +88,7 @@ int main() for (auto k = 0; k < dim; ++k) { auto x = i - dim / 2; auto y = j - dim / 2; - auto z = k + 1; + auto z = k + 5; auto position = Eigen::Vector3d(x, y, z); auto size = Eigen::Vector3d(0.9, 0.9, 0.9); auto color = Eigen::Vector3d( @@ -104,6 +111,7 @@ int main() dynamics::DynamicsAspect>( std::make_shared(Eigen::Vector3d(25.0, 25.0, 0.1))); groundShapeNode->getVisualAspect()->setColor(dart::Color::LightGray()); + groundShapeNode->getDynamicsAspect()->setRestitutionCoeff(0.9); world->addSkeleton(ground); // Wrap a WorldNode around it @@ -134,8 +142,8 @@ int main() // Adjust the viewpoint of the Viewer viewer.getCameraManipulator()->setHomePosition( - ::osg::Vec3(15.0f, 15.0f, 10.0f), - ::osg::Vec3(0.00f, 0.00f, 2.50f), + ::osg::Vec3(20.0f, 20.0f, 15.0f), + ::osg::Vec3(0.00f, 0.00f, 3.00f), ::osg::Vec3(0, 0, 1.0f)); // We need to re-dirty the CameraManipulator by passing it into the viewer diff --git a/tests/benchmark/integration/CMakeLists.txt b/tests/benchmark/integration/CMakeLists.txt index e4a1a12753506..4288272e62a02 100644 --- a/tests/benchmark/integration/CMakeLists.txt +++ b/tests/benchmark/integration/CMakeLists.txt @@ -34,22 +34,27 @@ dart_benchmarks( bm_empty.cpp ) -dart_benchmarks( - TYPE BM_INTEGRATION - SOURCES - bm_boxes.cpp - LINK_LIBRARIES - dart -) +if(TARGET dart-collision-bullet) + + dart_benchmarks( + TYPE BM_INTEGRATION + SOURCES + bm_boxes.cpp + LINK_LIBRARIES + dart + dart-collision-bullet + ) + +endif() if(TARGET dart-utils) -dart_benchmarks( - TYPE BM_INTEGRATION - SOURCES - bm_kinematics.cpp - LINK_LIBRARIES - dart-utils -) + dart_benchmarks( + TYPE BM_INTEGRATION + SOURCES + bm_kinematics.cpp + LINK_LIBRARIES + dart-utils + ) endif() diff --git a/tests/benchmark/integration/bm_boxes.cpp b/tests/benchmark/integration/bm_boxes.cpp index 474244a6eae9e..ca61f00147636 100644 --- a/tests/benchmark/integration/bm_boxes.cpp +++ b/tests/benchmark/integration/bm_boxes.cpp @@ -32,6 +32,10 @@ #include +#include + +#include + #include #include @@ -63,6 +67,7 @@ namespace { dynamics::CollisionAspect, dynamics::DynamicsAspect>(boxShape); shapeNode->getVisualAspect()->setColor(color); + shapeNode->getDynamicsAspect()->setRestitutionCoeff(0.9); // Put the body into position Eigen::Isometry3d tf = Eigen::Isometry3d::Identity(); @@ -77,13 +82,17 @@ namespace { // Create an empty world auto world = simulation::World::create(); + // Set collision detector type + world->getConstraintSolver()->setCollisionDetector( + collision::BulletCollisionDetector::create()); + // Create dim x dim x dim boxes for (auto i = 0u; i < dim; ++i) { for (auto j = 0u; j < dim; ++j) { for (auto k = 0u; k < dim; ++k) { auto x = i - dim / 2; auto y = j - dim / 2; - auto z = k + 1; + auto z = k + 5; auto position = Eigen::Vector3d(x, y, z); auto size = Eigen::Vector3d(0.9, 0.9, 0.9); auto color = Eigen::Vector3d( @@ -106,6 +115,7 @@ namespace { dynamics::DynamicsAspect>( std::make_shared(Eigen::Vector3d(10.0, 10.0, 0.1))); groundShapeNode->getVisualAspect()->setColor(dart::Color::LightGray()); + groundShapeNode->getDynamicsAspect()->setRestitutionCoeff(0.9); world->addSkeleton(ground); return world; @@ -115,7 +125,7 @@ namespace { static void BM_RunBoxes(benchmark::State& state) { - const auto steps = 1000u; + const auto steps = 2000u; auto world = createWorld(state.range(0)); for (auto _ : state) {