-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1. #2207
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
Conversation
b7d59ed to
c76de2f
Compare
Yes, that would be great indeed. |
0e879d0 to
cbd55e8
Compare
|
You should probably also apply this patch: diff --git a/genesis/ext/pyrender/jit_render.py b/genesis/ext/pyrender/jit_render.py
index e163af05..beacb87c 100644
--- a/genesis/ext/pyrender/jit_render.py
+++ b/genesis/ext/pyrender/jit_render.py
@@ -374,7 +374,7 @@ class JITRenderer:
self.gl = GLWrapper()
IS_OPENGL_42_AVAILABLE = hasattr(self.gl.wrapper_instance, "glDrawElementsInstancedBaseInstance")
- OPENGL_42_ERROR_MSG = "Seperated env rendering not supported because OpenGL 4.2 not available on this machine."
+ OPENGL_42_ERROR_MSG = "Separated env rendering not supported because OpenGL 4.2 not available on this machine."
@nb.jit(
nb.none(
diff --git a/genesis/ext/pyrender/renderer.py b/genesis/ext/pyrender/renderer.py
index 4f72e509..a3d7c2ed 100644
--- a/genesis/ext/pyrender/renderer.py
+++ b/genesis/ext/pyrender/renderer.py
@@ -152,7 +152,7 @@ class Renderer(object):
if flags & RenderFlags.ENV_SEPARATE and flags & RenderFlags.OFFSCREEN:
n_envs = scene.n_envs
- use_env_idx = True
+ use_env_idx = True and scene.n_envs > 1
else:
n_envs = 1
use_env_idx = False
diff --git a/genesis/vis/camera.py b/genesis/vis/camera.py
index c1fb8bfb..32cedefa 100644
--- a/genesis/vis/camera.py
+++ b/genesis/vis/camera.py
@@ -156,7 +156,7 @@ class Camera(RBC):
self._raytracer.add_camera(self)
else:
self._is_batched = False
- if self._visualizer.scene.n_envs > 0 and self._visualizer._context.env_separate_rigid:
+ if self._visualizer.scene.n_envs > 1 and self._visualizer._context.env_separate_rigid:
gs.logger.warning(
"Batched rendering via 'VisOptions.env_separate_rigid=True' is only partially supported by "
"Rasterizer for now. The same camera transform will be used for all the environments."
@@ -165,7 +165,7 @@ class Camera(RBC):
if self._env_idx is None:
if not self._is_batched:
self._env_idx = int(self._visualizer._context.rendered_envs_idx[0])
- if self._visualizer.scene.n_envs > 0:
+ if self._visualizer.scene.n_envs > 1:
gs.logger.info(
"Raytracer and Rasterizer requires binding to the camera with a specific environment "
"index. Defaulting to 'rendered_envs_idx[0]'. Please specify 'env_idx' if necessary." |
cbd55e8 to
df9e938
Compare
df9e938 to
fbdfa79
Compare
|
What does |
fbdfa79 to
4f24497
Compare
|
4f24497 to
7789708
Compare
f26e933 to
6083c08
Compare
Description
This reallows RasterizerCameraSensor to work with n_envs > 1.
The PyRenderer requires
env_separate_rigid=Trueto correctly separate the rendering.This requires OpenGL 4.2 which is not available on Metal.
I moved the errorring out to the
.build()since I think it's easier on users to have errors earlier rather than later.I chose not to change the batched dimension on the Rasterizer (it can return a non batched variant when use_separate_rigid=False) to minimize the surface of this change.
Diff unfortunately includes some
ruff formatmodifications, not reverted automatically byblack.I can manually revert if necessary.
Motivation and Context
It's important to have rendering when using
n_envs>1in the context of leveraging the batched simulation.This version works, even if not optimal compared to a purely batched rendering.
I decided to not change other renderers as they belong in other PRs IMHO.
Screenshots (if appropriate):
https://huggingface.co/datasets/Genesis-Intelligence/snapshots/commit/1029f0b5ec874b93dc5170179f7f5a3e770b10ea
Checklist:
Submitting Code Changessection of CONTRIBUTING document.