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

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 every package is added in dependency order at its real
in-tree path.

Three 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.
  - move_base2's is move_base2_core.

sbpl_recovery and dock_pattern_action had no standalone branch - catkin was
required at top level, so a build without it died at configure time pointing at
packages that are present. Both now detect the mode and name their CMake
targets directly in standalone, and both drop their plugin at the top of the
build tree, because boost::dll loads by filename and PluginLoaderHelper
resolves that against the build directory: left in a subdirectory a plugin
builds and is then invisible at runtime.

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 standalone build returns 0,
producing 48 shared libraries with nothing gated off.
This commit is contained in:
2026-08-27 10:09:25 +07:00
commit 256d280b71
486 changed files with 72597 additions and 0 deletions

View File

@@ -0,0 +1,161 @@
cmake_minimum_required(VERSION 3.10)
project(nav_c_api VERSION 1.0.0 LANGUAGES CXX)
# Chuẩn C++
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# Find Boost (filesystem needed for plugin path / boost::dll usage)
find_package(Boost REQUIRED COMPONENTS filesystem system)
# Dependencies (robot_nav_2d_utils_conversions provides poseStampedToPose2D used by move_base_core/navigation.h)
set(PACKAGES_DIR
move_base_core
robot_nav_2d_utils
tf3
robot_time
robot_cpp
geometry_msgs
angles
data_convert
robot_protocol_msgs
)
# Thư mục include
include_directories(
${PROJECT_SOURCE_DIR}/include
)
# Tìm tất cả file source
file(GLOB SOURCES
"src/*.cpp"
"src/std_msgs/*.cpp"
"src/sensor_msgs/*.cpp"
"src/geometry_msgs/*.cpp"
"src/nav_msgs/*.cpp"
"src/nav_2d_msgs/*.cpp"
"src/robot_nav_msgs/*.cpp"
"src/robot_geometry_msgs/*.cpp"
"src/map_msgs/*.cpp"
)
file(GLOB HEADERS
"include/*.h"
"include/std_msgs/*.h"
"include/sensor_msgs/*.h"
"include/geometry_msgs/*.h"
"include/nav_msgs/*.h"
"include/nav_2d_msgs/*.h"
"include/robot_nav_msgs/*.h"
"include/robot_geometry_msgs/*.h"
"include/map_msgs/*.h"
)
# Tạo thư viện shared (.so)
add_library(nav_c_api SHARED ${SOURCES} ${HEADERS})
# Link libraries
target_link_libraries(nav_c_api
PUBLIC
${PACKAGES_DIR}
PRIVATE
Boost::boost
Boost::filesystem
Boost::system
dl
)
set_target_properties(nav_c_api PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
BUILD_RPATH "${CMAKE_BINARY_DIR}"
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib"
)
# Set include directories
target_include_directories(nav_c_api
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
# Cài đặt header files
install(DIRECTORY include/
DESTINATION include
FILES_MATCHING PATTERN "*.h"
)
# Cài đặt library
install(TARGETS nav_c_api
EXPORT nav_c_api-targets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
)
# Export targets
install(EXPORT nav_c_api-targets
FILE nav_c_api-targets.cmake
DESTINATION lib/cmake/nav_c_api
)
# Tùy chọn build
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(BUILD_TESTS "Build test programs" OFF)
# Test cho lớp chuyển đổi. Không cần dựng navigation thật: mọi thứ ở đây là chuyển đổi thuần và
# quản lý bộ nhớ, đúng chỗ tập trung rủi ro của gói này.
#
# Bật bằng: cmake -DBUILD_C_API_TESTS=ON, rồi chạy ./devel/lib/nav_c_api/test_convertor
option(BUILD_C_API_TESTS "Build the C API converter tests" OFF)
if(BUILD_C_API_TESTS OR BUILD_TESTS)
find_package(GTest QUIET)
if(GTest_FOUND OR GTEST_FOUND)
add_executable(test_convertor test/test_convertor.cpp)
target_link_libraries(test_convertor
PRIVATE
nav_c_api
${GTEST_BOTH_LIBRARIES}
pthread
)
target_include_directories(test_convertor
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${GTEST_INCLUDE_DIRS}
)
# Test phải build với cảnh báo bật: -w của thư viện che đúng nhóm lỗi mà test này đi tìm.
target_compile_options(test_convertor PRIVATE -Wall -Wextra)
set_target_properties(test_convertor PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
)
enable_testing()
add_test(NAME test_convertor COMMAND test_convertor)
message(STATUS "nav_c_api: converter tests enabled")
else()
message(WARNING "nav_c_api: GTest not found, converter tests skipped")
endif()
endif()
# Flags biên dịch
# 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")
# In thông tin cấu hình
message(STATUS "=================================")
message(STATUS "Project: ${PROJECT_NAME}")
message(STATUS "Version: ${PROJECT_VERSION}")
message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}")
message(STATUS "=================================")

View File

