Skip to content

Add tests demonstrating failure to recover from stream starvation - #552

Open
acmorrow wants to merge 4 commits into
UniversalRobots:masterfrom
acmorrow:gh-550-streaming-starvation-recovery-tests
Open

Add tests demonstrating failure to recover from stream starvation#552
acmorrow wants to merge 4 commits into
UniversalRobots:masterfrom
acmorrow:gh-550-streaming-starvation-recovery-tests

Conversation

@acmorrow

@acmorrow acmorrow commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Hi @urrsk -

This PR, which I'm opening as a draft because some of the tests are currently failing, demonstrates the failure to correctly recover to a valid state after starving the arm of points during a streaming move.

There are also some new tests that currently pass, acting as controls/validation for existing behavior. They came into being as I was validating my understanding of the urscript behavior. But they seem like worthwhile tests on their own, and useful to prevent regressions. Easy enough to drop them if you just want the failing tests.


Note

High Risk
Changes the on-robot trajectory wire protocol and motion execution path (stale-point rejection and streaming failure recovery); breaking API and mandatory script pairing increase integration risk for custom external_control users.

Overview
Adds per-move identifiers across the trajectory socket and reverse-interface control messages so the robot can discard stale points after cancel, failure, or underrun instead of running them on the next move. UrDriver increments trajectory_move_id_ for each TRAJECTORY_START / TRAJECTORY_STREAM_START and sets it on TrajectoryPointInterface before writing points; external_control.urscript snapshots the announced id in trajectoryThread and skips mismatched records (with periodic sync when discarding long runs).

Breaking: trajectory point records are 22 integers (was 21); control messages include move_id in former padding (writeTrajectoryControlMessage(action, move_id, point_number, …)). Library and shipped external_control.urscript must be upgraded together; migration notes cover 2.x → 3.x.

URScript fixes for streaming starvation / issue #550: on mid-stream underrun without STREAM_END, clear trajectory_streaming and trajectory_points_left so pre-move cleanup does not drain indefinitely; cleanup reads full point records including move id; is_first_point only clears after an executed point.

Tests: unit coverage for move id on reverse and trajectory interfaces; robot streaming tests for gaps, no-lookahead producers, finite/stream recovery after underrun, stale points not executed, cancel with short count—with RTDE joint checks where motion matters.

Reviewed by Cursor Bugbot for commit 4aaffdf. Bugbot is set up for automated code reviews on this repo. Configure here.

@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.50%. Comparing base (a854de9) to head (4aaffdf).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #552      +/-   ##
==========================================
+ Coverage   78.85%   79.50%   +0.65%     
==========================================
  Files         116      116              
  Lines        7632     6978     -654     
  Branches     3153     3084      -69     
==========================================
- Hits         6018     5548     -470     
+ Misses       1224     1050     -174     
+ Partials      390      380      -10     
Flag Coverage Δ
check_version_ur10-3.15.8 11.73% <0.00%> (-0.99%) ⬇️
check_version_ur10e-10.11.0 11.49% <0.00%> (-0.13%) ⬇️
check_version_ur10e-5.15.2 11.49% <0.00%> (-1.22%) ⬇️
check_version_ur12e-10.12.1 11.53% <0.00%> (-0.08%) ⬇️
check_version_ur12e-5.25.1 11.49% <0.00%> (-0.23%) ⬇️
check_version_ur15-10.12.1 11.49% <0.00%> (-0.13%) ⬇️
check_version_ur15-5.25.1 11.68% <0.00%> (-0.03%) ⬇️
check_version_ur16e-10.12.1 11.49% <0.00%> (-0.13%) ⬇️
check_version_ur16e-5.25.1 11.49% <0.00%> (-0.47%) ⬇️
check_version_ur18-10.12.1 11.49% <0.00%> (-0.05%) ⬇️
check_version_ur18-5.25.1 11.49% <0.00%> (-0.27%) ⬇️
check_version_ur20-10.12.1 11.49% <0.00%> (-0.13%) ⬇️
check_version_ur20-5.25.1 11.68% <0.00%> (-0.58%) ⬇️
check_version_ur3-3.14.3 11.53% <0.00%> (-0.65%) ⬇️
check_version_ur30-10.12.1 11.53% <0.00%> (-0.08%) ⬇️
check_version_ur30-5.25.1 11.49% <0.00%> (-0.57%) ⬇️
check_version_ur3e-10.11.0 11.49% <0.00%> (-0.13%) ⬇️
check_version_ur3e-5.9.4 11.68% <0.00%> (-0.43%) ⬇️
check_version_ur5-3.15.8 11.49% <0.00%> (-0.45%) ⬇️
check_version_ur5e-10.11.0 11.49% <0.00%> (-0.09%) ⬇️
check_version_ur5e-5.12.8 11.49% <0.00%> (-0.61%) ⬇️
check_version_ur7e-10.11.0 11.49% <0.00%> (-0.09%) ⬇️
check_version_ur7e-5.22.2 11.49% <0.00%> (-0.31%) ⬇️
check_version_ur8long-10.12.1 11.49% <0.00%> (-0.13%) ⬇️
check_version_ur8long-5.25.1 11.68% <0.00%> (-0.58%) ⬇️
python_scripts 75.90% <ø> (ø)
start_ursim 85.95% <ø> (-0.39%) ⬇️
ur20-latest 75.46% <100.00%> (-0.12%) ⬇️
ur5-3.14.3 75.39% <100.00%> (-0.17%) ⬇️
ur5e-10.11.0 70.08% <100.00%> (+0.18%) ⬆️
ur5e-10.12.0 71.16% <100.00%> (-0.13%) ⬇️
ur5e-10.7.0 69.43% <100.00%> (+0.14%) ⬆️
ur5e-5.9.4 ?
ur7e-10.13.0 71.22% <100.00%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@urrsk urrsk self-assigned this Aug 12, 2026
Comment thread tests/test_trajectory_streaming.cpp Outdated
// Stop writing to the trajectory socket for 500ms while the thread consumes
// what we already sent. We keep answering the reverse interface with NOOPs so
// that only the trajectory socket goes quiet.
for (int i = 0; i < 10; ++i)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe sleep slightly shorter than 0.5 sec as this is exactly the timeout define on the robot, to avoid unstable test and the time what is used to compare here might run on different computers.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, that's reasonable. I'll cut it to 400ms.

@acmorrow

Copy link
Copy Markdown
Contributor Author

@urrsk - I've pushed a possible solution to cleanup after starvation based on adding an id to points in a move. I followed up on your comment in #550 to discuss some of the ways my approach differs from your notes. Definitely interested to see what you think of this. It does seem to make the newly introduced tests go green, so that's a good start.

@acmorrow
acmorrow marked this pull request as ready for review August 12, 2026 13:30
@acmorrow
acmorrow requested a review from urrsk August 15, 2026 02:13
@acmorrow

Copy link
Copy Markdown
Contributor Author

Hi @urrsk - Just checking in on this PR. Generally, does it seem like a viable approach? Can the wire protocol change be accepted? Please let me know if there is anything you need from me in order to help move a fix for this issue forward, whether under this mechanism or some other that you would prefer. I'm happy to rework it if needed.

@urfeex

urfeex commented Aug 19, 2026

Copy link
Copy Markdown
Member

Without having dived into the details too much, it is obvious that this PR would require a major version bump. We do have a couple of things in mind that we want to change with the next major bump, so it might be reasonable to start preparing a 3.x on a new branch where this could potentially get merged to. Would you agree @urrsk ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants