before_code stringlengths 30 149k | reviewer_comment stringlengths 16 20.6k | after_code stringlengths 30 163k | diff_context stringlengths 0 22.4k | file_path stringlengths 6 155 | comment_line int64 0 26 | language stringclasses 19
values | quality_score float64 0.07 1 | comment_type stringclasses 9
values | comment_length int64 16 20.6k | before_lines int64 2 4.61k | after_lines int64 2 4.4k | is_negative bool 2
classes | pr_title stringlengths 7 140 | pr_number int64 18 61.2k | repo_name stringclasses 29
values | repo_stars int64 321 56k | repo_language stringclasses 14
values | reviewer_username stringclasses 378
values | author_username stringclasses 739
values | user stringlengths 361 200k | assistant stringlengths 16 20.6k | system stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
self._inertial_pos: "np.typing.ArrayLike | None" = inertial_pos
if inertial_quat is not None:
inertial_quat = np.asarray(inertial_quat, dtype=gs.np_float)
self._inertial_quat: "np.typing.ArrayLike | None" = inertial_quat
self._inertial_mass: float | None = inertial_mass
... | It is not clear if collision geometry of visual geometry should be used to compute such property. I have the feeling that collision geometries may be very off. There are often rough approximation using primitives, unless they are the output of convex decomposition. You can easily check in metadata of meshes whether the... | self._inertial_pos: "np.typing.ArrayLike | None" = inertial_pos
if inertial_quat is not None:
inertial_quat = np.asarray(inertial_quat, dtype=gs.np_float)
self._inertial_quat: "np.typing.ArrayLike | None" = inertial_quat
self._inertial_mass: float | None = inertial_mass
... | @@ -121,82 +122,88 @@ def _build(self):
for vgeom in self._vgeoms:
vgeom._build()
- self._init_mesh = self._compose_init_mesh()
-
- # inertial_mass and inertia_i
- if self._inertial_mass is None:
- if len(self._geoms) == 0 and len(self._vgeoms) == 0:
- ... | genesis/engine/entities/rigid_entity/rigid_link.py | 26 | Python | 0.5 | suggestion | 782 | 51 | 51 | false | [CHANGING][FEATURE] Improve inertial estimation if undefined. | 2,100 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_link.py
PR Title: [CHANGING][FEATURE] Improve inertial estimation if undefined.
BEFORE CODE: self._inertial_pos: "np.typing.ArrayLike | None" = inertial_pos
if inertial_quat is not None:
in... | It is not clear if collision geometry of visual geometry should be used to compute such property. I have the feeling that collision geometries may be very off. There are often rough approximation using primitives, unless they are the output of convex decomposition. You can easily check in metadata of meshes whether the... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
geom_list = self._vgeoms
get_mesh = lambda geom: trimesh.Trimesh(geom.init_vverts, geom.init_vfaces)
get_pos = lambda geom: geom._init_pos
get_quat = lambda geom: geom._init_quat
else:
# Fallback: use default values
... | Same. I don't like these random number. Why are you not used the convex hull in such a case?
You should also add a warning saying that inertia information may be wrongly estimated. | f"link '{self.name}'. Using visual geoms to compute inertial properties."
)
geom_list = self._vgeoms
is_visual = True
else:
gs.logger.info(
f"Link mass is not specified and no geoms found for "
... | @@ -121,82 +122,88 @@ def _build(self):
for vgeom in self._vgeoms:
vgeom._build()
- self._init_mesh = self._compose_init_mesh()
-
- # inertial_mass and inertia_i
- if self._inertial_mass is None:
- if len(self._geoms) == 0 and len(self._vgeoms) == 0:
- ... | genesis/engine/entities/rigid_entity/rigid_link.py | 26 | Python | 0.429 | bug | 181 | 51 | 51 | false | [CHANGING][FEATURE] Improve inertial estimation if undefined. | 2,100 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_link.py
PR Title: [CHANGING][FEATURE] Improve inertial estimation if undefined.
BEFORE CODE: geom_list = self._vgeoms
get_mesh = lambda geom: trimesh.Trimesh(geom.init_vverts, geom.init... | Same. I don't like these random number. Why are you not used the convex hull in such a case?
You should also add a warning saying that inertia information may be wrongly estimated. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
self._inertial_pos = np.zeros(3, dtype=gs.np_float)
self._inertial_i = np.zeros((3, 3), dtype=gs.np_float)
geom_list = []
# Process each geom individually and compose their properties
if len(geom_list) > 0:
total_mass = 0.0
... | You should just raise an exception is `inertia_mesh.mass < gs.EPS`. No point to support this, it will just cause more issues later on. | f"link '{self.name}'. Inertial and mass are set to zero."
)
self._inertial_mass = gs.EPS
self._inertial_pos = np.zeros(3, dtype=gs.np_float)
self._inertial_i = np.eye(3, dtype=gs.np_float) * gs.EPS
geom_list = []
... | @@ -121,82 +122,88 @@ def _build(self):
for vgeom in self._vgeoms:
vgeom._build()
- self._init_mesh = self._compose_init_mesh()
-
- # inertial_mass and inertia_i
- if self._inertial_mass is None:
- if len(self._geoms) == 0 and len(self._vgeoms) == 0:
- ... | genesis/engine/entities/rigid_entity/rigid_link.py | 26 | Python | 0.714 | suggestion | 134 | 51 | 51 | false | [CHANGING][FEATURE] Improve inertial estimation if undefined. | 2,100 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_link.py
PR Title: [CHANGING][FEATURE] Improve inertial estimation if undefined.
BEFORE CODE: self._inertial_pos = np.zeros(3, dtype=gs.np_float)
self._inertial_i = np.zeros((3, 3), dtyp... | You should just raise an exception is `inertia_mesh.mass < gs.EPS`. No point to support this, it will just cause more issues later on. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
self._inertial_pos = np.zeros(3, dtype=gs.np_float)
self._inertial_i = np.zeros((3, 3), dtype=gs.np_float)
geom_list = []
# Process each geom individually and compose their properties
if len(geom_list) > 0:
total_mass = 0.0
... | This condition is completely irrelevant. A convex hull cannot be non-watertight. | f"link '{self.name}'. Inertial and mass are set to zero."
)
self._inertial_mass = gs.EPS
self._inertial_pos = np.zeros(3, dtype=gs.np_float)
self._inertial_i = np.eye(3, dtype=gs.np_float) * gs.EPS
geom_list = []
... | @@ -121,82 +122,88 @@ def _build(self):
for vgeom in self._vgeoms:
vgeom._build()
- self._init_mesh = self._compose_init_mesh()
-
- # inertial_mass and inertia_i
- if self._inertial_mass is None:
- if len(self._geoms) == 0 and len(self._vgeoms) == 0:
- ... | genesis/engine/entities/rigid_entity/rigid_link.py | 26 | Python | 0.214 | suggestion | 80 | 51 | 51 | false | [CHANGING][FEATURE] Improve inertial estimation if undefined. | 2,100 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_link.py
PR Title: [CHANGING][FEATURE] Improve inertial estimation if undefined.
BEFORE CODE: self._inertial_pos = np.zeros(3, dtype=gs.np_float)
self._inertial_i = np.zeros((3, 3), dtyp... | This condition is completely irrelevant. A convex hull cannot be non-watertight. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# Body 2: Mass=1.0 at [3,0,0] with zero inertia (point mass)
# Body 3: Mass=1.5 at [0,2,0] with different inertia tensor
mass1, com1 = 2.0, np.array([0.0, 0.0, 0.0])
inertia1 = np.array([[2.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.5]]) # Asymmetric inertia
mass2, com2 = 1.0, np.array([3.0, 0.0... | Ideally it would be nice to have a different value for x, y, and z. | import math
from unittest.mock import patch
import pytest
import torch
import numpy as np
import genesis as gs
import genesis.utils.geom as gu
from genesis.utils.tools import FPSTracker
from genesis.utils.misc import tensor_to_array
from genesis.utils import warnings as warnings_mod
from genesis.utils.warnings import... | @@ -435,3 +436,51 @@ def test_fps_tracker():
fps = tracker.step(current_time=10.45)
# num envs * [num steps] / (delta time)
assert math.isclose(fps, n_envs * 4 / 0.14)
+
+
+@pytest.mark.required
+def test_compose_inertial_properties():
+ """Test composition of inertial properties combining multiple ef... | tests/test_utils.py | 26 | Python | 0.214 | suggestion | 67 | 41 | 469 | false | [CHANGING][FEATURE] Improve inertial estimation if undefined. | 2,100 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: tests/test_utils.py
PR Title: [CHANGING][FEATURE] Improve inertial estimation if undefined.
BEFORE CODE: # Body 2: Mass=1.0 at [3,0,0] with zero inertia (point mass)
# Body 3: Mass=1.5 at [0,2,0] with different inertia tensor
mass1, com1 = 2.0, np... | Ideally it would be nice to have a different value for x, y, and z. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
)
total_mass, total_com, total_inertia = compose_inertial_properties(
combined_mass_12, combined_com_12, combined_inertia_12, mass3, com3, inertia3
)
# Total mass = 2.0 + 1.0 + 1.5 = 4.5
expected_mass = 4.5
# Center of mass calculation:
# COM_x = (2.0*0 + 1.0*3 + 1.5*0) / 4.5 = 3/... | Compute the exact value and check that the entire matrix matches expectation, ideally with some number that can be easily checked by hand but not necessarily. | import math
from unittest.mock import patch
import pytest
import torch
import numpy as np
import genesis as gs
import genesis.utils.geom as gu
from genesis.utils.tools import FPSTracker
from genesis.utils.misc import tensor_to_array
from genesis.utils import warnings as warnings_mod
from genesis.utils.warnings import... | @@ -435,3 +436,51 @@ def test_fps_tracker():
fps = tracker.step(current_time=10.45)
# num envs * [num steps] / (delta time)
assert math.isclose(fps, n_envs * 4 / 0.14)
+
+
+@pytest.mark.required
+def test_compose_inertial_properties():
+ """Test composition of inertial properties combining multiple ef... | tests/test_utils.py | 26 | Python | 0.357 | suggestion | 158 | 27 | 469 | false | [CHANGING][FEATURE] Improve inertial estimation if undefined. | 2,100 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: tests/test_utils.py
PR Title: [CHANGING][FEATURE] Improve inertial estimation if undefined.
BEFORE CODE: )
total_mass, total_com, total_inertia = compose_inertial_properties(
combined_mass_12, combined_com_12, combined_inertia_12, mass3, com3,... | Compute the exact value and check that the entire matrix matches expectation, ideally with some number that can be easily checked by hand but not necessarily. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if is_visual:
inertia_mesh = trimesh.Trimesh(geom.init_vverts, geom.init_vfaces)
else:
inertia_mesh = trimesh.Trimesh(geom.init_verts, geom.init_faces)
geom_pos = geom._init_pos
geom_quat = g... | I'm not convinced it makes sense to have such branching. | if len(geom_list) > 0:
total_mass = gs.EPS # to avoid nan in inv_mass in interactive mode
total_com = np.zeros(3, dtype=gs.np_float)
total_inertia = np.eye(3, dtype=gs.np_float) * gs.EPS
for geom in geom_list:
# Create mes... | @@ -121,83 +122,73 @@ def _build(self):
for vgeom in self._vgeoms:
vgeom._build()
- self._init_mesh = self._compose_init_mesh()
-
- # inertial_mass and inertia_i
- if self._inertial_mass is None:
- if len(self._geoms) == 0 and len(self._vgeoms) == 0:
- ... | genesis/engine/entities/rigid_entity/rigid_link.py | 26 | Python | 0.214 | suggestion | 56 | 51 | 51 | false | [CHANGING][FEATURE] Improve inertial estimation if undefined. | 2,100 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_link.py
PR Title: [CHANGING][FEATURE] Improve inertial estimation if undefined.
BEFORE CODE: if is_visual:
inertia_mesh = trimesh.Trimesh(geom.init_vverts, geom.init_vfaces)... | I'm not convinced it makes sense to have such branching. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if self._inertial_mass is None or self._inertial_pos is None or self._inertial_i is None:
# Determine which geom list to use: geoms first, then vgeoms, then fallback
if len(self._geoms) > 0:
geom_list = self._geoms
is_visual = False
elif len(s... | Can you add a comment to explain what using EPS mass is necessary? It does not make sense physically so it must be strongly motivated. |
if self._inertial_mass is None or self._inertial_pos is None or self._inertial_i is None:
# Determine which geom list to use: geoms first, then vgeoms, then fallback
if len(self._geoms) > 0:
geom_list = self._geoms
is_visual = False
elif len(s... | @@ -121,83 +122,77 @@ def _build(self):
for vgeom in self._vgeoms:
vgeom._build()
- self._init_mesh = self._compose_init_mesh()
-
- # inertial_mass and inertia_i
- if self._inertial_mass is None:
- if len(self._geoms) == 0 and len(self._vgeoms) == 0:
- ... | genesis/engine/entities/rigid_entity/rigid_link.py | 26 | Python | 0.357 | suggestion | 134 | 51 | 51 | false | [CHANGING][FEATURE] Improve inertial estimation if undefined. | 2,100 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_link.py
PR Title: [CHANGING][FEATURE] Improve inertial estimation if undefined.
BEFORE CODE:
if self._inertial_mass is None or self._inertial_pos is None or self._inertial_i is None:
# Determine w... | Can you add a comment to explain what using EPS mass is necessary? It does not make sense physically so it must be strongly motivated. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
else:
ti.loop_config(serialize=ti.static(static_rigid_sim_config.para_level < gs.PARA_LEVEL.ALL))
for i_d in range(dofs_info.invweight.shape[0]):
if force_update or dofs_info.invweight[i_d] < EPS:
dofs_info.invweight[i_d] = dofs_invweight[i_d]
@ti.kernel(fastcache=gs.us... | Atomic add is not necessary here. | else:
ti.loop_config(serialize=ti.static(static_rigid_sim_config.para_level < gs.PARA_LEVEL.ALL))
for i_d in range(dofs_info.invweight.shape[0]):
if force_update or dofs_info.invweight[i_d] < EPS:
dofs_info.invweight[i_d] = dofs_invweight[i_d]
@ti.kernel(fastcache=gs.us... | @@ -2868,7 +2868,7 @@ def kernel_init_meaninertia(
for i_e in range(n_entities):
for i_d in range(entities_info.dof_start[i_e], entities_info.dof_end[i_e]):
I_d = [i_d, i_b] if ti.static(static_rigid_sim_config.batch_dofs_info) else i_d
- rigid_globa... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.071 | suggestion | 34 | 51 | 51 | false | [MISC] Remove augmented assignment in rigid solver. | 2,135 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | hughperkins | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [MISC] Remove augmented assignment in rigid solver.
BEFORE CODE: else:
ti.loop_config(serialize=ti.static(static_rigid_sim_config.para_level < gs.PARA_LEVEL.ALL))
for i_d in rang... | Atomic add is not necessary here. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
static_rigid_sim_config.max_n_dofs_per_entity,
static_rigid_sim_config.max_n_dofs_per_entity,
)
):
i_d = entities_info.dof_start[i_e] + i_d_
j_d = entities_info.dof_start[i... | Atomic add is not necessary here. | ti.ndrange(
static_rigid_sim_config.max_n_dofs_per_entity,
static_rigid_sim_config.max_n_dofs_per_entity,
)
):
i_d = entities_info.dof_start[i_e] + i_d_
... | @@ -3663,13 +3663,17 @@ def func_compute_mass_matrix(
ti.loop_config(serialize=static_rigid_sim_config.para_level < gs.PARA_LEVEL.ALL)
for i_d, i_b in ti.ndrange(dofs_state.f_ang.shape[0], links_state.pos.shape[1]):
I_d = [i_d, i_b] if ti.static(static_rigid_sim_config.batch_dofs_info) el... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.071 | suggestion | 33 | 51 | 51 | false | [MISC] Remove augmented assignment in rigid solver. | 2,135 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | hughperkins | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [MISC] Remove augmented assignment in rigid solver.
BEFORE CODE: static_rigid_sim_config.max_n_dofs_per_entity,
static_rigid_sim_config.max_n_... | Atomic add is not necessary here. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
rigid_global_info.mass_mat[i_d, j_d, i_b] = rigid_global_info.mass_mat[j_d, i_d, i_b]
# Take into account motor armature
ti.loop_config(serialize=static_rigid_sim_config.para_level < gs.PARA_LEVEL.ALL)
for i_d, i_b in ti.ndrange(dofs_state.f_ang.shape[0], links_state.pos.shape[1... | Atomic add is not necessary here. | if i_d < entities_info.dof_end[i_e] and j_d < entities_info.dof_end[i_e] and j_d > i_d:
rigid_global_info.mass_mat[i_d, j_d, i_b] = rigid_global_info.mass_mat[j_d, i_d, i_b]
# Take into account motor armature
ti.loop_config(serialize=static_rigid_sim_config.p... | @@ -3663,13 +3663,17 @@ def func_compute_mass_matrix(
ti.loop_config(serialize=static_rigid_sim_config.para_level < gs.PARA_LEVEL.ALL)
for i_d, i_b in ti.ndrange(dofs_state.f_ang.shape[0], links_state.pos.shape[1]):
I_d = [i_d, i_b] if ti.static(static_rigid_sim_config.batch_dofs_info) el... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.071 | suggestion | 33 | 51 | 51 | false | [MISC] Remove augmented assignment in rigid solver. | 2,135 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | hughperkins | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [MISC] Remove augmented assignment in rigid solver.
BEFORE CODE: rigid_global_info.mass_mat[i_d, j_d, i_b] = rigid_global_info.mass_mat[j_d, i_d, i_b]
# Take into ac... | Atomic add is not necessary here. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
else ti.static(range(static_rigid_sim_config.max_n_dofs_per_entity))
):
i_d = i_d_ if ti.static(not BW) else entities_info.dof_start[i_e] + i_d_
if func_check_index_range(i_d, entity_dof_start, entity_dof_end, B... | atomic add is not necessary here. | range(entity_dof_start, entity_dof_end)
if ti.static(not BW)
else ti.static(range(static_rigid_sim_config.max_n_dofs_per_entity))
):
i_d = i_d_ if ti.static(not BW) else entities_info.... | @@ -3746,15 +3750,17 @@ def func_factor_mass(
if ti.static(implicit_damping):
I_d = [i_d, i_b] if ti.static(static_rigid_sim_config.batch_dofs_info) else i_d
- rigid_global_info.mass_mat_L[i_d, i_d, i_b] += (
- ... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.071 | suggestion | 33 | 51 | 51 | false | [MISC] Remove augmented assignment in rigid solver. | 2,135 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | hughperkins | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [MISC] Remove augmented assignment in rigid solver.
BEFORE CODE: else ti.static(range(static_rigid_sim_config.max_n_dofs_per_entity))
):
... | atomic add is not necessary here. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
):
j_d = j_d_ if ti.static(not BW) else entities_info.dof_start[i_e] + j_d_
if func_check_index_range(j_d, entity_dof_start, i_d + 1, BW):
rigid_global_info.mass_mat_L[i_d, j_... | atomic add is not necessary here. | if ti.static(not BW)
else ti.static(range(static_rigid_sim_config.max_n_dofs_per_entity))
):
j_d = j_d_ if ti.static(not BW) else entities_info.dof_start[i_e] + j_d_
... | @@ -3746,15 +3750,17 @@ def func_factor_mass(
if ti.static(implicit_damping):
I_d = [i_d, i_b] if ti.static(static_rigid_sim_config.batch_dofs_info) else i_d
- rigid_global_info.mass_mat_L[i_d, i_d, i_b] += (
- ... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.071 | suggestion | 33 | 51 | 51 | false | [MISC] Remove augmented assignment in rigid solver. | 2,135 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | hughperkins | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [MISC] Remove augmented assignment in rigid solver.
BEFORE CODE: ):
j_d = j_d_ if ti.static(not BW) else entities_info.dof_start[i... | atomic add is not necessary here. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# Step 1: Solve w st. L^T @ w = y
for i_d_ in (
range(n_dofs)
if ti.static(not BW)
else ti.static(range(static_rigid_sim_config.max_n_dofs_per_entity))
):
if func_check_index_range(i_d_, 0, n... | This is convoluted. Just use '-' directly. | if rigid_global_info.mass_mat_mask[i_e, i_b]:
entity_dof_start = entities_info.dof_start[i_e]
entity_dof_end = entities_info.dof_end[i_e]
n_dofs = entities_info.n_dofs[i_e]
# Step 1: Solve w st. L^T @ w = y
for i_d_ in (
... | @@ -3982,8 +3990,8 @@ def func_solve_mass_batched(
# Since we read out[j_d, i_b], and j_d > i_d, which means that out[j_d, i_b] is already
# finalized at this point, we don't need to care about AD mutation rule.
if ti.sta... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.143 | suggestion | 42 | 51 | 51 | false | [MISC] Remove augmented assignment in rigid solver. | 2,135 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | hughperkins | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [MISC] Remove augmented assignment in rigid solver.
BEFORE CODE:
# Step 1: Solve w st. L^T @ w = y
for i_d_ in (
range(n_dofs)
... | This is convoluted. Just use '-' directly. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
i_j = links_info.joint_start[I_l]
I_j = [i_j, i_b] if ti.static(static_rigid_sim_config.batch_joints_info) else i_j
joint_type = joints_info.type[I_j]
if joint_type == gs.JOINT_TYPE.FREE:
pos = ti.Vector(
... | I don't think atomic add should be used here. | dof_start = links_info.dof_start[I_l]
q_start = links_info.q_start[I_l]
q_end = links_info.q_end[I_l]
i_j = links_info.joint_start[I_l]
I_j = [i_j, i_b] if ti.static(static_rigid_sim_config.batch_joints_info) else i_j
... | @@ -6652,7 +6662,7 @@ def func_integrate(
)
# Backward pass requires atomic add
if ti.static(BW):
- pos += vel * rigid_global_info.substep_dt[None]
+ ti.atomic_add(pos, vel * rigid_global_inf... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.143 | suggestion | 45 | 51 | 51 | false | [MISC] Remove augmented assignment in rigid solver. | 2,135 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | hughperkins | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [MISC] Remove augmented assignment in rigid solver.
BEFORE CODE:
i_j = links_info.joint_start[I_l]
I_j = [i_j, i_b] if ti.static(static_rigid_sim_config.batc... | I don't think atomic add should be used here. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# update double sided
if self.double_sided is None or force:
if double_sided is not None:
self.double_sided = double_sided
def requires_uv(self):
textures = (
self.get_texture(),
self.opacity_texture,
self.roughness_texture,
... | Do not skip line after function signature if there is no docstring.
Do not define nested function `fetch_batch`. Just do a for-loop:
```python
all_textures = []
for texture in (
self.get_texture() if self.emissive_texture is None else self.emissive_texture,
self.opacity_texture,
):
textures = texture.textu... | # update double sided
if self.double_sided is None or force:
if double_sided is not None:
self.double_sided = double_sided
def requires_uv(self):
textures = (
self.get_texture(),
self.opacity_texture,
self.roughness_texture,
... | @@ -215,52 +216,77 @@ def update_texture(
self.double_sided = double_sided
def requires_uv(self):
- return (
- isinstance(self.get_texture(), ImageTexture)
- or isinstance(self.opacity_texture, ImageTexture)
- or isinstance(self.roughness_texture, ImageTex... | genesis/options/surfaces.py | 26 | Python | 0.786 | performance | 488 | 51 | 51 | false | [Feature] Support Fisheye BatchCamera. | 2,138 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | ACMLCZH | Review this pull request change.
Language: Python
File: genesis/options/surfaces.py
PR Title: [Feature] Support Fisheye BatchCamera.
BEFORE CODE: # update double sided
if self.double_sided is None or force:
if double_sided is not None:
self.double_sided = double_sided
... | Do not skip line after function signature if there is no docstring.
Do not define nested function `fetch_batch`. Just do a for-loop:
```python
all_textures = []
for texture in (
self.get_texture() if self.emissive_texture is None else self.emissive_texture,
self.opacity_texture,
):
textures = texture.textu... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
args["tex_offsets"] = np.array(texture_offsets, np.int64)
args["mat_rgba"] = np.array(mat_rgbas, np.float32)
args["mat_tex_ids"] = np.array(mat_texture_indices, np.int32)
args["mat_tex_offsets"] = np.array(mat_texture_offsets, np.int32)
return args
# FIXME: Use a kernel to ... | Keep everything on a single line. | args["tex_nchans"] = np.array(texture_nchans, np.int32)
args["tex_data"] = np.concatenate(texture_data, axis=0) if texture_data else np.array([], np.uint8)
args["tex_offsets"] = np.array(texture_offsets, np.int64)
args["mat_rgba"] = np.array(mat_rgbas, np.float32)
args["mat_tex_i... | @@ -84,104 +86,124 @@ def retrieve_rigid_meshes_static(self):
seg_key = self.get_seg_key(vgeom)
seg_id = self.seg_color_map.seg_key_to_idxc(seg_key)
geom_data_ids.append(seg_id)
+ if vgeom.uvs is not None:
+ mesh_uvs.append(vgeom.uvs.astype(np.float32))
+... | genesis/vis/batch_renderer.py | 26 | Python | 0.071 | suggestion | 33 | 51 | 51 | false | [Feature] Support Fisheye BatchCamera. | 2,138 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | ACMLCZH | Review this pull request change.
Language: Python
File: genesis/vis/batch_renderer.py
PR Title: [Feature] Support Fisheye BatchCamera.
BEFORE CODE: args["tex_offsets"] = np.array(texture_offsets, np.int64)
args["mat_rgba"] = np.array(mat_rgbas, np.float32)
args["mat_tex_ids"] = np.array(mat_... | Keep everything on a single line. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
for vgeom in vgeoms:
geom_surface = vgeom.surface
geom_textures = geom_surface.get_rgba(batch=True).textures
geom_texture_indices = []
for geom_texture in geom_textures:
if isinstance(geom_texture, gs.textures.ImageTexture) and geom_texture.image... | What does this means? What will happen in the meantime? Should we raise an exception? |
for vgeom in vgeoms:
geom_surface = vgeom.surface
geom_textures = geom_surface.get_rgba(batch=True).textures
geom_texture_indices = []
for geom_texture in geom_textures:
if isinstance(geom_texture, gs.textures.ImageTexture) and geom_texture.image... | @@ -84,104 +86,124 @@ def retrieve_rigid_meshes_static(self):
seg_key = self.get_seg_key(vgeom)
seg_id = self.seg_color_map.seg_key_to_idxc(seg_key)
geom_data_ids.append(seg_id)
+ if vgeom.uvs is not None:
+ mesh_uvs.append(vgeom.uvs.astype(np.float32))
+... | genesis/vis/batch_renderer.py | 26 | Python | 0.429 | question | 85 | 51 | 51 | false | [Feature] Support Fisheye BatchCamera. | 2,138 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | ACMLCZH | Review this pull request change.
Language: Python
File: genesis/vis/batch_renderer.py
PR Title: [Feature] Support Fisheye BatchCamera.
BEFORE CODE:
for vgeom in vgeoms:
geom_surface = vgeom.surface
geom_textures = geom_surface.get_rgba(batch=True).textures
geom_texture_... | What does this means? What will happen in the meantime? Should we raise an exception? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
def res(self):
"""The resolution of the camera."""
return self._res
@property
def fov(self):
"""The field of view of the camera."""
return self._fov
@property
def aperture(self):
"""The aperture of the camera."""
return self._aperture
@property
... | Just tuple for immutable sequences. | def res(self):
"""The resolution of the camera."""
return self._res
@property
def fov(self):
"""The field of view of the camera."""
return self._fov
@property
def aperture(self):
"""The aperture of the camera."""
return self._aperture
@property
... | @@ -838,7 +838,7 @@ def focal_len(self):
projected_pixel_size = min(0.036 / self._res[1], 0.024 / self._res[0])
image_dist = self._res[1] * projected_pixel_size / (2 * tan_half_fov)
return 1.0 / (1.0 / image_dist + 1.0 / self._focus_dist)
- elif self.model == "pinhole":... | genesis/vis/camera.py | 26 | Python | 0.071 | suggestion | 35 | 51 | 51 | false | [Feature] Support Fisheye BatchCamera. | 2,138 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | ACMLCZH | Review this pull request change.
Language: Python
File: genesis/vis/camera.py
PR Title: [Feature] Support Fisheye BatchCamera.
BEFORE CODE: def res(self):
"""The resolution of the camera."""
return self._res
@property
def fov(self):
"""The field of view of the camera."""
... | Just tuple for immutable sequences. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
)
# Check that cameras are recording different part of the scene
for rgb_diff in np.diff(frame_data[:3], axis=0):
for rgb_diff_i in rgb_diff if n_envs else (rgb_diff,):
assert np.max(np.std(rgb_diff.reshape((-1, rgb_diff_i.shape[-1])), axis=0)) > 10.0
# ... | Remove this comment, it is useless. It is obvious that it means that images do not match in case of failure. | frame_data = tuple(
tensor_to_array(img_data).astype(np.float32)
for img_data in (*rgb_all, *depth_normalized_all, *seg_all, *normal_all)
)
for img_data in frame_data:
for img_data_i in img_data if n_envs else (img_data,):
assert np.max(np.std(... | @@ -507,7 +507,75 @@ def test_render_api_advanced(tmp_path, n_envs, show_viewer, png_snapshot, render
# Verify that the output is correct pixel-wise over multiple simulation steps
for image_file in sorted(tmp_path.rglob("*.png")):
with open(image_file, "rb") as f:
- assert f.read() == png_... | tests/test_render.py | 26 | Python | 0.429 | bug | 108 | 51 | 51 | false | [Feature] Support Fisheye BatchCamera. | 2,138 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | ACMLCZH | Review this pull request change.
Language: Python
File: tests/test_render.py
PR Title: [Feature] Support Fisheye BatchCamera.
BEFORE CODE: )
# Check that cameras are recording different part of the scene
for rgb_diff in np.diff(frame_data[:3], axis=0):
for rgb_diff_i in rgb_... | Remove this comment, it is useless. It is obvious that it means that images do not match in case of failure. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# Check that images are changing over time.
# We expect sufficient difference between two consecutive frames.
if frames_prev is not None:
for img_data_prev, img_data in zip(frames_prev, frame_data):
assert np.sum(np.abs(img_data_prev - img_data) > np.finfo(np.float32)... | This decorator makes no sense here, since madrone is not supported on MacOS. |
# Export a few frames for later pixel-matching validation
if i < 2:
exporter.export_frame_all_cameras(i, rgb=rgb_all, depth=depth_all, segmentation=seg_all, normal=normal_all)
exporter.export_frame_single_camera(
i, cam_1.idx, rgb=rgb_1, depth=depth_1, segmentati... | @@ -507,7 +507,75 @@ def test_render_api_advanced(tmp_path, n_envs, show_viewer, png_snapshot, render
# Verify that the output is correct pixel-wise over multiple simulation steps
for image_file in sorted(tmp_path.rglob("*.png")):
with open(image_file, "rb") as f:
- assert f.read() == png_... | tests/test_render.py | 26 | Python | 0.214 | suggestion | 76 | 51 | 51 | false | [Feature] Support Fisheye BatchCamera. | 2,138 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | ACMLCZH | Review this pull request change.
Language: Python
File: tests/test_render.py
PR Title: [Feature] Support Fisheye BatchCamera.
BEFORE CODE: # Check that images are changing over time.
# We expect sufficient difference between two consecutive frames.
if frames_prev is not None:
for... | This decorator makes no sense here, since madrone is not supported on MacOS. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
for img_data_prev, img_data in zip(frames_prev, frame_data):
assert np.sum(np.abs(img_data_prev - img_data) > np.finfo(np.float32).eps) > DIFF_TOL * img_data.size
frames_prev = frame_data
# Add current frame to monitor video
rgb_debug, *_ = cam_debug.render(rgb=True,... | I guess (128, 128) should be good enough? | exporter.export_frame_all_cameras(i, rgb=rgb_all, depth=depth_all, segmentation=seg_all, normal=normal_all)
exporter.export_frame_single_camera(
i, cam_1.idx, rgb=rgb_1, depth=depth_1, segmentation=seg_1, normal=normal_1
)
# Check that cameras are recording d... | @@ -507,7 +507,75 @@ def test_render_api_advanced(tmp_path, n_envs, show_viewer, png_snapshot, render
# Verify that the output is correct pixel-wise over multiple simulation steps
for image_file in sorted(tmp_path.rglob("*.png")):
with open(image_file, "rb") as f:
- assert f.read() == png_... | tests/test_render.py | 26 | Python | 0.143 | question | 41 | 51 | 51 | false | [Feature] Support Fisheye BatchCamera. | 2,138 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | ACMLCZH | Review this pull request change.
Language: Python
File: tests/test_render.py
PR Title: [Feature] Support Fisheye BatchCamera.
BEFORE CODE: for img_data_prev, img_data in zip(frames_prev, frame_data):
assert np.sum(np.abs(img_data_prev - img_data) > np.finfo(np.float32).eps) > DIFF_TOL * ... | I guess (128, 128) should be good enough? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
cam_debug.stop_recording(save_to_filename=(tmp_path / "video.mp4"))
# Verify that the output is correct pixel-wise over multiple simulation steps
for image_file in sorted(tmp_path.rglob("*.png")):
with open(image_file, "rb") as f:
assert f.read() == png_snapshot, f"Image file {image_fil... | I can generate the images on the CI and upload them on Hugging Face for you if necessary. However, you should figure out why it does not match. Are the other unit tests passing? Do you have image comparison to better understand what is happening here? | # Check that images are changing over time.
# We expect sufficient difference between two consecutive frames.
if frames_prev is not None:
try:
for img_data_prev, img_data in zip(frames_prev, frame_data):
img_diff = np.abs(img_data_prev - img_data)
... | @@ -507,7 +507,75 @@ def test_render_api_advanced(tmp_path, n_envs, show_viewer, png_snapshot, render
# Verify that the output is correct pixel-wise over multiple simulation steps
for image_file in sorted(tmp_path.rglob("*.png")):
with open(image_file, "rb") as f:
- assert f.read() == png_... | tests/test_render.py | 26 | Python | 0.5 | question | 251 | 51 | 51 | false | [Feature] Support Fisheye BatchCamera. | 2,138 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | ACMLCZH | Review this pull request change.
Language: Python
File: tests/test_render.py
PR Title: [Feature] Support Fisheye BatchCamera.
BEFORE CODE: cam_debug.stop_recording(save_to_filename=(tmp_path / "video.mp4"))
# Verify that the output is correct pixel-wise over multiple simulation steps
for image_file in ... | I can generate the images on the CI and upload them on Hugging Face for you if necessary. However, you should figure out why it does not match. Are the other unit tests passing? Do you have image comparison to better understand what is happening here? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
debug=True,
)
cam_0 = scene.add_camera(
res=(512, 512),
pos=(1.5, 0.5, 1.5),
lookat=(0.0, 0.0, 0.5),
fov=45,
GUI=args.vis,
)
cam_0.attach(franka.links[6], trans_to_T(np.array([0.0, 0.5, 0.0])))
cam_1 = scene.add_camera(
res=(512, 512),
... | Could you add a new input argument to enable/disable fisheye? | GUI=args.vis,
debug=True,
)
cam_0 = scene.add_camera(
res=(512, 512),
pos=(1.5, 0.5, 1.5),
lookat=(0.0, 0.0, 0.5),
fov=45,
GUI=args.vis,
)
cam_0.attach(franka.links[6], trans_to_T(np.array([0.0, 0.5, 0.0])))
cam_1 = scene.add_camera(
re... | @@ -68,9 +68,10 @@ def main():
)
cam_2 = scene.add_camera(
res=(512, 512),
- pos=(0.0, 0.1, 5.0),
+ pos=(0.0, 0.0, 5.0),
lookat=(0.0, 0.0, 0.0),
- fov=45,
+ fov=70,
+ model="fisheye",
GUI=args.vis,
) | examples/rigid/single_franka_batch_render.py | 26 | Python | 0.286 | question | 61 | 51 | 51 | false | [Feature] Support Fisheye BatchCamera. | 2,138 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | ACMLCZH | Review this pull request change.
Language: Python
File: examples/rigid/single_franka_batch_render.py
PR Title: [Feature] Support Fisheye BatchCamera.
BEFORE CODE: debug=True,
)
cam_0 = scene.add_camera(
res=(512, 512),
pos=(1.5, 0.5, 1.5),
lookat=(0.0, 0.0, 0.5),
fov=... | Could you add a new input argument to enable/disable fisheye? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
self,
model="pinhole",
res=(320, 320),
pos=(0.5, 2.5, 3.5),
lookat=(0.5, 0.5, 0.5),
up=(0.0, 0.0, 1.0),
fov=30,
aperture=2.0,
focus_dist=None,
GUI=False,
spp=256,
denoise=None,
near=0.1,
far=20.0,
env... | Only move to next line when hitting the linewidth (120 chars), or if you are using bullet points. | far=20.0,
env_idx=None,
debug=False,
):
"""
Add a camera to the scene.
The camera model can be either 'pinhole', 'thinlens' or 'fisheye':
- The 'pinhole' model is a simple camera model that captures light rays from a single point in space.
- The 'thin... | @@ -596,9 +596,12 @@ def add_camera(
"""
Add a camera to the scene.
- The camera model can be either 'pinhole' or 'thinlens'. The 'pinhole' model is a simple camera model that
- captures light rays from a single point in space. The 'thinlens' model is a more complex camera model that
-... | genesis/engine/scene.py | 26 | Python | 0.286 | suggestion | 97 | 51 | 51 | false | [Feature] Support Fisheye BatchCamera. | 2,138 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | ACMLCZH | Review this pull request change.
Language: Python
File: genesis/engine/scene.py
PR Title: [Feature] Support Fisheye BatchCamera.
BEFORE CODE: self,
model="pinhole",
res=(320, 320),
pos=(0.5, 2.5, 3.5),
lookat=(0.5, 0.5, 0.5),
up=(0.0, 0.0, 1.0),
fov=30,
... | Only move to next line when hitting the linewidth (120 chars), or if you are using bullet points. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
raise
frames_prev = frame_data
# Add current frame to monitor video
rgb_debug, *_ = cam_debug.render(rgb=True, depth=False, segmentation=False, colorize_seg=False, normal=False)
assert isinstance(rgb_debug, np.ndarray)
assert rgb_debug.shape == (480, 640, 3)
... | I would suggest to define some helper method:
```python
def _create_scene_batch_render(show_viewer, renderer, camera_model):
[...]
```
Then define 2 completely independent unit test for batch texture and camera types. This way, it would be easier to diagnose the issue in case of CI failure. | raise
frames_prev = frame_data
# Add current frame to monitor video
rgb_debug, *_ = cam_debug.render(rgb=True, depth=False, segmentation=False, colorize_seg=False, normal=False)
assert isinstance(rgb_debug, np.ndarray)
assert rgb_debug.shape == (480, 640, 3)
... | @@ -536,7 +536,8 @@ def test_render_api_advanced(tmp_path, n_envs, show_viewer, png_snapshot, render
@pytest.mark.required
@pytest.mark.parametrize("renderer_type", [RENDERER_TYPE.BATCHRENDER_RASTERIZER, RENDERER_TYPE.BATCHRENDER_RAYTRACER])
-def test_batch_texture(show_viewer, png_snapshot, renderer):
+@pytest.mar... | tests/test_render.py | 26 | Python | 0.929 | bug | 297 | 51 | 51 | false | [Feature] Support Fisheye BatchCamera. | 2,138 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | ACMLCZH | Review this pull request change.
Language: Python
File: tests/test_render.py
PR Title: [Feature] Support Fisheye BatchCamera.
BEFORE CODE: raise
frames_prev = frame_data
# Add current frame to monitor video
rgb_debug, *_ = cam_debug.render(rgb=True, depth=False, segmentation... | I would suggest to define some helper method:
```python
def _create_scene_batch_render(show_viewer, renderer, camera_model):
[...]
```
Then define 2 completely independent unit test for batch texture and camera types. This way, it would be easier to diagnose the issue in case of CI failure. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
self._gravity.from_numpy(gravity)
# ------------------------------------------------------------------------------------
# -------------------------------------- misc ----------------------------------------
# ------------------------------------------------------------------------------------
... | Just do `for u, v, w in ti.ndrange(*self.res):` | self._gravity.from_numpy(gravity)
# ------------------------------------------------------------------------------------
# -------------------------------------- misc ----------------------------------------
# ------------------------------------------------------------------------------------
... | @@ -97,12 +97,13 @@ def reset_swap(self):
@ti.kernel
def pressure_jacobi(self, pf: ti.template(), new_pf: ti.template()):
for I in ti.grouped(ti.ndrange(*self.res)):
- pl = pf[self.compute_location(*I, -1, 0, 0)]
- pr = pf[self.compute_location(*I, 1, 0, 0)]
- pb = pf... | genesis/engine/solvers/sf_solver.py | 26 | Python | 0.214 | suggestion | 47 | 51 | 51 | false | [MISC] Avoid argument unpacking in GsTaichi kernels fo SFSolver. | 2,151 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | hughperkins | Review this pull request change.
Language: Python
File: genesis/engine/solvers/sf_solver.py
PR Title: [MISC] Avoid argument unpacking in GsTaichi kernels fo SFSolver.
BEFORE CODE: self._gravity.from_numpy(gravity)
# -----------------------------------------------------------------------------------... | Just do `for u, v, w in ti.ndrange(*self.res):` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@ti.data_oriented
class RigidVisGeom(RBC):
"""
A `RigidVisGeom` is a counterpart of `RigidGeom`, but for visualization purposes. This can be accessed via `link.vis_geoms`.
"""
def __init__(
self,
link,
idx,
vvert_start,
vface_start,
vmesh,
init_po... | Will this take a long time to preprocess every time if vmesh is very big? | link,
idx,
vvert_start,
vface_start,
vmesh,
init_pos,
init_quat,
):
self._link = link
self._entity = link.entity
self._material = link.entity.material
self._solver = link.entity.solver
self._vmesh = vmesh
# Lazy... | @@ -839,6 +842,14 @@ def __init__(
self._solver = link.entity.solver
self._vmesh = vmesh
+ # Note that ggressiveness has been tuned to give sub-millimeter accuracy most of the time
+ aabb_mesh = vmesh.copy()
+ aabb_mesh.convexify()
+ aabb_mesh.decimate(decimate_face_num=N... | genesis/engine/entities/rigid_entity/rigid_geom.py | 26 | Python | 0.214 | question | 73 | 51 | 51 | false | [FEATURE] Add method to compute axis-aligned bounding boxes of visual geometries. | 2,185 | Genesis-Embodied-AI/Genesis | 26,702 | Python | YilingQiao | duburcqa | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_geom.py
PR Title: [FEATURE] Add method to compute axis-aligned bounding boxes of visual geometries.
BEFORE CODE: @ti.data_oriented
class RigidVisGeom(RBC):
"""
A `RigidVisGeom` is a counterpart of `RigidGeom`,... | Will this take a long time to preprocess every time if vmesh is very big? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
test_by_psid = get_test_name_by_pid()
num_tests = len(test_by_psid)
_mem_by_test = {}
for psid, test in test_by_psid.items():
if psid not in mem_by_pid:
continue
if test.strip() == "":
continue
_mem = mem_by_pid[psid]
... | Why are you splitting this in so many lines?! I found it more confusing than helpful.
```python
potential_output_line = (
f"{num_tests} tests running, of which {len(_mem_by_test)} on gpu. "
f"Num results written: {num_results_written} [updating] "
)
``` | last_output_line = None
while not args.die_with_parent or os.getppid() != 1:
mem_by_pid = get_cuda_usage()
test_by_psid = get_test_name_by_pid()
num_tests = len(test_by_psid)
_mem_by_test = {}
for psid, test in test_by_psid.items():
if psid not in mem_by_pid:
... | @@ -89,17 +90,18 @@ def main() -> None:
f.flush()
num_results_written += 1
spinny = "x" if disp else "+"
- print(
- num_tests,
- "tests running, of which",
- len(_mem_by_test),
- "on gpu. Num results written: ",
- n... | tests/monitor_test_mem.py | 26 | Python | 0.786 | question | 270 | 39 | 36 | false | [MISC] Reduce benchmarks GPU memory monitor debug trace spam. | 2,194 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | hughperkins | Review this pull request change.
Language: Python
File: tests/monitor_test_mem.py
PR Title: [MISC] Reduce benchmarks GPU memory monitor debug trace spam.
BEFORE CODE: test_by_psid = get_test_name_by_pid()
num_tests = len(test_by_psid)
_mem_by_test = {}
for psid, test in test_by_psid.... | Why are you splitting this in so many lines?! I found it more confusing than helpful.
```python
potential_output_line = (
f"{num_tests} tests running, of which {len(_mem_by_test)} on gpu. "
f"Num results written: {num_results_written} [updating] "
)
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
continue
_mem = mem_by_pid[psid]
_mem_by_test[test] = _mem
for test, _mem in _mem_by_test.items():
max_mem_by_test[test] = max(_mem, max_mem_by_test[test])
for _test, _mem in old_mem_by_test.items():
if _test not in _mem_by_test:
... | Could you add some global variable in uppercase on top of this script instead of an hard-coded constant? | if psid not in mem_by_pid:
continue
if test.strip() == "":
continue
_mem = mem_by_pid[psid]
_mem_by_test[test] = _mem
for test, _mem in _mem_by_test.items():
max_mem_by_test[test] = max(_mem, max_mem_by_test[test])
... | @@ -89,17 +90,18 @@ def main() -> None:
f.flush()
num_results_written += 1
spinny = "x" if disp else "+"
- print(
- num_tests,
- "tests running, of which",
- len(_mem_by_test),
- "on gpu. Num results written: ",
- n... | tests/monitor_test_mem.py | 26 | Python | 0.429 | question | 104 | 32 | 29 | false | [MISC] Reduce benchmarks GPU memory monitor debug trace spam. | 2,194 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | hughperkins | Review this pull request change.
Language: Python
File: tests/monitor_test_mem.py
PR Title: [MISC] Reduce benchmarks GPU memory monitor debug trace spam.
BEFORE CODE: continue
_mem = mem_by_pid[psid]
_mem_by_test[test] = _mem
for test, _mem in _mem_by_test.items():
... | Could you add some global variable in uppercase on top of this script instead of an hard-coded constant? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
#!/bin/bash
set -ex
curl -LsSf https://astral.sh/uv/install.sh | sh
which uv
uv --version
uv venv --python '3.10' /venv
source /venv/bin/activate
uv pip install torch --index-url https://download.pytorch.org/whl/cu129
uv pip install ".[dev,render]"
| Why not to use the same script in both cases? I see no reason to use different venv config in both cases. | #!/bin/bash
set -ex
curl -LsSf https://astral.sh/uv/install.sh | sh
uv --version
# TODO: USD baking does not currently support Python 3.11 since
# NVIDIA does not currently release `omniverse-kit==107.3` on PyPI.
# See: https://github.com/Genesis-Embodied-AI/Genesis/pull/1300
uv venv --python '3.10' /venv
source /ve... | .github/workflows/scripts/production_build.sh | 1 | Shell | 0.429 | question | 105 | 13 | 20 | false | [MISC] Migrate from pip to uv for unit tests venv in production CI. | 2,195 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | hughperkins | Review this pull request change.
Language: Shell
File: .github/workflows/scripts/production_build.sh
PR Title: [MISC] Migrate from pip to uv for unit tests venv in production CI.
BEFORE CODE: #!/bin/bash
set -ex
curl -LsSf https://astral.sh/uv/install.sh | sh
which uv
uv --version
uv venv --python '3.10' /venv
s... | Why not to use the same script in both cases? I see no reason to use different venv config in both cases. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
#!/bin/bash
set -ex
curl -LsSf https://astral.sh/uv/install.sh | sh
which uv
uv --version
uv venv --python '3.10' /venv
source /venv/bin/activate
uv pip install torch --index-url https://download.pytorch.org/whl/cu129
uv pip install ".[dev,render]"
| This comment should probably go above, when the desired python version is specified. | #!/bin/bash
set -ex
curl -LsSf https://astral.sh/uv/install.sh | sh
uv --version
# TODO: USD baking does not currently support Python 3.11 since
# NVIDIA does not currently release `omniverse-kit==107.3` on PyPI.
# See: https://github.com/Genesis-Embodied-AI/Genesis/pull/1300
uv venv --python '3.10' /venv
source /ve... | @@ -0,0 +1,16 @@
+#!/bin/bash
+
+set -ex
+
+curl -LsSf https://astral.sh/uv/install.sh | sh
+which uv
+uv --version
+
+uv venv --python '3.10' /venv
+source /venv/bin/activate
+# TODO: USD baking does not currently support Python 3.11 since
+# NVIDIA does not currently release `omniverse-kit==107.3` on PyPI.
+# See: ht... | .github/workflows/scripts/production_build.sh | 10 | Shell | 0.286 | suggestion | 84 | 13 | 20 | false | [MISC] Migrate from pip to uv for unit tests venv in production CI. | 2,195 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | hughperkins | Review this pull request change.
Language: Shell
File: .github/workflows/scripts/production_build.sh
PR Title: [MISC] Migrate from pip to uv for unit tests venv in production CI.
BEFORE CODE: #!/bin/bash
set -ex
curl -LsSf https://astral.sh/uv/install.sh | sh
which uv
uv --version
uv venv --python '3.10' /venv
s... | This comment should probably go above, when the desired python version is specified. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
#!/bin/bash
set -ex
curl -LsSf https://astral.sh/uv/install.sh | sh
which uv
uv --version
uv venv --python '3.10' /venv
source /venv/bin/activate
uv pip install torch --index-url https://download.pytorch.org/whl/cu129
uv pip install ".[dev,render]"
| Maybe add a comment to specify that the version of cuda must tightly align with what is being installed in the Slurm container image, otherwise poorly packaged libraries such as libuipc may fail to import. | #!/bin/bash
set -ex
curl -LsSf https://astral.sh/uv/install.sh | sh
uv --version
# TODO: USD baking does not currently support Python 3.11 since
# NVIDIA does not currently release `omniverse-kit==107.3` on PyPI.
# See: https://github.com/Genesis-Embodied-AI/Genesis/pull/1300
uv venv --python '3.10' /venv
source /ve... | @@ -0,0 +1,16 @@
+#!/bin/bash
+
+set -ex
+
+curl -LsSf https://astral.sh/uv/install.sh | sh
+which uv
+uv --version
+
+uv venv --python '3.10' /venv
+source /venv/bin/activate
+# TODO: USD baking does not currently support Python 3.11 since
+# NVIDIA does not currently release `omniverse-kit==107.3` on PyPI.
+# See: ht... | .github/workflows/scripts/production_build.sh | 13 | Shell | 0.429 | bug | 205 | 13 | 20 | false | [MISC] Migrate from pip to uv for unit tests venv in production CI. | 2,195 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | hughperkins | Review this pull request change.
Language: Shell
File: .github/workflows/scripts/production_build.sh
PR Title: [MISC] Migrate from pip to uv for unit tests venv in production CI.
BEFORE CODE: #!/bin/bash
set -ex
curl -LsSf https://astral.sh/uv/install.sh | sh
which uv
uv --version
uv venv --python '3.10' /venv
s... | Maybe add a comment to specify that the version of cuda must tightly align with what is being installed in the Slurm container image, otherwise poorly packaged libraries such as libuipc may fail to import. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
#!/bin/bash
set -ex
curl -LsSf https://astral.sh/uv/install.sh | sh
uv --version
# TODO: USD baking does not currently support Python 3.11 since
# NVIDIA does not currently release `omniverse-kit==107.3` on PyPI.
# See: https://github.com/Genesis-Embodied-AI/Genesis/pull/1300
uv venv --python '3.10' /venv
source /ve... | Could you add `uv pip install pip wheel setuptools` ? | #!/bin/bash
set -ex
curl -LsSf https://astral.sh/uv/install.sh | sh
uv --version
# TODO: USD baking does not currently support Python 3.11 since
# NVIDIA does not currently release `omniverse-kit==107.3` on PyPI.
# See: https://github.com/Genesis-Embodied-AI/Genesis/pull/1300
uv venv --python '3.10' /venv
source /ve... | @@ -3,10 +3,15 @@
set -ex
curl -LsSf https://astral.sh/uv/install.sh | sh
-which uv
uv --version
+# TODO: USD baking does not currently support Python 3.11 since
+# NVIDIA does not currently release `omniverse-kit==107.3` on PyPI.
+# See: https://github.com/Genesis-Embodied-AI/Genesis/pull/1300
uv venv --python... | .github/workflows/scripts/production_build.sh | 13 | Shell | 0.429 | question | 53 | 18 | 20 | false | [MISC] Migrate from pip to uv for unit tests venv in production CI. | 2,195 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | hughperkins | Review this pull request change.
Language: Shell
File: .github/workflows/scripts/production_build.sh
PR Title: [MISC] Migrate from pip to uv for unit tests venv in production CI.
BEFORE CODE: #!/bin/bash
set -ex
curl -LsSf https://astral.sh/uv/install.sh | sh
uv --version
# TODO: USD baking does not currently su... | Could you add `uv pip install pip wheel setuptools` ? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
assert_allclose(water.get_particles_vel(), 0.0, atol=5e-2)
@pytest.mark.required
def test_mpm_particle_constraints_disabled(show_viewer):
"""Test that particle constraints raise error when disabled."""
scene = gs.Scene(
sim_options=gs.options.SimOptions(dt=2e-3, substeps=10),
mpm_options=g... | enable_particle_constraints=False by default since the data structure for constraints is hugh | assert_allclose(water.get_particles_vel(), 0.0, atol=5e-2)
@pytest.mark.required
def test_mpm_particle_constraints(show_viewer):
"""Test MPM particle constraints: bbox selection, attachment, and following."""
scene = gs.Scene(
sim_options=gs.options.SimOptions(
dt=2e-3,
sub... | @@ -221,6 +221,71 @@ def test_deformable_parallel(show_viewer):
assert_allclose(water.get_particles_vel(), 0.0, atol=5e-2)
+@pytest.mark.required
+def test_mpm_particle_constraints_disabled(show_viewer):
+ """Test that particle constraints raise error when disabled."""
+ scene = gs.Scene(
+ sim_op... | tests/test_deformable_physics.py | 26 | Python | 0.214 | suggestion | 93 | 51 | 51 | false | [FEATURE] Adds support for attaching MPM particles to rigid links. | 2,205 | Genesis-Embodied-AI/Genesis | 26,702 | Python | YilingQiao | YilingQiao | Review this pull request change.
Language: Python
File: tests/test_deformable_physics.py
PR Title: [FEATURE] Adds support for attaching MPM particles to rigid links.
BEFORE CODE: assert_allclose(water.get_particles_vel(), 0.0, atol=5e-2)
@pytest.mark.required
def test_mpm_particle_constraints_disabled(show_vi... | enable_particle_constraints=False by default since the data structure for constraints is hugh | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Returns
-------
particles_idx_local : torch.Tensor, shape (n_in_bbox,)
Local particle indices within the bounding box.
"""
bbox_min = torch.tensor(bbox_min, dtype=gs.tc_float, device=gs.device)
bbox_max = torch.tensor(bbox_max, dtype=gs.tc_float, device=gs.de... | `torch.nonzero` should be avoided because it forces GPU sync. Try supporting boolean mask all the way for efficiency. | -------
mask : torch.Tensor, shape (n_envs, n_particles)
Boolean mask where True indicates particle is within the bounding box.
"""
bbox_min = torch.as_tensor(bbox_min, dtype=gs.tc_float, device=gs.device)
bbox_max = torch.as_tensor(bbox_max, dtype=gs.tc_float, device... | @@ -581,3 +581,131 @@ def get_free(self):
free = self._sanitize_particles_tensor(None, gs.tc_bool)
self.solver._kernel_get_particles_free(self._particle_start, self._n_particles, free)
return free
+
+ # ------------------------------------------------------------------------------------
+ ... | genesis/engine/entities/mpm_entity.py | 26 | Python | 0.571 | suggestion | 117 | 51 | 51 | false | [FEATURE] Adds support for attaching MPM particles to rigid links. | 2,205 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/engine/entities/mpm_entity.py
PR Title: [FEATURE] Adds support for attaching MPM particles to rigid links.
BEFORE CODE:
Returns
-------
particles_idx_local : torch.Tensor, shape (n_in_bbox,)
Local particle indices w... | `torch.nonzero` should be avoided because it forces GPU sync. Try supporting boolean mask all the way for efficiency. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
The particles will be pulled toward their relative position on the link
using spring forces with critical damping.
Parameters
----------
particles_idx_local : array_like
Local particle indices to constrain.
link : RigidLink
The rigid link to attac... | Add support of zero copy with boolean masking. | """
if not isinstance(link_idx, int):
gs.raise_exception("link_idx must be an integer.")
if not self._solver._constraints_initialized:
self._solver.init_constraints()
# Get link position and quaternion for all envs
rigid_solver = self._sim.coupler.rigid_... | @@ -581,3 +581,131 @@ def get_free(self):
free = self._sanitize_particles_tensor(None, gs.tc_bool)
self.solver._kernel_get_particles_free(self._particle_start, self._n_particles, free)
return free
+
+ # ------------------------------------------------------------------------------------
+ ... | genesis/engine/entities/mpm_entity.py | 26 | Python | 0.071 | suggestion | 46 | 51 | 46 | false | [FEATURE] Adds support for attaching MPM particles to rigid links. | 2,205 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/engine/entities/mpm_entity.py
PR Title: [FEATURE] Adds support for attaching MPM particles to rigid links.
BEFORE CODE: The particles will be pulled toward their relative position on the link
using spring forces with critical damping.
... | Add support of zero copy with boolean masking. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@gs.assert_built
def remove_particle_constraints(self, particles_idx_local=None, envs_idx=None):
"""
Remove constraints from specified particles, or all if None.
Parameters
----------
particles_idx_local : array_like, optional
Local particle indices to uncons... | Add support of zero-copy with boolean masking. | import functools
import gstaichi as ti
import torch
import genesis as gs
from genesis.engine.states.entities import MPMEntityState
from genesis.utils.misc import to_gs_tensor
from .particle_entity import assert_active, ParticleEntity
def assert_muscle(method):
@functools.wraps(method)
def wrapper(self, *ar... | @@ -581,3 +581,131 @@ def get_free(self):
free = self._sanitize_particles_tensor(None, gs.tc_bool)
self.solver._kernel_get_particles_free(self._particle_start, self._n_particles, free)
return free
+
+ # ------------------------------------------------------------------------------------
+ ... | genesis/engine/entities/mpm_entity.py | 26 | Python | 0.071 | suggestion | 46 | 27 | 679 | false | [FEATURE] Adds support for attaching MPM particles to rigid links. | 2,205 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/engine/entities/mpm_entity.py
PR Title: [FEATURE] Adds support for attaching MPM particles to rigid links.
BEFORE CODE: @gs.assert_built
def remove_particle_constraints(self, particles_idx_local=None, envs_idx=None):
"""
Remove ... | Add support of zero-copy with boolean masking. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
class MPMOptions(Options):
"""
Options configuring the MPMSolver.
Note
----
MPM is a hybrid lagrangian-eulerian method for simulating soft materials. In the eulerian phase, it uses a grid representation. The `upper_bound` and `lower_bound` specify the simulation domain, but a safety padding will be... | I'm not convinced it is relevant to have a flag to disable this feature. What is supposed to be the drawback of enabling this systematically? Flags complexifying the control flow should only be added if necessary because it makes the codebase harder to maintain and comprehend. | class MPMOptions(Options):
"""
Options configuring the MPMSolver.
Note
----
MPM is a hybrid lagrangian-eulerian method for simulating soft materials. In the eulerian phase, it uses a grid representation. The `upper_bound` and `lower_bound` specify the simulation domain, but a safety padding will be... | @@ -431,6 +431,8 @@ class MPMOptions(Options):
Lower bound of the simulation domain. Defaults to (-1.0, -1.0, 0.0).
upper_bound : tuple, shape (3,), optional
Upper bound of the simulation domain. Defaults to (1.0, 1.0, 1.0).
+ enable_particle_constraints : bool, optional
+ Whether to en... | genesis/options/solvers.py | 26 | Python | 0.5 | suggestion | 277 | 51 | 51 | false | [FEATURE] Adds support for attaching MPM particles to rigid links. | 2,205 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/options/solvers.py
PR Title: [FEATURE] Adds support for attaching MPM particles to rigid links.
BEFORE CODE: class MPMOptions(Options):
"""
Options configuring the MPMSolver.
Note
----
MPM is a hybrid lagrangian-eulerian method for... | I'm not convinced it is relevant to have a flag to disable this feature. What is supposed to be the drawback of enabling this systematically? Flags complexifying the control flow should only be added if necessary because it makes the codebase harder to maintain and comprehend. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Note
----
Requires `enable_particle_constraints=True` in MPMOptions.
"""
from genesis.engine.entities.rigid_entity import RigidLink
if not self._solver._enable_particle_constraints:
gs.raise_exception(
"Particle constraints are disabled. Set ... | I don't think this warning is relevant. | link_quat = link_quat.unsqueeze(0)
link_pos = link_pos[:, 0, :] # (n_envs, 3)
link_quat = link_quat[:, 0, :] # (n_envs, 4)
self._solver._kernel_set_particle_constraints(
self._sim.cur_substep_local,
particles_mask,
self._particle_start,
... | @@ -581,3 +581,131 @@ def get_free(self):
free = self._sanitize_particles_tensor(None, gs.tc_bool)
self.solver._kernel_get_particles_free(self._particle_start, self._n_particles, free)
return free
+
+ # ------------------------------------------------------------------------------------
+ ... | genesis/engine/entities/mpm_entity.py | 26 | Python | 0.071 | suggestion | 39 | 51 | 33 | false | [FEATURE] Adds support for attaching MPM particles to rigid links. | 2,205 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/engine/entities/mpm_entity.py
PR Title: [FEATURE] Adds support for attaching MPM particles to rigid links.
BEFORE CODE:
Note
----
Requires `enable_particle_constraints=True` in MPMOptions.
"""
from genesis.engin... | I don't think this warning is relevant. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Maximum corner of the bounding box [x, y, z].
envs_idx : array_like, optional
Environment indices. If None, uses first environment for position query.
Returns
-------
particles_idx_local : torch.Tensor, shape (n_in_bbox,)
Local particle indices within... | Please vectorise these computations:
```python
in_bbox = (bbox_min <= poss & poss <= bbox_max).all(dim=-1)
``` | Maximum corner of the bounding box [x, y, z].
Returns
-------
mask : torch.Tensor, shape (n_envs, n_particles)
Boolean mask where True indicates particle is within the bounding box.
"""
bbox_min = torch.as_tensor(bbox_min, dtype=gs.tc_float, device=gs.dev... | @@ -581,3 +581,131 @@ def get_free(self):
free = self._sanitize_particles_tensor(None, gs.tc_bool)
self.solver._kernel_get_particles_free(self._particle_start, self._n_particles, free)
return free
+
+ # ------------------------------------------------------------------------------------
+ ... | genesis/engine/entities/mpm_entity.py | 26 | Python | 0.714 | suggestion | 110 | 51 | 51 | false | [FEATURE] Adds support for attaching MPM particles to rigid links. | 2,205 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/engine/entities/mpm_entity.py
PR Title: [FEATURE] Adds support for attaching MPM particles to rigid links.
BEFORE CODE: Maximum corner of the bounding box [x, y, z].
envs_idx : array_like, optional
Environment indices. I... | Please vectorise these computations:
```python
in_bbox = (bbox_min <= poss & poss <= bbox_max).all(dim=-1)
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@gs.assert_built
def get_particles_in_bbox(self, bbox_min, bbox_max, envs_idx=None):
"""
Get local particle indices within a bounding box.
Parameters
----------
bbox_min : array_like, shape (3,)
Minimum corner of the bounding box [x, y, z].
bbox_max :... | This is not acceptable. Please add support of batching. This is straightforward if you return a boolean mask as I requested anyway. | @gs.assert_built
def get_particles_in_bbox(self, bbox_min, bbox_max):
"""
Get boolean mask for particles within a bounding box.
Parameters
----------
bbox_min : array_like, shape (3,)
Minimum corner of the bounding box [x, y, z].
bbox_max : array_like... | @@ -581,3 +581,131 @@ def get_free(self):
free = self._sanitize_particles_tensor(None, gs.tc_bool)
self.solver._kernel_get_particles_free(self._particle_start, self._n_particles, free)
return free
+
+ # ------------------------------------------------------------------------------------
+ ... | genesis/engine/entities/mpm_entity.py | 26 | Python | 0.357 | performance | 131 | 51 | 51 | false | [FEATURE] Adds support for attaching MPM particles to rigid links. | 2,205 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/engine/entities/mpm_entity.py
PR Title: [FEATURE] Adds support for attaching MPM particles to rigid links.
BEFORE CODE: @gs.assert_built
def get_particles_in_bbox(self, bbox_min, bbox_max, envs_idx=None):
"""
Get local particle ... | This is not acceptable. Please add support of batching. This is straightforward if you return a boolean mask as I requested anyway. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
particles_idx_local : torch.Tensor, shape (n_in_bbox,)
Local particle indices within the bounding box.
"""
bbox_min = torch.tensor(bbox_min, dtype=gs.tc_float, device=gs.device)
bbox_max = torch.tensor(bbox_max, dtype=gs.tc_float, device=gs.device)
# Get particle pos... | Do not pass link but rather link_idx. We do not want to pass complex objects as input arguments. It is just asking for trouble in terms of memory management, and it is harder to keep track of the simulation state. | """
bbox_min = torch.as_tensor(bbox_min, dtype=gs.tc_float, device=gs.device)
bbox_max = torch.as_tensor(bbox_max, dtype=gs.tc_float, device=gs.device)
# Get particle positions: shape (n_envs, n_particles, 3)
poss = self.get_particles_pos()
if poss.ndim == 2:
... | @@ -581,3 +581,131 @@ def get_free(self):
free = self._sanitize_particles_tensor(None, gs.tc_bool)
self.solver._kernel_get_particles_free(self._particle_start, self._n_particles, free)
return free
+
+ # ------------------------------------------------------------------------------------
+ ... | genesis/engine/entities/mpm_entity.py | 26 | Python | 0.571 | suggestion | 213 | 51 | 51 | false | [FEATURE] Adds support for attaching MPM particles to rigid links. | 2,205 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/engine/entities/mpm_entity.py
PR Title: [FEATURE] Adds support for attaching MPM particles to rigid links.
BEFORE CODE: particles_idx_local : torch.Tensor, shape (n_in_bbox,)
Local particle indices within the bounding box.
"... | Do not pass link but rather link_idx. We do not want to pass complex objects as input arguments. It is just asking for trouble in terms of memory management, and it is harder to keep track of the simulation state. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
& (poss[:, 0] <= bbox_max[0])
& (poss[:, 1] >= bbox_min[1])
& (poss[:, 1] <= bbox_max[1])
& (poss[:, 2] >= bbox_min[2])
& (poss[:, 2] <= bbox_max[2])
)
particles_idx_local = torch.nonzero(in_bbox, as_tuple=False).squeeze(-1)
return par... | I'm not in favour of adding default value. It is very much system specific, there is no good universal default. | def set_particle_constraints(self, particles_mask, link_idx, stiffness):
"""
Attach MPM particles to a rigid link using soft constraints.
The particles will be pulled toward their relative position on the link
using spring forces with critical damping.
Parameters
--... | @@ -581,3 +581,131 @@ def get_free(self):
free = self._sanitize_particles_tensor(None, gs.tc_bool)
self.solver._kernel_get_particles_free(self._particle_start, self._n_particles, free)
return free
+
+ # ------------------------------------------------------------------------------------
+ ... | genesis/engine/entities/mpm_entity.py | 26 | Python | 0.357 | suggestion | 111 | 51 | 51 | false | [FEATURE] Adds support for attaching MPM particles to rigid links. | 2,205 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/engine/entities/mpm_entity.py
PR Title: [FEATURE] Adds support for attaching MPM particles to rigid links.
BEFORE CODE: & (poss[:, 0] <= bbox_max[0])
& (poss[:, 1] >= bbox_min[1])
& (poss[:, 1] <= bbox_max[1])
... | I'm not in favour of adding default value. It is very much system specific, there is no good universal default. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
)
def init_ckpt(self):
self._ckpt = dict()
def init_constraints(self):
"""Lazy initialization of particle constraint fields."""
self._constraints_initialized = True
particle_constraint_info = ti.types.struct(
is_constrained=gs.ti_bool, # whether particle i... | Add a check to make sure the index fits in memory -> self._n_particles * self._B * 3 < max(int32) |
def init_ckpt(self):
self._ckpt = dict()
def init_constraints(self):
"""Lazy initialization of particle constraint fields."""
# Memory check: ensure index fits in int32
if self._n_particles * self._B * 3 > np.iinfo(np.int32).max:
gs.raise_exception(
... | @@ -163,6 +165,25 @@ def init_vvert_fields(self):
def init_ckpt(self):
self._ckpt = dict()
+ def init_constraints(self):
+ """Lazy initialization of particle constraint fields."""
+ self._constraints_initialized = True
+
+ particle_constraint_info = ti.types.struct(
+ ... | genesis/engine/solvers/mpm_solver.py | 26 | Python | 0.357 | suggestion | 97 | 51 | 51 | false | [FEATURE] Adds support for attaching MPM particles to rigid links. | 2,205 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/engine/solvers/mpm_solver.py
PR Title: [FEATURE] Adds support for attaching MPM particles to rigid links.
BEFORE CODE: )
def init_ckpt(self):
self._ckpt = dict()
def init_constraints(self):
"""Lazy initialization of pa... | Add a check to make sure the index fits in memory -> self._n_particles * self._B * 3 < max(int32) | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
final_mpm_cube_pos = mpm_cube.get_particles_pos()
final_cloth_pos = cloth.get_particles_pos()
final_water_pos = water.get_particles_pos()
# check if the positions are changed
assert (init_mpm_cube_pos - final_mpm_cube_pos).abs().sum() > 0.1
assert (init_cloth_pos - final_cloth_pos).abs().sum()... | One line per option in unit tests. |
final_mpm_cube_pos = mpm_cube.get_particles_pos()
final_cloth_pos = cloth.get_particles_pos()
final_water_pos = water.get_particles_pos()
# check if the positions are changed
assert (init_mpm_cube_pos - final_mpm_cube_pos).abs().sum() > 0.1
assert (init_cloth_pos - final_cloth_pos).abs().sum()... | @@ -221,6 +221,71 @@ def test_deformable_parallel(show_viewer):
assert_allclose(water.get_particles_vel(), 0.0, atol=5e-2)
+@pytest.mark.required
+def test_mpm_particle_constraints_disabled(show_viewer):
+ """Test that particle constraints raise error when disabled."""
+ scene = gs.Scene(
+ sim_op... | tests/test_deformable_physics.py | 26 | Python | 0.071 | nitpick | 34 | 51 | 51 | false | [FEATURE] Adds support for attaching MPM particles to rigid links. | 2,205 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: tests/test_deformable_physics.py
PR Title: [FEATURE] Adds support for attaching MPM particles to rigid links.
BEFORE CODE:
final_mpm_cube_pos = mpm_cube.get_particles_pos()
final_cloth_pos = cloth.get_particles_pos()
final_water_pos = water.get_pa... | One line per option in unit tests. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
assert_allclose(cloth.get_particles_vel(), 0.0, atol=1e-5)
assert_allclose(mpm_cube.get_particles_vel(), 0.0, atol=1e-4)
assert_allclose(entity_fem._solver.get_state(0).vel, 0, atol=1e-3)
assert_allclose(water.get_particles_vel(), 0.0, atol=5e-2)
@pytest.mark.required
def test_mpm_particle_constraint... | One line per option in unit tests |
assert_allclose(cloth.get_particles_vel(), 0.0, atol=1e-5)
assert_allclose(mpm_cube.get_particles_vel(), 0.0, atol=1e-4)
assert_allclose(entity_fem._solver.get_state(0).vel, 0, atol=1e-3)
assert_allclose(water.get_particles_vel(), 0.0, atol=5e-2)
@pytest.mark.required
def test_mpm_particle_constraint... | @@ -221,6 +221,71 @@ def test_deformable_parallel(show_viewer):
assert_allclose(water.get_particles_vel(), 0.0, atol=5e-2)
+@pytest.mark.required
+def test_mpm_particle_constraints_disabled(show_viewer):
+ """Test that particle constraints raise error when disabled."""
+ scene = gs.Scene(
+ sim_op... | tests/test_deformable_physics.py | 26 | Python | 0.071 | nitpick | 33 | 51 | 51 | false | [FEATURE] Adds support for attaching MPM particles to rigid links. | 2,205 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: tests/test_deformable_physics.py
PR Title: [FEATURE] Adds support for attaching MPM particles to rigid links.
BEFORE CODE:
assert_allclose(cloth.get_particles_vel(), 0.0, atol=1e-5)
assert_allclose(mpm_cube.get_particles_vel(), 0.0, atol=1e-4)
ass... | One line per option in unit tests | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
assert_allclose(cloth.get_particles_vel(), 0.0, atol=1e-5)
assert_allclose(mpm_cube.get_particles_vel(), 0.0, atol=1e-4)
assert_allclose(entity_fem._solver.get_state(0).vel, 0, atol=1e-3)
assert_allclose(water.get_particles_vel(), 0.0, atol=5e-2)
@pytest.mark.required
def test_mpm_particle_constraint... | Make sure that batching is supported. |
assert_allclose(cloth.get_particles_vel(), 0.0, atol=1e-5)
assert_allclose(mpm_cube.get_particles_vel(), 0.0, atol=1e-4)
assert_allclose(entity_fem._solver.get_state(0).vel, 0, atol=1e-3)
assert_allclose(water.get_particles_vel(), 0.0, atol=5e-2)
@pytest.mark.required
def test_mpm_particle_constraint... | @@ -221,6 +221,71 @@ def test_deformable_parallel(show_viewer):
assert_allclose(water.get_particles_vel(), 0.0, atol=5e-2)
+@pytest.mark.required
+def test_mpm_particle_constraints_disabled(show_viewer):
+ """Test that particle constraints raise error when disabled."""
+ scene = gs.Scene(
+ sim_op... | tests/test_deformable_physics.py | 26 | Python | 0.071 | performance | 37 | 51 | 51 | false | [FEATURE] Adds support for attaching MPM particles to rigid links. | 2,205 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: tests/test_deformable_physics.py
PR Title: [FEATURE] Adds support for attaching MPM particles to rigid links.
BEFORE CODE:
assert_allclose(cloth.get_particles_vel(), 0.0, atol=1e-5)
assert_allclose(mpm_cube.get_particles_vel(), 0.0, atol=1e-4)
ass... | Make sure that batching is supported. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
enable_particle_constraints=True,
),
show_viewer=show_viewer,
)
scene.add_entity(gs.morphs.Plane())
rigid_box = scene.add_entity(gs.morphs.Box(pos=(0, 0, 0.55), size=(0.12, 0.12, 0.05), fixed=True))
mpm_cube = scene.add_entity(
material=gs.materials.MPM.Elastic(E=5e4,... | 50 steps is too much. Can you reduce this? Otherwise I'm afraid this test will be too slow. | )
scene.build(n_envs=2)
# Test get_particles_in_bbox - returns (n_envs, n_particles) mask
mask = mpm_cube.get_particles_in_bbox((-0.08, -0.08, 0.41), (0.08, 0.08, 0.44))
assert mask.shape == (2, mpm_cube.n_particles), "mask should be (n_envs, n_particles)"
assert mask.any(), "bbox should select... | @@ -221,6 +221,71 @@ def test_deformable_parallel(show_viewer):
assert_allclose(water.get_particles_vel(), 0.0, atol=5e-2)
+@pytest.mark.required
+def test_mpm_particle_constraints_disabled(show_viewer):
+ """Test that particle constraints raise error when disabled."""
+ scene = gs.Scene(
+ sim_op... | tests/test_deformable_physics.py | 26 | Python | 0.214 | performance | 91 | 51 | 51 | false | [FEATURE] Adds support for attaching MPM particles to rigid links. | 2,205 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: tests/test_deformable_physics.py
PR Title: [FEATURE] Adds support for attaching MPM particles to rigid links.
BEFORE CODE: enable_particle_constraints=True,
),
show_viewer=show_viewer,
)
scene.add_entity(gs.morphs.Plane())
... | 50 steps is too much. Can you reduce this? Otherwise I'm afraid this test will be too slow. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
scene.get_state()
for i in range(1500):
scene.step()
final_mpm_cube_pos = mpm_cube.get_particles_pos()
final_cloth_pos = cloth.get_particles_pos()
final_water_pos = water.get_particles_pos()
# check if the positions are changed
assert (init_mpm_cube_pos - final_mpm_cube_pos).abs().... | You should flag this test as slow if it is (>200s). Beware that it means that it will only run on production CI, so only do this if necessary. | scene.get_state()
for i in range(1500):
scene.step()
final_mpm_cube_pos = mpm_cube.get_particles_pos()
final_cloth_pos = cloth.get_particles_pos()
final_water_pos = water.get_particles_pos()
# check if the positions are changed
assert (init_mpm_cube_pos - final_mpm_cube_pos).abs().... | @@ -221,6 +221,71 @@ def test_deformable_parallel(show_viewer):
assert_allclose(water.get_particles_vel(), 0.0, atol=5e-2)
+@pytest.mark.required
+def test_mpm_particle_constraints_disabled(show_viewer):
+ """Test that particle constraints raise error when disabled."""
+ scene = gs.Scene(
+ sim_op... | tests/test_deformable_physics.py | 26 | Python | 0.429 | performance | 142 | 51 | 51 | false | [FEATURE] Adds support for attaching MPM particles to rigid links. | 2,205 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: tests/test_deformable_physics.py
PR Title: [FEATURE] Adds support for attaching MPM particles to rigid links.
BEFORE CODE: scene.get_state()
for i in range(1500):
scene.step()
final_mpm_cube_pos = mpm_cube.get_particles_pos()
final_clo... | You should flag this test as slow if it is (>200s). Beware that it means that it will only run on production CI, so only do this if necessary. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
pose = pose[0]
return pose[:3, 3].copy()
cam_pos_initial = _get_camera_world_pos(raster_cam_attached)
cam_pos_initial_offset_T = _get_camera_world_pos(raster_cam_offset_T)
for i in range(10): # Test over multiple steps
scene.step()
data_attached_moved = raster_cam_attache... | Not sure it is worth adding this fixture at this point since it is used only once and it seems quite specific. | pose = context._scene.get_pose(node)
if pose.ndim == 3:
pose = pose[0]
return pose[:3, 3].copy()
cam_pos_initial = _get_camera_world_pos(raster_cam_attached)
cam_pos_initial_offset_T = _get_camera_world_pos(raster_cam_offset_T)
for i in range(10): # Test over multiple ... | @@ -130,3 +131,66 @@ def _get_camera_world_pos(sensor):
cam_move_dist_offset_T = np.linalg.norm(cam_pos_final_offset_T - cam_pos_initial_offset_T)
assert cam_move_dist_offset_T > 1e-2
assert_allclose(cam_move_dist_offset_T, cam_move_dist, atol=1e-2)
+
+
+# ========================== Multi-environment tes... | tests/test_sensor_camera.py | 26 | Python | 0.429 | suggestion | 110 | 51 | 51 | false | [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1. | 2,207 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: tests/test_sensor_camera.py
PR Title: [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1.
BEFORE CODE: pose = pose[0]
return pose[:3, 3].copy()
cam_pos_initial = _get_camera_world_pos(raster_cam_attached)
cam_pos_i... | Not sure it is worth adding this fixture at this point since it is used only once and it seems quite specific. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
surface=gs.surfaces.Rough(color=(0.4, 0.4, 0.4)),
)
# Add a sphere
sphere = scene.add_entity(
morph=gs.morphs.Sphere(pos=(0.0, 0.0, 1.0), radius=0.3),
surface=gs.surfaces.Smooth(color=(1.0, 0.5, 0.5)),
)
options = gs.sensors.RasterizerCameraOptions(
res=(64, 64),
... | `sphere.set_pos([[0.0, 0.0, 1.0], [0.2, 0.0, 0.5]])` is good enough. | # Add a plane
scene.add_entity(
morph=gs.morphs.Plane(),
surface=gs.surfaces.Rough(color=(0.4, 0.4, 0.4)),
)
# Add a sphere
sphere = scene.add_entity(
morph=gs.morphs.Sphere(pos=(0.0, 0.0, 1.0), radius=0.3),
surface=gs.surfaces.Smooth(color=(1.0, 0.5, 0.5)),
)
... | @@ -130,3 +131,66 @@ def _get_camera_world_pos(sensor):
cam_move_dist_offset_T = np.linalg.norm(cam_pos_final_offset_T - cam_pos_initial_offset_T)
assert cam_move_dist_offset_T > 1e-2
assert_allclose(cam_move_dist_offset_T, cam_move_dist, atol=1e-2)
+
+
+# ========================== Multi-environment tes... | tests/test_sensor_camera.py | 26 | Python | 0.357 | suggestion | 68 | 44 | 51 | false | [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1. | 2,207 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: tests/test_sensor_camera.py
PR Title: [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1.
BEFORE CODE: surface=gs.surfaces.Rough(color=(0.4, 0.4, 0.4)),
)
# Add a sphere
sphere = scene.add_entity(
morph=gs.morphs.S... | `sphere.set_pos([[0.0, 0.0, 1.0], [0.2, 0.0, 0.5]])` is good enough. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
options = gs.sensors.RasterizerCameraOptions(
res=(64, 64),
pos=(3.0, 0.0, 1.5),
lookat=(0.0, 0.0, 0.5),
fov=60.0,
)
camera = scene.add_sensor(options)
return scene, sphere, camera
def test_rasterizer_camera_sensor_n_envs(rasterizer_camera_scene, png_snapshot):
sc... | I'm not convinced these assert descriptions are bringing any value.
| morph=gs.morphs.Sphere(pos=(0.0, 0.0, 1.0), radius=0.3),
surface=gs.surfaces.Smooth(color=(1.0, 0.5, 0.5)),
)
options = gs.sensors.RasterizerCameraOptions(
res=(64, 64), pos=(3.0, 0.0, 1.5), lookat=(0.0, 0.0, 0.5), fov=60.0, draw_debug=show_viewer
)
camera = scene.add_sensor(opt... | @@ -130,3 +131,66 @@ def _get_camera_world_pos(sensor):
cam_move_dist_offset_T = np.linalg.norm(cam_pos_final_offset_T - cam_pos_initial_offset_T)
assert cam_move_dist_offset_T > 1e-2
assert_allclose(cam_move_dist_offset_T, cam_move_dist, atol=1e-2)
+
+
+# ========================== Multi-environment tes... | tests/test_sensor_camera.py | 26 | Python | 0.214 | suggestion | 69 | 36 | 51 | false | [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1. | 2,207 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: tests/test_sensor_camera.py
PR Title: [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1.
BEFORE CODE:
options = gs.sensors.RasterizerCameraOptions(
res=(64, 64),
pos=(3.0, 0.0, 1.5),
lookat=(0.0, 0.0, 0.5),
... | I'm not convinced these assert descriptions are bringing any value.
| You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
options = gs.sensors.RasterizerCameraOptions(
res=(64, 64),
pos=(3.0, 0.0, 1.5),
lookat=(0.0, 0.0, 0.5),
fov=60.0,
)
camera = scene.add_sensor(options)
return scene, sphere, camera
def test_rasterizer_camera_sensor_n_envs(rasterizer_camera_scene, png_snapshot):
sc... | Why not just `assert (data.rgb[0] != data.rgb[1]).any()` ? | morph=gs.morphs.Sphere(pos=(0.0, 0.0, 1.0), radius=0.3),
surface=gs.surfaces.Smooth(color=(1.0, 0.5, 0.5)),
)
options = gs.sensors.RasterizerCameraOptions(
res=(64, 64), pos=(3.0, 0.0, 1.5), lookat=(0.0, 0.0, 0.5), fov=60.0, draw_debug=show_viewer
)
camera = scene.add_sensor(opt... | @@ -130,3 +131,66 @@ def _get_camera_world_pos(sensor):
cam_move_dist_offset_T = np.linalg.norm(cam_pos_final_offset_T - cam_pos_initial_offset_T)
assert cam_move_dist_offset_T > 1e-2
assert_allclose(cam_move_dist_offset_T, cam_move_dist, atol=1e-2)
+
+
+# ========================== Multi-environment tes... | tests/test_sensor_camera.py | 26 | Python | 0.357 | question | 58 | 36 | 51 | false | [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1. | 2,207 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: tests/test_sensor_camera.py
PR Title: [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1.
BEFORE CODE:
options = gs.sensors.RasterizerCameraOptions(
res=(64, 64),
pos=(3.0, 0.0, 1.5),
lookat=(0.0, 0.0, 0.5),
... | Why not just `assert (data.rgb[0] != data.rgb[1]).any()` ? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
)
# Add a plane
scene.add_entity(
morph=gs.morphs.Plane(),
surface=gs.surfaces.Rough(color=(0.4, 0.4, 0.4)),
)
# Add a sphere
sphere = scene.add_entity(
morph=gs.morphs.Sphere(pos=(0.0, 0.0, 1.0), radius=0.3),
surface=gs.surfaces.Smooth(color=(1.0, 0.5, 0.5)),
... | Missing `@pytest.mark.required` decorator. | rigid_options=gs.options.RigidOptions(),
renderer=gs.renderers.Rasterizer(),
show_viewer=show_viewer,
)
# Add a plane
scene.add_entity(
morph=gs.morphs.Plane(),
surface=gs.surfaces.Rough(color=(0.4, 0.4, 0.4)),
)
# Add a sphere
sphere = scene.add_entity(... | @@ -130,3 +131,66 @@ def _get_camera_world_pos(sensor):
cam_move_dist_offset_T = np.linalg.norm(cam_pos_final_offset_T - cam_pos_initial_offset_T)
assert cam_move_dist_offset_T > 1e-2
assert_allclose(cam_move_dist_offset_T, cam_move_dist, atol=1e-2)
+
+
+# ========================== Multi-environment tes... | tests/test_sensor_camera.py | 26 | Python | 0.214 | suggestion | 42 | 49 | 51 | false | [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1. | 2,207 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: tests/test_sensor_camera.py
PR Title: [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1.
BEFORE CODE: )
# Add a plane
scene.add_entity(
morph=gs.morphs.Plane(),
surface=gs.surfaces.Rough(color=(0.4, 0.4, 0.4)),
... | Missing `@pytest.mark.required` decorator. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
camera_wrapper = self._get_camera_wrapper()
self._shared_metadata.renderer.add_camera(camera_wrapper)
self._update_camera_pose()
n_envs = max(self._manager._sim._B, 1)
h, w = self._options.res[1], self._options.res[0]
self._shared_metadata.image_cache[self._idx] = torch... | You should probably add a warning about bad performance using Batched rendering with rasterizer, plus mention that camera pose is not batched. | self._shared_metadata.renderer.build()
self._shared_metadata.sensors.append(self)
# Add lights from options to the shared metadata
for light_config in self._options.lights:
if self._shared_metadata.lights is not None:
# Convert light config to rasterizer... | @@ -423,11 +428,22 @@ def build(self):
def _create_standalone_context(self, scene):
"""Create a simplified RasterizerContext for camera sensors."""
+ if not scene.sim._rigid_only and scene.n_envs > 1:
+ gs.raise_exception("Rasterizer with n_envs > 1, does not work when using non rigid ... | genesis/engine/sensors/camera.py | 26 | Python | 0.571 | performance | 142 | 51 | 51 | false | [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1. | 2,207 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: genesis/engine/sensors/camera.py
PR Title: [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1.
BEFORE CODE:
camera_wrapper = self._get_camera_wrapper()
self._shared_metadata.renderer.add_camera(camera_wrapper)
self._up... | You should probably add a warning about bad performance using Batched rendering with rasterizer, plus mention that camera pose is not batched. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
show_viewer=False,
)
# Add a plane
scene.add_entity(
morph=gs.morphs.Plane(),
surface=gs.surfaces.Rough(color=(0.4, 0.4, 0.4)),
)
# Add a sphere
sphere = scene.add_entity(
morph=gs.morphs.Sphere(pos=(0.0, 0.0, 1.0), radius=0.3),
surface=gs.surfaces.Smoot... | Could you add a comment to explain what you are trying to catch here? | import sys
import numpy as np
import pytest
import torch
import genesis as gs
from genesis.utils.misc import tensor_to_array
from .utils import assert_allclose, rgb_array_to_png_bytes
@pytest.mark.required
@pytest.mark.parametrize("n_envs", [0, 1])
def test_rasterizer_camera_sensor(show_viewer, tol, n_envs):
sc... | @@ -130,3 +132,106 @@ def _get_camera_world_pos(sensor):
cam_move_dist_offset_T = np.linalg.norm(cam_pos_final_offset_T - cam_pos_initial_offset_T)
assert cam_move_dist_offset_T > 1e-2
assert_allclose(cam_move_dist_offset_T, cam_move_dist, atol=1e-2)
+
+
+# ========================== Multi-environment te... | tests/test_sensor_camera.py | 26 | Python | 0.286 | question | 69 | 28 | 219 | false | [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1. | 2,207 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: tests/test_sensor_camera.py
PR Title: [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1.
BEFORE CODE: show_viewer=False,
)
# Add a plane
scene.add_entity(
morph=gs.morphs.Plane(),
surface=gs.surfaces.Rough... | Could you add a comment to explain what you are trying to catch here? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
assert png == png_snapshot
@pytest.mark.required
def test_rasterizer_camera_sensor_n_envs_attached_camera():
if sys.platform == "darwin":
pytest.skip(
"Batched rendering with Rasterizer backend is not supported on this machine because it requires OpenGL 4.2."
)
scene = gs.... | You could remove the plane. Not sure that adding a surface is relevant here but as you want. | import sys
import numpy as np
import pytest
import torch
import genesis as gs
from genesis.utils.misc import tensor_to_array
from .utils import assert_allclose, rgb_array_to_png_bytes
@pytest.mark.required
@pytest.mark.parametrize("n_envs", [0, 1])
def test_rasterizer_camera_sensor(show_viewer, tol, n_envs):
sc... | @@ -130,3 +132,106 @@ def _get_camera_world_pos(sensor):
cam_move_dist_offset_T = np.linalg.norm(cam_pos_final_offset_T - cam_pos_initial_offset_T)
assert cam_move_dist_offset_T > 1e-2
assert_allclose(cam_move_dist_offset_T, cam_move_dist, atol=1e-2)
+
+
+# ========================== Multi-environment te... | tests/test_sensor_camera.py | 26 | Python | 0.286 | suggestion | 92 | 44 | 219 | false | [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1. | 2,207 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: tests/test_sensor_camera.py
PR Title: [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1.
BEFORE CODE: assert png == png_snapshot
@pytest.mark.required
def test_rasterizer_camera_sensor_n_envs_attached_camera():
if sys.platform =... | You could remove the plane. Not sure that adding a surface is relevant here but as you want. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
assert data.rgb.shape == (2, 64, 64, 3)
assert data.rgb.dtype == torch.uint8
assert (data.rgb[0] != data.rgb[1]).any(), "We should have different frames"
from PIL import Image
import io
for i in range(n_envs):
buffer = io.BytesIO()
img0 = Image.fromarray(data.rgb[i].numpy())
... | Remove these options, they are irrelevant in this context. | assert rgb_array_to_png_bytes(data.rgb[i]) == png_snapshot
@pytest.mark.required
def test_rasterizer_camera_sensor_n_envs_attached_camera(show_viewer):
if sys.platform == "darwin":
pytest.skip(
"Batched rendering with Rasterizer backend is not supported on this machine because it requi... | @@ -130,3 +132,106 @@ def _get_camera_world_pos(sensor):
cam_move_dist_offset_T = np.linalg.norm(cam_pos_final_offset_T - cam_pos_initial_offset_T)
assert cam_move_dist_offset_T > 1e-2
assert_allclose(cam_move_dist_offset_T, cam_move_dist, atol=1e-2)
+
+
+# ========================== Multi-environment te... | tests/test_sensor_camera.py | 26 | Python | 0.286 | suggestion | 58 | 51 | 36 | false | [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1. | 2,207 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: tests/test_sensor_camera.py
PR Title: [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1.
BEFORE CODE: assert data.rgb.shape == (2, 64, 64, 3)
assert data.rgb.dtype == torch.uint8
assert (data.rgb[0] != data.rgb[1]).any(), "We shou... | Remove these options, they are irrelevant in this context. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if pose.ndim == 3:
pose = pose[0]
return pose[:3, 3].copy()
cam_pos_initial = _get_camera_world_pos(raster_cam_attached)
cam_pos_initial_offset_T = _get_camera_world_pos(raster_cam_offset_T)
for i in range(10): # Test over multiple steps
scene.step()
data_attached... | Consider supporting `show_viewer`. This "global" flag is used to enable interactive viewer within unit tests. This is meant to use debugging in case of failure. It is enabled via the comment line argument `--vis`. Not sure if it is useful in this context. In this case, it should enable `show_viewer=True` at scene leve... | pose = context._scene.get_pose(node)
if pose.ndim == 3:
pose = pose[0]
return pose[:3, 3].copy()
cam_pos_initial = _get_camera_world_pos(raster_cam_attached)
cam_pos_initial_offset_T = _get_camera_world_pos(raster_cam_offset_T)
for i in range(10): # Test over multiple ... | @@ -130,3 +132,106 @@ def _get_camera_world_pos(sensor):
cam_move_dist_offset_T = np.linalg.norm(cam_pos_final_offset_T - cam_pos_initial_offset_T)
assert cam_move_dist_offset_T > 1e-2
assert_allclose(cam_move_dist_offset_T, cam_move_dist, atol=1e-2)
+
+
+# ========================== Multi-environment te... | tests/test_sensor_camera.py | 26 | Python | 0.786 | bug | 390 | 51 | 51 | false | [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1. | 2,207 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: tests/test_sensor_camera.py
PR Title: [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1.
BEFORE CODE: if pose.ndim == 3:
pose = pose[0]
return pose[:3, 3].copy()
cam_pos_initial = _get_camera_world_pos(raster_... | Consider supporting `show_viewer`. This "global" flag is used to enable interactive viewer within unit tests. This is meant to use debugging in case of failure. It is enabled via the comment line argument `--vis`. Not sure if it is useful in this context. In this case, it should enable `show_viewer=True` at scene leve... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
sphere = scene.add_entity(
morph=gs.morphs.Sphere(pos=(0.0, 0.0, 1.0), radius=0.3),
surface=gs.surfaces.Smooth(color=(1.0, 0.5, 0.5)),
)
options = gs.sensors.RasterizerCameraOptions(
res=(64, 64),
pos=(3.0, 0.0, 1.5),
lookat=(0.0, 0.0, 0.5),
fov=60.0,
)
... | You can move these imports only top level of this file. | surface=gs.surfaces.Smooth(color=(1.0, 0.5, 0.5)),
)
options = gs.sensors.RasterizerCameraOptions(
res=(64, 64), pos=(3.0, 0.0, 1.5), lookat=(0.0, 0.0, 0.5), fov=60.0, draw_debug=show_viewer
)
camera = scene.add_sensor(options)
n_envs = 2
scene.build(n_envs=n_envs)
sphere.s... | @@ -130,3 +132,106 @@ def _get_camera_world_pos(sensor):
cam_move_dist_offset_T = np.linalg.norm(cam_pos_final_offset_T - cam_pos_initial_offset_T)
assert cam_move_dist_offset_T > 1e-2
assert_allclose(cam_move_dist_offset_T, cam_move_dist, atol=1e-2)
+
+
+# ========================== Multi-environment te... | tests/test_sensor_camera.py | 26 | Python | 0.286 | suggestion | 55 | 51 | 51 | false | [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1. | 2,207 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: tests/test_sensor_camera.py
PR Title: [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1.
BEFORE CODE: sphere = scene.add_entity(
morph=gs.morphs.Sphere(pos=(0.0, 0.0, 1.0), radius=0.3),
surface=gs.surfaces.Smooth(color=(1.... | You can move these imports only top level of this file. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
pos=(3.0, 0.0, 1.5),
lookat=(0.0, 0.0, 0.5),
fov=60.0,
)
camera = scene.add_sensor(options)
n_envs = 2
scene.build(n_envs=n_envs)
sphere.set_pos([[0.0, 0.0, 1.0], [0.2, 0.0, 0.5]])
scene.step()
data = camera.read()
assert data.rgb.shape == (2, 64, 64, 3)
a... | Just do `rgb_array_to_png_bytes(data.rgb[i]) == png_snapshot` | n_envs = 2
scene.build(n_envs=n_envs)
sphere.set_pos([[0.0, 0.0, 1.0], [0.2, 0.0, 0.5]])
scene.step()
data = camera.read()
assert data.rgb.shape == (2, 64, 64, 3)
assert data.rgb.dtype == torch.uint8
assert (data.rgb[0] != data.rgb[1]).any(), "We should have different frames"
fo... | @@ -130,3 +132,106 @@ def _get_camera_world_pos(sensor):
cam_move_dist_offset_T = np.linalg.norm(cam_pos_final_offset_T - cam_pos_initial_offset_T)
assert cam_move_dist_offset_T > 1e-2
assert_allclose(cam_move_dist_offset_T, cam_move_dist, atol=1e-2)
+
+
+# ========================== Multi-environment te... | tests/test_sensor_camera.py | 26 | Python | 0.357 | suggestion | 61 | 51 | 50 | false | [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1. | 2,207 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: tests/test_sensor_camera.py
PR Title: [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1.
BEFORE CODE: pos=(3.0, 0.0, 1.5),
lookat=(0.0, 0.0, 0.5),
fov=60.0,
)
camera = scene.add_sensor(options)
n_envs = 2
... | Just do `rgb_array_to_png_bytes(data.rgb[i]) == png_snapshot` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
import numpy as np
import pytest
import torch
import sys
import genesis as gs
from genesis.utils.misc import tensor_to_array
from .utils import assert_allclose
@pytest.mark.required
@pytest.mark.parametrize("n_envs", [0, 1])
def test_rasterizer_camera_sensor(show_viewer, tol, n_envs):
scene = gs.Scene(
p... | We are (manually sadly...) organising imports. Here is the rule: You should first import standards libraries, skip line, then ubiquitous third-party libraries (torch, numpy, tqdm...etc), skip line, then random third-party libraries, skip line, then our own custom libraries, skip line, then relative genesis imports. For... | import sys
import numpy as np
import pytest
import torch
import genesis as gs
from genesis.utils.misc import tensor_to_array
from .utils import assert_allclose, rgb_array_to_png_bytes
@pytest.mark.required
@pytest.mark.parametrize("n_envs", [0, 1])
def test_rasterizer_camera_sensor(show_viewer, tol, n_envs):
sc... | @@ -1,5 +1,7 @@
import numpy as np
import pytest
+import torch
+import sys | tests/test_sensor_camera.py | 4 | Python | 0.5 | style | 371 | 29 | 29 | false | [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1. | 2,207 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: tests/test_sensor_camera.py
PR Title: [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1.
BEFORE CODE: import numpy as np
import pytest
import torch
import sys
import genesis as gs
from genesis.utils.misc import tensor_to_array
from .utils im... | We are (manually sadly...) organising imports. Here is the rule: You should first import standards libraries, skip line, then ubiquitous third-party libraries (torch, numpy, tqdm...etc), skip line, then random third-party libraries, skip line, then our own custom libraries, skip line, then relative genesis imports. For... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
import numpy as np
from numpy.__config__ import show
import pytest
import torch
import sys
import genesis as gs
from genesis.utils.misc import tensor_to_array
from .utils import assert_allclose, rgb_array_to_png_bytes
@pytest.mark.required
@pytest.mark.parametrize("n_envs", [0, 1])
def test_rasterizer_camera_sensor(... | You added this line by mistake. | import sys
import numpy as np
import pytest
import torch
import genesis as gs
from genesis.utils.misc import tensor_to_array
from .utils import assert_allclose, rgb_array_to_png_bytes
@pytest.mark.required
@pytest.mark.parametrize("n_envs", [0, 1])
def test_rasterizer_camera_sensor(show_viewer, tol, n_envs):
sc... | @@ -1,9 +1,12 @@
import numpy as np
+from numpy.__config__ import show | tests/test_sensor_camera.py | 2 | Python | 0.071 | suggestion | 31 | 27 | 27 | false | [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1. | 2,207 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: tests/test_sensor_camera.py
PR Title: [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1.
BEFORE CODE: import numpy as np
from numpy.__config__ import show
import pytest
import torch
import sys
import genesis as gs
from genesis.utils.misc imp... | You added this line by mistake. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
import numpy as np
from numpy.__config__ import show
import pytest
import torch
import sys
import genesis as gs
from genesis.utils.misc import tensor_to_array
from .utils import assert_allclose, rgb_array_to_png_bytes
@pytest.mark.required
@pytest.mark.parametrize("n_envs", [0, 1])
def test_rasterizer_camera_sensor(... | `import sys` should be moved on top, separated from the rest. | import sys
import numpy as np
import pytest
import torch
import genesis as gs
from genesis.utils.misc import tensor_to_array
from .utils import assert_allclose, rgb_array_to_png_bytes
@pytest.mark.required
@pytest.mark.parametrize("n_envs", [0, 1])
def test_rasterizer_camera_sensor(show_viewer, tol, n_envs):
sc... | @@ -1,9 +1,12 @@
import numpy as np
+from numpy.__config__ import show
import pytest
+import torch
+import sys | tests/test_sensor_camera.py | 5 | Python | 0.429 | suggestion | 61 | 30 | 30 | false | [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1. | 2,207 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: tests/test_sensor_camera.py
PR Title: [FEATURE] Enabling rasterizer camera sensor to work with n_envs > 1.
BEFORE CODE: import numpy as np
from numpy.__config__ import show
import pytest
import torch
import sys
import genesis as gs
from genesis.utils.misc imp... | `import sys` should be moved on top, separated from the rest. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# add every node with geometry to the pyrender scene
for node in trimesh_scene.graph.nodes_geometry:
pose, geom_name = trimesh_scene.graph[node]
scene_pr.add(geometries[geom_name], pose=pose)
return scene_pr
def sorted_mesh_nodes(self):
cam_pos = self.get_p... | This part is happening before the rendering pass so we don't really have `env_idx` here.
Before (with `cam_loc` unbatched) we were already using this behavior. So this is not modifying behavior even if it looks wrong/odd.
Given the TODO I decided to leave it as-is as it might warrant a bigger change to "fix" this (if... |
# add every node with geometry to the pyrender scene
for node in trimesh_scene.graph.nodes_geometry:
pose, geom_name = trimesh_scene.graph[node]
scene_pr.add(geometries[geom_name], pose=pose)
return scene_pr
def sorted_mesh_nodes(self):
cam_pos = self.get_p... | @@ -612,7 +618,11 @@ def sorted_mesh_nodes(self):
solid_nodes.append(node)
# TODO BETTER SORTING METHOD
- trans_nodes.sort(key=lambda n: -np.linalg.norm(self.get_pose(n)[:3, 3] - cam_loc))
- solid_nodes.sort(key=lambda n: -np.linalg.norm(self.get_pose(n)[:3, 3] - cam_loc))
+ ... | genesis/ext/pyrender/scene.py | 26 | Python | 0.643 | bug | 389 | 35 | 32 | false | [FEATURE] Support attaching camera sensors with Rasterizer batched rendering. | 2,212 | Genesis-Embodied-AI/Genesis | 26,702 | Python | Narsil | Narsil | Review this pull request change.
Language: Python
File: genesis/ext/pyrender/scene.py
PR Title: [FEATURE] Support attaching camera sensors with Rasterizer batched rendering.
BEFORE CODE:
# add every node with geometry to the pyrender scene
for node in trimesh_scene.graph.nodes_geometry:
... | This part is happening before the rendering pass so we don't really have `env_idx` here.
Before (with `cam_loc` unbatched) we were already using this behavior. So this is not modifying behavior even if it looks wrong/odd.
Given the TODO I decided to leave it as-is as it might warrant a bigger change to "fix" this (if... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Returns
-------
scene_pr : :class:`Scene`
A scene containing the same geometry as the trimesh scene.
"""
# convert trimesh geometries to pyrender geometries
geometries = {name: Mesh.from_trimesh(geom) for name, geom in trimesh_scene.geometry.items()}
... | What about
```python
cam_pos = self.get_pose(self.main_camera_node)[..., :3, 3]
batched_pos = len(cam_pos.shape) == 2
```
? | Returns
-------
scene_pr : :class:`Scene`
A scene containing the same geometry as the trimesh scene.
"""
# convert trimesh geometries to pyrender geometries
geometries = {name: Mesh.from_trimesh(geom) for name, geom in trimesh_scene.geometry.items()}
... | @@ -601,7 +601,13 @@ def from_trimesh_scene(trimesh_scene, bg_color=None, ambient_light=None):
return scene_pr
def sorted_mesh_nodes(self):
- cam_loc = self.get_pose(self.main_camera_node)[:3, 3]
+ cam_pos = self.get_pose(self.main_camera_node)
+ if len(cam_pos.shape) == 3:
+ ... | genesis/ext/pyrender/scene.py | 26 | Python | 0.714 | performance | 125 | 45 | 42 | false | [FEATURE] Support attaching camera sensors with Rasterizer batched rendering. | 2,212 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: genesis/ext/pyrender/scene.py
PR Title: [FEATURE] Support attaching camera sensors with Rasterizer batched rendering.
BEFORE CODE: Returns
-------
scene_pr : :class:`Scene`
A scene containing the same geometry as the trimesh... | What about
```python
cam_pos = self.get_pose(self.main_camera_node)[..., :3, 3]
batched_pos = len(cam_pos.shape) == 2
```
? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
scene = gs.Scene(show_viewer=show_viewer)
# Add a plane
scene.add_entity(
morph=gs.morphs.Plane(),
)
# Add a sphere
sphere = scene.add_entity(
morph=gs.morphs.Sphere(
radius=0.3,
pos=(0.0, 0.0, 1.0),
),
surface=gs.surfaces.Smooth(
... | Maybe enable debug_draw with show_viewer ? | scene = gs.Scene(show_viewer=show_viewer)
# Add a plane
scene.add_entity(
morph=gs.morphs.Plane(),
)
# Add a sphere
sphere = scene.add_entity(
morph=gs.morphs.Sphere(
radius=0.3,
pos=(0.0, 0.0, 1.0),
),
surface=gs.surfaces.Smooth(
... | @@ -206,11 +211,28 @@ def test_rasterizer_camera_sensor_n_envs_attached_camera():
),
)
- scene.add_sensor(
- gs.sensors.RasterizerCameraOptions(
- entity_idx=sphere.idx,
- )
+ options = gs.sensors.RasterizerCameraOptions(
+ res=(64, 64),
+ pos=(-0.4, 0.1, 2.0... | tests/test_sensor_camera.py | 26 | Python | 0.214 | bug | 42 | 44 | 45 | false | [FEATURE] Support attaching camera sensors with Rasterizer batched rendering. | 2,212 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: tests/test_sensor_camera.py
PR Title: [FEATURE] Support attaching camera sensors with Rasterizer batched rendering.
BEFORE CODE: scene = gs.Scene(show_viewer=show_viewer)
# Add a plane
scene.add_entity(
morph=gs.morphs.Plane(),
)
... | Maybe enable debug_draw with show_viewer ? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
batch_idx,
geoms_state: array_class.GeomsState,
geoms_info: array_class.GeomsInfo,
links_state: array_class.LinksState,
sdf_info: array_class.SDFInfo,
rigid_global_info: array_class.RigidGlobalInfo,
collider_static_config: ti.template(),
):
"""
... | Just comment the entire function call. It is linked to some commented code block 5 lines below. | batch_idx,
geoms_state: array_class.GeomsState,
geoms_info: array_class.GeomsInfo,
links_state: array_class.LinksState,
sdf_info: array_class.SDFInfo,
rigid_global_info: array_class.RigidGlobalInfo,
collider_static_config: ti.template(),
):
"""
... | genesis/engine/couplers/legacy_coupler.py | 26 | Python | 0.214 | suggestion | 95 | 51 | 51 | false | [MISC] Re-enable more Ruff format rules. | 2,215 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: genesis/engine/couplers/legacy_coupler.py
PR Title: [MISC] Re-enable more Ruff format rules.
BEFORE CODE: batch_idx,
geoms_state: array_class.GeomsState,
geoms_info: array_class.GeomsInfo,
links_state: array_class.LinksState,
... | Just comment the entire function call. It is linked to some commented code block 5 lines below. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
self.fem_state_v.impulse[i_b, i_v].norm_sqr() / self.fem_solver.elements_v_info[i_v].mass
)
@ti.func
def add_rigid_norms(self, rigid_global_info: array_class.RigidGlobalInfo):
for i_b, i_d in ti.ndrange(self._B, self.rigid_solver.n_dofs):
if not self.batch_active... | WTF?? The original code is garbage. This bug was introduced in this PR:
https://github.com/Genesis-Embodied-AI/Genesis/pull/1565/changes | self.fem_state_v.impulse[i_b, i_v].norm_sqr() / self.fem_solver.elements_v_info[i_v].mass
)
@ti.func
def add_rigid_norms(self, rigid_global_info: array_class.RigidGlobalInfo):
for i_b, i_d in ti.ndrange(self._B, self.rigid_solver.n_dofs):
if not self.batch_active... | @@ -851,7 +851,7 @@ def update_batch_active(self):
for i_b in range(self._B):
if not self.batch_active[i_b]:
continue
- norm_thr = self._sap_convergence_atol + self._sap_convergence_rtol * ti.max(
+ self._sap_convergence_atol + self._sap_convergence_rtol * ti... | genesis/engine/couplers/sap_coupler.py | 26 | Python | 0.571 | bug | 137 | 51 | 51 | false | [MISC] Re-enable more Ruff format rules. | 2,215 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: genesis/engine/couplers/sap_coupler.py
PR Title: [MISC] Re-enable more Ruff format rules.
BEFORE CODE: self.fem_state_v.impulse[i_b, i_v].norm_sqr() / self.fem_solver.elements_v_info[i_v].mass
)
@ti.func
def add_rigid_norms... | WTF?? The original code is garbage. This bug was introduced in this PR:
https://github.com/Genesis-Embodied-AI/Genesis/pull/1565/changes | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
from dataclasses import dataclass, field
from functools import partial
from typing import TYPE_CHECKING, Generic, Sequence, Type, TypeVar
import gstaichi as ti
import numpy as np
import torch
import genesis as gs
from genesis.options.sensors.options import SensorOptions
from genesis.repr_base import RBC
from genesis.... | I would advice to add this in TYPE_CHECKING block for consistency. | from dataclasses import dataclass, field
from functools import partial
from typing import TYPE_CHECKING, Generic, Sequence, Type, TypeVar
import gstaichi as ti
import numpy as np
import torch
import genesis as gs
from genesis.repr_base import RBC
from genesis.utils.geom import euler_to_quat
from genesis.utils.misc im... | @@ -7,6 +7,7 @@
import torch
import genesis as gs
+from genesis.options.sensors.options import SensorOptions | genesis/engine/sensors/base_sensor.py | 10 | Python | 0.357 | style | 66 | 35 | 35 | false | [MISC] Re-enable more Ruff format rules. | 2,215 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: genesis/engine/sensors/base_sensor.py
PR Title: [MISC] Re-enable more Ruff format rules.
BEFORE CODE: from dataclasses import dataclass, field
from functools import partial
from typing import TYPE_CHECKING, Generic, Sequence, Type, TypeVar
import gstaichi as ... | I would advice to add this in TYPE_CHECKING block for consistency. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
improvement = gs.ti_float(0.0)
if i_iter == 0:
for i_c in range(constraint_state.n_constraints[i_b]):
improvement += 0.5 * constraint_state.efc_force[i_c, i_b] ** 2 * constraint_state.diag[i_c, i_b]
for i_c in range(ne, ne + nf):
r... | @YilingQiao Why mu is not used? Is this expected?? | improvement = gs.ti_float(0.0)
if i_iter == 0:
for i_c in range(constraint_state.n_constraints[i_b]):
improvement += 0.5 * constraint_state.efc_force[i_c, i_b] ** 2 * constraint_state.diag[i_c, i_b]
for i_c in range(ne, ne + nf):
r... | @@ -109,7 +109,7 @@ def kernel_noslip(
# Project contact friction (pyramidal 4-edge) with normal fixed
for i_col in range(n_con):
base = const_start + i_col * 4
- mu = collider_state.contact_data.friction[i_col, i_b]
+ collider_state.contact_data.... | genesis/engine/solvers/rigid/constraint_noslip.py | 26 | Python | 0.286 | question | 50 | 51 | 51 | false | [MISC] Re-enable more Ruff format rules. | 2,215 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/constraint_noslip.py
PR Title: [MISC] Re-enable more Ruff format rules.
BEFORE CODE: improvement = gs.ti_float(0.0)
if i_iter == 0:
for i_c in range(constraint_state.n_constraints[i_b]):
... | @YilingQiao Why mu is not used? Is this expected?? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
from typing import TYPE_CHECKING
import gstaichi as ti
import genesis as gs
import genesis.utils.array_class as array_class
if TYPE_CHECKING:
from genesis.engine.solvers.rigid.collider_decomp import Collider
from genesis.engine.solvers.rigid.rigid_solver_decomp import RigidSolver
@ti.data_oriented
class Co... | Remove this structure entirely. | from typing import TYPE_CHECKING
import gstaichi as ti
import genesis as gs
import genesis.utils.array_class as array_class
if TYPE_CHECKING:
from genesis.engine.solvers.rigid.collider_decomp import Collider
from genesis.engine.solvers.rigid.rigid_solver_decomp import RigidSolver
@ti.data_oriented
class Co... | genesis/engine/solvers/rigid/contact_island.py | 23 | Python | 0.143 | refactor | 31 | 48 | 48 | false | [MISC] Re-enable more Ruff format rules. | 2,215 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/contact_island.py
PR Title: [MISC] Re-enable more Ruff format rules.
BEFORE CODE: from typing import TYPE_CHECKING
import gstaichi as ti
import genesis as gs
import genesis.utils.array_class as array_class
if TYPE_CHECKING:
... | Remove this structure entirely. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
The name of the parent node, can be specified instead of
`parent_node`.
Returns
-------
node : :class:`Node`
The newly-created and inserted node.
"""
if isinstance(obj, Mesh):
node = Node(name=name, matrix=pose, mesh=obj)
e... | This is less efficient I think. | The name of the parent node, can be specified instead of
`parent_node`.
Returns
-------
node : :class:`Node`
The newly-created and inserted node.
"""
if isinstance(obj, Mesh):
node = Node(name=name, matrix=pose, mesh=obj)
e... | @@ -293,14 +292,12 @@ def add(self, obj, name=None, pose=None, parent_node=None, parent_name=None):
raise TypeError("Unrecognized object type")
if parent_node is None and parent_name is not None:
- try:
- (parent_node,) = self.get_nodes(name=parent_name)
- ex... | genesis/ext/pyrender/scene.py | 26 | Python | 0.071 | performance | 31 | 51 | 51 | false | [MISC] Re-enable more Ruff format rules. | 2,215 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: genesis/ext/pyrender/scene.py
PR Title: [MISC] Re-enable more Ruff format rules.
BEFORE CODE: The name of the parent node, can be specified instead of
`parent_node`.
Returns
-------
node : :class:`Node`
... | This is less efficient I think. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
self._meshes = value
@classmethod
def _from_xml(cls, node, root, path):
kwargs = cls._parse(node, root, path)
# Load the mesh, combining collision geometry meshes but keeping
# visual ones separate to preserve colors and textures
fn = get_filename(path, kwargs["filename... | Update comment: `# Make sure that parent directory exists` | self._meshes = value
@classmethod
def _from_xml(cls, node, root, path):
kwargs = cls._parse(node, root, path)
# Load the mesh, combining collision geometry meshes but keeping
# visual ones separate to preserve colors and textures
fn = get_filename(path, kwargs["filename... | @@ -673,7 +673,7 @@ def _from_xml(cls, node, root, path):
def _to_xml(self, parent, path):
# Get the filename | genesis/ext/urdfpy/urdf.py | 26 | Python | 0.357 | suggestion | 58 | 51 | 51 | false | [MISC] Re-enable more Ruff format rules. | 2,215 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: genesis/ext/urdfpy/urdf.py
PR Title: [MISC] Re-enable more Ruff format rules.
BEFORE CODE: self._meshes = value
@classmethod
def _from_xml(cls, node, root, path):
kwargs = cls._parse(node, root, path)
# Load the mesh, combinin... | Update comment: `# Make sure that parent directory exists` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
class TimeElapser:
"""
A tool that can be called with `with` statement, and starts a separate thread that continuously outputs logger message with elasped time.
"""
def __init__(self, logger, refresh_rate, end_msg):
self.logger = logger
self.dt = 1.0 / refresh_rate
self.n = np.c... | Comment these functions instead of removing them. | class TimeElapser:
"""
A tool that can be called with `with` statement, and starts a separate thread that continuously outputs logger message with elasped time.
"""
def __init__(self, logger, refresh_rate, end_msg):
self.logger = logger
self.dt = 1.0 / refresh_rate
self.n = np.c... | @@ -23,15 +23,6 @@ def __init__(self, logger, refresh_rate, end_msg):
# adding back the reset character
self.end_msg = end_msg + self.last_logger_output[-4:] + "\n"
- def __enter__(self):
- self.thread = threading.Thread(target=self.run)
- self.thread.start()
- return self
-
... | genesis/logging/time_elapser.py | 26 | Python | 0.143 | suggestion | 49 | 43 | 51 | false | [MISC] Re-enable more Ruff format rules. | 2,215 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: genesis/logging/time_elapser.py
PR Title: [MISC] Re-enable more Ruff format rules.
BEFORE CODE: class TimeElapser:
"""
A tool that can be called with `with` statement, and starts a separate thread that continuously outputs logger message with elasped t... | Comment these functions instead of removing them. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
from typing import Sequence
import numpy as np
from pydantic import Field
import genesis as gs
from genesis.engine.scene import Scene
from ..options import Options
from .raycaster import DepthCameraPattern, RaycastPattern
Tuple3FType = tuple[float, float, float]
MaybeTuple3FType = float | Tuple3FType
Matrix3x3Type ... | This is a bug. You cannot do this. Guard this with `TYPE_CHECKING` | from typing import TYPE_CHECKING, Sequence
import numpy as np
from pydantic import Field
import genesis as gs
from ..options import Options
from .raycaster import DepthCameraPattern, RaycastPattern
Tuple3FType = tuple[float, float, float]
MaybeTuple3FType = float | Tuple3FType
Matrix3x3Type = tuple[tuple[float, flo... | @@ -4,6 +4,7 @@
from pydantic import Field
import genesis as gs
+from genesis.engine.scene import Scene | genesis/options/sensors/options.py | 7 | Python | 0.5 | bug | 66 | 32 | 32 | false | [MISC] Re-enable more Ruff format rules. | 2,215 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: genesis/options/sensors/options.py
PR Title: [MISC] Re-enable more Ruff format rules.
BEFORE CODE: from typing import Sequence
import numpy as np
from pydantic import Field
import genesis as gs
from genesis.engine.scene import Scene
from ..options import Op... | This is a bug. You cannot do this. Guard this with `TYPE_CHECKING` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Whether the color is transitioning from black to white as value increases or conversely. Default to False.
"""
# Cast data to float32
data_float = data.astype(np.float32)
# Clip data, with special handling for non-finite values only if necessary for efficiency
valid_mask = np.isfinite(data_... | There is a bug here. I will fix it. | Whether the color is transitioning from black to white as value increases or conversely. Default to False.
"""
# Cast data to float32
data_float = data.astype(np.float32)
# Clip data, with special handling for non-finite values only if necessary for efficiency
valid_mask = np.isfinite(data_... | @@ -52,7 +52,7 @@ def as_grayscale_image(
# Normalize values between 0.0 and 1.0
data_delta = data_max - data_min
- data_rel = data_float - data_min if black_to_white else data_max - data_float
+ data_float - data_min if black_to_white else data_max - data_float
data_normalized = np.divide(data_m... | genesis/utils/image_exporter.py | 26 | Python | 0.214 | bug | 35 | 51 | 51 | false | [MISC] Re-enable more Ruff format rules. | 2,215 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: genesis/utils/image_exporter.py
PR Title: [MISC] Re-enable more Ruff format rules.
BEFORE CODE: Whether the color is transitioning from black to white as value increases or conversely. Default to False.
"""
# Cast data to float32
data_float... | There is a bug here. I will fix it. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
surf_idx, inv = np.unique(triangles.flat, return_inverse=True)
triangles = inv.reshape(triangles.shape)
vertices = vertices[surf_idx]
mesh = trimesh.Trimesh(vertices, triangles, process=False)
mesh.v... | Remove the entire computation. | surf_idx, inv = np.unique(triangles.flat, return_inverse=True)
triangles = inv.reshape(triangles.shape)
vertices = vertices[surf_idx]
mesh = trimesh.Trimesh(vertices, triangles, process=False)
mesh.v... | @@ -747,7 +747,7 @@ def update_fem(self, buffer_updates):
for fem_entity in self.sim.fem_solver.entities:
if fem_entity.surface.vis_mode == "visual":
- triangles = (
+ (
triangles_all[fem_entity.s_start : (fem_entity.s_start ... | genesis/vis/rasterizer_context.py | 26 | Python | 0.143 | suggestion | 30 | 51 | 51 | false | [MISC] Re-enable more Ruff format rules. | 2,215 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: genesis/vis/rasterizer_context.py
PR Title: [MISC] Re-enable more Ruff format rules.
BEFORE CODE: surf_idx, inv = np.unique(triangles.flat, return_inverse=True)
triangles = inv.reshape(triangles.shape)
... | Remove the entire computation. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
continue
elif joint.type == gs.JOINT_TYPE.FIXED:
continue
dofs_idx_local = robot.get_joint(joint.name).dofs_idx_local
if dofs_idx_local:
if len(dofs_idx_local) == 1:
dofs_name = [joint.name]
else:
dofs_name = [f"{joi... | You probably need to make sure this variable does not get garbage collected. I'm not 100% sure. | continue
elif joint.type == gs.JOINT_TYPE.FIXED:
continue
dofs_idx_local = robot.get_joint(joint.name).dofs_idx_local
if dofs_idx_local:
if len(dofs_idx_local) == 1:
dofs_name = [joint.name]
else:
dofs_name = [f"{joi... | @@ -108,7 +104,7 @@ def on_close():
root.quit()
root = tk.Tk()
- app = JointControlGUI(root, motors_name, motors_position_limit, motors_position)
+ JointControlGUI(root, motors_name, motors_position_limit, motors_position) | genesis/_main.py | 26 | Python | 0.214 | suggestion | 95 | 51 | 51 | false | [MISC] Re-enable more Ruff format rules. | 2,215 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: genesis/_main.py
PR Title: [MISC] Re-enable more Ruff format rules.
BEFORE CODE: continue
elif joint.type == gs.JOINT_TYPE.FIXED:
continue
dofs_idx_local = robot.get_joint(joint.name).dofs_idx_local
if dofs_idx_l... | You probably need to make sure this variable does not get garbage collected. I'm not 100% sure. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
robot.set_pos(pos_delta)
if show_viewer:
scene.visualizer.update()
with nullcontext() if batch_fixed_verts else pytest.raises(gs.GenesisException):
robot.set_pos(pos_delta[[0]], envs_idx=[0])
if show_viewer:
scene.visualizer.update()
cube.set_pos(pos_delta... | Just replace `assert_allclose(sphere.get_AABB(), sphere.geoms[0].get_AABB(), tol=tol)` by `assert_allclose(sphere_aabb, sphere_base_aabb, tol=tol)` | robot.set_pos(pos_delta)
if show_viewer:
scene.visualizer.update()
with nullcontext() if batch_fixed_verts else pytest.raises(gs.GenesisException):
robot.set_pos(pos_delta[[0]], envs_idx=[0])
if show_viewer:
scene.visualizer.update()
cube.set_pos(pos_delta... | @@ -1284,7 +1280,7 @@ def test_set_root_pose(batch_fixed_verts, relative, show_viewer, tol):
if show_viewer:
scene.visualizer.update()
- sphere_aabb, sphere_base_aabb = sphere.get_AABB(), sphere.geoms[0].get_AABB()
+ sphere_aabb, _sphere_base_aabb = sphere.get_AABB(), sphere.geoms[0].get_AABB()
... | tests/test_rigid_physics.py | 26 | Python | 0.571 | suggestion | 147 | 51 | 51 | false | [MISC] Re-enable more Ruff format rules. | 2,215 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Narsil | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [MISC] Re-enable more Ruff format rules.
BEFORE CODE: robot.set_pos(pos_delta)
if show_viewer:
scene.visualizer.update()
with nullcontext() if batch_fixed_verts else pytest.raises(gs.Genesis... | Just replace `assert_allclose(sphere.get_AABB(), sphere.geoms[0].get_AABB(), tol=tol)` by `assert_allclose(sphere_aabb, sphere_base_aabb, tol=tol)` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
show_viewer=show_viewer,
show_FPS=False,
)
asset_path = get_hf_dataset(pattern="fridge/*")
fridge = scene.add_entity(
gs.morphs.URDF(
file=f"{asset_path}/fridge/fridge.urdf",
fixed=True,
)
)
@pytest.mark.required
def test_plane_texture_path_preser... | * No need to build the scene
* You can remove Scene options if you don't build, they won't be used anyway
* assert "texture_path" in vgeom.vmesh.metadata is still not necessary. pytest will throw a clear exception anyway (plain asserts are being post-processed to ease debugging).
```python
scene = gs.Scene()
... | show_viewer=show_viewer,
show_FPS=False,
)
asset_path = get_hf_dataset(pattern="fridge/*")
fridge = scene.add_entity(
gs.morphs.URDF(
file=f"{asset_path}/fridge/fridge.urdf",
fixed=True,
)
)
@pytest.mark.required
def test_plane_texture_path_prese... | @@ -510,6 +510,22 @@ def test_2_channels_luminance_alpha_textures(show_viewer):
)
)
+@pytest.mark.required
+def test_plane_texture_path_preservation(show_viewer):
+ """Test that plane primitives preserve texture paths in metadata."""
+ scene = gs.Scene(show_viewer=show_viewer, show_FPS=False)
+ ... | tests/test_mesh.py | 26 | Python | 1 | bug | 505 | 51 | 51 | false | [MISC] Store texture path for primitive morphs as metadata. | 2,227 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Rush2k | Review this pull request change.
Language: Python
File: tests/test_mesh.py
PR Title: [MISC] Store texture path for primitive morphs as metadata.
BEFORE CODE: show_viewer=show_viewer,
show_FPS=False,
)
asset_path = get_hf_dataset(pattern="fridge/*")
fridge = scene.add_entity(
gs.m... | * No need to build the scene
* You can remove Scene options if you don't build, they won't be used anyway
* assert "texture_path" in vgeom.vmesh.metadata is still not necessary. pytest will throw a clear exception anyway (plain asserts are being post-processed to ease debugging).
```python
scene = gs.Scene()
... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if color is None: # use checkerboard texture
n_tile_x, n_tile_y = plane_size[0] / tile_size[0], plane_size[1] / tile_size[1]
vmesh.visual = trimesh.visual.TextureVisuals(
uv=np.array(
[
[0, 0],
[n_tile_x, 0],
[n... | I'm not a huge fan of returning metadata this way, because this helpers are not aware of what `metadata` is.
Maybe create plane should take some `color_to_texture_path` input argument, that default to some global variable `DEFAULT_PLANE_TEXTURE_PATH` that would be defined on top of this module. Then when you create t... | )
faces = np.arange(6, dtype=np.int32).reshape(-1, 3)
vmesh = trimesh.Trimesh(verts, faces, process=False)
vmesh.vertices[:, 2] -= thickness / 2
vmesh.vertices = gu.transform_by_R(vmesh.vertices, gu.z_up_to_R(np.asarray(normal, dtype=np.float32)))
if texture_path is not None:
n_tile_x, ... | @@ -927,15 +930,17 @@ def create_plane(normal=(0.0, 0.0, 1.0), plane_size=(1e3, 1e3), tile_size=(1, 1)
dtype=np.float32,
),
material=trimesh.visual.material.SimpleMaterial(
- image=Image.open(os.path.join(get_assets_dir(), "textures/checker.png")),
+ ... | genesis/utils/mesh.py | 26 | Python | 0.643 | refactor | 412 | 51 | 51 | false | [MISC] Store texture path for primitive morphs as metadata. | 2,227 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Rush2k | Review this pull request change.
Language: Python
File: genesis/utils/mesh.py
PR Title: [MISC] Store texture path for primitive morphs as metadata.
BEFORE CODE: if color is None: # use checkerboard texture
n_tile_x, n_tile_y = plane_size[0] / tile_size[0], plane_size[1] / tile_size[1]
vmesh.vis... | I'm not a huge fan of returning metadata this way, because this helpers are not aware of what `metadata` is.
Maybe create plane should take some `color_to_texture_path` input argument, that default to some global variable `DEFAULT_PLANE_TEXTURE_PATH` that would be defined on top of this module. Then when you create t... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
for _ in range(30):
scene.step()
attach_link = franka.get_link("attachment")
assert_allclose(attach_link.get_pos(), hand.links[0].get_pos(), tol=gs.EPS)
offset_quat = gu.transform_quat_by_quat(hand.links[0].get_quat(), gu.inv_quat(attach_link.get_quat()))
assert_allclose(gu.quat_to_xyz(offs... | Do we need to use single line for those un-important arguments? | ),
vis_mode="collision",
)
tool = scene.add_entity(
gs.morphs.Sphere(
radius=0.005,
),
)
box = scene.add_entity(
gs.morphs.Box(
size=(0.02, 0.02, 0.02),
pos=(0.3, 0.0, 0.01),
),
)
with pytest.raises(gs.GenesisExc... | @@ -3854,3 +3854,26 @@ def test_merge_entities(is_fixed, merge_fixed_links, show_viewer, tol, monkeypat
assert_allclose(torch.linalg.norm(hand.links[-1].get_pos() - attach_link.get_pos(), dim=-1), 0.105, tol=tol)
assert_allclose(tool.get_pos(), hand.get_link("right_finger").get_pos(), tol=gs.EPS)
+
+
+@... | tests/test_rigid_physics.py | 26 | Python | 0.286 | question | 63 | 37 | 38 | false | [BUG FIX] Clear dynamic weld at scene reset. | 2,233 | Genesis-Embodied-AI/Genesis | 26,702 | Python | YilingQiao | YilingQiao | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [BUG FIX] Clear dynamic weld at scene reset.
BEFORE CODE: for _ in range(30):
scene.step()
attach_link = franka.get_link("attachment")
assert_allclose(attach_link.get_pos(), hand.links[0].get_pos(), to... | Do we need to use single line for those un-important arguments? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
surface=surface,
uvs=uvs,
)
@classmethod
def from_morph_surface(cls, morph, surface=None):
"""
Create a genesis.Mesh from morph and surface options.
If the morph is a Mesh morph (morphs.Mesh), it could contain multiple sub-meshes, so we return a list.
... | I think it is still worth to make configurable. I found some assets that has been made z up already.
Adding this conversion by default makes sense though. | visual=mu.surface_uvs_to_trimesh_visual(surface, uvs, len(verts)),
process=False,
),
surface=surface,
uvs=uvs,
)
@classmethod
def from_morph_surface(cls, morph, surface=None):
"""
Create a genesis.Mesh from morph and su... | @@ -340,20 +343,19 @@ def from_morph_surface(cls, morph, surface=None):
if isinstance(morph, gs.options.morphs.Mesh):
if morph.is_format(gs.options.morphs.MESH_FORMATS):
meshes = mu.parse_mesh_trimesh(morph.file, morph.group_by_material, morph.scale, surface)
+ if n... | genesis/engine/mesh.py | 26 | Python | 0.357 | suggestion | 155 | 51 | 51 | false | [BREAKING][FEATURE] Improve import of y-up vs z-up file meshes. | 2,237 | Genesis-Embodied-AI/Genesis | 26,702 | Python | Kashu7100 | AnisB | Review this pull request change.
Language: Python
File: genesis/engine/mesh.py
PR Title: [BREAKING][FEATURE] Improve import of y-up vs z-up file meshes.
BEFORE CODE: surface=surface,
uvs=uvs,
)
@classmethod
def from_morph_surface(cls, morph, surface=None):
"""
... | I think it is still worth to make configurable. I found some assets that has been made z up already.
Adding this conversion by default makes sense though. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# collision mesh uses default color
self._preprocess()
def _build(self):
pass
def _preprocess(self):
# compute file name via hashing for caching
self._gsd_path = mu.get_gsd_path(
self._init_verts,
self._init_faces,
self._material.sdf... | should we delete the corrupted cache file? |
# collision mesh uses default color
self._preprocess()
def _build(self):
pass
def _preprocess(self):
# compute file name via hashing for caching
self._gsd_path = mu.get_gsd_path(
self._init_verts,
self._init_faces,
self._material.sdf... | @@ -140,7 +140,7 @@ def _preprocess(self):
with open(self._gsd_path, "rb") as file:
gsd_dict = pkl.load(file)
is_cached_loaded = True
- except (EOFError, ModuleNotFoundError, pkl.UnpicklingError):
+ except (EOFError, ModuleNotFoundError, pkl.U... | genesis/engine/entities/rigid_entity/rigid_geom.py | 26 | Python | 0.143 | performance | 42 | 51 | 51 | false | [BUG FIX] More robust handling of corrupted cache. | 2,241 | Genesis-Embodied-AI/Genesis | 26,702 | Python | hughperkins | duburcqa | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_geom.py
PR Title: [BUG FIX] More robust handling of corrupted cache.
BEFORE CODE:
# collision mesh uses default color
self._preprocess()
def _build(self):
pass
def _preprocess(self):... | should we delete the corrupted cache file? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
s1 = sin_theta / sin_theta_0
new_q = s0 * q0 + s1 * q1
out = np.where(small_mask, lerp, new_q)
return out[0] if scalar_output else out
@torch.jit.script
def _tc_slerp(q0, q1, t):
scalar_output = q0.ndim == 1 and (t.ndim == 0 or (t.ndim == 1 and t.shape[0] == 1))
if q0.ndim == 1:
q0 = ... | I'm surprised it is not impossible to replace this by 2 lines of code. | def slerp(q0, q1, t):
"""
Perform spherical linear interpolation between two quaternions.
Parameters
----------
q0 : numpy.array | torch.Tensor
The start quaternion (w, x, y, z), can be batched.
q1 : numpy.array | torch.Tensor
The end quaternion (w, x, y, z), can be batched.
... | @@ -1445,6 +1445,133 @@ def polar(A, pure_rotation: bool = True, side: Literal["right", "left"] = "right
gs.raise_exception(f"the input must be either torch.Tensor or np.ndarray. got: {type(A)=}")
+def _np_slerp(q0, q1, t):
+ q0 = np.asarray(q0)
+ q1 = np.asarray(q1)
+ t = np.asarray(t)
+
+ scalar_... | genesis/utils/geom.py | 26 | Python | 0.286 | suggestion | 70 | 51 | 51 | false | [FEATURE] Improve performance and add torch support to 'utils.geom.slerp'. | 2,260 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Kashu7100 | Review this pull request change.
Language: Python
File: genesis/utils/geom.py
PR Title: [FEATURE] Improve performance and add torch support to 'utils.geom.slerp'.
BEFORE CODE: s1 = sin_theta / sin_theta_0
new_q = s0 * q0 + s1 * q1
out = np.where(small_mask, lerp, new_q)
return out[0] if scalar_outp... | I'm surprised it is not impossible to replace this by 2 lines of code. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
return _np_polar(A, pure_rotation, side)
gs.raise_exception(f"the input must be either torch.Tensor or np.ndarray. got: {type(A)=}")
def _np_slerp(q0, q1, t):
q0 = np.asarray(q0)
q1 = np.asarray(q1)
t = np.asarray(t)
scalar_output = q0.ndim == 1 and (t.ndim == 0 or (t.ndim == 1 and t.shap... | Same. This is crazy complex for just fixing dimension issues. Worst case, you flatten as batch dimensions, so that you keep performing all operations on a 2d tensor and done. I think we are already doing this for some other geom utils. | - P : The positive semi-definite matrix (scaling part). For 'right' decomposition,
P has shape (N, N) or (*batch, N, N). For 'left' decomposition, P has shape (M, M) or (*batch, M, M).
"""
if isinstance(A, np.ndarray):
return _np_polar(A, pure_rotation, side)
if isinstance(A, torch... | @@ -1445,6 +1445,133 @@ def polar(A, pure_rotation: bool = True, side: Literal["right", "left"] = "right
gs.raise_exception(f"the input must be either torch.Tensor or np.ndarray. got: {type(A)=}")
+def _np_slerp(q0, q1, t):
+ q0 = np.asarray(q0)
+ q1 = np.asarray(q1)
+ t = np.asarray(t)
+
+ scalar_... | genesis/utils/geom.py | 26 | Python | 0.429 | performance | 235 | 51 | 51 | false | [FEATURE] Improve performance and add torch support to 'utils.geom.slerp'. | 2,260 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Kashu7100 | Review this pull request change.
Language: Python
File: genesis/utils/geom.py
PR Title: [FEATURE] Improve performance and add torch support to 'utils.geom.slerp'.
BEFORE CODE: return _np_polar(A, pure_rotation, side)
gs.raise_exception(f"the input must be either torch.Tensor or np.ndarray. got: {type(A)... | Same. This is crazy complex for just fixing dimension issues. Worst case, you flatten as batch dimensions, so that you keep performing all operations on a 2d tensor and done. I think we are already doing this for some other geom utils. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
q0 = q0 / torch.linalg.norm(q0, dim=-1, keepdim=True)
q1 = q1 / torch.linalg.norm(q1, dim=-1, keepdim=True)
dot_product = torch.sum(q0 * q1, dim=-1, keepdim=True)
neg_mask = dot_product < 0
q1 = torch.where(neg_mask, -q1, q1)
dot_product = torch.where(neg_mask, -dot_product, dot_product)
... | Remove this temporary variable. It is useless here and theoretically slower. | is_theta_eps = dot_abs > 1.0 - eps
s0 = torch.where(is_theta_eps, 1.0 - t, torch.sin((1.0 - t) * theta) * sin_theta_inv)
s1 = torch.where(is_theta_eps, t, torch.sin(t * theta) * sin_theta_inv) * torch.where(dot < 0.0, -1.0, 1.0)
return s0 * q0 + s1 * q1
def slerp(q0, q1, t):
"""
Perform spheri... | @@ -1445,6 +1445,99 @@ def polar(A, pure_rotation: bool = True, side: Literal["right", "left"] = "right
gs.raise_exception(f"the input must be either torch.Tensor or np.ndarray. got: {type(A)=}")
+def _np_slerp(q0, q1, t):
+ q0 = q0.reshape(-1, 4)
+ q1 = q1.reshape(-1, 4)
+ t = t.reshape(-1, 1)
+ a... | genesis/utils/geom.py | 26 | Python | 0.286 | performance | 76 | 51 | 51 | false | [FEATURE] Improve performance and add torch support to 'utils.geom.slerp'. | 2,260 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Kashu7100 | Review this pull request change.
Language: Python
File: genesis/utils/geom.py
PR Title: [FEATURE] Improve performance and add torch support to 'utils.geom.slerp'.
BEFORE CODE:
q0 = q0 / torch.linalg.norm(q0, dim=-1, keepdim=True)
q1 = q1 / torch.linalg.norm(q1, dim=-1, keepdim=True)
dot_product = torc... | Remove this temporary variable. It is useless here and theoretically slower. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
q0 = q0 / np.linalg.norm(q0, axis=-1, keepdims=True)
q1 = q1 / np.linalg.norm(q1, axis=-1, keepdims=True)
dot_product = np.sum(q0 * q1, axis=-1, keepdims=True)
neg_mask = dot_product < 0.0
q1 = np.where(neg_mask, -q1, q1)
dot_product = np.where(neg_mask, -dot_product, dot_product)
dot_pro... | np.where is not appropriate on CPU because inefficient. I will reimplement this function entirely |
@nb.jit(nopython=True, cache=True)
def _np_slerp(q0, q1, t):
q0_norm = np.sqrt(np.sum(np.square(q0.reshape((-1, 4))), -1).reshape((*q0.shape[:-1], 1)))
q0 = q0 / q0_norm
q1_norm = np.sqrt(np.sum(np.square(q1.reshape((-1, 4))), -1).reshape((*q1.shape[:-1], 1)))
q1 = q1 / q1_norm
d = q0 * q1
dot... | @@ -1445,6 +1445,99 @@ def polar(A, pure_rotation: bool = True, side: Literal["right", "left"] = "right
gs.raise_exception(f"the input must be either torch.Tensor or np.ndarray. got: {type(A)=}")
+def _np_slerp(q0, q1, t):
+ q0 = q0.reshape(-1, 4)
+ q1 = q1.reshape(-1, 4)
+ t = t.reshape(-1, 1)
+ a... | genesis/utils/geom.py | 26 | Python | 0.286 | performance | 97 | 51 | 51 | false | [FEATURE] Improve performance and add torch support to 'utils.geom.slerp'. | 2,260 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Kashu7100 | Review this pull request change.
Language: Python
File: genesis/utils/geom.py
PR Title: [FEATURE] Improve performance and add torch support to 'utils.geom.slerp'.
BEFORE CODE:
q0 = q0 / np.linalg.norm(q0, axis=-1, keepdims=True)
q1 = q1 / np.linalg.norm(q1, axis=-1, keepdims=True)
dot_product = np.sum... | np.where is not appropriate on CPU because inefficient. I will reimplement this function entirely | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
length_per_value=3,
)
self._options.bias = _to_tuple(
self._options.acc_bias, self._options.gyro_bias, self._options.mag_bias, length_per_value=3
)
self._options.random_walk = _to_tuple(
self._options.acc_random_walk,
self._options.gyro_ran... | I don't want to risk introducing a bug. Are you sure that removing `.unsqueeze(0)` and adding one extra dim is equivalent? | length_per_value=3,
)
self._options.bias = _to_tuple(
self._options.acc_bias, self._options.gyro_bias, self._options.mag_bias, length_per_value=3
)
self._options.random_walk = _to_tuple(
self._options.acc_random_walk,
self._options.gyro_ran... | @@ -132,17 +151,31 @@ def build(self):
[
_get_cross_axis_coupling_to_alignment_matrix(self._options.acc_cross_axis_coupling),
_get_cross_axis_coupling_to_alignment_matrix(self._options.gyro_cross_axis_coupling),
+ _get_cross_axis_coupling_to_... | genesis/engine/sensors/imu.py | 26 | Python | 0.643 | bug | 122 | 51 | 51 | false | [FEATURE] Add Magnetometer measurement to IMU Sensor. | 2,265 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | sunkmechie | Review this pull request change.
Language: Python
File: genesis/engine/sensors/imu.py
PR Title: [FEATURE] Add Magnetometer measurement to IMU Sensor.
BEFORE CODE: length_per_value=3,
)
self._options.bias = _to_tuple(
self._options.acc_bias, self._options.gyro_bias, self._opti... | I don't want to risk introducing a bug. Are you sure that removing `.unsqueeze(0)` and adding one extra dim is equivalent? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
super().build() # set all shared metadata from RigidSensorBase and NoisySensorBase
self._shared_metadata.alignment_rot_matrix = concat_with_tensor(
self._shared_metadata.alignment_rot_matrix,
torch.stack(
[
_get_cross_axis_coupling_to_alignme... | Keep all args in one line if it fits. | super().build() # set all shared metadata from RigidSensorBase and NoisySensorBase
self._shared_metadata.alignment_rot_matrix = concat_with_tensor(
self._shared_metadata.alignment_rot_matrix,
torch.stack(
[
_get_cross_axis_coupling_to_alignme... | @@ -132,17 +151,31 @@ def build(self):
[
_get_cross_axis_coupling_to_alignment_matrix(self._options.acc_cross_axis_coupling),
_get_cross_axis_coupling_to_alignment_matrix(self._options.gyro_cross_axis_coupling),
+ _get_cross_axis_coupling_to_... | genesis/engine/sensors/imu.py | 26 | Python | 0.071 | suggestion | 37 | 51 | 51 | false | [FEATURE] Add Magnetometer measurement to IMU Sensor. | 2,265 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | sunkmechie | Review this pull request change.
Language: Python
File: genesis/engine/sensors/imu.py
PR Title: [FEATURE] Add Magnetometer measurement to IMU Sensor.
BEFORE CODE: super().build() # set all shared metadata from RigidSensorBase and NoisySensorBase
self._shared_metadata.alignment_rot_matrix = concat_... | Keep all args in one line if it fits. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
acc = shared_metadata.solver.get_links_acc(links_idx=shared_metadata.links_idx)
ang = shared_metadata.solver.get_links_ang(links_idx=shared_metadata.links_idx)
if acc.ndim == 2: # n_envs = 0
acc = acc[None]
ang = ang[None]
quats = quats[None]
offset_... | What reshape is supposed to be necessary here? What is the original shape? | acc = shared_metadata.solver.get_links_acc(links_idx=shared_metadata.links_idx)
ang = shared_metadata.solver.get_links_ang(links_idx=shared_metadata.links_idx)
if acc.ndim == 2: # n_envs = 0
acc = acc[None]
ang = ang[None]
quats = quats[None]
offset_... | @@ -182,11 +216,16 @@ def _update_shared_ground_truth_cache(
local_acc = inv_transform_by_quat(acc - gravity[..., None, :], offset_quats)
local_ang = inv_transform_by_quat(ang, offset_quats)
+ n_envs = quats.shape[0]
+ B_world = shared_metadata.magnetic_field_vector.reshape(n_envs, -1,... | genesis/engine/sensors/imu.py | 26 | Python | 0.214 | question | 74 | 51 | 51 | false | [FEATURE] Add Magnetometer measurement to IMU Sensor. | 2,265 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | sunkmechie | Review this pull request change.
Language: Python
File: genesis/engine/sensors/imu.py
PR Title: [FEATURE] Add Magnetometer measurement to IMU Sensor.
BEFORE CODE: acc = shared_metadata.solver.get_links_acc(links_idx=shared_metadata.links_idx)
ang = shared_metadata.solver.get_links_ang(links_idx=shar... | What reshape is supposed to be necessary here? What is the original shape? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# Extract acceleration and gravity in world frame
assert shared_metadata.solver is not None
gravity = shared_metadata.solver.get_gravity()
quats = shared_metadata.solver.get_links_quat(links_idx=shared_metadata.links_idx)
acc = shared_metadata.solver.get_links_acc(links_idx=share... | Why did you have to change this? | # Extract acceleration and gravity in world frame
assert shared_metadata.solver is not None
gravity = shared_metadata.solver.get_gravity()
quats = shared_metadata.solver.get_links_quat(links_idx=shared_metadata.links_idx)
acc = shared_metadata.solver.get_links_acc(links_idx=share... | @@ -208,12 +247,14 @@ def _update_shared_cache(
shared_metadata.cur_jitter_ts,
shared_metadata.interpolate,
)
- # apply rotation matrix to the shared cache
- shared_cache_xyz_view = shared_cache.view(shared_cache.shape[0], -1, 3)
- shared_cache_xyz_view.copy_(
- ... | genesis/engine/sensors/imu.py | 26 | Python | 0.143 | question | 32 | 51 | 51 | false | [FEATURE] Add Magnetometer measurement to IMU Sensor. | 2,265 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | sunkmechie | Review this pull request change.
Language: Python
File: genesis/engine/sensors/imu.py
PR Title: [FEATURE] Add Magnetometer measurement to IMU Sensor.
BEFORE CODE: # Extract acceleration and gravity in world frame
assert shared_metadata.solver is not None
gravity = shared_metadata.solver.get_... | Why did you have to change this? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# update noise and bias for accelerometer, gyroscope and magnetometer
imu_noisy.set_noise((0.01, 0.01, 0.01, 0.02, 0.02, 0.02, 0.01, 0.01, 0.01))
imu_noisy.set_bias((0.01, 0.01, 0.01, 0.02, 0.02, 0.02, 0.05, 0.05, 0.05))
imu_noisy.set_jitter(0.001)
for _ in range(10 - DELAY_STEPS):
scene.st... | Skip line between check blocks. | # update noise and bias for accelerometer, gyroscope and magnetometer
imu_noisy.set_noise((0.01, 0.01, 0.01, 0.02, 0.02, 0.02, 0.05, 0.05, 0.05))
imu_noisy.set_bias((0.01, 0.01, 0.01, 0.02, 0.02, 0.02, 0.05, 0.05, 0.05))
imu_noisy.set_jitter(0.001)
for _ in range(10 - DELAY_STEPS):
scene.st... | @@ -102,11 +112,18 @@ def test_imu_sensor(show_viewer, tol, n_envs):
with np.testing.assert_raises(AssertionError):
assert_allclose(lin_acc_no_offset, lin_acc_with_offset, atol=0.2)
imu.set_pos_offset((0.0, 0.0, 0.0))
+ # check that entity rotation affects magnetometer readings | tests/test_sensors.py | 26 | Python | 0.071 | suggestion | 31 | 51 | 51 | false | [FEATURE] Add Magnetometer measurement to IMU Sensor. | 2,265 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | sunkmechie | Review this pull request change.
Language: Python
File: tests/test_sensors.py
PR Title: [FEATURE] Add Magnetometer measurement to IMU Sensor.
BEFORE CODE: # update noise and bias for accelerometer, gyroscope and magnetometer
imu_noisy.set_noise((0.01, 0.01, 0.01, 0.02, 0.02, 0.02, 0.01, 0.01, 0.01))
imu... | Skip line between check blocks. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
assert_array_equal(imu.read_ground_truth().lin_acc, imu_delayed.read_ground_truth().lin_acc)
assert_array_equal(imu.read_ground_truth().ang_vel, imu_delayed.read_ground_truth().ang_vel)
with np.testing.assert_raises(AssertionError, msg="Angular velocity should not be zero due to COM shift"):
... | Remove torch.tensor as just pass type. |
with np.testing.assert_raises(AssertionError, msg="Delayed accl data should not be equal to the ground truth data"):
assert_array_equal(imu_delayed.read().lin_acc - imu_delayed.read_ground_truth().lin_acc, 0.0)
with np.testing.assert_raises(AssertionError, msg="Delayed mag data should not be equal to ... | @@ -117,32 +134,35 @@ def test_imu_sensor(show_viewer, tol, n_envs):
assert_array_equal(imu_delayed.read().lin_acc - imu_delayed.read_ground_truth().lin_acc, 0.0)
box.set_COM_shift([0.0, 0.0, 0.0])
- box.set_quat([0.0, 0.0, 0.0, 1.0])
+ box.set_quat(torch.tile(torch.tensor([1.0, 0.0, 0.0, 0.0]), (... | tests/test_sensors.py | 26 | Python | 0.286 | suggestion | 38 | 51 | 51 | false | [FEATURE] Add Magnetometer measurement to IMU Sensor. | 2,265 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | sunkmechie | Review this pull request change.
Language: Python
File: tests/test_sensors.py
PR Title: [FEATURE] Add Magnetometer measurement to IMU Sensor.
BEFORE CODE:
assert_array_equal(imu.read_ground_truth().lin_acc, imu_delayed.read_ground_truth().lin_acc)
assert_array_equal(imu.read_ground_truth().ang_vel,... | Remove torch.tensor as just pass type. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
import numpy as np
import pytest
import torch
import genesis as gs
import genesis.utils.geom as gu
from .utils import assert_allclose, assert_array_equal
@pytest.mark.required
@pytest.mark.parametrize("n_envs", [0, 2])
def test_imu_sensor(show_viewer, tol, n_envs):
"""Test if the 9-axis IMU sensor returns the c... | Do not change what the existing unit test is doing, unless you can explain why this is necessary.
You can add additional checks for magnometer but there is no reason to update what is already there. | import numpy as np
import pytest
import torch
import genesis as gs
import genesis.utils.geom as gu
from .utils import assert_allclose, assert_array_equal
@pytest.mark.required
@pytest.mark.parametrize("n_envs", [0, 2])
def test_imu_sensor(show_viewer, tol, n_envs):
"""Test if the IMU sensor returns the correct ... | tests/test_sensors.py | 1 | Python | 0.429 | suggestion | 199 | 26 | 26 | false | [FEATURE] Add Magnetometer measurement to IMU Sensor. | 2,265 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | sunkmechie | Review this pull request change.
Language: Python
File: tests/test_sensors.py
PR Title: [FEATURE] Add Magnetometer measurement to IMU Sensor.
BEFORE CODE: import numpy as np
import pytest
import torch
import genesis as gs
import genesis.utils.geom as gu
from .utils import assert_allclose, assert_array_equal
@py... | Do not change what the existing unit test is doing, unless you can explain why this is necessary.
You can add additional checks for magnometer but there is no reason to update what is already there. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
scene = gs.Scene(
sim_options=gs.options.SimOptions(
dt=4e-3,
substeps=10,
),
sph_options=gs.options.SPHOptions(
lower_bound=(-0.5, -0.5, 0.0),
upper_bound=(0.5, 0.5, 1),
particle_size=0.01,
),
vis_options=gs.options.VisOptions(
visualize_sph_boundary... | This should work by default without this patch. I would rather remove it to keep it simple. |
scene = gs.Scene(
sim_options=gs.options.SimOptions(
dt=4e-3,
substeps=10,
),
sph_options=gs.options.SPHOptions(
lower_bound=(-0.5, -0.5, 0.0),
upper_bound=(0.5, 0.5, 1),
particle_size=0.01,
),
vis_options=gs.options.VisOptions(
visualize_sph_boundary... | @@ -32,7 +32,7 @@
liquid = scene.add_entity(
# viscous liquid
# material=gs.materials.SPH.Liquid(mu=0.02, gamma=0.02),
- material=gs.materials.SPH.Liquid(),
+ material=gs.materials.SPH.Liquid(sampler="regular"), | examples/tutorials/sph_liquid.py | 26 | Python | 0.286 | suggestion | 91 | 46 | 46 | false | [BUG FIX] Fix wrong sampler for SPH solver causing numerical stability issues. | 2,280 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | erizmr | Review this pull request change.
Language: Python
File: examples/tutorials/sph_liquid.py
PR Title: [BUG FIX] Fix wrong sampler for SPH solver causing numerical stability issues.
BEFORE CODE:
scene = gs.Scene(
sim_options=gs.options.SimOptions(
dt=4e-3,
substeps=10,
),
sph_options=gs.opt... | This should work by default without this patch. I would rather remove it to keep it simple. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@ti.data_oriented
class Liquid(Base):
"""
The liquid material class for SPH.
Parameters
----------
rho: float, optional
The density (kg/m^3) the material tends to maintain in equilibrium (i.e., the "rest" or undeformed state). Default is 1000.
stiffness: float, optional
State ... | Do not skip line. Besides, respect 120 chars linewidth for docstring. |
@ti.data_oriented
class Liquid(Base):
"""
The liquid material class for SPH.
Parameters
----------
rho: float, optional
The density (kg/m^3) the material tends to maintain in equilibrium (i.e., the "rest" or undeformed state). Default is 1000.
stiffness: float, optional
State ... | @@ -22,7 +22,11 @@ class Liquid(Base):
The surface tension of the liquid. Controls how strongly the material "clumps" together at boundaries. Default is 0.01
sampler: str, optional
Particle sampler ('pbs', 'regular', 'random'). Note that 'pbs' is only supported on Linux x86 for now. Defaults
- ... | genesis/engine/materials/SPH/liquid.py | 26 | Python | 0.214 | suggestion | 69 | 51 | 51 | false | [BUG FIX] Fix wrong sampler for SPH solver causing numerical stability issues. | 2,280 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | erizmr | Review this pull request change.
Language: Python
File: genesis/engine/materials/SPH/liquid.py
PR Title: [BUG FIX] Fix wrong sampler for SPH solver causing numerical stability issues.
BEFORE CODE:
@ti.data_oriented
class Liquid(Base):
"""
The liquid material class for SPH.
Parameters
----------
... | Do not skip line. Besides, respect 120 chars linewidth for docstring. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
return scene, liquid
def get_sph_density_pressure(scene, n_particles):
"""
Helper function to compute and retrieve density and pressure from SPH solver.
This triggers the density computation kernel and returns the computed values.
Parameters
----------
scene : gs.Scene
The built ... | Could you clarify in comment why this is needed? |
@pytest.fixture(scope="function")
def sph_scene(show_viewer):
"""Fixture to create a basic SPH scene with regular sampler."""
return create_sph_scene(show_viewer)
def get_sph_density_pressure(scene, n_particles):
"""
Helper function to compute and retrieve density and pressure from SPH solver.
... | @@ -0,0 +1,302 @@
+# Tests for SPH simulation - initial density and pressure validation
+#
+# Background:
+# SPH is sensitive to the initial particle distribution, as it directly determines the initial density and pressure fields.
+# To ensure numerical stability, particles must be initialized using a regular sampler t... | tests/test_sph.py | 26 | Python | 0.143 | question | 48 | 51 | 51 | false | [BUG FIX] Fix wrong sampler for SPH solver causing numerical stability issues. | 2,280 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | erizmr | Review this pull request change.
Language: Python
File: tests/test_sph.py
PR Title: [BUG FIX] Fix wrong sampler for SPH solver causing numerical stability issues.
BEFORE CODE: return scene, liquid
def get_sph_density_pressure(scene, n_particles):
"""
Helper function to compute and retrieve density and... | Could you clarify in comment why this is needed? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.