Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
194 changes: 147 additions & 47 deletions ocs2_robotic_examples/ocs2_legged_robot/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,40 @@ project(ocs2_legged_robot)

# Generate compile_commands.json for clang tools
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CATKIN_PACKAGE_DEPENDENCIES
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)
find_package(ocs2_core REQUIRED)
find_package(ocs2_mpc REQUIRED)
find_package(ocs2_robotic_tools REQUIRED)
find_package(ocs2_oc REQUIRED)
find_package(ocs2_sqp REQUIRED)
find_package(ocs2_thirdparty REQUIRED)
find_package(ocs2_ddp REQUIRED)
find_package(ocs2_msgs REQUIRED)
find_package(ocs2_pinocchio_interface REQUIRED)
find_package(ocs2_centroidal_model REQUIRED)
find_package(ocs2_ros_interfaces REQUIRED)
find_package(ocs2_robotic_assets REQUIRED)
find_package(OpenMP REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
find_package(urdf REQUIRED)
find_package(kdl_parser REQUIRED)
find_package(robot_state_publisher REQUIRED)
find_package(visualization_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(std_srvs REQUIRED)

set(AMENT_PACKAGE_DEPENDENCIES
ocs2_core
ocs2_oc
ocs2_ddp
Expand All @@ -14,38 +46,41 @@ set(CATKIN_PACKAGE_DEPENDENCIES
ocs2_pinocchio_interface
ocs2_centroidal_model
ocs2_robotic_assets
ocs2_thirdparty
ocs2_msgs
ocs2_ros_interfaces
rclcpp
kdl_parser
tf2
urdf
robot_state_publisher
tf2_ros
tf2_geometry_msgs
std_srvs
# trajectory_msgs
visualization_msgs
pinocchio
)

find_package(catkin REQUIRED COMPONENTS
${CATKIN_PACKAGE_DEPENDENCIES}
)

find_package(Boost REQUIRED COMPONENTS
system
filesystem
log
log_setup
)

find_package(Eigen3 3.3 REQUIRED NO_MODULE)

find_package(PkgConfig REQUIRED)
pkg_check_modules(pinocchio REQUIRED pinocchio)
if ( EXISTS "/opt/openrobots/lib/libpinocchio.so")
else()
message(FATAL_ERROR "Install Pinocchio first. Instructions: https://stack-of-tasks.github.io/pinocchio/download.html")
endif()

###################################
## catkin specific configuration ##
###################################
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -fopenmp -std=c++11 -Wfatal-errors")

catkin_package(
INCLUDE_DIRS
include
${EIGEN3_INCLUDE_DIRS}
LIBRARIES
${PROJECT_NAME}
CATKIN_DEPENDS
${CATKIN_PACKAGE_DEPENDENCIES}
DEPENDS
Boost
pinocchio
)
list(APPEND CMAKE_PREFIX_PATH "/opt/openrobots/")
find_package(pinocchio REQUIRED)

###########
## Build ##
Expand All @@ -54,7 +89,7 @@ catkin_package(
# Resolve for the package path at compile time.
configure_file (
"${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/package_path.h.in"
"${PROJECT_BINARY_DIR}/include/${PROJECT_NAME}/package_path.h" @ONLY
"${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME}/package_path.h" @ONLY
)

set(FLAGS
Expand Down Expand Up @@ -99,16 +134,30 @@ add_library(${PROJECT_NAME}
src/LeggedRobotInterface.cpp
src/LeggedRobotPreComputation.cpp
)
add_dependencies(${PROJECT_NAME}
${catkin_EXPORTED_TARGETS}

set_target_properties(${PROJECT_NAME}
PROPERTIES INSTALL_RPATH "/opt/openrobots/lib"
)

target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

target_link_libraries(${PROJECT_NAME}
${catkin_LIBRARIES}
Eigen3::Eigen
${Boost_LIBRARIES}
${pinocchio_LIBRARIES}
dl
)

ament_target_dependencies(
ocs2_legged_robot
${AMENT_PACKAGE_DEPENDENCIES}
)

target_compile_options(${PROJECT_NAME} PUBLIC ${FLAGS})
target_compile_definitions(${PROJECT_NAME} PRIVATE BOOST_LOG_DYN_LINK=true)

#########################
### CLANG TOOLING ###
Expand All @@ -129,36 +178,87 @@ endif(cmake_clang_tools_FOUND)
## Install ##
#############

install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
# install(TARGETS ${PROJECT_NAME}
# EXPORT export_${PROJECT_NAME}
# ARCHIVE DESTINATION lib
# LIBRARY DESTINATION lib
# RUNTIME DESTINATION bin
# )

install(
TARGETS ${PROJECT_NAME}
EXPORT export_${PROJECT_NAME}
RUNTIME DESTINATION lib/${PROJECT_NAME}
INCLUDES DESTINATION include
)


install(DIRECTORY include/
DESTINATION include
)

install(DIRECTORY config
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
DESTINATION share/${PROJECT_NAME}
)

ament_export_include_directories(include)

ament_export_libraries(${PROJECT_NAME})

ament_export_targets(
export_${PROJECT_NAME}
)

ament_export_dependencies(ocs2_core)
ament_export_dependencies(ocs2_mpc)
ament_export_dependencies(ocs2_robotic_tools)
ament_export_dependencies(ocs2_oc)
ament_export_dependencies(ocs2_thirdparty)
ament_export_dependencies(ocs2_ddp)
ament_export_dependencies(ocs2_msgs)
ament_export_dependencies(ocs2_pinocchio_interface)
ament_export_dependencies(ocs2_centroidal_model)
ament_export_dependencies(ocs2_ros_interfaces)
ament_export_dependencies(tf2)
ament_export_dependencies(urdf)
ament_export_dependencies(kdl_parser)
ament_export_dependencies(robot_state_publisher)
ament_export_dependencies(visualization_msgs)
ament_export_dependencies(nav_msgs)
ament_export_dependencies(std_srvs)

#############
## Testing ##
#############

catkin_add_gtest(${PROJECT_NAME}_test
test/AnymalFactoryFunctions.cpp
test/constraint/testEndEffectorLinearConstraint.cpp
test/constraint/testFrictionConeConstraint.cpp
test/constraint/testZeroForceConstraint.cpp
)
target_include_directories(${PROJECT_NAME}_test PRIVATE
test/include
${PROJECT_BINARY_DIR}/include
)
target_link_libraries(${PROJECT_NAME}_test
gtest_main
${PROJECT_NAME}
${catkin_LIBRARIES}
${Boost_LIBRARIES}
)
target_compile_options(${PROJECT_NAME}_test PRIVATE ${FLAGS})
# if(BUILD_TESTING)

# # Include linting tests
# find_package(ament_lint_auto REQUIRED)
# find_package(ament_cmake_gtest REQUIRED)
# ament_lint_auto_find_test_dependencies()

# # test_time_triggered_rollout
# ament_add_gtest(${PROJECT_NAME}_test
# test/AnymalFactoryFunctions.cpp
# test/constraint/testEndEffectorLinearConstraint.cpp
# test/constraint/testFrictionConeConstraint.cpp
# test/constraint/testZeroForceConstraint.cpp
# )

# target_link_libraries(${PROJECT_NAME}_test
# ${PROJECT_NAME}
# ${Boost_LIBRARIES}
# gtest_main
# )

# target_compile_options(${PROJECT_NAME}_test PRIVATE ${FLAGS})

# target_include_directories(${PROJECT_NAME}_test PUBLIC
# $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test/include>
# $<INSTALL_INTERFACE:include>
# )
# endif(BUILD_TESTING)

ament_package()

29 changes: 17 additions & 12 deletions ocs2_robotic_examples/ocs2_legged_robot/package.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<package format="2">
<?xml version="2.0"?>
<package>
<name>ocs2_legged_robot</name>
<version>0.0.1</version>
<description>The ocs2_legged_robot package</description>
Expand All @@ -12,15 +12,20 @@

<buildtool_depend>ament_cmake</buildtool_depend>

<depend>ocs2_core</depend>
<depend>ocs2_oc</depend>
<depend>ocs2_ddp</depend>
<depend>ocs2_mpc</depend>
<depend>ocs2_sqp</depend>
<depend>ocs2_robotic_assets</depend>
<depend>ocs2_robotic_tools</depend>
<depend>ocs2_pinocchio_interface</depend>
<depend>ocs2_centroidal_model</depend>
<depend>pinocchio</depend>
<build_depend>ocs2_core</build_depend>
<build_depend>ocs2_oc</build_depend>
<build_depend>ocs2_ddp</build_depend>
<build_depend>ocs2_mpc</build_depend>
<build_depend>ocs2_sqp</build_depend>
<build_depend>ocs2_msgs</build_depend>
<build_depend>ocs2_robotic_assets</build_depend>
<build_depend>ocs2_robotic_tools</build_depend>
<build_depend>ocs2_pinocchio_interface</build_depend>
<build_depend>ocs2_ros_interfaces</build_depend>
<build_depend>ocs2_centroidal_model</build_depend>
<build_depend>pinocchio</build_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Loading