Stiffness control API

Overview | API

See also


Method list

class ALMotionProxy
void ALMotionProxy::stiffnessInterpolation(const AL::ALValue& names, const AL::ALValue& stiffnessLists, const AL::ALValue& timeLists)

Interpolates one or multiple joints to a targeted stiffness or along timed trajectories of stiffness. This is a blocking call.

Parameters:
  • names – Name or names of joints, chains, “Body”, “BodyJoints” or “BodyActuators”.
  • stiffnessLists – An stiffness, list of stiffnesses or list of list of stiffnesses
  • timeLists – A time, list of times or list of list of times.

almotion_stiffnessinterpolation.py

import sys
from naoqi import ALProxy
import time

if (len(sys.argv) < 2):
    print "Usage: 'python motion_stiffnessinterpolation.py IP [PORT]'"
    sys.exit(1)

IP = sys.argv[1]
PORT = 9559
if (len(sys.argv) > 2):
    PORT = sys.argv[2]
try:
    proxy = ALProxy("ALMotion", IP, PORT)
except Exception,e:
    print "Could not create proxy to ALMotion"
    print "Error was: ",e
    sys.exit(1)

# Example showing how to interpolate to maximum stiffness in 1 second
names  = 'Body'
stiffnessLists  = 0.0
timeLists  = 1.0
proxy.stiffnessInterpolation(names, stiffnessLists, timeLists)

time.sleep(1.0)

# Example showing a stiffness trajectory for a single joint
names  = ['HeadYaw']
stiffnessLists  = [0.25,0.5,1.0, 0.0]
timeLists  = [1.0,2.0,3.0, 4.0]
proxy.stiffnessInterpolation(names, stiffnessLists, timeLists)
void ALMotionProxy::setStiffnesses(const AL::ALValue& names, const AL::ALValue& stiffnesses)

Sets the stiffness of one or more joints. This is a non-blocking call.

Parameters:
  • names – Names of joints, chains, “Body”, “BodyJoints” or “BodyActuators”.
  • stiffnesses – One or more stiffnesses between zero and one.

almotion_setstiffnesses.cpp

#include <iostream>
#include <alproxies/almotionproxy.h>

int main(int argc, char **argv)
{
  if (argc < 2) {
    std::cerr << "Usage: motion_setstiffnesses pIp"
              << std::endl;
    return 1;
  }
  const std::string pIp = argv[1];

  AL::ALMotionProxy motion(pIp);

  // Example showing how to set the stiffness to 1.0.
  // Beware, doing this could be dangerous, it is safer to use the
  // stiffnessInterpolation method which takes a duration parameter.
  std::string names  = "Body";
  // If only one parameter is received, this is applied to all joints
  float stiffnesses  = 1.0f;
  motion.setStiffnesses(names, stiffnesses);

  return 0;
}

almotion_setstiffnesses.py

import sys
from naoqi import ALProxy

if (len(sys.argv) < 2):
    print "Usage: 'python motion_setstiffnesses.py IP [PORT]'"
    sys.exit(1)

IP = sys.argv[1]
PORT = 9559
if (len(sys.argv) > 2):
    PORT = sys.argv[2]
try:
    proxy = ALProxy("ALMotion", IP, PORT)
except Exception,e:
    print "Could not create proxy to ALMotion"
    print "Error was: ",e
    sys.exit(1)

# Example showing how to set the stiffness to 1.0.
# Beware, doing this could be dangerous, it is safer to use the 
#   stiffnessInterpolation method which takes a duration parameter.
names  = 'Body'
# If only one parameter is received, this is applied to all joints
stiffnesses  = 1.0
proxy.setStiffnesses(names, stiffnesses)
std::vector<float> ALMotionProxy::getStiffnesses(const AL::ALValue& jointName)

Gets stiffness of a joint or group of joints

Parameters:
  • jointName – Name of the joints, chains, “Body”, “BodyJoints” or “BodyActuators”.
Returns:

One or more stiffnesses. 1.0 indicates maximum stiffness. 0.0 indicated minimum stiffness

almotion_getstiffnesses.cpp

#include <iostream>
#include <alproxies/almotionproxy.h>

int main(int argc, char **argv)
{
  if (argc < 2) {
    std::cerr << "Usage: motion_getstiffnesses pIp"
              << std::endl;
    return 1;
  }
  const std::string pIp = argv[1];

  AL::ALMotionProxy motion(pIp);

  // Example showing how to get the Body stiffnesses
  std::string jointName = "Body";
  std::vector<float> stiffnesses = motion.getStiffnesses(jointName);

  std::cout << jointName << "stiffnesses: " << stiffnesses << std::endl;

  return 0;
}

almotion_getstiffnesses.py

import sys
from naoqi import ALProxy

if (len(sys.argv) < 2):
    print "Usage: 'python motion_getstiffnesses.py IP [PORT]'"
    sys.exit(1)

IP = sys.argv[1]
PORT = 9559
if (len(sys.argv) > 2):
    PORT = sys.argv[2]
try:
    proxy = ALProxy("ALMotion", IP, PORT)
except Exception,e:
    print "Could not create proxy to ALMotion"
    print "Error was: ",e
    sys.exit(1)

# Example showing how to get the Body stiffnesses 
jointName  = "Body" 
stiffnesses = proxy.getStiffnesses(jointName) 
print "Body Stiffnesses", stiffnesses