class
EnvBatchRendererWrapper for batch rendering functionality, which renders visual sensors of N environments simultaneously.
Batch rendering reduces multi-environment memory usage and loading time by pre-loading all graphics assets once. This is accomplished by loading a composite GLTF file that contains all assets that will be used during a rollout. It also increases rendering performance by batching, leveraging data locality, minimizing amount of contexts.
Internally, the system is a replay renderer, meaning that it renders gfx-replay keyframes emitted by simulators. When batch rendering, simulators produce keyframes and add them to observations as KEYFRAME_OBSERVATION_KEY. In “post_step”, the renderer aggregates these observations, reconstitutes each state then renders them simultaneously.
Static methods
- def _create_core_sensor_suite(config: omegaconf.dictconfig.DictConfig) -> simulator.SensorSuite
- Instantiates a core sensor suite from configuration that only contains visual sensors.
- def _create_replay_renderer_cfg(config: omegaconf.dictconfig.DictConfig, num_env: int, sensor_specifications: typing.List[habitat_sim._ext.habitat_sim_bindings.SensorSpec]) -> habitat_sim._ext.habitat_sim_bindings.ReplayRendererConfiguration
- Creates the configuration info for creating a replay renderer.
- def _create_sensor_specifications(config: omegaconf.dictconfig.DictConfig, sensor_suite: simulator.SensorSuite) -> typing.List[habitat_sim._ext.habitat_sim_bindings.SensorSpec]
- Creates a list of Habitat-Sim sensor specifications from a specified core sensor suite.
- def _float_image_to_rgb_image(float_image: numpy.ndarray)
- Creates a visualization-friendly RGB image from a float image. The image is normalized from [min, max] to [0, 255].
Methods
- def _draw_observations(self, sensor_spec: habitat_sim._ext.habitat_sim_bindings.SensorSpec) -> typing.Union[numpy.ndarray, torch.Tensor]
- Draw observations for all environments.
- def _draw_observations_gpu_to_cpu(self, sensor_spec: habitat_sim._ext.habitat_sim_bindings.SensorSpec) -> numpy.ndarray
- Draw observations for all environments. Copies sensors output from GPU memory into CPU ndarrays, during which the thread is blocked.
- def close(self) -> None
- Release the resources and graphics context.
- def copy_output_to_image(self) -> typing.List[numpy.ndarray]
- Utility function that creates a list of RGB images (as ndarrays) for each environment using unprocessed data that was rendered during the last post_step call. For testing and debugging only.
- def post_step(self, observations: typing.List[collections.OrderedDict]) -> typing.List[collections.OrderedDict]
- Renders observations for all environments by consuming keyframe observations.
Special methods
Method documentation
def habitat. core. batch_rendering. env_batch_renderer. EnvBatchRenderer. _create_core_sensor_suite(config: omegaconf.dictconfig.DictConfig) -> simulator.SensorSuite staticmethod
Instantiates a core sensor suite from configuration that only contains visual sensors.
Parameters | |
---|---|
config | Base configuration. |
def habitat. core. batch_rendering. env_batch_renderer. EnvBatchRenderer. _create_replay_renderer_cfg(config: omegaconf.dictconfig.DictConfig,
num_env: int,
sensor_specifications: typing.List[habitat_sim._ext.habitat_sim_bindings.SensorSpec]) -> habitat_sim._ext.habitat_sim_bindings.ReplayRendererConfiguration staticmethod
Creates the configuration info for creating a replay renderer.
Parameters | |
---|---|
config | Base configuration. |
num_env | Number of environments. |
sensor_specifications | Habitat-Sim visual sensor specifications. See _create_sensor_specifications(). |
Returns | Replay renderer configuration. |
def habitat. core. batch_rendering. env_batch_renderer. EnvBatchRenderer. _create_sensor_specifications(config: omegaconf.dictconfig.DictConfig,
sensor_suite: simulator.SensorSuite) -> typing.List[habitat_sim._ext.habitat_sim_bindings.SensorSpec] staticmethod
Creates a list of Habitat-Sim sensor specifications from a specified core sensor suite.
Parameters | |
---|---|
config | Base configuration. |
sensor_suite | Core sensor suite that only contains visual sensors. See _create_core_sensor_suite(). |
def habitat. core. batch_rendering. env_batch_renderer. EnvBatchRenderer. _float_image_to_rgb_image(float_image: numpy.ndarray) staticmethod
Creates a visualization-friendly RGB image from a float image. The image is normalized from [min, max] to [0, 255].
Parameters | |
---|---|
float_image | 2-dimension float ndarray to be transformed. |
def habitat. core. batch_rendering. env_batch_renderer. EnvBatchRenderer. _draw_observations(self,
sensor_spec: habitat_sim._ext.habitat_sim_bindings.SensorSpec) -> typing.Union[numpy.ndarray, torch.Tensor]
Draw observations for all environments.
Parameters | |
---|---|
sensor_spec | Habitat-sim sensor specifications. |
Returns | A numpy ndarray in GPU-to-CPU mode, or a torch tensor in GPU-to-GPU mode. |
def habitat. core. batch_rendering. env_batch_renderer. EnvBatchRenderer. _draw_observations_gpu_to_cpu(self,
sensor_spec: habitat_sim._ext.habitat_sim_bindings.SensorSpec) -> numpy.ndarray
Draw observations for all environments. Copies sensors output from GPU memory into CPU ndarrays, during which the thread is blocked.
Parameters | |
---|---|
sensor_spec | Habitat-sim sensor specifications. |
Returns | ndarray containing renders. |
def habitat. core. batch_rendering. env_batch_renderer. EnvBatchRenderer. copy_output_to_image(self) -> typing.List[numpy.ndarray]
Utility function that creates a list of RGB images (as ndarrays) for each environment using unprocessed data that was rendered during the last post_step call. For testing and debugging only.
Returns | List of RGB images as ndarrays. |
---|
def habitat. core. batch_rendering. env_batch_renderer. EnvBatchRenderer. post_step(self,
observations: typing.List[collections.OrderedDict]) -> typing.List[collections.OrderedDict]
Renders observations for all environments by consuming keyframe observations.
Parameters | |
---|---|
observations | List of observations for each environment. |
Returns | List of rendered observations for each environment. |