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


Python ALProxy.setExternalCollisionProtectionEnabled方法代码示例

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


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

示例1: main

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setExternalCollisionProtectionEnabled [as 别名]
def main(robotIP, PORT = 9559, steps=1):
    motionProxy = ALProxy("ALMotion", robotIP, PORT)
    postureProxy = ALProxy("ALRobotPosture", robotIP, PORT)
    
    motionProxy.wakeUp()
    postureProxy.goToPosture("StandInit", 0.5)
    motionProxy.setMoveArmsEnabled(True, True)
    motionProxy.setExternalCollisionProtectionEnabled("All", False)
    motionProxy.moveTo(steps / 4.0, 0, 0) # X, Y, Theta
开发者ID:icrl,项目名称:nico,代码行数:11,代码来源:move_forward.py

示例2: __walk_to

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setExternalCollisionProtectionEnabled [as 别名]
    def __walk_to(self, data):
        #self.__posture("Stand")
        motion = ALProxy("ALMotion", Settings.naoHostName, Settings.naoPort)
        motion.setMoveArmsEnabled( data['arms'], data['arms'] )
        
        self.__motionActive = True
        start_new_thread( self.__motion_background_task, () )

        collisionDetectionEnabled = motion.getExternalCollisionProtectionEnabled("Move")
        motion.setExternalCollisionProtectionEnabled("Move", False)
        motion.moveTo( data['x'], data['y'], radians(data['theta']) )
        motion.setExternalCollisionProtectionEnabled("Move", collisionDetectionEnabled) 
        
        self.__motionActive = False
开发者ID:Adriencerbelaud,项目名称:NAO-Communication-server,代码行数:16,代码来源:cmdPlayProgram.py

示例3: main

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

    motionProxy.wakeUp()
    postureProxy.goToPosture("StandInit", 0.5)
    motionProxy.setMoveArmsEnabled(True, True)
    motionProxy.setExternalCollisionProtectionEnabled("All", False)
    
    if turn == "left":
        theta = .5
    else:
        theta = -.5

    # X, Y, Theta, Freq
    motionProxy.setWalkTargetVelocity(0, 0, theta, 1)
    time.sleep(3.65)
    motionProxy.setWalkTargetVelocity(0, 0, 0, 0) # stop motion
开发者ID:icrl,项目名称:nico,代码行数:20,代码来源:turn.py

示例4: walk

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setExternalCollisionProtectionEnabled [as 别名]
    def walk(self):
        motionProxy = ALProxy("ALMotion")
        #http://doc.aldebaran.com/2-1/dev/python/making_nao_move.html?highlight=post#making-nao-move
        postureProxy = ALProxy("ALRobotPosture")

        # Wake up robot
        motionProxy.wakeUp()

        # Send robot to Stand Init
        postureProxy.goToPosture("StandInit", 1.0)
        time.sleep(1)
        motionProxy.setExternalCollisionProtectionEnabled("All", False)
        motionProxy.moveInit()
        #http://doc.aldebaran.com/2-1/dev/python/examples/motion/walk.html#move-to
        motionProxy.post.moveTo(0.5, 0, 0)
        #moveTo with post isn't a blocking call
        # Go to rest position

        postureProxy.goToPosture("Sit", 1.0)
开发者ID:afranka69,项目名称:ShowRobbie,代码行数:21,代码来源:NonBlockWalk2.py

示例5: walk

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setExternalCollisionProtectionEnabled [as 别名]
    def walk(self):
        motionProxy = ALProxy("ALMotion")
        #http://doc.aldebaran.com/2-1/dev/python/making_nao_move.html?highlight=post#making-nao-move
        postureProxy = ALProxy("ALRobotPosture")
        speechProxy = ALProxy("ALTextToSpeech")

        # Wake up robot
        motionProxy.wakeUp()

        # Send robot to Stand Init
        postureProxy.goToPosture("StandInit", 1.0)
        time.sleep(1)
        motionProxy.setExternalCollisionProtectionEnabled("All", False)
        motionProxy.moveInit()
        #http://doc.aldebaran.com/2-1/dev/python/examples/motion/walk.html#move-to
        motionProxy.post.moveTo(2.0, 0, 0)
        speechProxy.say("I have arrived.")
        #moveTo with post isn't a blocking call, as illustrated by him
        #saying "I have arrived" before actually arriving
        # Go to rest position
        postureProxy.goToPosture("Sit", 1.0)
