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


Python ALProxy.runBehavior方法代码示例

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


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

示例1: main

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import runBehavior [as 别名]
def main(robotIP, PORT=9559):
    tts = ALProxy("ALTextToSpeech", robotIP, PORT)
    tts.post.say("大家好!!我是,Nao,机器人,,很高兴见到大家.")
    print "Robot Say Hello"

    behavior = 'animations/Stand/Gestures/Hey_1'
    alBehaviorManager = ALProxy("ALBehaviorManager", robotIP, PORT)
    alBehaviorManager.runBehavior(behavior)

    print "Robot Behavior:", behavior
开发者ID:ZiqianXY,项目名称:NaoController,代码行数:12,代码来源:hello.py

示例2: main

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import runBehavior [as 别名]
def main(robotIP, PORT=9559):
    motionProxy = ALProxy("ALMotion", robotIP, PORT)
    postureProxy = ALProxy("ALRobotPosture", robotIP, PORT)
    motionProxy.wakeUp()
    postureProxy.goToPosture("Stand", 0.8)

    behavior = 'animations/Stand/Waiting/DriveCar_1'
    alBehaviorManager = ALProxy("ALBehaviorManager", robotIP, PORT)
    alBehaviorManager.runBehavior(behavior)
    print "Robot Behavior:", behavior
开发者ID:ZiqianXY,项目名称:NaoController,代码行数:12,代码来源:drive.py

示例3: main

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import runBehavior [as 别名]
def main(robotIP, PORT=9559):
    tts = ALProxy("ALTextToSpeech", robotIP, PORT)
    tts.post.say("来,,我教你照相.")

    postureProxy = ALProxy("ALRobotPosture", robotIP, PORT)
    postureProxy.goToPosture("Stand", 0.5)

    behavior = 'animations/Stand/Waiting/TakePicture_1'
    alBehaviorManager = ALProxy("ALBehaviorManager", robotIP, PORT)
    alBehaviorManager.runBehavior(behavior)
    print "Robot Behavior:", behavior
开发者ID:ZiqianXY,项目名称:NaoController,代码行数:13,代码来源:takePhoto.py

示例4: main

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import runBehavior [as 别名]
def main():
    """ Main entry point

    """
    parser = OptionParser()
    parser.add_option("--pip",
        help="Parent broker port. The IP address or your robot",
        dest="pip")
    parser.add_option("--pport",
        help="Parent broker port. The port NAOqi is listening to",
        dest="pport",
        type="int")
    parser.set_defaults(
        pip=NAO_IP,
        pport=NAO_PORT)

    (opts, args_) = parser.parse_args()
    pip   = opts.pip
    pport = opts.pport

    # We need this broker to be able to construct
    # NAOqi modules and subscribe to other modules
    # The broker must stay alive until the program exists
    myBroker = ALBroker("myBroker",
       "0.0.0.0",   # listen to anyone
       0,           # find a free port and use it
       pip,         # parent broker IP
       pport)       # parent broker port


    # Warning: Watson must be a global variable
    # The name given to the constructor must be the name of the
    # variable
    global ALWatson
    ALWatson = ALWatson("ALWatson")
    beh = ALProxy("ALBehaviorManager")
    
    try:
        while True:
            time.sleep(5)
            command = ALWatson.heartbeat()
            if "wave" in str(command):
                beh.runBehavior("animations/Stand/Gestures/Hey_1")
            continue

    except KeyboardInterrupt:
        print
        print "Interrupted by user, shutting down"
        myBroker.shutdown()
        sys.exit(0)
开发者ID:philippe-gregoire,项目名称:watson_robotic_client,代码行数:52,代码来源:alwatson.py

