Tuning Joint Drive Gains#
Learning Objectives#
In this tutorial, we will learn how to tune joints on a robot so that it behaves as expected. We recommend that you finish Import URDF prior to starting this tutorial.
Using Adding a Controller, you can also send direct effort commands and implement your own joint drives, but that goes beyond the scope of this document.
Understanding Joint Drives#
Joint Drives are dual-proportional controllers used to set a joint to a given target. One proportional gain is moderating the error in position, while the other gain is moderating the error in velocity. For historical reasons, these gains are called Stiffness and Damping, respectively.
Note
These Joint drives are implicit - meaning the position and velocity constraints are imposed by the drive with respect to the current time-step, in contrast to how it is usually done in engineering where it uses a closed loop control with readings of the previous time-step of position and velocity and reacting to it for future control. See Articulation Joint Drives.
While Stiffness is easy to understand, as it’s the same as a spring stiffness constant multiplying the error in position, as if the spring was stretched by that amount, Damping comes from the effect of targeting zero velocity - and therefore any movement would result in a reaction that attempts to stop it. In reality, we can actually have it track a velocity that is different than zero, and the effect is the same as stiffness would be in position.
where \(q\) and \(\dot{q}\) are the joint position and velocity, respectively. Note that when \(\dot{q}_{target} = 0\), the system reduces to a conventional PD controller on the joint position.
This formula applies for both revolute and prismatic joints.
The joint max force will act as a clamp for \(\tau\), and finally, the drive type will dictate if the effort will be applied directly as a torque/force or if it will be converted into an acceleration applied to the bodies connected to the joint.
Drive Modes#
This dual-proportional controller provides two main ways to control the robot - Through position target and Velocity target. Position target is used for controlled joints that are driven by defining a target distance/angle that the connected bodies should be. While the Velocity control is usually done for wheels or other free-spinning objects.
To have a position-controlled joint: set Stiffness to something greater than zero, and Damping can be any value.
To have a velocity-controlled joint: set Stiffness to zero, and Damping to any value greater than zero.
Gain Tuning#
By arbitrarily setting these values, a robot may behave in ways that it is not intended. For example, low damping/stiffness may not be able to overcome the robot’s inertia, and the measured value will be offset from the target value, and too high of a stiffness may cause the robot to overshoot and oscillate around the target. For a position-based control, in general, the following procedure can be used to achieve desired results:
Position Drive#
For each joint of the robot:
Start by setting the damping to zero and only tuning the stiffness. This will help you establish a stable response without the influence of the derivative term.
Increase the stiffness until the joint is able to converge near the target position.
Reduce the stiffness by one order of magnitude.
After setting the stiffness, Add damping with one order of magnitude lower than stiffness. This will be your baseline for the parameters and in general should not overshoot. If you want a faster response, reduce damping further.
Fine-tune both gains around this established baseline to achieve the desired performance, considering factors such as stability, response time, and overshoot.
It’s important to note that the specific tuning process may vary based on the characteristics of the robot and its control system.
If you want to emulate a control that includes gravity compensation, select all rigid bodies of the robot and check Disable Gravity in the properties panel.
Velocity limit and Industrial robots#
Many robots - including the majority of Industrial robots - come with pre-tuned PD control for their joint drives and can be set up to have perfect position control response, always driving at the given joint velocity limit. In order to reproduce this behavior, we can increase the joint stiffness from the previous tuning heuristic by a factor of two and define the maximum joint velocity in the Joint -> Advanced -> Maximum Joint velocity in the Properties panel. Run the simulation to verify the joint velocity is meeting the specification and fine-tune the stiffness until the joint max velocity limit is within tolerance. If stiffness is too high, the max velocity may still be violated, so it is not advised to just add infinite stiffness to the joint, and instead operate with stiffness similar to the ones calibrated without a max joint velocity.
Velocity Drive#
For each joint of the robot:
Start by setting the Stiffness to zero and only tuning the damping.
Increase the damping until the joint is able to converge near the target velocity.
If the robot may carry additional load, slightly increase the damping (e.g., add 10% extra) to account for the extra load.
For velocity-controlled joints - you can also set the max joint velocity, and the output will be limited by that value. You can also restrict the max joint force to impose maximum joint load effort.
Try it yourself#
You can do that by importing any robot on the library and working on the joint drive parameters, but for a more isolated test you can also author a simple prismatic joint connected to a fixed base, and model gains based on a rigid body with a given mass that moves along this prismatic joint. The suggested exercise is attempting a control that is able to quickly ramp to position but keep overshoot within 1% of the target.
The Gain Tuner Extension allows you to visualize the effects of different gains.