Stiffness control

NAOqi Motion - Overview | API


What it does

These API control the Stiffness of one or several joint(s).
The Stiffness of the joint is equivalent to a torque limitation into the motors.
  • If the joint stiffness is set to 0.0, the joint controller does nothing and the joint is free.
  • Else with a value at 1.0 the joint is allowed to use full torque power to reach a given position.
  • Between these two extremes, the joint is more or less compliant (tries to reach a position but if torque need to move is higher than the limitation of Stiffness, the joint doesn’t reach the target position).
The Stiffness can be managed:

How it works

These API just create a higher level of the DCM hardness definition and provide interpolation in order to have more smooth behavior.

Use Cases

Case 1: Stiffness On

When NAO is switched on, he initially has zero Stiffness. When at zero Stiffness, you can send any commands to the motors, but he will not move.

To give power to the motors, you can call one of Motion’s Stiffness methods:

motion_stiffnessOn.py

# -*- encoding: UTF-8 -*- 

'''Stiffness On: active stiffness of all joints and actuators'''

import sys
from naoqi import ALProxy

def main(robotIP):

    try:
        motionProxy = ALProxy("ALMotion", robotIP, 9559)
    except Exception, e:
        print "Could not create proxy to ALMotion"
        print "Error was: ", e

    # We use the "Body" name to signify the collection of all joints
    pNames = "Body"
    pStiffnessLists = 1.0
    pTimeLists = 1.0
    motionProxy.stiffnessInterpolation(pNames, pStiffnessLists, pTimeLists)

    # print motion state
    print motionProxy.getSummary()


if __name__ == "__main__":
    robotIp = "127.0.0.1"

    if len(sys.argv) <= 1:
        print "Usage python motion_stiffnessOn.py robotIP (optional default: 127.0.0.1)"
    else:
        robotIp = sys.argv[1]

    main(robotIp)

Avoiding judder

When changing Stiffness away from zero, it is best to do it gently so as to reduce the chance of a judder when powering up the motors.

Adapting the Stiffness to task

Many tasks can be achieved at less than maximum Stiffness (Stiffness = 0.6), but tasks such as “Get up” require all the power they can get (Stiffness = 1.0).

Case 2: Stiffness Off

When you reduce the Stiffness to zero, you cut all the power to the motors, so you should be careful that NAO is in a self-stable pose, otherwise he could fall.

motion_stiffnessOff.py

# -*- encoding: UTF-8 -*- 

'''Stiffness Off: remove stiffness of all joints and actuators'''

import sys
from naoqi import ALProxy

def main(robotIP):

    try:
        motionProxy = ALProxy("ALMotion", robotIP, 9559)
    except Exception, e:
        print "Could not create proxy to ALMotion"
        print "Error was: ", e

    # We use the "Body" name to signify the collection of all joints
    pNames = "Body"
    pStiffnessLists = 0.0
    pTimeLists = 1.0
    motionProxy.stiffnessInterpolation(pNames, pStiffnessLists, pTimeLists)

    # print motion state
    print motionProxy.getSummary()


if __name__ == "__main__":
    robotIp = "127.0.0.1"

    if len(sys.argv) <= 1:
        print "Usage python motion_stiffnessOff.py robotIP (optional default: 127.0.0.1)"
    else:
        robotIp = sys.argv[1]

    main(robotIp)

Case 3: Stiffness Trajectories

Should you wish to vary the Stiffness of a joint over time, you can request a ‘trajectory’ of Stiffness.

# Example showing a stiffness trajectory
# Here the stiffness of the HeadYaw Joint, rises to
# 0.8, then goes back to zero.
pNames          = "HeadYaw"
pStiffnessLists = [0.0, 0.8, 0.0]
pTimeLists      = [0.5, 1.0, 1.5]
proxy.stiffnessInterpolation(pNames, pStiffnessLists, pTimeLists)

Like angle interpolation commands, multiple trajectories can be specified in the same command.

# Example showing multiple stiffness trajectories
# Here the stiffness of the HeadYaw Joint, rises to
# 0.5, then goes back to zero, while the HeadPitch
# joint rises to 1.0
pNames          = ["HeadYaw", "HeadPitch"]
pStiffnessLists = [[0.0, 0.5, 0.0], [0.0, 1.0, 0.0]]
pTimeLists      = [[0.5, 1.0, 1.5], [0.5, 1.0, 1.5]]
proxy.stiffnessInterpolation(pNames, pStiffnessLists, pTimeLists)