Practical guide to lift gravity compensation

TLDR: If your lift tends to slowly descend under its own weight, you may need to adjust your gravity compensation

Lift gravity compensation for Stretch may be something you didn’t even know existed. In most cases, you won’t need to.

In some cases we’ve seen users with a DexWrist using gravity compensations settings for the standard gripper (causing their lift to drift downward).

Gravity compensation adds a fixed ‘feedforward’ current to the motor controller to support the lift against gravity. This allows the lift to ‘float’ when the runstop is enabled, for example. If the feedforward current is too low, the lift will drift downward. If it is too high, it will drift upward.

If the payload or tool for Stretch changes then you may want to adjust the gravity compensation value to allow the lift to float correctly.

First, check your current values:

stretch_params.py | grep lift | grep feed 
stretch_body.robot_params.nominal_params          param.hello-motor-lift.gains.i_safety_feedforward                      0.54                           
stretch_configuration_params.yaml      param.lift.i_feedforward                   0.54   

As you see, there are two relevant parameters. The i_safety_feedforward is the amount of current (A) applied when the motor is in safety mode (eg, runstop enabled). The i_feedforward term is applied when the lift is in normal operation. Generally the two parameters will be identical.

Fortunately, there’s a simple tool to run that will compute these values. REx_calibrate_gravity_comp.py will move the lift to a few positions, sampled the applied motor currents, and update your gravity compensation parameters.

Finally, the maximum current of the lift motor can be found as shown. In general the gravity compensation currents should be below 50% of the maximum assuming a reasonable payload on the arm:

stretch_params.py | grep lift | grep iMax
stretch_body.robot_params.nominal_params                               param.hello-motor-lift.gains.iMax_neg                                  -3.2                          
stretch_body.robot_params.nominal_params                               param.hello-motor-lift.gains.iMax_pos                                  3.2 ```
2 Likes