import gym
import gym_duckietown
import duckievillage
from duckievillage import DuckievillageEnv

env = DuckievillageEnv(
  seed = 101,
  map_name = './maps/udem1.yaml',
  draw_curve = False,
  draw_bbox = False,
  domain_rand = False,
  distortion = False,
  top_down = False
)
# Set mark-mode whenever we run waypoints.py with the -m or --mark-waypoints flag.
waypoints = duckievillage.Waypoints(env, '--read-from-file' in sys.argv)

state = "searching"
next_wp = None
turn_precision = .001
move_precision = .01

env.reset()
env.render()

@env.unwrapped.window.event
def on_key_press(symbol, mods):
  if symbol == key.ESCAPE:
    waypoints.write('waypoints.txt')
    env.close()
    sys.exit(0)
示例#2
0
        tile_dict[coord] = (pos, kind, tile)

    # itera sobre as tiles, e para cada tile, itera nas suas tiles adjacentes
    # para conectar as duas
    for tile1 in env.drivable_tiles:
        for v in get_adjacent(tile1, tile_dict):
            tile2 = v[0]
            way = v[1]
            connect_two_tiles(tile1, tile2, way, tile_dict)


key_handler = key.KeyStateHandler()
env.unwrapped.window.push_handlers(key_handler)
build_better_digraph()

waypoints = duckievillage.Waypoints(env, False)
goal = None
state = 'turn'
prev_dist = -1
dist = -1


def update(dt):
    action = [0.0, 0.0]
    global Q
    global goal
    global state
    global prev_dist
    global dist

    # This is where you'll write the Duckie's logic.