Skip to content

Commit

Permalink
[Development] Batch renderer integration (facebookresearch#1200)
Browse files Browse the repository at this point in the history
* Add batch renderer configuration fields.

* Set simulator configuration flags for batch rendering.

* Add BatchRenderVectorEnv.

* Add BatchRenderVectorEnv creation.

* Add type annotations.

* Add batch renderer class and load it.

* Add render_state to sim observations when batch rendering.

* Add batch rendered vector env test.

* Add gpu-to-cpu batch rendering implementation.

* Make test_rl_batch_render_envs execute gpu-to-cpu only flow only.

* Clean up batch renderer.

* Code clean-up.

* Simplify transfer buffer.

* Update docstrings.

* Create a file containing batch rendering constants. Move hardcoded string to constants.

* Formatting fix.

* Change render function name to match new habitat-sim api.

* Rename render state to keyframe. Rename batch vector env render function.

* Assert config instead of automatically correcting it.

* Remove BatchRendererVectorEnv. Directly use batch renderer from VectorEnv instead.

* Format fix

* Create batch renderer config. Move composite file specification in it.

* Formatting fixes.

* Rename BatchRenderer to EnvBatchRenderer and BatchRendererConfig to RendererConfig. Add asserts.

* Move enable_batch_renderer into RendererConfig.

* Formatting fixes.

* Fix composite file config path change.

* Compare rgb image produced by reset in batch env test.

* Add classic replay renderer option.

* Add classic replay renderer test.

* Review pass.

* Change replayer renderer render call to match main.

* Fix package import for new directory.

* Fix CI module import issue.

* Change condition for assertion.
  • Loading branch information
0mdc authored Apr 4, 2023
1 parent 1bd1016 commit 972dc70
Show file tree
Hide file tree
Showing 9 changed files with 586 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,8 @@ def construct_envs(
env_fn_args=tuple((c,) for c in configs),
workers_ignore_signals=workers_ignore_signals,
)

if config.habitat.simulator.renderer.enable_batch_renderer:
envs.initialize_batch_renderer(config)

return envs
16 changes: 16 additions & 0 deletions habitat-lab/habitat/config/default_structured_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,20 @@ class AgentConfig(HabitatBaseConfig):
motion_data_path: str = ""


@dataclass
class RendererConfig(HabitatBaseConfig):
r"""Configuration for the renderer.
:property enable_batch_renderer: [Experimental] Enables batch rendering, which accelerates rendering for concurrent environments. See env_batch_renderer.py for details.
:property composite_files: List of composite GLTF files to be pre-loaded by the batch renderer.
:property classic_replay_renderer: For debugging. Create a ClassicReplayRenderer instead of BatchReplayRenderer when enable_batch_renderer is active.
"""

enable_batch_renderer: bool = False
composite_files: Optional[List[str]] = None
classic_replay_renderer: bool = False


@dataclass
class HabitatSimV0Config(HabitatBaseConfig):
gpu_device_id: int = 0
Expand Down Expand Up @@ -1401,6 +1415,8 @@ class SimulatorConfig(HabitatBaseConfig):
ep_info: Optional[Any] = None
# The offset id values for the object
object_ids_start: int = 100
# Configuration for rendering
renderer: RendererConfig = RendererConfig()


@dataclass
Expand Down
5 changes: 5 additions & 0 deletions habitat-lab/habitat/core/batch_rendering/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env python3

# Copyright (c) Meta Platforms, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
Loading

0 comments on commit 972dc70

Please sign in to comment.