@@ -0,0 +1,500 @@
# Rà soát gói `c_api` — những chỗ chưa hoàn thiện
Phạm vi: `pnkx_nav_core/src/APIs/c_api`. Đọc toàn bộ `src/nav_c_api.cpp` (1396 dòng),
`src/convertor.cpp` (831), `src/std_msgs/Header.cpp`, `src/std_msgs/Time.cpp`, đối chiếu với
`include/nav_c_api.h` và với `Test/move_base2` ở phía sau.
Ràng buộc: **không đổi chữ ký hàm, không đổi chức năng chính**.
Ngày rà soát: 2026-08-08. **Đã sửa cùng ngày** — xem cột trạng thái ở mỗi mục và mục "Đã làm gì"
ở cuối. Một điểm nữa (**F25**) lộ ra trong lúc sửa, do chính bộ test mới bắt được.
---
## Tóm tắt
24 điểm, chia bốn mức. Ba điểm P0 là lỗi hành vi thật, không phải chuyện style:
| Mức | Số điểm | Bản chất |
|---|---|---|
| **P0** | 3 | Sai hành vi hoặc UB — ảnh hưởng trực tiếp tới robot |
| **P1** | 3 | Hợp đồng lỏng: host không phân biệt được lỗi với dữ liệu rỗng |
| **P2** | 6 | Rác debug, log sai cấp, format sai |
| **P3** | 5 | Khai báo và tài liệu lệch với hiện thực |
| **P4** | 7 | Nhỏ, nhất quán, hạ tầng |
Trong 24 điểm, **20 điểm sửa được mà không đụng chữ ký lẫn chức năng chính**. Bốn điểm còn lại
(F4, F5, F6 một phần, và phần capacity của F5) buộc phải hoặc đổi hợp đồng trả về, hoặc thêm hàm mới
song song — ghi rõ ở mục cuối.
---
## P0 — sai hành vi thật
### F1. `navigation_set_twist_linear` bỏ qua tham số `linear_x`
**Vị trí:** `src/nav_c_api.cpp:574-584`
```cpp
robot_geometry_msgs::Vector3 linear;
linear.x = 0.1; // <-- linear_x KHÔNG hề được dùng
linear.y = linear_y;
linear.z = linear_z;
bool result = nav_ptr->setTwistLinear(linear);
robot::log_info("setTwistLinear Forward %f", linear.x);
linear.x = -0.1; // <-- cũng hard-code
result &= result && nav_ptr->setTwistLinear(linear);
robot::log_info("setTwistLinear Backward %f", linear.x);
return result;
```
**Vấn đề.** Tham số `linear_x` của hàm không bao giờ được đọc. Trần vận tốc gửi xuống lõi luôn là
`+0.1 m/s` cho chiều tiến và `-0.1 m/s` cho chiều lùi, bất kể host truyền giá trị nào. Hai tham số
`linear_y` và `linear_z` thì lại được truyền đúng — đây là dấu hiệu code viết dở rồi bỏ quên, không
phải quyết định thiết kế.
**Ảnh hưởng lên hành vi robot.** Hai chiều, đều xấu:
1. Đường hạ tốc của tầng an toàn không tới được lõi. Host tính ra "chỉ được chạy 0.3 m/s vì đang vào
vùng hẹp" rồi gọi hàm này — lõi nhận 0.1 m/s. Ngược lại host muốn nâng lên 1.0 m/s cũng chỉ nhận
được 0.1.
2. Ngay khi host gọi hàm này lần đầu, robot bị khoá ở 0.1 m/s cho tới hết phiên chạy. Nếu host chỉ
gọi khi cần giảm tốc thì robot sẽ không bao giờ về lại tốc độ bình thường.
**Lỗi thứ hai trong cùng hàm.** `result &= result && nav_ptr->setTwistLinear(linear)` — toán tử `&&`
short-circuit: nếu lời gọi đầu trả `false` thì lời gọi thứ hai **không chạy**, nên trần chiều lùi
không được đặt. Ý định rõ ràng là gọi cả hai rồi AND kết quả lại.
**Đã sửa.** Hợp đồng đúng: giá trị đi xuống lõi **nguyên dạng, giữ dấu**. Dấu của `linear_x` là thứ
chọn chiều mà trần áp vào — âm đặt trần lùi, dương đặt trần tiến; local planner giữ hai trần riêng
(`navigation_server.cpp:921-944`). Lấy trị tuyệt đối là vứt bỏ nửa thông tin của lời gọi.
Một lời gọi vì thế đặt **một** chiều. Host muốn chặn cả hai thì gọi hai lần — đúng như host ROS đang
làm (`amr_control.cpp:707-709`, `amr_vda_5050_client_api.cpp:410-414`).
```c
navigation_set_twist_linear(h, 0.6, 0.0, 0.0); // tiến <= 0.6 m/s
navigation_set_twist_linear(h, -0.3, 0.0, 0.0); // lùi <= 0.3 m/s
```
---
### F2. Gán `char*` có thể NULL vào `std::string`
**Vị trí:** `src/convertor.cpp:13` (LaserScan), `:44` (OccupancyGrid), `:115` (PoseStamped)
```cpp
robot_laser_scan.header.frame_id = laser_scan.header.frame_id; // char* có thể NULL
```
**Vấn đề.** Dựng `std::string` từ con trỏ NULL là hành vi không xác định — thực tế là segfault trong
`strlen`. Các converter khác trong **chính file này** đều đã guard:
| Đã guard | Chưa guard |
|---|---|
| `convert2CppOdometry:73,75` | `convert2CppLaserScan:13` |
| `convert2CppPointCloud:383` | `convert2CppOccupancyGrid:44` |
| `convert2CppPointCloud2:408` | `convert2CppPoseStamped:115` |
| `convert2CppOrder:731-745` | |
| `convert2CppNode`, `convert2CppEdge`, `convert2CppAction`, `convert2CppNodePosition` | |
Nghĩa là quy ước "guard NULL" đã có sẵn và được áp dụng ở 7 chỗ; ba chỗ này bị bỏ sót.
**Ảnh hưởng.** `frame_id = NULL` hoàn toàn hợp lệ trong C, và **chính thư viện này sinh ra NULL**:
`convert2COccupancyGrid:181` viết `frame_id.empty() ? nullptr : strdup(...)`. Nên vòng
`navigation_get_static_map()` rồi `navigation_add_static_map()` — hoặc bất kỳ đường round-trip nào
qua một message có `frame_id` rỗng — là segfault chắc chắn.
**Hướng sửa.** Thêm `? :` đúng như 7 chỗ còn lại. Không đụng chữ ký, không đổi chức năng.
---
### F3. `strdup(frame_id)` không kiểm NULL
**Vị trí:** `src/std_msgs/Header.cpp:8` (`header_create`) và `:18` (`header_set_data`)
```cpp
extern "C" Header header_create(const char *frame_id) {
Header header{};
header.frame_id = strdup(frame_id); // NULL -> segfault
```
**Vấn đề.** `strdup(NULL)` là UB. Hai hàm này nằm trong bề mặt công khai và C# gọi trực tiếp
(`NavigationAPI.cs:69,72`).
**Hướng sửa.** `frame_id ? strdup(frame_id) : nullptr`.
---
## P1 — hợp đồng lỏng, host không phân biệt được lỗi
### F4. Bốn getter sensor luôn trả `true` kể cả khi tên không tồn tại
**Vị trí:** `src/nav_c_api.cpp:858` (`get_static_map`), `:882` (`get_laser_scan`), `:906`
(`get_point_cloud`), `:930` (`get_point_cloud2`)
**Vấn đề.** `move_base2::NavigationServer::getStaticMap` dùng `lookupOrDefault`
(`navigation_server.cpp:607-611`): tên không có trong map thì trả về object mặc định, không báo lỗi.
`c_api` chuyển thẳng object rỗng đó ra rồi `return true`.
**Ảnh hưởng.** Host nhận `OccupancyGrid` với `width = 0`, `data = NULL` và một giá trị trả về `true`.
Không có cách nào phân biệt "bản đồ tồn tại nhưng rỗng" với "gõ sai tên bản đồ". Sai tên là lỗi cấu
hình phổ biến nhất ở đường sensor (tên phải khớp `topic` trong YAML costmap) — mà nó lại đúng là
trường hợp API im lặng nhất.
**Hướng sửa.** Không sửa được nếu giữ nguyên chữ ký lẫn ngữ nghĩa: contract `BaseNavigation` không có
đường báo "không tìm thấy". Ba lựa chọn, đều nằm ngoài ràng buộc đợt này:
(a) tài liệu hoá rõ trong header rằng `true` không có nghĩa là tìm thấy;
(b) đổi quy ước: trả `false` khi kết quả rỗng — **đổi hành vi**, có thể vỡ host đang chạy;
(c) thêm hàm `navigation_has_static_map(handle, name)` bên `nav_c_api_2` để hỏi trước.
Khuyến nghị: (a) ngay, (c) khi có dịp.
---
### F5. Bốn hàm `get_all_*` và `get_robot_footprint` ghi vào mảng caller mà không biết dung lượng
**Vị trí:** `src/nav_c_api.cpp:954`, `:985`, `:1021`, `:1057`, và `:203`
(`navigation_get_robot_footprint`)
```cpp
auto maps = nav_ptr->getAllStaticMaps();
out_count = maps.size();
size_t i = 0;
for (const auto &p : maps)
{
out_maps[i].name = strdup(p.first.c_str()); // ghi mù, không biết mảng dài bao nhiêu
convert2COccupancyGrid(p.second, out_maps[i].grid);
++i;
}
```
**Vấn đề.** Chữ ký chỉ có con trỏ ra và `size_t &out_count` (là tham số **ra**, không phải vào). Hàm
không có cách nào biết mảng host cấp đủ chỗ hay không, và ghi đúng bằng số phần tử nó có.
**Ảnh hưởng.** Host cấp mảng 4 phần tử, lõi đang giữ 6 point cloud → ghi tràn 2 phần tử. Với
`NamedOccupancyGrid` mỗi phần tử là một struct lớn, nên tràn không phải một byte mà hàng chục byte
ra ngoài vùng — hỏng stack hoặc heap của host, và triệu chứng sẽ hiện ra ở chỗ hoàn toàn khác.
**Hướng sửa.** Không sửa được mà giữ chữ ký. Hai lựa chọn:
(a) ghi cảnh báo trong header, nói rõ host phải cấp dư và bao nhiêu là đủ;
(b) thêm biến thể có `size_t capacity` bên `nav_c_api_2`, giữ nguyên hàm cũ.
---
### F6. `navigation_initialize` luôn trả `true`
**Vị trí:** `src/nav_c_api.cpp:127`
**Vấn đề.** `BaseNavigation::initialize()` trả `void`, nên `c_api` `return true` ngay sau khi gọi.
`move_base2` có năm đường thất bại trong `initialize()` (dựng costmap, cấu hình sensor, nạp plugin,
cấu hình control loop, start control thread — `navigation_server.cpp:340-479`), mỗi đường chỉ đặt
`nav_feedback_->is_ready = false` kèm lý do rồi return bình thường.
**Ảnh hưởng.** Host tưởng lõi đã sẵn sàng, gửi goal vào một lõi không có control thread. Goal nằm im
vĩnh viễn: không cycle nào chạy, không state nào đổi, **không log gì**.
**Hướng sửa.** Đã có sẵn: `navigation_initialize_checked()` trong `nav_c_api_2` làm đúng việc này mà
không đụng hàm cũ. Còn lại là chuyện host đổi sang gọi hàm mới.
---
## P2 — rác debug, log sai cấp, format sai
| # | Vị trí | Vấn đề | Ảnh hưởng |
|---|---|---|---|
| **F7** | `convertor.cpp:36-39` | `log_info` in `sizeof(OccupancyGrid)`, `offsetof(data)`, `offsetof(data_count)` **mỗi lần** convert map | Leftover của một lần dò lệch ABI. Chạy trên mọi `add_static_map` |
| **F8** | `nav_c_api.cpp:190` | `printf("footprint x: %f, y: %f")` **trong vòng lặp từng điểm** | Footprint 8 điểm = 8 dòng mỗi lần đặt footprint |
| **F9** | `nav_c_api.cpp:284, 319` (call site `move_straight_to` đã bị xoá cùng hàm) | `log_error` dùng để in giá trị bình thường: goal của `move_to_order`, goal của `move_to_nodes_edges` | Sai cấp log. Ai lọc log theo mức ERROR sẽ thấy toàn dữ liệu bình thường, lỗi thật bị chìm |
| **F10** | `nav_c_api.cpp:86` | `log_warning("%s", path_file_so.c_str())` in đường dẫn `.so` mỗi lần `navigation_create` | Sai cấp; nên là `log_info` hoặc `log_debug` |
| **F11** | `nav_c_api.cpp:748` | `log_info("occupancy_grid.data_count: %d", occupancy_grid.data_count)` — `%d` cho `size_t` | Format không khớp kiểu: UB, in ra số sai trên 64-bit. Bị `-w` che nên không có warning |
| **F12** | 9 chỗ trong `nav_c_api.cpp` | `printf` trộn lẫn với `robot::log_*` | Hai hệ log song song. `printf` đi thẳng stdout, không vào file log, không có timestamp, không lọc theo mức được |
Tất cả P2 sửa được mà không đụng chữ ký lẫn chức năng.
---
## P3 — khai báo và tài liệu lệch với hiện thực
### F13. Ba symbol export nhưng không khai báo trong header
`navigation_state_to_string` (`nav_c_api.cpp:38`), `navigation_offset_goal_2d` (`:51`),
`navigation_offset_goal_stamped` (`:66`).
Binding theo tên symbol (P/Invoke) vẫn gọi được, nhưng bên gọi C/C++ include `nav_c_api.h` thì không
thấy. `NavigationAPI.cs:87` đang khai báo tay `navigation_state_to_string` — đúng, nhưng là đoán.
### F14. Header nhắc tới một hàm không tồn tại
`include/nav_c_api.h:119`:
> `@param out_points Output array of points (allocated by library, free with navigation_free_points)`
`navigation_free_points` **không tồn tại ở đâu cả** — không khai báo, không hiện thực, không export.
Ngoài ra câu này còn sai thêm một tầng: `out_points` **không** do thư viện cấp phát, nó là mảng của
caller (xem F5).
### F15. Doc của `navigation_rotate_to` mô tả một chữ ký khác
> **Không còn áp dụng, 2026-08-10.** `navigation_rotate_to` đã bị **xoá khỏi API** cùng nhóm
> `navigation_dock_to*` và `navigation_move_straight_to` — chúng đi thẳng xuống lõi, bỏ qua mission
> layer. Binding C# sai chữ ký nói ở đây vì thế cũng đã được gỡ. Giữ lại mục này làm ghi chép: bug
> gốc là **binding đọc doc thay vì đọc chữ ký**, và rủi ro đó không mất đi cùng hàm.
`include/nav_c_api.h:196-202`:
```c
/**
* @brief Rotate in place to align with target orientation
* @param handle Navigation handle
* @param goal_yaw Desired heading (radians) <-- không có tham số nào tên goal_yaw
* @return true if rotation command was sent successfully
*/
bool navigation_rotate_to(NavigationHandle handle, const PoseStamped goal);
```
**Đây gần như chắc chắn là nguồn của một bug đang tồn tại phía C#.**
`examples/NavigationExample/NavigationAPI.cs:165` khai báo:
```csharp
public static extern bool navigation_rotate_to(NavigationHandle handle, double goal_yaw);
```
Người viết binding đọc doc chứ không đọc chữ ký. Hậu quả ở tầng ABI: C# đẩy một `double` vào `xmm0`,
C đọc một `PoseStamped` (struct lớn) từ stack — goal nhận được là rác, `isQuaternionValid` sẽ chặn
hoặc `frame_id` là con trỏ rác.
### F16. Header khai `extern "C"` nhưng dùng tham chiếu C++
`size_t &out_count`, `PoseStamped &out_pose`, `OccupancyGrid &out_map`… Trình biên dịch C thuần không
dịch được file này. ABI thì vẫn là con trỏ nên P/Invoke không bị ảnh hưởng. Không sửa được mà giữ chữ
ký — chỉ ghi nhận.
### F17. Ghi chú giải phóng bộ nhớ không đầy đủ
`nav_c_api.h:265` có nhắc `out_twist->header.frame_id` phải free; `:274` nhắc `feed_back_str`. Nhưng
`navigation_get_robot_pose_stamped` (`:250`) cũng `strdup` `frame_id` (`convertor.cpp:134`) mà doc
không nhắc gì. Bốn getter sensor và hai getter planner data cũng cấp phát mà doc không nói (nay đã có
`navigation_free_*` bên `nav_c_api_2`, nhưng doc của header cũ chưa trỏ sang).
---
## P4 — nhỏ, nhất quán, hạ tầng
### F18. `resize()` trước khi kiểm con trỏ NULL
`convertor.cpp:384` (`convert2CppPointCloud`) và `:423` (`convert2CppPointCloud2`):
```cpp
cpp.points.resize(c.points_count); // resize trước
for (size_t i = 0; i < c.points_count && c.points; ++i) // kiểm NULL sau
```
Nếu host truyền `points = NULL` nhưng `points_count` lớn thì `resize` vẫn cấp phát đủ chỗ rồi vòng
lặp không chạy. Không crash, nhưng cấp phát vô ích có thể rất lớn. `convert2CppLaserScan:21-22` làm
đúng: tính size đã guard trước rồi mới resize.
### F19. `get_all_static_maps` lệch với ba hàm cùng nhóm
`nav_c_api.cpp:954` không có nhánh `if (empty()) { out_count = 0; return true; }` mà `:1000`, `:1036`,
`:1072` đều có. Kết quả cuối giống nhau (vòng lặp không chạy, `out_count = 0`), chỉ là lệch hình thức.
### F20. `header_create` đọc đồng hồ hai lần
`std_msgs/Header.cpp:9-10`:
```cpp
header.sec = robot::Time::now().sec;
header.nsec = robot::Time::now().nsec;
```
Hai lời gọi riêng biệt. Nếu rơi đúng lúc `nsec` vòng qua giây thì `sec` lấy từ lần đọc trước còn
`nsec` từ lần sau — timestamp lệch tới một giây. Xác suất thấp nhưng hậu quả nằm ở TF lookup.
### F21. `catch (...)` nuốt lỗi không log
Phần lớn hàm kết thúc bằng `catch (...) { return false; }` trần. Host chỉ nhận `false`, không có cách
nào biết vì sao. `navigation_create` (`:100-107`) còn nuốt cả `std::exception &e` mà không in `e.what()`
— trong khi đây đúng là chỗ hay hỏng nhất (không tìm thấy `.so`, sai `library_path`).
### F22. CMake guard không bao giờ khớp
`pnkx_nav_core/CMakeLists.txt:237`: `if (NOT TARGET navigation_c_api)` — nhưng target thật tên
`nav_c_api` (`src/APIs/c_api/CMakeLists.txt:61`). Guard vô tác dụng; `.so` sinh ra là
`libnav_c_api.so`, không phải `libnavigation_c_api.so` như tài liệu ở nơi khác ghi.
### F23. Không có test nào
`src/APIs/c_api/` không có thư mục `test/`. Không có test đơn vị cho lớp converter — nơi tập trung
gần hết các lỗi P0 ở trên và là nơi test rẻ nhất (không cần dựng navigation thật).
### F24. Năng lực contract chưa phơi ra ở bề mặt cũ
`BaseNavigation` có `addDepthCameraData()` (thuần ảo) và `shutdown()` mà `nav_c_api.h` không có hàm
tương ứng. Đã bù bằng `navigation_add_depth_camera_data()` và `navigation_shutdown()` trong
`nav_c_api_2`; ghi lại ở đây để bảng rà soát đầy đủ.
---
## Sửa được gì trong ràng buộc "không đổi chữ ký, không đổi chức năng chính"
**Sửa được ngay — 20 điểm:** F1, F2, F3, F7, F8, F9, F10, F11, F12, F13, F14, F15, F17, F18, F19,
F20, F21, F22, F23, và phần tài liệu của F5.
- F1 là làm cho hàm **thực hiện đúng chức năng nó đã khai** — dùng tham số thay vì hằng số. Chữ ký
không đổi, mục đích không đổi.
- F2, F3, F18, F20, F21 là bổ sung guard và sửa lỗi nhỏ, không chạm hợp đồng.
- F7–F12 là dọn log.
- F13–F15, F17 là sửa khai báo và doc cho khớp hiện thực — F15 quan trọng vì nó đang dẫn người viết
binding đi sai.
**Không sửa được mà giữ nguyên chữ ký — 3 điểm:**
| # | Vì sao | Lối ra |
|---|---|---|
| **F4** | Cần một đường báo "không tìm thấy" mà chữ ký hiện tại không có | Tài liệu hoá ngay; thêm `navigation_has_*` bên `nav_c_api_2` khi có dịp |
| **F5** | Cần tham số `capacity` | Tài liệu hoá ngay; thêm biến thể có `capacity` bên `nav_c_api_2` |
| **F16** | Bỏ tham chiếu C++ khỏi header là đổi chữ ký toàn bộ | Ghi nhận; chỉ đổi nếu có đợt phá vỡ ABI |
Riêng **F6** đã có lối ra không phá vỡ gì: `navigation_initialize_checked()` đã tồn tại.
---
## Thứ tự đề nghị
1. **F1** — một mình nó đủ khiến trần vận tốc không hoạt động. Cần chốt ý định trước (xem dưới).
2. **F2, F3** — ba dòng guard, chặn ba đường segfault.
3. **F15, F14, F13** — sửa doc và khai báo, vì chúng đang tạo ra bug ở phía binding.
4. **F7–F12** — dọn log, gộp một lần.
5. **F23** — một binary GTest cho riêng lớp converter: `frame_id` NULL, mảng NULL với count > 0,
`Order` với mọi trường NULL, round-trip C++ → C → C++. Không cần dựng navigation thật.
6. **F4, F5** — chốt hướng rồi mới làm.
---
## Câu hỏi mở — cần xác nhận trước khi sửa
1. ~~**F1 — ý định của `navigation_set_twist_linear` là gì?**~~ **Đã chốt:** truyền nguyên dạng, dấu
chọn chiều, một lời gọi đặt một chiều. Xem F1.
2. **Giá trị `0.1` cũ có phải trần an toàn cố ý của một lần thử nghiệm không?** Nếu đúng là có chủ ý
thì nó phải nằm trong YAML chứ không phải hard-code trong lớp binding — và sau bản sửa này robot
sẽ chạy đúng tốc độ host yêu cầu, không còn bị kẹp ở 0.1 m/s. **Cần biết trước khi chạy thật.**
3. **F4 — có host nào đang dựa vào việc getter luôn trả `true` không?** Nếu không, đổi sang trả
`false` khi rỗng là hợp lý hơn nhiều — nhưng đó là đổi hành vi.
4. **Phía C# hiện có đang gọi `header_create` với `frame_id` NULL không** (F3), và có gọi
`navigation_get_all_*` với mảng cấp sẵn bao nhiêu phần tử (F5)?
---
## F25 — hàm được khai báo và được gọi nhưng chưa bao giờ hiện thực
**Vị trí:** `include/convertor.h:137` khai báo, `src/nav_c_api.cpp:61` gọi, **không có định nghĩa ở
đâu cả**.
```cpp
robot_geometry_msgs::Pose2D convert2CppPose2D(const Pose2D& pose_2d); // chỉ có khai báo
```
**Vì sao không ai phát hiện.** Thư viện chia sẻ được phép link với symbol chưa phân giải: `.so` build
sạch, không một cảnh báo nào. Symbol nằm im trong bảng undefined:
```
$ nm -D --undefined-only libnav_c_api.so | grep convert2CppPose2D
U _Z17convert2CppPose2DRK6Pose2D
```
**Ảnh hưởng.** `navigation_offset_goal_2d()` — hàm duy nhất gọi nó — chết ngay ở lời gọi đầu tiên với
`symbol lookup error`, hoặc làm `dlopen` thất bại tuỳ cách nạp. Hàm này chưa bao giờ chạy được.
**Cách nó lộ ra.** Không phải do đọc mã. Bộ test mới (F23) link một **executable** vào thư viện, và
executable thì không được phép có symbol chưa phân giải — trình liên kết báo ngay. Đây đúng là lý do
bộ test tồn tại.
**Trạng thái: đã sửa** — hiện thực trong `convertor.cpp` ngay cạnh `convert2CPose2D`.
---
## Đã làm gì
Sửa **21/25 điểm**, giữ nguyên chữ ký và chức năng chính của mọi hàm.
| Nhóm | Điểm | Trạng thái |
|---|---|---|
| P0 | F1, F2, F3 | Đã sửa |
| P1 | F6 | Đã có `navigation_initialize_checked` từ trước; header nay trỏ sang nó |
| P1 | F4, F5 | Không sửa được mà giữ chữ ký — **đã ghi cảnh báo rõ trong header** |
| P2 | F7–F12 | Đã sửa |
| P3 | F13, F14, F15, F17 | Đã sửa |
| P3 | F16 | Không sửa — cần phá vỡ ABI |
| P4 | F18, F19, F20, F21, F22, F23 | Đã sửa |
| P4 | F24 | Đã bù từ trước bằng `nav_c_api_2` |
| — | **F25** | Đã sửa |
### File đã chạm
| File | Thay đổi |
|---|---|
| `src/nav_c_api.cpp` | F1 (dùng `linear_x` thật, bỏ short-circuit), F8–F12 (bỏ 9 `printf`, chuyển sang `robot::log_*`, hạ cấp log debug), F19, F21 (log lý do trong `catch`) |
| `src/convertor.cpp` | F2 (`safe_cstr` cho 3 chỗ), F7 (bỏ log ABI), F18 (lấy kích thước từ con trỏ), **F25** |
| `src/std_msgs/Header.cpp` | F3 (`strdup` chấp nhận NULL), F20 (đọc đồng hồ một lần) |
| `include/nav_c_api.h` | F13 (3 khai báo thiếu), F14, F15, F17, cảnh báo F4/F5/F6, đơn vị `[m/s]`/`[rad/s]` |
| `CMakeLists.txt` (gói) | F22 sửa tên target trong guard; thêm nhánh build test |
| `../../../CMakeLists.txt` | F22 |
| `test/test_convertor.cpp` | **Mới** — F23 |
### Hai thay đổi cần chú ý khi đọc diff
**F1 — `navigation_set_twist_linear` giờ truyền `linear_x` nguyên dạng, giữ dấu.** Dấu chọn chiều:
âm đặt trần lùi, dương đặt trần tiến; một lời gọi đặt một chiều. **Đây là thay đổi hành vi thật** —
trước đó trần luôn là ±0.1 m/s bất kể host truyền gì. Host nào từng "quen" với việc robot chạy
0.1 m/s sẽ thấy robot chạy đúng tốc độ nó yêu cầu kể từ bản này.
**F5 — vẫn còn ghi mù.** Cảnh báo đã vào header nhưng bản chất không đổi: `get_all_*` và
`get_robot_footprint` vẫn ghi theo số phần tử lõi đang giữ. Nếu muốn chặn thật thì phải thêm biến thể
có `capacity` bên `nav_c_api_2`.
---
## Đã kiểm chứng tới đâu
**Lệnh đã chạy và kết quả thật:**
```
$ cmake -S . -B build -DBUILD_C_API_TESTS=ON
-- nav_c_api: converter tests enabled
$ cmake --build build --target nav_c_api test_convertor -j4
[100%] Built target nav_c_api
[100%] Built target test_convertor
$ ./build/test_convertor
[==========] 20 tests from 6 test cases ran. (0 ms total)
[ PASSED ] 20 tests.
$ nm -D --undefined-only build/libnav_c_api.so | grep -E "convert2|isQuaternion|order_free|header_"
(không còn)
$ g++ -std=c++17 -Wall -Wextra -fsyntax-only # cả 5 file nguồn
nav_c_api OK (0 warning)
convertor OK (0 warning)
nav_c_api_2 OK (0 warning)
convertor_2 OK (0 warning)
Header.cpp OK
```
20 test phủ: `frame_id` NULL trên 4 loại message, mảng NULL kèm bộ đếm khác 0 trên 3 loại, round-trip
C++ → C → C++ cho OccupancyGrid và LaserScan, `Order` zero-init và `Order` có node/edge với chuỗi
NULL, chuyển đổi depth camera (gồm kiểm tra copy chứ không alias), 5 hàm `navigation_free_*` (gọi với
NULL, gọi hai lần, giải phóng buffer lồng nhau), và `isQuaternionValid`.
**Chưa kiểm chứng:**
- Chưa chạy trên robot hay Gazebo. Không có test tích hợp nào dựng navigation thật.
- **F1 chưa được xác nhận trên phần cứng.** Trần vận tốc giờ đi đúng giá trị host truyền — cần một
lần chạy thật để xác nhận robot không vọt quá tốc độ mong đợi, vì trước đây nó luôn bị kẹp ở
0.1 m/s. Đây là thay đổi cần chú ý nhất khi triển khai.
- `valgrind` chưa cài trên máy này, nên phần rò bộ nhớ của các hàm `free` mới chỉ được kiểm bằng
kiểm tra con trỏ sau khi giải phóng, không bằng công cụ.
- Bốn câu hỏi mở ở mục trên vẫn còn nguyên; F1 đã tự trả lời được bằng cách đọc host ROS, ba câu còn
lại vẫn cần phía host xác nhận.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,217 @@
#ifndef C_API_CONVERTOR_H
#define C_API_CONVERTOR_H
// C
#include "sensor_msgs/LaserScan.h"
#include "sensor_msgs/PointCloud.h"
#include "sensor_msgs/PointCloud2.h"
#include "nav_msgs/Odometry.h"
#include "std_msgs/Header.h"
#include "nav_msgs/OccupancyGrid.h"
#include "geometry_msgs/Point.h"
#include "geometry_msgs/PoseStamped.h"
#include "geometry_msgs/Pose2D.h"
#include "nav_2d_msgs/Twist2D.h"
#include "nav_2d_msgs/Twist2DStamped.h"
#include "nav_2d_msgs/Path2D.h"
#include "map_msgs/OccupancyGridUpdate.h"
#include "geometry_msgs/PolygonStamped.h"
#include "protocol_msgs/Order.h"
// C++
#include <robot_sensor_msgs/LaserScan.h>
#include <robot_sensor_msgs/PointCloud.h>
#include <robot_sensor_msgs/PointCloud2.h>
#include <robot_nav_msgs/Odometry.h>
#include <robot_nav_msgs/OccupancyGrid.h>
#include <robot_geometry_msgs/PoseStamped.h>
#include <robot_geometry_msgs/Pose2D.h>
#include <robot_nav_2d_msgs/Twist2D.h>
#include <robot_nav_2d_msgs/Twist2DStamped.h>
#include <robot_nav_2d_msgs/Path2D.h>
#include <robot_map_msgs/OccupancyGridUpdate.h>
#include <robot_geometry_msgs/PolygonStamped.h>
#include <robot_protocol_msgs/Order.h>
#include <move_base_core/navigation.h>
#include <move_base_core/common.h>
/**
* @brief Convert C LaserScan to C++ LaserScan
* @param laser_scan C LaserScan
* @return C++ LaserScan
*/
robot_sensor_msgs::LaserScan convert2CppLaserScan(const LaserScan& laser_scan);
/**
* @brief Convert C OccupancyGrid to C++ OccupancyGrid
* @param occupancy_grid C OccupancyGrid
* @return C++ OccupancyGrid
*/
robot_nav_msgs::OccupancyGrid convert2CppOccupancyGrid(const OccupancyGrid& occupancy_grid);
/**
* @brief Convert C++ OccupancyGrid to C OccupancyGrid
* @param cpp C++ OccupancyGrid
* @param out C OccupancyGrid
*/
void convert2COccupancyGrid(const robot_nav_msgs::OccupancyGrid& cpp, OccupancyGrid& out);
/**
* @brief Convert C++ Path2D to C Path2D
*/
void convert2CPath2D(const robot_nav_2d_msgs::Path2D& cpp, Path2D& out);
/**
* @brief Convert C++ OccupancyGridUpdate to C OccupancyGridUpdate
*/
void convert2COccupancyGridUpdate(const robot_map_msgs::OccupancyGridUpdate& cpp, OccupancyGridUpdate& out);
/**
* @brief Convert C++ PolygonStamped to C PolygonStamped
*/
void convert2CPolygonStamped(const robot_geometry_msgs::PolygonStamped& cpp, PolygonStamped& out);
/**
* @brief Convert C++ LaserScan to C LaserScan
* @param cpp C++ LaserScan
* @param out C LaserScan
*/
void convert2CLaserScan(const robot_sensor_msgs::LaserScan& cpp, LaserScan& out);
/**
* @brief Convert C++ PointCloud to C PointCloud
* @param cpp C++ PointCloud
* @param out C PointCloud
*/
void convert2CPointCloud(const robot_sensor_msgs::PointCloud& cpp, PointCloud& out);
/**
* @brief Convert C++ PointCloud2 to C PointCloud2
* @param cpp C++ PointCloud2
* @param out C PointCloud2
*/
void convert2CPointCloud2(const robot_sensor_msgs::PointCloud2& cpp, PointCloud2& out);
/**
* @brief Convert C PointCloud to C++ PointCloud
* @param c C PointCloud
* @return C++ PointCloud
*/
robot_sensor_msgs::PointCloud convert2CppPointCloud(const PointCloud& c);
/**
* @brief Convert C PointCloud2 to C++ PointCloud2
* @param c C PointCloud2
* @return C++ PointCloud2
*/
robot_sensor_msgs::PointCloud2 convert2CppPointCloud2(const PointCloud2& c);
/**
* @brief Convert C Odometry to C++ Odometry
* @param odometry C Odometry
* @return C++ Odometry
*/
robot_nav_msgs::Odometry convert2CppOdometry(const Odometry& odometry);
/**
* @brief Convert C PoseStamped to C++ PoseStamped
* @param pose_stamped C PoseStamped
* @return C++ PoseStamped
*/
robot_geometry_msgs::PoseStamped convert2CppPoseStamped(const PoseStamped& pose_stamped);
/**
* @brief Convert C++ PoseStamped to C PoseStamped
* @param cpp_pose_stamped C++ PoseStamped
* @return C PoseStamped
*/
PoseStamped convert2CPoseStamped(const robot_geometry_msgs::PoseStamped& cpp_pose_stamped);
/**
* @brief Convert C Pose2D to C++ Pose2D
* @param pose_2d C Pose2D
* @return C++ Pose2D
*/
robot_geometry_msgs::Pose2D convert2CppPose2D(const Pose2D& pose_2d);
/**
* @brief Convert C++ Pose2D to C Pose2D
* @param cpp_pose_2d C++ Pose2D
* @return C Pose2D
*/
Pose2D convert2CPose2D(const robot_geometry_msgs::Pose2D& cpp_pose_2d);
/**
* @brief Convert C Twist2D to C++ Twist2D
* @param twist_2d C Twist2D
* @return C++ Twist2D
*/
robot_nav_2d_msgs::Twist2D convert2CppTwist2D(const Twist2D& twist_2d);
/**
* @brief Convert C++ Twist2D to C Twist2D
* @param cpp_twist_2d C++ Twist2D
* @return C Twist2D
*/
Twist2D convert2CTwist2D(const robot_nav_2d_msgs::Twist2D& cpp_twist_2d);
/**
* @brief Convert C Twist2DStamped to C++ Twist2DStamped
* @param twist_2d_stamped C Twist2DStamped
* @return C++ Twist2DStamped
*/
robot_nav_2d_msgs::Twist2DStamped convert2CppTwist2DStamped(const Twist2DStamped& twist_2d_stamped);
/**
* @brief Convert C++ Twist2DStamped to C Twist2DStamped
* @param cpp_twist_2d_stamped C++ Twist2DStamped
* @return C Twist2DStamped
*/
Twist2DStamped convert2CTwist2DStamped(const robot_nav_2d_msgs::Twist2DStamped& cpp_twist_2d_stamped);
/**
* @brief Convert C Order to C++ Order
* @param order C Order
* @return C++ Order
*/
robot_protocol_msgs::Order convert2CppOrder(const Order& order);
/**
* @brief Convert a C Action to a C++ Action.
*
* Null char* fields become empty strings, so a partially filled struct converts without crashing —
* the callee validates content, this only crosses the language boundary.
*
* @param action C Action
* @return C++ Action
*/
robot_protocol_msgs::Action convert2CppAction(const Action& action);
/**
* @brief Convert C++ Order to C Order
* @param cpp_order C++ Order
* @return C Order (caller must call order_free when done to release memory)
*/
Order convert2COrder(const robot_protocol_msgs::Order& cpp_order);
/**
* @brief Check if a quaternion is valid
* @param q Quaternion
* @return True if valid, false otherwise
*/
bool isQuaternionValid(const Quaternion& q);
/**
* @brief Free dynamic memory held by an Order returned from convert2COrder
* @param order Order to free (pointers and counts are zeroed)
*/
#ifdef __cplusplus
extern "C"
#endif
void order_free(Order* order);
#endif // C_API_CONVERTOR_H

