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


Python Robot.howfar方法代码示例

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


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

示例1: Robot

# 需要导入模块: from Robot import Robot [as 别名]
# 或者: from Robot.Robot import howfar [as 别名]
from Sonar import Sonar
from nxt.motor import PORT_A, PORT_B, PORT_C
from nxt.sensor import PORT_4, PORT_3, PORT_2, PORT_1

robot = Robot('ICTCLUB2')
robot.extend(Mover(PORT_C, PORT_B))
robot.extend(Light(PORT_3))
robot.extend(Sonar(PORT_1))

# Program start

# start turning left at power = 10%
robot.startturningleft(10)

# every 0.5 seconds print out how far nearest item is while nearest item is > 100cm away
while robot.howfar() > 100:
  print robot.howfar()
  sleep(0.5)

# Something is < 100cm away so stop and shine the red light
print "Intruder"
robot.stopmoving()
robot.lightred()
sleep(5)

# turn the light off and shutdown
robot.lightoff()
print "Stop"

robot.__del__()
开发者ID:notclive,项目名称:ICT-Club,代码行数:32,代码来源:ExampleIntruder.py

示例2: Robot

# 需要导入模块: from Robot import Robot [as 别名]
# 或者: from Robot.Robot import howfar [as 别名]
import sys
from time import sleep
from Robot import Robot
from Mover import Mover
from Shooter import Shooter
from Light import Light
from Sonar import Sonar
from nxt.motor import PORT_A, PORT_B, PORT_C
from nxt.sensor import PORT_4, PORT_3, PORT_2, PORT_1

print "Robot4"
robot = Robot('ICTCLUB4')
robot.extend(Light(PORT_3))
robot.extend(Mover(PORT_B, PORT_C))
robot.extend(Sonar(PORT_1))

#Program starts here
for x in range(10,10000):
	robot.forward(0.1,80)
	if robot.howfar() < 40 :
		robot.turnright(4,80)
        
robot.__del__()
开发者ID:notclive,项目名称:ICT-Club,代码行数:25,代码来源:Freddie-Walrus.py

示例3: Robot

# 需要导入模块: from Robot import Robot [as 别名]
# 或者: from Robot.Robot import howfar [as 别名]
import sys
from time import sleep
from Robot import Robot
from Mover import Mover
from Shooter import Shooter
from Light import Light
from Sonar import Sonar
from nxt.motor import PORT_A, PORT_B, PORT_C
from nxt.sensor import PORT_4, PORT_3, PORT_2, PORT_1


print "Robot"
robot = Robot('ICTCLUB6')
robot.extend(Light(PORT_3))
robot.extend(Mover(PORT_B, PORT_C))
robot.extend(Sonar(PORT_1))

for x in range(1,100):
	print robot.howfar()
	sleep(0.1)

robot.__del__()
开发者ID:rhodri,项目名称:ICT-Club,代码行数:24,代码来源:SonarTest.py

示例4: Robot

# 需要导入模块: from Robot import Robot [as 别名]
# 或者: from Robot.Robot import howfar [as 别名]
import sys
from time import sleep
from Robot import Robot
from Mover import Mover
from Shooter import Shooter
from Light import Light
from Sonar import Sonar
from nxt.motor import PORT_A, PORT_B, PORT_C
from nxt.sensor import PORT_4, PORT_3, PORT_2, PORT_1

print "Robot4"
robot = Robot('ICTCLUB4')
robot.extend(Light(PORT_3))
robot.extend(Mover(PORT_B, PORT_C))

a=1
while a == 1:
 robot.forward(1,50)
 if robot.howfar() < 10:
  robot.turnleft(1,50)

robot.__del__()
开发者ID:notclive,项目名称:ICT-Club,代码行数:24,代码来源:WMP.py


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