General tools API

Overview | API

See also


Method list

class ALMotionProxy
std::vector<std::string> ALMotionProxy::getJointNames(const std::string& name)

Gets the names of all the joints in the collection.

Parameters:
  • name – Name of a chain, “Body”, “BodyJoints” or “BodyActuators”.
Returns:

Vector of strings, one for each joint in the collection

almotion_getjointnames.cpp

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

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

  AL::ALMotionProxy motion(pIp);

  // Example showing how to get the names of all the joints in the body.
  std::vector<std::string> bodyNames = motion.getJointNames("Body");
  std::cout << "All joints in Body: " << std::endl;
  std::cout << bodyNames << std::endl;

  // Example showing how to get the names of all the joints in the left leg.
  std::vector<std::string> leftLegJointNames = motion.getJointNames("LLeg");
  std::cout << "All joints in LLeg: " << std::endl;
  std::cout << leftLegJointNames << std::endl;

  return 0;
}

almotion_getjointnames.py

import sys
from naoqi import ALProxy

if (len(sys.argv) < 2):
    print "Usage: 'python motion_getjointnames.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 names of all the joints in the body. 
bodyNames = proxy.getJointNames("Body")
print "Body: " + str(bodyNames)

# Example showing how to get the names of all the joints in the left leg. 
leftLegJointNames = proxy.getJointNames("LLeg")
print "LLed: " + str(bodyNames)
std::vector<std::string> ALMotionProxy::getSensorNames()

Gets the list of sensors supported on your robot.

Returns:Vector of sensor names

almotion_getsensornames.cpp

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

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

  AL::ALMotionProxy motion(pIp);

  // Gets the list of sensors supported on your robot.
  std::vector<std::string> sensorList = motion.getSensorNames();
  std::cout << "Sensors: " << std::endl;
  for (unsigned int i=0; i<sensorList.size(); i++)
  {
     std::cout << sensorList.at(i) << std::endl;
  }

  return 0;
}

almotion_getsensornames.py

import sys
from naoqi import ALProxy

if (len(sys.argv) < 2):
    print "Usage: 'python motion_getsensornames.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 list of the sensors 
sensorList = proxy.getSensorNames() 
for sensor in sensorList: 
    print sensor
AL::ALValue ALMotionProxy::getLimits(const std::string& name)

Get the minAngle (rad), maxAngle (rad), and maxVelocity (rad.s-1) for a given joint or actuator in the body.

Parameters:
  • name – Name of a joint, chain, “Body”, “BodyJoints” or “BodyActuators”.
Returns:

Array of ALValue arrays containing the minAngle, maxAngle and maxVelocity for all the joints specified.

almotion_getlimits.cpp

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

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

  AL::ALMotionProxy motion(pIp);

  // Example showing how to get the limits for the whole body
  std::string name = "Body";
  std::vector<std::string> jointNames = motion.getJointNames(name);
  AL::ALValue limits = motion.getLimits(name);
  for (unsigned int i=0; i<limits.getSize(); i++)
  {
    std::cout << " Joint name " << jointNames[i]
              << " MinAngle " << limits[i][0] << " rad"
              << " MaxAngle " << limits[i][1] << " rad"
              << " MaxChange " << limits[i][2] << " rad.s-1"
              << std::endl;
  }

  return 0;
}

almotion_getlimits.py

import sys
from naoqi import ALProxy

if (len(sys.argv) < 2):
    print "Usage: 'python motion_getlimits.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 limits for the whole body 
name = "Body" 
limits = proxy.getLimits(name) 
jointNames = proxy.getJointNames(name) 
for i in range(0,len(limits)): 
  print jointNames[i] + ":"
  print "MinAngle", limits[i][0], "MaxAngle", limits[i][1],"MaxVelocity", limits[i][2]
AL::ALValue ALMotionProxy::getRobotConfig()

Get the robot configuration. Get the minAngle (rad), maxAngle (rad), and maxVelocity (rad.s-1) for a given joint or actuator in the body.

Returns:ALValue arrays containing the robot parameter names and the robot parameter values.

almotion_getrobotconfig.cpp

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

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

  AL::ALMotionProxy motion(pIp);

  // Example showing how to get the robot config
  AL::ALValue robotConfig = motion.getRobotConfig();
  for (unsigned int i=0; i<robotConfig[0].getSize(); i++)
  {
    std::cout << robotConfig[0][i] << ": " << robotConfig[1][i] << std::endl;
  }

  return 0;
}

