(world, sensors, n_vehicles, n_walkers, spawn_points, client)
| 152 | |
| 153 | |
| 154 | def create_environment(world, sensors, n_vehicles, n_walkers, spawn_points, client): |
| 155 | global sensors_callback |
| 156 | sensors_ret = [] |
| 157 | blueprint_library = world.get_blueprint_library() |
| 158 | |
| 159 | # setup sensors |
| 160 | for sensor_spec in sensors: |
| 161 | bp = blueprint_library.find(sensor_spec['type']) |
| 162 | |
| 163 | if sensor_spec['type'].startswith('sensor.camera'): |
| 164 | bp.set_attribute('image_size_x', str(sensor_spec['width'])) |
| 165 | bp.set_attribute('image_size_y', str(sensor_spec['height'])) |
| 166 | bp.set_attribute('fov', str(sensor_spec['fov'])) |
| 167 | sensor_location = carla.Location( |
| 168 | x=sensor_spec['x'], |
| 169 | y=sensor_spec['y'], |
| 170 | z=sensor_spec['z']) |
| 171 | sensor_rotation = carla.Rotation( |
| 172 | pitch=sensor_spec['pitch'], |
| 173 | roll=sensor_spec['roll'], |
| 174 | yaw=sensor_spec['yaw']) |
| 175 | |
| 176 | elif sensor_spec['type'].startswith('sensor.lidar'): |
| 177 | bp.set_attribute('range', '200') |
| 178 | bp.set_attribute('rotation_frequency', '10') |
| 179 | bp.set_attribute('channels', '32') |
| 180 | bp.set_attribute('upper_fov', '15') |
| 181 | bp.set_attribute('lower_fov', '-30') |
| 182 | bp.set_attribute('points_per_second', '500000') |
| 183 | sensor_location = carla.Location( |
| 184 | x=sensor_spec['x'], |
| 185 | y=sensor_spec['y'], |
| 186 | z=sensor_spec['z']) |
| 187 | sensor_rotation = carla.Rotation( |
| 188 | pitch=sensor_spec['pitch'], |
| 189 | roll=sensor_spec['roll'], |
| 190 | yaw=sensor_spec['yaw']) |
| 191 | |
| 192 | elif sensor_spec['type'].startswith('sensor.other.gnss'): |
| 193 | sensor_location = carla.Location(x=sensor_spec['x'], y=sensor_spec['y'], z=sensor_spec['z']) |
| 194 | sensor_rotation = carla.Rotation() |
| 195 | |
| 196 | # create sensor |
| 197 | sensor_transform = carla.Transform(sensor_location, sensor_rotation) |
| 198 | sensor = world.spawn_actor(bp, sensor_transform) |
| 199 | |
| 200 | # add callbacks |
| 201 | sc = CallBack() |
| 202 | sensor.listen(sc) |
| 203 | |
| 204 | sensors_callback.append(sc) |
| 205 | sensors_ret.append(sensor) |
| 206 | |
| 207 | vehicles_list = [] |
| 208 | walkers_list = [] |
| 209 | all_id = [] |
| 210 | |
| 211 | blueprint = world.get_blueprint_library().filter('vehicle.audi.a2')[0] |
no test coverage detected