General tools API

NAOqi Motion - Overview | API


Method list

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

Gets the names of all the joints in the collection.

Parameters:
  • name – Name of a chain, “Body”, “Chains”, “JointActuators”, “Joints” or “Actuators”.
Returns:

Vector of strings, one for each joint in the collection

almotion_getbodynames.cpp

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

int main(int argc, char **argv)
{
  std::string robotIp = "127.0.0.1";

  if (argc < 2) {
    std::cerr << "Usage: almotion_getbodynames robotIp "
              << "(optional default \"127.0.0.1\")."<< std::endl;
  }
  else {
    robotIp = argv[1];
  }

  AL::ALMotionProxy motion(robotIp);

  // Example showing how to get the names of all the joints in the body.
  std::vector<std::string> bodyNames = motion.getBodyNames("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.getBodyNames("LLeg");
  std::cout << "All joints in LLeg: " << std::endl;
  std::cout << leftLegJointNames << std::endl;

  return 0;
}

almotion_getbodynames.py

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

import sys
from naoqi import ALProxy


def main(robotIP):
    PORT = 9559

    try:
        motionProxy = ALProxy("ALMotion", robotIP, 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 = motionProxy.getBodyNames("Body")
    print "Body:"
    print str(bodyNames)
    print ""

    # Example showing how to get the names of all the joints in the left leg.
    leftLegJointNames = motionProxy.getBodyNames("LLeg")
    print "LLeg:"
    print str(leftLegJointNames)


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

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

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

Deprecated since version 1.14: use ALMotionProxy::getBodyNames() instead.

param name:Name of a chain, “Body”, “Chains”, “JointActuators”, “Joints” or “Actuators”.
return:Vector of strings, one for each joint in the collection

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)
{
  std::string robotIp = "127.0.0.1";

  if (argc < 2) {
    std::cerr << "Usage: almotion_getsensornames robotIp "
              << "(optional default \"127.0.0.1\")."<< std::endl;
  }
  else {
    robotIp = argv[1];
  }

  AL::ALMotionProxy motion(robotIp);

  // 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

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

import sys
from naoqi import ALProxy


def main(robotIP):
    PORT = 9559

    try:
        motionProxy = ALProxy("ALMotion", robotIP, 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 = motionProxy.getSensorNames()
    for sensor in sensorList:
        print sensor


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

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

    main(robotIp)
AL::ALValue ALMotionProxy::getLimits(const std::string& name)

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

Parameters:
  • name – Name of a joint, chain, “Body”, “JointActuators”, “Joints” or “Actuators”.
Returns:

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

almotion_getlimits.cpp

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

int main(int argc, char **argv)
{
  std::string robotIp = "127.0.0.1";

  if (argc < 2) {
    std::cerr << "Usage: almotion_getlimits robotIp "
              << "(optional default \"127.0.0.1\")."<< std::endl;
  }
  else {
    robotIp = argv[1];
  }

  AL::ALMotionProxy motion(robotIp);

  // Example showing how to get the limits for the whole body
  std::string name = "Body";
  std::vector<std::string> jointNames = motion.getBodyNames(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"
              << " maxTorque " << limits[i][3] << " N.m"
              << std::endl;
  }

  return 0;
}

almotion_getlimits.py

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

import sys
from naoqi import ALProxy

def main(robotIP):
    PORT = 9559

    try:
        motionProxy = ALProxy("ALMotion", robotIP, 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 = motionProxy.getLimits(name)
    jointNames = motionProxy.getBodyNames(name)
    for i in range(0,len(limits)):
        print jointNames[i] + ":"
        print "minAngle", limits[i][0],\
            "maxAngle", limits[i][1],\
            "maxVelocity", limits[i][2],\
            "maxTorque", limits[i][3]


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

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

    main(robotIp)
AL::ALValue ALMotionProxy::getMotionCycleTime()

Get the motion cycle time in milliseconds.

Returns:ALValue containing the cycle time in milliseconds as an integer.
AL::ALValue ALMotionProxy::getRobotConfig()

Get the robot configuration.

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)
{
  std::string robotIp = "127.0.0.1";

  if (argc < 2) {
    std::cerr << "Usage: almotion_getrobotconfig robotIp "
              << "(optional default \"127.0.0.1\")."<< std::endl;
  }
  else {
    robotIp = argv[1];
  }

  AL::ALMotionProxy motion(robotIp);

  // 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

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

import sys
from naoqi import ALProxy


def main(robotIP):
    PORT = 9559

    try:
        motionProxy = ALProxy("ALMotion", robotIP, 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 = motionProxy.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".
    # Number of Legs : 0 or 2
    # Number of Arms : 0 or 2
    # Number of Hands: 0 or 2


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

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

    main(robotIp)
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)
{
  std::string robotIp = "127.0.0.1";

  if (argc < 2) {
    std::cerr << "Usage: almotion_getsummary robotIp "
              << "(optional default \"127.0.0.1\")."<< std::endl;
  }
  else {
    robotIp = argv[1];
  }

  AL::ALMotionProxy motion(robotIp);

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

  return 0;
}

almotion_getsummary.py

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

import sys
from naoqi import ALProxy


def main(robotIP):
    PORT = 9559

    try:
        motionProxy = ALProxy("ALMotion", robotIP, 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 motionProxy.getSummary()


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

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

    main(robotIp)
float ALMotionProxy::getMass(const std::string& pName)

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

Parameters:
  • pName – Name of the body which we want the mass. “Body”, “Joints” 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)
{
  std::string robotIp = "127.0.0.1";

  if (argc < 2) {
    std::cerr << "Usage: almotion_getmass robotIp "
              << "(optional default \"127.0.0.1\")."<< std::endl;
  }
  else {
    robotIp = argv[1];
  }

  AL::ALMotionProxy motion(robotIp);

  // 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

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

import sys
from naoqi import ALProxy


def main(robotIP):
    PORT = 9559

    try:
        motionProxy = ALProxy("ALMotion", robotIP, 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 = motionProxy.getMass(pName)
    print pName + " mass: " + str(mass)

    # Example showing how to get the mass "LLeg" chain.
    pName = "LLeg"
    print "LLeg mass: ", motionProxy.getMass(pName)

    # It is equivalent to the following script
    pNameList = motionProxy.getBodyNames("LLeg")
    mass = 0.0
    for pName in pNameList:
        jointMass = motionProxy.getMass(pName)
        print pName + " mass: " + str(jointMass)
        mass = mass + jointMass
    print "LLeg mass:", mass


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

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

    main(robotIp)
std::vector<float> ALMotionProxy::getCOM(const std::string& pName, const int& pSpace, const bool& pUseSensorValues)

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

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 {FRAME_TORSO = 0, FRAME_WORLD = 1, FRAME_ROBOT = 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)
{
  std::string robotIp = "127.0.0.1";

  if (argc < 2) {
    std::cerr << "Usage: almotion_getcom robotIp "
              << "(optional default \"127.0.0.1\")."<< std::endl;
  }
  else {
    robotIp = argv[1];
  }

  AL::ALMotionProxy motion(robotIp);

  // Example showing how to get the COM of "HeadYaw".
  std::string pName = "HeadYaw";
  int pSpace = 0; // FRAME_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

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

import sys
from naoqi import ALProxy
import motion

def main(robotIP):
    PORT = 9559

    try:
        motionProxy = ALProxy("ALMotion", robotIP, 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 = motion.FRAME_TORSO
    pUseSensors = False
    pos = motionProxy.getCOM(pName, pSpace, pUseSensors)
    print "HeadYaw COM Position: x = ", pos[0], " y:", pos[1], " z:", pos[2]


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

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

    main(robotIp)
void ALMotionProxy::setMotionConfig(const AL::ALValue& config)

Internal Use.

Parameters:
  • config – Internal: An array of ALValues [i][0]: name, [i][1]: value
void ALMotionProxy::updateTrackerTarget(const float& pTargetPositionWy, const float& pTargetPositionWz, const int& pTimeSinceDetectionMs, const bool& pUseOfWholeBody)

Update the target to follow by the head of NAO.

Parameters:
  • pTargetPositionWy – The target position wy in FRAME_ROBOT
  • pTargetPositionWz – The target position wz in FRAME_ROBOT
  • pTimeSinceDetectionMs – The time in Ms since the target was detected
  • pUseOfWholeBody – If true, the target is follow in Cartesian space by the Head with whole Body constraints.