开发者ID:afranka69,项目名称:ShowRobbie,代码行数:23,代码来源:NonBlockWalk.py

示例6: __init__

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

#.........这里部分代码省略.........
                        return


    # Nao walks close to ball
    def walkToBall(self, widget):
        ballPosition = self.tracker.getPosition()
        headYawTreshold = ((math.pi*10)/180)
        x = ballPosition[0]/2 + 0.05
        self.motion.stiffnessInterpolation("Body", 1.0, 0.1)
        self.motion.walkInit()
        self.turnToBall(self)
        self.motion.post.walkTo(x,0,0)
        while True:
            headYawAngle = self.motion.getAngles("HeadYaw", False)
            if headYawAngle[0] >= headYawTreshold or headYawAngle[0] <= -headYawTreshold:
                self.motion.stopWalk()
                self.turnToBall(self)
                self.walkToBall(self)
                break
            #dist = self.getDistance()
            # if dist < 0.1:
            #     self.motion.stopWalk()
            #     self.turnToBall()
            #     self.safePosition()
            #     time.sleep(1)
            #     self.tts.say("You have 5 seconds to move the ball")
            #     time.sleep(5)
            #     # naoWalkToPosition()
            #     self.walkToPosition()
            #     self.setTopCamera()
            #     break
                return


    # nao turns to ball 
    def turnToBall(self, widget):
        if not self.hasBall(self):
            return False
        self.ballPosition = self.tracker.getPosition()
        b = self.ballPosition[1]/self.ballPosition[0]
        z = math.atan(b)
        self.motion.stiffnessInterpolation("Body", 1.0, 0.1)
        self.motion.walkInit()
        self.motion.walkTo(0,0,z)


    # checks ball
    def checkForBall(self, widget):
        newdata = self.tracker.isNewData()
        if newdata == True:
            self.tracker.getPosition()
            return newdata
        if newdata == False:
            self.tracker.getPosition()
            return newdata


    # has to be called after walkToBall()
    def walkToPosition(self, widget):
        x = (self.targetPosition[0]/2)
        self.motion.walkTo(x,0,0)


    # Determine safe position
    def safePosition(self, widget):
        if self.hasBall():
            self.targetPosition = self.tracker.getPosition()
        else:
            return False


    # gets the distance from ball
    def getDistance(self, widget):
        if self.hasBall():
            ballPosition = self.tracker.getPosition()
            return math.sqrt(math.pow(ballPosition[0],2) + math.pow(ballPosition[1],2))


    # setting up top camera
    def setTopCamera(self, widget):
        self.vision.setParam(18,0)
        self.currentCamera = 0


    # setting up bottom camera
    def setBottomCamera(self, widget):
        self.vision.setParam(18,1)
        self.currentCamera = 1


    # protection off to move free
    def protectionOff(self, widget):
        self.motion.setExternalCollisionProtectionEnabled( "All", False )
        print "Protection Off"


    # protection on
    def protectionOn(self, widget):
        self.motion.setExternalCollisionProtectionEnabled( "All", True )
        print "Protection On"
开发者ID:muratarslan,项目名称:nao_ball_tracker,代码行数:104,代码来源:actions.py

