Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
poses_tasks = self._poses()
vehicles_tasks = [0, 15, 70]
pedestrians_tasks = [0, 50, 150]
task_names = ['empty', 'normal', 'cluttered']
experiments_vector = []
for weather in self.weathers:
for iteration in range(len(poses_tasks)):
poses = poses_tasks[iteration]
vehicles = vehicles_tasks[iteration]
pedestrians = pedestrians_tasks[iteration]
conditions = CarlaSettings()
conditions.set(
SendNonPlayerAgentsInfo=True,
NumberOfVehicles=vehicles,
NumberOfPedestrians=pedestrians,
WeatherId=weather
)
conditions.set(DisableTwoWheeledVehicles=True)
# Add all the cameras that were set for this experiments
conditions.add_sensor(camera)
experiment = Experiment()
experiment.set(
Conditions=conditions,
Poses=poses,
def default_settings():
settings = CarlaSettings()
settings.set(
SynchronousMode=True,
SendNonPlayerAgentsInfo=True,
NumberOfVehicles=0,
NumberOfPedestrians=0,
WeatherId=1, # random.choice([1, 3, 7, 8, 14]),
PlayerVehicle='/Game/Blueprints/Vehicles/Mustang/Mustang.Mustang_C',
QualityLevel='Epic')
settings.randomize_seeds()
camera_RGB = Camera('CameraRGB')
camera_RGB.set_image_size(256, 256)
camera_RGB.set_position(1, 0, 2.50)
settings.add_sensor(camera_RGB)
camera_seg = Camera('CameraSegmentation', PostProcessing='SemanticSegmentation')
def default_settings():
settings = CarlaSettings()
settings.set(
SynchronousMode=True,
SendNonPlayerAgentsInfo=True,
NumberOfVehicles=0,
NumberOfPedestrians=0,
WeatherId=1, # random.choice([1, 3, 7, 8, 14]),
PlayerVehicle='/Game/Blueprints/Vehicles/Mustang/Mustang.Mustang_C',
QualityLevel='Epic')
settings.randomize_seeds()
camera_RGB = Camera('CameraRGB')
camera_RGB.set_image_size(256, 256)
camera_RGB.set_position(1, 0, 2.50)
settings.add_sensor(camera_RGB)
camera_seg = Camera('CameraSegmentation', PostProcessing='SemanticSegmentation')
def setup_carla_client(self, client, params):
self.client = client
self.param_sensors = params.get('sensors', {})
self.carla_settings = CarlaSettings()
self.carla_settings.set(
SendNonPlayerAgentsInfo=params.get('SendNonPlayerAgentsInfo', True),
NumberOfVehicles=params.get('NumberOfVehicles', 20),
NumberOfPedestrians=params.get('NumberOfPedestrians', 40),
WeatherId=params.get('WeatherId', random.choice([1, 3, 7, 8, 14])),
SynchronousMode=params.get('SynchronousMode', True),
QualityLevel=params.get('QualityLevel', 'Low')
)
self.carla_settings.randomize_seeds()
def reset_env(self):
self.num_steps = 0
self.total_reward = 0
self.prev_measurement = None
self.prev_image = None
self.episode_id = datetime.today().strftime("%Y-%m-%d_%H-%M-%S_%f")
self.measurements_file = None
# Create a CarlaSettings object. This object is a wrapper around
# the CarlaSettings.ini file. Here we set the configuration we
# want for the new episode.
settings = CarlaSettings()
# If config["scenarios"] is a single scenario, then use it if it's an array of scenarios, randomly choose one and init
if isinstance(self.config["scenarios"],dict):
self.scenario = self.config["scenarios"]
else: #isinstance array of dict
self.scenario = random.choice(self.config["scenarios"])
assert self.scenario["city"] == self.city, (self.scenario, self.city)
self.weather = random.choice(self.scenario["weather_distribution"])
settings.set(
SynchronousMode=True,
SendNonPlayerAgentsInfo=True,
NumberOfVehicles=self.scenario["num_vehicles"],
NumberOfPedestrians=self.scenario["num_pedestrians"],
WeatherId=self.weather)
settings.randomize_seeds()
if self.config["use_depth_camera"]:
def make_carla_settings(args):
"""Make a CarlaSettings object with the settings we need."""
settings = CarlaSettings()
settings.set(
SynchronousMode=False,
SendNonPlayerAgentsInfo=True,
NumberOfVehicles=15,
NumberOfPedestrians=30,
WeatherId=random.choice([1, 3, 7, 8, 14]),
QualityLevel=args.quality_level)
settings.randomize_seeds()
camera0 = sensor.Camera('CameraRGB')
camera0.set_image_size(WINDOW_WIDTH, WINDOW_HEIGHT)
camera0.set_position(2.0, 0.0, 1.4)
camera0.set_rotation(0.0, 0.0, 0.0)
settings.add_sensor(camera0)
camera1 = sensor.Camera('CameraDepth', PostProcessing='Depth')
camera1.set_image_size(MINI_WINDOW_WIDTH, MINI_WINDOW_HEIGHT)
camera1.set_position(2.0, 0.0, 1.4)
# host:port. To create a connection we can use the `make_carla_client`
# context manager, it creates a CARLA client object and starts the
# connection. It will throw an exception if something goes wrong. The
# context manager makes sure the connection is always cleaned up on exit.
with make_carla_client(host, port) as client:
print('CarlaClient connected')
for episode in range(0, number_of_episodes):
# Start a new episode.
if settings_filepath is None:
# Create a CarlaSettings object. This object is a wrapper around
# the CarlaSettings.ini file. Here we set the configuration we
# want for the new episode.
settings = CarlaSettings()
settings.set(
SynchronousMode=True,
NumberOfVehicles=20,
NumberOfPedestrians=40,
WeatherId=random.choice([1, 3, 7, 8, 14]))
settings.randomize_seeds()
# Now we want to add a couple of cameras to the player vehicle.
# We will collect the images produced by these cameras every
# frame.
# The default camera captures RGB images of the scene.
camera0 = Camera('CameraRGB')
# Set image resolution in pixels.
camera0.set_image_size(800, 600)
# Set its position relative to the car in centimeters.
def run_carla_client(host, port):
global frame
with make_carla_client(host, port) as client:
print('CarlaClient connected')
settings = CarlaSettings()
settings.set(
SynchronousMode=True,
SendNonPlayerAgentsInfo=True,
NumberOfVehicles=0,
NumberOfPedestrians=0,
WeatherId=1) # random.choice([1, 3, 7, 8, 14]))
settings.randomize_seeds()
camera0 = Camera('CameraRGB')
camera0.set_image_size(800, 600)
camera0.set_position(30, 0, 130)
settings.add_sensor(camera0)
camera1 = Camera('CameraDepth', PostProcessing='Depth')
camera1.set_image_size(800, 600)
camera1.set_position(30, 0, 130)
camera.set_rotation(-15.0, 0, 0)
poses_tasks = self._poses()
vehicles_tasks = [0]
pedestrians_tasks = [250]
experiments_vector = []
for weather in self.weathers:
for iteration in range(len(poses_tasks)):
poses = poses_tasks[iteration]
vehicles = vehicles_tasks[iteration]
pedestrians = pedestrians_tasks[iteration]
conditions = CarlaSettings()
conditions.set(
SendNonPlayerAgentsInfo=True,
NumberOfVehicles=vehicles,
NumberOfPedestrians=pedestrians,
WeatherId=weather
)
conditions.set(DisableTwoWheeledVehicles=True)
# Add all the cameras that were set for this experiments
conditions.add_sensor(camera)
experiment = Experiment()
experiment.set(
Conditions=conditions,
Poses=poses,
Task=iteration,