diff --git a/metadrive/constants.py b/metadrive/constants.py index 00f5cc5bd..e98e055c5 100644 --- a/metadrive/constants.py +++ b/metadrive/constants.py @@ -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]) diff --git a/metadrive/engine/top_down_renderer.py b/metadrive/engine/top_down_renderer.py index 841614e4b..e425a1e61 100644 --- a/metadrive/engine/top_down_renderer.py +++ b/metadrive/engine/top_down_renderer.py @@ -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, diff --git a/metadrive/type.py b/metadrive/type.py index 00f9fdd1a..7af0d865f 100644 --- a/metadrive/type.py +++ b/metadrive/type.py @@ -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" @@ -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