Walk control API

Overview | API | foot planner Tutorial | robot position Tutorial

See also


Method list

class ALMotionProxy
void ALMotionProxy::setWalkTargetVelocity(const float& x, const float& y, const float& theta, const float& frequency)

There are three overload of this function :

Makes NAO walk at the given velocity. This is a non-blocking call.

Parameters:
  • x – Fraction of MaxStepX. Use negative for backwards. [-1.0 to 1.0]
  • y – Fraction of MaxStepY. Use negative for right. [-1.0 to 1.0]
  • theta – Fraction of MaxStepTheta. Use negative for clockwise [-1.0 to 1.0]
  • frequency – Fraction of MaxStepFrequency [0.0 to 1.0]

almotion_setwalktargetvelocity.py

import sys
import time
from naoqi import ALProxy

if (len(sys.argv) < 2):
    print "Usage: 'python motion_setwalktargetveclocity.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)

proxy.stiffnessInterpolation("Body", 1.0, 0.1)
proxy.walkInit()

# Example showing the use of setWalkTargetVelocity
# The parameters are fractions of the maximums
# Here we are asking for full speed forwards
x  = 1.0
y  = 0.0
theta  = 0.0
frequency  = 1.0
proxy.setWalkTargetVelocity(x, y, theta, frequency)
# If we don't send another command, he will walk forever
# Lets make him slow down(step length) and turn after 3 seconds
time.sleep(3)
x = 0.5
theta = 0.6
proxy.setWalkTargetVelocity(x, y, theta, frequency)
# Lets make him slow down(frequency) after 3 seconds
time.sleep(3)
frequency  = 0.5
proxy.setWalkTargetVelocity(x, y, theta, frequency)
# Lets make him stop after 3 seconds
time.sleep(3)
proxy.stopWalk()
# Note that at any time, you can use a walkTo command
# to walk a precise distance. The last command received,
# of velocity or position always wins
void ALMotionProxy::setWalkTargetVelocity(const float& x, const float& y, const float& theta, const float& frequency, const AL::ALValue& feetGaitConfig)

Makes NAO walk at the given velocity. This is a non-blocking call.

Parameters:
  • x – Fraction of MaxStepX. Use negative for backwards. [-1.0 to 1.0]
  • y – Fraction of MaxStepY. Use negative for right. [-1.0 to 1.0]
  • theta – Fraction of MaxStepTheta. Use negative for clockwise [-1.0 to 1.0]
  • frequency – Fraction of MaxStepFrequency [0.0 to 1.0]
  • feetGaitConfig – An ALValue with the custom gait configuration for both feet
void ALMotionProxy::setWalkTargetVelocity(const float& x, const float& y, const float& theta, const float& frequency, const AL::ALValue& leftFootGaitConfig, const AL::ALValue& rightFootGaitConfig)

Makes NAO walk at the given velocity. This is a non-blocking call.

Parameters:
  • x – Fraction of MaxStepX. Use negative for backwards. [-1.0 to 1.0]
  • y – Fraction of MaxStepY. Use negative for right. [-1.0 to 1.0]
  • theta – Fraction of MaxStepTheta. Use negative for clockwise [-1.0 to 1.0]
  • frequency – Fraction of MaxStepFrequency [0.0 to 1.0]
  • leftFootGaitConfig – An ALValue with custom gait configuration for the left foot
  • rightFootGaitConfig – An ALValue with custom gait configuration for the right foot
void ALMotionProxy::walkTo(const float& x, const float& y, const float& theta)

There are four overload of this function :

Makes NAO walk to the given relative Position. This is a blocking call.

Parameters:
  • x – Distance along the X axis in meters.
  • y – Distance along the Y axis in meters.
  • theta – Rotation around the Z axis in radians [-3.1415 to 3.1415].

