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


Python Robot.extend方法代码示例

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


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

示例1: Robot

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

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)
开发者ID:notclive,项目名称:ICT-Club,代码行数:32,代码来源:ExampleIntruder.py

示例2: Robot

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

示例3: Robot

# 需要导入模块: from Robot import Robot [as 别名]
# 或者: from Robot.Robot import extend [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 "Robot2"
robot = Robot('ICTCLUB2')
robot.extend(Light(PORT_3))

i = 0
while i < 60 :
  robot.lightred()
  sleep(1)
  robot.lightblue()
  sleep(1)
  i=i+1
robot.lightoff()
robot.__del__()
开发者ID:notclive,项目名称:ICT-Club,代码行数:25,代码来源:Test2.py

示例4: Robot

# 需要导入模块: from Robot import Robot [as 别名]
# 或者: from Robot.Robot import extend [as 别名]
import sys
import curses
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

from pygame.locals import *
from Keyboard import KeyboardController

robot = Robot('ICTCLUB4')
robot.extend(Mover(PORT_C, PORT_B))
robot.extend(Light(PORT_4))
robot.extend(Sonar(PORT_3))
robot.extend(Shooter(PORT_A))

def forward():
    robot.forward(2,99)
    
def stop():
    print 'stop'
    
def shoot():
    robot.shoot()
    
def turnleft():
    robot.startturningleft(30)
开发者ID:notclive,项目名称:ICT-Club,代码行数:33,代码来源:KeyboardExample.py

示例5: Robot

# 需要导入模块: from Robot import Robot [as 别名]
# 或者: from Robot.Robot import extend [as 别名]
import sys
from time import sleep
from Robot import Robot
from RemoteControl import RemoteControl
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(RemoteControl(PORT_1,1))

# Program start

while 1==1 :
  print str(robot.red()) + "," + str(robot.blue())

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

示例6: Robot

# 需要导入模块: from Robot import Robot [as 别名]
# 或者: from Robot.Robot import extend [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 "Robot3"
robot = Robot('ICTCLUB3')
robot.extend(Mover(PORT_B, PORT_C))

robot.forwards(20,200)
robot.turnright(5,50)
robot.turnleft(5,50)
robot.forwards(5,50)
开发者ID:rhodri,项目名称:ICT-Club,代码行数:20,代码来源:Jack.py


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