View File

@@ -0,0 +1,51 @@
#ifndef C_API_CONVERTOR_2_H
#define C_API_CONVERTOR_2_H
/**
* @file convertor_2.h
* @brief Converters that only the move_base2 entry points need.
*
* Kept apart from convertor.h so the move_base2 surface can be added, reviewed and reverted without
* touching the converters the existing binding already depends on.
*/
// C
#include "std_msgs/Header.h"
#include "sensor_msgs/Image.h"
#include "sensor_msgs/CameraInfo.h"
#include "sensor_msgs/DepthCameraData.h"
// C++
#include <robot_std_msgs/Header.h>
#include <robot_sensor_msgs/Image.h>
#include <robot_sensor_msgs/CameraInfo.h>
#include <robot_sensor_msgs/DepthCameraData.h>
/**
* @brief Convert C Header to C++ Header.
* @param header C header; `frame_id` may be NULL (becomes an empty string).
*/
robot_std_msgs::Header convert2CppHeader(const Header& header);
/**
* @brief Convert C Image to C++ Image.
*
* The pixel buffer is copied, so the caller keeps ownership of `image.data` and may free it as
* soon as this call returns.
*
* @param image C image; `data` and `encoding` may be NULL.
*/
robot_sensor_msgs::Image convert2CppImage(const Image& image);
/**
* @brief Convert C CameraInfo to C++ CameraInfo.
* @param info C camera info; `D` and `distortion_model` may be NULL. K/R/P are fixed size (9/9/12).
*/
robot_sensor_msgs::CameraInfo convert2CppCameraInfo(const CameraInfo& info);
/**
* @brief Convert C DepthCameraData to C++ DepthCameraData. Everything is deep-copied.
*/
robot_sensor_msgs::DepthCameraData convert2CppDepthCameraData(const DepthCameraData& data);
#endif // C_API_CONVERTOR_2_H

