From 97063bea1e2e34749d9839a9d75d0c63824eda94 Mon Sep 17 00:00:00 2001 From: Latuuuuu Date: Wed, 25 Nov 2026 20:52:34 +0800 Subject: [PATCH] feat(contract): localization pose is nav_msgs/Odometry on the stream QoS --- base/eurobot_common/contract.yaml | 8 +++++--- base/eurobot_common/test/test_contract.cpp | 11 ++++++++++- docs/contract.md | 2 +- docs/reference/config.md | 7 ++++--- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/base/eurobot_common/contract.yaml b/base/eurobot_common/contract.yaml index 53bc577..240296b 100644 --- a/base/eurobot_common/contract.yaml +++ b/base/eurobot_common/contract.yaml @@ -60,12 +60,14 @@ topics: LOCALIZATION_POSE: name: /robot/localization/pose - type: geometry_msgs/msg/PoseWithCovarianceStamped - qos: sensor + type: nav_msgs/msg/Odometry + qos: stream publisher: localization subscribers: [navigation, main] rate_hz: 50 - doc: Fused robot pose in the map frame. header.stamp = time of the newest fused measurement. + doc: >- + Fused robot pose in the map frame (the 2026 final_pose; child_frame_id = robot frame, + pose.covariance from the EKF). header.stamp = time of the newest fused measurement. VISION_RIVAL_POSES: name: /robot/vision/rival_poses diff --git a/base/eurobot_common/test/test_contract.cpp b/base/eurobot_common/test/test_contract.cpp index 08fbb0d..3b033ff 100644 --- a/base/eurobot_common/test/test_contract.cpp +++ b/base/eurobot_common/test/test_contract.cpp @@ -4,15 +4,24 @@ #include "eurobot_common/contract.hpp" +using eurobot_common::contract::HEARTBEAT; using eurobot_common::contract::LOCALIZATION_POSE; using eurobot_common::contract::STARTUP_STATUS; TEST(Contract, SensorTopicsAreBestEffortKeepLast1) { - auto qos = LOCALIZATION_POSE.qos().get_rmw_qos_profile(); + auto qos = HEARTBEAT.qos().get_rmw_qos_profile(); EXPECT_EQ(qos.reliability, RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT); EXPECT_EQ(qos.depth, 1u); } +// Nav2 subscribes to odometry as reliable; a best_effort publisher would never match. +TEST(Contract, StreamTopicsAreReliableKeepLast10) { + auto qos = LOCALIZATION_POSE.qos().get_rmw_qos_profile(); + EXPECT_EQ(qos.reliability, RMW_QOS_POLICY_RELIABILITY_RELIABLE); + EXPECT_EQ(qos.durability, RMW_QOS_POLICY_DURABILITY_VOLATILE); + EXPECT_EQ(qos.depth, 10u); +} + TEST(Contract, StateTopicsLatch) { auto qos = STARTUP_STATUS.qos().get_rmw_qos_profile(); EXPECT_EQ(qos.durability, RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL); diff --git a/docs/contract.md b/docs/contract.md index 8a288f8..01c5be0 100644 --- a/docs/contract.md +++ b/docs/contract.md @@ -17,7 +17,7 @@ |---|---|---|---|---|---|---| | `/robot/startup/status` | `eurobot_interfaces/msg/StartupStatus` | state | main | * | | Which domains have reported ready; all_ready gates the match start. | | `/robot/system/heartbeat` | `eurobot_interfaces/msg/ModuleHeartbeat` | sensor | * | main | 1 | One message per module per second; missing heartbeats mean a dead module. | -| `/robot/localization/pose` | `geometry_msgs/msg/PoseWithCovarianceStamped` | sensor | localization | navigation, main | 50 | Fused robot pose in the map frame. header.stamp = time of the newest fused measurement. | +| `/robot/localization/pose` | `nav_msgs/msg/Odometry` | stream | localization | navigation, main | 50 | Fused robot pose in the map frame (the 2026 final_pose; child_frame_id = robot frame, pose.covariance from the EKF). header.stamp = time of the newest fused measurement. | | `/robot/vision/rival_poses` | `geometry_msgs/msg/PoseArray` | sensor | vision | localization, navigation, main | 15 | Detected opponent robots in the map frame. | | `/robot/navigation/goal` | `geometry_msgs/msg/PoseStamped` | command | main | navigation | | Where main wants the robot to go next. | | `/robot/navigation/status` | `std_msgs/msg/String` | state | navigation | main | | One of: idle, moving, arrived, blocked. | diff --git a/docs/reference/config.md b/docs/reference/config.md index 32760a6..6ddc487 100644 --- a/docs/reference/config.md +++ b/docs/reference/config.md @@ -118,12 +118,13 @@ qos: sensor: {reliability: best_effort, durability: volatile, history: keep_last, depth: 1} state: {reliability: reliable, durability: transient_local, history: keep_last, depth: 1} command: {reliability: reliable, durability: volatile, history: keep_last, depth: 10} + stream: {reliability: reliable, durability: volatile, history: keep_last, depth: 10} topics: LOCALIZATION_POSE: name: /robot/localization/pose - type: geometry_msgs/msg/PoseWithCovarianceStamped - qos: sensor + type: nav_msgs/msg/Odometry + qos: stream publisher: localization subscribers: [navigation, main] rate_hz: 50 @@ -133,7 +134,7 @@ topics: | 欄位 | 說明 | |---|---| | `domains` | 系統可識別的 domain;啟動交握會拒絕不在此清單中的 domain | -| `qos` | 三種 QoS profile;每個 topic 必須從中選用一種,請勿自行定義 | +| `qos` | 四種 QoS profile;每個 topic 必須從中選用一種,請勿自行定義 | | `topics.` | KEY 會成為程式中的常數:`contract.LOCALIZATION_POSE` / `eurobot_common::contract::LOCALIZATION_POSE` | | `name` | 格式為 `/robot/<區域>/<東西>`,使用 snake_case;區域為擁有該 topic 的 domain,或 `startup` / `system` | | `type` | message 型別,請盡量使用標準型別 |