MCPcopy Create free account
hub / github.com/OpenDriveLab/DriveAdapter / run

Method run

leaderboard/leaderboard/envs/sensor_interface.py:62–77  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

60
61 @threaded
62 def run(self):
63 first_time = True
64 latest_time = GameTime.get_time()
65 while self._run_ps:
66 if self._callback is not None:
67 current_time = GameTime.get_time()
68
69 # Second part forces the sensors to send data at the first tick, regardless of frequency
70 if current_time - latest_time > (1 / self._reading_frequency) \
71 or (first_time and GameTime.get_frame() != 0):
72 self._callback(GenericMeasurement(self.__call__(), GameTime.get_frame()))
73 latest_time = GameTime.get_time()
74 first_time = False
75
76 else:
77 time.sleep(0.001)
78
79 def listen(self, callback):
80 # Tell that this function receives what the producer does.

Callers 1

__init__Method · 0.95

Calls 4

__call__Method · 0.95
GenericMeasurementClass · 0.85
get_timeMethod · 0.80
get_frameMethod · 0.80

Tested by

no test coverage detected