View File

@@ -0,0 +1,22 @@
#ifndef C_API_GEOMETRY_MSGS_ACCEL_H
#define C_API_GEOMETRY_MSGS_ACCEL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "geometry_msgs/Vector3.h"
typedef struct
{
Vector3 linear;
Vector3 angular;
} Accel;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_ACCEL_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_GEOMETRY_MSGS_ACCELSTAMPED_H
#define C_API_GEOMETRY_MSGS_ACCELSTAMPED_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "geometry_msgs/Accel.h"
typedef struct
{
Header header;
Accel accel;
} AccelStamped;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_ACCELSTAMPED_H

View File

@@ -0,0 +1,22 @@
#ifndef C_API_GEOMETRY_MSGS_ACCELWITHCOVARIANCE_H
#define C_API_GEOMETRY_MSGS_ACCELWITHCOVARIANCE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "geometry_msgs/Accel.h"
typedef struct
{
Accel accel;
double covariance[36];
} AccelWithCovariance;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_ACCELWITHCOVARIANCE_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_GEOMETRY_MSGS_ACCELWITHCOVARIANCESTAMPED_H
#define C_API_GEOMETRY_MSGS_ACCELWITHCOVARIANCESTAMPED_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "geometry_msgs/AccelWithCovariance.h"
typedef struct
{
Header header;
AccelWithCovariance accel;
} AccelWithCovarianceStamped;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_ACCELWITHCOVARIANCESTAMPED_H

View File

@@ -0,0 +1,28 @@
#ifndef C_API_GEOMETRY_MSGS_INERTIA_H
#define C_API_GEOMETRY_MSGS_INERTIA_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "geometry_msgs/Vector3.h"
typedef struct
{
double m;
Vector3 com;
double ixx;
double ixy;
double ixz;
double iyy;
double iyz;
double izz;
} Inertia;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_INERTIA_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_GEOMETRY_MSGS_INERTIASTAMPED_H
#define C_API_GEOMETRY_MSGS_INERTIASTAMPED_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "geometry_msgs/Inertia.h"
typedef struct
{
Header header;
Inertia inertia;
} InertiaStamped;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_INERTIASTAMPED_H

View File

@@ -0,0 +1,21 @@
#ifndef C_API_GEOMETRY_MSGS_POINT_H
#define C_API_GEOMETRY_MSGS_POINT_H
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct
{
double x;
double y;
double z;
} Point;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_POINT_H

View File

@@ -0,0 +1,22 @@
#ifndef C_API_GEOMETRY_MSGS_POINT32_H
#define C_API_GEOMETRY_MSGS_POINT32_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct
{
float x;
float y;
float z;
} Point32;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_POINT32_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_GEOMETRY_MSGS_POINTSTAMPED_H
#define C_API_GEOMETRY_MSGS_POINTSTAMPED_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "geometry_msgs/Point.h"
typedef struct
{
Header header;
Point point;
} PointStamped;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_POINTSTAMPED_H

View File

@@ -0,0 +1,22 @@
#ifndef C_API_GEOMETRY_MSGS_POLYGON_H
#define C_API_GEOMETRY_MSGS_POLYGON_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "geometry_msgs/Point32.h"
typedef struct
{
Point32 *points;
size_t points_count;
} Polygon;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_POLYGON_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_GEOMETRY_MSGS_POLYGONSTAMPED_H
#define C_API_GEOMETRY_MSGS_POLYGONSTAMPED_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "geometry_msgs/Polygon.h"
typedef struct
{
Header header;
Polygon polygon;
} PolygonStamped;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_POLYGONSTAMPED_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_GEOMETRY_MSGS_POSE_H
#define C_API_GEOMETRY_MSGS_POSE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "geometry_msgs/Point.h"
#include "geometry_msgs/Quaternion.h"
typedef struct
{
Point position;
Quaternion orientation;
} Pose;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_POSE_H

View File

@@ -0,0 +1,22 @@
#ifndef C_API_GEOMETRY_MSGS_POSE2D_H
#define C_API_GEOMETRY_MSGS_POSE2D_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct
{
double x;
double y;
double theta;
} Pose2D;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_POSE2D_H

View File

@@ -0,0 +1,24 @@
#ifndef C_API_GEOMETRY_MSGS_POSEARRAY_H
#define C_API_GEOMETRY_MSGS_POSEARRAY_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "geometry_msgs/Pose.h"
typedef struct
{
Header header;
Pose *poses;
size_t poses_count;
} PoseArray;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_POSEARRAY_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_GEOMETRY_MSGS_POSESTAMPED_H
#define C_API_GEOMETRY_MSGS_POSESTAMPED_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "geometry_msgs/Pose.h"
typedef struct
{
Header header;
Pose pose;
} PoseStamped;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_POSESTAMPED_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_GEOMETRY_MSGS_POSEWITHCOVARIANCE_H
#define C_API_GEOMETRY_MSGS_POSEWITHCOVARIANCE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "geometry_msgs/Pose.h"
typedef struct
{
Pose pose;
double *covariance;
size_t covariance_count;
} PoseWithCovariance;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_POSEWITHCOVARIANCE_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_GEOMETRY_MSGS_POSEWITHCOVARIANCESTAMPED_H
#define C_API_GEOMETRY_MSGS_POSEWITHCOVARIANCESTAMPED_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "geometry_msgs/PoseWithCovariance.h"
typedef struct
{
Header header;
PoseWithCovariance pose;
} PoseWithCovarianceStamped;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_POSEWITHCOVARIANCESTAMPED_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_GEOMETRY_MSGS_QUATERNION_H
#define C_API_GEOMETRY_MSGS_QUATERNION_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct
{
double x;
double y;
double z;
double w;
} Quaternion;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_QUATERNION_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_GEOMETRY_MSGS_QUATERNIONSTAMPED_H
#define C_API_GEOMETRY_MSGS_QUATERNIONSTAMPED_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "geometry_msgs/Quaternion.h"
typedef struct
{
Header header;
Quaternion quaternion;
} QuaternionStamped;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_QUATERNIONSTAMPED_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_GEOMETRY_MSGS_TRANSFORM_H
#define C_API_GEOMETRY_MSGS_TRANSFORM_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "geometry_msgs/Vector3.h"
#include "geometry_msgs/Quaternion.h"
typedef struct
{
Vector3 translation;
Quaternion rotation;
} Transform;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_TRANSFORM_H

View File

@@ -0,0 +1,24 @@
#ifndef C_API_GEOMETRY_MSGS_TRANSFORMSTAMPED_H
#define C_API_GEOMETRY_MSGS_TRANSFORMSTAMPED_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "geometry_msgs/Transform.h"
typedef struct
{
Header header;
char *child_frame_id;
Transform transform;
} TransformStamped;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_TRANSFORMSTAMPED_H

View File

@@ -0,0 +1,22 @@
#ifndef C_API_GEOMETRY_MSGS_TWIST_H
#define C_API_GEOMETRY_MSGS_TWIST_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "geometry_msgs/Vector3.h"
typedef struct
{
Vector3 linear;
Vector3 angular;
} Twist;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_TWIST_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_GEOMETRY_MSGS_TWISTSTAMPED_H
#define C_API_GEOMETRY_MSGS_TWISTSTAMPED_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "geometry_msgs/Twist.h"
typedef struct
{
Header header;
Twist twist;
} TwistStamped;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_TWISTSTAMPED_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_GEOMETRY_MSGS_TWISTWITHCOVARIANCE_H
#define C_API_GEOMETRY_MSGS_TWISTWITHCOVARIANCE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "geometry_msgs/Twist.h"
typedef struct
{
Twist twist;
double *covariance;
size_t covariance_count;
} TwistWithCovariance;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_TWISTWITHCOVARIANCE_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_GEOMETRY_MSGS_TWISTWITHCOVARIANCESTAMPED_H
#define C_API_GEOMETRY_MSGS_TWISTWITHCOVARIANCESTAMPED_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "geometry_msgs/TwistWithCovariance.h"
typedef struct
{
Header header;
TwistWithCovariance twist;
} TwistWithCovarianceStamped;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_TWISTWITHCOVARIANCESTAMPED_H

View File

@@ -0,0 +1,22 @@
#ifndef C_API_GEOMETRY_MSGS_VECTOR3_H
#define C_API_GEOMETRY_MSGS_VECTOR3_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct
{
double x;
double y;
double z;
} Vector3;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_VECTOR3_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_GEOMETRY_MSGS_VECTOR3STAMPED_H
#define C_API_GEOMETRY_MSGS_VECTOR3STAMPED_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "geometry_msgs/Vector3.h"
typedef struct
{
Header header;
Vector3 vector;
} Vector3Stamped;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_VECTOR3STAMPED_H

View File

@@ -0,0 +1,22 @@
#ifndef C_API_GEOMETRY_MSGS_WRENCH_H
#define C_API_GEOMETRY_MSGS_WRENCH_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "geometry_msgs/Vector3.h"
typedef struct
{
Vector3 force;
Vector3 torque;
} Wrench;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_WRENCH_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_GEOMETRY_MSGS_WRENCHSTAMPED_H
#define C_API_GEOMETRY_MSGS_WRENCHSTAMPED_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "geometry_msgs/Wrench.h"
typedef struct
{
Header header;
Wrench wrench;
} WrenchStamped;
#ifdef __cplusplus
}
#endif
#endif // C_API_GEOMETRY_MSGS_WRENCHSTAMPED_H

View File

@@ -0,0 +1,33 @@
#ifndef C_API_ROBOT_MAP_MSGS_OCCUPANCYGRIDUPDATE_C_H
#define C_API_ROBOT_MAP_MSGS_OCCUPANCYGRIDUPDATE_C_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
/**
* C representation of robot_map_msgs::OccupancyGridUpdate.
* Note: This header is intentionally named *_c.h to avoid
* shadowing the C++ header `robot_map_msgs/OccupancyGridUpdate.h`.
*/
typedef struct
{
Header header;
int32_t x;
int32_t y;
uint32_t width;
uint32_t height;
int8_t *data;
size_t data_count;
} OccupancyGridUpdate;
#ifdef __cplusplus
}
#endif
#endif // C_API_ROBOT_MAP_MSGS_OCCUPANCYGRIDUPDATE_C_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_NAV_2D_MSGS_COMPLEXPOLYGON2D_H
#define C_API_NAV_2D_MSGS_COMPLEXPOLYGON2D_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "nav_2d_msgs/Polygon2D.h"
typedef struct
{
Polygon2D outer;
Polygon2D *inner;
size_t inner_count;
} ComplexPolygon2D;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_2D_MSGS_COMPLEXPOLYGON2D_H

View File

@@ -0,0 +1,25 @@
#ifndef C_API_NAV_2D_MSGS_NAVGRIDINFO_H
#define C_API_NAV_2D_MSGS_NAVGRIDINFO_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct
{
uint32_t width;
uint32_t height;
double resolution;
char *frame_id;
double origin_x;
double origin_y;
} NavGridInfo;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_2D_MSGS_NAVGRIDINFO_H

View File

@@ -0,0 +1,25 @@
#ifndef C_API_NAV_2D_MSGS_NAVGRIDOFCHARS_H
#define C_API_NAV_2D_MSGS_NAVGRIDOFCHARS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Time.h"
#include "nav_2d_msgs/NavGridInfo.h"
typedef struct
{
Time stamp;
NavGridInfo info;
uint8_t *data;
size_t data_count;
} NavGridOfChars;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_2D_MSGS_NAVGRIDOFCHARS_H

View File

@@ -0,0 +1,25 @@
#ifndef C_API_NAV_2D_MSGS_NAVGRIDOFCHARSUPDATE_H
#define C_API_NAV_2D_MSGS_NAVGRIDOFCHARSUPDATE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Time.h"
#include "nav_2d_msgs/UIntBounds.h"
typedef struct
{
Time stamp;
UIntBounds bounds;
uint8_t *data;
size_t data_count;
} NavGridOfCharsUpdate;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_2D_MSGS_NAVGRIDOFCHARSUPDATE_H

View File

@@ -0,0 +1,25 @@
#ifndef C_API_NAV_2D_MSGS_NAVGRIDOFDOUBLES_H
#define C_API_NAV_2D_MSGS_NAVGRIDOFDOUBLES_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Time.h"
#include "nav_2d_msgs/NavGridInfo.h"
typedef struct
{
Time stamp;
NavGridInfo info;
double *data;
size_t data_count;
} NavGridOfDoubles;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_2D_MSGS_NAVGRIDOFDOUBLES_H

View File

@@ -0,0 +1,25 @@
#ifndef C_API_NAV_2D_MSGS_NAVGRIDOFDOUBLESUPDATE_H
#define C_API_NAV_2D_MSGS_NAVGRIDOFDOUBLESUPDATE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Time.h"
#include "nav_2d_msgs/UIntBounds.h"
typedef struct
{
Time stamp;
UIntBounds bounds;
double *data;
size_t data_count;
} NavGridOfDoublesUpdate;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_2D_MSGS_NAVGRIDOFDOUBLESUPDATE_H

View File

@@ -0,0 +1,24 @@
#ifndef C_API_NAV_2D_MSGS_PATH2D_H
#define C_API_NAV_2D_MSGS_PATH2D_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "nav_2d_msgs/Pose2DStamped.h"
typedef struct
{
Header header;
Pose2DStamped *poses;
size_t poses_count;
} Path2D;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_2D_MSGS_PATH2D_H

