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.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 dng C++17 set(BUILDING_WITH_CATKIN TRUE)
set(CMAKE_POSITION_INDEPENDENT_CODE ON) # Thư vin có th build thành shared lib message(STATUS "Building custom_planner with Catkin")
# --- RPATH settings: ưu tiên thư vin build ti ch --- else()
# Dùng đ runtime linker tìm thư vin đã 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ư vin cn 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ư vin Eigen cho toán hc 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 cha 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
# To thư vin 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ư vin ph thuc --- # Cu 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
)
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 --- if(BUILDING_WITH_CATKIN)
target_include_directories(custom_planner add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
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ư vin vào h thng khi chy make install --- target_include_directories(${PROJECT_NAME}
install(TARGETS custom_planner PUBLIC
EXPORT custom_planner-targets $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
ARCHIVE DESTINATION lib # Thư vin tĩnh .a $<INSTALL_INTERFACE:include>
LIBRARY DESTINATION lib # Thư vin đng .so )
RUNTIME DESTINATION bin # File thc thi (nếu )
INCLUDES DESTINATION include # Cài đt include
)
# --- Xut export set robot_costmap_2dTargets thành file CMake module --- target_link_libraries(${PROJECT_NAME}
# --- To file lib/cmake/custom_planner/robot_costmap_2dTargets.cmake --- PUBLIC ${catkin_LIBRARIES}
# --- File này cha cu hình giúp project khác có th dùng --- PRIVATE Eigen3::Eigen Boost::system Boost::thread Boost::filesystem
# --- 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 --- else()
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION include/${PROJECT_NAME}
)
# # --- Plugin libraries --- target_include_directories(${PROJECT_NAME}
# # To các plugin shared library PUBLIC
# add_library(plugins $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
# SHARED $<INSTALL_INTERFACE:include>
# 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 target_link_libraries(${PROJECT_NAME}
# custom_planner PUBLIC
# ${Boost_LIBRARIES} ${PACKAGES_DIR}
# yaml-cpp PRIVATE
# robot_time 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>