示例7: ALProxy

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setExternalCollisionProtectionEnabled [as 别名]
        print "Could not create proxy to ALMotion"
        print "Error was: ", e

    try:
        postureProxy = ALProxy("ALRobotPosture", robotIP, PORT)
    except Exception, e:
        print "Could not create proxy to ALRobotPosture"
        print "Error was: ", e

    try:
        ledsProxy = ALProxy("ALLeds", robotIP, PORT)
    except Exception, e:
        print "Could not create proxy to ALLeds"
        print "Error was: ", e

    motionProxy.setExternalCollisionProtectionEnabled("Move", False)

    # Init robot position.
    initRobotPosition(motionProxy, postureProxy)

    # Wait for the user to press the front tactile sensor.
    print "Please press head front tactile sensor to start."
    while not memoryProxy.getData("FrontTactilTouched"):
        pass

    print "To guide the robot use the robot left arm."
    print "Move LShoulderPitch to set x, y target and move LWristYaw to set wz target."
    print "When the robot eyes are green, the robot is ready to move."

    print "Starting..."
    print "Please press head rear tactile sensor to stop."
开发者ID:L-SEG,项目名称:PythonAndNao,代码行数:33,代码来源:almath_robot_guide.py

示例8: ALProxy

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


#will be addressed via shell file 

argvs = sys.argv 
ip = argvs[1]
port = 9559

try:
	motion_proxy = ALProxy('ALMotion',ip,port)
except:
	quit()

motion_proxy.wakeUp()
motion_proxy.setExternalCollisionProtectionEnabled('All', False)

try:
	leds = ALProxy("ALLeds", ip, port)
except Exception as e:
	quit()

#led controller
def onLed(group, r, g, b, duration):
	# file:///Applications/Choregraphe.app/Contents/Resources/share/doc/naoqi/sensors/alleds.html
	leds.fadeRGB(group, r, g, b, duration)

# change LED to color to white
onLed('RightFaceLeds', 1.0, 1.0, 1.0, 0.0)
onLed('LeftFaceLeds', 1.0, 1.0, 1.0, 0.0)
onLed('ChestLeds', 1.0, 1.0, 1.0, 0.0)
开发者ID:yasushisakai,项目名称:AHD-salt-examples,代码行数:32,代码来源:wake_up.py

示例9: Tracker

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

示例10: TalkingBot

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

#.........这里部分代码省略.........

		global iAmGlobal
		iAmGlobal = self
		print iAmGlobal
		print participantName
		##############################
		# connec to NAO

		#add self to touch events
		#global reactToTouch
		#reactToTouch.setThread(self)
		
		self.decision = None
		self.robotIP = robotIP
		self.PORT = PORT
		self.participantName = participantName
		self.volume = volume

		self.tts  = ALProxy("ALAnimatedSpeech", robotIP, PORT)
		self.motion = ALProxy("ALMotion", robotIP, PORT)
		self.posture = ALProxy("ALRobotPosture", robotIP, PORT)
		self.vol = ALProxy("ALAudioDevice", robotIP, PORT)
		self.video = ALProxy("ALVideoDevice", robotIP, PORT)
		self.autonomousMoves = ALProxy("ALAutonomousMoves", robotIP, PORT)
		self.compass = ALProxy("ALVisualCompass", robotIP, PORT)
		self.markProxy = ALProxy("ALLandMarkDetection", robotIP, PORT)
		self.memProxy = ALProxy("ALMemory", robotIP, PORT)
		self.behave = ALProxy("ALBehaviorManager", robotIP, PORT)
		
		self.markProxy.subscribe("Test_LandMark", 500, 0.0 )
		#json_data=open('randomSeceneDataSet.json')
		#data = json.load(json_data)
		self.data = cjson.parse_json('randomSeceneDataSet.json')
		self.motion.setExternalCollisionProtectionEnabled("All", False)
		self.motion.setOrthogonalSecurityDistance(0.0)
		self.motion.setTangentialSecurityDistance(0.0)
		self.autonomousMoves.setExpressiveListeningEnabled(False)
		#print(data)


		#ReactToTouch.setThread(self)

		self.wakeRobotUp()
		self.vol.setOutputVolume(volume)
		#self.goToPerson(str(participantName))
		self.walkTo(int(user_id), True)
		


		##############################
		# Activity should be later. This is just for now
		
		self.data["activity"]
		self.maxActivies = []


		for a in self.data["activity"]:
			
			t = {
				"name":a["name"],
				"animation":a["animation"],
				"file":a["file"],
				"time":a["time"],
				"text":None
			}
开发者ID:BrandiATMuhkuh,项目名称:NAOatFUSE,代码行数:69,代码来源:tryJson.py

示例11: __init__

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setExternalCollisionProtectionEnabled [as 别名]
class RobotController:
	def __init__(self, ip, port, simulation_mode=True):
		self.ip = ip
		self.port = port
		self.camProxy = ALProxy("ALVideoDevice", self.ip, self.port)
		self.postureProxy = ALProxy("ALRobotPosture", self.ip, self.port)
		self.motionProxy = ALProxy("ALMotion", self.ip, self.port)
		self.memoryProxy = ALProxy("ALMemory", self.ip, self.port)
		self.blobProxy = ALProxy("ALColorBlobDetection", self.ip, self.port)
		self.trackerProxy = ALProxy("ALTracker", self.ip, self.port)
		self.ttsProxy = ALProxy("ALTextToSpeech", self.ip, self.port)
		self.broker = ALBroker("pythonMotionBroker", "0.0.0.0", 0, 
			self.ip, self.port)

		if simulation_mode == False:
			self.autolifeProxy = ALProxy("ALAutonomousLife", self.ip, self.port)
			self.autolifeProxy.setState("disabled")

		self.topCamera = self.camProxy.subscribeCamera("topCamera_pycli", 
			0, vision_definitions.kVGA, vision_definitions.kBGRColorSpace,
			framerate)
		self.bottomCamera = self.camProxy.subscribeCamera(
			"bottomCamera_pycli", 1, vision_definitions.kQQVGA, 
			vision_definitions.kBGRColorSpace, framerate)

		self.motionProxy.wakeUp()
		self.enableExternalCollisionProtection()
		self.postureProxy.goToPosture("StandInit", 1.0)

	def stiffnessOn(self):
		# We use the "Body" name to signify the collection of all joints
		pNames = "Body"
		pStiffnessLists = 1.0
		pTimeLists = 1.0
		self.motionProxy.stiffnessInterpolation(pNames, pStiffnessLists, 
			pTimeLists)

	def stiffnessOff(self):
		# We use the "Body" name to signify the collection of all joints
		pNames = "Body"
		pStiffnessLists = 0.0
		pTimeLists = 1.0
		self.motionProxy.stiffnessInterpolation(pNames, pStiffnessLists, 
			pTimeLists)

	def enableArmCollisionProtection(self):
		chainName = "Arms"
		enable  = True
		isSuccess = self.motionProxy.setCollisionProtectionEnabled(chainName, 
			enable)
		pprint("Anticollision activation on arms: " + str(isSuccess))

	def disableArmCollisionProtection(self):
		chainName = "Arms"
		enable  = False
		isSuccess = self.motionProxy.setCollisionProtectionEnabled(chainName, 
			enable)
		pprint("Anticollision deactivation on arms: " + str(isSuccess))

	def enableExternalCollisionProtection(self):
		self.motionProxy.setExternalCollisionProtectionEnabled("All", True)

	def disableExternalCollisionProtection(self):
		self.motionProxy.setExternalCollisionProtectionEnabled("All", False)

	def headRotateAbsolute(self, degrees):
		# Example showing a single target angle for one joint
		# Interpolate the head yaw to 15 degrees in 1.0 second
		names      = "HeadYaw"
		angleLists = degrees*almath.TO_RAD
		timeLists  = 1.0 if (degrees == 0.0) else abs(15.0/degrees)
		isAbsolute = True
		self.motionProxy.angleInterpolation(names, angleLists, timeLists, 
			isAbsolute)

	def headPitchAbsolute(self, degrees):
		# Example showing a single target angle for one joint
		# Interpolate the head pitch to 15 degrees in 1.0 second
		names      = "HeadPitch"
		angleLists = degrees*almath.TO_RAD
		timeLists  = 1.0 if (degrees == 0.0) else abs(15.0/degrees)
		isAbsolute = True
		self.motionProxy.angleInterpolation(names, angleLists, timeLists, 
			isAbsolute)	

	def bodyRotateAbsolute(self, degrees):
		self.motionProxy.moveTo(0.0, 0.0, degrees*almath.TO_RAD)

	def bodyWalkForward(self, distance):
		self.motionProxy.moveTo(distance, 0.0, 0.0)

	def takePicture(self, camera):
		naoImage = self.camProxy.getImageRemote(camera)

		# Get the image size and pixel array.
		imageWidth = naoImage[0]
		imageHeight = naoImage[1]
		timestampUS = naoImage[5]
		array = naoImage[6]
		cameraID = naoImage[7]
