def resetCamera(): print "Resetting Camera" bot.moveToDegAngle(5, 0, cameraSpeed) bot.moveToDegAngle(6, 0, cameraSpeed) bot.moveToDegAngle(7, 0, cameraSpeed)
#Send throttle and steering data to be prepared to g to the wheels turn = throttleSteeringToLeftRight(command[0], command[1]) #Set servo speeds bot.spinAtPcSpeed(1, turn[0]) bot.spinAtPcSpeed(2, turn[1]) bot.spinAtPcSpeed(3, turn[1]) bot.spinAtPcSpeed(4, turn[0]) #Update camera positions cameraPos[0] += command[5] #Update target location for Servo 5 cameraPos[1] += command[3] #Update target location for Servo 6 cameraPos[2] += -command[2] #Update target location for Servo 7 #Move camera to positions bot.moveToDegAngle(5, cameraPos[0], cameraSpeed) bot.moveToDegAngle(6, cameraPos[1], cameraSpeed) bot.moveToDegAngle(7, cameraPos[2], cameraSpeed) data = None #Clear data, just in case #Stop servos when loop broken bot.spinAtPcSpeed(1, 0) bot.spinAtPcSpeed(2, 0) bot.spinAtPcSpeed(3, 0) bot.spinAtPcSpeed(4, 0) conn.close() #Close connection to try and avoid 'address already in use' error