Skip to content

Commit

Permalink
Add bullet-featherstone plugin (#373)
Browse files Browse the repository at this point in the history
This PR adds a gz-physics-bullet-featherstone-plugin which wraps the Featherstone API of the bullet physics engine. This is created as a separate plugin from gz-physics-bullet-plugin because the API of Bullet's Featherstone dynamics is different enough that there isn't really feature parity or easy interchangeability between them. Users will need to choose whether they are willing to settle for fewer features in exchange for the better performance of Bullet's Featherstone implementation.


Signed-off-by: Louise Poubel <[email protected]>
Signed-off-by: Michael X. Grey <[email protected]>
Signed-off-by: ahcorde <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
Co-authored-by: Louise Poubel <[email protected]>
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
Co-authored-by: Steve Peters <[email protected]>
Co-authored-by: Michael Carroll <[email protected]>
  • Loading branch information
5 people authored Oct 15, 2022
1 parent 09b3e44 commit cd40651
Show file tree
Hide file tree
Showing 42 changed files with 4,737 additions and 58 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ gz_find_package(DART
# Find bullet for the bullet plugin wrapper
gz_find_package(GzBullet
VERSION 2.87
REQUIRED_BY bullet
REQUIRED_BY bullet bullet-featherstone
PKGCONFIG bullet
PKGCONFIG_VER_COMPARISON >=)

Expand All @@ -101,7 +101,7 @@ set(GZ_PHYSICS_ENGINE_INSTALL_DIR
# Configure the build
#============================================================================
gz_configure_build(QUIT_IF_BUILD_ERRORS
COMPONENTS sdf heightmap mesh dartsim tpe bullet)
COMPONENTS sdf heightmap mesh dartsim tpe bullet bullet-featherstone)


#============================================================================
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ See the [installation tutorial](https://gazebosim.org/api/physics/5.0/installati

# Usage

Please refer to the [examples directory](https://github.com/gazebosim/gz-physics/raw/ign-physics6/examples/).
Please refer to the [examples directory](https://github.com/gazebosim/gz-physics/raw/gz-physics6/examples/).

# Documentation

Expand All @@ -90,7 +90,7 @@ You can also generate the documentation from a clone of this repository by follo
2. Clone the repository
```
git clone https://github.com/gazebosim/gz-physics -b ign-physics6
git clone https://github.com/gazebosim/gz-physics -b gz-physics6
```
3. Configure and build the documentation.
Expand Down
46 changes: 46 additions & 0 deletions bullet-featherstone/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This component expresses custom features of the bullet plugin, which can
# expose native bullet data types.
gz_add_component(bullet-featherstone INTERFACE
DEPENDS_ON_COMPONENTS sdf mesh
GET_TARGET_NAME features)

link_directories(${BULLET_LIBRARY_DIRS})
target_link_libraries(${features} INTERFACE GzBullet::GzBullet)

gz_get_libsources_and_unittests(sources test_sources)

# TODO(MXG): Think about an gz_add_plugin(~) macro for ign-cmake
set(engine_name bullet-featherstone-plugin)
gz_add_component(${engine_name}
SOURCES ${sources}
DEPENDS_ON_COMPONENTS bullet-featherstone
GET_TARGET_NAME bullet_plugin)

target_link_libraries(${bullet_plugin}
PUBLIC
${features}
${PROJECT_LIBRARY_TARGET_NAME}-sdf
${PROJECT_LIBRARY_TARGET_NAME}-mesh
gz-common${GZ_COMMON_VER}::gz-common${GZ_COMMON_VER}
gz-math${GZ_MATH_VER}::eigen3)

# Note that plugins are currently being installed in 2 places: /lib and the engine-plugins dir
install(TARGETS ${bullet_plugin} DESTINATION ${GZ_PHYSICS_ENGINE_INSTALL_DIR})

# The library created by `gz_add_component` includes the ign-physics version
# (i.e. libgz-physics1-name-plugin.so), but for portability,
# we also install an unversioned symlink into the same versioned folder.
set(versioned ${CMAKE_SHARED_LIBRARY_PREFIX}${bullet_plugin}${CMAKE_SHARED_LIBRARY_SUFFIX})
set(unversioned ${CMAKE_SHARED_LIBRARY_PREFIX}${PROJECT_NAME_NO_VERSION_LOWER}-${engine_name}${CMAKE_SHARED_LIBRARY_SUFFIX})
if (WIN32)
# disable MSVC inherit via dominance warning
target_compile_options(${bullet_plugin} PUBLIC "/wd4250")
INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy
${GZ_PHYSICS_ENGINE_INSTALL_DIR}\/${versioned}
${GZ_PHYSICS_ENGINE_INSTALL_DIR}\/${unversioned})")
else()
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink ${versioned} ${unversioned})
INSTALL(FILES ${PROJECT_BINARY_DIR}/${unversioned} DESTINATION ${GZ_PHYSICS_ENGINE_INSTALL_DIR})
endif()
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink ${versioned} ${unversioned})
INSTALL(FILES ${PROJECT_BINARY_DIR}/${unversioned} DESTINATION ${GZ_PHYSICS_ENGINE_INSTALL_DIR})
45 changes: 45 additions & 0 deletions bullet-featherstone/src/Base.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (C) 2022 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#include "Base.hh"

#include <utility>

namespace gz {
namespace physics {
namespace bullet_featherstone {

/////////////////////////////////////////////////
WorldInfo::WorldInfo(std::string name_)
: name(std::move(name_))
{
this->collisionConfiguration =
std::make_unique<btDefaultCollisionConfiguration>();
this->dispatcher =
std::make_unique<btCollisionDispatcher>(collisionConfiguration.get());
this->broadphase = std::make_unique<btDbvtBroadphase>();
this->solver = std::make_unique<btMultiBodyConstraintSolver>();
this->world = std::make_unique<btMultiBodyDynamicsWorld>(
dispatcher.get(), broadphase.get(), solver.get(),
collisionConfiguration.get());

btGImpactCollisionAlgorithm::registerAlgorithm(dispatcher.get());
}

} // namespace bullet_featherstone
} // namespace physics
} // namespace gz
Loading

0 comments on commit cd40651

Please sign in to comment.