almotion_getrobotconfig.py

import sys
from naoqi import ALProxy

if (len(sys.argv) < 2):
    print "Usage: 'python motion_getrobotconfig.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 robot config 
robotConfig = proxy.getRobotConfig() 
for i in range(len(robotConfig[0])): 
    print robotConfig[0][i], ": ", robotConfig[1][i] 
 
# "Model Type"   : "naoH25", "naoH21", "naoT14" or "naoT2".
# "Head Version" : "VERSION_32" or "VERSION_33" or "VERSION_40".
# "Body Version" : "VERSION_32" or "VERSION_33" or "VERSION_40".
# "Laser"        : True or False.
# "Legs"         : True or False.
# "Arms"         : True or False.
# "Extended Arms": True or False.
# "Hands"        : True or False.
# "Arm Version"  : "VERSION_32" or "VERSION_33" or "VERSION_40".
std::string ALMotionProxy::getSummary()

Returns a string representation of the Model’s state

Returns:A formated string

almotion_getsummary.cpp

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

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

  AL::ALMotionProxy motion(pIp);

  // Example showing how to get a summary of Nao's state
  std::cout << motion.getSummary() << std::endl;

  return 0;
}

almotion_getsummary.py

import sys
from naoqi import ALProxy

if (len(sys.argv) < 2):
    print "Usage: 'python motion_getsummary.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 a summary of Nao's state
print proxy.getSummary()
float ALMotionProxy::getMass(const std::string& pName)

Gets the mass of a joint, chain, “Body” or “BodyJoints”.

Parameters:
  • pName – Name of the body which we want the mass. “Body”, “BodyJoints” and “Com” give the total mass of NAO. For the chain, it gives the total mass of the chain.
Returns:

The mass in kg.

almotion_getmass.cpp

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

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

  AL::ALMotionProxy motion(pIp);

  // Example showing how to get the mass of "HeadYaw".
  std::string pName = "HeadYaw";
  float mass = motion.getMass(pName);

  std::cout << "Mass on " << pName << " is " << mass << std::endl;

  return 0;
}

almotion_getmass.py

import sys
from naoqi import ALProxy

if (len(sys.argv) < 2):
    print "Usage: 'python motion_getmass.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 mass of "HeadYaw". 
pName = "HeadYaw" 
mass = proxy.getMass(pName)
print pName + " mass: " + str(mass)

# Example showing how to get the mass "LLeg" chain. 
pName = "LLeg" 
print "LLeg : ", proxy.getMass(pName) 
 
# It is equivalent to the following script 
pNameList = ["LHipYawPitch", "LHipRoll", "LHipPitch", "LKneePitch", "LAnkleRoll", "LAnklePitch"] 
mass = 0 
for pName in pNameList: 
    mass = mass + proxy.getMass(pName) 
print "LLeg :", mass
std::vector<float> ALMotionProxy::getCOM(const std::string& pName, const int& pSpace, const bool& pUseSensorValues)

Gets the COM of a joint, chain, “Body” or “BodyJoints”.

Parameters:
  • pName – Name of the body which we want the mass. In chain name case, this function give the com of the chain.
  • pSpace – Task space {SPACE_TORSO = 0, SPACE_WORLD = 1, SPACE_NAO = 2}.
  • pUseSensorValues – If true, the sensor values will be used to determine the position.
Returns:

The COM position (meter).

almotion_getcom.cpp

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

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

  AL::ALMotionProxy motion(pIp);

  // Example showing how to get the COM of "HeadYaw".
  std::string pName = "HeadYaw";
  int pSpace = 0; // SPACE_TORSO
  bool pUseSensors = false;
  std::vector<float> pos = motion.getCOM(pName, pSpace, pUseSensors);

  std::cout << pName << " COM position: " << std::endl;
  std::cout << "x: " << pos[0] << "; y: " << pos[1] << "; z: " << pos[2]
            << std::endl;

  return 0;
}

almotion_getcom.py

import sys
from naoqi import ALProxy

if (len(sys.argv) < 2):
    print "Usage: 'python motion_getcom.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 COM position of "HeadYaw". 
pName = "HeadYaw" 
pSpace = 0 # SPACE_TORSO 
pUseSensors = False 
pos = proxy.getCOM(pName, pSpace, pUseSensors) 
print "HeadYaw COM Position: x = ", pos[0], " y:", pos[1], " z:", pos[2]