Skip to content

Commit 129410c

Browse files
moved CARLA clock to tick last, ensuring all data is sent
1 parent fbf15c5 commit 129410c

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

srunner/autoagents/autoware_carla_interface/carla_ros.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -488,11 +488,6 @@ def ego_status(self):
488488

489489
def run_step(self, input_data, timestamp):
490490
self.timestamp = timestamp
491-
seconds = int(self.timestamp)
492-
nanoseconds = int((self.timestamp - int(self.timestamp)) * 1000000000.0)
493-
obj_clock = Clock()
494-
obj_clock.clock = Time(sec=seconds, nanosec=nanoseconds)
495-
self.clock_publisher.publish(obj_clock)
496491

497492
# publish data of all sensors
498493
for key, data in input_data.items():
@@ -510,6 +505,16 @@ def run_step(self, input_data, timestamp):
510505

511506
# Publish ego vehicle status
512507
self.ego_status()
508+
509+
time.sleep(0.001) # small delay to ensure all data can be sent in time
510+
511+
# publish clock last to ensure all sensor data is waiting for autoware
512+
seconds = int(self.timestamp)
513+
nanoseconds = int((self.timestamp - int(self.timestamp)) * 1000000000.0)
514+
obj_clock = Clock()
515+
obj_clock.clock = Time(sec=seconds, nanosec=nanoseconds)
516+
self.clock_publisher.publish(obj_clock)
517+
513518
return self.current_control
514519

515520
def shutdown(self):

0 commit comments

Comments
 (0)