Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ego car color in top down view and fix expert bug. #718

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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])
Comment on lines 460 to +464
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work if is_vehicle call before is_ego_vehicle?

# 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
Loading