Exemplo n.º 1
0
    def __init__(self, client: carla.Client):
        print("Available Maps:")
        print(client.get_available_maps())
        client.load_world('Town04')
        client.reload_world()
        self.carla_world: carla.World = client.get_world()
        blueprint_library: carla.BlueprintLibrary = self.carla_world.get_blueprint_library(
        )

        # Create vehicle
        vehicle_bp = blueprint_library.filter('vehicle.citroen.c3')[0]
        spawn_point = self.carla_world.get_map().get_spawn_points()[86]
        self.ego_vehicle: carla.Vehicle = self.carla_world.spawn_actor(
            vehicle_bp, spawn_point)
        self.ego_vehicle.set_autopilot(False)

        for idx, waypoint in enumerate(
                self.carla_world.get_map().get_spawn_points()):
            self.carla_world.debug.draw_string(waypoint.location,
                                               str(idx),
                                               draw_shadow=False,
                                               color=carla.Color(r=255,
                                                                 g=0,
                                                                 b=0),
                                               life_time=1000,
                                               persistent_lines=True)

        # Move spectator cam into a topview close to the spawn point
        self.carla_world.get_spectator().set_transform(
            carla.Transform(
                self.ego_vehicle.get_location() +
                carla.Location(x=0, y=-10, z=100.0),
                carla.Rotation(pitch=-80)))

        self.create_traffic(client, [88, 84, 73, 357])
Exemplo n.º 2
0
def prepare_ngsim_scenario(client: carla.Client) -> Scenario:
    data_dir = os.environ.get("NGSIM_DIR")
    assert data_dir, "Path to the directory with NGSIM dataset is required"
    ngsim_map = NGSimDatasets.list()
    ngsim_dataset = random.choice(ngsim_map)
    client.load_world(ngsim_dataset.carla_map.level_path)
    return NGSimLaneChangeScenario(
        ngsim_dataset,
        dataset_mode=DatasetMode.TRAIN,
        data_dir=data_dir,
        reward_type=RewardType.DENSE,
        client=client,
    )
Exemplo n.º 3
0
def prepare_opendd_scenario(client: carla.Client) -> Scenario:
    data_dir = os.environ.get("OPENDD_DIR")
    assert data_dir, "Path to the directory with openDD dataset is required"
    maps = ["rdb1", "rdb2", "rdb3", "rdb4", "rdb5", "rdb6", "rdb7"]
    map_name = random.choice(maps)
    carla_map = getattr(CarlaMaps, map_name.upper())
    client.load_world(carla_map.level_path)
    return OpenDDScenario(
        client,
        dataset_dir=data_dir,
        dataset_mode=DatasetMode.TRAIN,
        reward_type=RewardType.DENSE,
        place_name=map_name,
    )
Exemplo n.º 4
0
from carla import LaneMarking

import carla

import random
import time
import math
import sys

# starting proper work now

print('attempting to connect...')  # DEBUG
client = Client('localhost', 2000, worker_threads=12)
client.set_timeout(10.0)

client.load_world('/Game/Carla/Maps/single_left_bend')
print('connected!')  # DEBUG

world = client.get_world()
# ##################################################
# Change weather for data collection
# ClearNoon, ClearSunset, WetSunset, WetNoon
world.set_weather(carla.WeatherParameters.WetSunset)

# ##################################################
# bp of all actors
blueprint_lib = world.get_blueprint_library()

vehicle_bp = blueprint_lib.find('vehicle.audi.tt')
lane_invasion_sensor_bp = blueprint_lib.find('sensor.other.lane_invasion')