NAOqi Motion - Overview | API
Deprecated Methods
Gets an ALValue structure describing the tasks in the Task List
Returns: | An ALValue containing an ALValue for each task. The inner ALValue contains: Name, MotionID |
---|
#include <qi/os.hpp>
#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_gettasklist robotIp "
<< "(optional default \"127.0.0.1\")."<< std::endl;
}
else {
robotIp = argv[1];
}
AL::ALMotionProxy motion(robotIp);
// Example showing how to get the current task list
// We will create a task first, so that we see a result
AL::ALValue names = "HeadYaw";
AL::ALValue angleLists = 1.0f;
AL::ALValue timeList = 3.0f;
bool isAbsolute = true;
motion.setStiffnesses(names, 1.0f);
motion.post.angleInterpolation(names, angleLists, timeList, isAbsolute);
qi::os::msleep(100);
std::cout << "Tasklist: " << motion.getTaskList() << std::endl;
qi::os::sleep(3.0f);
motion.setStiffnesses(names, 0.0f);
return 0;
}
# -*- encoding: UTF-8 -*-
import time
import argparse
from naoqi import ALProxy
def main(robotIP, PORT=9559):
motionProxy = ALProxy("ALMotion", robotIP, PORT)
motionProxy.setStiffnesses("Head", 1.0)
# Example showing how to get the current task list
# We will create a task first, so that we see a result
names = "HeadYaw"
angleLists = 1.0
timeList = 3.0
isAbsolute = True
motionProxy.post.angleInterpolation(names, angleLists, timeList, isAbsolute)
time.sleep(0.1)
print 'Tasklist: ', motionProxy.getTaskList()
time.sleep(2.0)
motionProxy.setStiffnesses("Head", 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)
Returns true if all the desired resources are available. Only motion API’s‘ blocking call takes resources.
Parameters: |
|
---|---|
Returns: | True if the resources are available |
almotion_areresourcesavailable.cpp
#include <iostream>
#include <alproxies/almotionproxy.h>
#include <qi/os.hpp>
int main(int argc, char **argv)
{
std::string robotIp = "127.0.0.1";
if (argc < 2) {
std::cerr << "Usage: almotion_areresourcesavailable robotIp "
<< "(optional default \"127.0.0.1\")."<< std::endl;
}
else {
robotIp = argv[1];
}
AL::ALMotionProxy motion(robotIp);
// Setting head stiffness on.
motion.setStiffnesses("Head", 1.0f);
// Example showing how to use areResourcesAvailable
// We will create a task first, so that we see a result
AL::ALValue names = "HeadYaw";
AL::ALValue angleLists = 1.0f;
AL::ALValue timeList = 3.0f;
bool isAbsolute = true;
motion.post.angleInterpolation(names, angleLists, timeList, isAbsolute);
qi::os::msleep(100);
std::cout << "Are resources "<< names << " available?" << std::endl;
std::cout << motion.areResourcesAvailable(AL::ALValue::array(names)) << std::endl;
qi::os::sleep(3.0f);
// Setting head stiffness off.
motion.setStiffnesses("Head", 0.0f);
return 0;
}
almotion_areResourcesAvailable.py
# -*- encoding: UTF-8 -*-
import time
import argparse
from naoqi import ALProxy
def main(robotIP, PORT = 9559):
motionProxy = ALProxy("ALMotion", robotIP, PORT)
motionProxy.setStiffnesses("Head", 1.0)
# Example showing how to use areResourcesAvailable
# We will create a task first, so that we see a result
name = "HeadYaw"
motionProxy.post.angleInterpolation(name, 1.0, 1.0, True)
time.sleep(0.1)
print "Are " + name + " resources available? " + str(motionProxy.areResourcesAvailable([name]))
time.sleep(1.0)
motionProxy.setStiffnesses("Head", 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)
Kills a motion task.
Parameters: |
|
---|---|
Returns: | Return true if the specified motionTaskId has been killed. |
#include <qi/os.hpp>
#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_killtask robotIp "
<< "(optional default \"127.0.0.1\")."<< std::endl;
}
else {
robotIp = argv[1];
}
AL::ALMotionProxy motion(robotIp);
AL::ALValue names = "HeadYaw";
AL::ALValue angleLists = 1.0f;
AL::ALValue timeLists = 10.0f;
bool isAbsolute = true;
motion.setStiffnesses(names, 1.0f);
motion.post.angleInterpolation(names, angleLists, timeLists, isAbsolute);
qi::os::msleep(3000);
std::cout << "Killing task..." << std::endl;
AL::ALValue TaskList = motion.getTaskList();
int uiMotion = TaskList[0][1];
motion.killTask(uiMotion);
std::cout << "Task killed." << std::endl;
motion.setStiffnesses(names, 0.0f);
return 0;
}
# -*- encoding: UTF-8 -*-
import almath
import time
import argparse
from naoqi import ALProxy
def main(robotIP, PORT=9559):
motionProxy = ALProxy("ALMotion", robotIP, PORT)
motionProxy.setStiffnesses("Head", 1.0)
# This function is useful to kill motion Task
# To see the current motionTask please use getTaskList() function
motionProxy.post.angleInterpolation('HeadYaw', 90*almath.TO_RAD, 10, True)
time.sleep(3)
taskList = motionProxy.getTaskList()
uiMotion = taskList[0][1]
motionProxy.killTask(uiMotion)
motionProxy.setStiffnesses("Head", 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)
Kills all tasks that use any of the resources given. Only motion API’s‘ blocking call takes resources and can be killed.
Parameters: |
|
---|
almotion_killtasksusingresources.cpp
#include <qi/os.hpp>
#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_killtasksusingresources robotIp "
<< "(optional default \"127.0.0.1\")."<< std::endl;
}
else {
robotIp = argv[1];
}
AL::ALMotionProxy motion(robotIp);
// Example showing how to killTasksUsingResources
// We will create a task first, so that we see a result
AL::ALValue names = "HeadYaw";
AL::ALValue angleLists = 1.0f;
AL::ALValue timeList = 3.0f;
bool isAbsolute = true;
motion.setStiffnesses(names, 1.0f);
motion.post.angleInterpolation(names, angleLists, timeList, isAbsolute);
qi::os::msleep(1000);
std::cout << "Killing task..." << std::endl;
motion.killTasksUsingResources(AL::ALValue::array(names));
std::cout << "Task killed." << std::endl;
motion.setStiffnesses(names, 0.0f);
return 0;
}
almotion_killTasksUsingResources.py
# -*- encoding: UTF-8 -*-
import time
import argparse
from naoqi import ALProxy
def main(robotIP, PORT=9559):
motionProxy = ALProxy("ALMotion", robotIP, PORT)
motionProxy.setStiffnesses("Head", 1.0)
# Example showing how to killTasksUsingResources
# We will create a task first, so that we see a result
name = "HeadYaw"
motionProxy.post.angleInterpolation(name, 1.0, 1.0, True)
time.sleep(0.5)
motionProxy.killTasksUsingResources([name])
motionProxy.setStiffnesses("Head", 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)
Deprecated since version 1.14: use ALMotionProxy::killMove() instead.
Emergency Stop on Walk task: this method will end the walk task brutally, without attempting to return to a balanced state. If the robot has one foot in the air, he could easily fall.
Emergency Stop on Move task: this method will end the move task brutally, without attempting to return to a balanced state. If the robot has one foot in the air, he could easily fall.
#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_killmove robotIp "
<< "(optional default \"127.0.0.1\")."<< std::endl;
}
else {
robotIp = argv[1];
}
AL::ALMotionProxy motion(robotIp);
// Example showing how to use Emergency Stop on Move task.
motion.killMove();
std::cout << "Killed move." << std::endl;
return 0;
}
# -*- encoding: UTF-8 -*-
import time
import argparse
from naoqi import ALProxy
def main(robotIP, PORT=9559):
motionProxy = ALProxy("ALMotion", robotIP, PORT)
postureProxy = ALProxy("ALRobotPosture", robotIP, PORT)
# Wake up robot
motionProxy.wakeUp()
# Send robot to Stand Init
postureProxy.goToPosture("StandInit", 0.5)
motionProxy.post.moveTo(0.5, 0.0, 0.0)
time.sleep(3.0)
# End the walk suddenly (around 20ms)
motionProxy.killMove()
# Go to rest position
motionProxy.rest()
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)
Kills all tasks.
#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_killall robotIp "
<< "(optional default \"127.0.0.1\")."<< std::endl;
}
else {
robotIp = argv[1];
}
AL::ALMotionProxy motion(robotIp);
// Example showing how to kill all the tasks.
motion.killAll();
std::cout << "All tasks killed." << std::endl;
return 0;
}
# -*- encoding: UTF-8 -*-
import argparse
from naoqi import ALProxy
def main(robotIP, PORT=9559):
motionProxy = ALProxy("ALMotion", robotIP, PORT)
# Example showing how to kill all the tasks.
motionProxy.killAll()
print "All tasks killed."
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)