Guest User

nao_walk.py

a guest
Apr 20th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.75 KB | None | 0 0
  1. # -*- encoding: UTF-8 -*-
  2.  
  3. ''' setFootStep: Small example to make Nao execute     '''
  4. '''              The Cha Cha Basic Steps for Men       '''
  5. '''              Using setFootStep API                 '''
  6. ''' http://www.dancing4beginners.com/cha-cha-steps.htm '''
  7. ''' This example is only compatible with NAO '''
  8.  
  9. import argparse
  10. from naoqi import ALProxy
  11.  
  12. def main(robotIP, PORT=9559):
  13.  
  14.     motionProxy  = ALProxy("ALMotion", robotIP, PORT)
  15.     postureProxy = ALProxy("ALRobotPosture", robotIP, PORT)
  16.  
  17.     # Wake up robot
  18.     motionProxy.wakeUp()
  19.  
  20.     # Send robot to Stand Init
  21.     postureProxy.goToPosture("StandInit", 0.5)
  22.  
  23.     ###############################
  24.     # First we defined each step
  25.     ###############################
  26.     footStepsList = []
  27.  
  28.     # 1) Step forward with your left foot
  29.     footStepsList.append([["LLeg"], [[0.06, 0.1, 0.0]]])
  30.  
  31.     # 2) Sidestep to the left with your left foot
  32.     footStepsList.append([["LLeg"], [[0.00, 0.16, 0.0]]])
  33.  
  34.     # 3) Move your right foot to your left foot
  35.     footStepsList.append([["RLeg"], [[0.00, -0.1, 0.0]]])
  36.  
  37.     # 4) Sidestep to the left with your left foot
  38.     footStepsList.append([["LLeg"], [[0.00, 0.16, 0.0]]])
  39.  
  40.     # 5) Step backward & left with your right foot
  41.     footStepsList.append([["RLeg"], [[-0.04, -0.1, 0.0]]])
  42.  
  43.     # 6)Step forward & right with your right foot
  44.     footStepsList.append([["RLeg"], [[0.00, -0.16, 0.0]]])
  45.  
  46.     # 7) Move your left foot to your right foot
  47.     footStepsList.append([["LLeg"], [[0.00, 0.1, 0.0]]])
  48.  
  49.     # 8) Sidestep to the right with your right foot
  50.     footStepsList.append([["RLeg"], [[0.00, -0.16, 0.0]]])
  51.  
  52.     ###############################
  53.     # Send Foot step
  54.     ###############################
  55.     stepFrequency = 0.8
  56.     clearExisting = False
  57.     nbStepDance = 2 # defined the number of cycle to make
  58.  
  59.     for j in range( nbStepDance ):
  60.         for i in range( len(footStepsList) ):
  61.             try:
  62.                 motionProxy.setFootStepsWithSpeed(
  63.                     footStepsList[i][0],
  64.                     footStepsList[i][1],
  65.                     [stepFrequency],
  66.                     clearExisting)
  67.             except Exception, errorMsg:
  68.                 print str(errorMsg)
  69.                 print "This example is not allowed on this robot."
  70.                 exit()
  71.  
  72.  
  73.     motionProxy.waitUntilMoveIsFinished()
  74.  
  75.     # Go to rest position
  76.     motionProxy.rest()
  77.  
  78. if __name__ == "__main__":
  79.     parser = argparse.ArgumentParser()
  80.     parser.add_argument("--ip", type=str, default="127.0.0.1",
  81.                         help="Robot ip address")
  82.     parser.add_argument("--port", type=int, default=9559,
  83.                         help="Robot port number")
  84.  
  85.     args = parser.parse_args()
  86.     main(args.ip, args.port)
Add Comment
Please, Sign In to add comment