Allow setting payload inertia matrix via set_payload service #1808
Allow setting payload inertia matrix via set_payload service #1808srvald wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.
Reviewed by Cursor Bugbot for commit ae33e9e. Configure here.
| readData(data_package_buffer_, "tcp_offset", tcp_offset_); | ||
| readData(data_package_buffer_, "payload", rtde_payload_mass_); | ||
| readData(data_package_buffer_, "payload_cog", rtde_payload_cog_); | ||
| readData(data_package_buffer_, "payload_inertia", rtde_payload_inertia_); |
There was a problem hiding this comment.
RTDE read throws missing inertia
High Severity
The driver always reads payload_inertia from each RTDE packet and throws if the field is absent. Controllers or PolyScope builds that negotiate RTDE without that output can fail during read() instead of degrading payload-inertia verification only.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit ae33e9e. Configure here.
|
|
||
| if (transition_time > 0.0) { | ||
| std::this_thread::sleep_for(std::chrono::milliseconds(static_cast<int>(transition_time * 1000))); | ||
| } |
There was a problem hiding this comment.
Transition wait starts too early
Medium Severity
With verify_payload_on_set enabled, waitForPayloadRtdeMatch sleeps for the full transition_time only after async success returns, not from when the robot actually starts the transition. Early async completion plus delayed script execution can make RTDE checks run before inertia values settle, causing false verification failures.
Reviewed by Cursor Bugbot for commit ae33e9e. Configure here.
| PAYLOAD_STATE_INERTIA_IXY = 78, | ||
| PAYLOAD_STATE_INERTIA_IXZ = 79, | ||
| PAYLOAD_STATE_INERTIA_IYZ = 80, | ||
| PAYLOAD_STATE_TRANSITION_TIME = 81, |
There was a problem hiding this comment.
Invalid payload state enum index
Low Severity
PAYLOAD_STATE_TRANSITION_TIME is defined as index 81, but state_interface_configuration() only registers payload state interfaces through index 80. There is no matching state interface, so using this enum would index past the claimed interfaces.
Reviewed by Cursor Bugbot for commit ae33e9e. Configure here.


Summary
Implements the driver-side changes to support the extended
SetPayloadservice,which now accepts a full
geometry_msgs/Inertiapayload (mass, center of gravity,and 6-component inertia tensor) and a
transition_timefield.This enables use of the robot's
set_target_payload(m, cog, inertia, transition_time)URScript function instead of the simpler
set_payload(m, cog) (DEPRECATED).Breaking changes
The
set_payloadservice request format changes (driven by theur_msgsupdate).Any existing callers must be updated to use
geometry_msgs/Inertiainstead ofseparate
massandcogfields.Changes
ur_controllersPAYLOAD_INERTIA_IXX/IYY/IZZ/IXY/IXZ/IYZandPAYLOAD_TRANSITION_TIMEentries to the
CommandInterfacesenum ingpio_controller.hppPAYLOAD_STATE_INERTIA_*entries to theStateInterfacesenumcommand_interface_configuration()andstate_interface_configuration()with the new payload interfaces
setPayload()callback to pass inertia and transition_time to thecommand interfaces
waitForPayloadRtdeMatch()to verify inertia components and to waitfor
transition_timeto elapse before checking RTDE feedbackur_robot_driverpayload_inertia_,payload_transition_time_andrtde_payload_inertia_members tohardware_interface.hpp(backed by RTDE feedback) to
export_state_interfaces()andexport_command_interfaces()inhardware_interface.cppcheckAsyncIO()to callsetTargetPayload()instead ofsetPayload().payload_inertiatortde_output_recipe.txtur.ros2_control.xacrowith the new payload command and state interfacesintegration_test_payload.pyand registered it inCMakeLists.txtTest
Open one terminal and launch the
ur_ros2_driverby:Then in another terminal execute:
ros2 service call /io_and_status_controller/set_payload ur_msgs/srv/SetPayload '{payload: {m: 0.01, com: {x: 0.2, y: 0.1, z: 0.3}, ixx: 0.01, ixy: 0.0, ixz: 0.03, iyy: 0.01, iyz: 0.02, izz: 0.01}, transition_time: 1.0}'It will successfully set the new changes.
Design notes
geometry_msgs/Inertiawas chosen because it encapsulates mass, center of gravity,and the full inertia tensor in a single standard ROS type, resulting in a cleaner API.
This is a breaking change: the previous
mass(float32) andcog(Vector3) fieldsare replaced by
geometry_msgs/Inertia payload. A backwards-compatible alternativewould be to keep
massandcogand add individualfloat64fields for the inertiacomponents (
ixx,iyy,izz,ixy,ixz,iyz) andtransition_time.If this approach is preferred, then I'll update the implementation, which will mean that the
SetPayload.srvwill be:Related issues
Closes #1711
Note
Medium Risk
Breaking SetPayload API and changes how robot payload is applied (setTargetPayload); incorrect inertia or timing could affect dynamics and motion, though scope is limited to payload configuration.
Overview
Extends
set_payloadso callers can set a full tool payload (mass, center of gravity, inertia tensor, and optional ramp time) instead of mass/COG only, using UR’sset_target_payloadpath rather than deprecatedset_payload.GPIOControllermaps the updatedSetPayloadrequest (geometry_msgs/Inertia+transition_time) onto new ros2_control command interfaces for inertia components and transition time, andwaitForPayloadRtdeMatchnow compares RTDEpayload_inertiafeedback (with tolerances) and sleeps fortransition_timebefore verification when enabled.URPositionHardwareInterfacewires matching command/state GPIOs, readspayload_inertiafrom RTDE, and triggerssetTargetPayloadonce all payload fields are written.ur.ros2_control.xacroandrtde_output_recipe.txtare updated accordingly.Adds
integration_test_payload.py(mass/COG-only, full inertia, transition time, sequential updates). Breaking: existingSetPayloadclients must adopt the newur_msgsrequest shape; depends onur_msgsandur_client_librarycompanion PRs.Reviewed by Cursor Bugbot for commit ae33e9e. Bugbot is set up for automated code reviews on this repo. Configure here.