Repository navigation
Retry motor limit queries until every motor replies #12
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -932,6 +932,30 @@ bool PiperInterfaceV2::searchAllMotorLimits() | |
| return true; | ||
| } | ||
|
|
||
| bool PiperInterfaceV2::waitForMotorLimits(std::chrono::milliseconds timeout, std::chrono::milliseconds retry_interval) | ||
| { | ||
| using clock = std::chrono::steady_clock; | ||
| const auto deadline = clock::now() + timeout; | ||
| // Success must mean replies to these queries, not whatever an earlier session cached. | ||
| arm_all_motor_angle_limit_max_spd_.reset(); | ||
| arm_all_motor_max_acc_limit_.reset(); | ||
| auto last_sent = clock::now(); | ||
| if (!searchAllMotorLimits()) | ||
| return false; // not connected or the bus is down: waiting cannot help | ||
| while (!(arm_all_motor_angle_limit_max_spd_.isValid() && arm_all_motor_max_acc_limit_.isValid())) | ||
| { | ||
| if (clock::now() >= deadline) | ||
|
Comment on lines
+945
to
+947
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · Success arrives after timeout When the final replies arrive after the deadline but before the next loop-condition check, Check the deadline before accepting aggregate validity as success. Prompt for AI agentsIn `piper_cpp/src/interface/piper_interface_v2.cpp` at lines 941-943:
**Success arrives after timeout**
When the final replies arrive after the deadline but before the next loop-condition check, `waitForMotorLimits()` checks aggregate validity before checking the deadline, so replies received after the timeout make the method return true.
Check the deadline before accepting aggregate validity as success. |
||
| return false; | ||
| std::this_thread::sleep_for(std::chrono::milliseconds(10)); | ||
| if (clock::now() - last_sent >= retry_interval) | ||
| { | ||
| searchAllMotorLimits(); | ||
| last_sent = clock::now(); | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| bool PiperInterfaceV2::sendFirmwareQuery() | ||
| { | ||
| if (!connected_.load(std::memory_order_relaxed)) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.