almotion_walkto.cpp

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

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

  AL::ALMotionProxy motion(pIp);

  motion.setStiffnesses("Body", 1.0f);
  motion.walkInit();

  // Example showing the walkTo command
  // as length of path is less than 0.4m
  // the path will be an SE3 interpolation
  // The units for this command are meters and radians
  float x  = 0.2f;
  float y  = 0.2f;
  // pi/2 anti-clockwise (90 degrees)
  float theta = 1.5709f;
  motion.walkTo(x, y, theta);
  // Will block until walk Task is finished

  // Example showing the walkTo command
  // as length of path is more than 0.4m
  // the path will be follow a dubins curve
  // The units for this command are meters and radians
  x  = -0.1f;
  y  = -0.7f;
  theta  = 0.0f;
  motion.walkTo(x, y, theta);

  return 0;
}

almotion_walkto.py

import sys
import math
from naoqi import ALProxy

if (len(sys.argv) < 2):
    print "Usage: 'python motion_walkto.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)

proxy.stiffnessInterpolation("Body", 1.0, 0.1)
proxy.walkInit()

# Example showing the walkTo command 
# The units for this command are meters and radians 
x  = 0.2 
y  = 0.2 
theta  = math.pi/2
proxy.walkTo(x, y, theta) 
# Will block until walk Task is finished

########
# NOTE #
########
# If walkTo() method does nothing on the robot,
# please refer to special walk protection in the
# setWalkTargetVelocity() method description below.
void ALMotionProxy::walkTo(const float& x, const float& y, const float& theta, const AL::ALValue& feetGaitConfig)

Makes NAO walk to the given relative Position with custom gait parmaters.

Parameters:
  • x – Distance along the X axis in meters.
  • y – Distance along the Y axis in meters.
  • theta – Rotation around the Z axis in radians [-3.1415 to 3.1415].
  • feetGaitConfig – An ALValue with the custom gait configuration for both feet.
void ALMotionProxy::walkTo(const AL::ALValue& controlPoint)

Makes NAO walk to the given relative Position. This is a blocking call.

