refactor: fire controller - #65
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
Walkthrough本 PR 重构了火控与跟踪链路:射击评估、弹道求解和火控瞄准流程改为新的参数与状态表达;跟踪模型统一 getter 命名并新增旋转速度;同时更新配置结构、调试信息输出、日志 const 限定与开发规范。 Changes火控/跟踪重构与配套变更
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@AGENTS.md`:
- Line 26: The command example uses inconsistent placeholder styling in the
clang-tidy invocation: <构建目录> is wrapped in backticks while <修改的文件路径> uses angle
brackets. Update the example in the documentation to use the same angle-bracket
placeholder style consistently, using the clang-tidy command snippet as the
reference location.
In `@src/kernel/fire_control.cpp`:
- Around line 166-175: The dynamic window in fire_control.cpp is mixing units:
config.attack_window is already in radians, but velocity/acceleration limits in
the physical_limit calculation are being normalized by 2π before comparison,
which can shrink the window too much at high speeds. Update the logic in the
fire_control path so the limits compared against attack_window use consistent
angle units, and verify the returned window values in the function that builds
the dynamic attack window remain in radians.
In `@src/module/fire_control/shoot_evaluator.cpp`:
- Around line 136-137: The pitch stability check in shoot_evaluator.cpp is using
the current gimbal pitch instead of the previous command, which can bypass
require_stable_command for pitch changes. Update the command_stable logic in the
code around in_yaw_window/in_pitch_window to compare last_command->pitch against
command.pitch for the pitch window, keeping the yaw comparison unchanged.
🪄 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: 0c1beb5c-6f00-42a4-a9f9-5ab0dd84a1ad
📒 Files selected for processing (19)
AGENTS.mdconfig/config.yamlsrc/kernel/auto_aim.cppsrc/kernel/fire_control.cppsrc/kernel/fire_control.hppsrc/kernel/tracker.cppsrc/kernel/tracker.hppsrc/module/fire_control/gimbal_state.hppsrc/module/fire_control/shoot_evaluator.cppsrc/module/fire_control/shoot_evaluator.hppsrc/module/fire_control/trajectory_solution.cppsrc/module/fire_control/trajectory_solution.hppsrc/module/tracker/model/outpost.cppsrc/module/tracker/model/outpost.hppsrc/module/tracker/model/robot.cppsrc/module/tracker/model/robot.hppsrc/module/tracker/trackable.hppsrc/utility/logging/printer.cppsrc/utility/logging/printer.hpp
💤 Files with no reviewable changes (1)
- src/module/fire_control/gimbal_state.hpp
概括
经测试,高速小陀螺 43 / 63 ≈ 70%,低速小陀螺 56 / 63 ≈ 90%,下面是低速小陀螺的效果视频:
6f5ae92b9c4b789eaba87bc15de16bbb.mp4
本次 PR 重构了火控链路与其与跟踪模块/自动瞄准的联动,重点提升高速、小角度场景下的瞄准稳定性与命中一致性。
FireControllerV2将对外输入统一为update(Timestamp, double yaw, double pitch)并缓存cached_stamp/cached_yaw/cached_pitch;在aim()中根据 当前输入时间戳与 trackable 时间戳的差值 计算increment = shoot_delay + (cached_stamp - trackable.get_timestamp),随后通过trackable.clone()->jump_into(fly_time + increment)进行延迟补偿后的未来预测,再结合弹道求解迭代收敛 yaw/pitch。FireControllerV2新增max_vel/max_acc约束,并在get_attack_window()中基于周期时间动态收缩attack_window;Aimed结构体新增pre_aim标志,auto_aim绘制/上色逻辑区分shoot / pre_aim / 其他,以便可视化瞄准状态差异。ShootEvaluator不再依赖GimbalState/YAML初始化,改为接收evaluate(Command, yaw, pitch);其 yaw/pitch 容差基于几何关系进行动态缩放(通过cos(yaw_angle(center, armor))影响容差窗口),并通过require_stable_command与is_lazy_gimbal在 yaw/pitch 窗口内执行稳定性与惰性云台判断。Trackable/RobotModel/OutpostModel的direction/aimpoints/timestamp迁移为get_direction/get_aimpoints/get_timestamp,并新增get_rotation_speed();同时在TrackerV2::Addition增加infos承载多条带文本与点位的调试信息,在前哨站/机器人收敛分支输出旋转角速度与速度分量等。Point3d,并对TrajectorySolution做命名空间与内部实现重构(将常量/估计逻辑收进文件内details)。fire_control配置移除旧的shoot_evaluator子结构,改为直接引入速度/加速度约束、稳定/惰性开关以及 yaw/pitch 容差等字段;AGENTS.md新增基于clangd --check与clang-tidy -p的“先静态检查再编译验证”流程;Printer日志模板/实现改为const成员函数以兼容只读调用场景。整体上,修改把火控决策链从“静态阈值 + 旧接口”升级为“结合时间戳差的延迟补偿预测 + 速度约束的攻击窗口 + 几何驱动的容差窗口与稳定性/惰性云台判定”,并同步完成 tracker/模型接口统一与可视化调试信息增强。