Idle API¶
NAOqi Motion - Overview | API
Method list¶
-
class
ALMotionProxy
¶
ALMotionProxy::setIdlePostureEnabled
ALMotionProxy::getIdlePostureEnabled
ALMotionProxy::setBreathEnabled
ALMotionProxy::getBreathEnabled
ALMotionProxy::setBreathConfig
ALMotionProxy::getBreathConfig
-
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.
#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; }
#! /usr/bin/env python # -*- encoding: UTF-8 -*- """Example: Use setBreathConfig Method""" import qi import argparse import sys def main(session): """ This example uses the setBreathConfig method. """ # Get the service ALMotion. motion_service = session.service("ALMotion") # Example showing how to set breath config # Fast breathing: 20 Bpm and low Amplitude motion_service.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. On robot or Local Naoqi: use '127.0.0.1'.") parser.add_argument("--port", type=int, default=9559, help="Naoqi port number") args = parser.parse_args() session = qi.Session() try: session.connect("tcp://" + args.ip + ":" + str(args.port)) except RuntimeError: print ("Can't connect to Naoqi at ip \"" + args.ip + "\" on port " + str(args.port) +".\n" "Please check your script arguments. Run with -h option for help.") sys.exit(1) main(session)
- pConfig – An ALValue of the form
-
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.