Skip to content

Commit

Permalink
Render() should be called after engine.after_step() to make sure cons…
Browse files Browse the repository at this point in the history
…istency (#608)

* move render to after_step to ensure consistency

* format
  • Loading branch information
QuanyiLi committed Jan 22, 2024
1 parent bc162e1 commit fb53a72
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 0 additions & 4 deletions metadrive/engine/base_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,6 @@ def step(self, step_num: int = 1) -> None:

if self.force_fps.real_time_simulation and i < step_num - 1:
self.task_manager.step()
# panda3d render and garbage collecting loop
self.task_manager.step()
if self.on_screen_message is not None:
self.on_screen_message.render()

def after_step(self, *args, **kwargs) -> Dict:
"""
Expand Down
6 changes: 6 additions & 0 deletions metadrive/envs/base_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,12 @@ def _step_simulator(self, actions):
self.engine.step(self.config["decision_repeat"])
# update states, if restore from episode data, position and heading will be force set in update_state() function
scene_manager_after_step_infos = self.engine.after_step()

# Do rendering
self.engine.task_manager.step()
if self.engine.on_screen_message is not None:
self.engine.on_screen_message.render()

# Note that we use shallow update for info dict in this function! This will accelerate system.
return merge_dicts(
scene_manager_after_step_infos, scene_manager_before_step_infos, allow_new_keys=True, without_copy=True
Expand Down
2 changes: 1 addition & 1 deletion metadrive/tests/vis_env/vis_nuscenes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# "need_lane_localization": False,
# "image_observation": True,
"show_logo": False,
"no_traffic": True,
"no_traffic": False,
"store_data": False,
"sequential_seed": True,
# "pstats": True,
Expand Down

0 comments on commit fb53a72

Please sign in to comment.