pnkx_nav_core 1.0 — every package with a remote is a submodule, and the root CMake builds them

A single commit on an orphan branch: the whole tree as it should land on a
robot, with no history from the branch it grew out of.

The rule applied: a package that has its own remote becomes a submodule; a
package that only ever lived inside this repository stays as ordinary files.
That comes to 29 submodules, 18 registered here for the first time. They were
sitting in the tree as plain clones, which looks right locally and is empty on
the robot - a clone of this repository would have carried the directory names
and none of the contents.

.gitignore is fixed at the source rather than patched per path. The rule
**/[Pp]ackages/* comes from the Visual Studio template and targets NuGet's
generated packages/ folder; here Packages/ is a SOURCE directory, so it hid
whole packages from git status - and a missing package then becomes invisible
to exactly the command you would use to look for one. It cost move_base2,
dock_pattern_action and sbpl_recovery, and sbpl_recovery surfaced only by
walking the tree for .git directories and diffing against .gitmodules. The
exception now re-includes src/*/Packages/** wholesale, placed immediately after
the NuGet rule so the build-artifact rules further down still win. Listing
paths one by one is what let one slip in the first place.

The root CMakeLists.txt described a tree that no longer exists. Its second half
was a migration shim that looked for a sibling Test/ directory from AMR_T800 and
added packages out of it; PNKX_NAV_CORE_BUILD_TEST_PACKAGES defaults to ON, so
with the migration finished it would have hit FATAL_ERROR at configure time.
That is gone, and the 18 packages are added in dependency order at their real
in-tree paths.

Two guard names are traps worth naming, because a guard that never matches adds
the subdirectory twice on a re-entrant configure:
  - src/Libraries/angles is project robot_angles_prv, and a DIFFERENT package
    called angles lives at src/Algorithms/Libraries/angles. Both are in the
    tree; guarding on `angles` would silently skip the first.
  - dock_pattern_action's library target is dock_pattern_action_handler, and
    move_base2's is move_base2_core.

sbpl_recovery and dock_pattern_action call find_package(catkin REQUIRED) at top
level with no standalone branch, so they sit behind
PNKX_NAV_CORE_BUILD_CATKIN_ONLY_PACKAGES, OFF, with a message naming why. They
still build under catkin_make, which does not go through this file. Pulling
them into the standalone graph fails with "Could not find recovery_core", which
misleads: recovery_core IS in the tree and was added above, but the catkin
branch wants a recovery_coreConfig.cmake that a standalone build never
produces.

grid_map_core and image_geometry were added because hybrid_local_planner and
depth_image_proc link robot_grid_map_core and robot_image_geometry, and neither
was in the tree - found by scanning every CMakeLists for internal library names
and diffing against the targets the tree defines, then confirmed by the build.

Every submodule points at the tip of the branch it was already pinned to, not
blindly at main. costmap_2d stays on dev_cam_intel; that branch exists for a
reason, and this tree carries field calibration that does not belong on main.

config/ is flattened into config/runtime/, matching the layout the nav core
reads. The .zip snapshots of old package states are gone - manual backups, not
build inputs.

Verified: cmake configure returns 0 and a full build returns 0, producing 46
shared libraries.
This commit is contained in:
2026-08-27 10:09:25 +07:00
commit 70caf52530
486 changed files with 72704 additions and 0 deletions

293
CMakeLists.txt Normal file
View File

@@ -0,0 +1,293 @@
# ========================================================
# 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()
# Port của ROS `angles`. KHÔNG phải gói `angles` ở src/Algorithms/Libraries — đó là package khác,
# target tên `angles`, và cả hai cùng có mặt trong cây. Project lẫn target của gói này đều tên
# `robot_angles_prv`, nên guard phải kiểm ĐÚNG tên đó: kiểm `angles` sẽ trúng gói kia và gói này
# lặng lẽ không bao giờ được add.
if (NOT TARGET robot_angles_prv)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/angles)
endif()
# Lõi hình học thuần, không phụ thuộc gói nào trong cây ngoài robot_cpp. Đặt sớm vì
# dock_pattern_detector khớp đường tròn trên chính đoạn thẳng mà gói này trích ra.
if (NOT TARGET robot_line_extraction)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/robot_line_extraction)
endif()
if (NOT TARGET dock_pattern_detector)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/dock_pattern_detector)
endif()
# Lõi grid map. hybrid_local_planner link thẳng vào `robot_grid_map_core`, nên nó phải có trước.
# Project và target đều tên `robot_grid_map_core`, không phải `grid_map_core`.
if (NOT TARGET robot_grid_map_core)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/grid_map_core)
endif()
# Port của ROS `image_geometry`. Project và target đều tên `robot_image_geometry`, không phải
# `image_geometry` — guard phải kiểm đúng tên đó.
if (NOT TARGET robot_image_geometry)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/image_geometry)
endif()
# Phải đứng SAU robot_image_geometry: nhánh standalone của nó link thẳng vào target đó.
if (NOT TARGET robot_depth_image_proc)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/depth_image_proc)
endif()
# Kho cảm biến thô dùng chung. move_base2 ĐẨY vào đây từ bên trong addLaserScan/addPointCloud2/...,
# còn bộ dò dock và (sau này) RL planner ĐỌC ra — nên nó phải có trước cả hai.
if (NOT TARGET robot_sensor_ports)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/robot_sensor_ports)
endif()
# Bộ giải lattice. sbpl_lattice_planner link vào nó, nên thứ tự này là ràng buộc thật.
if (NOT TARGET sbpl)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/sbpl)
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()
# Phải đứng SAU `sbpl`: đây là plugin bọc bộ giải đó.
if (NOT TARGET sbpl_lattice_planner)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Packages/global_planners/sbpl_lattice_planner)
endif()
if (NOT TARGET pnkx_local_planner)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Packages/local_planners/pnkx_local_planner)
endif()
# Ba local planner hiện thực interface robot_nav_core2::LocalPlanner, được gọi tới qua
# LocalPlannerAdapter. Đều cần robot_nav_core2 + robot_costmap_2d đã có ở trên.
#
# ⚠ move_base_common_params.yaml đang trỏ `PriestLocalPlanner` và `HybridDockingLocalPlanner`.
# Thiếu một trong hai .so là move_base2 chết ngay ở `initialize()`.
if (NOT TARGET hybrid_local_planner)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Packages/local_planners/hybrid_local_planner)
endif()
if (NOT TARGET mppi_local_planner)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Packages/local_planners/mppi_local_planner)
endif()
if (NOT TARGET priest_local_planner)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Packages/local_planners/priest_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()
if (NOT TARGET robot_clear_costmap_recovery)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Navigations/Libraries/robot_clear_costmap_recovery)
endif()
# 3. Mission / action / recovery framework, rồi navigation runtime
#
# Trước đây khối này là một shim di trú: nó đi tìm thư mục `Test/` bên cạnh (của AMR_T800) và add
# gói từ đó. Cây này đã di trú xong — mọi gói nằm in-tree dưới dạng git submodule — nên shim bị gỡ
# hẳn. Giữ lại là một quả bom hẹn giờ: `PNKX_NAV_CORE_BUILD_TEST_PACKAGES` mặc định ON, không tìm
# thấy `Test/` là FATAL_ERROR ngay lúc configure.
#
# Thứ tự dưới đây 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
# framework (ActionRunner <- action_core, RecoveryRunner <- recovery_core, MissionLayer <-
# mission_adapters) nên nó phải đứng cuối cùng.
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()
# Guard là `move_base2_core`, không phải `move_base2`: project tên một đằng còn target thư viện tên
# một nẻo, và guard sai tên thì không bao giờ khớp — subdirectory được add hai lần khi configure
# lại, lỗi hiện ra dưới dạng "target đã tồn tại".
if (NOT TARGET move_base2_core)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Navigations/Packages/move_base2)
endif()
# 4. Gói CHỈ build được trong catkin workspace
#
# Hai gói dưới đây gọi `find_package(catkin REQUIRED ...)` ở cấp cao nhất — không có nhánh
# standalone. Kéo chúng vào đồ thị này là hỏng ngay lúc configure:
#
# CMake Error at catkinConfig.cmake:83 (find_package):
# Could not find a package configuration file provided by "recovery_core"
#
# Lỗi đó gây hiểu nhầm: `recovery_core` CÓ trong cây và đã được add ở trên, nhưng nhánh catkin đi
# tìm `recovery_coreConfig.cmake` do một workspace catkin sinh ra, thứ không tồn tại ở build
# standalone. Sửa đúng là cho hai gói này một nhánh standalone như các gói khác đã có; tới lúc đó
# thì để tắt và nói rõ, đừng để nó phá cả lần configure.
#
# Trong catkin workspace (`catkin_make`) cả hai vẫn build bình thường — chúng không đi qua file này.
option(PNKX_NAV_CORE_BUILD_CATKIN_ONLY_PACKAGES
"Build cac goi chi co nhanh catkin (sbpl_recovery, dock_pattern_action)"
OFF)
if(PNKX_NAV_CORE_BUILD_CATKIN_ONLY_PACKAGES)
if (NOT TARGET sbpl_recovery)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Packages/recoveries/sbpl_recovery)
endif()
# Guard kiểm `dock_pattern_action_handler`, không phải `dock_pattern_action`.
if (NOT TARGET dock_pattern_action_handler)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Packages/actions/dock_pattern_action)
endif()
else()
message(STATUS
"[pnkx_nav_core] Bo qua sbpl_recovery va dock_pattern_action: hai goi nay chi co nhanh "
"catkin. Dung catkin_make, hoac bat -DPNKX_NAV_CORE_BUILD_CATKIN_ONLY_PACKAGES=ON sau "
"khi them nhanh standalone cho chung.")
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 "========================================")