update for ROS
This commit is contained in:
parent
0b01c22019
commit
540d79321b
243
CMakeLists.txt
243
CMakeLists.txt
|
|
@ -1,51 +1,39 @@
|
||||||
# --- CMake version và project name ---
|
cmake_minimum_required(VERSION 3.0.2)
|
||||||
cmake_minimum_required(VERSION 3.10)
|
project(custom_planner VERSION 1.0.0 LANGUAGES CXX)
|
||||||
project(custom_planner)
|
|
||||||
|
|
||||||
# --- C++ standard và position independent code ---
|
if(DEFINED CATKIN_DEVEL_PREFIX OR DEFINED CATKIN_TOPLEVEL)
|
||||||
set(CMAKE_CXX_STANDARD 17) # Sử dụng C++17
|
set(BUILDING_WITH_CATKIN TRUE)
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON) # Thư viện có thể build thành shared lib
|
message(STATUS "Building custom_planner with Catkin")
|
||||||
|
|
||||||
# --- RPATH settings: ưu tiên thư viện build tại chỗ ---
|
else()
|
||||||
# Dùng để runtime linker tìm thư viện đã build trước khi install
|
set(BUILDING_WITH_CATKIN FALSE)
|
||||||
set(CMAKE_SKIP_BUILD_RPATH FALSE)
|
message(STATUS "Building custom_planner with Standalone CMake")
|
||||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
endif()
|
||||||
set(CMAKE_BUILD_RPATH "${CMAKE_BINARY_DIR}/custom_planner")
|
|
||||||
set(CMAKE_INSTALL_RPATH "${CMAKE_BINARY_DIR}/custom_planner")
|
|
||||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
||||||
|
|
||||||
# --- Dependencies ---
|
# C++ Standard - must be set before find_package
|
||||||
# Tìm các thư viện cần thiết
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
# find_package(tf3 REQUIRED) # Nếu dùng tf3
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
find_package(Eigen3 REQUIRED) # Thư viện Eigen cho toán học
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
find_package(Boost REQUIRED COMPONENTS system thread filesystem) # Boost: system, thread, filesystem
|
|
||||||
|
|
||||||
# --- Include directories ---
|
# Find dependencies
|
||||||
# Thêm các folder chứa header files
|
find_package(Eigen3 REQUIRED)
|
||||||
include_directories(
|
find_package(Boost REQUIRED COMPONENTS system thread filesystem)
|
||||||
include
|
|
||||||
${EIGEN3_INCLUDE_DIRS}
|
|
||||||
${Boost_INCLUDE_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
# --- Eigen và PCL definitions ---
|
if (NOT BUILDING_WITH_CATKIN)
|
||||||
add_definitions(${EIGEN3_DEFINITIONS})
|
|
||||||
|
|
||||||
# --- Core library: custom_planner ---
|
# Enable Position Independent Code
|
||||||
# Tạo thư viện chính
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
add_library(custom_planner
|
|
||||||
src/custom_planner.cpp
|
|
||||||
src/pathway.cc
|
|
||||||
src/pose.cc
|
|
||||||
src/Curve_common.cpp
|
|
||||||
src/merge_path_calc.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
# --- Link các thư viện phụ thuộc ---
|
# Cấu hình RPATH để tránh cycle trong runtime search path
|
||||||
target_link_libraries(custom_planner
|
set(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE)
|
||||||
${Boost_LIBRARIES} # Boost
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||||
|
set(CMAKE_BUILD_RPATH "${CMAKE_BINARY_DIR}")
|
||||||
|
|
||||||
|
set(PACKAGES_DIR
|
||||||
robot_visualization_msgs
|
robot_visualization_msgs
|
||||||
robot_nav_msgs
|
robot_nav_msgs
|
||||||
|
robot_std_msgs
|
||||||
|
robot_geometry_msgs
|
||||||
tf3
|
tf3
|
||||||
robot_tf3_geometry_msgs
|
robot_tf3_geometry_msgs
|
||||||
robot_time
|
robot_time
|
||||||
|
|
@ -53,58 +41,139 @@ target_link_libraries(custom_planner
|
||||||
robot_costmap_2d
|
robot_costmap_2d
|
||||||
robot_nav_core
|
robot_nav_core
|
||||||
robot_protocol_msgs
|
robot_protocol_msgs
|
||||||
)
|
robot_cpp
|
||||||
|
|
||||||
# --- Include directories cho target ---
|
|
||||||
target_include_directories(custom_planner
|
|
||||||
PUBLIC
|
|
||||||
${Boost_INCLUDE_DIRS} # Boost headers
|
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> # Khi build từ source
|
|
||||||
$<INSTALL_INTERFACE:include/${PROJECT_NAME}> # Khi install
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# --- Cài đặt thư viện vào hệ thống khi chạy make install ---
|
else()
|
||||||
install(TARGETS custom_planner
|
|
||||||
EXPORT custom_planner-targets
|
# ========================================================
|
||||||
ARCHIVE DESTINATION lib # Thư viện tĩnh .a
|
# Catkin specific configuration
|
||||||
LIBRARY DESTINATION lib # Thư viện động .so
|
# ========================================================
|
||||||
RUNTIME DESTINATION bin # File thực thi (nếu có)
|
find_package(catkin REQUIRED COMPONENTS
|
||||||
INCLUDES DESTINATION include # Cài đặt include
|
robot_visualization_msgs
|
||||||
|
robot_nav_msgs
|
||||||
|
robot_std_msgs
|
||||||
|
robot_geometry_msgs
|
||||||
|
tf3
|
||||||
|
robot_tf3_geometry_msgs
|
||||||
|
robot_time
|
||||||
|
data_convert
|
||||||
|
robot_costmap_2d
|
||||||
|
robot_nav_core
|
||||||
|
robot_protocol_msgs
|
||||||
|
robot_cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
catkin_package(
|
||||||
|
INCLUDE_DIRS include
|
||||||
|
LIBRARIES ${PROJECT_NAME}
|
||||||
|
CATKIN_DEPENDS robot_visualization_msgs robot_nav_msgs robot_std_msgs robot_geometry_msgs tf3 robot_tf3_geometry_msgs robot_time data_convert robot_costmap_2d robot_nav_core robot_protocol_msgs robot_cpp
|
||||||
|
DEPENDS Eigen3 Boost
|
||||||
|
)
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
include
|
||||||
|
${catkin_INCLUDE_DIRS}
|
||||||
|
${EIGEN3_INCLUDE_DIRS}
|
||||||
|
${Boost_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# ========================================================
|
||||||
|
# Libraries
|
||||||
|
# ========================================================
|
||||||
|
add_library(${PROJECT_NAME} SHARED
|
||||||
|
src/custom_planner.cpp
|
||||||
|
src/pathway.cc
|
||||||
|
src/pose.cc
|
||||||
|
src/Curve_common.cpp
|
||||||
|
src/merge_path_calc.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# --- Xuất export set robot_costmap_2dTargets thành file CMake module ---
|
if(BUILDING_WITH_CATKIN)
|
||||||
# --- Tạo file lib/cmake/custom_planner/robot_costmap_2dTargets.cmake ---
|
add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
||||||
# --- File này chứa cấu hình giúp project khác có thể dùng ---
|
|
||||||
# --- Find_package(custom_planner REQUIRED) ---
|
|
||||||
# --- Target_link_libraries(my_app PRIVATE custom_planner::custom_planner) ---
|
|
||||||
install(EXPORT custom_planner-targets
|
|
||||||
FILE custom_planner-targets.cmake
|
|
||||||
NAMESPACE custom_planner::
|
|
||||||
DESTINATION lib/cmake/custom_planner
|
|
||||||
)
|
|
||||||
|
|
||||||
# --- Cài đặt headers ---
|
target_include_directories(${PROJECT_NAME}
|
||||||
install(DIRECTORY include/${PROJECT_NAME}/
|
PUBLIC
|
||||||
DESTINATION include/${PROJECT_NAME}
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
)
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
|
|
||||||
# # --- Plugin libraries ---
|
target_link_libraries(${PROJECT_NAME}
|
||||||
# # Tạo các plugin shared library
|
PUBLIC ${catkin_LIBRARIES}
|
||||||
# add_library(plugins
|
PRIVATE Eigen3::Eigen Boost::system Boost::thread Boost::filesystem
|
||||||
# SHARED
|
)
|
||||||
# plugins/static_layer.cpp
|
|
||||||
# plugins/obstacle_layer.cpp
|
|
||||||
# plugins/inflation_layer.cpp
|
|
||||||
# plugins/voxel_layer.cpp
|
|
||||||
# plugins/critical_layer.cpp
|
|
||||||
# plugins/directional_layer.cpp
|
|
||||||
# plugins/preferred_layer.cpp
|
|
||||||
# plugins/unpreferred_layer.cpp
|
|
||||||
# )
|
|
||||||
|
|
||||||
# target_link_libraries(plugins
|
else()
|
||||||
# custom_planner
|
|
||||||
# ${Boost_LIBRARIES}
|
target_include_directories(${PROJECT_NAME}
|
||||||
# yaml-cpp
|
PUBLIC
|
||||||
# robot_time
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
# )
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT_NAME}
|
||||||
|
PUBLIC
|
||||||
|
${PACKAGES_DIR}
|
||||||
|
PRIVATE
|
||||||
|
Eigen3::Eigen Boost::system Boost::thread Boost::filesystem
|
||||||
|
)
|
||||||
|
|
||||||
|
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||||
|
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||||
|
BUILD_RPATH "${CMAKE_BINARY_DIR}"
|
||||||
|
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib"
|
||||||
|
)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# ========================================================
|
||||||
|
# Install
|
||||||
|
# ========================================================
|
||||||
|
if(BUILDING_WITH_CATKIN)
|
||||||
|
## Mark libraries for installation
|
||||||
|
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html
|
||||||
|
install(TARGETS ${PROJECT_NAME}
|
||||||
|
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
|
||||||
|
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
|
||||||
|
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
|
||||||
|
)
|
||||||
|
|
||||||
|
## Mark cpp header files for installation
|
||||||
|
install(DIRECTORY include/${PROJECT_NAME}/
|
||||||
|
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
|
||||||
|
FILES_MATCHING PATTERN "*.h"
|
||||||
|
PATTERN ".svn" EXCLUDE
|
||||||
|
)
|
||||||
|
|
||||||
|
else()
|
||||||
|
|
||||||
|
install(TARGETS ${PROJECT_NAME}
|
||||||
|
EXPORT ${PROJECT_NAME}-targets
|
||||||
|
ARCHIVE DESTINATION lib
|
||||||
|
LIBRARY DESTINATION lib
|
||||||
|
RUNTIME DESTINATION bin
|
||||||
|
)
|
||||||
|
|
||||||
|
# Export targets
|
||||||
|
install(EXPORT ${PROJECT_NAME}-targets
|
||||||
|
FILE ${PROJECT_NAME}-targets.cmake
|
||||||
|
NAMESPACE ${PROJECT_NAME}::
|
||||||
|
DESTINATION lib/cmake/${PROJECT_NAME}
|
||||||
|
)
|
||||||
|
|
||||||
|
## Mark cpp header files for installation
|
||||||
|
install(DIRECTORY include/${PROJECT_NAME}/
|
||||||
|
DESTINATION include
|
||||||
|
FILES_MATCHING PATTERN "*.h"
|
||||||
|
PATTERN ".svn" EXCLUDE
|
||||||
|
)
|
||||||
|
|
||||||
|
# Print configuration info
|
||||||
|
message(STATUS "=================================")
|
||||||
|
message(STATUS "Project: ${PROJECT_NAME}")
|
||||||
|
message(STATUS "Version: ${PROJECT_VERSION}")
|
||||||
|
message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}")
|
||||||
|
message(STATUS "Dependencies: robot_visualization_msgs, robot_nav_msgs, robot_std_msgs, robot_geometry_msgs, tf3, robot_tf3_geometry_msgs, robot_time, data_convert, robot_costmap_2d, robot_nav_core, robot_protocol_msgs, robot_cpp, Eigen3, Boost")
|
||||||
|
message(STATUS "=================================")
|
||||||
|
endif()
|
||||||
|
|
|
||||||
58
package.xml
Normal file
58
package.xml
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
<package>
|
||||||
|
<name>custom_planner</name>
|
||||||
|
<version>0.7.10</version>
|
||||||
|
<description>
|
||||||
|
custom_planner is the second generation of the transform library, which lets
|
||||||
|
the user keep track of multiple coordinate frames over time. custom_planner
|
||||||
|
maintains the relationship between coordinate frames in a tree
|
||||||
|
structure buffered in time, and lets the user transform points,
|
||||||
|
vectors, etc between any two coordinate frames at any desired
|
||||||
|
point in time.
|
||||||
|
</description>
|
||||||
|
<author>Tully Foote</author>
|
||||||
|
<author>Eitan Marder-Eppstein</author>
|
||||||
|
<author>Wim Meeussen</author>
|
||||||
|
<maintainer email="tfoote@osrfoundation.org">Tully Foote</maintainer>
|
||||||
|
<license>BSD</license>
|
||||||
|
|
||||||
|
<url type="website">http://www.ros.org/wiki/custom_planner</url>
|
||||||
|
|
||||||
|
<buildtool_depend version_gte="0.5.68">catkin</buildtool_depend>
|
||||||
|
|
||||||
|
<build_depend>robot_costmap_2d</build_depend>
|
||||||
|
<run_depend>robot_costmap_2d</run_depend>
|
||||||
|
|
||||||
|
<build_depend>robot_nav_core</build_depend>
|
||||||
|
<run_depend>robot_nav_core</run_depend>
|
||||||
|
|
||||||
|
<build_depend>robot_geometry_msgs</build_depend>
|
||||||
|
<run_depend>robot_geometry_msgs</run_depend>
|
||||||
|
|
||||||
|
<build_depend>robot_nav_msgs</build_depend>
|
||||||
|
<run_depend>robot_nav_msgs</run_depend>
|
||||||
|
|
||||||
|
<build_depend>robot_std_msgs</build_depend>
|
||||||
|
<run_depend>robot_std_msgs</run_depend>
|
||||||
|
|
||||||
|
<build_depend>tf3</build_depend>
|
||||||
|
<run_depend>tf3</run_depend>
|
||||||
|
|
||||||
|
<build_depend>robot_tf3_geometry_msgs</build_depend>
|
||||||
|
<run_depend>robot_tf3_geometry_msgs</run_depend>
|
||||||
|
|
||||||
|
<build_depend>robot_cpp</build_depend>
|
||||||
|
<run_depend>robot_cpp</run_depend>
|
||||||
|
|
||||||
|
<build_depend>robot_protocol_msgs</build_depend>
|
||||||
|
<run_depend>robot_protocol_msgs</run_depend>
|
||||||
|
|
||||||
|
<build_depend>robot_time</build_depend>
|
||||||
|
<run_depend>robot_time</run_depend>
|
||||||
|
|
||||||
|
<build_depend>robot_visualization_msgs</build_depend>
|
||||||
|
<run_depend>robot_visualization_msgs</run_depend>
|
||||||
|
|
||||||
|
<build_depend>data_convert</build_depend>
|
||||||
|
<run_depend>data_convert</run_depend>
|
||||||
|
|
||||||
|
</package>
|
||||||
Loading…
Reference in New Issue
Block a user