Skip to content

Optionally enable an embedded copy of DART 6.10 Open Robotics fork #274

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

Draft
wants to merge 21 commits into
base: ign-physics3
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
91 changes: 79 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,85 @@ ign_find_package(sdformat10

#--------------------------------------
# Find dartsim for the dartsim plugin wrapper
ign_find_package(DART
COMPONENTS
collision-ode
utils
utils-urdf
EXTRA_ARGS CONFIG
VERSION 6.9
REQUIRED_BY dartsim
PKGCONFIG dart
PKGCONFIG_VER_COMPARISON >=)

# respect user explicit values and also provide a default value for Ubuntu Focal
# to make ground vehicles to work properly
set(DEFAULT_VENDOR_DART OFF)
if(NOT DEFINED USE_VENDOR_DART)
find_program(LSB_RELEASE_EXEC lsb_release)

if(LSB_RELEASE_EXEC)
execute_process(COMMAND ${LSB_RELEASE_EXEC} -rs
OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(LSB_RELEASE_ID_SHORT STREQUAL "20.04")
message(STATUS "DETECTED Ubuntu 20.04, default USE_VENDOR_DART set to "
"ON to make ground vehicles to work properly")
set(DEFAULT_VENDOR_DART ON)
endif()
endif()
endif()

option(USE_VENDOR_DART "Use internal Open Robotics fork of DART" ${DEFAULT_VENDOR_DART})

find_program(LSB_RELEASE_EXEC lsb_release)
if(USE_VENDOR_DART)
include(ExternalProject)

set(DART_VENDOR_INSTALL_DIR ${CMAKE_BINARY_DIR}/vendor/dart/install)
set(DART_VENDOR_INCLUDE_DIRS "${DART_VENDOR_INSTALL_DIR}/include")
set(DART_VENDOR_LIBRARY_DIR "${DART_VENDOR_INSTALL_DIR}/lib")
# Three libraries needed
set(DART_VENDOR_LIBRARY_PATH
"${DART_VENDOR_LIBRARY_DIR}/libdart.so.6.10.0")
set(DART_VENDOR_LIBRARY_LINK_PATH
"${DART_VENDOR_LIBRARY_DIR}/libdart.so.6.10")
add_library(dart SHARED IMPORTED)
set_target_properties(dart PROPERTIES
IMPORTED_LOCATION ${DART_VENDOR_LIBRARY_PATH})

set(DART_ODEL_VENDOR_LIBRARY_PATH
"${DART_VENDOR_LIBRARY_DIR}/libdart-external-odelcpsolver.so.6.10.0")
set(DART_ODEL_VENDOR_LIBRARY_LINK_PATH
"${DART_VENDOR_LIBRARY_DIR}/libdart-external-odelcpsolver.so.6.10")
add_library(dart_external_odelcpsolver SHARED IMPORTED)
set_target_properties(dart_external_odelcpsolver PROPERTIES
IMPORTED_LOCATION ${DART_ODEL_VENDOR_LIBRARY_PATH})

set(DART_COLLISION_VENDOR_LIBRARY_PATH
"${DART_VENDOR_LIBRARY_DIR}/libdart-collision-ode.so.6.10.0")
set(DART_COLLISION_VENDOR_LIBRARY_LINK_PATH
"${DART_VENDOR_LIBRARY_DIR}/libdart-collision-ode.so.6.10")
add_library(dart_collision_ode SHARED IMPORTED)
set_target_properties(dart_collision_ode PROPERTIES
IMPORTED_LOCATION ${DART_COLLISION_VENDOR_LIBRARY_PATH})

set(DART_LIBRARIES dart dart_external_odelcpsolver dart_collision_ode)

ExternalProject_Add(dart_project
DOWNLOAD_COMMAND ""
UPDATE_COMMAND ""
PREFIX ${CMAKE_BINARY_DIR}/vendor/dart
INSTALL_DIR ${DART_VENDOR_INSTALL_DIR}
SOURCE_DIR ${CMAKE_SOURCE_DIR}/vendor/dart
# Seems a bug since INSTALL_DIR and SOURCE_DIR should handle it
# https://gitlab.kitware.com/cmake/cmake/-/issues/18790
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${DART_VENDOR_INSTALL_DIR}
)

add_definitions(-DDART_VERSION=6.10.0)
else()
ign_find_package(DART
COMPONENTS
collision-ode
utils
utils-urdf
EXTRA_ARGS CONFIG
VERSION 6.9
REQUIRED_BY dartsim
PKGCONFIG dart
PKGCONFIG_VER_COMPARISON >=)
endif()

#--------------------------------------
# Find bullet for the bullet plugin wrapper
Expand All @@ -80,8 +149,6 @@ ign_find_package(IgnBullet
PKGCONFIG bullet
PKGCONFIG_VER_COMPARISON >=)

message(STATUS "-------------------------------------------\n")

set(IGNITION_PHYSICS_RESOURCE_DIR "${CMAKE_SOURCE_DIR}/resources")

# Plugin install dirs
Expand Down
37 changes: 36 additions & 1 deletion dartsim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@ ign_add_component(dartsim INTERFACE
GET_TARGET_NAME features)

target_link_libraries(${features} INTERFACE ${DART_LIBRARIES})
target_include_directories(${features} SYSTEM INTERFACE ${DART_INCLUDE_DIRS})

if(USE_VENDOR_DART)
target_include_directories(${features} INTERFACE
$<BUILD_INTERFACE:${DART_VENDOR_INCLUDE_DIRS}>
$<BUILD_INTERFACE:${BULLET_INCLUDE_DIRS}>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>
$<INSTALL_INTERFACE:${IGN_INCLUDE_INSTALL_DIR_FULL}/vendor/dart>)
else()
target_include_directories(${features} SYSTEM INTERFACE ${DART_INCLUDE_DIRS})
endif()

if (MSVC)
# needed by DART, see https://github.com/dartsim/dart/issues/753
target_compile_options(${features} INTERFACE "/permissive-")
Expand All @@ -25,6 +35,11 @@ ign_add_component(${engine_name}
DEPENDS_ON_COMPONENTS dartsim
GET_TARGET_NAME dartsim_plugin)

add_dependencies(${PROJECT_LIBRARY_TARGET_NAME}-dartsim-plugin dart)
if(USE_VENDOR_DART)
add_dependencies(${PROJECT_LIBRARY_TARGET_NAME}-dartsim-plugin dart_project)
endif()

target_link_libraries(${dartsim_plugin}
PUBLIC
${features}
Expand All @@ -40,6 +55,22 @@ target_link_libraries(${dartsim_plugin}
# Note that plugins are currently being installed in 2 places: /lib and the engine-plugins dir
install(TARGETS ${dartsim_plugin} DESTINATION ${IGNITION_PHYSICS_ENGINE_INSTALL_DIR})

if(USE_VENDOR_DART)
# Set RPATH/RUNPATH to point to engine install dir. This makes possible
# to find embedded dart libraries withotu interfere with oter system directories
set_target_properties(${dartsim_plugin} PROPERTIES
INSTALL_RPATH ${IGNITION_PHYSICS_ENGINE_INSTALL_DIR})

foreach(lib ${DART_VENDOR_LIBRARY_PATH} ${DART_VENDOR_LIBRARY_LINK_PATH}
${DART_COLLISION_VENDOR_LIBRARY_PATH} ${DART_COLLISION_VENDOR_LIBRARY_LINK_PATH}
${DART_ODEL_VENDOR_LIBRARY_PATH} ${DART_ODEL_VENDOR_LIBRARY_LINK_PATH})
# install(FILES ${lib}
# DESTINATION ${CMAKE_INSTALL_PREFIX}/${IGN_LIB_INSTALL_DIR})
install(FILES ${lib}
DESTINATION ${IGNITION_PHYSICS_ENGINE_INSTALL_DIR})
endforeach()
endif()

# The library created by `ign_add_component` includes the ign-physics version
# (i.e. libignition-physics1-name-plugin.so), but for portability,
# we also install an unversioned symlink into the same versioned folder.
Expand Down Expand Up @@ -69,6 +100,10 @@ ign_build_tests(
TEST_LIST tests)

foreach(test ${tests})
if(USE_VENDOR_DART)
set_tests_properties(${test} PROPERTIES
ENVIRONMENT "LD_LIBRARY_PATH=${DART_VENDOR_LIBRARY_DIR}")
endif()

target_compile_definitions(${test} PRIVATE
"dartsim_plugin_LIB=\"$<TARGET_FILE:${dartsim_plugin}>\""
Expand Down
Binary file added vendor/dart/.CMakeLists.txt.swn
Binary file not shown.
Binary file added vendor/dart/.CMakeLists.txt.swo
Binary file not shown.
Loading