Skip to content

Commit

Permalink
Update default argument for TopDownRenderer (#609)
Browse files Browse the repository at this point in the history
* change default value for topdown renderer

* format

* main camera
  • Loading branch information
QuanyiLi committed Jan 22, 2024
1 parent fb53a72 commit 32fc74e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion metadrive/engine/core/main_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,10 @@ def _wheel_up_height(self):
def _move_to_pointer(self):
if self.engine.task_manager.hasTaskNamed(self.TOP_DOWN_TASK_NAME):
# Get to and from pos in camera coordinates
pMouse = self.engine.mouseWatcherNode.getMouse()
try:
pMouse = self.engine.mouseWatcherNode.getMouse()
except:
return
pFrom = Point3()
pTo = Point3()
self.engine.cam.node().getLens().extrude(pMouse, pFrom, pTo)
Expand Down
10 changes: 8 additions & 2 deletions metadrive/obs/top_down_renderer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import copy
from metadrive.engine.logger import get_logger

from metadrive.utils import generate_gif
import math
Expand Down Expand Up @@ -165,7 +166,7 @@ def __init__(
self,
film_size=(2000, 2000), # draw map in size = film_size/scaling. By default, it is set to 400m
scaling=5, # None for auto-scale
screen_size=(1000, 1000),
screen_size=(800, 800),
num_stack=15,
history_smooth=0,
show_agent_name=False,
Expand All @@ -191,7 +192,7 @@ def __init__(
screen_size: The size of the window popped up. It shows a region with width and length = screen_size/scaling
num_stack: How many history steps to keep. History trajectory will show in faded color
num_stack: How many history steps to keep. History trajectory will show in faded color. It should be > 1
history_smooth: Smoothing the trajectory by drawing less history positions. This value determines the sample
rate. By default, this value is 0, meaning positions in previous num_stack steps will be shown.
Expand Down Expand Up @@ -221,6 +222,11 @@ def __init__(
# LQY: do not delete the above line !!!!!

# Setup some useful flags
self.logger = get_logger()
if num_stack < 1:
self.logger.warning("num_stack should be greater than 0. Current value: {}. Set to 1".format(num_stack))
num_stack = 1

self.position = camera_position
self.target_vehicle_heading_up = target_vehicle_heading_up
self.show_agent_name = show_agent_name
Expand Down

0 comments on commit 32fc74e

Please sign in to comment.