Based on contributions by How-to, bram.leinberger.
When picking up objects with a UR robot, the controller needs to know the payload’s mass and center of gravity. Get this wrong and the robot can run into protective stops or move incorrectly. This article shows the URScript commands to read and update the payload at run-time, e.g. right before the robot grips a heavier object.
What you need
- A UR robot with URScript access (via Polyscope, or via Python using How to find and set the IP address for connecting a PC to a UR robot)
- The mass of the payload in kg
- Either a known center of gravity offset, or access to Polyscope’s built-in payload wizard to measure it
Steps
1. Set payload, center of gravity and inertia
set_target_payload(m, cog, inertia)
m: mass of the payload, in kg (required)cog: center of gravity offset from the tool mount, as[CoGx, CoGy, CoGz](required)inertia: as[Ixx, Iyy, Izz, Ixy, Ixz, Iyz](optional)
2. Measure mass and center of gravity
Polyscope has a built-in wizard that calculates the mass and center of gravity for you: you move the robot to four different positions with the payload attached, and it computes the values automatically. This is much less error-prone than calculating them manually.
3. Read back the current payload settings
get_target_payload()
get_target_payload_cog()
get_target_payload_inertia()
These return the payload parameters currently set on the robot.
4. Update payload for a heavy object right before you pick it up
For lighter objects that don’t noticeably affect the robot’s motion, you can weigh them while already carrying them and update the payload afterwards.
For heavier objects, update the payload at the correct moment: move to just above the object, call set_target_payload() with the new values, and only then close the gripper and lift. This avoids the robot moving with the wrong payload set for any significant distance.
5. Setting the tool center point (TCP)
Check: the sources for this article only describe setting payload, not scripting the TCP itself. The standard way to set the TCP is Polyscope’s built-in 4-point calibration wizard (the same one used for payload/CoG). If you need to set or change the TCP from Python instead, use
setTcp()from the RTDE library — see the custom control class in How to find and set the IP address for connecting a PC to a UR robot.
Troubleshooting / Common mistakes
- An incorrectly set payload is a common cause of protective stops when picking up or moving objects.
- “Move until contact” is not available as a URScript function — the source notes it can only be used from the Polyscope interface, not scripted directly.
Related
- How to find and set the IP address for connecting a PC to a UR robot — control the robot (and set payload/TCP) from Python with RTDE
- How to set the payload and center of gravity on a UR e-Series robot — calculate and set the payload and centre of gravity on the pendant (Installation tab)
- How to find and set the IP address for connecting a PC to a UR robot — find/set the robot’s IP address
Rewritten and consolidated (Sept 2026) from the original student how-to’s: Set tool center, payload and center of gravity on a Universal Robot at run-time, How to Actively set the payload of the UR robot.