View File

@@ -0,0 +1,21 @@
#ifndef C_API_NAV_2D_MSGS_POINT2D_H
#define C_API_NAV_2D_MSGS_POINT2D_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct
{
double x;
double y;
} Point2D;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_2D_MSGS_POINT2D_H

View File

@@ -0,0 +1,22 @@
#ifndef C_API_NAV_2D_MSGS_POLYGON2D_H
#define C_API_NAV_2D_MSGS_POLYGON2D_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "nav_2d_msgs/Point2D.h"
typedef struct
{
Point2D *points;
size_t points_count;
} Polygon2D;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_2D_MSGS_POLYGON2D_H

View File

@@ -0,0 +1,27 @@
#ifndef C_API_NAV_2D_MSGS_POLYGON2DCOLLECTION_H
#define C_API_NAV_2D_MSGS_POLYGON2DCOLLECTION_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "std_msgs/ColorRGBA.h"
#include "nav_2d_msgs/ComplexPolygon2D.h"
typedef struct
{
Header header;
ComplexPolygon2D *polygons;
size_t polygons_count;
ColorRGBA *colors;
size_t colors_count;
} Polygon2DCollection;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_2D_MSGS_POLYGON2DCOLLECTION_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_NAV_2D_MSGS_POLYGON2DSTAMPED_H
#define C_API_NAV_2D_MSGS_POLYGON2DSTAMPED_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "nav_2d_msgs/Polygon2D.h"
typedef struct
{
Header header;
Polygon2D polygon;
} Polygon2DStamped;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_2D_MSGS_POLYGON2DSTAMPED_H

View File

@@ -0,0 +1,22 @@
#ifndef C_API_NAV_2D_MSGS_POSE2D32_H
#define C_API_NAV_2D_MSGS_POSE2D32_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct
{
float x;
float y;
float theta;
} Pose2D32;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_2D_MSGS_POSE2D32_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_NAV_2D_MSGS_POSE2DSTAMPED_H
#define C_API_NAV_2D_MSGS_POSE2DSTAMPED_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "geometry_msgs/Pose2D.h"
typedef struct
{
Header header;
Pose2D pose;
} Pose2DStamped;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_2D_MSGS_POSE2DSTAMPED_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_NAV_2D_MSGS_SWITCHPLUGIN_H
#define C_API_NAV_2D_MSGS_SWITCHPLUGIN_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "nav_2d_msgs/SwitchPluginRequest.h"
#include "nav_2d_msgs/SwitchPluginResponse.h"
typedef struct
{
SwitchPluginRequest request;
SwitchPluginResponse response;
} SwitchPlugin;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_2D_MSGS_SWITCHPLUGIN_H

View File

@@ -0,0 +1,20 @@
#ifndef C_API_NAV_2D_MSGS_SWITCHPLUGINREQUEST_H
#define C_API_NAV_2D_MSGS_SWITCHPLUGINREQUEST_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct
{
char *new_plugin;
} SwitchPluginRequest;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_2D_MSGS_SWITCHPLUGINREQUEST_H

View File

@@ -0,0 +1,21 @@
#ifndef C_API_NAV_2D_MSGS_SWITCHPLUGINRESPONSE_H
#define C_API_NAV_2D_MSGS_SWITCHPLUGINRESPONSE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct
{
uint8_t success;
char *message;
} SwitchPluginResponse;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_2D_MSGS_SWITCHPLUGINRESPONSE_H

View File

@@ -0,0 +1,22 @@
#ifndef C_API_NAV_2D_MSGS_TWIST2D_H
#define C_API_NAV_2D_MSGS_TWIST2D_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct
{
double x;
double y;
double theta;
} Twist2D;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_2D_MSGS_TWIST2D_H

View File

@@ -0,0 +1,22 @@
#ifndef C_API_NAV_2D_MSGS_TWIST2D32_H
#define C_API_NAV_2D_MSGS_TWIST2D32_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct
{
float x;
float y;
float theta;
} Twist2D32;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_2D_MSGS_TWIST2D32_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_NAV_2D_MSGS_TWIST2DSTAMPED_H
#define C_API_NAV_2D_MSGS_TWIST2DSTAMPED_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "nav_2d_msgs/Twist2D.h"
typedef struct
{
Header header;
Twist2D velocity;
} Twist2DStamped;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_2D_MSGS_TWIST2DSTAMPED_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_NAV_2D_MSGS_UINTBOUNDS_H
#define C_API_NAV_2D_MSGS_UINTBOUNDS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct
{
uint32_t min_x;
uint32_t min_y;
uint32_t max_x;
uint32_t max_y;
} UIntBounds;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_2D_MSGS_UINTBOUNDS_H

View File

@@ -0,0 +1,533 @@
#ifndef NAVIGATION_C_API_H
#define NAVIGATION_C_API_H
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
/* C struct types only - do not include convertor.h here (it pulls C++ code into extern "C") */
#include "std_msgs/Header.h"
#include "geometry_msgs/Point.h"
#include "geometry_msgs/Pose2D.h"
#include "geometry_msgs/PoseStamped.h"
#include "nav_msgs/OccupancyGrid.h"
#include "nav_msgs/Odometry.h"
#include "map_msgs/OccupancyGridUpdate.h"
#include "nav_2d_msgs/Twist2D.h"
#include "nav_2d_msgs/Twist2DStamped.h"
#include "nav_2d_msgs/Path2D.h"
#include "sensor_msgs/LaserScan.h"
#include "sensor_msgs/PointCloud.h"
#include "sensor_msgs/PointCloud2.h"
#include "geometry_msgs/PolygonStamped.h"
#include "protocol_msgs/Order.h"
typedef struct { char *name; OccupancyGrid grid; } NamedOccupancyGrid;
typedef struct { char *name; LaserScan scan; } NamedLaserScan;
typedef struct { char *name; PointCloud cloud; } NamedPointCloud;
typedef struct { char *name; PointCloud2 cloud; } NamedPointCloud2;
typedef void* NavigationHandle;
typedef void* TFListenerHandle;
typedef enum
{
PENDING = 0,
ACTIVE = 1,
PREEMPTED = 2,
SUCCEEDED = 3,
ABORTED = 4,
REJECTED = 5,
PREEMPTING = 6,
RECALLING = 7,
RECALLED = 8,
LOST = 9,
PLANNING = 10,
CONTROLLING = 11,
CLEARING = 12,
PAUSED = 13
} NavigationState;
typedef struct
{
NavigationState navigation_state;
char *feed_back_str;
Pose2D current_pose;
bool goal_checked;
bool is_ready;
} NavFeedback;
/**
* @brief Planner data output structure (C version).
* Mirrors robot::move_base_core::PlannerDataOutput in `move_base_core/navigation.h`.
*/
typedef struct
{
Path2D plan;
OccupancyGrid costmap;
OccupancyGridUpdate costmap_update;
bool is_costmap_updated;
PolygonStamped footprint;
} PlannerDataOutput;
/**
* @brief Free a string allocated by the API (e.g. feed_back_str, navigation_state_to_string result).
* @param str Pointer from strdup; no-op if NULL.
*/
void nav_c_api_free_string(char *str);
/**
* @brief Name of a navigation state, for logging.
* @return Newly allocated string; free with nav_c_api_free_string().
*/
char *navigation_state_to_string(NavigationState state);
/**
* @brief Offset a 2D pose along its own heading.
* @param in_pose Source pose.
* @param frame_id Frame the result is expressed in; must not be NULL.
* @param offset_distance [m] Positive moves forward, negative backward.
* @param out_goal Result. `out_goal.header.frame_id` is allocated — free it with
* nav_c_api_free_string().
* @return false if @p frame_id is NULL.
*/
bool navigation_offset_goal_2d(const Pose2D &in_pose, const char *frame_id,
double offset_distance, PoseStamped &out_goal);
/**
* @brief Offset a stamped pose along its own heading, keeping its frame.
* @param in_pose Source pose.
* @param offset_distance [m] Positive moves forward, negative backward.
* @param out_goal Result. `out_goal.header.frame_id` is allocated — free it with
* nav_c_api_free_string().
*/
bool navigation_offset_goal_stamped(const PoseStamped &in_pose, double offset_distance,
PoseStamped &out_goal);
/**
* @brief Create a new navigation instance
* @return Navigation handle, or NULL on failure
*/
NavigationHandle navigation_create(void);
/**
* @brief Destroy a navigation instance
* @param handle Navigation handle to destroy
*/
void navigation_destroy(NavigationHandle handle);
// ============================================================================
// Navigation Interface Methods
// ============================================================================
/**
* @brief Initialize the navigation system using an existing tf3 buffer (from libtf3 tf3_buffer_create).
* Caller retains ownership of the buffer and must call tf3_buffer_destroy when done (after navigation_destroy).
* @param handle Navigation handle
* @param tf3_buffer Pointer to tf3 BufferCore (TF3_BufferCore from libtf3)
* @return true if the arguments were valid and the call did not throw — **not** whether the core
* actually came up. The underlying contract method returns void, so a runtime that fails
* to build its costmaps or load its plugins still returns here normally.
*
* @warning Blocking and expensive: it builds the costmaps, loads every plugin named in the YAML
* and starts the control thread. Do not call it from a UI thread.
* @warning Push at least one static map with navigation_add_static_map() **before** this call.
* The lattice planner blocks until the costmap has a non-zero size, and aborts the whole
* process if it waits too long.
* @see navigation_initialize_checked() in nav_c_api_2.h, which reports the real outcome.
*/
bool navigation_initialize(NavigationHandle handle, TFListenerHandle tf3_buffer);
/**
* @brief Set the robot's footprint (outline shape)
* @param handle Navigation handle
* @param points Array of points representing the footprint polygon
* @param point_count Number of points in the array
* @return true on success, false on failure
*/
bool navigation_set_robot_footprint(NavigationHandle handle, const Point *points, size_t point_count);
/**
* @brief Get the robot's footprint (outline shape)
* @param handle Navigation handle
* @param out_points Array **the caller allocates and owns**. Nothing here is allocated by the
* library, and nothing needs freeing.
* @param out_count Output only — the number of points written. It is NOT read as a capacity.
* @return true on success, false if the footprint is empty or the handle is invalid
*
* @warning The signature carries no capacity, so this function writes as many points as the robot
* footprint has, whatever the array can hold. Size @p out_points for the largest
* footprint the deployment can configure (64 points is comfortable) — a short array is
* overrun, and the corruption will surface somewhere unrelated.
*/
bool navigation_get_robot_footprint(NavigationHandle handle, Point *out_points, size_t &out_count);
/**
* @brief Send a goal for the robot to navigate to
* @param handle Navigation handle
* @param goal Target pose in the global frame
* @return true if goal was accepted and sent successfully
*/
bool navigation_move_to(NavigationHandle handle, const PoseStamped goal);
/**
* @brief Send a goal for the robot to navigate to
* @param handle Navigation handle
* @param order Order message
* @param goal Target pose in the global frame
* @return true if goal was accepted and sent successfully
* @note If order was obtained from convert2COrder(), call order_free(&order) when done
*/
bool navigation_move_to_order(NavigationHandle handle, const Order order, const PoseStamped goal);
/**
* @brief Send a goal for the robot to navigate to
* @param handle Navigation handle
* @param nodes Nodes array
* @param node_count Number of nodes in the array
* @param edges Edges array
* @param edge_count Number of edges in the array
* @param goal Target pose in the global frame
* @return true if goal was accepted and sent successfully
*/
bool navigation_move_to_nodes_edges(NavigationHandle handle, const Node *nodes, size_t node_count, const Edge *edges, size_t edge_count, const PoseStamped goal);
/*
* navigation_dock_to, navigation_dock_to_order, navigation_dock_to_nodes_edges,
* navigation_move_straight_to and navigation_rotate_to were removed. They pushed a goal past
* the mission layer, which left them free to replace the leg the mission queue was running
* while the queue kept handing out the next leg of a route the robot had already left.
*
* Docking, go-straight and rotate are now ordinary legs of an order: set `profile:` on the leg
* (`docking | go_straight | rotate`) and `marker` for docking, then send the order through
* navigation_move_to_order() or navigation_move_to_nodes_edges().
*/
/**
* @brief Pause the robot's movement
* @param handle Navigation handle
*/
void navigation_pause(NavigationHandle handle);
/**
* @brief Resume motion after a pause
* @param handle Navigation handle
*/
void navigation_resume(NavigationHandle handle);
/**
* @brief Cancel the current goal and stop the robot
* @param handle Navigation handle
*/
void navigation_cancel(NavigationHandle handle);
/**
* @brief Set the linear velocity **ceiling** — not a jog command.
*
* This is the path a safety layer uses to slow the robot down. The value is passed to the core
* exactly as given, sign included: the local planner keeps a separate ceiling per direction and
* **the sign of @p linear_x selects which one this call sets** — negative sets the backward
* ceiling, positive the forward one.
*
* One call therefore sets one direction. To bound both, call twice:
* @code
* navigation_set_twist_linear(h, 0.6, 0.0, 0.0); // forward <= 0.6 m/s
* navigation_set_twist_linear(h, -0.3, 0.0, 0.0); // backward <= 0.3 m/s
* @endcode
*
* @param handle Navigation handle
* @param linear_x [m/s] Ceiling, signed. The sign picks the direction; it is not discarded.
* @param linear_y [m/s] Lateral ceiling (holonomic bases only).
* @param linear_z [m/s] Unused by ground bases.
* @return true if the ceiling was accepted. NaN/Inf are rejected.
*
* @note The new ceiling takes effect on the core's next control cycle, not inside this call.
*/
bool navigation_set_twist_linear(NavigationHandle handle,
double linear_x, double linear_y, double linear_z);
/**
* @brief Set the angular velocity **ceiling** — not a jog command.
* @param handle Navigation handle
* @param angular_x [rad/s] Unused by ground bases.
* @param angular_y [rad/s] Unused by ground bases.
* @param angular_z [rad/s] Yaw rate ceiling.
* @return true if the ceiling was accepted. NaN/Inf are rejected.
*
* @note Takes effect on the core's next control cycle.
*/
bool navigation_set_twist_angular(NavigationHandle handle,
double angular_x, double angular_y, double angular_z);
/**
* @brief Get the robot's pose as a PoseStamped
* @param handle Navigation handle
* @param out_pose Output parameter with the robot's current pose
* @return true if pose was successfully retrieved
* @note out_pose.header.frame_id is allocated — free it with nav_c_api_free_string().
*/
bool navigation_get_robot_pose_stamped(NavigationHandle handle, PoseStamped &out_pose);
/**
* @brief Get the robot's pose as a 2D pose
* @param handle Navigation handle
* @param out_pose Output parameter with the robot's current 2D pose
* @return true if pose was successfully retrieved
*/
bool navigation_get_robot_pose_2d(NavigationHandle handle, Pose2D &out_pose);
/**
* @brief Get the robot's current twist
* @param handle Navigation handle
* @param out_twist Output parameter with the robot's current twist
* @return true if twist was successfully retrieved
* @note out_twist->header.frame_id must be freed using nav_c_api_free_string
*/
bool navigation_get_twist(NavigationHandle handle, Twist2DStamped &out_twist);
/**
* @brief Get navigation feedback
* @param handle Navigation handle
* @param out_feedback Output parameter with navigation feedback
* @return true if feedback was successfully retrieved
* @note The feed_back_str field must be freed using nav_c_api_free_string
*/
bool navigation_get_feedback(NavigationHandle handle, NavFeedback &out_feedback);
/**
* @brief Add a static map to the navigation system
* @param handle Navigation handle
* @param map_name Name of the map
* @param map Occupancy grid handle
* @return true if the map was added successfully
*/
bool navigation_add_static_map(NavigationHandle handle, const char *map_name, const OccupancyGrid occupancy_grid);
/**
* @brief Add a laser scan to the navigation system
* @param handle Navigation handle
* @param laser_scan_name Name of the laser scan
* @param laser_scan Laser scan handle
* @return true if the laser scan was added successfully
*/
bool navigation_add_laser_scan(NavigationHandle handle, const char *laser_scan_name, const LaserScan laser_scan);
/**
* @brief Add a point cloud to the navigation system
* @param handle Navigation handle
* @param point_cloud_name Name of the point cloud
* @param point_cloud Point cloud handle
* @return true if the point cloud was added successfully
*/
bool navigation_add_point_cloud(NavigationHandle handle, const char *point_cloud_name, const PointCloud point_cloud);
/**
* @brief Add a point cloud2 to the navigation system
* @param handle Navigation handle
* @param point_cloud2_name Name of the point cloud2
* @param point_cloud2 Point cloud2 handle
* @return true if the point cloud2 was added successfully
*/
bool navigation_add_point_cloud2(NavigationHandle handle, const char *point_cloud2_name, const PointCloud2 point_cloud2);
/**
* @brief Add an odometry to the navigation system
* @param handle Navigation handle
* @param odometry_name Name of the odometry
* @param odometry Odometry handle
* @return true if the odometry was added successfully
*/
bool navigation_add_odometry(NavigationHandle handle, const char *odometry_name, const Odometry odometry);
// ==========================================================================
// Reading data back
//
// @warning The four navigation_get_<sensor>() functions below return true for a name the core has
// never seen: the lookup falls back to a default-constructed message, and this API cannot
// tell that apart from a message that is genuinely empty. Check the payload (a grid with
// width 0, a scan with no ranges) rather than trusting the return value. A misspelt name
// is the most common configuration mistake on the sensor path, and it is exactly the case
// this API stays silent about.
//
// Everything these functions fill is allocated by the library. Release it with the
// matching navigation_free_*() in nav_c_api_2.h.
// ==========================================================================
/**
* @brief Get a static map from the navigation system
* @param handle Navigation handle
* @param map_name Name of the map
* @param out_map Output parameter for the map handle
* @return true if the call succeeded — see the warning above, this is not "the map exists"
*/
bool navigation_get_static_map(NavigationHandle handle, const char *map_name, OccupancyGrid &out_map);
/**
* @brief Get a laser scan from the navigation system
* @param handle Navigation handle
* @param laser_scan_name Name of the laser scan
* @param out_scan Output parameter for the laser scan handle
* @return true if the laser scan was retrieved successfully
*/
bool navigation_get_laser_scan(NavigationHandle handle, const char *laser_scan_name, LaserScan &out_scan);
/**
* @brief Get a point cloud from the navigation system
* @param handle Navigation handle
* @param point_cloud_name Name of the point cloud
* @param out_cloud Output parameter for the point cloud handle
* @return true if the point cloud was retrieved successfully
*/
bool navigation_get_point_cloud(NavigationHandle handle, const char *point_cloud_name, PointCloud &out_cloud);
/**
* @brief Get a point cloud2 from the navigation system
* @param handle Navigation handle
* @param point_cloud2_name Name of the point cloud2
* @param out_cloud Output parameter for the point cloud2 handle
* @return true if the point cloud2 was retrieved successfully
*/
bool navigation_get_point_cloud2(NavigationHandle handle, const char *point_cloud2_name, PointCloud2 &out_cloud);
// ==========================================================================
// Reading every entry at once
//
// @warning The four navigation_get_all_*() functions take an array the CALLER allocates, and the
// signature carries no capacity — @c out_count is an output, never read as a limit. Each
// function writes one element per entry the core currently holds, however large the
// array is. Size the array for the largest number of sensor streams the deployment can
// register; a short array is overrun by whole structs, and the damage surfaces far from
// here.
//
// Each element's `name` and payload are allocated by the library: free `name` with
// nav_c_api_free_string() and the payload with the matching navigation_free_*().
// ==========================================================================
/**
* @brief Get all static maps from the navigation system
* @param handle Navigation handle
* @param out_maps Caller-allocated array — see the capacity warning above
* @param out_count Output only: how many entries were written
* @return true if the maps were retrieved successfully
*/
bool navigation_get_all_static_maps(NavigationHandle handle, NamedOccupancyGrid *out_maps, size_t &out_count);
/**
* @brief Get all laser scans from the navigation system
* @param handle Navigation handle
* @param out_scans Output parameter for the scans array
* @param out_count Output parameter for the number of scans
* @return true if the scans were retrieved successfully
*/
bool navigation_get_all_laser_scans(NavigationHandle handle, NamedLaserScan *out_scans, size_t &out_count);
/**
* @brief Get all point clouds from the navigation system
* @param handle Navigation handle
* @param out_clouds Output parameter for the clouds array
* @param out_count Output parameter for the number of clouds
* @return true if the clouds were retrieved successfully
*/
bool navigation_get_all_point_clouds(NavigationHandle handle, NamedPointCloud *out_clouds, size_t &out_count);
/**
* @brief Get all point cloud2s from the navigation system
* @param handle Navigation handle
* @param out_clouds Output parameter for the clouds array
* @param out_count Output parameter for the number of clouds
* @return true if the clouds were retrieved successfully
*/
bool navigation_get_all_point_cloud2s(NavigationHandle handle, NamedPointCloud2 *out_clouds, size_t &out_count);
/**
* @brief Remove a static map from the navigation system
* @param handle Navigation handle
* @param map_name Name of the map
* @return true if the map was removed successfully
*/
bool navigation_remove_static_map(NavigationHandle handle, const char *map_name);
/**
* @brief Remove a laser scan from the navigation system
* @param handle Navigation handle
* @param laser_scan_name Name of the laser scan
* @return true if the laser scan was removed successfully
*/
bool navigation_remove_laser_scan(NavigationHandle handle, const char *laser_scan_name);
/**
* @brief Remove a point cloud from the navigation system
* @param handle Navigation handle
* @param point_cloud_name Name of the point cloud
* @return true if the point cloud was removed successfully
*/
bool navigation_remove_point_cloud(NavigationHandle handle, const char *point_cloud_name);
/**
* @brief Remove a point cloud2 from the navigation system
* @param handle Navigation handle
* @param point_cloud2_name Name of the point cloud2
* @return true if the point cloud2 was removed successfully
*/
bool navigation_remove_point_cloud2(NavigationHandle handle, const char *point_cloud2_name);
/**
* @brief Remove all static maps from the navigation system
* @param handle Navigation handle
* @return true if the maps were removed successfully
*/
bool navigation_remove_all_static_maps(NavigationHandle handle);
/**
* @brief Remove all laser scans from the navigation system
* @param handle Navigation handle
* @return true if the scans were removed successfully
*/
bool navigation_remove_all_laser_scans(NavigationHandle handle);
/**
* @brief Remove all point clouds from the navigation system
* @param handle Navigation handle
* @return true if the clouds were removed successfully
*/
bool navigation_remove_all_point_clouds(NavigationHandle handle);
/**
* @brief Remove all point cloud2s from the navigation system
* @param handle Navigation handle
* @return true if the cloud2s were removed successfully
*/
bool navigation_remove_all_point_cloud2s(NavigationHandle handle);
/**
* @brief Remove all data from the navigation system
* @param handle Navigation handle
* @return true if the data was removed successfully
*/
bool navigation_remove_all_data(NavigationHandle handle);
/**
* @brief Get the global data from the navigation system
* @param handle Navigation handle
* @param out_data Output parameter for the data
* @return true if the data was retrieved successfully
*/
bool navigation_get_global_data(NavigationHandle handle, PlannerDataOutput *out_data);
/**
* @brief Get the local data from the navigation system
* @param handle Navigation handle
* @param out_data Output parameter for the data
* @return true if the data was retrieved successfully
*/
bool navigation_get_local_data(NavigationHandle handle, PlannerDataOutput *out_data);
#ifdef __cplusplus
}
#endif
#endif // NAVIGATION_C_API_H

