Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 42
Add VT13 remote control and dual control arbitration#93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2 rmcs_ws/src/rmcs_bringup/config/steering-hero-little-six-friction.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 23 additions & 4 deletions
27 rmcs_ws/src/rmcs_core/src/hardware/deformable-infantry-omni-b.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 8 additions & 1 deletion
9 rmcs_ws/src/rmcs_core/src/hardware/deformable-infantry-omni.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 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 语义
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); }Also applies to: 192-198, 279-280, 155-156
🤖 Prompt for AI Agents