Add set_target_payload support to ScriptCommandInterface#515
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #515 +/- ##
==========================================
- Coverage 77.66% 76.70% -0.97%
==========================================
Files 115 116 +1
Lines 6480 6649 +169
Branches 2898 2939 +41
==========================================
+ Hits 5033 5100 +67
- Misses 1081 1210 +129
+ Partials 366 339 -27
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
67d123d to
2d1074a
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 2cfc96c. Configure here.
urfeex
left a comment
There was a problem hiding this comment.
This is looking clean! I'm only wondering whether we should move the MULT_TIME up to ReverseInterface and re-use that for the transition time. I think, we should do that.
urfeex
left a comment
There was a problem hiding this comment.
Please also add documentation updates to script_command_interface.rst and add a command to the script_command_example,
|
@urfeex Should we put somewhere that setPayload is deprecated? |
I would say let's not add a compile time deprecation. We could print a warning when |

Description
Adds support for the URScript
set_target_payload()command through theScriptCommandInterface, allowing users to set the payload mass, center ofgravity, 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: AddedsetTargetPayload()declaration and theSET_TARGET_PAYLOAD = 12enum valueto
ScriptCommand.include/ur_client_library/ur/ur_driver.h: AddedsetTargetPayload()declaration to
UrDriver.src/control/script_command_interface.cpp: ImplementedScriptCommandInterface::setTargetPayload(), encoding mass, CoG (3 values),inertia matrix (6 values), and transition time into the binary message.
src/ur/ur_driver.cpp: ImplementedUrDriver::setTargetPayload().resources/external_control.urscript: AddedSET_TARGET_PAYLOAD = 12constant and the corresponding
elifbranch in thescript_commandsthreadto call
set_target_payload().tests/test_script_command_interface.cpp: Addedtest_set_target_payloadunit 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
12)Notes
transition_timedefaults to0.0seconds (no transition).Related issues
UniversalRobots/Universal_Robots_ROS2_Driver#1711
Related PR (ur_ros2_driver): UniversalRobots/Universal_Robots_ROS2_Driver#1808
Tasks
Note
Medium Risk
Changes active payload modeling on the robot (mass, inertia, transition), which affects motion and force behavior; version fallbacks omit inertia on older PolyScope.
Overview
Adds
setTargetPayloadend-to-end so clients can set mass, CoG, inertia, and transition time via the script command socket (command 12), mirroring existingsetPayload.ScriptCommandInterfaceandUrDriverexpose the new API; the driver uses the binary interface when connected, otherwise emitsset_target_payload()(PolyScope ≥ 5.10) or falls back toset_payload()with a warning.external_control.urscriptdecodes the message and callsset_target_payload()on supported versions.MULT_TIMEmoves toReverseInterface(shared with script command encoding); docs and the script-command example are updated. Unit/integration tests cover wire format and fallback script paths.Reviewed by Cursor Bugbot for commit 8e57d54. Bugbot is set up for automated code reviews on this repo. Configure here.