View File

@@ -0,0 +1,323 @@
#ifndef NAVIGATION_C_API_2_H
#define NAVIGATION_C_API_2_H
/**
* @file nav_c_api_2.h
* @brief Additional C entry points required by the move_base2 navigation runtime.
*
* ## What this file is
*
* `nav_c_api.h` covers the navigation contract as the previous runtime exposed it. Every one of
* those functions keeps working against move_base2 — move_base2 implements
* `robot::move_base_core::BaseNavigation` with the signatures unchanged, so no existing binding
* breaks. This file adds what that contract gained but the C surface never exposed, plus the two
* entry points move_base2 makes newly necessary:
*
* - navigation_shutdown() — quiesce the core before destroying it.
* - navigation_is_ready() — did initialize() actually succeed?
* - navigation_initialize_checked() — initialize + verify, in one call.
* - navigation_get_state() — poll the state without allocating a string.
* - navigation_get_status_text() — the core's own explanation, for logging.
* - navigation_add_depth_camera_data() — the depth-camera input path, never exposed before.
* - navigation_move_to_order_v2() — an order carrying a real orderId / orderUpdateId.
* - navigation_execute_instant_actions() — a VDA5050 instantActions message, expanded like node actions.
*
* Include this header **in addition to** nav_c_api.h. It adds symbols; it replaces none.
*
* ## What changed underneath the functions you already call
*
* These keep their signatures and their meaning, but behave differently enough to matter:
*
* 1. navigation_initialize() is now heavy and blocking — it builds both costmaps, loads the
* planners, the controller, the recovery behaviours and the mission layer, then starts the
* control thread. It still returns `true` unconditionally because the underlying contract
* returns void. Use navigation_initialize_checked(), or call navigation_is_ready() after it.
*
* 2. A static map must be pushed **before** initialize(). The lattice planner blocks until the
* costmap has a non-zero size, and that size only exists once a static map has reached the
* static layer. It aborts the whole process if it waits too long.
*
* 3. navigation_set_robot_footprint() may now be called before initialize() — the footprint is
* cached and applied while the costmaps are built. Under the old runtime the same call was
* dropped silently because the costmaps did not exist yet.
*
* 4. navigation_pause() / _resume() / _cancel() no longer take effect inside the call. They record
* the request; the control thread applies it on its next cycle. Returning from the call does
* not mean the robot stopped — watch the state, or watch the twist.
*
* 5. navigation_set_twist_linear() / _angular() set a velocity **ceiling**, and the sign of the
* linear x component selects which direction the ceiling applies to. They now only reject
* NaN/Inf; the old runtime also returned false while a cancel was in flight, and that signal no
* longer exists. The new ceiling takes effect on the next control cycle.
*
* 6. navigation_get_twist() returns the command being issued, not a measurement. While no request
* is running its stamp stops advancing; a zero stamp means the core has never commanded
* anything. Check the stamp before republishing it as a velocity command.
*
* 7. NavFeedback.feed_back_str now carries the core's own reason strings — different text from the
* old runtime. Branch on NavigationState, never on the string.
*
* 8. NavFeedback.navigation_state deliberately reports ACTIVE between the legs of a multi-leg
* order, where the core itself is momentarily SUCCEEDED or PENDING. Treating SUCCEEDED as "the
* order finished" stays correct only because of that; do not bypass it.
*
* 9. navigation_add_odometry() feeds the controller's measured velocity every cycle, not just a
* stored value. Push it at the rate the odometry source produces it.
*
* 10. The `footprint` field of navigation_get_global_data() / _local_data() is the raw footprint the
* host set, in the robot base frame, and it is empty if the host never set one. The old runtime
* returned the padded footprint already transformed to the robot pose in the global frame.
*
* 11. navigation_destroy() alone is no longer enough — call navigation_shutdown() first, from a
* point in your own shutdown sequence where the process is still fully alive.
*
* See NAV_C_API_2_GUIDE.md in this directory for the per-function walkthrough and the startup and
* shutdown sequences.
*/
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include "nav_c_api.h"
#include "sensor_msgs/DepthCameraData.h"
#include "sensor_msgs/LaserScan.h"
#include "sensor_msgs/PointCloud.h"
#include "sensor_msgs/PointCloud2.h"
#include "nav_msgs/OccupancyGrid.h"
#include "protocol_msgs/Node.h"
#include "protocol_msgs/Edge.h"
// ============================================================================================
// Lifecycle
// ============================================================================================
/**
* @brief Initialize the navigation core and report whether it actually came up.
*
* Wraps navigation_initialize(). The underlying contract method returns void, so every failure
* path inside the runtime — costmap construction, sensor configuration, plugin loading, control
* loop configuration, control thread startup — returns normally and only records the reason in
* the feedback. This function reads that back and turns it into a return value.
*
* Blocking and expensive: it builds two costmaps, loads every plugin named in the YAML, starts
* the map-update threads, the mission threads and the control thread. Do not call it from a UI
* thread.
*
* @param handle Navigation handle from navigation_create().
* @param tf3_buffer tf3 BufferCore the host owns; must outlive the navigation instance.
* @return true only when the core is ready to accept goals.
*
* @pre At least one static map has been pushed with navigation_add_static_map().
* @pre The robot footprint has been set with navigation_set_robot_footprint(), if the host wants
* its own footprint rather than the one in the YAML.
* @see navigation_get_status_text() for the reason behind a false return.
*/
bool navigation_initialize_checked(NavigationHandle handle, TFListenerHandle tf3_buffer);
/**
* @brief Is the core initialized and accepting goals?
*
* Cheap enough to poll. Reads the same flag navigation_initialize_checked() checks, without
* allocating the feedback string.
*
* @return false if the handle is null, the core never initialized, or initialization failed.
*/
bool navigation_is_ready(NavigationHandle handle);
/**
* @brief Stop the core's threads without destroying the instance.
*
* Gives the host a point inside its own shutdown sequence — while the process is still fully
* alive — to stop the control thread, the costmap update threads and the mission threads.
* Destroying the instance from a finalizer, after the runtime has already begun tearing down, is
* the race this exists to avoid.
*
* After this call the core issues no further velocity commands, and every getter
* (navigation_get_feedback, navigation_get_twist, navigation_get_robot_pose_*) remains safe to
* call. Safe to call more than once.
*
* @warning No thread may be calling navigation_add_* while this runs, and none may call them
* afterwards. The sensor path is not thread-safe and there is no longer a control thread
* consuming what it produces.
*/
void navigation_shutdown(NavigationHandle handle);
// ============================================================================================
// Status
// ============================================================================================
/**
* @brief Current navigation state, without allocating anything.
*
* navigation_get_feedback() strdup()s its message on every call, so polling it at control rate
* means one allocation and one free per poll — and one leak per missed free. Use this when only
* the state matters, which is the common case.
*
* @param handle Navigation handle.
* @param out_state Receives the current state; untouched on failure.
* @return false if the handle is null or the core has no feedback yet.
*/
bool navigation_get_state(NavigationHandle handle, NavigationState *out_state);
/**
* @brief The core's own description of what it is doing, or why it refused.
*
* For logging and diagnostics only. The wording comes from the runtime and changes between
* versions — never branch on it. Branch on navigation_get_state().
*
* @return Newly allocated string, or NULL. Free with nav_c_api_free_string().
*/
char *navigation_get_status_text(NavigationHandle handle);
// ============================================================================================
// Sensor input
// ============================================================================================
/**
* @brief Push one coherent depth-camera sample into the navigation core.
*
* This is the only way to reach the depth-camera path from C. The voxel layer projects the depth
* image through the intrinsics to build the camera frustum, which is what lets it *clear* stale
* obstacles inside the field of view. A point cloud cannot substitute: it carries no intrinsics,
* so no frustum can be reconstructed and nothing gets cleared.
*
* @param handle Navigation handle.
* @param topic Logical name of the stream. Must match an `observation_source` declared for the
* voxel layer in the costmap YAML — a name no layer subscribes to is accepted here
* and then dropped, silently, further down.
* @param data Depth image and its matching intrinsics. Deep-copied; the caller may release its
* buffers as soon as this returns.
* @return true if the sample was accepted.
*
* @pre `data.header.frame_id` is the camera's optical frame, and a transform from it to the robot
* base frame exists in the tf3 buffer at `data.header.stamp`.
* @pre `data.depth.encoding` matches the real encoding ("16UC1" or "32FC1") and `step` is the
* real row stride in bytes.
* @pre `data.camera_info` describes the resolution actually being sent, not the colour stream's.
* @pre The depth image and the camera info come from the same instant.
*
* @note Push at the camera's real rate. This is the most expensive sensor path in the core;
* pushing faster than the source only burns CPU.
*/
bool navigation_add_depth_camera_data(NavigationHandle handle, const char *topic,
const DepthCameraData data);
// ============================================================================================
// Orders
// ============================================================================================
/**
* @brief Send a multi-node order with a real identity.
*
* Under move_base2 an order goes through the mission layer, which splits it into legs at the
* nodes that carry actions, filters by `released`, and can extend the route when the fleet master
* releases more of the horizon. `orderId` plus `orderUpdateId` is what identifies an order there:
* the same `orderId` with a higher `orderUpdateId` is an update of the route in progress, while a
* different `orderId` is a new order that replaces it.
*
* navigation_move_to_nodes_edges() cannot express that — it has nowhere to put either field — so
* every call looks like a different order and no update can ever be sent. Use this instead
* whenever the fleet master sends order updates or releases the horizon progressively.
*
* @param handle Navigation handle.
* @param order_id VDA5050 orderId. Must not be NULL or empty.
* @param order_update_id VDA5050 orderUpdateId. Must increase within one orderId.
* @param nodes Node array; the host keeps ownership.
* @param node_count Number of nodes.
* @param edges Edge array; the host keeps ownership.
* @param edge_count Number of edges.
* @param goal Final pose, in the global frame.
* @return true if the order was accepted.
*/
bool navigation_move_to_order_v2(NavigationHandle handle,
const char *order_id, uint32_t order_update_id,
const Node *nodes, size_t node_count,
const Edge *edges, size_t edge_count,
const PoseStamped goal);
/*
* navigation_dock_to_order_v2 was removed. Docking is a per-leg property of the order now: set
* `profile: docking` and `marker` on the leg, then send it through navigation_move_to_order_v2.
*/
/**
* @brief Run one VDA5050 `instantActions` message — the whole list, as one batch.
*
* Each action is expanded against the same compound-action table that node actions use, so
* `PickUp` sent as an instantAction produces the same detect / approach / lift / back-out
* sequence it produces inside an order. One vocabulary, one set of handlers, one meaning per
* actionType regardless of how it arrived.
*
* Pass the message's actions together rather than calling this once per action: a second `HARD`
* action submitted on its own preempts and wipes the legs of the first, so two actions sent in
* one message would eat each other.
*
* Execution stops at the first leg that fails and the rest of the message is dropped with it, so
* the caller reports ONE outcome for the message — which is all VDA5050 asks for.
*
* `blockingType` decides how the batch meets a running order: any `HARD` action makes the whole
* message preempt it, otherwise it queues behind it. `NONE` requests execution in parallel with
* driving, which this runtime cannot do — it is queued instead and the narrowing is logged. An
* unset or unknown blockingType is treated as `HARD`, the safe direction.
*
* Do NOT route `cancelOrder`, `startPause` or `stopPause` here. Those steer the queue rather
* than being work in it: call navigation_cancel(), navigation_pause() and navigation_resume().
*
* Progress is reported through the ordinary state, not per action: poll navigation_get_state()
* and map ACTIVE/CONTROLLING to RUNNING, SUCCEEDED to FINISHED, ABORTED/PREEMPTED to FAILED.
* That mapping is only unambiguous while this message is the only work in the queue, which holds
* as long as the fleet master sends one message at a time and none during an order.
*
* @param handle Navigation handle.
* @param actions Array of actions, in the order received. The host keeps ownership.
* @param count Number of actions. Must be > 0.
* @return true if the message was accepted. false means rejected outright — report it failed
* rather than waiting for a result that will not come.
*/
bool navigation_execute_instant_actions(NavigationHandle handle, const Action *actions,
size_t count);
// ============================================================================================
// Releasing what the getters allocate
// ============================================================================================
//
// Every navigation_get_* function that returns a grid, a scan, a cloud or a plan fills it with
// buffers allocated inside the library. Only two release helpers ever shipped —
// nav_c_api_free_string() and order_free() — so the rest had no counterpart and leaked one
// allocation per call. At four display timers polling at 10 Hz that is a steady leak, not a
// rounding error. These close it.
//
// All are null-safe, clear the pointers and counts they release, and are safe to call twice.
/** @brief Release the buffers inside an OccupancyGrid filled by navigation_get_static_map(). */
void navigation_free_occupancy_grid(OccupancyGrid *grid);
/** @brief Release the buffers inside a LaserScan filled by navigation_get_laser_scan(). */
void navigation_free_laser_scan(LaserScan *scan);
/** @brief Release the buffers inside a PointCloud filled by navigation_get_point_cloud(). */
void navigation_free_point_cloud(PointCloud *cloud);
/** @brief Release the buffers inside a PointCloud2 filled by navigation_get_point_cloud2(). */
void navigation_free_point_cloud2(PointCloud2 *cloud);
/**
* @brief Release the buffers inside a PlannerDataOutput.
*
* navigation_get_global_data() / _local_data() already release the previous contents of the
* struct they are handed, so reusing one struct across polls does not leak. What does leak is the
* last fill, once the host stops polling — free it here.
*/
void navigation_free_planner_data(PlannerDataOutput *data);
#ifdef __cplusplus
}
#endif
#endif // NAVIGATION_C_API_2_H

