Skip to content

Commit

Permalink
Allow to config "set_static", default to False to fix the bug of flic…
Browse files Browse the repository at this point in the history
…kerring visualization.
  • Loading branch information
pengzhenghao committed Dec 6, 2024
1 parent 0bdb17e commit 44fea91
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
11 changes: 9 additions & 2 deletions metadrive/envs/scenario_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
lane_line_detector=dict(num_lasers=0, distance=50),
side_detector=dict(num_lasers=12, distance=50),
),
# If set_static=True, then the agent will not "fall from the sky". This will be helpful if you want to
# capture per-frame data for the agent (for example for collecting static sensor data).
# However, the physics engine will not update the position of the agent. So in the visualization, the image will be
# very chunky as the agent will not suddenly move to the next position for each step.
# Set to False for better visualization.
set_static=False,

# ===== Reward Scheme =====
# See: https://github.com/metadriverse/metadrive/issues/283
Expand Down Expand Up @@ -410,7 +416,8 @@ def _reset_global_seed(self, force_seed=None):
# "no_traffic":True,
# "start_scenario_index": 192,
# "start_scenario_index": 1000,
"num_scenarios": 30,
"num_scenarios": 3,
"set_static": True,
# "force_reuse_object_name": True,
# "data_directory": "/home/shady/Downloads/test_processed",
"horizon": 1000,
Expand All @@ -424,7 +431,7 @@ def _reset_global_seed(self, force_seed=None):
lane_line_detector=dict(num_lasers=12, distance=50),
side_detector=dict(num_lasers=160, distance=50)
),
"data_directory": AssetLoader.file_path("nuplan", unix_style=False),
"data_directory": AssetLoader.file_path("nuscenes", unix_style=False),
}
)
success = []
Expand Down
9 changes: 8 additions & 1 deletion metadrive/policy/replay_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@ def act(self, *args, **kwargs):
self.control_object.set_velocity(info["velocity"], in_local_frame=self._velocity_local_frame)
self.control_object.set_heading_theta(info["heading"])
self.control_object.set_angular_velocity(info["angular_velocity"])
self.control_object.set_static(True)

# If set_static, then the agent will not "fall from the sky".
# However, the physics engine will not update the position of the agent.
# So in the visualization, the image will be very chunky as the agent will not suddenly move to the next
# position for each step.

if self.engine.global_config.get("set_static", False):
self.control_object.set_static(True)

return None # Return None action so the base vehicle will not overwrite the steering & throttle

Expand Down

0 comments on commit 44fea91

Please sign in to comment.