271 lines
10 KiB
CMake
271 lines
10 KiB
CMake
# ========================================================
|
|
# ROOT CMakeLists.txt
|
|
# Đặt ở: Navigations/CMakeLists.txt
|
|
# ========================================================
|
|
cmake_minimum_required(VERSION 3.0.2)
|
|
project(navigations VERSION 1.0.0 LANGUAGES CXX)
|
|
|
|
# Chuẩn C++
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
# Build type
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
endif()
|
|
|
|
# Flags chung
|
|
# Warning flags - disabled to suppress warnings during build
|
|
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") # -w suppresses all warnings
|
|
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
|
|
|
message(STATUS "========================================")
|
|
message(STATUS "Building Navigations Project")
|
|
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
|
|
message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}")
|
|
message(STATUS "========================================")
|
|
|
|
# Build các packages theo thứ tự phụ thuộc
|
|
# 1. Core libraries (header-only hoặc base libraries)
|
|
|
|
if (NOT TARGET robot_time)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/robot_time)
|
|
endif()
|
|
|
|
if (NOT TARGET xmlrpcpp)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/xmlrpcpp)
|
|
endif()
|
|
|
|
if (NOT TARGET robot_cpp)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/robot_cpp)
|
|
endif()
|
|
|
|
if (NOT TARGET data_convert)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/data_convert)
|
|
endif()
|
|
|
|
if (NOT TARGET geometry2)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/geometry2)
|
|
endif()
|
|
|
|
if (NOT TARGET common_msgs)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/common_msgs)
|
|
endif()
|
|
|
|
if (NOT TARGET laser_geometry)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/laser_geometry)
|
|
endif()
|
|
|
|
if (NOT TARGET voxel_grid)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/voxel_grid)
|
|
endif()
|
|
|
|
if (NOT TARGET robot_nav_2d_msgs)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/robot_nav_2d_msgs)
|
|
endif()
|
|
|
|
if (NOT TARGET costmap_2d)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/costmap_2d)
|
|
endif()
|
|
|
|
if (NOT TARGET robot_nav_2d_utils)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/robot_nav_2d_utils)
|
|
endif()
|
|
|
|
if (NOT TARGET laser_filter)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/laser_filter)
|
|
endif()
|
|
|
|
# KHÔNG phải gói `angles` ở src/Algorithms/Libraries — đó là package khác, target tên `angles`.
|
|
# Gói này là port của ROS `angles`, project và target đều tên `robot_angles_prv`, và đó chính là
|
|
# thứ stanley_local_planner link tới. Guard phải kiểm `robot_angles_prv`, kiểm `angles` sẽ trúng
|
|
# nhầm gói kia rồi bỏ qua gói này, và link mới hỏng ở tận cuối build.
|
|
if (NOT TARGET robot_angles_prv)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/angles)
|
|
endif()
|
|
|
|
if (NOT TARGET robot_nav_core)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Navigations/Cores/robot_nav_core)
|
|
endif()
|
|
|
|
if (NOT TARGET nav_grid)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Navigations/Libraries/nav_grid)
|
|
endif()
|
|
|
|
if (NOT TARGET robot_nav_core2)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Navigations/Cores/robot_nav_core2)
|
|
endif()
|
|
|
|
if (NOT TARGET robot_nav_core_adapter)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Navigations/Cores/robot_nav_core_adapter)
|
|
endif()
|
|
|
|
if (NOT TARGET move_base_core)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Navigations/Cores/move_base_core)
|
|
endif()
|
|
|
|
if (NOT TARGET mkt_msgs)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Libraries/mkt_msgs)
|
|
endif()
|
|
|
|
if (NOT TARGET angles)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Libraries/angles)
|
|
endif()
|
|
|
|
if (NOT TARGET kalman)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Libraries/kalman)
|
|
endif()
|
|
|
|
if (NOT TARGET score_algorithm)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Cores/score_algorithm)
|
|
endif()
|
|
|
|
if (NOT TARGET mkt_plugins)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Libraries/mkt_plugins)
|
|
endif()
|
|
|
|
if (NOT TARGET mkt_algorithm)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Libraries/mkt_algorithm)
|
|
endif()
|
|
|
|
if (NOT TARGET two_points_planner)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Packages/global_planners/two_points_planner)
|
|
endif()
|
|
|
|
if (NOT TARGET custom_planner)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Packages/global_planners/custom_planner)
|
|
endif()
|
|
|
|
if (NOT TARGET dock_planner)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Packages/global_planners/dock_planner)
|
|
endif()
|
|
|
|
if (NOT TARGET pnkx_local_planner)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Packages/local_planners/pnkx_local_planner)
|
|
endif()
|
|
|
|
# Local planner đang chạy trên robot thật: cả bốn profile trong move_base_common_params.yaml đều
|
|
# trỏ `StanleyLocalPlanner`. Thiếu libstanley_local_planner.so là move_base2 chết ngay ở
|
|
# `initialize()` ("could not load the initial local planner").
|
|
if (NOT TARGET stanley_local_planner)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Packages/local_planners/stanley_local_planner)
|
|
endif()
|
|
|
|
if (NOT TARGET robot_actionlib_msgs)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Navigations/Libraries/robot_actionlib_msgs)
|
|
endif()
|
|
|
|
if (NOT TARGET robot_move_base_msgs)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Navigations/Libraries/robot_move_base_msgs)
|
|
endif()
|
|
|
|
# Mission/action/recovery framework + navigation runtime. Bốn gói này đã được đưa hẳn vào cây
|
|
# (submodule) nên add thẳng như mọi gói in-tree khác, KHÔNG đi qua pnkx_add_test_package.
|
|
#
|
|
# Thứ tự là ràng buộc thật, không phải phong cách: move_base2 tiêu thụ API của cả ba gói trên
|
|
# (ActionRunner <- action_core, RecoveryRunner <- recovery_core, MissionLayer <- mission_adapters)
|
|
# nên phải đứng cuối.
|
|
if (NOT TARGET action_core)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/action_core)
|
|
endif()
|
|
|
|
if (NOT TARGET recovery_core)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/recovery_core)
|
|
endif()
|
|
|
|
if (NOT TARGET mission_adapters)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/mission_adapters)
|
|
endif()
|
|
|
|
if (NOT TARGET move_base2_core)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Navigations/Packages/move_base2)
|
|
endif()
|
|
|
|
# 3. Packages being migrated from AMR_T800/Test
|
|
#
|
|
# Prefer the future in-tree location. Until the migration is physically done,
|
|
# keep the current sibling Test directory buildable from this root CMake file.
|
|
option(PNKX_NAV_CORE_BUILD_TEST_PACKAGES
|
|
"Build navigation packages currently kept in AMR_T800/Test"
|
|
ON)
|
|
|
|
option(PNKX_NAV_CORE_BUILD_CATKIN_TEST_PACKAGES
|
|
"Build Test packages that require a catkin workspace instead of standalone CMake"
|
|
OFF)
|
|
|
|
set(PNKX_NAV_CORE_TEST_PACKAGES_DIR ""
|
|
CACHE PATH "Directory containing the migrated navigation Test packages")
|
|
|
|
if(NOT PNKX_NAV_CORE_TEST_PACKAGES_DIR)
|
|
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Test")
|
|
set(PNKX_NAV_CORE_TEST_PACKAGES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Test")
|
|
elseif(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../Test")
|
|
set(PNKX_NAV_CORE_TEST_PACKAGES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../Test")
|
|
endif()
|
|
endif()
|
|
|
|
function(pnkx_add_test_package package_name)
|
|
set(package_dir "${PNKX_NAV_CORE_TEST_PACKAGES_DIR}/${package_name}")
|
|
if(EXISTS "${package_dir}/CMakeLists.txt")
|
|
message(STATUS "[pnkx_nav_core] Adding migrated Test package: ${package_name}")
|
|
add_subdirectory("${package_dir}" "${CMAKE_BINARY_DIR}/Test/${package_name}")
|
|
else()
|
|
message(WARNING
|
|
"[pnkx_nav_core] Test package '${package_name}' was not found in "
|
|
"'${PNKX_NAV_CORE_TEST_PACKAGES_DIR}'.")
|
|
endif()
|
|
endfunction()
|
|
|
|
if(PNKX_NAV_CORE_BUILD_TEST_PACKAGES AND NOT PNKX_NAV_CORE_TEST_PACKAGES_DIR)
|
|
# Không còn là lỗi: bốn gói từng nằm ở Test/ nay đã in-tree, nên một cây không có Test/ vẫn
|
|
# build được đầy đủ nav runtime. Chỉ những gói CHƯA di trú (planner, msgs) là bị bỏ qua.
|
|
message(STATUS
|
|
"[pnkx_nav_core] No Test package directory found — skipping the packages still kept "
|
|
"in AMR_T800/Test. Set PNKX_NAV_CORE_TEST_PACKAGES_DIR to build them.")
|
|
set(PNKX_NAV_CORE_BUILD_TEST_PACKAGES OFF)
|
|
endif()
|
|
|
|
if(PNKX_NAV_CORE_BUILD_TEST_PACKAGES)
|
|
# Foundation and message packages.
|
|
pnkx_add_test_package(angles)
|
|
pnkx_add_test_package(image_geometry)
|
|
pnkx_add_test_package(grid_map_core)
|
|
pnkx_add_test_package(vda5050_msgs)
|
|
|
|
# Planner libraries and plugins. SBPL must precede its lattice plugin.
|
|
pnkx_add_test_package(sbpl)
|
|
pnkx_add_test_package(sbpl_lattice_planner)
|
|
pnkx_add_test_package(base_local_planner)
|
|
pnkx_add_test_package(hybrid_local_planner)
|
|
pnkx_add_test_package(mppi_local_planner)
|
|
pnkx_add_test_package(priest_local_planner)
|
|
pnkx_add_test_package(stanley_local_planner)
|
|
|
|
# Supporting runtime packages and test utilities.
|
|
# action_core / recovery_core / mission_adapters / move_base2 KHÔNG còn ở đây — đã in-tree,
|
|
# add ở mục 2 bên trên.
|
|
pnkx_add_test_package(depth_image_proc)
|
|
pnkx_add_test_package(nav_test_harness)
|
|
endif()
|
|
|
|
# These packages call find_package(catkin REQUIRED ...) for T800 packages.
|
|
# Keep them outside the standalone graph until their dependencies export
|
|
# *Config.cmake files, or build them through a catkin workspace.
|
|
if(PNKX_NAV_CORE_BUILD_CATKIN_TEST_PACKAGES)
|
|
pnkx_add_test_package(deep_mpc_local_planner)
|
|
pnkx_add_test_package(nav_ros_bridge)
|
|
pnkx_add_test_package(depth_local_costmap_noetic_test)
|
|
endif()
|
|
|
|
# C API for .NET/C# integration. Target is `nav_c_api` — the guard must name the same target,
|
|
# otherwise it never matches and the subdirectory is added twice on a re-entrant configure.
|
|
if (NOT TARGET nav_c_api)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/src/APIs/c_api)
|
|
endif()
|
|
|
|
message(STATUS "========================================")
|
|
message(STATUS "All packages configured successfully")
|
|
message(STATUS "========================================")
|