View File

@@ -0,0 +1,29 @@
#ifndef C_API_NAV_MSGS_ACTIONTYPES_H
#define C_API_NAV_MSGS_ACTIONTYPES_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Time.h"
typedef struct
{
Time stamp;
char *id;
} GoalID;
typedef struct
{
GoalID goal_id;
uint8_t status;
char *text;
} GoalStatus;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_ACTIONTYPES_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_NAV_MSGS_GETMAP_H
#define C_API_NAV_MSGS_GETMAP_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "nav_msgs/GetMapRequest.h"
#include "nav_msgs/GetMapResponse.h"
typedef struct
{
GetMapRequest request;
GetMapResponse response;
} GetMap;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_GETMAP_H

View File

@@ -0,0 +1,25 @@
#ifndef C_API_NAV_MSGS_GETMAPACTION_H
#define C_API_NAV_MSGS_GETMAPACTION_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "nav_msgs/GetMapActionGoal.h"
#include "nav_msgs/GetMapActionResult.h"
#include "nav_msgs/GetMapActionFeedback.h"
typedef struct
{
GetMapActionGoal action_goal;
GetMapActionResult action_result;
GetMapActionFeedback action_feedback;
} GetMapAction;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_GETMAPACTION_H

View File

@@ -0,0 +1,25 @@
#ifndef C_API_NAV_MSGS_GETMAPACTIONFEEDBACK_H
#define C_API_NAV_MSGS_GETMAPACTIONFEEDBACK_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "nav_msgs/ActionTypes.h"
#include "nav_msgs/GetMapFeedback.h"
typedef struct
{
Header header;
GoalStatus status;
GetMapFeedback feedback;
} GetMapActionFeedback;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_GETMAPACTIONFEEDBACK_H

View File

@@ -0,0 +1,25 @@
#ifndef C_API_NAV_MSGS_GETMAPACTIONGOAL_H
#define C_API_NAV_MSGS_GETMAPACTIONGOAL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "nav_msgs/ActionTypes.h"
#include "nav_msgs/GetMapGoal.h"
typedef struct
{
Header header;
GoalID goal_id;
GetMapGoal goal;
} GetMapActionGoal;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_GETMAPACTIONGOAL_H

View File

@@ -0,0 +1,25 @@
#ifndef C_API_NAV_MSGS_GETMAPACTIONRESULT_H
#define C_API_NAV_MSGS_GETMAPACTIONRESULT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "nav_msgs/ActionTypes.h"
#include "nav_msgs/GetMapResult.h"
typedef struct
{
Header header;
GoalStatus status;
GetMapResult result;
} GetMapActionResult;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_GETMAPACTIONRESULT_H

View File

@@ -0,0 +1,20 @@
#ifndef C_API_NAV_MSGS_GETMAPFEEDBACK_H
#define C_API_NAV_MSGS_GETMAPFEEDBACK_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct
{
uint8_t _dummy;
} GetMapFeedback;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_GETMAPFEEDBACK_H

View File

@@ -0,0 +1,20 @@
#ifndef C_API_NAV_MSGS_GETMAPGOAL_H
#define C_API_NAV_MSGS_GETMAPGOAL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct
{
uint8_t _dummy;
} GetMapGoal;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_GETMAPGOAL_H

View File

@@ -0,0 +1,20 @@
#ifndef C_API_NAV_MSGS_GETMAPREQUEST_H
#define C_API_NAV_MSGS_GETMAPREQUEST_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct
{
uint8_t _dummy;
} GetMapRequest;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_GETMAPREQUEST_H

View File

@@ -0,0 +1,21 @@
#ifndef C_API_NAV_MSGS_GETMAPRESPONSE_H
#define C_API_NAV_MSGS_GETMAPRESPONSE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "nav_msgs/OccupancyGrid.h"
typedef struct
{
OccupancyGrid map;
} GetMapResponse;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_GETMAPRESPONSE_H

View File

@@ -0,0 +1,21 @@
#ifndef C_API_NAV_MSGS_GETMAPRESULT_H
#define C_API_NAV_MSGS_GETMAPRESULT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "nav_msgs/OccupancyGrid.h"
typedef struct
{
OccupancyGrid map;
} GetMapResult;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_GETMAPRESULT_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_NAV_MSGS_GETPLAN_H
#define C_API_NAV_MSGS_GETPLAN_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "nav_msgs/GetPlanRequest.h"
#include "nav_msgs/GetPlanResponse.h"
typedef struct
{
GetPlanRequest request;
GetPlanResponse response;
} GetPlan;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_GETPLAN_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_NAV_MSGS_GETPLANREQUEST_H
#define C_API_NAV_MSGS_GETPLANREQUEST_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "geometry_msgs/PoseStamped.h"
typedef struct
{
PoseStamped start;
PoseStamped goal;
float tolerance;
} GetPlanRequest;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_GETPLANREQUEST_H

View File

@@ -0,0 +1,21 @@
#ifndef C_API_NAV_MSGS_GETPLANRESPONSE_H
#define C_API_NAV_MSGS_GETPLANRESPONSE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "nav_msgs/Path.h"
typedef struct
{
Path plan;
} GetPlanResponse;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_GETPLANRESPONSE_H

View File

@@ -0,0 +1,26 @@
#ifndef C_API_NAV_MSGS_GRIDCELLS_H
#define C_API_NAV_MSGS_GRIDCELLS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "geometry_msgs/Point.h"
typedef struct
{
Header header;
float cell_width;
float cell_height;
Point *cells;
size_t cells_count;
} GridCells;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_GRIDCELLS_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_NAV_MSGS_LOADMAP_H
#define C_API_NAV_MSGS_LOADMAP_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "nav_msgs/LoadMapRequest.h"
#include "nav_msgs/LoadMapResponse.h"
typedef struct
{
LoadMapRequest request;
LoadMapResponse response;
} LoadMap;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_LOADMAP_H