Parameters:
  • controlPoint – An ALValue with all the control point [[x1,y1,theta1], ..., [xN,yN,thetaN]
void ALMotionProxy::walkTo(const AL::ALValue& controlPoint, const AL::ALValue& feetGaitConfig)

Makes NAO walk to the given relative Position. This is a blocking call.

Parameters:
  • controlPoint – An ALValue with all the control point [[x1,y1,theta1], ..., [xN,yN,thetaN]
  • feetGaitConfig – An ALValue with the custom gait configuration for both feet
void ALMotionProxy::stepTo(const std::string& legName, const float& x, const float& y, const float& theta)

Deprecated since version 1.12: Use ALMotionProxy::setFootSteps or ALMotionProxy::setFootStepsWithSpeed instead.

Parameters:
  • legName – name of the leg to move(‘LLeg’or ‘RLeg’)
  • x – Position along X axis of the leg relative to the other Leg in meters. Must be less than MaxStepX
  • y – Position along Y axis of the leg relative to the other Leg in meters. Must be less than MaxStepY
  • theta – Orientation round Z axis of the leg relative to the other leg in radians. Must be less than MaxStepX
void ALMotionProxy::setFootSteps(const std::vector<std::string>& legName, const AL::ALValue& footSteps, const std::vector<float>& timeList, const bool& clearExisting)

Makes NAO do foot step planner. This is a non-blocking call.

Parameters:
  • legName – name of the leg to move(‘LLeg’or ‘RLeg’)
  • footSteps – [x, y, theta], [Position along X/Y, Orientation round Z axis] of the leg relative to the other Leg in [meters, meters, radians]. Must be less than [MaxStepX, MaxStepY, MaxStepTheta]
  • timeList – time list of each foot step
  • clearExisting – Clear existing foot steps.

almotion_setfootsteps.py

import sys
import time
from naoqi import ALProxy

if (len(sys.argv) < 2):
    print "Usage: 'python motion_setfootsteps.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)
    
proxy.setStiffnesses("Body", 1.0)
proxy.walkInit()

# A small step forwards and anti-clockwise with the left foot 
legName  = ["LLeg"]
X        = 0.2
Y        = 0.1
Theta    = 0.3
footSteps = [[X, Y, Theta]]
timeList = [0.6]
clearExisting = False
proxy.setFootSteps(legName, footSteps, timeList, clearExisting)

time.sleep(1.0)

# A small step forwards and anti-clockwise with the left foot 
legName = ["LLeg", "RLeg"]
X       = 0.2
Y       = 0.1
Theta   = 0.3
footSteps = [[X, Y, Theta], [X, -Y, Theta]]
timeList = [0.6, 1.2]
clearExisting = False
proxy.setFootSteps(legName, footSteps, timeList, clearExisting)
void ALMotionProxy::setFootStepsWithSpeed(const std::vector<std::string>& legName, const AL::ALValue& footSteps, const std::vector<float>& fractionMaxSpeed, const bool& clearExisting)

Makes NAO do foot step planner with speed. This is a blocking call.

Parameters:
  • legName – name of the leg to move(‘LLeg’or ‘RLeg’)
  • footSteps – [x, y, theta], [Position along X/Y, Orientation round Z axis] of the leg relative to the other Leg in [meters, meters, radians]. Must be less than [MaxStepX, MaxStepY, MaxStepTheta]
  • fractionMaxSpeed – speed of each foot step. Must be between 0 and 1.
  • clearExisting – Clear existing foot steps.

almotion_setfootstepswithspeed.py

import sys
import time
from naoqi import ALProxy

if (len(sys.argv) < 2):
    print "Usage: 'python motion_setfootstepswithspeed.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)
    
proxy.setStiffnesses("Body", 1.0)
proxy.walkInit()

# A small step forwards and anti-clockwise with the left foot 
legName = ["LLeg"]
X       = 0.2
Y       = 0.1
Theta   = 0.3
footSteps = [[X, Y, Theta]]
fractionMaxSpeed = [1.0]
clearExisting = False
proxy.setFootStepsWithSpeed(legName, footSteps, fractionMaxSpeed, clearExisting)

time.sleep(0.5)

# A small step forwards and anti-clockwise with the left foot 
legName = ["LLeg", "RLeg"]
X       = 0.2
Y       = 0.1
Theta   = 0.3
footSteps = [[X, Y, Theta], [X, -Y, Theta]]
fractionMaxSpeed = [1.0, 1.0]
clearExisting = False
proxy.setFootStepsWithSpeed(legName, footSteps, fractionMaxSpeed, clearExisting)
AL::ALValue ALMotionProxy::getFootSteps()

Get the actual foot steps vector. This is a non-blocking call.

Returns:An ALValue containing three vector with
[
  [The actual position of the left and right foot steps in world frame]
  [The unChangeable foot steps]
  [The changeable foot steps]
]

In More details

[
  [
    [(float) LFootWorld_X, (float) LFootWorld_Y, (float) LFootWorld_Theta],
    [(float) RFootWorld_X, (float) RFootWorld_Y, (float) RFootWorld_Theta]
  ]
  [
    [(std::string) LegName, (float) Time, [(float) Move_X, (float) Move_Y, (float) Move_Y],
    [...],
    [(std::string) LegName, (float) Time, [(float) Move_X, (float) Move_Y, (float) Move_Y]
  ]
  [
    [(std::string) LegName, (float) Time, [(float) Move_X, (float) Move_Y, (float) Move_Y],
    [...],
    [(std::string) LegName, (float) Time, [(float) Move_X, (float) Move_Y, (float) Move_Y]
  ]
]

Each move of foot step is relative to the previous location of the opposite foot step. For example, a foot step move of LFoot will be relative to the last position of the RFoot.

If you use setFootSteps or setFootStepsWithSpeed with clearExisting parmater equal true, walk engine execute unchangeable foot step and remove the other.

almotion_getfootsteps.py

import sys
import time
from naoqi import ALProxy

if (len(sys.argv) < 2):
    print "Usage: 'python motion_getfootsteps.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)

#####################################
# A small example using getFootSteps
#####################################

# Initialize the walk
proxy.walkInit()

# First call of walk API
# with post prefix to not be bloquing here.
proxy.post.walkTo(0.3, 0.0, 0.5)

# wait that the walk process start running
time.sleep(0.1)

# get the foot steps vector
footSteps = proxy.getFootSteps()

# print the result
leftFootWorldPosition = footSteps[0][0]
print "leftFootWorldPosition: " , leftFootWorldPosition
rightFootWorldPosition = footSteps[0][1]
print "rightFootWorldPosition: " , rightFootWorldPosition

footStepsUnchangeable = footSteps[1]
print "Unchangeable: " , footStepsUnchangeable

footStepsChangeable   = footSteps[2]
print "Changeable: " , footStepsChangeable
void ALMotionProxy::walkInit()

Initialize the walk process. Check the robot pose and take a right posture.This is blocking called.

almotion_walkinit.cpp

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

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

  AL::ALMotionProxy motion(pIp);

  std::vector<float> stiffnesses = motion.getStiffnesses("Body");
  if (stiffnesses[0] < 0.5f) {
    std::cerr << "Warning: this example will have no effect. "
              << "Robot must be stiff and standing." << std::endl;
    return 1;
  }

  // Example showing how Initialize walk process.
  motion.walkInit();

  return 0;
}

almotion_walkinit.py

import sys
from naoqi import ALProxy

if (len(sys.argv) < 2):
    print "Usage: 'python motion_walkinit.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)

proxy.stiffnessInterpolation("Body", 1.0, 0.1)

# Example showing how Initialize walk process. 
proxy.walkInit()
void ALMotionProxy::waitUntilWalkIsFinished()

Waits until the WalkTask is finished: This method can be used to block your script/code execution until the walk task is totally finished.

almotion_waituntilwalkisfinished.cpp

#include <iostream>
#include <alproxies/almotionproxy.h>
#include <qi/os.hpp>

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

  AL::ALMotionProxy motion(pIp);

  std::vector<float> stiffnesses = motion.getStiffnesses("Body");
  if (stiffnesses[0] < 0.5f) {
    std::cerr << "Warning: this example will have no effect. "
              << "Robot must be stiff and standing." << std::endl;
    return 1;
  }

  // Example showing how to use waitUntilWalkIsFinished.
  // Start a walk
  float x = 0.10f;
  float y = 0.0f;
  float theta = 0.0f;
  motion.walkTo(x, y, theta);

  // Wait for it to finish
  motion.waitUntilWalkIsFinished();
  // Then do something else

  return 0;
}

almotion_waituntilwalkisfinished.py

import sys
from naoqi import ALProxy

if (len(sys.argv) < 2):
    print "Usage: 'python motion_waituntilwalkisfinished.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)

proxy.stiffnessInterpolation("Body", 1.0, 0.1)
proxy.walkInit()

# Example showing how to use waitUntilWalkIsFinished. 
 
# Start a walk 
x = 0.2 
y = 0.0 
theta = 0.0 
proxy.post.walkTo(x, y, theta) 
 
# Wait for it to finish  
proxy.waitUntilWalkIsFinished()
 
# Then do something else
print "Walk is finished"
bool ALMotionProxy::walkIsActive()

Return True if Walk is Active.

Returns:

almotion_walkisactive.cpp

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

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

  AL::ALMotionProxy motion(pIp);

  // Example showing how to use walk is active.
  bool walkIsActive = motion.walkIsActive();

  std::cout << "Walk is active: " << walkIsActive << std::endl;

  return 0;
}

almotion_walkisactive.py

import sys
import time
from naoqi import ALProxy

if (len(sys.argv) < 2):
    print "Usage: 'python motion_walkisactive.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)

proxy.stiffnessInterpolation("Body", 1.0, 0.1)
proxy.walkInit()

# Example showing how to use walk is active. 
# start a 0.2 meter walk 
proxy.post.walkTo(0.2, 0.0, 0.0)

while proxy.walkIsActive(): 
    # do something
    print "Walk is active"

# sleep a little 
time.sleep(1) 

# when finished do something else
void ALMotionProxy::stopWalk()

Stop Walk task at next double support: This method will end the walk task less brutally than killWalk but more quickly than setWalkTargetVelocity(0.0, 0.0, 0.0, pFrequency).

AL::ALValue ALMotionProxy::getFootGaitConfig(const std::string& config)

Gets the foot Gait config (“MaxStepX”, “MaxStepY”, “MaxStepTheta”, “MaxStepFrequency”, “StepHeight”, “TorsoWx”, “TorsoWy”)

Parameters:
  • config – a string should be “Max”, “Min”, “Default”
Returns:

An ALValue with the following form

[ ["MaxStepX", value],
  ["MaxStepY", value],
  ["MaxStepTheta", value],
  ["MaxStepFrequency", value],
  ["StepHeight", value],
  ["TorsoWx", value],
  ["TorsoWy", value]
]

std::vector<float> ALMotionProxy::getRobotPosition(const bool& useSensors)

Gets the World Absolute Robot Position.

Parameters:
  • useSensors – If true, use the sensor values
Returns:

A vector containing the World Absolute Robot Position. (Absolute Position X, Absolute Position Y, Absolute Angle Z)

almotion_getrobotposition.cpp

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

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

  AL::ALMotionProxy motion(pIp);

  // Example showing how to get a simplified robot position in world.
  bool useSensorValues = false;
  std::vector<float> result = motion.getRobotPosition(useSensorValues);

  std::cout << "Robot position is: " << result << std::endl;

  return 0;
}

almotion_getrobotposition.py

import sys
from naoqi import ALProxy
import almath

if (len(sys.argv) < 2):
    print "Usage: 'python motion_getrobotposition.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)
    
proxy.setStiffnesses("Body", 1.0)
proxy.walkInit()

# Example showing how to get a simplified robot position in world. 
useSensorValues = False 
result = proxy.getRobotPosition(useSensorValues) 
print "Robot Position", result

# Example showing how to use this information to know the robot's diplacement. 
useSensorValues = False 
initRobotPosition = almath.Pose2D(almath.vectorFloat(proxy.getRobotPosition(useSensorValues))) 

# Make the robot walk
proxy.walkTo(0.1,0.0,0.2)

endRobotPosition = almath.Pose2D(almath.vectorFloat(proxy.getRobotPosition(useSensorValues))) 

# Compute robot's' displacement
robotMove = almath.pose2DInverse(initRobotPosition)*endRobotPosition
print "Robot Move :", robotMove
std::vector<float> ALMotionProxy::getNextRobotPosition()

Gets the World Absolute next Robot Position.

When no walk process active, getNextRobotPosition() = getRobotPosition().

Else getNextRobotPosition return the position of the robot after the unchangeable foot steps.

Returns:A vector containing the World Absolute next Robot position.(Absolute Position X, Absolute Position Y, Absolute Angle Z)

almotion_getnextrobotposition.cpp

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

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

  AL::ALMotionProxy motion(pIp);

  // Example showing how to get a simplified next robot position in world.
  std::vector<float> result = motion.getNextRobotPosition();

  std::cout << "Next robot position is: " << result << std::endl;

  return 0;
}

almotion_getnextrobotposition.py

import sys
import time
from naoqi import ALProxy
import almath as m #python's wrapping of almath

if (len(sys.argv) < 2):
    print "Usage: 'python motion_getnextrobotposition.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)

proxy.setStiffnesses("Body", 1.0)
proxy.walkInit()

# Example showing how to get a simplified robot position in world. 
result = proxy.getNextRobotPosition() 
print "Next Robot Position", result

# Example showing how to use this information to know the robot's diplacement
# during the walk process.

# Make the robot walk
proxy.post.walkTo(0.6,0.0,0.5)  #No blocking due to post called
time.sleep(1.0)
initRobotPosition = m.Pose2D(m.vectorFloat(proxy.getNextRobotPosition())) 

# Make the robot walk
proxy.walkTo(0.1,0.0,0.2)

endRobotPosition = m.Pose2D(m.vectorFloat(proxy.getNextRobotPosition())) 

# Compute robot's' displacement
robotMove = m.pose2DInverse(initRobotPosition)*endRobotPosition
print "Robot Move :", robotMove
std::vector<float> ALMotionProxy::getRobotVelocity()

Gets the World Absolute Robot Velocity.

Returns:A vector containing the World Absolute Robot Velocity. (Absolute Velocity Translation X [m.s-1], Absolute Velocity Translation Y[m.s-1], Absolute Velocity Rotation WZ [rd.s-1])

almotion_getrobotvelocity.cpp

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

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

  AL::ALMotionProxy motion(pIp);

  // Example showing how to get a simplified robot velocity in world.
  std::vector<float> result = motion.getRobotVelocity();

  std::cout << "Robot velocity is: " << result << std::endl;

  return 0;
}

