Gravity Compensation for a UR10e controller with the UR ROS package

We’re using the Universal Robots ROS package from Github for our project, with Gazebo simulating UR robots. Each joint has an Effort Controller following a predefined trajectory. However, gravity affects the robot arm as it nears the desired position, preventing it from reaching it fully. That’s why we want to add a gravity compensation torque to the existing PID control torque for the joints.

Where in Gazebo are the PID parameters of individual joints used to calculate joint positions and velocities? Also, how can we intervene to implement Gravity Compensation in the Effort Controller?

It seems that the PID controllers in Gazebo are responsible for controlling the joint positions and velocities. At what point can the gravity compensation term be implemented? Be it in the form of a vector with 6 entries or separately.

Any insights on the implementation details in ROS/Gazebo would be greatly appreciated. Thank you!

Have you set your payload and TCP correctly? There is a dynamics model (including gravity compensation) inside the robot software. It should do its job work when payload, TCP, mounting and so on is set correctly. It sounds like you’re trying to solve a problem in ROS that should be solved by the robot software instead.

We don’t have a payload/tool in our simulation, so we have nothing to set. We want to develop a software in the loop simulation within ROS/Gazebo, so we are not working with the hardware right now. We are using the ROS package from this repository GitHub - ros-industrial/universal_robot: ROS-Industrial Universal Robots support (

As fas as we understand, this UR package doesn’t contain explicit dynamics nor a gravity compensation. That’s why we want to implement a gravity compensation in joint space. Our problem is, that we don’t know how to access the joint efforts applied to each joint in Gazebo to add the compensation torques (efforts).

Can you give us any advice on which ROS package to use for the simulation of gravity and its compensation of the UR10e robotic arm?

I am not sure I understand exactly what you’re trying to achieve.

However, if you want to get results that takes UR’s dynamics model, time-scaling, etc. into account, then you’re probably best off having the UR software in the loop somehow. This doesn’t have to be a physical robot. It can be our URSim. You can connect to that the same way you’d connect to a real robot.

UR have supported development of ROS drivers with the goal of making ROS work as smoothly as possible with the UR software, including time-scaling, safety functions, easy programming on our teach pendant, and much more. This is the driver for ROS2:

There is also a version for ROS1 and there is a client library version that’s not ROS dependent.

Maybe this is something you want to consider looking into?

I am not sure if this is helpful at all?