Uh oh!
There was an error while loading. Please reload this page.
Add VT13 remote control and dual control arbitration - #93
Conversation
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@rmcs_ws/src/rmcs_core/src/hardware/device/dr16.hpp`:
- Around line 49-58: Resolve the cross-thread race in the DR16 status state by
making valid_ atomic and using acquire/release semantics for its writes and
reads. Update store_status(), refresh_validity(), update_status(), and valid()
consistently, and synchronize last_remote_control_received_at_ as well—either
protect both fields with the same mutex or use an atomic time
representation—while preserving the existing validity and
RemoteControl::update() behavior.
🪄 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: a5d3fd9e-6cdd-4796-afe2-b4955972d969
📒 Files selected for processing (10)
rmcs_ws/src/rmcs_bringup/config/steering-hero-little-six-friction.yamlrmcs_ws/src/rmcs_core/src/hardware/deformable-infantry-omni-b.cpprmcs_ws/src/rmcs_core/src/hardware/deformable-infantry-omni.cpprmcs_ws/src/rmcs_core/src/hardware/device/dr16.hpprmcs_ws/src/rmcs_core/src/hardware/device/remote_control.hpprmcs_ws/src/rmcs_core/src/hardware/device/vt13.hpprmcs_ws/src/rmcs_core/src/hardware/flight.cpprmcs_ws/src/rmcs_core/src/hardware/omni_infantry.cpprmcs_ws/src/rmcs_core/src/hardware/sentry.cpprmcs_ws/src/rmcs_core/src/hardware/steering-hero-little-six-friction.cpp
| last_remote_control_received_at_ = Clock::now(); | ||
| valid_ = true; | ||
| } | ||
| void update_status() { | ||
| const auto now = Clock::now(); | ||
| refresh_validity(now); | ||
| if (!valid_) | ||
| return; |
There was a problem hiding this comment.
🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win
valid_ / last_remote_control_received_at_ 存在跨线程数据竞争。
store_status()(第 49-51 行)在 UART 回调线程中以普通(非原子)方式写入 last_remote_control_received_at_ 与 valid_;而 update_status()/refresh_validity()(第 55-58、192-198 行)以及 valid()(第 155 行)在组件主更新线程读取/写入这两个字段,全程没有任何同步(不像 data_part1_/data_part2_/data_part3_ 已经是 std::atomic)。这是本 PR 新引入的未同步跨线程访问,属于未定义行为的数据竞争。
对比 vt13.hpp:其 valid_/last_remote_control_received_at_ 只在 update_status()(主线程)内部写入,store_status() 只写入环形缓冲区,因此没有这个问题——这恰好印证了 dr16.hpp 这里的不对称是个真实缺陷。
该竞争会直接影响 RemoteControl::update() 在全部 6 个硬件文件(deformable-infantry-omni-b.cpp、deformable-infantry-omni.cpp、flight.cpp、omni_infantry.cpp、sentry.cpp、steering-hero-little-six-friction.cpp)中基于 dr16_->valid() 的仲裁判断,因此在此处统一说明,不在各硬件文件重复。
🔒 建议修复:将 valid_ 改为原子变量并使用 acquire/release 语义
- Vector mouse_velocity_ = Vector::zero();- double mouse_wheel_ = 0.0;+ Vector mouse_velocity_ = Vector::zero();+ double mouse_wheel_ = 0.0;
@@
- double rotary_knob_ = 0.0;- rmcs_msgs::Switch rotary_knob_switch_ = rmcs_msgs::Switch::UNKNOWN;- TimePoint last_remote_control_received_at_ = TimePoint::min();- bool valid_ = false;+ double rotary_knob_ = 0.0;+ rmcs_msgs::Switch rotary_knob_switch_ = rmcs_msgs::Switch::UNKNOWN;+ TimePoint last_remote_control_received_at_ = TimePoint::min();+ std::atomic<bool> valid_ = false;- last_remote_control_received_at_ = Clock::now();- valid_ = true;+ last_remote_control_received_at_ = Clock::now();+ valid_.store(true, std::memory_order::release); void update_status() {
const auto now = Clock::now();
refresh_validity(now);
- if (!valid_)+ if (!valid_.load(std::memory_order::acquire))
return; void refresh_validity(const TimePoint now) {
- if (!valid_ || now - last_remote_control_received_at_ <= kFreshTimeout)+ if (!valid_.load(std::memory_order::acquire)+ || now - last_remote_control_received_at_ <= kFreshTimeout)
return;
reset_remote_control_state();
- valid_ = false;+ valid_.store(false, std::memory_order::relaxed);
}- bool valid() const noexcept { return valid_; }+ bool valid() const noexcept { return valid_.load(std::memory_order::acquire); }Also applies to: 192-198, 279-280, 155-156
🤖 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 `@rmcs_ws/src/rmcs_core/src/hardware/device/dr16.hpp` around lines 49 - 58,
Resolve the cross-thread race in the DR16 status state by making valid_ atomic
and using acquire/release semantics for its writes and reads. Update
store_status(), refresh_validity(), update_status(), and valid() consistently,
and synchronize last_remote_control_received_at_ as well—either protect both
fields with the same mutex or use an atomic time representation—while preserving
the existing validity and RemoteControl::update() behavior.
Uh oh!
There was an error while loading. Please reload this page.
commit 4d1b9fc Author: creeper5820 <cqq1960180796@163.com> Date: Mon Jul 20 23:13:59 2026 +0800 feat: Refine auto-aim fire control and bringup configs commit 94da5b9 Author: creeper5820 <cqq1960180796@163.com> Date: Sun Jul 19 20:18:47 2026 +0800 chore: Clean up code and apply format commit eb9d651 Author: creeper5820 <cqq1960180796@163.com> Date: Sun Jul 19 19:09:06 2026 +0800 chore: Update auto aim submodule commit ef4ef90 Author: FloatPigeon <floatpigeon@proton.me> Date: Sun Jul 19 20:11:54 2026 +0800 feat: Add VT13 remote control and dual control arbitration (#93) commit d49071c Author: creeper5820 <cqq1960180796@163.com> Date: Sun Jul 19 11:09:07 2026 +0800 feat: Adapt rune single shoot mode commit 91aaa6b Author: creeper5820 <cqq1960180796@163.com> Date: Sat Jul 18 17:55:26 2026 +0800 fix: No response of switching item in scan-remote commit b868fd3 Author: creeper5820 <cqq1960180796@163.com> Date: Sat Jul 18 17:35:00 2026 +0800 chore: Add auto aim as submodule commit 0d84265 Author: creeper5820 <cqq1960180796@163.com> Date: Sat Jul 18 17:29:59 2026 +0800 merge(robot): Merge sentry impl into this branch commit e588f08 Author: creeper5820 <cqq1960180796@163.com> Date: Sat Jul 18 11:20:01 2026 +0800 fix(hero): Update auto-aim config and should_control gating commit 77444dd Author: creeper5820 <cqq1960180796@163.com> Date: Sat Jul 18 10:37:57 2026 +0800 fix: Correct hero friction order commit 768369c Author: creeper5820 <cqq1960180796@163.com> Date: Sat Jul 18 08:55:39 2026 +0800 wip: Merge hero and infantry 3/4, remove unused robot commit 5b9d180 Merge: fbe3ec51fd53eb Author: creeper5820 <cqq1960180796@163.com> Date: Sat Jul 18 01:39:23 2026 +0800 Merge branch 'merge/hero' into merge/robots commit 1fd53eb Author: creeper5820 <cqq1960180796@163.com> Date: Thu Jul 16 00:41:59 2026 +0800 chore: Modify hero config commit 38f562d Author: creeper5820 <cqq1960180796@163.com> Date: Wed Jul 15 21:12:29 2026 +0800 wip: Adapt auto aim control commit 4a8722d Author: creeper5820 <cqq1960180796@163.com> Date: Wed Jul 15 19:14:09 2026 +0800 wip: Adapt auto aim for hardware and clean config commit de27628 Author: dwx5 <1591215786@qq.com> Date: Wed Jul 15 22:32:11 2026 +0800 parameter changes for 12m/s commit afda3ee Author: creeper5820 <cqq1960180796@163.com> Date: Wed Jul 15 18:47:45 2026 +0800 wip: Rebase with main branch commit 81a0232 Author: dwx5 <1591215786@qq.com> Date: Wed Jul 15 15:16:50 2026 +0800 stable commit 143cee6 Author: dwx5 <1591215786@qq.com> Date: Wed Jul 8 23:39:08 2026 +0800 friction_sweep and parameter changes commit 016bd08 Author: qzhhhi <zihanqin2048@gmail.com> Date: Fri May 22 13:21:21 2026 +0800 vt13 test (rmcs_board need : chore(rmcs_board): Raise UART0 baudrate for temporary debugging by qzhhhi · Pull Request #55 · Allia) commit 119730e Author: dwx5 <1591215786@qq.com> Date: Thu Jul 2 22:10:14 2026 +0800 1、lk_motor: multiple angle dynamically transform 2、interfere clean 3、six_friction: rename and reset parameter 4、putter return commit 3c061e8 Author: dwx5 <1591215786@qq.com> Date: Wed Jul 1 20:39:00 2026 +0800 six-friction commit 8ad0751 Author: dwx5 <1591215786@qq.com> Date: Sat Jun 6 20:11:57 2026 +0800 add yaw brake commit f398929 Author: dwx5 <1591215786@qq.com> Date: Thu Jun 4 21:08:50 2026 +0800 update after merge main commit ad17156 Author: qzhhhi <zihanqin2048@gmail.com> Date: Sun Jul 12 02:19:02 2026 +0800 feat: success buff
commit 0e1e1ad Author: creeper5820 <cqq1960180796@163.com> Date: Wed Jul 22 03:12:17 2026 +0800 wip: Develop sentry navigation commit 97020e1 Author: creeper5820 <cqq1960180796@163.com> Date: Wed Jul 22 02:12:15 2026 +0800 wip: Adjust 17mm bullet feeder behavior, improve rmcs host util and update auto_aim commit 4d1b9fc Author: creeper5820 <cqq1960180796@163.com> Date: Mon Jul 20 23:13:59 2026 +0800 feat: Refine auto-aim fire control and bringup configs commit 94da5b9 Author: creeper5820 <cqq1960180796@163.com> Date: Sun Jul 19 20:18:47 2026 +0800 chore: Clean up code and apply format commit eb9d651 Author: creeper5820 <cqq1960180796@163.com> Date: Sun Jul 19 19:09:06 2026 +0800 chore: Update auto aim submodule commit ef4ef90 Author: FloatPigeon <floatpigeon@proton.me> Date: Sun Jul 19 20:11:54 2026 +0800 feat: Add VT13 remote control and dual control arbitration (#93) commit d49071c Author: creeper5820 <cqq1960180796@163.com> Date: Sun Jul 19 11:09:07 2026 +0800 feat: Adapt rune single shoot mode commit 91aaa6b Author: creeper5820 <cqq1960180796@163.com> Date: Sat Jul 18 17:55:26 2026 +0800 fix: No response of switching item in scan-remote commit b868fd3 Author: creeper5820 <cqq1960180796@163.com> Date: Sat Jul 18 17:35:00 2026 +0800 chore: Add auto aim as submodule commit 0d84265 Author: creeper5820 <cqq1960180796@163.com> Date: Sat Jul 18 17:29:59 2026 +0800 merge(robot): Merge sentry impl into this branch commit e588f08 Author: creeper5820 <cqq1960180796@163.com> Date: Sat Jul 18 11:20:01 2026 +0800 fix(hero): Update auto-aim config and should_control gating commit 77444dd Author: creeper5820 <cqq1960180796@163.com> Date: Sat Jul 18 10:37:57 2026 +0800 fix: Correct hero friction order commit 768369c Author: creeper5820 <cqq1960180796@163.com> Date: Sat Jul 18 08:55:39 2026 +0800 wip: Merge hero and infantry 3/4, remove unused robot commit 5b9d180 Merge: fbe3ec51fd53eb Author: creeper5820 <cqq1960180796@163.com> Date: Sat Jul 18 01:39:23 2026 +0800 Merge branch 'merge/hero' into merge/robots commit 1fd53eb Author: creeper5820 <cqq1960180796@163.com> Date: Thu Jul 16 00:41:59 2026 +0800 chore: Modify hero config commit 38f562d Author: creeper5820 <cqq1960180796@163.com> Date: Wed Jul 15 21:12:29 2026 +0800 wip: Adapt auto aim control commit 4a8722d Author: creeper5820 <cqq1960180796@163.com> Date: Wed Jul 15 19:14:09 2026 +0800 wip: Adapt auto aim for hardware and clean config commit de27628 Author: dwx5 <1591215786@qq.com> Date: Wed Jul 15 22:32:11 2026 +0800 parameter changes for 12m/s commit afda3ee Author: creeper5820 <cqq1960180796@163.com> Date: Wed Jul 15 18:47:45 2026 +0800 wip: Rebase with main branch commit 81a0232 Author: dwx5 <1591215786@qq.com> Date: Wed Jul 15 15:16:50 2026 +0800 stable commit 143cee6 Author: dwx5 <1591215786@qq.com> Date: Wed Jul 8 23:39:08 2026 +0800 friction_sweep and parameter changes commit 016bd08 Author: qzhhhi <zihanqin2048@gmail.com> Date: Fri May 22 13:21:21 2026 +0800 vt13 test (rmcs_board need : chore(rmcs_board): Raise UART0 baudrate for temporary debugging by qzhhhi · Pull Request #55 · Allia) commit 119730e Author: dwx5 <1591215786@qq.com> Date: Thu Jul 2 22:10:14 2026 +0800 1、lk_motor: multiple angle dynamically transform 2、interfere clean 3、six_friction: rename and reset parameter 4、putter return commit 3c061e8 Author: dwx5 <1591215786@qq.com> Date: Wed Jul 1 20:39:00 2026 +0800 six-friction commit 8ad0751 Author: dwx5 <1591215786@qq.com> Date: Sat Jun 6 20:11:57 2026 +0800 add yaw brake commit f398929 Author: dwx5 <1591215786@qq.com> Date: Thu Jun 4 21:08:50 2026 +0800 update after merge main commit ad17156 Author: qzhhhi <zihanqin2048@gmail.com> Date: Sun Jul 12 02:19:02 2026 +0800 feat: success buff
VT13图传链路遥控接入与双遥控器仲裁
PR 摘要
通过视频传输链路新增 VT13 遥控接入,并实现 DR16 与 VT13 两类遥控器的输入仲裁。
主要变更
RemoteControl,统一注册 DR16/VT13,并根据控制模式和设备有效性选择输入源。AutoAimUi配置条目顺序,不改变其参数内容。