diff --git a/CMakeLists.txt b/CMakeLists.txt index 48026ef..44f277e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0.2) project(robot_base_local_planner VERSION 1.0.0 LANGUAGES CXX) # ======================================================== -# Detect Catkin or Standalone +# Detect build mode # ======================================================== if(DEFINED CATKIN_DEVEL_PREFIX OR DEFINED CATKIN_TOPLEVEL) set(BUILDING_WITH_CATKIN TRUE) @@ -24,53 +24,15 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) add_compile_options(-Wall -Wextra -Wpedantic) # ======================================================== -# Dependencies +# Common dependencies # ======================================================== find_package(Boost REQUIRED COMPONENTS thread) find_package(Eigen3 REQUIRED) # ======================================================== -# Catkin configuration -# ======================================================== -if(BUILDING_WITH_CATKIN) - - find_package(catkin REQUIRED COMPONENTS - robot_angles - robot_costmap_2d - robot_std_msgs - robot_geometry_msgs - robot_sensor_msgs - robot_nav_msgs - robot_cpp - tf3 - robot_tf3_geometry_msgs - robot_voxel_grid - data_convert - ) - - catkin_package( - INCLUDE_DIRS include - LIBRARIES ${PROJECT_NAME} - CATKIN_DEPENDS - robot_angles - robot_costmap_2d - robot_std_msgs - robot_geometry_msgs - robot_sensor_msgs - robot_nav_msgs - robot_cpp - tf3 - robot_tf3_geometry_msgs - robot_voxel_grid - data_convert - DEPENDS Boost Eigen3 - ) - -else() - -# ======================================================== -# Standalone configuration +# Standalone mode # ======================================================== +if(NOT BUILDING_WITH_CATKIN) set(CMAKE_POSITION_INDEPENDENT_CODE ON) @@ -78,20 +40,79 @@ else() set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) set(CMAKE_BUILD_RPATH "${CMAKE_BINARY_DIR}") + # ⚠️ placeholder libraries set(PACKAGES_DIR - robot_angles + robot_angles_prv robot_costmap_2d robot_std_msgs robot_geometry_msgs robot_sensor_msgs robot_nav_msgs robot_cpp - tf3 robot_tf3_geometry_msgs robot_voxel_grid data_convert ) + find_library(TF3_LIBRARY + NAMES tf3 + PATHS /usr/lib /usr/local/lib /usr/lib/x86_64-linux-gnu + ) + + if(NOT TF3_LIBRARY) + message(FATAL_ERROR "❌ tf3 library not found") + endif() + +# ======================================================== +# Catkin mode +# ======================================================== +else() + + find_package(catkin REQUIRED COMPONENTS + robot_angles_prv + robot_costmap_2d + robot_std_msgs + robot_geometry_msgs + robot_sensor_msgs + robot_nav_msgs + robot_cpp + robot_tf3_geometry_msgs + robot_voxel_grid + data_convert + ) + + find_library(TF3_LIBRARY + NAMES tf3 + PATHS /usr/lib /usr/local/lib /usr/lib/x86_64-linux-gnu + ) + + if(NOT TF3_LIBRARY) + message(FATAL_ERROR "❌ tf3 library not found") + endif() + + catkin_package( + INCLUDE_DIRS include + LIBRARIES ${PROJECT_NAME} + CATKIN_DEPENDS + robot_angles_prv + robot_costmap_2d + robot_std_msgs + robot_geometry_msgs + robot_sensor_msgs + robot_nav_msgs + robot_cpp + robot_tf3_geometry_msgs + robot_voxel_grid + data_convert + DEPENDS Boost Eigen3 + ) + + include_directories( + include + ${catkin_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} + ) + endif() # ======================================================== @@ -129,18 +150,7 @@ add_library(${PROJECT_NAME} SHARED ) # ======================================================== -# Include directories -# ======================================================== -target_include_directories(${PROJECT_NAME} - - PUBLIC - $ - $ - -) - -# ======================================================== -# Dependencies +# Catkin linking # ======================================================== if(BUILDING_WITH_CATKIN) @@ -148,6 +158,12 @@ if(BUILDING_WITH_CATKIN) ${catkin_EXPORTED_TARGETS} ) + target_include_directories(${PROJECT_NAME} + PUBLIC + $ + $ + ) + target_link_libraries(${PROJECT_NAME} PUBLIC @@ -156,10 +172,20 @@ if(BUILDING_WITH_CATKIN) PRIVATE Boost::thread Eigen3::Eigen + ${TF3_LIBRARY} ) +# ======================================================== +# Standalone linking +# ======================================================== else() + target_include_directories(${PROJECT_NAME} + PUBLIC + $ + $ + ) + target_link_libraries(${PROJECT_NAME} PUBLIC @@ -168,6 +194,7 @@ else() PRIVATE Boost::thread Eigen3::Eigen + ${TF3_LIBRARY} ) set_target_properties(${PROJECT_NAME} PROPERTIES @@ -192,14 +219,22 @@ if(BUILDING_WITH_CATKIN) install(DIRECTORY include/${PROJECT_NAME}/ DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} + FILES_MATCHING PATTERN "*.h" ) + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/plugins.xml) + install(FILES plugins.xml + DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} + ) + endif() + else() install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets - LIBRARY DESTINATION lib ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin ) install(EXPORT ${PROJECT_NAME}-targets @@ -210,13 +245,13 @@ else() install(DIRECTORY include/${PROJECT_NAME}/ DESTINATION include + FILES_MATCHING PATTERN "*.h" ) - message(STATUS "=================================") - message(STATUS "Project: ${PROJECT_NAME}") - message(STATUS "Version: ${PROJECT_VERSION}") - message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}") - message(STATUS "Libraries: ${PROJECT_NAME}") - message(STATUS "=================================") + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/plugins.xml) + install(FILES plugins.xml + DESTINATION share/${PROJECT_NAME} + ) + endif() endif() diff --git a/include/robot_base_local_planner/goal_functions.h b/include/robot_base_local_planner/goal_functions.h index 7505f8a..6ca1477 100644 --- a/include/robot_base_local_planner/goal_functions.h +++ b/include/robot_base_local_planner/goal_functions.h @@ -48,7 +48,7 @@ #include #include -#include +#include #include #include diff --git a/package.xml b/package.xml index dcd631e..d84f049 100644 --- a/package.xml +++ b/package.xml @@ -23,7 +23,7 @@ libconsole-bridge-dev robot_tf3_geometry_msgs - robot_angles + robot_angles_prv robot_costmap_2d eigen robot_geometry_msgs @@ -37,7 +37,7 @@ data_convert robot_tf3_geometry_msgs - robot_angles + robot_angles_prv robot_costmap_2d eigen robot_geometry_msgs diff --git a/src/goal_functions.cpp b/src/goal_functions.cpp index 474b69d..5bfb89a 100644 --- a/src/goal_functions.cpp +++ b/src/goal_functions.cpp @@ -52,7 +52,7 @@ namespace robot_base_local_planner { double getGoalOrientationAngleDifference(const robot_geometry_msgs::PoseStamped& global_pose, double goal_th) { double yaw = data_convert::getYaw(global_pose.pose.orientation); - return robot_angles::shortest_angular_distance(yaw, goal_th); + return robot_angles_prv::shortest_angular_distance(yaw, goal_th); } // void publishPlan(const std::vector& path, const ros::Publisher& pub) { diff --git a/src/trajectory_planner.cpp b/src/trajectory_planner.cpp index 52624f3..9f9e3ce 100644 --- a/src/trajectory_planner.cpp +++ b/src/trajectory_planner.cpp @@ -40,7 +40,7 @@ #include #include #include -#include +#include @@ -378,7 +378,7 @@ namespace robot_base_local_planner{ if (lineCost(cell_x, goal_cell_x, cell_y, goal_cell_y) >= 0) { double gx, gy; costmap_.mapToWorld(goal_cell_x, goal_cell_y, gx, gy); - return fabs(angles::shortest_angular_distance(heading, atan2(gy - y, gx - x))); + return fabs(robot_angles_prv::shortest_angular_distance(heading, atan2(gy - y, gx - x))); } } } @@ -742,7 +742,7 @@ namespace robot_base_local_planner{ dist = hypot(x - escape_x_, y - escape_y_); if(dist > escape_reset_dist_ || - fabs(angles::shortest_angular_distance(escape_theta_, theta)) > escape_reset_theta_){ + fabs(robot_angles_prv::shortest_angular_distance(escape_theta_, theta)) > escape_reset_theta_){ escaping_ = false; } @@ -839,7 +839,7 @@ namespace robot_base_local_planner{ } dist = hypot(x - escape_x_, y - escape_y_); - if(dist > escape_reset_dist_ || fabs(angles::shortest_angular_distance(escape_theta_, theta)) > escape_reset_theta_) { + if(dist > escape_reset_dist_ || fabs(robot_angles_prv::shortest_angular_distance(escape_theta_, theta)) > escape_reset_theta_) { escaping_ = false; } @@ -890,7 +890,7 @@ namespace robot_base_local_planner{ dist = hypot(x - escape_x_, y - escape_y_); if (dist > escape_reset_dist_ || - fabs(angles::shortest_angular_distance(escape_theta_, theta)) > escape_reset_theta_) { + fabs(robot_angles_prv::shortest_angular_distance(escape_theta_, theta)) > escape_reset_theta_) { escaping_ = false; } @@ -998,4 +998,3 @@ namespace robot_base_local_planner{ }; -