示例5: TouchDanceModule

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import runBehavior [as 别名]
class TouchDanceModule(ALModule):
    def __init__(self, name):
        ALModule.__init__(self, name)

        global memory

        # 循环仅仅用于个别用途
        while True:
            try:
                memory = ALProxy("ALMemory")
                self.speech = ALProxy("ALTextToSpeech")
                self.behavior = ALProxy("ALBehaviorManager")
                self.motion = ALProxy("ALMotion")
                self.leds = ALProxy("ALLeds")
                self.flag = False # 用于防止误触碰触发事件
                break
            except:
                time.sleep(1)
        
        memory.subscribeToEvent("TouchChanged",
            "TouchDance",
            "onTouchChanged")

    def onTouchChanged(self,strVarName,value):
        try:
            memory.unsubscribeToEvent("TouchChanged",
                "TouchDance")
        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")
                    if self.flag == False:
                        self.leds.rotateEyes(0x00ff00, 0.5, 2)
                        self.leds.reset("AllLeds")
                        self.flag = True
                        self.motion.wakeUp()
                        self.speech.post.say("Ready")
                    else:
                        self.leds.rotateEyes(0x0000ff, 0.5, 2)
                        self.leds.reset("AllLeds")
                        self.flag = False
                        self.motion.wakeUp()
                        self.speech.post.say("Start")
                        # 预加载舞蹈程序jtw
                        self.behavior.preloadBehavior("jtw")

                        self.dev_time = memory.getData("DelayTime")
                        # print self.dev_time

                        # 等待秒数为0才执行事件处理函数
                        while True:
                            if datetime.datetime.now().second == 0:
                                self.runBehavior()
                                break
                # 右脚脚趾触碰事件,主要用于把误碰左脚脚趾的事件标志flag置为False
                elif sensor[0] == "RFoot/Bumper/Left" or sensor[0] == "RFoot/Bumper/Right":
                    # self.speech.say("over")
                    self.leds.rotateEyes(0xff0000, 0.5, 2)
                    self.leds.reset("AllLeds")
                    self.flag = False
                    self.motion.rest()
                    self.speech.post.say("Over")
                    # self.flag = False
                    # self.speech.post.say("over")
                    
        memory.subscribeToEvent("TouchChanged",
            "TouchDance",
            "onTouchChanged")
        
    def runBehavior(self):
        # 延时"2s+时间偏移"
        time.sleep(2+self.dev_time)
        self.speech.say("下面进行舞蹈表演")
        self.behavior.runBehavior("jtw")
开发者ID:vimior,项目名称:nao,代码行数:80,代码来源:naoTouchDance.py