almotion_getrobotvelocity.py

import sys
from naoqi import ALProxy

if (len(sys.argv) < 2):
    print "Usage: 'python motion_getrobotvelocity.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 simplified robot velocity in world. 
result = proxy.getRobotVelocity() 
print "Robot Velocity", result
AL::ALValue ALMotionProxy::getWalkArmsEnable()

Deprecated since version 1.12: Use ALMotionProxy::getWalkArmsEnabled instead.

Returns:True Arm Motions are controlled by the Walk Task.

almotion_getwalkarmsenable.cpp

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

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

  AL::ALMotionProxy motion(pIp);

  // Example showing how to get the enabled flags for the arms
  AL::ALValue result = motion.getWalkArmsEnable();
  std::cout << "LeftArmEnabled: " << result[0] << std::endl;
  std::cout << "RightArmEnabled: " << result[1] << std::endl;

  return 0;
}

almotion_getwalkarmsenable.py

import sys
from naoqi import ALProxy

if (len(sys.argv) < 2):
    print "Usage: 'python motion_getwalkarmsenable.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 enabled flags for the arms 
result = proxy.getWalkArmsEnable() 
print 'LeftArmEnabled: ', result[0] 
print 'RightArmEnabled: ', result[1]
void ALMotionProxy::setWalkArmsEnable(const bool& leftArmEnable, const bool& rightArmEnable)

