Skip to content

Commit

Permalink
Merge pull request #75 from ju6ge/casadi
Browse files Browse the repository at this point in the history
RBDL version 3.1.2 with Casadi \o/
  • Loading branch information
ju6ge committed Sep 21, 2021
2 parents f1a2622 + a0c1f2c commit 7787c19
Show file tree
Hide file tree
Showing 50 changed files with 3,272 additions and 295 deletions.
136 changes: 133 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,135 @@
debug
build
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# dotenv
.env

# virtualenv
.venv
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject
Pipfile.lock
.idea

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# Visual code
.vscode

# Visual studio
.vs

# CMake
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
CMakeLists.txt.user

# Specific project files and folders
build*
debug*
install*
*.user*
includes/numpy
S2MSource
pyomeca
release*
*.DS_Store

doc/html
**/build
CMakeLists.txt.user
29 changes: 29 additions & 0 deletions CMake/FindCasadi.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# - Find Casadi
# Find the native Casadi includes and libraries
#
# Casadi_INCLUDE_DIR - where to find casadi.hpp, etc.
# Casadi_LIBRARIES - List of libraries when using Casadi.
# Casadi_FOUND - True if Casadi is found.

if (Casadi_INCLUDE_DIR)
# Already in cache, be silent
set (Casadi_FIND_QUIETLY TRUE)
endif (Casadi_INCLUDE_DIR)

find_path (Casadi_INCLUDE_DIR "casadi.hpp"
PATHS ${CMAKE_INSTALL_PREFIX}/include/casadi ${CMAKE_INSTALL_PREFIX}/Library/include/casadi
)
find_library (Casadi_LIBRARY NAMES casadi
PATHS ${CMAKE_INSTALL_PREFIX}/lib ${CMAKE_INSTALL_PREFIX}/Library/lib
)

# handle the QUIETLY and REQUIRED arguments and set Casadi_FOUND to TRUE if
# all listed variables are TRUE
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (Casadi DEFAULT_MSG
Casadi_LIBRARY
Casadi_INCLUDE_DIR
)



72 changes: 50 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.10)

SET ( RBDL_VERSION_MAJOR 3 )
SET ( RBDL_VERSION_MINOR 0 )
SET ( RBDL_VERSION_PATCH 0 )
SET ( RBDL_VERSION_MINOR 1 )
SET ( RBDL_VERSION_PATCH 2 )
SET ( RBDL_VERSION
${RBDL_VERSION_MAJOR}.${RBDL_VERSION_MINOR}.${RBDL_VERSION_PATCH}
)
Expand All @@ -16,7 +16,6 @@ LIST( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake )

INCLUDE_DIRECTORIES (
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/include
)


Expand All @@ -36,15 +35,6 @@ IF(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
ENDIF()

# Find and use the system's Eigen3 library
FIND_PACKAGE (Eigen3 3.0.0)

IF (NOT EIGEN3_FOUND)
MESSAGE (WARNING "Could not find Eigen3 on your system. Please install it!")
ENDIF (NOT EIGEN3_FOUND)

INCLUDE_DIRECTORIES (${EIGEN3_INCLUDE_DIR})

IF (MSVC)
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj /permissive- /std:c++17")
ENDIF (MSVC)
Expand All @@ -61,6 +51,9 @@ ELSE( ${CMAKE_VERSION} VERSION_LESS 3.12.0 )
ENDIF( ${CMAKE_VERSION} VERSION_LESS 3.12.0 )


SET (RBDL_BUILD_COMPILER_ID ${CMAKE_CXX_COMPILER_ID})
SET (RBDL_BUILD_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION})

