当前位置: 首页>>代码示例>>Python>>正文


Python ALProxy.stopBehavior方法代码示例

本文整理汇总了Python中naoqi.ALProxy.stopBehavior方法的典型用法代码示例。如果您正苦于以下问题:Python ALProxy.stopBehavior方法的具体用法?Python ALProxy.stopBehavior怎么用?Python ALProxy.stopBehavior使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在naoqi.ALProxy的用法示例。


在下文中一共展示了ALProxy.stopBehavior方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import stopBehavior [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
开发者ID:YueCoding,项目名称:NAO-,代码行数:33,代码来源:LoadBehavior.py

示例2: stop_behavior

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import stopBehavior [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
开发者ID:Kajvdh,项目名称:nao-flask,代码行数:16,代码来源:app.py

示例3: TouchEventModule

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import stopBehavior [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")
开发者ID:vimior,项目名称:nao,代码行数:49,代码来源:TouchEvent.py

示例4: main

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import stopBehavior [as 别名]
def main(robotIP, PORT=9559):
    tts = ALProxy("ALTextToSpeech", robotIP, PORT)
    tts.post.say("stop")

    motionProxy = ALProxy("ALMotion", robotIP, PORT)
    motionProxy.killAll()

    postureProxy = ALProxy("ALRobotPosture", robotIP, PORT)
    print ('\n=======posture=====before=====')
    print postureProxy.getPosture()
    postureProxy.stopMove()
    print ('=======after=====')
    print postureProxy.getPosture()

    audioDeviceProxy = ALProxy("ALAudioDevice", robotIP, PORT)
    print 'muted:', audioDeviceProxy.isAudioOutMuted()
    audioDeviceProxy.flushAudioOutputs()
    print 'muted:', audioDeviceProxy.isAudioOutMuted()

    audioPlayerProxy = ALProxy("ALAudioPlayer", robotIP, PORT)
    print ('\n=======audio=====before=====')
    allItems = audioPlayerProxy.getLoadedSoundSetsList()
    for i in allItems:
        print i
    # audioPlayerProxy.unloadAllFiles()
    # print ('=======afterUnload=====')
    # allItems = audioPlayerProxy.getLoadedSoundSetsList()
    # for i in allItems:
    #     print i
    audioPlayerProxy.stopAll()
    print ('=======afterStop=====')
    allItems = audioPlayerProxy.getLoadedSoundSetsList()
    for i in allItems:
        print i

    alBehaviorManagerProxy = ALProxy("ALBehaviorManager", robotIP, PORT)
    print ('\n=======behavior=====before=====')
    allItems = alBehaviorManagerProxy.getRunningBehaviors()
    for i in allItems:
        print i
    alBehaviorManagerProxy.stopBehavior('gangnam-style')
    alBehaviorManagerProxy.stopBehavior('taichi-dance-free')
    alBehaviorManagerProxy.stopBehavior('caravan-palace')
    print ('=======after=====')
    allItems = alBehaviorManagerProxy.getRunningBehaviors()
    for i in allItems:
        print i
开发者ID:ZiqianXY,项目名称:NaoController,代码行数:49,代码来源:move-stop.py

示例5: __init__

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import stopBehavior [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]
        
#.........这里部分代码省略.........
开发者ID:MihaiLupoiu,项目名称:Inteligent-Sistems,代码行数:103,代码来源:Nao.py

示例6: ALProxy

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import stopBehavior [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')
开发者ID:MihaiLupoiu,项目名称:Inteligent-Sistems,代码行数:19,代码来源:stand_up.py

示例7: __init__

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import stopBehavior [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()
#.........这里部分代码省略.........
开发者ID:vainmouse,项目名称:Nao,代码行数:103,代码来源:behaviors.py

示例8: Window

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import stopBehavior [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.
#.........这里部分代码省略.........
开发者ID:MihaiLupoiu,项目名称:Inteligent-Sistems,代码行数:103,代码来源:nao_control.py


注:本文中的naoqi.ALProxy.stopBehavior方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。