NAOqi Motion - Overview | API
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 sys
import time
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)
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__":
robotIp = "127.0.0.1"
if len(sys.argv) <= 1:
print "Usage python almotion_advancedcreaterotation.py robotIP (optional default: 127.0.0.1)"
else:
robotIp = sys.argv[1]
main(robotIp)
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 sys
import time
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)
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__":
robotIp = "127.0.0.1"
if len(sys.argv) <= 1:
print "Usage python almotion_areresourcesavailable.py robotIP (optional default: 127.0.0.1)"
else:
robotIp = sys.argv[1]
main(robotIp)
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 sys
import time
from naoqi import ALProxy
import almath
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)
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__":
robotIp = "127.0.0.1"
if len(sys.argv) <= 1:
print "Usage python almotion_killtask.py robotIP (optional default: 127.0.0.1)"
else:
robotIp = sys.argv[1]
main(robotIp)
Kills all tasks that use any of the resources given. Only motion API’s‘ blocking call takes resources and can be killed. Use getBodyNames("Body") to get the list of the available joints for your robot.
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 sys
import time
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)
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__":
robotIp = "127.0.0.1"
if len(sys.argv) <= 1:
print "Usage python almotion_killtasksusingresources.py robotIP (optional default: 127.0.0.1)"
else:
robotIp = sys.argv[1]
main(robotIp)
Emergency Stop on Walk task: This method will end the walk task brutally, without attempting to return to a balanced state. If NAO has one foot in the air, he could easily fall.
Deprecated since version 1.14: use ALMotionProxy::killMove() instead.
Emergency Stop on Move task: This method will end the move task brutally, without attempting to return to a balanced state. If NAO 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 sys
import time
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)
try:
postureProxy = ALProxy("ALRobotPosture", robotIP, PORT)
except Exception, e:
print "Could not create proxy to ALRobotPosture"
print "Error was: ", e
# Send NAO to Pose 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()
if __name__ == "__main__":
robotIp = "127.0.0.1"
if len(sys.argv) <= 1:
print "Usage python almotion_killmove.py robotIP (optional default: 127.0.0.1)"
else:
robotIp = sys.argv[1]
main(robotIp)
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 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 kill all the tasks.
motionProxy.killAll()
print "All tasks killed."
if __name__ == "__main__":
robotIp = "127.0.0.1"
if len(sys.argv) <= 1:
print "Usage python almotion_advancedcreaterotation.py robotIP (optional default: 127.0.0.1)"
else:
robotIp = sys.argv[1]
main(robotIp)