# Options
SET (RBDL_BUILD_STATIC_DEFAULT OFF)
OPTION (RBDL_BUILD_STATIC "Build statically linked library (otherwise dynamiclly linked)" ${RBDL_BUILD_STATIC_DEFAULT})
Expand All @@ -76,10 +69,17 @@ OPTION (RBDL_BUILD_ADDON_MUSCLE "Build the muscle library" OFF)
OPTION (RBDL_BUILD_ADDON_MUSCLE_FITTING "Build muscle library fitting functions (requires Ipopt)" OFF)
OPTION (RBDL_BUILD_EXECUTABLES "Build addon executables, disable this if you only want to build the libraries." ON)
OPTION (RBDL_USE_PYTHON_2 "Use python 2 instead of python 3" OFF)
OPTION (RBDL_USE_CASADI_MATH "Use the CasADi backend" OFF)

SET (RBDL_BUILD_COMPILER_ID ${CMAKE_CXX_COMPILER_ID})
SET (RBDL_BUILD_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION})

# Find and use the system's Eigen3 library
FIND_PACKAGE (Eigen3 3.0.0)

IF (NOT EIGEN3_FOUND)
MESSAGE (WARNING "Could not find Eigen3 on your system. Please install it!")
ENDIF (NOT EIGEN3_FOUND)

INCLUDE_DIRECTORIES (${EIGEN3_INCLUDE_DIR})

# Addons
IF (RBDL_BUILD_ADDON_URDFREADER)
Expand All @@ -90,7 +90,9 @@ IF (RBDL_BUILD_ADDON_BENCHMARK)
ADD_SUBDIRECTORY ( addons/benchmark )
ENDIF (RBDL_BUILD_ADDON_BENCHMARK)


IF (RBDL_USE_CASADI_MATH)
ADD_SUBDIRECTORY( casadi )
ENDIF (RBDL_USE_CASADI_MATH)

IF(RBDL_BUILD_ADDON_MUSCLE)
SET(RBDL_BUILD_ADDON_GEOMETRY ON CACHE BOOL "Build the geometry library" FORCE)
Expand Down Expand Up @@ -138,16 +140,13 @@ SET ( RBDL_SOURCES
src/Kinematics.cc
)

#IF (MSVC AND NOT RBDL_BUILD_STATIC)
# MESSAGE (FATAL_ERROR, "Compiling RBDL as a DLL currently not supported. Please enable RBDL_BUILD_STATIC.")
#ENDIF (MSVC AND NOT RBDL_BUILD_STATIC)

# Static / dynamic builds
IF (RBDL_BUILD_STATIC)
ADD_LIBRARY ( rbdl-static STATIC ${RBDL_SOURCES} )
IF (NOT WIN32)
TARGET_INCLUDE_DIRECTORIES(rbdl-static PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include)
IF (NOT MSVC)
SET_TARGET_PROPERTIES ( rbdl-static PROPERTIES PREFIX "lib")
ENDIF (NOT WIN32)
ENDIF (NOT MSVC)
SET_TARGET_PROPERTIES ( rbdl-static PROPERTIES OUTPUT_NAME "rbdl")

IF (RBDL_BUILD_ADDON_LUAMODEL)
Expand All @@ -160,6 +159,11 @@ IF (RBDL_BUILD_STATIC)
rbdl_urdfreader-static
)
ENDIF (RBDL_BUILD_ADDON_URDFREADER)
IF (RBDL_USE_CASADI_MATH)
TARGET_LINK_LIBRARIES ( rbdl-static
${Casadi_LIBRARY}
)
ENDIF (RBDL_USE_CASADI_MATH)

INSTALL (TARGETS rbdl-static
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand All @@ -168,11 +172,18 @@ IF (RBDL_BUILD_STATIC)
)
ELSE (RBDL_BUILD_STATIC)
ADD_LIBRARY ( rbdl SHARED ${RBDL_SOURCES} )
TARGET_INCLUDE_DIRECTORIES(rbdl PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include)
SET_TARGET_PROPERTIES ( rbdl PROPERTIES
VERSION ${RBDL_VERSION}
SOVERSION ${RBDL_SO_VERSION}
)

