update for ROS

This commit is contained in:
HiepLM 2026-01-07 16:54:53 +07:00
parent 0b01c22019
commit 540d79321b
2 changed files with 214 additions and 87 deletions

View File

@ -1,51 +1,39 @@
# --- CMake version và project name ---
cmake_minimum_required(VERSION 3.10)
project(custom_planner)
cmake_minimum_required(VERSION 3.0.2)
project(custom_planner VERSION 1.0.0 LANGUAGES CXX)
# --- C++ standard và position independent code ---
set(CMAKE_CXX_STANDARD 17) # S dng C++17
set(CMAKE_POSITION_INDEPENDENT_CODE ON) # Thư vin có th build thành shared lib
if(DEFINED CATKIN_DEVEL_PREFIX OR DEFINED CATKIN_TOPLEVEL)
set(BUILDING_WITH_CATKIN TRUE)
message(STATUS "Building custom_planner with Catkin")
# --- RPATH settings: ưu tiên thư vin build ti ch ---
# Dùng đ runtime linker tìm thư vin đã build trưc khi install
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
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)
else()
set(BUILDING_WITH_CATKIN FALSE)
message(STATUS "Building custom_planner with Standalone CMake")
endif()
# --- Dependencies ---
# Tìm các thư vin cn thiết
# find_package(tf3 REQUIRED) # Nếu dùng tf3
find_package(Eigen3 REQUIRED) # Thư vin Eigen cho toán hc
find_package(Boost REQUIRED COMPONENTS system thread filesystem) # Boost: system, thread, filesystem
# C++ Standard - must be set before find_package
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# --- Include directories ---
# Thêm các folder cha header files
include_directories(
include
${EIGEN3_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
)
# Find dependencies
find_package(Eigen3 REQUIRED)
find_package(Boost REQUIRED COMPONENTS system thread filesystem)
# --- Eigen và PCL definitions ---
add_definitions(${EIGEN3_DEFINITIONS})
if (NOT BUILDING_WITH_CATKIN)
# --- Core library: custom_planner ---
# To thư vin chính
add_library(custom_planner
src/custom_planner.cpp
src/pathway.cc
src/pose.cc
src/Curve_common.cpp
src/merge_path_calc.cpp
)
# Enable Position Independent Code
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# --- Link các thư vin ph thuc ---
target_link_libraries(custom_planner
${Boost_LIBRARIES} # Boost
# Cu hình RPATH đ tránh cycle trong runtime search path
set(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_BUILD_RPATH "${CMAKE_BINARY_DIR}")
set(PACKAGES_DIR
robot_visualization_msgs
robot_nav_msgs
robot_std_msgs
robot_geometry_msgs
tf3
robot_tf3_geometry_msgs
robot_time
@ -53,58 +41,139 @@ target_link_libraries(custom_planner
robot_costmap_2d
robot_nav_core
robot_protocol_msgs
robot_cpp
)
else()
# ========================================================
# Catkin specific configuration
# ========================================================
find_package(catkin REQUIRED COMPONENTS
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
)
# --- 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
)
if(BUILDING_WITH_CATKIN)
add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
# --- Cài đt thư vin vào h thng khi chy make install ---
install(TARGETS custom_planner
EXPORT custom_planner-targets
ARCHIVE DESTINATION lib # Thư vin tĩnh .a
LIBRARY DESTINATION lib # Thư vin đng .so
RUNTIME DESTINATION bin # File thc thi (nếu )
INCLUDES DESTINATION include # Cài đt include
)
target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
# --- Xut export set robot_costmap_2dTargets thành file CMake module ---
# --- To file lib/cmake/custom_planner/robot_costmap_2dTargets.cmake ---
# --- File này cha cu 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
)
target_link_libraries(${PROJECT_NAME}
PUBLIC ${catkin_LIBRARIES}
PRIVATE Eigen3::Eigen Boost::system Boost::thread Boost::filesystem
)
# --- Cài đt headers ---
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION include/${PROJECT_NAME}
)
else()
# # --- Plugin libraries ---
# # To các plugin shared library
# add_library(plugins
# 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_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
# target_link_libraries(plugins
# custom_planner
# ${Boost_LIBRARIES}
# yaml-cpp
# robot_time
# )
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
View 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>