Idle API

NAOqi Motion - Overview | API


Method list

class ALMotionProxy
void ALMotionProxy::setIdlePostureEnabled(const std::string& pChainName, const bool& pEnable)

Starts or stops idle posture control on a chain.

Parameters:
  • pChainName – The chain name {“Body”, “Legs”, “Arms”, “LArm”, “RArm” or “Head”}.
  • pEnable – Activate or deactivate idle posture control on the desired Chain.
bool ALMotionProxy::getIdlePostureEnabled(const std::string& pChainName)

Gets the status of idle posture control on a chain.

Parameters:
  • pChainName – The chain name {“Body”, “Legs”, “Arms”, “LArm”, “RArm” or “Head”}.
Returns:

true if idle posture control is active on the chain, false otherwise.

void ALMotionProxy::setBreathEnabled(const std::string& pChainName, const bool& pEnable)

Starts or stops breathing animation on a chain.

Parameters:
  • pChainName – The chain name {“Body”, “Legs”, “Arms”, “LArm”, “RArm” or “Head”}.
  • pEnable – Activate or deactivate breathing animation on the desired Chain.
bool ALMotionProxy::getBreathEnabled(const std::string& pChainName)

Gets the status of breathing animation on a chain.

Parameters:
  • pChainName – The chain name {“Body”, “Legs”, “Arms”, “LArm”, “RArm” or “Head”}.
Returns:

true if breathing is started on the chain, false otherwise.

void ALMotionProxy::setBreathConfig(const AL::ALValue& pConfig)

Configures the breathing animation.

Parameters:
  • pConfig – An ALValue of the form [["Bpm", pBpm], ["Amplitude", pAmplitude]]. pBpm is a float between 5 and 30 setting the breathing frequency in beats per minute. pAmplitude is a float between 0 and 1 setting the amplitude of the breathing animation. At high frequencies, only low amplitudes are allowed. Input amplitude may be clipped.

almotion_setBreathConfig.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_setBreathConfig robotIp "
              << "(optional default \"127.0.0.1\")."<< std::endl;
  }
  else {
    robotIp = argv[1];
  }

  AL::ALMotionProxy motion(robotIp);

  // Example showing how to change the breathing configuration
  // Setting a relaxed configuration: 5 breaths per minute at max amplitude
  AL::ALValue breathConfig;
  breathConfig.arraySetSize(2);

  AL::ALValue tmp;
  tmp.arraySetSize(2);
  tmp[0] = "Bpm";
  tmp[1] = 5.0f;
  breathConfig[0] = tmp;

  tmp[0] = "Amplitude";
  tmp[1] = 1.0f;
  breathConfig[1] = tmp;
  motion.setBreathConfig(breathConfig);

  return 0;
}

almotion_setBreathConfig.py

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

import time
import argparse
from naoqi import ALProxy

def main(robotIP, PORT=9559):
    motionProxy = ALProxy("ALMotion", robotIP, PORT)

    # Example showing how to set breath config
    # Fast breathing: 20 Bpm and low Amplitude
    motionProxy.setBreathConfig([['Bpm', 20.0], ['Amplitude', 0.0]])

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--ip", type=str, default="127.0.0.1",
                        help="Robot ip address")
    parser.add_argument("--port", type=int, default=9559,
                        help="Robot port number")

    args = parser.parse_args()
    main(args.ip, args.port)
AL::ALValue ALMotionProxy::getBreathConfig()

This function gets the current breathing configuration.

Returns:An ALValue of the form [["Bpm", bpm], ["Amplitude", amplitude]]. bpm is the breathing frequency in beats per minute. amplitude is the normalized amplitude of the breathing animation, between 0 and 1.