IF (RBDL_USE_CASADI_MATH)
TARGET_LINK_LIBRARIES ( rbdl
${Casadi_LIBRARY}
)
ENDIF (RBDL_USE_CASADI_MATH)

INSTALL (TARGETS rbdl
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand Down Expand Up @@ -217,14 +228,31 @@ INSTALL ( FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rbdl )

# pkg-config
CONFIGURE_FILE (
${CMAKE_CURRENT_SOURCE_DIR}/rbdl.pc.cmake
${CMAKE_CURRENT_SOURCE_DIR}/share/rbdl.pc.cmake
${CMAKE_CURRENT_BINARY_DIR}/rbdl.pc @ONLY
)
INSTALL (
FILES ${CMAKE_CURRENT_BINARY_DIR}/rbdl.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)

# Prepare share
if(WIN32 AND NOT CYGWIN)
set(CMAKE_SHARE_DIR cmake)
else()
set(CMAKE_SHARE_DIR lib/cmake/RBDL)
endif()
include(CMakePackageConfigHelpers)
configure_package_config_file(
share/RBDLConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/RBDLConfig.cmake
INSTALL_DESTINATION ${CMAKE_SHARE_DIR}
)
INSTALL (
FILES ${CMAKE_CURRENT_BINARY_DIR}/RBDLConfig.cmake
DESTINATION ${CMAKE_SHARE_DIR}
)

# Packaging
SET(CPACK_GENERATOR "DEB")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Martin Felis <[email protected]>")
Expand Down
4 changes: 3 additions & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,8 @@ INPUT = ./src \
addons/muscle/MuscleFunctionFactory.h \
addons/muscle/TorqueMuscleFunctionFactory.h \
addons/muscle/TorqueMuscleFittingToolkit.h \
./include/rbdl
./include/rbdl \
casadi/info.h

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
Expand Down Expand Up @@ -772,6 +773,7 @@ EXAMPLE_PATH = doc \
examples/luamodel \
examples/simple \
examples/python \
examples


# If the value of the EXAMPLE_PATH tag contains directories, you can use the
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,10 @@ at which point you will see full list of build options for RBDL. We recommend th
- Install Ipopt. One of the easier ways to do this is to follow these instructions from [Ipopt's online documentation](https://www.coin-or.org/Ipopt/documentation/node12.html#SECTION00042300000000000000) which guides you through the process. Instructions to build the code appear in the README located in the Ipopt folder
- Configure RBDL's cmake file with these flags set to 'On'
```
RBDL_BUILD_ADDON_GEOMETRY ON
RBDL_BUILD_ADDON_LUAMODEL ON
RBDL_BUILD_ADDON_MUSCLE ON
RBDL_BUILD_ADDON_MUSCLE_FITTING ON
RBDL_BUILD_ADDON_GEOMETRY ON
RBDL_BUILD_ADDON_LUAMODEL ON
RBDL_BUILD_ADDON_MUSCLE ON
RBDL_BUILD_ADDON_MUSCLE_FITTING ON
```

- Set the CUSTOM_IPOPT_PATH to the main Ipopt directory.
Expand Down
2 changes: 1 addition & 1 deletion addons/geometry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ FILE ( GLOB headers

INSTALL ( FILES ${GEOMETRY_HEADERS}
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/rbdl/addons/geometry
${CMAKE_INSTALL_INCLUDEDIR}/rbdl/addons/geometry
)
4 changes: 2 additions & 2 deletions addons/luamodel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ ELSE (RBDL_BUILD_STATIC)
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
)
ENDIF (RBDL_BUILD_STATIC)

FILE ( GLOB headers
Expand All @@ -128,5 +128,5 @@ FILE ( GLOB headers

INSTALL ( FILES ${headers}
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/rbdl/addons/luamodel
${CMAKE_INSTALL_INCLUDEDIR}/rbdl/addons/luamodel
)
Loading

0 comments on commit 7787c19

Please sign in to comment.