Skip to content

Commit

Permalink
Add custom render space format.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gamenot committed Feb 28, 2024
1 parent f67fc79 commit 26efbcc
Showing 1 changed file with 27 additions and 0 deletions.
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

0 comments on commit 26efbcc

Please sign in to comment.