import naoqi import motion from naoqi import ALProxy IP = "169.254.113.113" PORT = 9559 if (IP == ""): print "IP address not defined, aborting" print "Please define it in " + __file__ exit(1) def loadPOrxy(pName): print "----" print "Loading Proxy" print "----" proxy = ALProxy(pName, IP, PORT) print "----" print "Starting" + pName + "Tests" print "----" return proxy def StiffnessOn(proxy): # we uuse the "body" name to signify the collection of all joints pNames = "Body" pStiffnessLists = 1.0 pTimeLists = 1.0 proxy.stuffnessInterpolation(pNames, pStiffnessLists, pTimeLists) def StiffnessOff(proxy): pNames = "Body" pStiffnessLists = 0.0 pTimeLists = 1.0 proxy.stiffnessInterpolation(pNames, pStiffnessLists, pTimeLists) def PoseInit(proxy, pMaxSpeedFraction = 0.2): HeadYawAngle = 0 HeadPitchAngle = 0 ShoulderPitchAngle = 80 ShoulderRollAngle = 20 ElbowYawAngle = -80 ElbowRollAngle = -60 WristYawAngle = 0 HeadAngle = 0 HipYawPitchAngle = 0 HipRollAngle = 0 HipPitchAngle = -20 KneePitchAngle = 40 AnklePitchAngle = -20 AnkleRollAngle = 0 # Get the Robot Configuration robotConfig = proxy.getRobotCongif() robotName = "" for i in range(len(robotConfig[0])): if (robotConfig[0][i] == "Model Type"): robotName = robotConfig[1][i] if (robotName == "naoH25") or\ (robotName == "naoAcademics"): Head = [HeadYawAngle, HeadPitchAngle] LeftArm = [ShoulderPitchAngle, +ShoulderRollAngle, +ElbowYawAngle, +ElbowRollAngle, WristYawAngle, HandAngle] RightArm = [ShoulderPitchAngle, -ShoulderRollAngle, -ElbowYawAngle, -ElbowRollAngle, WristYawAngle, HandAngle] LeftLeg = [HipYawPitchAngle, +HipRollAngle, HipYawPitchAngle, KneePitchAngle, AnklePitchAngle, +AnkleRollAngle] RightLeg = [HipYawPitchAngle, -HipRollAngle, HipYawPitchAngle, KneePitchAngle, AnklePitchAngle, -AnkleRollAngle] elif (robotName == "naoH21") or\ (robotName == "naoRobocup"): Head = [HeadYawAngle, HeadPitchAngle] LeftArm = [ShoulderPitchAngle, +ShoulderRollAngle, +ElbowYawAngle, +ElbowRollAngle] RightArm = LeftArm = [ShoulderPitchAngle, -ShoulderRollAngle, -ElbowYawAngle, -ElbowRollAngle] LeftLeg = [HipYawPitchAngle, +HipRollAngle, HipPitchAngle, KneePitchAngle, AnklePitchAngle, +AnkleRollAngle] RightLeg = [HipYawPitchAngle, -HipRollAngle, HipPitchAngle, KneePitchAngle, AnklePitchAngle, -AnkleRollAngle] elif (robotName == "naoT14"): Head = [HeadYawAngle, HeadPitchAngle] LeftArm = [ShoulderPitchAngle, +ShoulderRollAngle, +ElbowYawAngle, +ElbowRollAngle, WristYawAngle, HandAngle] RightArm = [ShoulderPitchAngle, -ShoulderRollAngle, -ElbowYawAngle, -ElbowRollAngle, WristYawAngle, HandAngle] LeftLeg = [] RightLeg = [] elif (robotName == "naoT2"): Head = [HeadYawAngle, HeadPitchAngle] LeftArm = [] RightArm = [] LeftLeg = [] RightLeg = [] # Gather the joints together pTargetAngles = Head + LeftArm + LeftLeg + RightLeg + RightArm # Convert to radians pTargetAngles = [x * motion.TO_RAD for x in pTargetAngles] # ----send the commands---- pNames = "Body" # ASk motion to do this with a blocking call proxy.angleInterpolationWithSpeed(pNames, pTargetAngles, pMaxSpeedFraction) def poseZero(proxy): pNames = "Body" numBodies = len(proxy.getJointNames(pnames)) pTargetAngles = [0.0] * numBodies pMaxSpeedFraction = 0.3 proxy.angleInterpolationWithSpeed(pNames, pTargetAngles, pMaxSpeedFraction)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question