NAOqi Motion - Overview | API
The robot wakes up: sets Motor on and, if needed, goes to initial position. For example, H25 or H21 sets the Stiffness on and keeps is current position.
# -*- encoding: UTF-8 -*-
'''Wake up: sets Motor on and, if needed, goes to initial position'''
import sys
from naoqi import ALProxy
def main(robotIP):
try:
motionProxy = ALProxy("ALMotion", robotIP, 9559)
except Exception, e:
print "Could not create proxy to ALMotion"
print "Error was: ", e
motionProxy.wakeUp()
# print motion state
print motionProxy.getSummary()
if __name__ == "__main__":
robotIp = "127.0.0.1"
if len(sys.argv) <= 1:
print "Usage python almotion_wake_up.py robotIP (optional default: 127.0.0.1)"
else:
robotIp = sys.argv[1]
main(robotIp)
The robot rests: goes to a relax and safe position and sets Motor off. For example, H25 or H21 goes to the Crouch posture and sets the Stiffness off.
# -*- encoding: UTF-8 -*-
'''Rest: goes to a relax and safe position and sets Motor off'''
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
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.rest()
# print motion state
print motionProxy.getSummary()
if __name__ == "__main__":
robotIp = "127.0.0.1"
if len(sys.argv) <= 1:
print "Usage python almotion_rest.py robotIP (optional default: 127.0.0.1)"
else:
robotIp = sys.argv[1]
main(robotIp)
Interpolates one or multiple joints to a targeted stiffness or along timed trajectories of stiffness. This is a blocking call.
Parameters: |
|
---|
almotion_stiffnessinterpolation.py
# -*- encoding: UTF-8 -*-
import sys
from naoqi import ALProxy
import time
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 interpolate to maximum stiffness in 1 second
names = 'Body'
stiffnessLists = 0.0
timeLists = 1.0
motionProxy.stiffnessInterpolation(names, stiffnessLists, timeLists)
time.sleep(1.0)
# Example showing a stiffness trajectory for a single joint
names = ['HeadYaw']
stiffnessLists = [0.25, 0.5, 1.0, 0.0]
timeLists = [1.0, 2.0, 3.0, 4.0]
motionProxy.stiffnessInterpolation(names, stiffnessLists, timeLists)
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)
Sets the stiffness of one or more joints. This is a non-blocking call.
Parameters: |
|
---|
#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_setstiffnesses robotIp "
<< "(optional default \"127.0.0.1\")."<< std::endl;
}
else {
robotIp = argv[1];
}
AL::ALMotionProxy motion(robotIp);
// Example showing how to set the stiffness to 1.0.
// Beware, doing this could be dangerous, it is safer to use the
// stiffnessInterpolation method which takes a duration parameter.
std::string names = "Body";
// If only one parameter is received, this is applied to all joints
float stiffnesses = 1.0f;
motion.setStiffnesses(names, stiffnesses);
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 set the stiffness to 1.0.
# Beware, doing this could be dangerous, it is safer to use the
# stiffnessInterpolation method which takes a duration parameter.
names = 'Body'
# If only one parameter is received, this is applied to all joints
stiffnesses = 1.0
motionProxy.setStiffnesses(names, stiffnesses)
if __name__ == "__main__":
robotIp = "127.0.0.1"
if len(sys.argv) <= 1:
print "Usage python almotion_setstiffnesses.py robotIP (optional default: 127.0.0.1)"
else:
robotIp = sys.argv[1]
main(robotIp)
Gets stiffness of a joint or group of joints
Parameters: |
|
---|---|
Returns: | One or more stiffnesses. 1.0 indicates maximum stiffness. 0.0 indicated minimum stiffness |
#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_getstiffnesses robotIp "
<< "(optional default \"127.0.0.1\")."<< std::endl;
}
else {
robotIp = argv[1];
}
AL::ALMotionProxy motion(robotIp);
// Example showing how to get the Body stiffnesses
std::string jointName = "Body";
std::vector<float> stiffnesses = motion.getStiffnesses(jointName);
std::cout << jointName << "stiffnesses: " << stiffnesses << 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 get the Body stiffnesses
jointName = "Body"
stiffnesses = motionProxy.getStiffnesses(jointName)
print "Body Stiffnesses:"
print stiffnesses
if __name__ == "__main__":
robotIp = "127.0.0.1"
if len(sys.argv) <= 1:
print "Usage python almotion_getstiffnesses.py robotIP (optional default: 127.0.0.1)"
else:
robotIp = sys.argv[1]
main(robotIp)