Skip to content

Commit 9a4dd92

Browse files
cleanup code + fix missing dois
1 parent bc2d145 commit 9a4dd92

4 files changed

Lines changed: 39 additions & 27 deletions

File tree

cawsr.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from typing import Optional, Union, Callable
2828

2929
from srunner.scenariomanager.scenario_manager import ScenarioManager
30+
from srunner.scenariomanager.timer import GameTime
3031
from srunner.tools.results_manager import ScenarioDefinitionManager
3132
from srunner.scenarios.route_scenario import RouteScenario
3233
from srunner.scenariomanager.carla_data_provider import CarlaDataProvider
@@ -86,7 +87,7 @@ def __init__(self, cawsr_config: dict, carla_conf: CARLA) -> None:
8687
# manages results directories
8788
self.results_manager = ScenarioDefinitionManager()
8889

89-
# capture SIGINT for cleanp
90+
# capture SIGINT for cleanup
9091
self._shutdown_requested = False
9192

9293
if sys.platform != "win32":
@@ -163,7 +164,8 @@ def run_scenario(
163164
self.ego_vehicles.append(actor)
164165
logger.info(f"Spawned ego with id: {actor.id}")
165166

166-
self.carla_world.tick() # client must tick to spawn actors
167+
# client must tick to spawn actors
168+
self._tick_carla()
167169

168170
logger.info("Initialising Autoware...")
169171
agent_class_name = self.module_aw_agent.__name__.title().replace("_", "")
@@ -188,7 +190,7 @@ def run_scenario(
188190

189191
ego.prepare_ego(route[0][0]) # set location to first waypoint
190192

191-
self.carla_world.tick()
193+
self._tick_carla()
192194

193195
logger.info("Loading Traffic Manager...")
194196
tm_port = int(self._carla.TRAFFIC_MANAGER.PORT) # type: ignore
@@ -265,6 +267,18 @@ def run_scenario(
265267

266268
result_.put(result_dict)
267269

270+
def _tick_carla(self) -> None:
271+
timestamp = None
272+
world = CarlaDataProvider.get_world()
273+
if world:
274+
snapshot = world.get_snapshot()
275+
if snapshot:
276+
timestamp = snapshot.timestamp
277+
if timestamp:
278+
CarlaDataProvider.get_world().tick()
279+
CarlaDataProvider.on_carla_tick()
280+
GameTime.on_carla_tick(timestamp)
281+
268282
def _load_alg(self) -> type[BasicAlgorithm]:
269283
"""Load an algorithm instance from mounted docker volume algorithms/
270284
@@ -285,10 +299,12 @@ def _load_alg(self) -> type[BasicAlgorithm]:
285299
)
286300

287301
def run_algorithm(self) -> None:
288-
"""Executes CAWSR in algorithm mode. Every scenario"""
302+
"""Executes CAWSR in algorithm mode"""
303+
289304
# load the algorithm and scenario defintion
290305
optimisation_algorithm = self._load_alg()
291306
scenario = pathlib.Path(self._conf["algorithm"]["initial_definition"])
307+
292308
# add some code here
293309
# if scenario = null (initial definition not given)
294310
# run the algorithm to generate a new, random scenario
@@ -317,7 +333,7 @@ def run_algorithm(self) -> None:
317333
self.results_manager.last_scenario, env_config
318334
)[
319335
0
320-
] # route id. Multiple routes currently aren't supported, so use first route
336+
] # route id. Multiple routes currently aren't supported, so use first route -> fix to use config
321337

322338
json_definition = self._cawsr_process(
323339
route_config=route_config,

paper.bib

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ @inproceedings{carla_sim
99
@inproceedings{osikowicz2025empirically,
1010
title = {Empirically evaluating flaky tests for autonomous driving systems in simulated environments},
1111
author = {Osikowicz, Olek and McMinn, Phil and Shin, Donghwan},
12+
doi = {10.1109/FTW66604.2025.00009},
1213
booktitle = {2025 IEEE/ACM International Flaky Tests Workshop (FTW)},
1314
pages = {13--20},
1415
year = {2025},
@@ -18,6 +19,7 @@ @inproceedings{osikowicz2025empirically
1819
@article{Jaeger2023ICCV,
1920
title = {Hidden Biases of End-to-End Driving Models},
2021
author = {Bernhard Jaeger and Kashyap Chitta and Andreas Geiger},
22+
doi = {10.1109/iccv51070.2023.00757},
2123
booktitle = {Proc. of the IEEE International Conf. on Computer Vision (ICCV)},
2224
year = {2023}
2325
}
@@ -26,6 +28,7 @@ @inproceedings{kato2018autoware
2628
title = {Autoware on board: Enabling autonomous vehicles with embedded systems},
2729
author = {Kato, Shinpei and Tokunaga, Shota and Maruyama, Yuya and Maeda, Seiya and Hirabayashi, Manato and Kitsukawa, Yuki and Monrroy, Abraham and Ando, Tomohito and Fujii, Yusuke and Azumi, Takuya},
2830
booktitle = {2018 ACM/IEEE 9th International Conference on Cyber-Physical Systems (ICCPS)},
31+
doi = {10.1109/iccps.2018.00035},
2932
pages = {287--296},
3033
year = {2018},
3134
organization = {IEEE}
@@ -74,6 +77,7 @@ @article{carlaautowarebridge
7477
@inproceedings{tehrani2025pcla,
7578
title = {PCLA: A Framework for Testing Autonomous Agents in the CARLA Simulator},
7679
author = {Tehrani, Masoud Jamshidiyan and Kim, Jinhan and Tonella, Paolo},
80+
doi = {10.1145/3696630.3728577},
7781
booktitle = {Proceedings of the 33rd ACM International Conference on the Foundations of Software Engineering},
7882
pages = {1040--1044},
7983
year = {2025}
@@ -131,8 +135,8 @@ @article{tang2023survey
131135

132136
@ARTICLE{9793395,
133137
author={Chance, Greg and Ghobrial, Abanoub and McAreavey, Kevin and Lemaignan, Séverin and Pipe, Tony and Eder, Kerstin},
134-
journal={IEEE Transactions on Intelligent Transportation Systems},
135-
title={On Determinism of Game Engines Used for Simulation-Based Autonomous Vehicle Verification},
138+
journal={IEEE Transactions on Intelligent Transportation Systems},
139+
title={On Determinism of Game Engines Used for Simulation-Based Autonomous Vehicle Verification},
136140
year={2022},
137141
volume={23},
138142
number={11},
@@ -142,8 +146,8 @@ @ARTICLE{9793395
142146

143147
@INPROCEEDINGS{9294422,
144148
author={Rong, Guodong and Shin, Byung Hyun and Tabatabaee, Hadi and Lu, Qiang and Lemke, Steve and Možeiko, Mārtiņš and Boise, Eric and Uhm, Geehoon and Gerow, Mark and Mehta, Shalin and Agafonov, Eugene and Kim, Tae Hyung and Sterner, Eric and Ushiroda, Keunhae and Reyes, Michael and Zelenkovsky, Dmitry and Kim, Seonman},
145-
booktitle={2020 IEEE 23rd International Conference on Intelligent Transportation Systems (ITSC)},
146-
title={LGSVL Simulator: A High Fidelity Simulator for Autonomous Driving},
149+
booktitle={2020 IEEE 23rd International Conference on Intelligent Transportation Systems (ITSC)},
150+
title={LGSVL Simulator: A High Fidelity Simulator for Autonomous Driving},
147151
year={2020},
148152
volume={},
149153
number={},

srunner/autoagents/autoware_carla_interface/carla_ros.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import json
1616
import math
17-
import time
1817

1918
# pylint: disable=import-error
2019
from autoware_vehicle_msgs.msg import ControlModeReport
@@ -475,6 +474,12 @@ def ego_status(self):
475474
def run_step(self, input_data, timestamp):
476475
self.timestamp = timestamp
477476

477+
seconds = int(self.timestamp)
478+
nanoseconds = int((self.timestamp - int(self.timestamp)) * 1000000000.0)
479+
obj_clock = Clock()
480+
obj_clock.clock = Time(sec=seconds, nanosec=nanoseconds)
481+
self.clock_publisher.publish(obj_clock)
482+
478483
# publish data of all sensors
479484
for key, data in input_data.items():
480485
sensor_type = self.id_to_sensor_type_map[key]
@@ -489,16 +494,7 @@ def run_step(self, input_data, timestamp):
489494
else:
490495
self.ros2_node.get_logger().info("No Publisher for [{key}] Sensor")
491496

492-
time.sleep(0.05) # 50ms delay to ensure published messages are received
493-
494-
seconds = int(self.timestamp)
495-
nanoseconds = int((self.timestamp - int(self.timestamp)) * 1000000000.0)
496-
obj_clock = Clock()
497-
obj_clock.clock = Time(sec=seconds, nanosec=nanoseconds)
498-
self.clock_publisher.publish(obj_clock)
499-
500497
self.ego_status()
501-
502498
return self.current_control
503499

504500
def shutdown(self):

srunner/scenariomanager/scenario_manager.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,22 +178,18 @@ def _tick_scenario(self, timestamp):
178178
if self._debug_mode:
179179
print("\n--------- Tick ---------\n")
180180

181-
181+
if self._agent is not None:
182+
self._agent() # pylint: disable=not-callable
182183

183184
_tick_carla_start = time.perf_counter_ns() / 1e6
184185
if self._sync_mode and self._watchdog.get_status():
185186
CarlaDataProvider.get_world().tick()
187+
GameTime.on_carla_tick(timestamp)
188+
CarlaDataProvider.on_carla_tick()
186189

187190
MetricsCollector.update_key(
188191
"carla_time", (time.perf_counter_ns() / 1e6) - _tick_carla_start
189192
)
190-
191-
if self._agent is not None:
192-
self._agent() # pylint: disable=not-callable
193-
194-
# Update game time and actor information
195-
GameTime.on_carla_tick(timestamp)
196-
CarlaDataProvider.on_carla_tick()
197193

198194
# Tick scenario
199195
_scenario_tick_start = time.perf_counter_ns() / 1e6

0 commit comments

Comments
 (0)