Overview | API
See also
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)
{
if (argc < 2) {
std::cerr << "Usage: motion_gettasklist pIp"
<< std::endl;
return 1;
}
const std::string pIp = argv[1];
AL::ALMotionProxy motion(pIp);
// 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;
}
import sys
import time
from naoqi import ALProxy
if (len(sys.argv) < 2):
print "Usage: 'python motion_gettasklist.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("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
proxy.post.angleInterpolation(names, angleLists, timeList, isAbsolute)
time.sleep(0.1)
print 'Tasklist', proxy.getTaskList()
time.sleep(2.0)
proxy.setStiffnesses("Head", 0.0)
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)
{
if (argc < 2) {
std::cerr << "Usage: motion_areresourcesavailable pIp"
<< std::endl;
return 1;
}
const std::string pIp = argv[1];
AL::ALMotionProxy motion(pIp);
// 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
import sys
import time
from naoqi import ALProxy
if (len(sys.argv) < 2):
print "Usage: 'python motion_areresourcesavailable.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("Head", 1.0)
# Example showing how to use areResourcesAvailable
# We will create a task first, so that we see a result
name = "HeadYaw"
proxy.post.angleInterpolation(name, 1.0, 1.0, True)
time.sleep(0.1)
print "Are " + name + " resources available? " + str(proxy.areResourcesAvailable([name]))
time.sleep(1.0)
proxy.setStiffnesses("Head", 0.0)
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)
{
if (argc < 2) {
std::cerr << "Usage: motion_killtask pIp"
<< std::endl;
return 1;
}
const std::string pIp = argv[1];
AL::ALMotionProxy motion(pIp);
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;
}
import sys
import time
from naoqi import ALProxy
from naoqi import motion
if (len(sys.argv) < 2):
print "Usage: 'python motion_killtask.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("Head", 1.0)
# This function is useful to kill motion Task
# To see the current motionTask please use getTaskList() function
proxy.post.angleInterpolation('HeadYaw', 90*motion.TO_RAD, 10, True)
time.sleep(3)
TaskList = proxy.getTaskList()
uiMotion = TaskList[0][1]
proxy.killTask(uiMotion)
proxy.setStiffnesses("Head", 0.0)
Kills all tasks that use any of the resources given. Only motion API’s‘ blocking call takes resources and can be killed. Use getJointNames("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)
{
if (argc < 2) {
std::cerr << "Usage: motion_killtaskusingresources pIp"
<< std::endl;
return 1;
}
const std::string pIp = argv[1];
AL::ALMotionProxy motion(pIp);
// 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
import sys
import time
from naoqi import ALProxy
if (len(sys.argv) < 2):
print "Usage: 'python motion_killtasksusingresources.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("Head", 1.0)
# Example showing how to killTasksUsingResources
# We will create a task first, so that we see a result
name = "HeadYaw"
proxy.post.angleInterpolation(name, 1.0, 1.0, True)
time.sleep(0.5)
proxy.killTasksUsingResources([name])
proxy.setStiffnesses("Head", 0.0)
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.
#include <iostream>
#include <alproxies/almotionproxy.h>
int main(int argc, char **argv)
{
if (argc < 2) {
std::cerr << "Usage: motion_killwalk pIp"
<< std::endl;
return 1;
}
const std::string pIp = argv[1];
AL::ALMotionProxy motion(pIp);
// Example showing how to use Emergency Stop on Walk task.
motion.killWalk();
std::cout << "Killed walk." << std::endl;
return 0;
}
import sys
import time
from naoqi import ALProxy
if (len(sys.argv) < 2):
print "Usage: 'python motion_killwalk.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()
proxy.post.walkTo(0.20, 0.0, 0.0)
time.sleep(0.5)
# End the walk suddenly (around 20ms)
proxy.killWalk()
Kills all tasks.
#include <iostream>
#include <alproxies/almotionproxy.h>
int main(int argc, char **argv)
{
if (argc < 2) {
std::cerr << "Usage: motion_killall pIp"
<< std::endl;
return 1;
}
const std::string pIp = argv[1];
AL::ALMotionProxy motion(pIp);
// Example showing how to kill all the tasks.
motion.killAll();
std::cout << "All tasks killed." << std::endl;
return 0;
}
import sys
from naoqi import ALProxy
if (len(sys.argv) < 2):
print "Usage: 'python motion_killall.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 kill all the tasks.
proxy.killAll()
print "All tasks killed"