示例6: __init__

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import runBehavior [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

示例7: ALProxy

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import runBehavior [as 别名]
from naoqi import ALProxy

# naoip = "192.168.1.54"
naoip = "169.254.95.24"
naopt = 9559

all = ALProxy("ALLeds", naoip, naopt)
all.randomEyes(5.0)

abm = ALProxy("ALBehaviorManager", naoip, naopt)
# print abm.getInstalledBehaviors()
abm.runBehavior("The Hump")

# amm = ALProxy("ALMemory", naoip, naopt);
# amm.insertData("parameter1", "We breed like rabbits")
# abm.runBehavior("Say from Memory")
# amm.removeData("parameter1")
# amm.insertData("walkx", "0.5")
# amm.insertData("walky", "0")
# abm.runBehavior("Toggle Stand");
# abm.runBehavior("Walk XY")
# print amm.getData("walkx")
# print amm.getData("walky")
# amm.removeData("walkx")
# amm.removeData("walky")
# abm.runBehavior("Toggle Stand")

# apm = ALProxy("ALRobotPose", naoip, naopt)
# print apm.getPoseNames()
# print apm.getActualPoseAndTime()
开发者ID:spurkis,项目名称:Nao-Therapist,代码行数:32,代码来源:sayhi.py

示例8: ALProxy

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import runBehavior [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

示例9: ALProxy

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import runBehavior [as 别名]
	if cmd=="standup":
		postureProxy = ALProxy("ALRobotPosture",config.ipnao, 9559)
		postureProxy.goToPosture("Stand", 1)
	elif cmd == "sitdown":
		postureProxy = ALProxy("ALRobotPosture",config.ipnao, 9559)
		postureProxy.goToPosture("Sit", 1)
		p = ALProxy("ALMotion",config.ipnao, 9559)
		p.rest()
	elif cmd == "crouch":
		postureProxy = ALProxy("ALRobotPosture",config.ipnao, 9559)
		postureProxy.goToPosture("Crouch", 1)
		p = ALProxy("ALMotion", "nao.local", 9559)
		p.rest()
	elif cmd == "gangnamstyle":
		behaviorManagerProxy = ALProxy("ALBehaviorManager",config.ipnao, 9559)
		behaviorManagerProxy.runBehavior("gangnamstyle")
	elif cmd == "caravanpalace":
		behaviorManagerProxy = ALProxy("ALBehaviorManager",config.ipnao, 9559)
		behaviorManagerProxy.runBehavior("caravanpalace")
	elif cmd == "grabobject":
		behaviorManagerProxy = ALProxy("ALBehaviorManager",config.ipnao, 9559)
		behaviorManagerProxy.runBehavior("grabObject")
	elif cmd == "lyingbelly":
		postureProxy = ALProxy("ALRobotPosture",config.ipnao, 9559)
		postureProxy.goToPosture("LyingBelly", 1)
		p = ALProxy("ALMotion",config.ipnao, 9559)
		p.rest()
	elif cmd == "lyingback":
		postureProxy = ALProxy("ALRobotPosture",config.ipnao, 9559)
		postureProxy.goToPosture("LyingBack", 1)
		p = ALProxy("ALMotion",config.ipnao, 9559)
开发者ID:Cydev2306,项目名称:NaoWebApp,代码行数:33,代码来源:walk.py

示例10: naoControl

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import runBehavior [as 别名]

#.........这里部分代码省略.........
    #  .. ip: STRING
    #  .. port: INT
    def setAddress(self,in_ip,in_port):
        self.ip = in_ip
        self.port = in_port



    # method to create proxies and initialize this object
    # TODO: get nao pose from naoqi and decide start conditions
    #       .. now we need to "stand up" to get stiff joints even if we start
    #       .. with nao already standing..
    def connect(self):
        # create Proxy to give motion commands
        self.motionproxy = ALProxy("ALMotion",self.ip,self.port)
        # create Proxy to call behaviors
        self.behaviorproxy = ALProxy("ALBehaviorManager", self.ip,self.port)        
        # create sensor object and share the motion proxy with it (connect(self))
        self.sensors = naoSensors.naoSensors()
        # give nao object to sensors, since it uses the same motionproxy
        self.sensors.connect(self)
        
        self.camera = naoCamera.naoCamera()
        self.camera.setAddress(self.ip,self.port)
        self.camera.connect()
        
        # read sensors, so that robot can start with current pose
        #  .. second parameter chooses if the value is read from the sensor or the last command
        # THOSE VALUES SHOULD COME FROM sensor object!
        #  .. change when implementation is done
        # SHOULD be OK now (changed to what it should be)
        self.headvalues = self.sensors.getHeadValues()
        #motionproxy.getAngles(self.headnames,True)
        self.armvalues = self.sensors.getRightArmValues()
        #self.motionproxy.getAngles(self.armnames,True)

        # set wich arm is free for balancing during walking
        self.setActiveArm("left")
        ## set Head to initial position
        #self.setHeadAngles(0,0)
        # TODO: better if this was "somewhere else"
        #self.motionproxy.stiffnessInterpolation("Body",1.0,0.5)
        self.motionproxy.stiffnessInterpolation("Head",1.0,0.5)
        print "!! press stand-up button !!"
        print "!!  If robot was already standing at start, just press stand-up button (default = left stick button) once to gain arm control"



    def setSimulatorSettings(self):
        self.maxAllowedJointDifference = 3
        self.fractionMaxSpeed = 0.3

    # method to choose the controllable arm
    #  .."left" or "right"
    # TODO: add mirrored armmovements, otherwise this function won't work correctly
    # CURRENTLY THIS METHOD DOESNT WORK FOR CHANGING THE REAL ACTIVE ARM
    #  .. armvalues need to be mirrored, checked and implemented for moveArm()
    #  .. and openHand() and closeHand()
    def setActiveArm(self,armstring):
        if (armstring == "left"):
            self.leftArmEnable = True
            self.rightArmEnable = False
        else:
            self.leftArmEnable = False
            self.rightArmEnable = True            
        self.motionproxy.setWalkArmsEnable(self.leftArmEnable, self.rightArmEnable)

        
        
    # method to set stiffness of whole robot body
    #  .. stiffnessvalue: FLOAT
    #  .. time: FLOAT
    def setStiffness(self,stiffnessvalue, time=0.5):
        # only allow to raise stiffness if nao is standing to avoid damaging motors by pushing against nao legs or body
        if ((self.robotStanding == 2) and (stiffnessvalue == 1.0)):
            self.stiffness = stiffnessvalue
            self.motionproxy.stiffnessInterpolation("Body",stiffnessvalue,time)
        # only allow lowering stiffness if sitting, to prevent nao from falling
        elif ((self.robotStanding == 0) and (stiffnessvalue == 0.0)):
            self.stiffness = stiffnessvalue
            self.motionproxy.stiffnessInterpolation("Body",stiffnessvalue,time)   
        #allow Head always to be moved
        self.motionproxy.stiffnessInterpolation("Head",1.0,time)


    # TODO: Include choregraphe behavior files & upload, if not available on nao
            
            
    # method to stand up fully, with legs in 'stable' position
    # .. needed after walking
    def stand(self):
        try:
            print "stand called"
            self.behaviorproxy.runBehavior("beineStrecken1")
            # set robotStanding to "fully standing"
            self.robotStanding = 2
            # allow moving arms
            self.setStiffness(1.0)
        except RuntimeError,e:
            print "could not run behavior! (beineStrecken1)"         
开发者ID:c0de2014,项目名称:nao-control,代码行数:104,代码来源:naoControl.py

示例11: NaoXO

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import runBehavior [as 别名]

#.........这里部分代码省略.........
        Then, calculate the 3D position for the tip of the arm in FRAME_ROBOT and which arm to use
        '''
        
        ## calculate the goal box
        if self.mode == 'x':
            [i,j] = strategija_x(self.board)
            self.goal = i*3+j
        else:
            [i,j] = strategija_o(self.board)
            self.goal = i*3+j
        
        ## obtain local transformation matrix from field points
        T_local = np.eye(4, 4, dtype=np.float64)
        T_local[0,3] = self.fieldPoints[0, self.goal]
        T_local[1,3] = self.fieldPoints[1, self.goal]
        T_local[2,3] = self.fieldPoints[2, self.goal]
        
        ## calculate transformation in FRAME_ROBOT
        T_global = np.dot(self.T_field, T_local)
        
        ## obtain 3D point from translation vector
        result = np.zeros((3,1), dtype=np.float64)
        result[0,0]=T_global[0,3]
        result[1,0]=T_global[1,3]
        result[2,0]=T_global[2,3]
        print("[INFO ] Calculated goal position of box %s: [%s, %s, %s]" % (self.goal+1, result[0,0], result[1,0], result[2,0]))
        
        ## calculate which arm to use
        nameEffector = 'RArm'
        nameHand = 'RHand'
        if self.goal == 0 or self.goal == 3 or self.goal == 6:
            nameEffector = 'LArm'
            nameHand = 'LHand'
            self.behavior.runBehavior('xo_animations-8894e3/request_token_left')
        else:
            self.behavior.runBehavior('xo_animations-8894e3/request_token_right')
        print("[INFO ] Using %s" % nameHand)
        
        ## Update the state of the game
        self.state[i*3+j] = self.mode
        if self.mode == 'x':
            self.board[i][j] = 1
        else:
            self.board[i][j] = 0

        return result, nameEffector, nameHand
    
    def playMove(self, nextMove):
        '''
        Moves nameHand with nameEffector to the goalPos using proxy to ALMotion
        TODO: rewrite to utilize PositionInterpolation method from ALMotion
        '''
        
        ## unpack next move
        goalPos = nextMove[0]
        nameEffector = nextMove[1]
        nameHand = nextMove[2]
        print("[INFO ] Put object in %s and touch arm tactile sensor" % nameHand)
        ## open hand
        self.motion.openHand(nameHand)
        ## wait for the object to be placed in the hand
        while True:
            if nameEffector == 'RArm':
                val1 = self.memory.getData("HandRightLeftTouched")
                val2 = self.memory.getData("HandRightBackTouched")
                val3 = self.memory.getData("HandRightRightTouched")
开发者ID:larics,项目名称:nao-xo,代码行数:70,代码来源:nao_xo.py

示例12: Tracker

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import runBehavior [as 别名]
class Tracker():

    def __init__(self):
	rospy.init_node('tracker_mykinect', anonymous=True)
	self.myFrame = 'kinect_link'
	self.r = rospy.Rate(20)		#rospy.Rate(1) = 1Hz
	
#Skeleton Listener
	self.tf = tf.TransformListener()
#Nao init and connect
	self.nao_init()
	self.startXPosition = 0.0;
	self.startYPosition = 0.0;
	self.naoXPosition = self.startXPosition
	self.naoYPosition = self.startYPosition
	rospy.loginfo("Start tracking for 3s...")
        rospy.sleep(3.0)
	rospy.loginfo("Tracking started!")
	self.hoh = 0.86 #Nao Hight in meters
	for i in range(1, 4):	
#Get all nessecery joins. (Right side = Left side if you stand front to sensor)		
		try:
			self.j_head = "{0}_{1}".format(rospy.get_param('~target_joint', '/head'), i)
			self.j_l_hand = "{0}_{1}".format(rospy.get_param('~target_joint', '/left_hand'), i) 
			self.j_r_hand = "{0}_{1}".format(rospy.get_param('~target_joint', '/right_hand'), i)
			self.j_l_shoul = "{0}_{1}".format(rospy.get_param('~target_joint', '/left_shoulder'), i)
			self.j_torso = "{0}_{1}".format(rospy.get_param('~target_joint', '/torso'), i)
			self.j_l_ehand = "{0}_{1}".format(rospy.get_param('~target_joint', '/left_elbow'), i)
			self.j_r_ehand = "{0}_{1}".format(rospy.get_param('~target_joint', '/right_elbow'), i)
			break
		except:
			pass
    
    def toRAD(self,angle):
	return angle*almath.TO_RAD

    def nao_init(self):
	#NAO CONNECT AND INIT
	# PORT AND IP NAO ROBOT
	#ip = rospy.get_param('~ip', '127.0.0.1')
	#port = int(rospy.get_param('~port', '51888'))
	ip = rospy.get_param('~ip', '10.104.16.53')
	port = int(rospy.get_param('~port', '9559'))

	self.al = ALProxy("ALAutonomousLife", ip, port)
	self.postureProxy = ALProxy("ALRobotPosture", ip, port)
	self.tts = ALProxy("ALTextToSpeech", ip, port)
	self.motionProxy = ALProxy("ALMotion", ip, port)
	self.behavior = ALProxy("ALBehaviorManager",ip,port)
	self.mistake = almath.Pose2D(self.motionProxy.getRobotPosition(False))
	#self.audioProxy = ALProxy("ALSpeechRecognition",ip,port)
	#self.audioProxy.setLanguage("English")
	#vocabulary = ["go"]
	#self.audioProxy.setVocabulary(vocabulary, False)
	#self.al.setState("disabled")
	#self.postureProxy.goToPosture("StandInit", 0.5)	
	#ALProxy("ALBasicAwareness", ip, port).stopAwareness()
	#self.motionProxy.setFallManagerEnabled(False)
	self.motionProxy.setExternalCollisionProtectionEnabled("All",False)

    def nao_hello(self):
#Nao hello module
	#self.postureProxy.goToPosture("StandInit",1.0)
	self.behavior.stopAllBehaviors()
	self.motionProxy.setAngles('RShoulderPitch',self.toRAD(-97.3),1.0)
	self.motionProxy.setAngles('RShoulderRoll',self.toRAD(-39.2),1.0)
	self.motionProxy.setAngles('RElbowRoll',self.toRAD(50.8),1.0)
	self.motionProxy.setAngles('RElbowYaw',self.toRAD(8.5),1.0)
	self.motionProxy.setAngles('RWristYaw',self.toRAD(-13.4),1.0)
	self.motionProxy.openHand('RHand')
	thread.start_new_thread((lambda:self.tts.say("Hello my friend")),())
	for i in range(0,2):
		self.motionProxy.angleInterpolation("RShoulderRoll",self.toRAD(-12.2),0.3,True)
		self.motionProxy.angleInterpolation("RShoulderRoll",self.toRAD(39.2),0.3,True)
		self.motionProxy.angleInterpolation("RShoulderRoll",self.toRAD(-50.4),0.3,True)
	
	self.postureProxy.goToPosture("StandInit",1.0)
	self.behavior.runBehavior('nao-14eaf5/BogdAL')


    def nao_sensei(self):
#Nao hello(sensei) module
	self.behavior.stopAllBehaviors()
	self.postureProxy.goToPosture("StandInit",1.0)
	
	self.motionProxy.setAngles(['RShoulderPitch','LShoulderPitch'],[self.toRAD(52.7),self.toRAD(49.1)],1.0)
	self.motionProxy.setAngles(['RShoulderRoll','LShoulderRoll'],[self.toRAD(13.3),self.toRAD(-8.9)],1.0)
	self.motionProxy.setAngles(['RElbowRoll','LElbowRoll'],[self.toRAD(88.3),self.toRAD(-87.6)],1.0)
	self.motionProxy.setAngles(['RElbowYaw','LElbowYaw'],[self.toRAD(68.1),self.toRAD(-60.9)],1.0)
	self.motionProxy.setAngles(['RWristYaw','LWristYaw'],[self.toRAD(-10.3),self.toRAD(11.0)],1.0)
	self.motionProxy.setAngles(['RHand','LHand'],[self.toRAD(-10.3),self.toRAD(11.0)],1.0)
	self.motionProxy.openHand('RHand')
	self.motionProxy.openHand('LHand')
	#sequence head
	self.tts.say("Domo Arigato")
	#self.motionProxy.angleInterpolation("HeadPitch",0.0,1.0,True)
	self.motionProxy.angleInterpolation("HeadPitch",self.toRAD(26.5),1.0,True)
	self.motionProxy.angleInterpolation("HeadPitch",0.0,1.0,True)
	
	self.postureProxy.goToPosture("StandInit",1)
#.........这里部分代码省略.........
开发者ID:PatrykBogd,项目名称:NaoMultimodalInteraction,代码行数:103,代码来源:dtrack.py

示例13: NaoMove

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

示例14: ALProxy

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import runBehavior [as 别名]
from naoqi import ALProxy

naoip = "192.168.1.67"
#naoip = "169.254.95.24"
#naoip = "172.20.10.5"
naopt = 9559

abm = ALProxy("ALBehaviorManager",naoip, naopt)
print abm.getInstalledBehaviors()

#amm = ALProxy("ALMemory", naoip, naopt);
#amm.insertData("walkx", "0.5")
#amm.insertData("walky", "0")
abm.runBehavior("Toggle Stand");
#abm.runBehavior("Tai Chi");
#abm.runBehavior("Walk XY")
#print amm.getData("walkx")
#print amm.getData("walky")
#amm.removeData("walkx")
#amm.removeData("walky")
#abm.runBehavior("Toggle Stand")

#apm = ALProxy("ALRobotPose", naoip, naopt)
#print apm.getPoseNames()
#print apm.getActualPoseAndTime()



开发者ID:spurkis,项目名称:Nao-Therapist,代码行数:27,代码来源:sit.py

示例15: print

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import runBehavior [as 别名]
                    elif key_map[button] == 'wake_up':
                        motion.wakeUp()
                    elif key_map[button] == 'rest':
                        motion.rest()
                    elif key_map[button] == 'enable':
                        print('Remote control disabled')
                        enabled = False
                        started = False
                    elif key_map[button] == 'say':
                        tts.say('Hello! I am NAO robot. I am here to inform you that I suck.')
                    elif key_map[button] == 'none':
                        pass
                    else:
                        try:
                            if motion.robotIsWakeUp():
                                behaviour.runBehavior(key_map[button])
                        except:
                            print('Behaviour %s not installed' % key_map[button])
                            raise
                if e.type == pygame.locals.JOYAXISMOTION and motion.robotIsWakeUp() and started:
                    x_turn, y_turn = dead_zone(-joy.get_axis(1), -joy.get_axis(0), 0.05)
                    theta = math.atan2(y_turn, x_turn)
                    x, y = dead_zone(-joy.get_axis(3), -joy.get_axis(2), 0.05)
                    motion.moveToward(x, y, theta/math.pi)
                if e.type == pygame.locals.JOYHATMOTION and started:
                    yaw, pitch = e.dict['value']

                    motion.changeAngles("HeadYaw", -yaw*0.087, 0.1)
                    motion.changeAngles("HeadPitch", -pitch*0.087, 0.1)

except KeyboardInterrupt:
开发者ID:larics,项目名称:nao-remote-control,代码行数:33,代码来源:remote_control.py


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