Skip to content

Add set_target_payload support to ScriptCommandInterface#515

Open
srvald wants to merge 1 commit into
UniversalRobots:masterfrom
srvald:set_target_payload
Open

Add set_target_payload support to ScriptCommandInterface#515
srvald wants to merge 1 commit into
UniversalRobots:masterfrom
srvald:set_target_payload

Conversation

@srvald
Copy link
Copy Markdown
Contributor

@srvald srvald commented Jun 5, 2026

Description

Adds support for the URScript set_target_payload() command through the
ScriptCommandInterface, allowing users to set the payload mass, center of
gravity, inertia matrix, and transition time.

This follows the same pattern as the existing setPayload() implementation.

Changes

  • include/ur_client_library/control/script_command_interface.h: Added
    setTargetPayload() declaration and the SET_TARGET_PAYLOAD = 12 enum value
    to ScriptCommand.
  • include/ur_client_library/ur/ur_driver.h: Added setTargetPayload()
    declaration to UrDriver.
  • src/control/script_command_interface.cpp: Implemented
    ScriptCommandInterface::setTargetPayload(), encoding mass, CoG (3 values),
    inertia matrix (6 values), and transition time into the binary message.
  • src/ur/ur_driver.cpp: Implemented UrDriver::setTargetPayload().
  • resources/external_control.urscript: Added SET_TARGET_PAYLOAD = 12
    constant and the corresponding elif branch in the script_commands thread
    to call set_target_payload().
  • tests/test_script_command_interface.cpp: Added
    test_set_target_payload unit test verifying correct encoding of all fields
    (mass, CoG, inertia, transition time) and that unused message slots are zero.

Message layout for SET_TARGET_PAYLOAD

Index Meaning
0 Command (12)
1 Mass (kg)
2–4 Center of gravity (m)
5–10 Inertia matrix elements (kg·m²)
11 Transition time (s)
12–27 Unused (zero-padded)

Notes

  • transition_time defaults to 0.0 seconds (no transition).

Related issues

UniversalRobots/Universal_Robots_ROS2_Driver#1711

Related PR (ur_ros2_driver): UniversalRobots/Universal_Robots_ROS2_Driver#1808


Note

Medium Risk
Adds a new path for robot payload/dynamics parameters; incorrect values could affect motion modeling, but the change mirrors the existing setPayload pattern with tests on the wire format.

Overview
Adds setTargetPayload end-to-end so clients can drive URScript set_target_payload() (mass, CoG, inertia, optional transition time) through the same script-command path as setPayload().

ScriptCommandInterface and UrDriver expose the new API; command SET_TARGET_PAYLOAD (12) encodes eleven payload fields into the fixed 28-int script-command buffer (with zero padding). external_control.urscript decodes the message and calls set_target_payload. When the script-command socket is down, UrDriver falls back to a plain set_target_payload(...) script, matching existing payload behavior. A unit test verifies command id and field encoding.

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 5, 2026

Codecov Report

❌ Patch coverage is 0% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 15.70%. Comparing base (627cf20) to head (67d123d).

Files with missing lines Patch % Lines
src/control/script_command_interface.cpp 0.00% 21 Missing ⚠️
src/ur/ur_driver.cpp 0.00% 12 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (627cf20) and HEAD (67d123d). Click for more details.

