Skip to content

Primary client script execution feedback#484

Merged
urfeex merged 78 commits into
UniversalRobots:masterfrom
URJala:primary_client_script_execution_feedback
May 21, 2026
Merged

Primary client script execution feedback#484
urfeex merged 78 commits into
UniversalRobots:masterfrom
URJala:primary_client_script_execution_feedback

Conversation

@URJala
Copy link
Copy Markdown
Collaborator

@URJala URJala commented Apr 16, 2026

This is not quite done yet, but the main logic and the test cases are there
Still missing documentation and example also needs to be finished.


Note

Medium Risk
Adds new blocking URScript execution flow in PrimaryClient that parses/rewrites scripts and reacts to robot error/key/runtime-exception messages, which could affect program execution/stop behavior. Includes substantial new test infrastructure (fake primary server) and example/docs, but changes are isolated to primary-client script sending paths.

Overview
Adds a new PrimaryClient::sendScriptBlocking() API that prepares and validates URScript, checks robot/safety state, sends the script, and then waits for PROGRAM_XXX_STARTED/STOPPED plus error-code and runtime-exception messages to determine success (optionally failing on warnings and issuing stop program on faults/violations).

Extends the primary consumer/visitor to handle KeyMessage and RuntimeExceptionMessage, adds ScriptCodeSyntaxException, and adjusts runtime-exception line/column types to uint32_t. Also adds a send_script example + docs and introduces a FakePrimaryServer with new unit/integration tests covering success paths, timeouts, read-only primary interface (C210), warnings/faults, and runtime exceptions.

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 16, 2026

Codecov Report

❌ Patch coverage is 90.81633% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.72%. Comparing base (3f95311) to head (772f460).
⚠️ Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
src/primary/primary_client.cpp 92.09% 1 Missing and 13 partials ⚠️
include/ur_client_library/exceptions.h 50.00% 2 Missing ⚠️
...clude/ur_client_library/primary/primary_consumer.h 83.33% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #484      +/-   ##
==========================================
+ Coverage   76.96%   77.72%   +0.75%     
==========================================
  Files         116      116              
  Lines        6343     6563     +220     
  Branches     2761     2898     +137     
==========================================
+ Hits         4882     5101     +219     
+ Misses       1113     1098      -15     
- Partials      348      364      +16     
Flag Coverage Δ
check_version_ur10-3.15.8 11.47% <3.57%> (?)
check_version_ur10e-10.11.0 11.47% <3.57%> (?)
check_version_ur10e-5.15.2 11.66% <3.57%> (?)
check_version_ur12e-10.12.1 11.47% <3.57%> (?)
check_version_ur12e-5.25.1 11.66% <3.57%> (?)
check_version_ur15-10.12.1 11.52% <3.57%> (?)
check_version_ur15-5.25.1 11.47% <3.57%> (?)
check_version_ur16e-10.12.1 11.47% <3.57%> (?)
check_version_ur16e-5.25.1 11.47% <3.57%> (?)
check_version_ur18-10.12.1 11.47% <3.57%> (?)
check_version_ur18-5.25.1 11.47% <3.57%> (?)
check_version_ur20-10.12.1 11.47% <3.57%> (?)
check_version_ur20-5.25.1 11.47% <3.57%> (?)
check_version_ur3-3.14.3 11.50% <3.57%> (?)
check_version_ur30-10.12.1 11.47% <3.57%> (?)
check_version_ur30-5.25.1 11.47% <3.57%> (?)
check_version_ur3e-10.11.0 11.47% <3.57%> (?)
check_version_ur3e-5.9.4 11.89% <3.57%> (?)
check_version_ur5-3.15.8 12.93% <3.57%> (?)
check_version_ur5e-10.11.0 11.47% <3.57%> (?)
check_version_ur5e-5.12.8 11.52% <3.57%> (?)
check_version_ur7e-10.11.0 11.47% <3.57%> (?)
check_version_ur7e-5.22.2 11.47% <3.57%> (?)
check_version_ur8long-10.12.1 11.47% <3.57%> (?)
check_version_ur8long-5.25.1 11.47% <3.57%> (?)
python_scripts 75.90% <ø> (ø)
start_ursim 81.75% <ø> (-3.34%) ⬇️
ur20-latest 73.54% <90.81%> (+0.37%) ⬆️
ur5-3.14.3 73.34% <90.30%> (?)
ur5e-10.11.0 67.75% <90.30%> (+0.43%) ⬆️
ur5e-10.12.0 68.75% <90.30%> (+0.43%) ⬆️
ur5e-10.7.0 67.17% <90.30%> (+0.51%) ⬆️
ur5e-5.9.4 74.04% <90.30%> (+0.34%) ⬆️

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

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

Copy link
Copy Markdown
Member

@urfeex urfeex left a comment

Choose a reason for hiding this comment

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

First, very high-level overview.