#.........这里部分代码省略.........
开发者ID:aearm,项目名称:NAOFindingObjects,代码行数:103,代码来源:NAOFindingObjects.py

示例12: Nao

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

#.........这里部分代码省略.........
                        return


    # Nao walks close to ball
    def walkToBall(self):
        ballPosition = self.tracker.getPosition()
        headYawTreshold = ((math.pi*10)/180)
        x = ballPosition[0]/2 + 0.05
        self.motion.stiffnessInterpolation("Body", 1.0, 0.1)
        self.motion.walkInit()
        self.turnToBall()
        self.motion.post.walkTo(x,0,0)
        while True:
            headYawAngle = self.motion.getAngles("HeadYaw", False)
            if headYawAngle[0] >= headYawTreshold or headYawAngle[0] <= -headYawTreshold:
                self.motion.stopWalk()
                self.turnToBall()
                self.walkToBall()
                break
            #dist = self.getDistance()
            # if dist < 0.1:
            #     self.motion.stopWalk()
            #     self.turnToBall()
            #     self.safePosition()
            #     time.sleep(1)
            #     self.tts.say("You have 5 seconds to move the ball")
            #     time.sleep(5)
            #     # naoWalkToPosition()
            #     self.walkToPosition()
            #     self.setTopCamera()
            #     break
                return


    # nao turns to ball 
    def turnToBall(self):
        if not self.hasBall():
            return False
        self.ballPosition = self.tracker.getPosition()
        b = self.ballPosition[1]/self.ballPosition[0]
        z = math.atan(b)
        self.motion.stiffnessInterpolation("Body", 1.0, 0.1)
        self.motion.walkInit()
        self.motion.walkTo(0,0,z)


    # checks ball
    def checkForBall(self):
        newdata = self.tracker.isNewData()
        if newdata == True:
            self.tracker.getPosition()
            return newdata
        if newdata == False:
            self.tracker.getPosition()
            return newdata


    # has to be called after walkToBall()
    def walkToPosition(self):
        x = (self.targetPosition[0]/2)
        self.motion.walkTo(x,0,0)


    # Determine safe position
    def safePosition(self):
        if self.hasBall():
            self.targetPosition = self.tracker.getPosition()
        else:
            return False


    # gets the distance from ball
    def getDistance(self):
        if self.hasBall():
            ballPosition = self.tracker.getPosition()
            return math.sqrt(math.pow(ballPosition[0],2) + math.pow(ballPosition[1],2))


    # setting up top camera
    def setTopCamera(self):
        self.vision.setParam(18,0)
        self.currentCamera = 0


    # setting up bottom camera
    def setBottomCamera(self):
        self.vision.setParam(18,1)
        self.currentCamera = 1


    # protection off to move free
    def protectionOff(self):
        self.motion.setExternalCollisionProtectionEnabled( "All", False )
        print "Protection Off"


    # protection on
    def protectionOn(self):
        self.motion.setExternalCollisionProtectionEnabled( "All", True )
        print "Protection On"
开发者ID:muratarslan,项目名称:nao_ball_tracker,代码行数:104,代码来源:ball.py


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