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


Python Car.stop方法代码示例

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


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

示例1: test_system

# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import stop [as 别名]
def test_system():
    straight = raw_input("Drive straight? ")
    path = Preset.STRAIGHT if straight == 'y' else None
    if not path:
        path = Preset.COUNTER_CLOCKWISE_CIRCLE if raw_input("Counter clockwise? ") == 'y' else path
    car = Car(path=path)
    car.start()
    try:
        raw_input("Running... press enter to start driving\n")
        car._driver.go()
        raw_input('Press enter to stop...')
    except KeyboardInterrupt:
        pass
    car.stop()
    print "Done"
开发者ID:jlucier,项目名称:6.S062-car-swarm,代码行数:17,代码来源:tests.py

示例2: mainloop

# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import stop [as 别名]
 def mainloop(self, port):
     sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     sck.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     sck.bind(('0.0.0.0', port))
     sck.listen(1)
     sck.setblocking(0)
     dt = datetime.datetime.now()
     idle = 0
     while True:
         try:
             client, addr = sck.accept()
             client.setblocking(0)
         except socket.error:
             time.sleep(0.1)
             continue
         while True:
             try:
                 t = client.recv(1)
                 if len(t) == 1: char = ord(t)
                 elif len(t) == 0: 
                     break
             except socket.error:
                 char = -1
             if char != -1:
                 if char == ord('d'): Car.right()
                 elif char == ord('a'): Car.left()
                 elif char == ord('w'):
                     if True or not bb.is_blocked(): 
                         Car.up()
                     else:
                         Car.stop()
                 elif char == ord('s'): Car.down()
                 elif char == ord('q'): Car.stop()
                 dt = datetime.datetime.now()
                 idle = 0
             elif idle >= 2:
                 if Car.moving: 
                     Car.stop() 
                 else:
                     time.sleep(0.1)
             else: 
                 idle += 1
                 time.sleep(0.1)
开发者ID:stewartpark,项目名称:raspi_car,代码行数:45,代码来源:remote.py

示例3: test_car_stop

# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import stop [as 别名]
def test_car_stop():
    road = Road()
    car = Car(road)
    assert car.speed == 15
    car.stop()
    assert car.speed == 0
开发者ID:jwaldrep,项目名称:traffic-simulation,代码行数:8,代码来源:test_car.py


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