|
1 | 1 | import xml.etree.ElementTree as ET |
2 | 2 | from xml.etree.ElementTree import Element |
3 | 3 |
|
4 | | -from srunner.scenariomanager.carla_data_provider import CarlaDataProvider |
| 4 | +from srunner.scenarioconfigs.environment_configuration import EnvironmentConfig |
| 5 | +from srunner.objects.sensors import DefaultSensor, CameraRGB, LidarRayCast |
5 | 6 |
|
6 | 7 | import carla |
7 | 8 | import logging |
8 | 9 |
|
9 | 10 |
|
10 | | -class EnvironmentConfig(object): |
11 | | - """ |
12 | | - Simple object to store information about the initial environment setup for the scenario loop |
13 | | - """ |
14 | | - |
15 | | - def __init__(self) -> None: |
16 | | - self.town: str = "" |
17 | | - self.ego_model: str = "" |
18 | | - self.ego_name: str = "" |
19 | | - self.ego_spawn: carla.Transform | None = None |
20 | | - self.sensor_config: list[DefaultSensor] = [] |
21 | | - self.route_id: int = 0 |
22 | | - |
23 | | - |
24 | | -class DefaultSensor(object): |
25 | | - """ |
26 | | - A class to encapsulate information about a basic sensor |
27 | | - """ |
28 | | - |
29 | | - def __init__(self) -> None: |
30 | | - self.type: str = "" |
31 | | - self.id: str = "" |
32 | | - self.spawn: carla.Transform | None = None |
33 | | - |
34 | | - def _spawn(self, bp_library, vehicle) -> None: |
35 | | - sensor_bp = bp_library.find(str(self.type)) |
36 | | - |
37 | | - ignored_params = ["serealize", "id", "spawn", "type"] |
38 | | - |
39 | | - sensor_params = [ |
40 | | - attr |
41 | | - for attr in dir(self) |
42 | | - if attr not in ignored_params or not attr.startswith("_") |
43 | | - ] |
44 | | - |
45 | | - for param in sensor_params: |
46 | | - sensor_bp.set_attribute(param, str(getattr(self, param))) |
47 | | - |
48 | | - CarlaDataProvider.get_world().spawn_actor(sensor_bp, self.spawn, vehicle) |
49 | | - CarlaDataProvider.get_world().wait_for_tick() |
50 | | - |
51 | | - def serealize(self): |
52 | | - return self.type, self.id |
53 | | - |
54 | | - |
55 | | -class CameraRGB(DefaultSensor): |
56 | | - """ |
57 | | - A class to hold additional information about a camera sensor |
58 | | - """ |
59 | | - |
60 | | - def __init__(self) -> None: |
61 | | - super().__init__() |
62 | | - self.image_size_x: int = 0 |
63 | | - self.image_size_y: int = 0 |
64 | | - self.fov: float = 0.0 |
65 | | - |
66 | | - |
67 | | -class LidarRayCast(DefaultSensor): |
68 | | - """ |
69 | | - A class to hold additional information about a Lidar sensor |
70 | | - """ |
71 | | - |
72 | | - def __init__(self) -> None: |
73 | | - super().__init__() |
74 | | - self.range: int = 0 |
75 | | - self.channels: int = 0 |
76 | | - self.points_per_second: int = 0 |
77 | | - self.upper_fov: float = 0.0 |
78 | | - self.lower_fov: float = 0.0 |
79 | | - self.rotation_frequency: int = 0 |
80 | | - |
81 | | - |
82 | | -class SensorGNSS(DefaultSensor): |
83 | | - """ |
84 | | - A class to hold additional information about GNSS |
85 | | - """ |
86 | | - |
87 | | - def __init__(self) -> None: |
88 | | - super().__init__() |
89 | | - self.noise_alt_stddev = 0.0 |
90 | | - self.noise_lat_stddev = 0.0 |
91 | | - self.noise_lon_stddev = 0.0 |
92 | | - self.noise_alt_bias = 0.0 |
93 | | - self.noise_lat_bias = 0.0 |
94 | | - self.noise_lon_bias = 0.0 |
95 | | - |
96 | | - |
97 | | -class SensorIMU(DefaultSensor): |
98 | | - """ |
99 | | - A class to hold additional information about IMU |
100 | | - """ |
101 | | - |
102 | | - def __init__(self) -> None: |
103 | | - super().__init__() |
104 | | - self.noise_accel_stddev_x = 0.0 |
105 | | - self.noise_accel_stddev_y = 0.0 |
106 | | - self.noise_accel_stddev_z = 0.0 |
107 | | - self.noise_gyro_stddev_x = 0.0 |
108 | | - self.noise_gyro_stddev_y = 0.0 |
109 | | - self.noise_gyro_stddev_z = 0.0 |
110 | | - |
111 | | - |
112 | 11 | class EnvironmentParser(object): |
113 | 12 | """ |
114 | 13 | Purely Static class for parsing Scenarion configuration files generated by the JSON parsers |
|
0 commit comments