Yuyuyu/relocation#14
Merged
vhjcgja-789 merged 5 commits intomainfrom May 6, 2026
Merged
Conversation
|
Caution Review failedPull request was closed or merged during review 概览此 PR 将 ROS2 服务驱动的 变更重定位功能集成
序列图sequenceDiagram
participant Lua as Lua 脚本
participant Nav as Navigation 组件
participant API as Lua API 层
participant Loc as Localization 引擎
participant Service as rmcs_relocation<br/>ROS2 服务
Lua->>Nav: 调用 api.relocalize_initial(x, y, yaw)
Nav->>API: 触发注册的重定位绑定
API->>Loc: 调用 relocalize(mode, x, y, yaw)
Loc->>Service: 异步发送 Relocalize 服务请求
activate Service
Loc->>Loc: arm_timeout() 启动超时定时器
Lua->>Nav: 轮询 api.relocalize_status()
Nav->>API: 查询状态
API->>Loc: 调用 relocalize_status()
Loc->>Loc: 从 Session 快照返回状态
API-->>Nav: 返回状态表<br/>(state, success, ...)
Service-->>Loc: 返回服务响应
deactivate Service
Loc->>Loc: status_from_response()<br/>更新 Session::last_status
Loc->>Loc: 取消超时定时器
Lua->>Nav: 轮询 api.relocalize_status()
Nav->>API: 查询状态
API->>Loc: 调用 relocalize_status()
Loc-->>API: 返回 SUCCEEDED 或失败态
API-->>Lua: 返回最终状态表
Lua->>Lua: 记录结果,继续执行
代码审查工作量估计🎯 3 (中等复杂) | ⏱️ ~20 分钟 诗歌
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
接入重定位服务
重定位服务集成
概览
本PR集成了重定位服务(rmcs_relocation),将导航系统从基于PCL/ND-T的点云定位重构为ROS2服务客户端驱动的重定位机制。主要改动包括新增重定位功能的编译依赖、服务接入逻辑以及完整的Lua API绑定。
关键变更
构建系统
github/workflows/ci.yml):新增步骤在RMCS工作空间克隆rmcs_relocation仓库至/tmp/RMCS/rmcs_ws/src/skills/rmcs_relocationrmcs_relocation依赖并链接其包含目录和库文件rmcs_relocation运行时依赖核心C++组件
导航组件 (
src/cxx/component.cc)Localization实例管理和relocalization_enabled标志relocalize_initial、relocalize_local、relocalize_wide三个重定位函数,以及relocalize_status状态查询函数定位引擎重构 (
src/cxx/util/localization/engine.cc/hh)从PCL点云定位完全重写为ROS2服务客户端模式:
API变更:
start_collecting()、start_localizing()方法relocalize(RelocalizeMode mode, double x, double y, double yaw) -> boolrelocalize_status() const -> RelocalizeStatus新增公开类型:
RelocalizeState枚举:IDLE、IN_FLIGHT、SUCCEEDED、FAILEDRelocalizeMode枚举:Initial、Local、Wide(对应初始化、局部、广域三种定位模式)RelocalizeStatus结构体:包含状态、成功标志、消息、适应度分数、置信度、估计位置(xyz)和四元数方向Config结构简化:
实现机制:
Lua脚本层
Lua API定义 (
src/lua/api.lua)文档化新增函数签名:
relocalize_initial/local/wide(x: number, y: number, yaw: number): booleanrelocalize_status(): table(包含state、success、message、fitness_score、confidence字段)动作控制流程 (
src/lua/action.lua)新增结构化重定位工作流:
relocalize_initial:单次重定位请求relocalize_local:循环重试模式,依赖验证锚点位姿(不可用则立即失败)relocalize_wide:使用用户位姿作为先验,回退至原点(位姿不可用时仍继续发送)send_and_await共享辅助函数:发送请求后轮询状态直至SUCCEEDED或终止态,返回最终状态和成功标志pose_unavailable校验器检测缺失或NaN位姿值架构变更
从点云驱动的本地定位方案演进为分布式服务模型,支持三层定位策略(初始、局部、广域),降低了导航系统与具体定位实现的耦合度。