本文整理汇总了Python中naoqi.ALProxy.rest方法的典型用法代码示例。如果您正苦于以下问题:Python ALProxy.rest方法的具体用法?Python ALProxy.rest怎么用?Python ALProxy.rest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类naoqi.ALProxy
的用法示例。
在下文中一共展示了ALProxy.rest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import rest [as 别名]
def main(ip, port):
motionProxy = ALProxy("ALMotion", ip, port)
postureProxy = ALProxy("ALRobotPosture", ip, port)
#Hodanje bez tocke optimuma
postureProxy.goToPosture("StandInit", 0.5)
functions.set_camera_angle(motionProxy, -15)
time.sleep(5)
"""
picture = 'pictures/stairs_nao.png'
theta_horizont = [89.5, 90.5]
theta_kose = [10, 25, 160, 165]
faktor_odbacivanja_linija = 8
faktor_osjetljivosti_stepenica = 70 # sto je majni faktor, to su osjetljivije
parametri_stepenica, tocke_3D = functions.image_processing(ip, port, picture, theta_horizont, theta_kose, faktor_odbacivanja_linija, faktor_osjetljivosti_stepenica)
functions.walking(motionProxy, parametri_stepenica[0][0][0]-0.3, 0, 0)
"""
climbing.main(motionProxy, postureProxy)
time.sleep(3)
motionProxy.rest()
示例2: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import rest [as 别名]
def main(robotIP, PORT=9559):
''' Example showing a hand ellipsoid
Warning: Needs a PoseInit before executing
'''
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)
#tts = ALProxy("ALTextToSpeech", "192.168.2.17", 9559)
tts = ALProxy("ALTextToSpeech", "168.156.34.195", 9559)
tts.say("Hello, I'm going to move my left arm.")
tts.say("Then I will go back to the rest position!")
effector = "LArm"
frame = motion.FRAME_TORSO
axisMask = almath.AXIS_MASK_VEL # just control position
useSensorValues = False
path = []
currentTf = motionProxy.getTransform(effector, frame, useSensorValues)
# point 1
targetTf = almath.Transform(currentTf)
targetTf.r2_c4 -= 0.05 # y
path.append(list(targetTf.toVector()))
# point 2
targetTf = almath.Transform(currentTf)
targetTf.r3_c4 += 0.04 # z
path.append(list(targetTf.toVector()))
# point 3
targetTf = almath.Transform(currentTf)
targetTf.r2_c4 += 0.04 # y
path.append(list(targetTf.toVector()))
# point 4
targetTf = almath.Transform(currentTf)
targetTf.r3_c4 -= 0.02 # z
path.append(list(targetTf.toVector()))
# point 5
targetTf = almath.Transform(currentTf)
targetTf.r2_c4 -= 0.05 # y
path.append(list(targetTf.toVector()))
# point 6
path.append(currentTf)
times = [0.5, 1.0, 2.0, 3.0, 4.0, 4.5] # seconds
motionProxy.transformInterpolations(effector, frame, path, axisMask, times)
# Go to rest position
motionProxy.rest()
示例3: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import rest [as 别名]
def main(robotIP, PORT=9559):
motionProxy = ALProxy("ALMotion", robotIP, PORT)
postureProxy = ALProxy("ALRobotPosture", robotIP, PORT)
# Wake up robot
motionProxy.wakeUp()
# Send robot to Stand Zero
postureProxy.goToPosture("StandZero", 0.5)
# We use the "Body" name to signify the collection of all joints and actuators
#pNames = "Body"
# Get the Number of Joints
#numBodies = len(motionProxy.getBodyNames(pNames))
# We prepare a collection of floats
#pTargetAngles = [0.0] * numBodies
# We set the fraction of max speed
#pMaxSpeedFraction = 0.3
# Ask motion to do this with a blocking call
#motionProxy.angleInterpolationWithSpeed(pNames, pTargetAngles, pMaxSpeedFraction)
# Go to rest position
motionProxy.rest()
示例4: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import rest [as 别名]
def main():
""" Simple code to test above motion data. """
# Choregraphe simplified export in Python.
from naoqi import ALProxy
from pprint import pprint
names = list()
times = list()
keys = list()
leftArmMovementList = [leftArmMovementList0, leftArmMovementList1, leftArmMovementList2, leftArmMovementList3]
choice = 2
for n, t, k in leftArmMovementList[1]:
names.append(n)
times.append(t)
keys.append(k)
try:
# uncomment the following line and modify the IP if you use this script outside Choregraphe.
IP = "mistcalf.local"
motion = ALProxy("ALMotion", IP, 9559)
posture = ALProxy("ALRobotPosture", IP, 9559)
motion.wakeUp()
posture.goToPosture("StandInit", 0.8)
# motion = ALProxy("ALMotion")
motion.angleInterpolation(names, keys, times, True)
posture.goToPosture("Crouch", 0.8)
motion.rest()
except BaseException, err:
print err
开发者ID:mikemcfarlane,项目名称:TickleMeNAO,代码行数:36,代码来源:python_motion_data_export_from_Choregraph_inc_run_code.py
示例5: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import rest [as 别名]
def main(IP, PORT, faceSize):
print "Connecting to", IP, "with port", PORT
motion = ALProxy("ALMotion", IP, PORT)
tracker = ALProxy("ALTracker", IP, PORT)
# First, wake up.
motion.wakeUp()
# Add target to track.
targetName = "Face"
faceWidth = faceSize
tracker.registerTarget(targetName, faceWidth)
# Then, start tracker.
tracker.track(targetName)
print "ALTracker successfully started, now show your face to robot!"
print "Use Ctrl+c to stop this script."
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
print
print "Interrupted by user"
print "Stopping..."
# Stop tracker.
tracker.stopTracker()
tracker.unregisterAllTargets()
motion.rest()
print "ALTracker stopped."
示例6: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import rest [as 别名]
def main(robotIP, PORT=9559):
''' Example showing a path of two positions
Warning: Needs a PoseInit before executing
'''
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)
tts = ALProxy("ALTextToSpeech", "192.168.2.17", 9559)
tts.say("I'm going to extend my left arm.")
moveArm(motionProxy, "LArm")
tts.say("Now I'm going to extend my right arm.")
moveArm(motionProxy, "RArm")
tts.say("Then I will go back to the rest position!")
# Go to rest position
motionProxy.rest()
示例7: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import rest [as 别名]
def main(robotIP, PORT=9559):
motionProxy = ALProxy("ALMotion", robotIP, PORT)
postureProxy = ALProxy("ALRobotPosture", robotIP, PORT)
# Wake up robot
motionProxy.wakeUp()
# Send robot to Pose Init
postureProxy.goToPosture("StandInit", 0.5)
# Example showing how to get a simplified robot position in world.
useSensorValues = False
result = motionProxy.getRobotPosition(useSensorValues)
print "Robot Position", result
# Example showing how to use this information to know the robot's diplacement.
useSensorValues = False
initRobotPosition = almath.Pose2D(motionProxy.getRobotPosition(useSensorValues))
# Make the robot move
motionProxy.moveTo(0.1, 0.0, 0.2)
endRobotPosition = almath.Pose2D(motionProxy.getRobotPosition(useSensorValues))
# Compute robot's' displacement
robotMove = almath.pose2DInverse(initRobotPosition)*endRobotPosition
print "Robot Move:", robotMove
# Go to rest position
motionProxy.rest()
示例8: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import rest [as 别名]
def main(robotIP, PORT=9559):
''' Example showing a path of two positions
Warning: Needs a PoseInit before executing
'''
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)
effector = "LArm"
frame = motion.FRAME_TORSO
axisMask = almath.AXIS_MASK_VEL # just control position
useSensorValues = False
path = []
currentTf = motionProxy.getTransform(effector, frame, useSensorValues)
targetTf = almath.Transform(currentTf)
targetTf.r1_c4 += 0.03 # x
targetTf.r2_c4 += 0.03 # y
path.append(list(targetTf.toVector()))
path.append(currentTf)
# Go to the target and back again
times = [2.0, 4.0] # seconds
motionProxy.transformInterpolations(effector, frame, path, axisMask, times)
# Go to rest position
motionProxy.rest()
示例9: BotFreezerModule
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import rest [as 别名]
class BotFreezerModule(ALModule):
""" A simple module able to react
to head tactile sensor events
"""
def __init__(self, name):
ALModule.__init__(self, name)
# No need for IP and port here because
# we have our Python broker connected to NAOqi broker
# Create a proxy to ALMotion for later use
self.tts = ALProxy("ALMotion")
# Subscribe to the MiddleTactilTouched event:
global memory
memory = ALProxy("ALMemory")
memory.subscribeToEvent("FrontTactilTouched",
"BotFreezer",
"onTactilTouched")
memory.subscribeToEvent("MiddleTactilTouched",
"BotFreezer",
"onTactilTouched")
memory.subscribeToEvent("RearTactilTouched",
"BotFreezer",
"onTactilTouched")
def onTactilTouched(self, *_args):
""" This will be called each time any head tactil is
detected.
"""
# Unsubscribe to the event
# to avoid repetitions
memory.unsubscribeToEvent("FrontTactilTouched",
"BotFreezer")
memory.unsubscribeToEvent("MiddleTactilTouched",
"BotFreezer")
memory.unsubscribeToEvent("RearTactilTouched",
"BotFreezer")
print "Stopping walk"
self.tts.stopMove();
self.tts.rest();
try:
sys.exit(0)
except SystemExit:
os._exit(0)
# Subscribe again to the event
memory.subscribeToEvent("FrontTactilTouched",
"BotFreezer",
"onTactilTouched")
memory.subscribeToEvent("MiddleTactilTouched",
"BotFreezer",
"onTactilTouched")
memory.subscribeToEvent("RearTactilTouched",
"BotFreezer",
"onTactilTouched")
示例10: TestModule
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import rest [as 别名]
class TestModule(ALModule):
"""A module used for testing Nao's functionality"""
def __init__(self, var_name):
"""Define the module's attributes and initialize their value"""
# Request the parent module to initialize and register the module
ALModule.__init__(self, var_name)
# Declare the memory
global memory
memory = ALProxy("ALMemory")
# Initialize a motion module
self.motion = ALProxy("ALMotion")
# Initialize a posture module
self.posture = ALProxy("ALRobotPosture")
def initialize(self):
"""Initialize the inner modules of the module"""
# Wake the robot up
self.motion.wakeUp()
# Enable the whole body motion
self.motion.wbEnable(True)
def shutdown(self):
"""Shut the module down gracefully"""
# Disable the whole body motion
self.motion.wbEnable(False)
# Put the robot to rest
self.motion.rest()
def kick(self):
"""Define the procedure to follow to accomplish a kick"""
# Go to stand init posture
self.posture.goToPosture("StandInit", 0.5)
# Define the joints we are interested in
hip_joints = ["RHipRoll", "LHipRoll"]
# Get the angles for HipRolls
angles = self.motion.getAngles(hip_joints, True)
# Modify the value of the hip rolls
angles[0] -= 10 * almath.TO_RAD
angles[1] += 10 * almath.TO_RAD
# Set the angles to have Nao stand on one foot
self.motion.setAngles(hip_joints, angles, 0.2)
# Wait for some time
sleep(5)
# Go back to stand init posture
self.posture.goToPosture("StandInit", 0.5)
示例11: Golf
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import rest [as 别名]
class Golf(ALModule):
def __init__(self, name, robotIP, port):
ALModule.__init__(self, name)
self.robotIP = robotIP
self.port = port
self.memory = ALProxy("ALMemory")
self.motion = ALProxy("ALMotion")
self.posture = ALProxy("ALRobotPosture")
self.memory.subscribeToEvent("ALChestButton/TripleClickOccurred", "myGolf", "chestButtonPressed")
self.memory.subscribeToEvent("FrontTactilTouched", "myGolf", "frontTactilTouched")
self.memory.subscribeToEvent("MiddleTactilTouched", "myGolf", "middleTactilTouched")
self.memory.subscribeToEvent("RearTactilTouched", "myGolf", "rearTactilTouched")
self.memory.subscribeToEvent("robotHasFallen", "myGolf", "fallDownDetected")
def frontTactilTouched(self):
print "frontTactilTouched!!!!!!!!!!!!!"
self.memory.unsubscribeToEvent("FrontTactilTouched", "myGolf")
global holeFlag
holeFlag = 1
self.memory.subscribeToEvent("FrontTactilTouched", "myGolf", "frontTactilTouched")
def middleTactilTouched(self):
print "middleTactilTouched!!!!!!!!!!!!!!!!!!"
self.memory.unsubscribeToEvent("MiddleTactilTouched", "myGolf")
global holeFlag
holeFlag = 2
self.memory.subscribeToEvent("MiddleTactilTouched", "myGolf", "middleTactilTouched")
def rearTactilTouched(self):
print "rearTactilTouched!!!!!!!!!!!!!!!!!!"
self.memory.unsubscribeToEvent("RearTactilTouched", "myGolf")
global holeFlag
holeFlag = 3
self.memory.subscribeToEvent("RearTactilTouched", "myGolf", "rearTactilTouched")
def chestButtonPressed(self):
print "chestButtonPressed!!!!!!!!!!!!!!!!"
self.memory.unsubscribeToEvent("ALChestButton/TripleClickOccurred", "myGolf")
global holeFlag
holeFlag = 0
self.motion.angleInterpolationWithSpeed("LHand", 0.8, 1)
time.sleep(2)
self.motion.angleInterpolationWithSpeed("LHand", 0.2, 1)
self.motion.rest()
self.memory.subscribeToEvent("ALChestButton/TripleClickOccurred", "myGolf", "chestButtonPressed")
def fallDownDetected(self):
print "fallDownDetected!!!!!!!!!!!!!!!!"
self.memory.unsubscribeToEvent("robotHasFallen", "myGolf")
global robotHasFallenFlag
robotHasFallenFlag = 1
self.posture.goToPosture("StandInit", 0.5)
releaseStick(self.robotIP, self.port)
time.sleep(15)
catchStick(self.robotIP, self.port)
standWithStick(0.1, self.robotIP, self.port)
self.memory.subscribeToEvent("robotHasFallen", "myGolf", "fallDownDetected")
示例12: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import rest [as 别名]
def main(robotIP, PORT=9559):
''' Example of a whole body head orientation control
Warning: Needs a PoseInit before executing
Whole body balancer must be inactivated at the end of the script
'''
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)
effectorName = "Head"
# Active Head tracking
isEnabled = True
motionProxy.wbEnableEffectorControl(effectorName, isEnabled)
# Example showing how to set orientation target for Head tracking
# The 3 coordinates are absolute head orientation in NAO_SPACE
# Rotation in RAD in x, y and z axis
# X Axis Head Orientation feasible movement = [-20.0, +20.0] degree
# Y Axis Head Orientation feasible movement = [-75.0, +70.0] degree
# Z Axis Head Orientation feasible movement = [-30.0, +30.0] degree
targetCoordinateList = [
[+20.0, 00.0, 00.0], # target 0
[-20.0, 00.0, 00.0], # target 1
[ 00.0, +70.0, 00.0], # target 2
[ 00.0, +70.0, +30.0], # target 3
[ 00.0, +70.0, -30.0], # target 4
[ 00.0, -75.0, 00.0], # target 5
[ 00.0, -75.0, +30.0], # target 6
[ 00.0, -75.0, -30.0], # target 7
[ 00.0, 00.0, 00.0], # target 8
]
# wbSetEffectorControl is a non blocking function
# time.sleep allow head go to his target
# The recommended minimum period between two successives set commands is
# 0.2 s.
for targetCoordinate in targetCoordinateList:
targetCoordinate = [target*math.pi/180.0 for target in targetCoordinate]
motionProxy.wbSetEffectorControl(effectorName, targetCoordinate)
time.sleep(3.0)
# Deactivate Head tracking
isEnabled = False
motionProxy.wbEnableEffectorControl(effectorName, isEnabled)
# Go to rest position
motionProxy.rest()
示例13: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import rest [as 别名]
def main(robotIP,PORT=9559):
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)
time.sleep(2);
#Go to rest position
motionProxy.rest()
示例14: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import rest [as 别名]
def main(robotIP, PORT=9559):
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)
#####################
## Enable arms control by move algorithm
#####################
motionProxy.setMoveArmsEnabled(True, True)
#~ motionProxy.setMoveArmsEnabled(False, False)
#####################
## FOOT CONTACT PROTECTION
#####################
#~ motionProxy.setMotionConfig([["ENABLE_FOOT_CONTACT_PROTECTION",False]])
motionProxy.setMotionConfig([["ENABLE_FOOT_CONTACT_PROTECTION", True]])
#####################
## get robot position before move
#####################
initRobotPosition = m.Pose2D(motionProxy.getRobotPosition(False))
X = 0.0
Y = 0.0
Theta = math.pi/2.0
motionProxy.post.moveTo(X, Y, Theta)
motionProxy.setAngles("HeadYaw", 0.6, 0.6)
# wait is useful because with post moveTo is not blocking function
motionProxy.waitUntilMoveIsFinished()
#####################
## get robot position after move
#####################
endRobotPosition = m.Pose2D(motionProxy.getRobotPosition(False))
#####################
## compute and print the robot motion
#####################
robotMove = m.pose2DInverse(initRobotPosition)*endRobotPosition
# return an angle between ]-PI, PI]
robotMove.theta = m.modulo2PI(robotMove.theta)
print "Robot Move:", robotMove
# Go to rest position
motionProxy.rest()
示例15: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import rest [as 别名]
def main():
""" Some simple robot processes.
"""
global motion, posture, memory
motion = ALProxy("ALMotion", NAO_IP, 9559)
posture = ALProxy("ALRobotPosture", NAO_IP, 9559)
memory = ALProxy("ALMemory", NAO_IP, 9559)
# Set stiffness on for Head motors and go to start pose.
print "Starting tests...."
motion.setStiffnesses("Head", 1.0)
print "\n---------------------------------------\n"
# Goto start position, and run test1Procedural
print "test1Procedural starting ..."
posture.goToPosture("Crouch", 2.0)
t1 = (timeit("test1Procedural()", setup = "from __main__ import test1Procedural", number = TESTREPS))
print "...end test1Procedural, time: ", t1
print "\n---------------------------------------\n"
# Goto start position, and run test2Post
print "test2Post starting ..."
posture.goToPosture("Crouch", 2.0)
t2 = (timeit("test2Post()", setup = "from __main__ import test2Post", number = TESTREPS))
print "...end test2Post, time: ", t2
print "\n---------------------------------------\n"
# Goto start position, and run test3Threading
print "test3Threading starting ..."
posture.goToPosture("Crouch", 2.0)
t3 = (timeit("test3Threading()", setup = "from __main__ import test3Threading", number = TESTREPS))
print "...end test3Threading, time: ", t3
print "\n---------------------------------------\n"
# Goto start position, and run test4Multiprocessing - NOT WORKING
print "test4Multiprocessing - not working"
#print "test4Multiprocessing starting ..."
#posture.goToPosture("Crouch", 2.0)
#test4Multiprocessing()
#t4 = (timeit("test4Multiprocessing()", setup = "from __main__ import test3Threading", number = TESTREPS))
#print "...end test4Multiprocessing, time: ", t4
print "\n---------------------------------------\n"
# Goto start position, and run test5Coroutine
print "test5Coroutine starting ..."
posture.goToPosture("Crouch", 2.0)
t5 = (timeit("test5Coroutine()", setup = "from __main__ import test5Coroutine", number = TESTREPS))
print "...end test5Coroutine, time: ", t5
print "\n---------------------------------------\n"
# Gently set stiff off for Head motors and relax.
print "...ending tests!"
motion.setStiffnesses("Head", 0.0)
motion.rest()