Skip to content

refactor: robot model and tracker - #64

Merged
creeper5820 merged 20 commits into
mainfrom
refactor/robot-model
Jun 30, 2026
Merged

refactor: robot model and tracker#64
creeper5820 merged 20 commits into
mainfrom
refactor/robot-model

Conversation

@creeper5820

@creeper5820 creeper5820 commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

概括

引入了基于 2D 观测的全新机器人 EKF 模型,效果拔群,性能优越,顺手重构了 snapshot 体系,trackable 将取而代之

重构止步于火控模块,planner 或等效优化器将于后续的 PR 引入

本次变更围绕“机器人模型与跟踪器重构”展开,核心是将旧的 Image/Snapshot/Tracker/FireControl 链路替换为基于 cv::Mat/Trackable/TrackerV2/FireControllerV2 的新体系,并在火控模块上止步于“瞄准/开火决策”(规划器/优化器后续另提)。

  • 机器人 EKF 模型与 trackable 抽象

    • 新增 RobotModel(EKF)用于机器人状态估计,提供相机/坐标更新、init/predict/correct、收敛/发散判断与装甲/灯条几何输出。
    • 新增 TrackableIns<State> 封装层:统一 aimpoints()direction()timestamp()jump_into()clone() 等接口,支撑 2D→3D→预测后的通用跟踪对象。
  • 跟踪系统重构:TrackerV2

    • TrackerV2 替换旧的 Tracker/Decider/ArmorFilter/Snapshot 等体系,改为 update_* / clean / store(...) / execute(Timestamp) 的缓存-执行管线。
    • 通过 update_track_color / update_track_genre 设置跟踪条件,并在 execute 阶段更新前哨站与机器人模型、做目标选择,输出 Trackable::Uniqueaddition()(tracked 2D/3D 与可选 lightbar 列表)。
    • 前哨站模型补充收敛判定与状态推进相关能力(如 converge()State 增加 index 等)。
  • 火控系统重构:FireControllerV2(去除旧 MPC/规划链路)

    • FireControllerV2 替换旧 FireControl,核心接口从 solve(snapshot, gimbal_state) 迁移为 aim(trackable)
    • 新流程:根据 trackable.direction() 估计飞行时间、jump_into(shoot_delay + fly_time) 后对 aimpoints() 进行装甲候选筛选与选择(带攻击窗口/角度容差),迭代 TrajectorySolution 求解得到 yaw/pitch,并应用偏置。
    • ShootEvaluator 的命令字段改为 center/attack 命名体系;同时移除了旧版 MPC/轨迹规划/目标求解器等模块(如 TinyMPCMpcAxisSolverReferenceBuilderTrajectoryPlannerTargetSolver 相关接口与实现)。
    • AutoAim 主流程对应调整为仅输出新的 cmd.should_track/should_shoot 与 yaw/pitch、中心/攻击点等信息。
  • 图像数据流与接口大规模迁移(Image → cv::Mat)

    • 将项目图像封装简化为公开 utility::Image { cv::Mat mat; Timestamp timestamp; },并移除 Image::Details/details().mat 等依赖;多个模块(捕获、预处理、识别、位姿估计、可视化、绘图/文字)改为直接以 cv::Mat 作为入参。
    • 识别侧同步扩展:例如灯条相邻ROI扩展、绿灯定位、identifier/pose_estimator/adjacency_lightbar/armor_detection/green_light/... 等接口参数类型切换为 cv::Mat
    • 可视化与捕获链路同步改用新矩阵字段(如 capturer.tick(newest->mat)Visualization::update_image(cv::Mat&) 等)。
  • 与配置/构建/测试的同步调整

    • config/config.yaml 更新了 trackerfire_control 等字段命名与结构(移除旧敌方颜色配置、弹道/偏置命名调整、新增/替换攻击窗口与相关参数块等)。
    • CMakeLists.txt 移除 FetchContent 拉取/启用 TinyMPC,并调整依赖链接(tinympcstaticopenvino::runtime)。
    • 测试与工具同步删减旧链路用例(pipeline、旧 image 相关、tiny mpc 等),并新增/补充机器人 EKF 相关可执行程序(如 tool/cxx/test_robot_ekf.cpp),同时修正 outpost ekf 测试使用的新头文件来源。

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@creeper5820, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 45 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ab9292f5-eff7-4394-9a34-3c68772f8e69

