Exemplo n.º 1
0
def convert_scenario_name_number(measurements):
    scenario = identify_scenario(measurements['distance_intersection'],
                                 measurements['road_angle'])
    if scenario == 'S0_lane_following':
        return [1, 0, 0, 0]
    elif scenario == 'S1_lane_following_curve':
        return [0, 1, 0, 0]
    elif scenario == 'S2_before_intersection':
        return [0, 0, 1, 0]
    elif scenario == 'S3_intersection':
        return [0, 0, 0, 1]
    else:
        raise ValueError(f'Unexpected scenario identified: {scenario}')
Exemplo n.º 2
0
def test_identification(world, N=100):
    # I will spawn N vehicles

    blueprint_library = world.get_blueprint_library()
    spawn_points = world.get_map().get_spawn_points()
    blueprint = random.choice(blueprint_library.filter('vehicle*'))
    capture = time.time()
    count = 1
    for point in spawn_points[:N]:
        vehicle = world.try_spawn_actor(blueprint, point)
        if vehicle is None:
            continue
        print("Spawn pont %d distance %f scenario %s " %
              (count,
               distance_to_intersection(
                   vehicle, world.get_map(),
                   resolution=0.1), identify_scenario(vehicle)))
        count += 1

    print("Took  %f  seconds " % ((time.time() - capture) / count))
                                no_display=True)

                        status = {
                            'speed':
                            forward_speed(
                                data_point['measurements']['ego_actor']),
                            'directions':
                            2.0,
                            'distance_intersection':
                            data_point['measurements']
                            ['distance_intersection'],
                            'road_angle':
                            data_point['measurements']['road_angle'],
                            'scenario':
                            identify_scenario(
                                data_point['measurements']
                                ['distance_intersection'],
                                data_point['measurements']['road_angle'])
                        }

                        # if we make video we set something for output image
                        if args.make_videos:
                            output_image = os.path.join(
                                '_tmp_img',
                                'image' + str(count_images).zfill(5) + '.png')
                        else:
                            output_image = None

                        screen.plot_camera_steer(rgb_left,
                                                 screen_position=[0, 0])
                        screen.plot_camera_steer(rgb_center,
                                                 control=None,