Comment thread include/ur_client_library/primary/primary_client.h Outdated
Comment thread src/primary/primary_client.cpp
Comment thread examples/primary_client.cpp Outdated
Copy link
Copy Markdown
Member

@urfeex urfeex left a comment

Choose a reason for hiding this comment

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

There seems to be an error somewhere in the logic. When I run the example with a robot that is not break-released, it releases breaks correctly, but then not all following commands are executed. I don't know whether there are some messages being lost due to the frequency things are called with or if there are flags that would need to be reset on the way.

This could be related with the error code handling. One example output is

[1776862206.490350] INFO /home/feex/git/ur_client_library/src/primary/primary_client.cpp 74: Starting primary client pipeline
Client connected
[1776862212.575126] INFO /home/feex/git/ur_client_library/include/ur_client_library/primary/primary_consumer.h 147: Logging an ErrorCodeMessage from the UR Controller Box: C100A7
[1776862212.581287] ERROR /home/feex/git/ur_client_library/src/primary/primary_client.cpp 237: Robot encountered error(s) during script execution, stopping program
[1776862212.581336] ERROR /home/feex/git/ur_client_library/src/primary/primary_client.cpp 240: Robot error code: C286A1
[1776862212.581351] ERROR /home/feex/git/ur_client_library/src/primary/primary_client.cpp 240: Robot error code: C286A1
[1776862212.581362] ERROR /home/feex/git/ur_client_library/src/primary/primary_client.cpp 240: Robot error code: C286A1
[1776862212.581385] ERROR /home/feex/git/ur_client_library/src/primary/primary_client.cpp 240: Robot error code: C286A1
[1776862212.581397] ERROR /home/feex/git/ur_client_library/src/primary/primary_client.cpp 240: Robot error code: C286A1
[1776862212.581407] ERROR /home/feex/git/ur_client_library/src/primary/primary_client.cpp 240: Robot error code: C286A1
[1776862212.581426] ERROR /home/feex/git/ur_client_library/src/primary/primary_client.cpp 240: Robot error code: C286A1
[1776862212.581438] ERROR /home/feex/git/ur_client_library/src/primary/primary_client.cpp 240: Robot error code: C286A1
[1776862212.581453] ERROR /home/feex/git/ur_client_library/src/primary/primary_client.cpp 240: Robot error code: C286A1
[1776862212.581466] ERROR /home/feex/git/ur_client_library/src/primary/primary_client.cpp 240: Robot error code: C286A1
[1776862212.581488] ERROR /home/feex/git/ur_client_library/src/primary/primary_client.cpp 240: Robot error code: C286A1
[1776862212.581505] ERROR /home/feex/git/ur_client_library/src/primary/primary_client.cpp 240: Robot error code: C286A1
[1776862212.581516] ERROR /home/feex/git/ur_client_library/src/primary/primary_client.cpp 240: Robot error code: C304A4
[1776862212.581537] ERROR /home/feex/git/ur_client_library/src/primary/primary_client.cpp 240: Robot error code: C100A7
[1776862212.684815] INFO /home/feex/git/ur_client_library/src/primary/primary_client.cpp 262: Script with name cool_function_name started
[1776862212.684926] INFO /home/feex/git/ur_client_library/src/primary/primary_client.cpp 256: Script with name cool_function_name executed successfully
[1776862212.685579] INFO /home/feex/git/ur_client_library/src/primary/primary_client.cpp 68: Stopping primary client pipeline

Comment thread examples/primary_client.cpp Outdated
Comment thread src/primary/primary_client.cpp Outdated
Comment thread src/primary/primary_client.cpp Outdated
@URJala URJala force-pushed the primary_client_script_execution_feedback branch 2 times, most recently from 34d20cb to 89f09ff Compare April 30, 2026 07:23
Comment thread src/primary/primary_client.cpp
Comment thread src/primary/primary_client.cpp
Comment thread src/primary/primary_client.cpp
Comment thread src/primary/primary_client.cpp
Comment thread examples/send_script_blocking.cpp Outdated
Comment thread include/ur_client_library/primary/primary_client.h Outdated
Comment thread include/ur_client_library/primary/primary_client.h Outdated
Comment thread include/ur_client_library/primary/primary_client.h Outdated
Comment thread tests/test_primary_client.cpp
Comment thread src/primary/primary_client.cpp Outdated
Comment thread src/primary/primary_client.cpp
Comment thread src/primary/primary_client.cpp
Comment thread src/primary/primary_client.cpp Outdated
Comment thread src/primary/primary_client.cpp Outdated
@urfeex urfeex force-pushed the primary_client_script_execution_feedback branch from fd597e0 to 4e0fced Compare May 20, 2026 10:46
Comment thread src/primary/primary_client.cpp
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default mode and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit dd01eae. Configure here.

Comment thread src/primary/primary_client.cpp
@urfeex urfeex merged commit 627cf20 into UniversalRobots:master May 21, 2026
53 of 63 checks passed
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.

2 participants