refactor: update AutoAimState with center position, adapt Adapter and…#44
refactor: update AutoAimState with center position, adapt Adapter and…#44creeper5820 merged 1 commit intomainfrom
Conversation
… sync component.cpp
Walkthrough该PR更新了自动瞄准系统的配置参数,引入了新的 Changes自动瞄准系统重构与配置调优
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/component.cpp (1)
27-27: ⚡ Quick win把注册初值也同步到 NaN 语义。
这里已经把“无指令”统一成
kNaN/kVectorNaN,但register_output里的control_direction、yaw_rate、pitch_rate、yaw_acc、pitch_acc仍然以0注册。若下游在首次update()前读取这些输出,会拿到看起来合法的零值而不是“无效态”。建议把注册初值一起改掉,和set_default_command()保持一致。建议修改
- register_output("/auto_aim/control_direction", target_direction, Eigen::Vector3d::Zero()); + register_output("/auto_aim/control_direction", target_direction, kVectorNaN); register_output("/auto_aim/robot_center", robot_center, kVectorNaN); register_output("/auto_aim/should_shoot", should_shoot, false); - register_output("/auto_aim/yaw_rate", yaw_rate, 0.0); - register_output("/auto_aim/pitch_rate", pitch_rate, 0.0); - register_output("/auto_aim/yaw_acc", yaw_acc, 0.0); - register_output("/auto_aim/pitch_acc", pitch_acc, 0.0); + register_output("/auto_aim/yaw_rate", yaw_rate, kNaN); + register_output("/auto_aim/pitch_rate", pitch_rate, kNaN); + register_output("/auto_aim/yaw_acc", yaw_acc, kNaN); + register_output("/auto_aim/pitch_acc", pitch_acc, kNaN);Also applies to: 114-124
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/component.cpp` at line 27, The registered output initial values for control signals are still 0 while the rest of the module uses NaN semantics; update the register_output calls for control_direction, yaw_rate, pitch_rate, yaw_acc, and pitch_acc to use kVectorNaN or kNaN as appropriate (matching the types used by set_default_command) so downstream readers before the first update() see an invalid/NaN state rather than zeros; locate these in the register_output invocations and replace the zero defaults with the corresponding kNaN/kVectorNaN constants to keep semantics consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/utility/shared/context.hpp`:
- Line 15: context.hpp uses std::numeric_limits<double>::quiet_NaN() (kNaN and
another usage at line ~45) but does not explicitly include <limits>; add an
explicit `#include` <limits> in context.hpp to satisfy header self-containment and
update the include ordering so standard headers (like <limits>) appear in the
standard-library group (between local and third-party groups with a single blank
line separating groups) before including "utility/math/linear.hpp".
---
Nitpick comments:
In `@src/component.cpp`:
- Line 27: The registered output initial values for control signals are still 0
while the rest of the module uses NaN semantics; update the register_output
calls for control_direction, yaw_rate, pitch_rate, yaw_acc, and pitch_acc to use
kVectorNaN or kNaN as appropriate (matching the types used by
set_default_command) so downstream readers before the first update() see an
invalid/NaN state rather than zeros; locate these in the register_output
invocations and replace the zero defaults with the corresponding kNaN/kVectorNaN
constants to keep semantics consistent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7953ac86-c40a-490a-805d-8460d8ba4845
📒 Files selected for processing (5)
config/config.yamlsrc/adapter/adapter.hppsrc/component.cppsrc/runtime.cppsrc/utility/shared/context.hpp
… sync component.cpp
PR 摘要
概述
本PR重构了自动瞄准系统的核心状态管理结构,增加了机器人中心位置追踪功能,并相应更新了适配器和组件的实现。主要涉及配置参数调整、新增Adapter类、以及对多个运行时组件的同步更新。
主要变更
配置参数调整 (config/config.yaml)
capturer.invert_image: true → false)initial_bullet_speed: 21.0 → 24.2)yaw_offset: 2.5 → 0.0)outpost_leaving_angle: 50.0 → 30.0)is_lazy_gimbal: true → false)新增适配器模块 (src/adapter/adapter.hpp)
rmcs::Adapter类,用于统一管理TF(Transform Frames)数据访问ready(): 检查TF系统准备状态camera_transform(): 获取OdomImu → CameraLink的变换矩阵(Eigen::Isometry3d)barrel_direction(): 获取枪管方向向量(Eigen::Vector3d)状态结构重构 (src/utility/shared/context.hpp)
AutoAimState增加robot_center字段,用于追踪机器人中心位置static constexpr kNaN常量,替代分散的std::numeric_limits<double>::quiet_NaN()调用组件核心逻辑更新 (src/component.cpp)
/auto_aim/robot_center,以支持中心位置的发布set_default_command()辅助函数,用于初始化每帧的默认输出latest.has_value()进行早期返回,处理缺失的飞书命令robot_center、速率/加速度和前馈有效性等字段adapter/sentry.hpp切换到adapter/adapter.hpp运行时初始化优化 (src/runtime.cpp)
<filesystem>标准库头文件utility/math/linear.hpp依赖visualization.update_mpc_plan()传递命令的偏航/俯仰角及其对应的速率和加速度参数技术意义
变更统计