Skip to content

Commit 9a89228

Browse files
Simplify non-realtime API
1 parent f9ed364 commit 9a89228

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

lgsvl/simulator.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,9 @@ def reset(self):
6060
def stop(self):
6161
self.stopped = True
6262

63-
@accepts((int, float))
64-
def run(self, time_limit = 0.0):
65-
self._process("simulator/run", {"time_limit": time_limit})
66-
67-
@accepts(int, (int, float))
68-
def step(self, frames = 1, framerate = 30.0):
69-
self._process("simulator/step", {"frames": frames, "framerate": framerate})
63+
@accepts((int, float), (int, float))
64+
def run(self, time_limit = 0.0, framerate = None):
65+
self._process("simulator/run", {"time_limit": time_limit, "framerate": framerate})
7066

7167
def _add_callback(self, agent, name, fn):
7268
if agent not in self.callbacks:

quickstart/24-ego-drive-straight-non-realtime.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@
3030
print("Simulation time = ", sim.current_time)
3131
print("Simulation frames = ", sim.current_frame)
3232

33-
input("Press Enter to drive forward for 100 frames")
33+
input("Press Enter to drive forward for 4 seconds")
3434

3535
# The simulator can be run for a set amount of time. time_limit is optional and if omitted or set to 0, then the simulator will run indefinitely
3636
t0 = time.time()
37-
sim.step(frames = 100, framerate = 20)
37+
sim.run(time_limit = 4, framerate = 20)
3838
t1 = time.time()
3939
print("Real time elapsed = ", t1 - t0)
4040
print("Simulation time = ", sim.current_time)
4141
print("Simulation frames = ", sim.current_frame)
4242

43-
input("Press Enter to continue driving for 100 frames")
43+
input("Press Enter to continue driving for 4 more seconds")
4444

4545
t2 = time.time()
46-
sim.step(frames = 100, framerate = 20)
46+
sim.run(time_limit = 4, framerate = 20)
4747
t3 = time.time()
4848

4949
print("Real time elapsed = ", t3 - t2 + t1 - t0)

0 commit comments

Comments
 (0)