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

[WIP] Add custom render to formatted observations. #2144

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
27 changes: 27 additions & 0 deletions smarts/env/utils/observation_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from smarts.core.observations import Observation, SignalObservation, VehicleObservation
from smarts.core.plan import NavigationMission
from smarts.core.road_map import Waypoint
from smarts.core.configuration import Config

_LIDAR_SHP = 300
_NEIGHBOR_SHP = 50
Expand Down Expand Up @@ -757,6 +758,24 @@ def active(self, agent_interface: AgentInterface) -> bool:
@property
def name(self):
return "top_down_rgb"


class CustomRenderSpaceFormat(Image8BSpaceFormat):
"""Formats a specific custom_render"""

def __init__(self, agent_interface: AgentInterface, index: int) -> None:
self._index = index
super().__init__(dimensions=agent_interface.custom_renders[index], layers=3)

def format(self, obs: Observation):
return obs.custom_renders[self._index].data.astype(np.uint8)

def active(self, agent_interface: AgentInterface) -> bool:
return bool(agent_interface.custom_renders[self._index])

@property
def name(self):
return str(self._index)


waypoint_paths_space_format = StandardSpaceFormat(
Expand Down Expand Up @@ -1053,6 +1072,14 @@ class ObservationSpacesFormatter:
shape=(height, width, 3). dtype=np.uint8.
"top_down_rgb": np.ndarray

Occlusion observable area map.
shape=(height, width, 3). dtype=np.uint8.
"top_down_rgb": np.ndarray

TODO Custom renders.
shape=(max_custom_image_sensors, height, width, 3). dtype=np.uint8.
"top_down_rgb": np.ndarray

Feature array of 20 waypoints ahead or in the mission route, from the
nearest 4 lanes. If lanes or waypoints ahead are insufficient, default
values are padded.
Expand Down
Loading