Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.15 KB | None | 0 0
  1. import naoqi
  2. import time
  3. from naoqi import ALProxy
  4. import sys
  5. import motion
  6. import almath
  7.        
  8. def main(robotIP):  
  9.         try:
  10.             motionProxy = ALProxy("ALMotion", robotIP, 9559)
  11.         except Exception, e:
  12.             print "Could not create proxy to ALMotion"
  13.             print "Error was: ", e
  14.  
  15.         try:
  16.             postureProxy = ALProxy("ALRobotPosture", robotIP, 9559)
  17.         except Exception, e:
  18.                 print "Could not create proxy to ALRobotPosture"
  19.                 print "Error was: ", e
  20.        
  21.     ##############################
  22.     #HERE THE INIT CODE
  23.     ##############################
  24.     #You don't need 'self' here because it's not a class (look at python class for more information)
  25.     tracker = ALProxy( "ALTracker", robotIP, 9559) #DONT FORGET IP AND PORT because you're not using choregraphe
  26.  
  27.         x = 0.0
  28.         y = 0.0
  29.         z = 0.0
  30.  
  31.         maxSpeed = 0.5
  32.  
  33.         effector = "Arms"
  34.     frame = 0 #FRAME TORSO
  35.        
  36.     ###################################
  37.     # WHAT THE BOX DOES WHEN ACTIVATED (OnInput_Start)
  38.     # In the class, self.getparameter() take the configuration of the box (when you click on the tool icon)
  39.     # It's not in choregraphe so you have to hardcode these parameters or pass them as arguments
  40.     #####################################
  41.     #GET THE PARAMETERS (where to point, at what speed and using what)
  42.         x = 1.5
  43.         y = 2
  44.         z = 3
  45.  
  46.         maxSpeed = 0.5 #50%
  47.         effector = "Arms" #Look at the doc for effector list
  48.  
  49.         frameStr = "Robot" #Same, take a look at the doc
  50.         if frameStr == "Torso":
  51.             frame = 0
  52.         elif frameStr == "World":
  53.             frame = 1
  54.         elif frameStr == "Robot":
  55.             frame = 2
  56.    
  57.     #AND Now, the actual function. You just need to set the tracker and call this function to make the robot point something
  58.     tracker.pointAt(effector, [x, y, z], frame, maxSpeed)
  59.        
  60. if __name__ == "__main__":
  61.     robotIp = "1111111"
  62.  
  63.     if len(sys.argv) <= 1:
  64.         print "Usage python motion_cartesianArm1.py robotIP (optional default: 127.0.0.1)"
  65.     else:
  66.         robotIp = sys.argv[1]
  67.  
  68.     main(robotIp)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement