本文整理汇总了Python中naoqi.ALProxy.isBehaviorRunning方法的典型用法代码示例。如果您正苦于以下问题:Python ALProxy.isBehaviorRunning方法的具体用法?Python ALProxy.isBehaviorRunning怎么用?Python ALProxy.isBehaviorRunning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类naoqi.ALProxy
的用法示例。
在下文中一共展示了ALProxy.isBehaviorRunning方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import isBehaviorRunning [as 别名]
class NaoBehavior:
naoip = ""
bhname = ""
def __init__(self,naoipaddress,behaviorName):
self.naoip = naoipaddress
self.bhname = behaviorName
self.nNB = ALProxy("ALBehaviorManager", self.naoip, 9559)
self.nposture = ALProxy("ALRobotPosture", self.naoip, 9559)
def lanuchAndStopBehavior(self):
if (self.nNB.isBehaviorInstalled(self.bhname)):
if (not self.nNB.isBehaviorRunning(self.bhname)):
self.nNB.post.runBehavior(self.bhname)
time.sleep(5)
else:
print "Behavior is already running"
else:
print "Behavior is not found"
return
names = self.nNB.getRunningBehaviors()
print "Running behaviors:"
self.nposture.goToPosture("Stand", 0.5)
print names
if (self.nNB.isBehaviorRunning(self.bhname)):
self.nNB.stopBehavior(self.bhname)
time.sleep(1.0)
else:
print "Behavior is already stopped."
names = self.nNB.getRunningBehaviors()
print "Running behaviors:"
print names
示例2: application
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import isBehaviorRunning [as 别名]
def application(environ, start_response):
status = '200 OK'
behaviourName = str(environ['QUERY_STRING'])
try:
managerProxy = ALProxy("ALBehaviorManager", "192.168.1.11", 9559)
if (managerProxy.isBehaviorInstalled(behaviourName)):
if (not managerProxy.isBehaviorRunning(behaviourName)):
managerProxy.post.runBehavior(behaviourName)
output = "Executed behaviour '%s' successfully" % behaviourName
else:
output = "Behavior '%s' is already running." % behaviourName
else:
output = "Behavior '%s' not found." % behaviourName
except:
output = "Problem executing behaviour '%s'" % behaviourName
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
示例3: TouchEventModule
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import isBehaviorRunning [as 别名]
class TouchEventModule(ALModule):
def __init__(self, name):
ALModule.__init__(self, name)
global memory
while True:
try:
memory = ALProxy("ALMemory")
self.behavior = ALProxy("ALBehaviorManager")
self.leds = ALProxy("ALLeds")
self.flag = True
break
except:
time.sleep(1)
memory.subscribeToEvent("TouchChanged",
"TouchEvent",
"onTouchChanged")
def onTouchChanged(self,strVarName,value):
try:
memory.unsubscribeToEvent("TouchChanged",
"TouchEvent")
except:
print "Filename %s, line: %d" %(sys._getframe().f_code.co_filename,sys._getframe().f_lineno)
for sensor in value:
if sensor[1] == True:
if sensor[0] == "LFoot/Bumper/Left":
# self.speech.say("start")
self.leds.rotateEyes(0x0000ff, 0.5, 3)
self.leds.reset("AllLeds")
if self.behavior.isBehaviorRunning("hdl_topic_new") == False:
self.behavior.startBehavior("hdl_topic_new")
elif sensor[0] == "RFoot/Bumper/Left" or sensor[0] == "RFoot/Bumper/Right":
self.leds.rotateEyes(0xff0000, 0.5, 3)
self.leds.reset("AllLeds")
if self.behavior.isBehaviorRunning("hdl_topic_new") == True:
self.behavior.stopBehavior("hdl_topic_new")
memory.subscribeToEvent("TouchChanged",
"TouchEvent",
"onTouchChanged")
示例4: stop_behavior
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import isBehaviorRunning [as 别名]
def stop_behavior():
logger.debug("stop_behavior() called")
if not request.json or not 'behavior' in request.json:
abort(400)
behavior = str(request.json['behavior'])
managerProxy = ALProxy("ALBehaviorManager", nao_host, nao_port)
if (managerProxy.isBehaviorRunning(behavior)):
logger.debug("Behavior "+behavior+" is running on the robot, stopping behavior...")
managerProxy.stopBehavior(behavior)
return jsonify({"stopped": behavior}), 200
else:
logger.debug("Behavior "+behavior+" is NOT running on the robot")
return jsonify({"error": "Behavior not running"}), 404
示例5: __init__
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import isBehaviorRunning [as 别名]
class Nao:
def __init__(self):
self.IP = "localhost" # Replace here with your NaoQi's IP address.
self.PORT = 9559
self.bmanager = ALProxy("ALBehaviorManager", self.IP, self.PORT)
self.poseProxy = ALProxy("ALRobotPose", self.IP, self.PORT)
self.motionProxy = ALProxy("ALMotion", self.IP, self.PORT)
self.memProxy = ALProxy("ALMemory",self.IP,self.PORT)
def stand_up(self):
if (self.bmanager.isBehaviorRunning('stand_up')):
self.bmanager.stopBehavior('stand_up')
time.sleep(1.0)
self.bmanager.runBehavior('stand_up')
def getActualPose(self):
pose, elapsedTime = self.poseProxy.getActualPoseAndTime()
return pose
def initCrawling(self):
proxy = self.motionProxy
proxy.setStiffnesses("Body", 1.0)
proxy.setAngles(['LShoulderPitch','RShoulderPitch'], [-0.25, -0.25], 0.5)
time.sleep(3)
proxy.setAngles(['LAnklePitch','RAnklePitch'], [-0.75, -0.75], 0.2)
time.sleep(3)
proxy.setStiffnesses("Body", 1.0)
names = ['HeadYaw', 'HeadPitch', 'LShoulderPitch', 'LShoulderRoll',
'LElbowYaw', 'LElbowRoll', 'LWristYaw', 'LHand',
'LHipYawPitch', 'LHipRoll', 'LHipPitch', 'LKneePitch',
'LAnklePitch', 'LAnkleRoll', 'RHipYawPitch', 'RHipRoll',
'RHipPitch', 'RKneePitch', 'RAnklePitch', 'RAnkleRoll',
'RShoulderPitch', 'RShoulderRoll', 'RElbowYaw', 'RElbowRoll',
'RWristYaw', 'RHand']
posture = [0.0, -0.7, -0.25, 0.1, -1.58, -0.1, 0.0, 0.0,
-0.4, 0.2437, -0.825, 1.8, 0.75, 0.68, -0.4, -0.2437,
-0.825, 1.8, 0.75, -0.68, -0.25, -0.1, 1.58, 0.1,
0.0, 0.0]
proxy.setAngles(names, posture, 0.2);
time.sleep(3)
proxy.setAngles(['LShoulderPitch','RShoulderPitch'], [0.21, 0.21], 1.0)
time.sleep(3)
def crawl(self, params, seconds=5):
proxy = self.motionProxy
proxy.setStiffnesses("Body", 1.0)
names = ["LShoulderPitch","RShoulderPitch",
"LShoulderRoll","RShoulderRoll",
"LElbowRoll","RElbowRoll",
"LKneePitch","RKneePitch",
"LHipPitch","RHipPitch",
"LHipRoll","RHipRoll",]
# PARAMETERS
# period = 1.28
#
# shoulderPitchA = 0.1
# shoulderPitchK = 0.21
# shoulderPitchPhi = 0.
#
# shoulderRollA = 0.035
# shoulderRollK = 0.039
# shoulderRollPhi = -2.
#
# hipPitchA = 0.12
# hipPitchK = -0.86
# hipPitchPhi = pi
#
# hipRollA = 0.06
# hipRollK = 0.33
# hipRollPhi = pi/2
#
# elbowRollA = 0.005
# elbowRollK = -0.11
# elbowRollPhi = -2.
#
# kneePitchA = 0.008
# kneePitchK = 1.8
# kneePitchPhi = 0.
period = params[0]
shoulderPitchA = params[1]
shoulderPitchK = params[2]
shoulderPitchPhi = params[3]
shoulderRollA = params[4]
shoulderRollK = params[5]
shoulderRollPhi = params[6]
hipPitchA = params[7]
hipPitchK = params[8]
hipPitchPhi = params[9]
hipRollA = params[10]
hipRollK = params[11]
hipRollPhi = params[12]
#.........这里部分代码省略.........
示例6: ALProxy
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import isBehaviorRunning [as 别名]
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 28 19:09:10 2013
@author: robinlab
"""
from naoqi import ALProxy
import time
IP = "localhost" # Replace here with your NaoQi's IP address.
PORT = 9559
bmanager = ALProxy("ALBehaviorManager", IP, PORT)
if (bmanager.isBehaviorRunning('stand_up')):
bmanager.stopBehavior('stand_up')
time.sleep(1.0)
bmanager.runBehavior('stand_up')
示例7: __init__
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import isBehaviorRunning [as 别名]
#.........这里部分代码省略.........
elif self.breathEnabled == False:
self.idlecount += 1
def rest(self):
# stop breathing if its enabled
self.resting = True
if self.breathEnabled == True:
self.breath(False)
self.motionProxy.rest()
time.sleep(1)
self.motionProxy.stiffnessInterpolation("Body", 0, 0.5)
self.asr.unsubscribe("ASR")
def breath(self, boolv):
# pBpm is a float between 5 and 30 setting the breathing frequency in beats per minute.
# pAmplitude is a float between 0 and 1 setting the amplitude of the breathing animation.
# At high frequencies, only low amplitudes are allowed. Input amplitude may be clipped.
if boolv == True:
self.checkawake()
self.breathEnabled = True
# Fast breathing: 20 Bpm and low Amplitude
self.motionProxy.setBreathConfig([['Bpm', 5.0], ['Amplitude', 0.3]])
else:
self.breathEnabled = False
self.motionProxy.setBreathEnabled('Legs' , boolv)
self.motionProxy.setBreathEnabled( 'Arms', boolv)
self.motionProxy.setBreathEnabled('Head',False)
def wakeup(self):
self.postureProxy.goToPosture("StandInit", 0.5)
self.resting = False
def checkawake(self):
self.managerProxy.stopAllBehaviors()
self.breath(False)
# if robot is not awake, wake it
if self.motionProxy.robotIsWakeUp() == False:
self.wakeup()
def sayAnimated(self, text):
self.checkawake()
# set the local configuration
configuration = {"bodyLanguageMode": "contextual"}
# say the text with the local configuration
self.animatedSpeechProxy.say(text, configuration)
def texttospeach(self, text):
self.tts.say(text)
def launchBehavior(self, behaviorName):
''' Launch and stop a behavior, if possible. '''
if (self.managerProxy.isBehaviorInstalled(behaviorName)):
# Check that it is not already running.
if (not self.managerProxy.isBehaviorRunning(behaviorName)):
# check if robot is awake
self.checkawake()
# Launch behavior. This is a blocking call, use post if you do not
# want to wait for the behavior to finish.
rospy.loginfo ("Running Behavior"+ behaviorName)
self.headlock = True
headodom = self.motionProxy.getAngles(["HeadYaw", "HeadPitch"], True)
Id = self.managerProxy.post.runBehavior(behaviorName)
self.headlock = False
# wait till behavior stops running
self.managerProxy.wait(Id, 0)
#return head back to original
self.headmove(headodom,0.1)
else:
rospy.loginfo("Behavior is already running.")
else:
rospy.loginfo("Behavior not found.")
def getBehaviors(self):
names = self.managerProxy.getInstalledBehaviors()
for x in names:
rospy.loginfo(x)
def on_shutdown(self):
self.asr.unsubscribe("ASR")
self.rest()
def jointstateC(self, data):
#keeps our odom up to date
self.headOdom[0] = data.position[0]
self.headOdom[1] = data.position[1]
def nod(self):
prevodom = self.headOdom
odom = self.headOdom
odom[1] -= 0.5
self.headmove(odom,0.08)
odom[1] += 0.5
self.headmove(odom,0.08)
示例8: __init__
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import isBehaviorRunning [as 别名]
class NaoBehavior:
def __init__(self,robotIP):
# Create proxy to ALBehaviorManager
self.managerProxy = ALProxy("ALBehaviorManager", robotIP, 9559)
self.motionProxy = ALProxy("ALMotion", robotIP, 9559)
self.animatedSpeechProxy = ALProxy("ALAnimatedSpeech", robotIP, 9559)
rospy.Subscriber("/nao_behavior/run_behavior", String, self.run_callback)
rospy.Subscriber("/nao_behavior/stop_behavior", String, self.stop)
self.wakeup()
self.auto = ALProxy("ALAutonomousLife", robotIP, 9559)
self.activeBehavior = 0
self.behaviorCount =0
self.nextBehavior = 1
self.autostate()
def disableAuto(self):
self.auto.stopAll()
def autostate(self):
self.auto.setState('solitary')
def run_callback(self,data):
self.auto.setState('disabled')
self.say(data.data)
self.autostate()
return
if data.data == 'wakeup':
self.wakeup()
return
if data.data == 'rest':
self.rest()
return
if data.data == "help":
self.getBehaviors()
# self.Action(data.data)
return
self.launchBehavior(data.data)
def say(self,data):
# set the local configuration
configuration = {"bodyLanguageMode": "contextual"}
# say the text with the local configuration
self.animatedSpeechProxy.say(data, configuration)
def launchBehavior(self, behaviorName):
''' Launch and stop a behavior, if possible. '''
self.behaviorCount = self.behaviorCount +1
behaviorNumber = self.behaviorCount
while True:
if self.activeBehavior ==0 and self.nextBehavior == behaviorNumber:
self.activeBehavior =1
# Check that the behavior exists.
if (self.managerProxy.isBehaviorInstalled(behaviorName)):
# Check that it is not already running.
if (not self.managerProxy.isBehaviorRunning(behaviorName)):
# Launch behavior. This is a blocking call, use post if you do not
# want to wait for the behavior to finish.
rospy.loginfo("Running Behavior")
self.managerProxy.post.runBehavior(behaviorName)
while( self.managerProxy.isBehaviorRunning(behaviorName) == True):
time.sleep(0.2)
else:
rospy.loginfo( "Behavior is already running.")
else:
rospy.loginfo( "Behavior not found.")
self.nextBehavior = behaviorNumber +1
self.activeBehavior =0
return
elif self.activeBehavior ==1:
print( str(behaviorNumber) +'queud')
def stop(self,behaviorName):
# Stop the behavior.
if (self.managerProxy.isBehaviorRunning(behaviorName.data)):
self.managerProxy.stopBehavior(behaviorName.data)
rospy.loginfo("Behavior stopped.")
time.sleep(1.0)
else:
rospy.loginfo("Behavior is already stopped.")
def wakeup(self):
self.motionProxy.wakeUp()
def rest(self):
self.motionProxy.rest()
#.........这里部分代码省略.........
示例9: NaoMove
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import isBehaviorRunning [as 别名]
class NaoMove():
# Class used to make all movements to Nao
def __init__(self, parent):
#Constructor
self.motionProxy = None
self.postureProxy = None
self.tts = None
self.memoryProxy = None
self.behaviourProxy = None
self.motorOn = False
self.parent = parent
self.memValue = ["FaceDetected"]
self.headNames = ["HeadYaw", "HeadPitch"]
self.leftArmNames = ["LShoulderRoll","LShoulderPitch","LElbowRoll","LElbowYaw"]
self.rightArmNames = ["RShoulderRoll","RShoulderPitch","RElbowRoll","RElbowYaw"]
def connect(self, robotIP, port):
try:
self.motionProxy = ALProxy("ALMotion", robotIP , port)
self.tts = ALProxy("ALTextToSpeech", robotIP, port)
self.postureProxy = ALProxy("ALRobotPosture", robotIP, port)
self.memoryProxy = ALProxy("ALMemory", robotIP, port)
self.behaviourProxy = ALProxy("ALBehaviorManager", robotIP, port)
except:
return 1
# If connection is successful, we initialize few variables for Arms
self.anglesRight = self.motionProxy.getAngles(self.rightArmNames, True)
self.anglesLeft = self.motionProxy.getAngles(self.leftArmNames, True)
return 0
def walk(self,x,y,theta,frequency):
# Test if the stiffness of Nao is set to 1.0
self.testMotorOn()
# Launch the walk
self.motionProxy.setWalkTargetVelocity(x, y, theta, frequency)
def stopWalk(self, frequency):
self.motionProxy.setWalkTargetVelocity(0.0, 0.0, 0.0, frequency)
self.motionProxy.waitUntilMoveIsFinished()
def stop(self):
self.motionProxy.killMove()
def standInit(self):
self.postureProxy.goToPosture("StandInit", constante.FREQUENCY)
def crouch(self):
self.postureProxy.goToPosture("Crouch", constante.FREQUENCY)
def runHello(self):
self.testMotorOn()
self.behaviourProxy.runBehavior("helloBoy")
def openHand(self, hand):
if hand == constante.RIGHT_HAND:
self.motionProxy.openHand('RHand')
else:
self.motionProxy.openHand('LHand')
def closeHand(self, hand):
if hand == constante.RIGHT_HAND:
self.motionProxy.closeHand('RHand')
else:
self.motionProxy.closeHand('LHand')
def moveHead(self, angles):
# Test if the stiffness of Nao is set to 1.0
self.testMotorOn()
current = self.motionProxy.getAngles(self.headNames, True)
# this boucle is used to dynamically calculate the speed of the movement
for i in range(len(angles)):
speed = abs(angles[i]-current[i])/2.0
if speed < 0.05:
speed = 0.05
if speed > 0.8:
speed = 0.8
# Make the movement
self.motionProxy.setAngles(self.headNames[i], angles[i], speed)
def detectFace(self):
# Check that it is not already running.
if (not self.behaviourProxy.isBehaviorRunning("faceDetect")):
# Launch behavior. This is a blocking call, use post if you do not
# want to wait for the behavior to finish.
self.behaviourProxy.post.runBehavior("faceDetect")
def naoMoveTwoArms(self, listPos):
# Test if the stiffness of Nao is set to 1.0
#.........这里部分代码省略.........
示例10: __init__
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import isBehaviorRunning [as 别名]
class wsNaoMotion:
MAX_HEADPITCH=0.32
MIN_HEADPITCH=-0.5
_motion=None
_behavior=None
_robotip=""
def __init__(self,ip="192.168.143.101"):
self._robotip=ip
self._motion=ALProxy("ALMotion",self._robotip,9559)
self._behavior=ALProxy("ALBehaviorManager",self._robotip, 9559)
def getBehaviors(self):
return self._behavior.getInstalledBehaviors()
def getRunningBehaviors(self):
return self._behavior.getRunningBehaviors()
def runBehavior(self,name):
if (self._behavior.isBehaviorInstalled(name)):
if (not self.isBehaviorRunning(name)):
self._behavior.post.runBehavior(name)
time.sleep(0.5)
else:
print "Behavior is already running."
else:
print "Behavior not found."
def stopBehavior(self):
pass
def isBehaviorRunning(self,name):
return self._behavior.isBehaviorRunning(name)
def stiffnessOn(self):
self._motion.stiffnessInterpolation("Body", 1.0, 1.0)
def stiffnessOff(self):
self._motion.stiffnessInterpolation("Body", 0.0, 1.0)
def getAngle(self,jname,sensor=True):
return self._motion.getAngles(jname,sensor)[0]
def getHeadPitchAngle(self):
return self._motion.getAngles('HeadPitch',True)[0]
def headRelativePitch(self,ang,speed=0.05):
self._motion.changeAngles('HeadPitch',ang,speed)
def headPitchTo(self,ang,speed=0.1):
self._motion.setAngles("HeadPitch", ang,speed)
def sitDown(self):
self.runBehavior("sitdown")
def standUp(self):
self.runBehavior("standup")
def hula(self,n,cw=1):
self.poseInit()
if cw!=1:cw=-1
# Define the changes relative to the current position
dx = 0.07 # translation axis X (meter)
dy = 0.07*cw # translation axis Y (meter)
dwx = 0.15*cw # rotation axis X (rad)
dwy = 0.15 # rotation axis Y (rad)
# Define a path of two hula hoop loops
tpath = [ [+dx, 0.0, 0.0, 0.0, -dwy, 0.0], # point 01 : forward / bend backward
[0.0, -dy, 0.0, -dwx, 0.0, 0.0], # point 02 : right / bend left
[-dx, 0.0, 0.0, 0.0, dwy, 0.0], # point 03 : backward / bend forward
[0.0, +dy, 0.0, dwx, 0.0, 0.0] # point 04 : left / bend right
]
path=[]
for i in range(n):
path+=tpath
timeOneMove = 0.4 #seconds
times = []
for i in range(len(path)):
times.append( (i+1)*timeOneMove )
# call the cartesian control API
effector = "Torso"
space = motion.SPACE_NAO
axisMask = almath.AXIS_MASK_ALL
isAbsolute = False
self._motion.positionInterpolation(effector, space, path, axisMask, times, isAbsolute)
self.poseInit()
def poseInit(self):
names = list()
times = list()
keys = list()
names.append("HeadYaw")
times.append([ 2.00000])
keys.append([ [ 0.00000, [ 3, -0.66667, 0.00000], [ 3, 0.00000, 0.00000]]])
names.append("HeadPitch")
times.append([ 2.00000])
keys.append([ [ 0.00000, [ 3, -0.66667, 0.00000], [ 3, 0.00000, 0.00000]]])
names.append("LShoulderPitch")
times.append([ 2.00000])
keys.append([ [ 1.39626, [ 3, -0.66667, 0.00000], [ 3, 0.00000, 0.00000]]])
names.append("LShoulderRoll")
times.append([ 2.00000])
keys.append([ [ 0.34907, [ 3, -0.66667, 0.00000], [ 3, 0.00000, 0.00000]]])
names.append("LElbowYaw")
times.append([ 2.00000])
keys.append([ [ -1.39626, [ 3, -0.66667, 0.00000], [ 3, 0.00000, 0.00000]]])
names.append("LElbowRoll")
times.append([ 2.00000])
#.........这里部分代码省略.........
示例11: Window
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import isBehaviorRunning [as 别名]
class Window(QWidget):
def __init__(self):
QWidget.__init__(self)
IP = "localhost" # Replace here with your NaoQi's IP address.
PORT = 9559
self._cameraID = 0
self._registerImageClient(IP, PORT)
self.imgnum = 0
self._bmanager = ALProxy("ALBehaviorManager", IP, PORT)
if not self._bmanager.isBehaviorInstalled('stand_up'):
self._bmanager.preloadBehavior('stand_up')
self._motion = ALProxy("ALMotion", IP, PORT)
self._memory = ALProxy("ALMemory",IP,PORT)
self.initUI()
def initUI(self):
self.imageLabel = QLabel('Image',self)
self.standUpButton = QPushButton('Stand Up', self)
self.standUpButton.clicked.connect(self.handleStandUpButton)
self.snapshotButton = QPushButton('Snapshot', self)
self.snapshotButton.clicked.connect(self.handleSnapshotButton)
self.walkButton = QPushButton('Forward', self)
self.walkButton.clicked.connect(self.handleWalkButton)
self.backButton = QPushButton('Backward', self)
self.backButton.clicked.connect(self.handleBackButton)
self.leftButton = QPushButton('Left', self)
self.leftButton.clicked.connect(self.handleLeftButton)
self.rightButton = QPushButton('Right', self)
self.rightButton.clicked.connect(self.handleRightButton)
hbox = QHBoxLayout()
hbox.addWidget(self.leftButton)
hbox.addWidget(self.walkButton)
hbox.addWidget(self.backButton)
hbox.addWidget(self.rightButton)
vbox = QVBoxLayout(self)
vbox.addWidget(self.imageLabel)
vbox.addWidget(self.standUpButton)
vbox.addWidget(self.snapshotButton)
vbox.addLayout(hbox)
self.setLayout(vbox)
self.setWindowTitle('Nao control')
# Trigget 'timerEvent' every 100 ms.
self.startTimer(100)
self.show()
def handleStandUpButton(self):
print 'StandUp'
x = self._memory.getData("Simulator/TorsoPosition/X")
y = self._memory.getData("Simulator/TorsoPosition/Y")
z = self._memory.getData("Simulator/TorsoPosition/Z")
print "Robot Position: ", (x,y,z)
if (self._bmanager.isBehaviorRunning('stand_up')):
self._bmanager.stopBehavior('stand_up')
time.sleep(1.0)
self._bmanager.post.runBehavior('stand_up')
def handleSnapshotButton(self):
print 'Snapshot'
self.image.save('img_' + format(self.imgnum, '04d') + '.png','PNG')
self.imgnum = self.imgnum + 1
def handleWalkButton(self):
print 'Forward'
x = self._memory.getData("Simulator/TorsoPosition/X")
y = self._memory.getData("Simulator/TorsoPosition/Y")
z = self._memory.getData("Simulator/TorsoPosition/Z")
print "Robot Position: ", (x,y,z)
self._motion.post.walkTo(0.5, 0.0, 0.0)
def handleBackButton(self):
print 'Backward'
x = self._memory.getData("Simulator/TorsoPosition/X")
y = self._memory.getData("Simulator/TorsoPosition/Y")
z = self._memory.getData("Simulator/TorsoPosition/Z")
print "Robot Position: ", (x,y,z)
self._motion.post.walkTo(-0.5, 0.0, 0.0)
def handleLeftButton(self):
print 'Left'
x = self._memory.getData("Simulator/TorsoPosition/X")
y = self._memory.getData("Simulator/TorsoPosition/Y")
z = self._memory.getData("Simulator/TorsoPosition/Z")
print "Robot Position: ", (x,y,z)
self._motion.post.walkTo(0.0, 0.0, 1.57)
def handleRightButton(self):
print 'Right'
x = self._memory.getData("Simulator/TorsoPosition/X")
y = self._memory.getData("Simulator/TorsoPosition/Y")
z = self._memory.getData("Simulator/TorsoPosition/Z")
print "Robot Position: ", (x,y,z)
self._motion.post.walkTo(0.0, 0.0, -1.57)
def _updateImage(self):
"""
Retrieve a new image from Nao.
"""
alImage = self._videoProxy.getImageRemote(self._imgClient)
self.image = QImage(alImage[6], # Pixel array.
#.........这里部分代码省略.........