本文整理汇总了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__()
示例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__()
示例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__()
示例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__()