Exemple #1
0
def run_path_follower(args, camera_rigs):
    """
    Runs the C++ PID-based path follower agent which uses a reference
    spline in the center of the lane, and speed annotations on tight turns
    to drive.

    Or on new maps a behavior tree based agent is used with communication
    between agents.

    Refer to https://github.com/deepdrive/deepdrive-sim/tree/b21e0a0bf8cec60538425fa41b5fc5ee28142556/Plugins/DeepDrivePlugin/Source/DeepDrivePlugin/Private/Simulation/Agent
    """
    done = False
    gym_env = None
    try:
        sim_args = get_sim_args_from_command_args(args)
        if sim_args is not None:
            sim_args = sim_args.to_dict()
        else:
            sim_args = {}
        cameras = camera_rigs
        if isinstance(camera_rigs[0], list):
            cameras = cameras[0]
        sim_args['cameras'] = cameras
        gym_env = sim.start(**sim_args)
        log.info('Path follower drive mode')
        episode_num = 0
        info = {}

        def should_stop(index, step_info):
            if dbox(step_info).should_close:
                return True
            elif args.max_episodes:
                return index >= args.max_episodes
            else:
                return False

        while not should_stop(episode_num, info):
            episode_num += 1
            done = False
            while not done:
                action = sim.action(has_control=False)
                obz, reward, done, info = gym_env.step(action)
                if done:
                    gym_env.reset()
    except KeyboardInterrupt:
        log.info('keyboard interrupt detected, closing')
    except Exception as e:
        log.error('Error running agent. %s', e)
        print(traceback.format_exc())
    else:
        log.info('Last episode complete, closing')
    finally:
        if gym_env:
            gym_env.close()
Exemple #2
0
def main():
    # TODO: Add some asserts and get working on Jenkins
    env = sim.start(is_sync=True)
    forward = sim.action(throttle=1, steering=0, brake=0)
    done = False
    i = 0
    while 1:
        i += 1
        observation, reward, done, info = env.step(forward)
        if i % 10 == 0:
            env.reset()
Exemple #3
0
def main():
    env = sim.start(

        # map can be canyons, kevindale, kevindale_bare, or jamestown
        map='kevindale_bare',

        # scenario can be 0 => 5 - Scenario descriptions:
        # https://gist.github.com/crizCraig/855a5cc4bc96fc2765cb9bf5d6f953b4
        scenario_index=1)
    forward = sim.action(throttle=0.75, steering=0, brake=0)
    done = False
    while not done:
        observation, reward, done, info = env.step(forward)
    env.close()