Skip to content

Primary client script execution feedback#484

Open
URJala wants to merge 64 commits into
UniversalRobots:masterfrom
URJala:primary_client_script_execution_feedback
Open

Primary client script execution feedback#484
URJala wants to merge 64 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 script-execution flow on the PrimaryClient that depends on robot state, safety mode, and asynchronous key/error/runtime-exception messages; failures here could impact program execution/stop behavior and client control flow.

Overview
Adds PrimaryClient::sendScriptBlocking() to upload URScript and wait for start/stop feedback, failing on robot errors, runtime exceptions, start timeout, and (optionally) warnings; it also introduces safetyModeAllowsExecution() plus script preparation/validation (comment stripping, auto-wrapping in def, name validation/truncation) and a new ScriptCodeSyntaxException.

Extends primary message consumption to handle KeyMessage and RuntimeExceptionMessage, queues them in PrimaryClient, and uses them to determine script outcome. Updates build config to silence GCC 13–15 <regex> warnings for primary_client.cpp, adds a new send_script_blocking example, expands primary-client tests for the new behavior, and documents the PrimaryClient architecture page.

Reviewed by Cursor Bugbot for commit 60e3346. 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 78.21229% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.69%. Comparing base (3f95311) to head (60e3346).

Files with missing lines Patch % Lines
src/primary/primary_client.cpp 78.12% 17 Missing and 18 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.85%   76.69%   -0.16%     
==========================================
  Files         116      116              
  Lines        6343     6519     +176     
  Branches     2761     2881     +120     
==========================================
+ Hits         4875     5000     +125     
- Misses       1120     1148      +28     
- Partials      348      371      +23     
Flag Coverage Δ
python_scripts 75.90% <ø> (ø)
start_ursim 84.55% <ø> (-0.54%) ⬇️
ur20-latest 73.11% <78.21%> (-0.02%) ⬇️
ur5e-10.11.0 67.09% <78.21%> (+0.09%) ⬆️
ur5e-10.12.0 68.54% <78.21%> (+0.22%) ⬆️
ur5e-10.7.0 66.67% <78.21%> (+0.01%) ⬆️
ur5e-5.9.4 73.68% <78.21%> (+0.08%) ⬆️

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
@URJala URJala force-pushed the primary_client_script_execution_feedback branch from 7d912f5 to 6a8cbe8 Compare May 15, 2026 10:40
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
Comment thread src/primary/primary_client.cpp Outdated
Comment thread src/primary/primary_client.cpp Outdated
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
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 60e3346. Configure here.

if (is_warning && fail_on_warnings)
{
return false;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning failure path doesn't stop running script

Medium Severity

When is_warning && fail_on_warnings is true, sendScriptBlocking returns false without calling commandStop() to halt the running program on the robot. The error-handling path (the is_error block just above) correctly calls commandStop() before returning false. This inconsistency means a warning that doesn't inherently stop the robot (i.e., not a protective stop) leaves the script still executing while the caller believes execution failed.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 60e3346. Configure here.

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