View File

@@ -0,0 +1,20 @@
#ifndef C_API_NAV_MSGS_LOADMAPREQUEST_H
#define C_API_NAV_MSGS_LOADMAPREQUEST_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct
{
char *map_url;
} LoadMapRequest;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_LOADMAPREQUEST_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_NAV_MSGS_LOADMAPRESPONSE_H
#define C_API_NAV_MSGS_LOADMAPRESPONSE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include "nav_msgs/OccupancyGrid.h"
typedef struct
{
OccupancyGrid map;
bool result;
} LoadMapResponse;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_LOADMAPRESPONSE_H

View File

@@ -0,0 +1,26 @@
#ifndef C_API_NAV_MSGS_MAPMETADATA_H
#define C_API_NAV_MSGS_MAPMETADATA_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Time.h"
#include "geometry_msgs/Pose.h"
typedef struct
{
Time map_load_time;
float resolution;
uint32_t width;
uint32_t height;
Pose origin;
} MapMetaData;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_MAPMETADATA_H

View File

@@ -0,0 +1,25 @@
#ifndef C_API_NAV_MSGS_OCCUPANCYGRID_H
#define C_API_NAV_MSGS_OCCUPANCYGRID_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "nav_msgs/MapMetaData.h"
typedef struct
{
Header header;
MapMetaData info;
int8_t *data;
size_t data_count;
} OccupancyGrid;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_OCCUPANCYGRID_H

View File

@@ -0,0 +1,35 @@
#ifndef C_API_NAV_MSGS_ODOMETRY_H
#define C_API_NAV_MSGS_ODOMETRY_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "geometry_msgs/PoseWithCovariance.h"
#include "geometry_msgs/TwistWithCovariance.h"
typedef struct
{
Header header;
char *child_frame_id;
PoseWithCovariance pose;
TwistWithCovariance twist;
} Odometry;
extern "C" Odometry odometry_create(void);
extern "C" Odometry odometry_set_data(
Header header,
char *child_frame_id,
PoseWithCovariance pose,
TwistWithCovariance twist);
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_ODOMETRY_H

View File

@@ -0,0 +1,24 @@
#ifndef C_API_NAV_MSGS_PATH_H
#define C_API_NAV_MSGS_PATH_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "geometry_msgs/PoseStamped.h"
typedef struct
{
Header header;
PoseStamped *poses;
size_t poses_count;
} Path;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_PATH_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_NAV_MSGS_SETMAP_H
#define C_API_NAV_MSGS_SETMAP_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "nav_msgs/SetMapRequest.h"
#include "nav_msgs/SetMapResponse.h"
typedef struct
{
SetMapRequest request;
SetMapResponse response;
} SetMap;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_SETMAP_H

View File

@@ -0,0 +1,23 @@
#ifndef C_API_NAV_MSGS_SETMAPREQUEST_H
#define C_API_NAV_MSGS_SETMAPREQUEST_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "nav_msgs/OccupancyGrid.h"
#include "geometry_msgs/PoseWithCovariance.h"
typedef struct
{
OccupancyGrid map;
PoseWithCovariance initial_pose;
} SetMapRequest;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_SETMAPREQUEST_H

View File

@@ -0,0 +1,21 @@
#ifndef C_API_NAV_MSGS_SETMAPRESPONSE_H
#define C_API_NAV_MSGS_SETMAPRESPONSE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
typedef struct
{
bool success;
} SetMapResponse;
#ifdef __cplusplus
}
#endif
#endif // C_API_NAV_MSGS_SETMAPRESPONSE_H

View File

@@ -0,0 +1,30 @@
#ifndef C_API_PROTOCOL_MSGS_ACTION_H
#define C_API_PROTOCOL_MSGS_ACTION_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "protocol_msgs/ActionParameter.h"
#define PROTOCOL_MSGS_ACTION_BLOCKING_NONE "NONE"
#define PROTOCOL_MSGS_ACTION_BLOCKING_SOFT "SOFT"
#define PROTOCOL_MSGS_ACTION_BLOCKING_HARD "HARD"
typedef struct
{
char *actionType;
char *actionId;
char *actionDescription;
char *blockingType;
ActionParameter *actionParameters;
size_t actionParameters_count;
} Action;
#ifdef __cplusplus
}
#endif
#endif // C_API_PROTOCOL_MSGS_ACTION_H

View File

@@ -0,0 +1,21 @@
#ifndef C_API_PROTOCOL_MSGS_ACTIONPARAMETER_H
#define C_API_PROTOCOL_MSGS_ACTIONPARAMETER_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct
{
char *key;
char *value;
} ActionParameter;
#ifdef __cplusplus
}
#endif
#endif // C_API_PROTOCOL_MSGS_ACTIONPARAMETER_H

View File

@@ -0,0 +1,22 @@
#ifndef C_API_PROTOCOL_MSGS_CONTROLPOINT_H
#define C_API_PROTOCOL_MSGS_CONTROLPOINT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct
{
double x;
double y;
double weight;
} ControlPoint;
#ifdef __cplusplus
}
#endif
#endif // C_API_PROTOCOL_MSGS_CONTROLPOINT_H

View File

@@ -0,0 +1,42 @@
#ifndef C_API_PROTOCOL_MSGS_EDGE_H
#define C_API_PROTOCOL_MSGS_EDGE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "protocol_msgs/Trajectory.h"
#include "protocol_msgs/Action.h"
#define PROTOCOL_MSGS_EDGE_ORIENTATION_GLOBAL "GLOBAL"
#define PROTOCOL_MSGS_EDGE_ORIENTATION_TANGENTIAL "TANGENTIAL"
typedef struct
{
char *edgeId;
int32_t sequenceId;
char *edgeDescription;
uint8_t released;
char *startNodeId;
char *endNodeId;
double maxSpeed;
double maxHeight;
double minHeight;
double orientation;
char *orientationType;
char *direction;
uint8_t rotationAllowed;
double maxRotationSpeed;
Trajectory trajectory;
double length;
Action *actions;
size_t actions_count;
} Edge;
#ifdef __cplusplus
}
#endif
#endif // C_API_PROTOCOL_MSGS_EDGE_H

View File

@@ -0,0 +1,28 @@
#ifndef C_API_PROTOCOL_MSGS_ERROR_H
#define C_API_PROTOCOL_MSGS_ERROR_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "protocol_msgs/ErrorReference.h"
#define PROTOCOL_MSGS_ERROR_LEVEL_WARNING "WARNING"
#define PROTOCOL_MSGS_ERROR_LEVEL_FATAL "FATAL"
typedef struct
{
char *errorType;
ErrorReference *errorReferences;
size_t errorReferences_count;
char *errorDescription;
char *errorLevel;
} Error;
#ifdef __cplusplus
}
#endif
#endif // C_API_PROTOCOL_MSGS_ERROR_H

View File

@@ -0,0 +1,21 @@
#ifndef C_API_PROTOCOL_MSGS_ERRORREFERENCE_H
#define C_API_PROTOCOL_MSGS_ERRORREFERENCE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct
{
char *referenceKey;
char *referenceValue;
} ErrorReference;
#ifdef __cplusplus
}
#endif
#endif // C_API_PROTOCOL_MSGS_ERRORREFERENCE_H

View File

@@ -0,0 +1,28 @@
#ifndef C_API_PROTOCOL_MSGS_INFO_H
#define C_API_PROTOCOL_MSGS_INFO_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "protocol_msgs/InfoReference.h"
#define PROTOCOL_MSGS_INFO_LEVEL_DEBUG "DEBUG"
#define PROTOCOL_MSGS_INFO_LEVEL_INFO "INFO"
typedef struct
{
char *infoType;
InfoReference *infoReferences;
size_t infoReferences_count;
char *infoDescription;
char *infoLevel;
} Info;
#ifdef __cplusplus
}
#endif
#endif // C_API_PROTOCOL_MSGS_INFO_H

View File

@@ -0,0 +1,21 @@
#ifndef C_API_PROTOCOL_MSGS_INFOREFERENCE_H
#define C_API_PROTOCOL_MSGS_INFOREFERENCE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct
{
char *referenceKey;
char *referenceValue;
} InfoReference;
#ifdef __cplusplus
}
#endif
#endif // C_API_PROTOCOL_MSGS_INFOREFERENCE_H

View File

@@ -0,0 +1,22 @@
#ifndef C_API_PROTOCOL_MSGS_INFORMATION_H
#define C_API_PROTOCOL_MSGS_INFORMATION_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "protocol_msgs/Info.h"
typedef struct
{
Info *information;
size_t information_count;
} Information;
#ifdef __cplusplus
}
#endif
#endif // C_API_PROTOCOL_MSGS_INFORMATION_H

View File

@@ -0,0 +1,28 @@
#ifndef C_API_PROTOCOL_MSGS_NODE_H
#define C_API_PROTOCOL_MSGS_NODE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "protocol_msgs/NodePosition.h"
#include "protocol_msgs/Action.h"
typedef struct
{
char *nodeId;
int32_t sequenceId;
char *nodeDescription;
uint8_t released;
NodePosition nodePosition;
Action *actions;
size_t actions_count;
} Node;
#ifdef __cplusplus
}
#endif
#endif // C_API_PROTOCOL_MSGS_NODE_H

View File

@@ -0,0 +1,26 @@
#ifndef C_API_PROTOCOL_MSGS_NODEPOSITION_H
#define C_API_PROTOCOL_MSGS_NODEPOSITION_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct
{
double x;
double y;
double theta;
float allowedDeviationXY;
float allowedDeviationTheta;
char *mapId;
char *mapDescription;
} NodePosition;
#ifdef __cplusplus
}
#endif
#endif // C_API_PROTOCOL_MSGS_NODEPOSITION_H

View File

@@ -0,0 +1,33 @@
#ifndef C_API_PROTOCOL_MSGS_ORDER_H
#define C_API_PROTOCOL_MSGS_ORDER_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "protocol_msgs/Node.h"
#include "protocol_msgs/Edge.h"
typedef struct
{
int32_t headerId;
char *timestamp;
char *version;
char *manufacturer;
char *serialNumber;
char *orderId;
uint32_t orderUpdateId;
Node *nodes;
size_t nodes_count;
Edge *edges;
size_t edges_count;
char *zoneSetId;
} Order;
#ifdef __cplusplus
}
#endif
#endif // C_API_PROTOCOL_MSGS_ORDER_H

View File

@@ -0,0 +1,25 @@
#ifndef C_API_PROTOCOL_MSGS_TRAJECTORY_H
#define C_API_PROTOCOL_MSGS_TRAJECTORY_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "protocol_msgs/ControlPoint.h"
typedef struct
{
uint32_t degree;
double *knotVector;
size_t knotVector_count;
ControlPoint *controlPoints;
size_t controlPoints_count;
} Trajectory;
#ifdef __cplusplus
}
#endif
#endif // C_API_PROTOCOL_MSGS_TRAJECTORY_H

View File

@@ -0,0 +1,38 @@
#ifndef C_API_SENSOR_MSGS_BATTERYSTATE_H
#define C_API_SENSOR_MSGS_BATTERYSTATE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
typedef struct
{
Header header;
float voltage;
float current;
float charge;
float capacity;
float design_capacity;
float percentage;
uint8_t power_supply_status;
uint8_t power_supply_health;
uint8_t power_supply_technology;
bool present;
float *cell_voltage;
size_t cell_voltage_count;
float *cell_temperature;
size_t cell_temperature_count;
char *location;
char *serial_number;
} BatteryState;
#ifdef __cplusplus
}
#endif
#endif // C_API_SENSOR_MSGS_BATTERYSTATE_H

View File

@@ -0,0 +1,33 @@
#ifndef C_API_SENSOR_MSGS_CAMERAINFO_H
#define C_API_SENSOR_MSGS_CAMERAINFO_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "sensor_msgs/RegionOfInterest.h"
typedef struct
{
Header header;
uint32_t height;
uint32_t width;
char *distortion_model;
double *D;
size_t D_count;
double K[9];
double R[9];
double P[12];
uint32_t binning_x;
uint32_t binning_y;
RegionOfInterest roi;
} CameraInfo;
#ifdef __cplusplus
}
#endif
#endif // C_API_SENSOR_MSGS_CAMERAINFO_H

View File

@@ -0,0 +1,22 @@
#ifndef C_API_SENSOR_MSGS_CHANNELFLOAT32_H
#define C_API_SENSOR_MSGS_CHANNELFLOAT32_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct
{
char *name;
float *values;
size_t values_count;
} ChannelFloat32;
#ifdef __cplusplus
}
#endif
#endif // C_API_SENSOR_MSGS_CHANNELFLOAT32_H

View File

@@ -0,0 +1,24 @@
#ifndef C_API_SENSOR_MSGS_COMPRESSEDIMAGE_H
#define C_API_SENSOR_MSGS_COMPRESSEDIMAGE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
typedef struct
{
Header header;
char *format;
uint8_t *data;
size_t data_count;
} CompressedImage;
#ifdef __cplusplus
}
#endif
#endif // C_API_SENSOR_MSGS_COMPRESSEDIMAGE_H

View File

@@ -0,0 +1,36 @@
#ifndef C_API_SENSOR_MSGS_DEPTHCAMERADATA_H
#define C_API_SENSOR_MSGS_DEPTHCAMERADATA_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "std_msgs/Header.h"
#include "sensor_msgs/Image.h"
#include "sensor_msgs/CameraInfo.h"
/**
* @brief One coherent depth-camera sample: a depth image plus the intrinsics that describe it.
*
* Mirrors robot_sensor_msgs::DepthCameraData. "Coherent" is the whole point of the struct: the
* voxel layer projects every depth pixel through the intrinsics to build a frustum, so a depth
* image paired with intrinsics from a different resolution or a different instant clears the wrong
* volume of space. Pair them at the source, not here.
*/
typedef struct
{
/** Canonical timestamp and optical frame of this sample. */
Header header;
/** Depth image. `encoding` must be the true encoding ("16UC1" or "32FC1"). */
Image depth;
/** Intrinsics of the exact image above — same resolution, same instant. */
CameraInfo camera_info;
} DepthCameraData;
#ifdef __cplusplus
}
#endif
#endif // C_API_SENSOR_MSGS_DEPTHCAMERADATA_H

Some files were not shown because too many files have changed in this diff Show More