📥 Commits

Reviewing files that changed from the base of the PR and between 3709340 and 1a52a54.

📒 Files selected for processing (1)
  • src/kernel/identifier.cpp

Walkthrough

本次变更将图像输入统一改为 cv::Mat,并以 TrackerV2FireControllerV2RobotModelOutpostModelTrackable 重构自瞄跟踪与火控链路,同时移除旧版 predictor、MPC 与相关接口。

Changes

自瞄追踪与火控 V2 重构

Layer / File(s) Summary
cv::Mat 图像管线
src/utility/image/image.hpp, src/utility/image/drawable.*, src/utility/image/text.*, src/module/identifier/*, src/kernel/*, src/module/capturer/*
Image 由 PIMPL 类改为公开字段结构体(mat/timestamp),绘制、文本、采集、识别、姿态估计与可视化接口改用 cv::Mat
共享类型与几何工具
src/utility/shared/context.hpp, src/utility/serializable.hpp, src/utility/robot/armor.hpp, src/utility/math/*, src/utility/rclcpp/*
共享状态字段、机器人/灯条默认值、线性概念约束、相机距离、机器人几何、PnP 约束与若干基础工具接口发生了字段或签名调整。
TrackerV2 与 FireControllerV2
src/module/tracker/*, src/kernel/tracker.*, src/kernel/fire_control.*, src/module/fire_control/shoot_evaluator.*, src/module/fire_control/trajectory_solution.*, src/kernel/auto_aim.cpp, src/component.cpp
TrackableRobotModelOutpostModelTrackerV2FireControllerV2ShootEvaluator 与主自瞄循环一起改写为新的跟踪和火控流程。
旧模块移除
src/module/fire_control/{armor_selector,planner/*,target_solver,types.hpp}, src/module/tracker/{armor_filter,decider}.*, src/module/predictor/*, src/utility/math/tiny_mpc_solver.hpp, src/module/pipeline/common.hpp
删除旧版 ArmorSelector、MPC 规划器/求解器、TargetSolver、Decider、ArmorFilter、Predictor 系列实现及 Pipe 工具。
配置、构建、测试与工具
config/config.yaml, CMakeLists.txt, test/CMakeLists.txt, test/*.cpp, tool/cxx/*
更新 tracker/fire_control 配置字段;移除 TinyMPC FetchContent,改链 openvino::runtime;新增 test_robot_ekf,并将测试和调试工具切换到新接口。

Sequence Diagram(s)

sequenceDiagram
  participant AutoAim
  participant TrackerV2
  participant RobotModel
  participant FireControllerV2
  participant ShootEvaluator

  AutoAim->>TrackerV2: store(armors/lightbars)
  AutoAim->>TrackerV2: execute(timestamp)
  TrackerV2->>RobotModel: predict(dt) / correct(armors, lightbars)
  RobotModel-->>TrackerV2: state()/converge()
  TrackerV2-->>AutoAim: Trackable
  AutoAim->>FireControllerV2: aim(trackable)
  FireControllerV2->>FireControllerV2: 迭代求解飞行时间/yaw/pitch
  FireControllerV2->>ShootEvaluator: evaluate(yaw,pitch,center,attack)
  ShootEvaluator-->>FireControllerV2: shoot决策
  FireControllerV2-->>AutoAim: Aimed
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~150 minutes

Possibly related PRs

Poem

小兔蹲在代码堆,
旧版追踪轻轻甩,
TrackerV2 跳出来,
弹道收敛眨眨眼。
cv::Mat 替了旧图框,
(≧◡≦) 一键编译不用慌~

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了本次对 robot model 和 tracker 的重构,且简洁明确。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/robot-model

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

🧹 Nitpick comments (5)
src/kernel/identifier.cpp (1)

48-52: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

统一枚举命名 同一字段前后混用 DeviceId::OUTPOST/BASEArmorGenre::OUTPOST/BASE,虽然 ArmorGenre 只是 DeviceId 的别名,但建议统一一种写法,避免阅读时来回切换。

🤖 Prompt for 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.

In `@src/kernel/identifier.cpp` around lines 48 - 52, The enum usage in the
identifier filtering logic is inconsistent because the same field is referenced
with both DeviceId::OUTPOST/BASE and ArmorGenre::OUTPOST/BASE; update the checks
in the identifier-related code to use one naming style consistently, preferably
the symbol already used in this function’s detected armor loop, so readers do
not have to switch between aliases while following the classification logic.
src/module/capturer/local_video.cpp (1)

184-189: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

可选:提取重复的“克隆 mat + 复制 timestamp”模式。

该模式在 158-162 行(optional<Image>unique_ptr<Image>)与本处(unique_ptr<Image>optional<Image>)中各出现一次,可考虑提取一个小工具函数以减少重复,但收益有限,可视情况推迟。

🤖 Prompt for 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.

In `@src/module/capturer/local_video.cpp` around lines 184 - 189, The repeated
“clone mat plus copy timestamp” logic appears in both the optional-to-unique_ptr
and unique_ptr-to-optional conversions in local_video.cpp, so consider
extracting that behavior into a small helper to reduce duplication. Update the
code around the image assignment in the relevant conversion paths to use a
shared utility for copying an Image while preserving the timestamp, and keep the
existing behavior unchanged if you choose not to refactor now.
src/kernel/visualization.hpp (1)

7-11: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

移除重复的 cv::Mat 头文件 includesrc/utility/image/drawable.hpp 已经引入了 <opencv2/core/mat.hpp>,这里在 src/kernel/visualization.hpp 里再直接包含一次是冗余的;如果没有独立依赖,建议删掉这行。

🤖 Prompt for 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.

In `@src/kernel/visualization.hpp` around lines 7 - 11, Remove the redundant
OpenCV mat include from visualization.hpp since drawable.hpp already brings in
cv::Mat; update the includes in src/kernel/visualization.hpp so it relies on the
existing transitive dependency unless a direct dependency is actually required.
Verify the remaining includes still satisfy all symbols used by
visualization.hpp, especially those coming from drawable.hpp and pimpl.hpp.

Source: Coding guidelines

src/kernel/tracker.cpp (1)

222-232: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

建议对 compute_distance2cam_x 的调用使用具名初始化构造 Transform

{ camera.translation, camera.orientation } 依赖 Transform 成员的声明顺序,而附近代码(如 189-192、205-208 行的 update_transform)均采用 {.translation = ..., .orientation = ...} 具名初始化方式。为保持一致性并避免未来 Transform 成员重排导致隐蔽错误,建议这里也改为具名初始化。

♻️ 建议修改
-            const auto distance_score =
-                compute_distance2cam_x({ camera.translation, camera.orientation }, p);
+            const auto distance_score = compute_distance2cam_x(
+                { .translation = camera.translation, .orientation = camera.orientation }, p);
🤖 Prompt for 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.

In `@src/kernel/tracker.cpp` around lines 222 - 232, The call to
compute_distance2cam_x in the calculate lambda is using positional aggregate
initialization for Transform, which is inconsistent with the nearby
update_transform usage and can break if Transform member order changes. Update
that call to construct the Transform with named fields for translation and
orientation, keeping the initialization explicit and aligned with the rest of
tracker.cpp.
src/utility/math/robot.cpp (1)

4-4: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

补齐 <numbers><ranges> 的显式包含。 std::numbers::pistd::views::iota 直接依赖这两个头文件,不要靠间接包含。

建议修改
 `#include` <eigen3/Eigen/Geometry>
+#include <numbers>
+#include <ranges>
🤖 Prompt for 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.

In `@src/utility/math/robot.cpp` at line 4, The include list in robot.cpp is
missing the explicit standard headers required by the symbols used elsewhere:
add direct includes for <numbers> and <ranges> alongside the existing Eigen
geometry include. Update the file’s top-level include section so
std::numbers::pi and std::views::iota are satisfied by their own headers rather
than relying on indirect transitive includes.
🤖 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 `@src/kernel/auto_aim.cpp`:
- Around line 91-95: The early continue in auto_aim.cpp after populating
armor2ds/lightbar2ds skips the later current_command = cmd write-back, which can
leave stale should_shoot/should_track state and also prevents tracker_v2 from
seeing non-empty lightbar2ds. Update the auto-aim loop around
armor2ds/lightbar2ds handling so empty armor frames still flow through the state
update path, or explicitly assign AutoAimState::kInvalid() before any continue;
keep the current_command update and the tracker_v2/AutoAimState logic aligned
with the auto aim state machine.

In `@src/kernel/fire_control.cpp`:
- Around line 45-53: In Impl’s YAML constructor in fire_control.cpp, add
validation after config.serialize succeeds to reject invalid fire-control
settings before they reach runtime. Specifically, ensure config.bullet_speed is
greater than 0 and that both values in config.attack_window are non-negative and
ordered sensibly before converting with util::deg2rad. If any check fails, throw
std::runtime_error from Impl with a clear FireControllerV2 message so
FireControllerV2::Impl never allows zero/negative bullet_speed or invalid
attack_window values into the rest of the logic.
- Around line 135-156: The convergence check in fire_control.cpp is using the
updated fly_time value, so the comparison in the iteration loop always becomes
zero and exits immediately. Update the loop in the fire_control logic to compare
the newly solved fly_time against the previous iteration’s fly_time before
assigning it, using the existing TrajectorySolution::solve result and the
fly_time variable so the kEpsilon break condition reflects real convergence.
- Around line 161-182: The Aimed result in fire_control.cpp is assigning both
aim_yaw and raw_yaw from the same post-offset yaw, so raw_yaw no longer
preserves the original solved angle. Update the yaw handling in the logic around
util::normalize_angle and shoot_evaluator.evaluate so you keep a pre-offset raw
yaw value before applying config.offset_yaw, then return that preserved value
through Aimed::raw_yaw while keeping the corrected value in Aimed::aim_yaw.

In `@src/kernel/identifier.cpp`:
- Around line 139-146: The length filter in identifier.cpp needs a zero-length
guard because armor_length can be 0 for a degenerate armor box, causing the
ratio check to produce inf/NaN and let invalid cases pass. Update the logic
around the armor_length/detected_length comparison to explicitly skip or reject
when armor_length is zero before performing the division, and keep the existing
threshold check in the same filter block.

In `@src/kernel/tracker.cpp`:
- Around line 60-68: The invalid fallback_color path in TrackerV2 currently only
logs an error and lets the constructor continue with the default
ArmorColor::DARK, which causes silent misconfiguration. Update the TrackerV2
construction logic in tracker.cpp so that the invalid config.fallback_color case
is treated as a hard failure, similar to serialize-related failures: after
logging, immediately stop construction by throwing an exception or otherwise
propagating an error to the caller. Use the existing symbols
config.fallback_color, track_color, logging.error, and the TrackerV2 constructor
block to locate the fix.
- Around line 184-219: The `robot_stamps` update at the end of the `tracker.cpp`
loop is re-creating entries that were just erased in the init-failure and
`model.diverged()` paths. Adjust the control flow around `robot_models`,
`robot_stamps`, and `id` so the timestamp is only refreshed when the
corresponding model still exists, and skip the final `robot_stamps[id] =
timestamp` after any branch that erases state.

In `@src/module/tracker/model/robot.hpp`:
- Around line 1-4: The robot.hpp header is missing direct standard library
includes for the types it uses, so it currently relies on transitive includes
from utility/robot/armor.hpp and utility/pimpl.hpp. Add the needed standard
headers directly in robot.hpp for std::vector, std::span, and std::numbers,
keeping the existing includes intact so the header is self-sufficient regardless
of include order or upstream changes.

In `@src/module/tracker/trackable.hpp`:
- Around line 3-10: The Trackable header uses std::unique_ptr and std::vector
without including their standard headers, so add explicit includes for those
types in trackable.hpp rather than relying on utility/clock.hpp or
utility/math/linear.hpp. Update the Trackable struct’s includes so the Unique
and Points aliases are self-contained and no longer depend on include order.

---

Nitpick comments:
In `@src/kernel/identifier.cpp`:
- Around line 48-52: The enum usage in the identifier filtering logic is
inconsistent because the same field is referenced with both
DeviceId::OUTPOST/BASE and ArmorGenre::OUTPOST/BASE; update the checks in the
identifier-related code to use one naming style consistently, preferably the
symbol already used in this function’s detected armor loop, so readers do not
have to switch between aliases while following the classification logic.

In `@src/kernel/tracker.cpp`:
- Around line 222-232: The call to compute_distance2cam_x in the calculate
lambda is using positional aggregate initialization for Transform, which is
inconsistent with the nearby update_transform usage and can break if Transform
member order changes. Update that call to construct the Transform with named
fields for translation and orientation, keeping the initialization explicit and
aligned with the rest of tracker.cpp.

In `@src/kernel/visualization.hpp`:
- Around line 7-11: Remove the redundant OpenCV mat include from
visualization.hpp since drawable.hpp already brings in cv::Mat; update the
includes in src/kernel/visualization.hpp so it relies on the existing transitive
dependency unless a direct dependency is actually required. Verify the remaining
includes still satisfy all symbols used by visualization.hpp, especially those
coming from drawable.hpp and pimpl.hpp.

In `@src/module/capturer/local_video.cpp`:
- Around line 184-189: The repeated “clone mat plus copy timestamp” logic
appears in both the optional-to-unique_ptr and unique_ptr-to-optional
conversions in local_video.cpp, so consider extracting that behavior into a
small helper to reduce duplication. Update the code around the image assignment
in the relevant conversion paths to use a shared utility for copying an Image
while preserving the timestamp, and keep the existing behavior unchanged if you
choose not to refactor now.

In `@src/utility/math/robot.cpp`:
- Line 4: The include list in robot.cpp is missing the explicit standard headers
required by the symbols used elsewhere: add direct includes for <numbers> and
<ranges> alongside the existing Eigen geometry include. Update the file’s
top-level include section so std::numbers::pi and std::views::iota are satisfied
by their own headers rather than relying on indirect transitive includes.
🪄 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: 0a8d673e-d299-4baa-b725-51f0efe6eb4e

📥 Commits

Reviewing files that changed from the base of the PR and between 9760bf5 and 892bebc.

📒 Files selected for processing (118)
  • CMakeLists.txt
  • config/config.yaml
  • src/component.cpp
  • src/kernel/auto_aim.cpp
  • src/kernel/capturer.cpp
  • src/kernel/capturer.hpp
  • src/kernel/fire_control.cpp
  • src/kernel/fire_control.hpp
  • src/kernel/identifier.cpp
  • src/kernel/identifier.hpp
  • src/kernel/pose_estimator.cpp
  • src/kernel/pose_estimator.hpp
  • src/kernel/tracker.cpp
  • src/kernel/tracker.hpp
  • src/kernel/visualization.cpp
  • src/kernel/visualization.hpp
  • src/module/capturer/common.hpp
  • src/module/capturer/hikcamera.cpp
  • src/module/capturer/hikcamera.hpp
  • src/module/capturer/local_video.cpp
  • src/module/capturer/local_video.hpp
  • src/module/capturer/video.cpp
  • src/module/debug/action_throttler.hpp
  • src/module/fire_control/armor_selector.cpp
  • src/module/fire_control/armor_selector.hpp
  • src/module/fire_control/planner/mpc_solver.cpp
  • src/module/fire_control/planner/mpc_solver.hpp
  • src/module/fire_control/planner/mpc_types.hpp
  • src/module/fire_control/planner/reference_builder.cpp
  • src/module/fire_control/planner/reference_builder.hpp
  • src/module/fire_control/planner/trajectory_planner.cpp
  • src/module/fire_control/planner/trajectory_planner.hpp
  • src/module/fire_control/shoot_evaluator.cpp
  • src/module/fire_control/shoot_evaluator.hpp
  • src/module/fire_control/target_solver.cpp
  • src/module/fire_control/target_solver.hpp
  • src/module/fire_control/trajectory_solution.cpp
  • src/module/fire_control/trajectory_solution.hpp
  • src/module/fire_control/types.hpp
  • src/module/identifier/adjacency_lightbar.cpp
  • src/module/identifier/adjacency_lightbar.hpp
  • src/module/identifier/armor_detection.cpp
  • src/module/identifier/armor_detection.hpp
  • src/module/identifier/green_light.cpp
  • src/module/identifier/green_light.hpp
  • src/module/identifier/lightbar.cpp
  • src/module/identifier/lightbar.hpp
  • src/module/identifier/preprocess.cpp
  • src/module/identifier/preprocess.hpp
  • src/module/perception/rotation_estimator.cpp
  • src/module/pipeline/common.hpp
  • src/module/predictor/model/robot.hpp
  • src/module/predictor/outpost/robot_state.cpp
  • src/module/predictor/outpost/robot_state.hpp
  • src/module/predictor/outpost/snapshot.cpp
  • src/module/predictor/outpost/snapshot.hpp
  • src/module/predictor/regular/ekf_parameter.hpp
  • src/module/predictor/regular/robot_state.cpp
  • src/module/predictor/regular/robot_state.hpp
  • src/module/predictor/regular/snapshot.cpp
  • src/module/predictor/regular/snapshot.hpp
  • src/module/predictor/robot_state.cpp
  • src/module/predictor/robot_state.hpp
  • src/module/predictor/snapshot.cpp
  • src/module/predictor/snapshot.hpp
  • src/module/tracker/armor_filter.cpp
  • src/module/tracker/armor_filter.hpp
  • src/module/tracker/decider.cpp
  • src/module/tracker/decider.hpp
  • src/module/tracker/model/outpost.cpp
  • src/module/tracker/model/outpost.hpp
  • src/module/tracker/model/robot.cpp
  • src/module/tracker/model/robot.hpp
  • src/module/tracker/trackable.hpp
  • src/utility/coroutine/common.hpp
  • src/utility/duck_type.hpp
  • src/utility/image/drawable.cpp
  • src/utility/image/drawable.hpp
  • src/utility/image/image.cpp
  • src/utility/image/image.details.hpp
  • src/utility/image/image.hpp
  • src/utility/image/text.cpp
  • src/utility/image/text.hpp
  • src/utility/math/camera.cpp
  • src/utility/math/camera.hpp
  • src/utility/math/corners_optimizor.cpp
  • src/utility/math/corners_optimizor.hpp
  • src/utility/math/linear.hpp
  • src/utility/math/robot.cpp
  • src/utility/math/robot.hpp
  • src/utility/math/solve_pnp/pnp_solution.cpp
  • src/utility/math/solve_pnp/pnp_solution.hpp
  • src/utility/math/solve_pnp/solve_pnp.hpp
  • src/utility/math/tiny_mpc_solver.hpp
  • src/utility/rclcpp/node.cpp
  • src/utility/rclcpp/node.details.hpp
  • src/utility/rclcpp/visual/lightbar.cpp
  • src/utility/rclcpp/visual/movable.hpp
  • src/utility/rclcpp/visual/scalar.cpp
  • src/utility/robot/armor.hpp
  • src/utility/serializable.hpp
  • src/utility/shared/context.hpp
  • src/utility/shared/interprocess.hpp
  • src/utility/yaml/tf.hpp
  • test/CMakeLists.txt
  • test/duck_type.cpp
  • test/model_infer.cpp
  • test/pipeline.cpp
  • test/serializable.cpp
  • test/solve_pnp.cpp
  • test/tiny_mpc_solver.cpp
  • tool/cxx/CMakeLists.txt
  • tool/cxx/hikcamera_test.cpp
  • tool/cxx/ov_model_status.cpp
  • tool/cxx/rotation_estimator.cpp
  • tool/cxx/test_outpost_ekf.cpp
  • tool/cxx/test_robot_ekf.cpp
  • tool/cxx/visualization.cpp
💤 Files with no reviewable changes (38)
  • src/module/fire_control/target_solver.hpp
  • src/module/predictor/outpost/robot_state.hpp
  • src/module/fire_control/planner/trajectory_planner.hpp
  • src/utility/image/image.details.hpp
  • src/module/predictor/model/robot.hpp
  • test/tiny_mpc_solver.cpp
  • src/module/fire_control/planner/mpc_types.hpp
  • src/module/predictor/snapshot.hpp
  • src/utility/math/tiny_mpc_solver.hpp
  • src/module/predictor/outpost/snapshot.cpp
  • src/module/pipeline/common.hpp
  • src/module/tracker/armor_filter.hpp
  • src/module/fire_control/planner/trajectory_planner.cpp
  • src/module/predictor/robot_state.hpp
  • src/module/predictor/regular/robot_state.cpp
  • src/module/predictor/regular/robot_state.hpp
  • src/utility/image/image.cpp
  • src/module/predictor/outpost/snapshot.hpp
  • src/module/tracker/decider.hpp
  • src/module/predictor/regular/snapshot.hpp
  • test/pipeline.cpp
  • src/module/fire_control/armor_selector.hpp
  • src/module/fire_control/types.hpp
  • src/module/fire_control/target_solver.cpp
  • src/module/predictor/regular/ekf_parameter.hpp
  • src/module/tracker/armor_filter.cpp
  • src/module/fire_control/planner/reference_builder.hpp
  • src/module/predictor/outpost/robot_state.cpp
  • src/module/fire_control/planner/reference_builder.cpp
  • src/module/predictor/robot_state.cpp
  • CMakeLists.txt
  • src/module/fire_control/armor_selector.cpp
  • src/module/fire_control/planner/mpc_solver.cpp
  • src/module/fire_control/planner/mpc_solver.hpp
  • src/module/predictor/regular/snapshot.cpp
  • test/CMakeLists.txt
  • src/module/predictor/snapshot.cpp
  • src/module/tracker/decider.cpp

Comment thread src/kernel/auto_aim.cpp
Comment thread src/kernel/fire_control.cpp
Comment thread src/kernel/fire_control.cpp Outdated
Comment thread src/kernel/fire_control.cpp
Comment thread src/kernel/identifier.cpp
Comment thread src/kernel/tracker.cpp
Comment thread src/kernel/tracker.cpp
Comment thread src/module/tracker/model/robot.hpp
Comment thread src/module/tracker/trackable.hpp

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/kernel/tracker.cpp (2)

224-234: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

不要把记忆目标的评分直接清零。

Line 231 让当前 track_genrescore 恒为 0;只要旧模型仍 converge(),距离更优的新目标也无法被选中。建议使用非零权重/偏置,而不是消除距离项。

🐛 建议修复
-            const auto memory_score = (id == track_genre) ? 0 : 1;
+            constexpr auto kTrackedTargetBias = 0.8;
+            const auto memory_score = (id == track_genre) ? kTrackedTargetBias : 1.0;
 
             return distance_score * memory_score;
🤖 Prompt for 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.

In `@src/kernel/tracker.cpp` around lines 224 - 234, The scoring logic in
calculate currently zeroes out the score for the remembered target via
memory_score, which makes track_genre always win regardless of distance. Update
calculate in tracker.cpp so the remembered target keeps a non-zero weight or
bias instead of multiplying the distance score by 0; keep the distance term
active and adjust the memory preference only as a soft preference tied to
track_genre.

76-88: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

不要用主点反推图像宽高 camera.camera_matrix[0][2] * 2 / [1][2] * 2 只在主点正好居中时才成立;一旦有裁剪、缩放或非居中标定,边界过滤就会误删/误放目标。改为直接使用实际帧的 cols/rows

🤖 Prompt for 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.

In `@src/kernel/tracker.cpp` around lines 76 - 88, The boundary filtering in
store() is deriving image size from camera.camera_matrix principal points, which
is only valid when the principal point is centered. Update the logic to use the
actual frame dimensions (cols/rows from the image source or frame object used by
tracker.cpp) instead of kWidth/kHeight computed from camera.camera_matrix, and
keep the min_x/max_x/min_y/max_y margin checks unchanged.
🧹 Nitpick comments (2)
src/kernel/tracker.cpp (2)

239-241: 🎯 Functional Correctness | 🔵 Trivial

请把这个 @FIXME 作为显式跟踪项。

这里描述的一帧误识别即可 converge() 会直接影响出靶结果;如果本 PR 暂不修,建议至少补 issue 或回归用例。需要的话我可以帮忙拆测试用例。

🤖 Prompt for 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.

In `@src/kernel/tracker.cpp` around lines 239 - 241, The current `@FIXME` in
Tracker::converge handling is a tracked defect and should be made explicit
rather than left as an inline note. Update the logic around outpost->converge()
in src/kernel/tracker.cpp to either create a formal issue/reference for this
one-frame false-positive convergence case or add a regression test that captures
the misrecognized-robot scenario; if the fix is deferred, leave a clear tracked
link or test name tied to Tracker and converge so it is visible and actionable.

184-193: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

复用 try_emplace 返回的迭代器。 这里已经拿到元素引用,继续写 robot_models[id] 会重复查找;直接用 it->second 更简洁。

♻️ 建议调整
-                robot_models.try_emplace(id, robot_config);
-                robot_models[id].update_camera(
+                auto [it, inserted] = robot_models.try_emplace(id, robot_config);
+                auto& model = it->second;
+                model.update_camera(
                     std::bit_cast<std::array<double, 9>>(camera.camera_matrix),
                     camera.distort_coeff);
-                robot_models[id].update_transform({
+                model.update_transform({
                     .translation = camera.translation,
                     .orientation = camera.orientation,
                 });
-                if (!robot_models[id].init(target.armor2ds)) {
+                if (!model.init(target.armor2ds)) {
🤖 Prompt for 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.

In `@src/kernel/tracker.cpp` around lines 184 - 193, The tracker logic in the
robot_models insertion path is doing redundant map lookups after try_emplace.
Reuse the iterator returned by robot_models.try_emplace in the containing block
of the update_camera, update_transform, and init calls, and switch all
robot_models[id] accesses to the inserted element via it->second to avoid
повторное поиск and keep the code concise.
🤖 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.

Outside diff comments:
In `@src/kernel/tracker.cpp`:
- Around line 224-234: The scoring logic in calculate currently zeroes out the
score for the remembered target via memory_score, which makes track_genre always
win regardless of distance. Update calculate in tracker.cpp so the remembered
target keeps a non-zero weight or bias instead of multiplying the distance score
by 0; keep the distance term active and adjust the memory preference only as a
soft preference tied to track_genre.
- Around line 76-88: The boundary filtering in store() is deriving image size
from camera.camera_matrix principal points, which is only valid when the
principal point is centered. Update the logic to use the actual frame dimensions
(cols/rows from the image source or frame object used by tracker.cpp) instead of
kWidth/kHeight computed from camera.camera_matrix, and keep the
min_x/max_x/min_y/max_y margin checks unchanged.

---

Nitpick comments:
In `@src/kernel/tracker.cpp`:
- Around line 239-241: The current `@FIXME` in Tracker::converge handling is a
tracked defect and should be made explicit rather than left as an inline note.
Update the logic around outpost->converge() in src/kernel/tracker.cpp to either
create a formal issue/reference for this one-frame false-positive convergence
case or add a regression test that captures the misrecognized-robot scenario; if
the fix is deferred, leave a clear tracked link or test name tied to Tracker and
converge so it is visible and actionable.
- Around line 184-193: The tracker logic in the robot_models insertion path is
doing redundant map lookups after try_emplace. Reuse the iterator returned by
robot_models.try_emplace in the containing block of the update_camera,
update_transform, and init calls, and switch all robot_models[id] accesses to
the inserted element via it->second to avoid повторное поиск and keep the code
concise.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 387ef271-9a2f-4c70-9c64-9c115210e476

📥 Commits

Reviewing files that changed from the base of the PR and between 892bebc and 3709340.

📒 Files selected for processing (4)
  • src/kernel/auto_aim.cpp
  • src/kernel/fire_control.cpp
  • src/kernel/tracker.cpp
  • src/module/tracker/model/robot.hpp
💤 Files with no reviewable changes (1)
  • src/kernel/auto_aim.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/module/tracker/model/robot.hpp
  • src/kernel/fire_control.cpp

@creeper5820
creeper5820 merged commit 3964c3d into main Jun 30, 2026
3 checks passed
@creeper5820
creeper5820 deleted the refactor/robot-model branch June 30, 2026 23:00
@github-project-automation github-project-automation Bot moved this from Todo to Done in RMCS Auto Aim V2 Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants