# -*- encoding: UTF-8 -*- from naoqi import ALProxy import almath import argparse import math def main(robotIP, PORT = 9559): navigationProxy = ALProxy("ALNavigation", robotIP, PORT) motionProxy = ALProxy("ALMotion", robotIP, PORT) postureProxy = ALProxy("ALRobotPosture", robotIP, PORT) # Wake up robot motionProxy.wakeUp() # Send robot to Stand Init postureProxy.goToPosture("StandInit", 0.5) # Scanning the environement. navigationProxy.startFreeZoneUpdate() ########################################################################### # Add here an animation with timelines and moves (less than 60 seconds). # # For example : motionProxy.moveTo(0.0, 0.0, 2.0 * math.pi) ########################################################################### desiredRadius = 0.6 displacementConstraint = 0.5 result = navigationProxy.findFreeZone(desiredRadius, displacementConstraint) errorCode = result[0] if errorCode != 1: worldToCenterFreeZone = almath.Pose2D(result[2][0], result[2][1], 0.0) worldToRobot = almath.Pose2D(motionProxy.getRobotPosition(True)) robotToFreeZoneCenter = almath.pinv(worldToRobot) * worldToCenterFreeZone motionProxy.moveTo(robotToFreeZoneCenter.x, robotToFreeZoneCenter.y, 0.0) else : print "Problem during the update of the free zone." if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--ip", type=str, default="127.0.0.1", help="Robot ip address") parser.add_argument("--port", type=int, default=9559, help="Robot port number") args = parser.parse_args() main(args.ip, args.port)