HEAD has 455 uploads less than BASE
Flag BASE (627cf20) HEAD (67d123d)
start_ursim 16 1
check_version_ur3-3.14.3 16 1
check_version_ur18-5.25.1 14 1
check_version_ur5e-5.12.8 16 1
check_version_ur3e-5.9.4 16 1
check_version_ur8long-5.25.1 16 1
check_version_ur15-5.25.1 16 1
check_version_ur20-5.25.1 16 1
check_version_ur10e-5.15.2 16 1
check_version_ur7e-5.22.2 16 1
check_version_ur12e-5.25.1 16 1
check_version_ur16e-5.25.1 16 1
check_version_ur5-3.15.8 16 1
check_version_ur30-5.25.1 16 1
check_version_ur15-10.12.1 16 1
check_version_ur20-10.12.1 16 1
check_version_ur8long-10.12.1 15 1
check_version_ur16e-10.12.1 16 1
check_version_ur5e-10.11.0 16 1
check_version_ur18-10.12.1 16 1
check_version_ur10-3.15.8 16 1
check_version_ur7e-10.11.0 16 1
check_version_ur10e-10.11.0 16 1
check_version_ur30-10.12.1 16 1
check_version_ur3e-10.11.0 15 1
check_version_ur12e-10.12.1 16 1
ur5e-10.11.0 13 0
ur5e-10.12.0 13 0
ur5e-10.7.0 13 0
ur20-latest 12 0
ur5-3.14.3 10 0
ur5e-5.9.4 8 0
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #515       +/-   ##
===========================================
- Coverage   78.12%   15.70%   -62.43%     
===========================================
  Files         116      116               
  Lines        6566     6596       +30     
  Branches     2898     2912       +14     
===========================================
- Hits         5130     1036     -4094     
- Misses       1077     5476     +4399     
+ Partials      359       84      -275     
Flag Coverage Δ
check_version_ur10-3.15.8 11.15% <0.00%> (-1.98%) ⬇️
check_version_ur10e-10.11.0 11.41% <0.00%> (-0.11%) ⬇️
check_version_ur10e-5.15.2 11.78% <0.00%> (-0.76%) ⬇️
check_version_ur12e-10.12.1 11.46% <0.00%> (-0.07%) ⬇️
check_version_ur12e-5.25.1 11.60% <0.00%> (-0.23%) ⬇️
check_version_ur15-10.12.1 11.46% <0.00%> (-0.07%) ⬇️
check_version_ur15-5.25.1 11.41% <0.00%> (-0.36%) ⬇️
check_version_ur16e-10.12.1 11.41% <0.00%> (-0.16%) ⬇️
check_version_ur16e-5.25.1 11.60% <0.00%> (-0.12%) ⬇️
check_version_ur18-10.12.1 11.41% <0.00%> (-0.16%) ⬇️
check_version_ur18-5.25.1 11.41% <0.00%> (-0.48%) ⬇️
check_version_ur20-10.12.1 11.41% <0.00%> (-0.16%) ⬇️
check_version_ur20-5.25.1 11.60% <0.00%> (-0.76%) ⬇️
check_version_ur3-3.14.3 11.46% <0.00%> (-1.81%) ⬇️
check_version_ur30-10.12.1 11.46% <0.00%> (-0.07%) ⬇️
check_version_ur30-5.25.1 11.60% <0.00%> (-0.23%) ⬇️
check_version_ur3e-10.11.0 11.41% <0.00%> (-0.11%) ⬇️
check_version_ur3e-5.9.4 11.41% <0.00%> (-0.53%) ⬇️
check_version_ur5-3.15.8 11.60% <0.00%> (-1.82%) ⬇️
check_version_ur5e-10.11.0 11.41% <0.00%> (-0.16%) ⬇️
check_version_ur5e-5.12.8 11.65% <0.00%> (-0.24%) ⬇️
check_version_ur7e-10.11.0 11.41% <0.00%> (-0.16%) ⬇️
check_version_ur7e-5.22.2 11.41% <0.00%> (-0.48%) ⬇️
check_version_ur8long-10.12.1 11.46% <0.00%> (-0.11%) ⬇️
check_version_ur8long-5.25.1 11.41% <0.00%> (-0.86%) ⬇️
python_scripts 75.90% <ø> (ø)
start_ursim 83.94% <ø> (-1.26%) ⬇️
ur20-latest ?
ur5-3.14.3 ?
ur5e-10.11.0 ?
ur5e-10.12.0 ?
ur5e-10.7.0 ?
ur5e-5.9.4 ?

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.

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.

1 participant