feat: refine visualization granularity with multi-layered debug control#45
feat: refine visualization granularity with multi-layered debug control#45creeper5820 merged 2 commits intomainfrom
Conversation
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 总览该PR为可视化系统添加了运行时配置的启用/禁用标志,包括图像发布、可见装甲/机器人、相机姿态、瞄准方向和MPC计划。配置项从YAML扩展到内部结构,所有可视化方法现通过早期返回执行条件控制。 改动可视化配置与条件控制
代码审查工作量估计🎯 2 (简单) | ⏱️ ~10 分钟 该变更主要涉及配置扩展和标志线程的添加,逻辑简单直观。虽然涉及三个文件,但改动分布均衡且无复杂交互,每处变更都是标准的早期返回guard或配置序列化,易于验证。 诗
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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. Review rate limit: 0/1 reviews remaining, refill in 38 minutes.Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/kernel/visualization.cpp (1)
123-126: ⚡ Quick win把“禁用图像”当成成功的 no-op。
image_enabled=false时这里直接返回false,会把有意关闭可视化和真正的传输失败混在一起。对未来调用方来说,这个状态位更适合表示“本次没有发送”,而不是“出错了”。♻️ 建议调整返回语义
- if (!config.image_enabled) return false; + if (!config.image_enabled) return true;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/kernel/visualization.cpp` around lines 123 - 126, In send_image(const Image& image) noexcept the current early return of false when config.image_enabled is false conflates an intentional no-op with an actual send failure; change the logic so that if !config.image_enabled the function returns true (indicating a successful no-op) while keeping the existing false return for !is_initialized and actual failures, and update any inline comment to document that config.image_enabled=false is treated as a successful no-op; reference send_image, is_initialized and config.image_enabled when making the change.src/runtime.cpp (1)
174-178: ⚡ Quick win把 visible_robot 的更新从控制分支里拆出来。
现在
visible_robot_enabled只有在allow_control && snapshot成立时才会生效;如果目标是“多层可视化开关”,这会让控制关闭时的机器人层完全失效。建议只依赖snapshot的存在性来刷新这层,或者在控制关闭时显式清空它。♻️ 建议拆分可视化更新
- if (target.allow_control && target.snapshot) { - auto& snapshot = target.snapshot; - auto armors = snapshot->predicted_armors(Clock::now()); - visualization.update_visible_robot(armors); - + if (target.snapshot) { + visualization.update_visible_robot(target.snapshot->predicted_armors(Clock::now())); + } + + if (target.allow_control && target.snapshot) { + auto& snapshot = target.snapshot; const auto control = target.tracking_confirmed;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/runtime.cpp` around lines 174 - 178, The visible_robot update is currently gated by target.allow_control which disables the visualization when control is off; instead, use only the presence of target.snapshot to refresh the robot layer (or explicitly clear it when snapshot is null). Move the visualization.update_visible_robot(...) call out of the if (target.allow_control && target.snapshot) block and call it when target.snapshot is non-null using snapshot->predicted_armors(Clock::now()), and ensure when target.snapshot is null (or if you prefer to keep control gating) you call visualization.clear_visible_robot() (or equivalent) so the layer isn’t left stale; update locations: the block that references target.allow_control, target.snapshot, snapshot, predicted_armors, and visualization.update_visible_robot.
🤖 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/runtime.cpp`:
- Around line 194-198: 当 command.feedforward_valid 为 false 时当前代码跳过调用
visualization.update_mpc_plan,导致 MpcPlanVisualizer 使用的
geometry_msgs::msg::Vector3Stamped 留下上帧轨迹。修改方法:在检测到 command.feedforward_valid ==
false 时,显式清除或覆盖旧的 MPC 轨迹—例如在该分支调用 visualization 的一个清除方法(如
visualization.clear_mpc_plan 或类似命名),或发送空/零向量类型的 Vector3Stamped
消息以覆盖旧发布内容;确保修改点在使用 visualization.update_aiming_direction 和 update_mpc_plan
的同一位置以保证行为一致。
---
Nitpick comments:
In `@src/kernel/visualization.cpp`:
- Around line 123-126: In send_image(const Image& image) noexcept the current
early return of false when config.image_enabled is false conflates an
intentional no-op with an actual send failure; change the logic so that if
!config.image_enabled the function returns true (indicating a successful no-op)
while keeping the existing false return for !is_initialized and actual failures,
and update any inline comment to document that config.image_enabled=false is
treated as a successful no-op; reference send_image, is_initialized and
config.image_enabled when making the change.
In `@src/runtime.cpp`:
- Around line 174-178: The visible_robot update is currently gated by
target.allow_control which disables the visualization when control is off;
instead, use only the presence of target.snapshot to refresh the robot layer (or
explicitly clear it when snapshot is null). Move the
visualization.update_visible_robot(...) call out of the if (target.allow_control
&& target.snapshot) block and call it when target.snapshot is non-null using
snapshot->predicted_armors(Clock::now()), and ensure when target.snapshot is
null (or if you prefer to keep control gating) you call
visualization.clear_visible_robot() (or equivalent) so the layer isn’t left
stale; update locations: the block that references target.allow_control,
target.snapshot, snapshot, predicted_armors, and
visualization.update_visible_robot.
🪄 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: f6e269f9-f0b9-46d3-9e6e-2639feb002f2
📒 Files selected for processing (3)
config/config.yamlsrc/kernel/visualization.cppsrc/runtime.cpp
PR 摘要:完善可视化函数的多层级调试控制
概述
本PR通过引入细粒度的可视化配置控制,增强了调试可视化功能的灵活性。用户现在可以通过配置文件独立启用或禁用各项可视化功能,包括图像发送、装甲识别、机器人预测、相机位置、瞄准方向和MPC规划等。
主要变更
配置文件改动 (
config/config.yaml)visualization部分新增6个布尔配置项:image_enabled:控制图像流发送visible_armors_enabled:控制装甲可视化visible_robot_enabled:控制机器人可视化camera_pose_enabled:控制相机位置可视化aiming_direction_enabled:控制瞄准方向可视化mpc_plan_enabled:控制MPC规划可视化可视化模块改动 (
src/kernel/visualization.cpp)Visualization::Impl::Config结构体中新增6个布尔字段,用于运行时控制各项可视化功能的启用状态Config的序列化元数据 (metas),包含所有新增布尔字段Config实例从initialize函数内的局部变量提升为Impl类成员变量send_image和各update_*方法中添加早期返回机制,根据对应的配置标志决定是否执行可视化操作运行时控制流改动 (
src/runtime.cpp)update_visible_robot()现在在获取预测装甲后立即调用update_aiming_direction()在完成火力控制求解后调用update_mpc_plan()现在条件性地执行,仅当command.feedforward_valid为真时才调用(之前无条件调用)这一调整使MPC规划的可视化与前馈有效性状态保持同步,避免在无效前馈情况下进行不必要的可视化更新。
影响范围
true,保持现有行为