-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bullet-featherstone plugin (#373)
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
1 parent
09b3e44
commit cd40651
Showing
42 changed files
with
4,737 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.