Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
QuanyiLi committed Sep 21, 2023
1 parent 11bbe21 commit dce0f0b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 38 deletions.
4 changes: 1 addition & 3 deletions metadrive/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ class MapTerrainSemanticColor:
Do not modify this as it is for terrain generation. If you want your own palette, just add a new one or modify
class lMapSemanticColor
"""

@staticmethod
def get_color(type):
if MetaDriveType.is_yellow_line(type):
Expand All @@ -394,7 +393,6 @@ class TopDownSemanticColor:
Do not modify this as it is for terrain generation. If you want your own palette, just add a new one or modify
class lMapSemanticColor
"""

@staticmethod
def get_color(type):
if MetaDriveType.is_lane(type):
Expand All @@ -408,7 +406,7 @@ def get_color(type):
elif MetaDriveType.is_yellow_line(type):
ret = np.array([20, 20, 20])
# lane divider
elif MetaDriveType.is_road_boundary_line(type) or MetaDriveType.is_white_line(type):
elif MetaDriveType.is_road_boundary_line(type) or MetaDriveType.is_white_line(type):
ret = np.array([140, 140, 140])
# vehicle
elif MetaDriveType.is_vehicle(type):
Expand Down
16 changes: 8 additions & 8 deletions metadrive/obs/top_down_obs_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ class ObjectGraphics:

@classmethod
def display(
cls,
object: history_object,
surface,
color,
heading,
label: bool = False,
draw_contour=False,
contour_width=1
cls,
object: history_object,
surface,
color,
heading,
label: bool = False,
draw_contour=False,
contour_width=1
) -> None:
"""
Display a vehicle on a pygame surface.
Expand Down
53 changes: 26 additions & 27 deletions metadrive/obs/top_down_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@


def draw_top_down_map(
map,
resolution: Iterable = (512, 512),
semantic_map=True,
return_surface=False,
film_size=None,
scaling=None,
semantic_broken_line=True
map,
resolution: Iterable = (512, 512),
semantic_map=True,
return_surface=False,
film_size=None,
scaling=None,
semantic_broken_line=True
) -> Optional[Union[np.ndarray, pygame.Surface]]:
import cv2
film_size = film_size or map.film_size
Expand Down Expand Up @@ -81,10 +81,9 @@ def draw_top_down_map(
for id, data in all_lanes.items():
if ScenarioDescription.POLYLINE not in data:
continue
LaneGraphics.display_scenario_line(data["polyline"],
data["type"],
surface,
line_sample_interval=line_sample_interval)
LaneGraphics.display_scenario_line(
data["polyline"], data["type"], surface, line_sample_interval=line_sample_interval
)

elif isinstance(map, NuPlanMap):
raise DeprecationWarning("We are using unifed ScenarioDescription Now!")
Expand Down Expand Up @@ -112,7 +111,7 @@ def draw_top_down_map(


def draw_top_down_trajectory(
surface: WorldSurface, episode_data: dict, entry_differ_color=False, exit_differ_color=False, color_list=None
surface: WorldSurface, episode_data: dict, entry_differ_color=False, exit_differ_color=False, color_list=None
):
if entry_differ_color or exit_differ_color:
assert color_list is not None
Expand Down Expand Up @@ -171,21 +170,21 @@ def draw_top_down_trajectory(

class TopDownRenderer:
def __init__(
self,
film_size=(1000, 1000),
screen_size=(1000, 1000),
num_stack=15,
history_smooth=0,
show_agent_name=False,
camera_position=None,
target_vehicle_heading_up=False,
draw_target_vehicle_trajectory=False,
semantic_map=False,
semantic_broken_line=True,
scaling=None, # auto-scale
draw_contour=True,
**kwargs
# current_track_vehicle=None
self,
film_size=(1000, 1000),
screen_size=(1000, 1000),
num_stack=15,
history_smooth=0,
show_agent_name=False,
camera_position=None,
target_vehicle_heading_up=False,
draw_target_vehicle_trajectory=False,
semantic_map=False,
semantic_broken_line=True,
scaling=None, # auto-scale
draw_contour=True,
**kwargs
# current_track_vehicle=None
):
# Setup some useful flags
self.position = camera_position
Expand Down

0 comments on commit dce0f0b

Please sign in to comment.