Deprecated since version 1.12: Use ALMotionProxy::setWalkArmsEnabled instead.

Parameters:
  • leftArmEnable – if true Left Arm motions are controlled by the Walk Task
  • rightArmEnable – if true Right Arm mMotions are controlled by the Walk Task

almotion_setwalkarmsenable.py

import sys
import time
from naoqi import ALProxy

if (len(sys.argv) < 2):
    print "Usage: 'python motion_setwalkarmsenable.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)
    
proxy.stiffnessInterpolation("Body", 1.0, 0.1)
proxy.walkInit()

x          = 0.6
y          = 0.0
theta      = 0.0
frequency  = 1.0
proxy.setWalkTargetVelocity(x, y, theta, frequency)

time.sleep(1.0)

# Example showing how to disable left arm motions during a walk
leftArmEnable  = False
rightArmEnable  = True
proxy.setWalkArmsEnable(leftArmEnable, rightArmEnable)
print "Disabled left arm"

# disable also right arm motion after 1 seconds
time.sleep(1.0)
rightArmEnable  = False
proxy.setWalkArmsEnable(leftArmEnable, rightArmEnable)
print "Disabled right arm"

time.sleep(1.0)

proxy.stopWalk()

leftArmEnable  = True
rightArmEnable  = True
proxy.setWalkArmsEnable(leftArmEnable, rightArmEnable)
AL::ALValue ALMotionProxy::getWalkArmsEnabled()

Gets if Arms Motions are enabled during the Walk Process.

Returns:True Arm Motions are controlled by the Walk Task.
void ALMotionProxy::setWalkArmsEnabled(const bool& leftArmEnable, const bool& rightArmEnable)

Sets if Arms Motions are enabled during the Walk Process.

Parameters:
  • leftArmEnable – if true Left Arm motions are controlled by the Walk Task
  • rightArmEnable – if true Right Arm mMotions are controlled by the Walk Task