Skip to content

Commit

Permalink
add ego car color in top down view
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlDegio committed May 20, 2024
1 parent 4299277 commit baa2901
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions metadrive/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,9 @@ def get_color(type):
# vehicle
elif MetaDriveType.is_vehicle(type):
ret = np.array([224, 177, 67])
# self vehicle
elif MetaDriveType.is_ego_vehicle(type):
ret = np.array([67, 177, 224])
# construction object
elif MetaDriveType.is_traffic_object(type):
ret = np.array([67, 143, 224])
Expand Down
6 changes: 5 additions & 1 deletion metadrive/engine/top_down_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,14 @@ def _append_frame_objects(objects):
"""
frame_objects = []
for name, obj in objects.items():
obj_type = obj.metadrive_type if hasattr(obj, "metadrive_type") else MetaDriveType.OTHER
if obj_type == MetaDriveType.VEHICLE:
obj_type = 'EGO_VEHICLE' if obj.class_name == 'DefaultVehicle' else MetaDriveType.VEHICLE

frame_objects.append(
history_object(
name=name,
type=obj.metadrive_type if hasattr(obj, "metadrive_type") else MetaDriveType.OTHER,
type=obj_type,
heading_theta=obj.heading_theta,
WIDTH=obj.top_down_width,
LENGTH=obj.top_down_length,
Expand Down
5 changes: 5 additions & 0 deletions metadrive/type.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class MetaDriveType:
# ===== Agent type =====
UNSET = "UNSET"
VEHICLE = "VEHICLE"
EGO_VEHICLE = "EGO_VEHICLE" # currently for top-down view
PEDESTRIAN = "PEDESTRIAN"
CYCLIST = "CYCLIST"
OTHER = "OTHER"
Expand Down Expand Up @@ -177,6 +178,10 @@ def is_crosswalk(cls, type):
def is_vehicle(cls, type):
return type == cls.VEHICLE

@classmethod
def is_ego_vehicle(cls, type):
return type == cls.EGO_VEHICLE

@classmethod
def is_pedestrian(cls, type):
return type == cls.PEDESTRIAN
Expand Down

0 comments on commit baa2901

Please sign in to comment.