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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
def set_geom_friction(self, friction, geoms_idx):
self._kernel_set_geom_friction(geoms_idx, friction)
@ti.kernel
def _kernel_set_geom_friction(self, geoms_idx: ti.i32, friction: ti.f32):
self.geoms_info[geoms_idx].friction = friction
def set_geoms_friction(self, friction, geoms_idx=Non... | Do not assign `envs_idx` at this point, to avoid `original_envs_idx` trick. | def set_geom_friction(self, friction, geoms_idx):
self._kernel_set_geom_friction(geoms_idx, friction)
@ti.kernel
def _kernel_set_geom_friction(self, geoms_idx: ti.i32, friction: ti.f32):
self.geoms_info[geoms_idx].friction = friction
def set_geoms_friction(self, friction, geoms_idx=Non... | @@ -4652,6 +4658,101 @@ def _kernel_set_geoms_friction(
for i_g_ in ti.ndrange(geoms_idx.shape[0]):
self.geoms_info[geoms_idx[i_g_]].friction = friction[i_g_]
+ def add_weld_constraint(self, link1_idx, link2_idx, envs_idx=None, *, unsafe=False):
+ original_envs_idx = envs_idx
+ ... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.429 | suggestion | 75 | 51 | 51 | false | [FEATURE] Add suction cup | 961 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [FEATURE] Add suction cup
BEFORE CODE: def set_geom_friction(self, friction, geoms_idx):
self._kernel_set_geom_friction(geoms_idx, friction)
@ti.kernel
def _kernel_set_geom_fric... | Do not assign `envs_idx` at this point, to avoid `original_envs_idx` trick. | 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.equality_info[i_e, i_b].eq_type = gs.ti_int(gs.EQUALITY_TYPE.WELD)
self.equality_info[i_e, i_b].eq_obj1id = l1
self.equality_info[i_e, i_b].eq_obj2id = l2
for i_3 in range(3):
self.equality_info[i_e, i_b].eq_data[i_3 + 3] = pos1[i_3]
... | `skip_allocation=True` is still missing (at the 4 different places). | self.equality_info[i_e, i_b].eq_obj2id = l2
for i_3 in range(3):
self.equality_info[i_e, i_b].eq_data[i_3 + 3] = pos1[i_3]
self.equality_info[i_e, i_b].eq_data[i_3] = pos2[i_3]
relpose = gu.ti_quat_mul(gu.ti_inv_quat(self.links_state[l1, i_b].quat), ... | @@ -4652,6 +4658,99 @@ def _kernel_set_geoms_friction(
for i_g_ in ti.ndrange(geoms_idx.shape[0]):
self.geoms_info[geoms_idx[i_g_]].friction = friction[i_g_]
+ def add_weld_constraint(self, link1_idx, link2_idx, envs_idx=None, *, unsafe=False):
+ _, link1_idx, _ = self._sanitize_1D_io_... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.357 | suggestion | 68 | 51 | 51 | false | [FEATURE] Add suction cup | 961 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [FEATURE] Add suction cup
BEFORE CODE:
self.equality_info[i_e, i_b].eq_type = gs.ti_int(gs.EQUALITY_TYPE.WELD)
self.equality_info[i_e, i_b].eq_obj1id = l1
self.e... | `skip_allocation=True` is still missing (at the 4 different places). | 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. |
xs = np.linspace(minx, maxx, nx, dtype=np.float32)
ys = np.linspace(miny, maxy, ny, dtype=np.float32)
# -------------------------------- fine grid ------------------------------
fx = nx * oversample
fy = ny * oversample
fx_lin = np.linspace(minx, maxx, fx, dtype=np.float32)
fy_lin = np.lins... | If h_coarse is entirely NaN, np.nanmin(h_coarse) will return NaN, which might not be the desired fallback value. Consider adding a conditional check to handle the scenario where the entire height field is NaN.
```suggestion
# change nan to min or fallback value if all are NaN
if np.isnan(h_coarse).all():
... | ny = math.ceil((maxy - miny) / dy) + 1
xs = np.linspace(minx, maxx, nx, dtype=np.float32)
ys = np.linspace(miny, maxy, ny, dtype=np.float32)
# -------------------------------- fine grid ------------------------------
fx = nx * oversample
fy = ny * oversample
fx_lin = np.linspace(minx, maxx... | @@ -352,3 +352,83 @@ def convert_heightfield_to_watertight_trimesh(height_field_raw, horizontal_scale
)
return mesh, sdf_mesh
+
+
+def mesh_to_heightfield(
+ path: str,
+ spacing: float | tuple[float, float],
+ oversample: int = 3,
+ *,
+ up_axis: str = "z",
+) -> tuple[np.ndarray, np.ndarray... | genesis/utils/terrain.py | 26 | Python | 1 | suggestion | 500 | 29 | 32 | false | [FEATURE] Add a function to convert terrain mesh to height field | 1,033 | Genesis-Embodied-AI/Genesis | 26,702 | Python | Copilot | YilingQiao | Review this pull request change.
Language: Python
File: genesis/utils/terrain.py
PR Title: [FEATURE] Add a function to convert terrain mesh to height field
BEFORE CODE: xs = np.linspace(minx, maxx, nx, dtype=np.float32)
ys = np.linspace(miny, maxy, ny, dtype=np.float32)
# ------------------------------... | If h_coarse is entirely NaN, np.nanmin(h_coarse) will return NaN, which might not be the desired fallback value. Consider adding a conditional check to handle the scenario where the entire height field is NaN.
```suggestion
# change nan to min or fallback value if all are NaN
if np.isnan(h_coarse).all():
... | 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. |
horizontal_scale = 2.0
gs_root = os.path.dirname(os.path.abspath(gs.__file__))
path_terrain = os.path.join(gs_root, "assets", "meshes", "terrain_45.obj")
hf_terrain, xs, ys = mesh_to_heightfield(path_terrain, spacing=horizontal_scale, oversample=1)
print("hf_terrain", path_terrain, hf_terrain.shape... | Why `convexify=False`? Since it is a plane that as no volume, it should not be convexified anyway. I think it is better to not specify arguments that are doing nothing. | )
horizontal_scale = 2.0
gs_root = os.path.dirname(os.path.abspath(gs.__file__))
path_terrain = os.path.join(gs_root, "assets", "meshes", "terrain_45.obj")
hf_terrain, xs, ys = mesh_to_heightfield(path_terrain, spacing=horizontal_scale, oversample=1)
print("hf_terrain", path_terrain, hf_terrain... | @@ -0,0 +1,69 @@
+import genesis as gs
+import numpy as np
+import argparse
+import os
+from genesis.utils.terrain import mesh_to_heightfield
+
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument("-v", "--vis", action="store_true", default=False)
+ parser.add_argument("-c", "--cpu", actio... | examples/rigid/terrain_from_mesh.py | 26 | Python | 0.571 | question | 168 | 46 | 39 | false | [FEATURE] Add a function to convert terrain mesh to height field | 1,033 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: examples/rigid/terrain_from_mesh.py
PR Title: [FEATURE] Add a function to convert terrain mesh to height field
BEFORE CODE:
horizontal_scale = 2.0
gs_root = os.path.dirname(os.path.abspath(gs.__file__))
path_terrain = os.path.join(gs_root, "assets... | Why `convexify=False`? Since it is a plane that as no volume, it should not be convexified anyway. I think it is better to not specify arguments that are doing nothing. | 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 os
import math
import numpy as np
import pickle
import trimesh
import genesis as gs
from genesis.ext import fast_simplification
from genesis.ext.isaacgym import terrain_utils as isaacgym_terrain_utils
from genesis.options.morphs import Terrain
from .misc import get_assets_dir
def parse_terrain(morph: Terrain... | Keep system deps seperated from common deps:
```
import os
import math
import pickle
import numpy as np
import trimesh
``` | import os
import math
import pickle
import numpy as np
import trimesh
import genesis as gs
from genesis.ext import fast_simplification
from genesis.ext.isaacgym import terrain_utils as isaacgym_terrain_utils
from genesis.options.morphs import Terrain
from .misc import get_assets_dir
def parse_terrain(morph: Terrai... | @@ -1,5 +1,5 @@
import os
-
+import math
import numpy as np
import pickle
import trimesh | genesis/utils/terrain.py | 6 | Python | 0.714 | suggestion | 131 | 31 | 31 | false | [FEATURE] Add a function to convert terrain mesh to height field | 1,033 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/utils/terrain.py
PR Title: [FEATURE] Add a function to convert terrain mesh to height field
BEFORE CODE: import os
import math
import numpy as np
import pickle
import trimesh
import genesis as gs
from genesis.ext import fast_simplification
from genesi... | Keep system deps seperated from common deps:
```
import os
import math
import pickle
import numpy as np
import trimesh
``` | 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. |
Parameters
----------
path : str
.glb / .obj / … file containing the terrain mesh.
spacing : float | (float, float)
Desired grid spacing Δx (and Δy). Units must match the mesh.
oversample : int, default 3
Number of extra rays per coarse‑grid axis. k = 1 reproduces the
... | "unless you have ample RAM" if vague. Do you have any rough estimate? (>64Gb, >512Gb...) | """
Parameters
----------
path : str
.glb / .obj / … file containing the terrain mesh.
spacing : float | (float, float)
Desired grid spacing Δx (and Δy). Units must match the mesh.
oversample : int, default 3
Number of extra rays per coarse‑grid axis. k = 1 reprodu... | @@ -352,3 +352,83 @@ def convert_heightfield_to_watertight_trimesh(height_field_raw, horizontal_scale
)
return mesh, sdf_mesh
+
+
+def mesh_to_heightfield(
+ path: str,
+ spacing: float | tuple[float, float],
+ oversample: int = 1,
+ *,
+ up_axis: str = "z",
+) -> tuple[np.ndarray, np.ndarray... | genesis/utils/terrain.py | 26 | Python | 0.214 | suggestion | 88 | 51 | 51 | false | [FEATURE] Add a function to convert terrain mesh to height field | 1,033 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/utils/terrain.py
PR Title: [FEATURE] Add a function to convert terrain mesh to height field
BEFORE CODE: Parameters
----------
path : str
.glb / .obj / … file containing the terrain mesh.
spacing : float | (float, float)
... | "unless you have ample RAM" if vague. Do you have any rough estimate? (>64Gb, >512Gb...) | 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
-------
heights : (nx, ny) float32 ndarray
Highest elevation per coarse cell (NaN if no hit).
xs : (nx,) float32 ndarray
ys : (ny,) float32 ndarray
Coordinates of grid lines (cell centres).
Notes
-----
• Requires `pyembree` or `rtree` for fast ... | It would be nice to avoid duplicating every lines for x and y:
```python
from collections.abc import ValuesView, Sequence
if np.isscalar(spacing):
spacing = (spacing, spacing)
n, s, f, f_lin = [None, None], [None, None], [None, None], [None, None]
for i, (vmin, vmax, delta) in range(2):
# -----------... |
Returns
-------
heights : (nx, ny) float32 ndarray
Highest elevation per coarse cell (NaN if no hit).
xs : (nx,) float32 ndarray
ys : (ny,) float32 ndarray
Coordinates of grid lines (cell centres).
Notes
-----
• Memory cost grows as oversample².
... | @@ -352,3 +352,83 @@ def convert_heightfield_to_watertight_trimesh(height_field_raw, horizontal_scale
)
return mesh, sdf_mesh
+
+
+def mesh_to_heightfield(
+ path: str,
+ spacing: float | tuple[float, float],
+ oversample: int = 1,
+ *,
+ up_axis: str = "z",
+) -> tuple[np.ndarray, np.ndarray... | genesis/utils/terrain.py | 26 | Python | 1 | suggestion | 781 | 51 | 51 | false | [FEATURE] Add a function to convert terrain mesh to height field | 1,033 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/utils/terrain.py
PR Title: [FEATURE] Add a function to convert terrain mesh to height field
BEFORE CODE: Returns
-------
heights : (nx, ny) float32 ndarray
Highest elevation per coarse cell (NaN if no hit).
xs : (nx,) ... | It would be nice to avoid duplicating every lines for x and y:
```python
from collections.abc import ValuesView, Sequence
if np.isscalar(spacing):
spacing = (spacing, spacing)
n, s, f, f_lin = [None, None], [None, None], [None, None], [None, None]
for i, (vmin, vmax, delta) in range(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. |
mesh = trimesh.load(path, force="mesh")
# -------------------------------- axis handling ---------------------------
if up_axis.lower() == "y":
# rotate so Z becomes up (‑90° around X)
T = trimesh.transformations.rotation_matrix(np.deg2rad(-90), [1, 0, 0])
mesh.apply_transform(T)
... | I would recommend `np.stack((fxx.ravel(), fyy.ravel(), np.full(fxx.size, maxz + 1.0)), axis=-1)` which is more readable and widley used. | spacing = (spacing, spacing)
mesh = trimesh.load(path, force="mesh")
# -------------------------------- axis handling ---------------------------
if up_axis.lower() == "y":
# rotate so Z becomes up (‑90° around X)
T = trimesh.transformations.rotation_matrix(np.deg2rad(-90), [1, 0, ... | @@ -352,3 +352,83 @@ def convert_heightfield_to_watertight_trimesh(height_field_raw, horizontal_scale
)
return mesh, sdf_mesh
+
+
+def mesh_to_heightfield(
+ path: str,
+ spacing: float | tuple[float, float],
+ oversample: int = 1,
+ *,
+ up_axis: str = "z",
+) -> tuple[np.ndarray, np.ndarray... | genesis/utils/terrain.py | 26 | Python | 0.571 | suggestion | 137 | 44 | 47 | false | [FEATURE] Add a function to convert terrain mesh to height field | 1,033 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/utils/terrain.py
PR Title: [FEATURE] Add a function to convert terrain mesh to height field
BEFORE CODE: mesh = trimesh.load(path, force="mesh")
# -------------------------------- axis handling ---------------------------
if up_axis.lower(... | I would recommend `np.stack((fxx.ravel(), fyy.ravel(), np.full(fxx.size, maxz + 1.0)), axis=-1)` which is more readable and widley used. | 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. |
) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
"""
Parameters
----------
path : str
.glb / .obj / … file containing the terrain mesh.
spacing : float | (float, float)
Desired grid spacing Δx (and Δy). Units must match the mesh.
oversample : int, default 3
Number of... | I would remove this comment entirely. `rtree` is already installed automatically as part of the requirements. | up_axis: str = "z",
) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
"""
Parameters
----------
path : str
.glb / .obj / … file containing the terrain mesh.
spacing : float | (float, float)
Desired grid spacing Δx (and Δy). Units must match the mesh.
oversample : int, def... | @@ -352,3 +352,83 @@ def convert_heightfield_to_watertight_trimesh(height_field_raw, horizontal_scale
)
return mesh, sdf_mesh
+
+
+def mesh_to_heightfield(
+ path: str,
+ spacing: float | tuple[float, float],
+ oversample: int = 1,
+ *,
+ up_axis: str = "z",
+) -> tuple[np.ndarray, np.ndarray... | genesis/utils/terrain.py | 26 | Python | 0.571 | refactor | 109 | 51 | 51 | false | [FEATURE] Add a function to convert terrain mesh to height field | 1,033 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/utils/terrain.py
PR Title: [FEATURE] Add a function to convert terrain mesh to height field
BEFORE CODE: ) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
"""
Parameters
----------
path : str
.glb / .obj / … file containing the te... | I would remove this comment entirely. `rtree` is already installed automatically as part of the requirements. | 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 sys
import xml.etree.ElementTree as ET
import pytest
import trimesh
import torch
import os
import numpy as np
from huggingface_hub import snapshot_download
import mujoco
import genesis as gs
from .utils import (
init_simulators,
check_mujoco_model_consistency,
check_mujoco_data_consistency,
si... | Could you split dependencies as mentioned above? | import sys
import xml.etree.ElementTree as ET
import os
import pytest
import trimesh
import torch
import numpy as np
from huggingface_hub import snapshot_download
import mujoco
import genesis as gs
from .utils import (
init_simulators,
check_mujoco_model_consistency,
check_mujoco_data_consistency,
si... | @@ -4,6 +4,7 @@
import pytest
import trimesh | tests/test_rigid_physics.py | 6 | Python | 0.143 | question | 48 | 31 | 31 | false | [FEATURE] Add a function to convert terrain mesh to height field | 1,033 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [FEATURE] Add a function to convert terrain mesh to height field
BEFORE CODE: import sys
import xml.etree.ElementTree as ET
import pytest
import trimesh
import torch
import os
import numpy as np
from huggingface_hub impor... | Could you split dependencies as mentioned above? | 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. |
dofs_pos = gs_s.get_dofs_position(dofs_idx, envs_idx)
dofs_vel = gs_s.get_dofs_velocity(dofs_idx, envs_idx)
gs_sim.rigid_solver.control_dofs_position(dofs_pos, dofs_idx, envs_idx)
gs_sim.rigid_solver.control_dofs_velocity(dofs_vel, dofs_idx, envs_idx)
@pytest.mark.xfail... | Just import this on top if it cannot fail. | dofs_pos = gs_s.get_dofs_position(dofs_idx, envs_idx)
dofs_vel = gs_s.get_dofs_velocity(dofs_idx, envs_idx)
gs_sim.rigid_solver.control_dofs_position(dofs_pos, dofs_idx, envs_idx)
gs_sim.rigid_solver.control_dofs_velocity(dofs_vel, dofs_idx, envs_idx)
@pytest.mark.xfail... | @@ -1100,3 +1101,57 @@ def test_equality_weld(gs_sim, mj_sim):
qpos = gs_sim.rigid_solver.dofs_state.pos.to_numpy()[:, 0]
qpos[0], qpos[1], qpos[2] = 0.1, 0.1, 0.1
simulate_and_check_mujoco_consistency(gs_sim, mj_sim, qpos, qvel, num_steps=300, atol=atol)
+
+
+@pytest.mark.parametrize("backend", [gs.cpu]... | tests/test_rigid_physics.py | 26 | Python | 0.071 | bug | 42 | 51 | 51 | false | [FEATURE] Add a function to convert terrain mesh to height field | 1,033 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [FEATURE] Add a function to convert terrain mesh to height field
BEFORE CODE: dofs_pos = gs_s.get_dofs_position(dofs_idx, envs_idx)
dofs_vel = gs_s.get_dofs_velocity(dofs_idx, envs_idx)
... | Just import this on top if it cannot fail. | 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. |
terrain_heightfield = scene.add_entity(
morph=gs.morphs.Terrain(
horizontal_scale=horizontal_scale,
vertical_scale=1.0,
height_field=hf_terrain,
pos=translation,
),
vis_mode="collision",
)
ball = scene.add_entity(
gs.morphs.Sp... | `qvel = ball.get_dofs_velocity().cpu()` | terrain_heightfield = scene.add_entity(
morph=gs.morphs.Terrain(
horizontal_scale=horizontal_scale,
vertical_scale=1.0,
height_field=hf_terrain,
pos=translation,
),
vis_mode="collision",
)
ball = scene.add_entity(
gs.morphs.Sph... | @@ -1100,3 +1101,57 @@ def test_equality_weld(gs_sim, mj_sim):
qpos = gs_sim.rigid_solver.dofs_state.pos.to_numpy()[:, 0]
qpos[0], qpos[1], qpos[2] = 0.1, 0.1, 0.1
simulate_and_check_mujoco_consistency(gs_sim, mj_sim, qpos, qvel, num_steps=300, atol=atol)
+
+
+@pytest.mark.parametrize("backend", [gs.cpu]... | tests/test_rigid_physics.py | 26 | Python | 0.214 | suggestion | 39 | 29 | 27 | false | [FEATURE] Add a function to convert terrain mesh to height field | 1,033 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [FEATURE] Add a function to convert terrain mesh to height field
BEFORE CODE:
terrain_heightfield = scene.add_entity(
morph=gs.morphs.Terrain(
horizontal_scale=horizontal_scale,
vertica... | `qvel = ball.get_dofs_velocity().cpu()` | 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. |
terrain_heightfield = scene.add_entity(
morph=gs.morphs.Terrain(
horizontal_scale=horizontal_scale,
vertical_scale=1.0,
height_field=hf_terrain,
pos=translation,
),
vis_mode="collision",
)
ball = scene.add_entity(
gs.morphs.Sph... | Remove the norm, it is useless | morph=gs.morphs.Terrain(
horizontal_scale=horizontal_scale,
vertical_scale=1.0,
height_field=hf_terrain,
pos=translation,
),
vis_mode="collision",
)
ball = scene.add_entity(
gs.morphs.Sphere(
pos=(10, 15, 10),
... | @@ -1100,3 +1101,57 @@ def test_equality_weld(gs_sim, mj_sim):
qpos = gs_sim.rigid_solver.dofs_state.pos.to_numpy()[:, 0]
qpos[0], qpos[1], qpos[2] = 0.1, 0.1, 0.1
simulate_and_check_mujoco_consistency(gs_sim, mj_sim, qpos, qvel, num_steps=300, atol=atol)
+
+
+@pytest.mark.parametrize("backend", [gs.cpu]... | tests/test_rigid_physics.py | 26 | Python | 0.143 | suggestion | 30 | 28 | 26 | false | [FEATURE] Add a function to convert terrain mesh to height field | 1,033 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [FEATURE] Add a function to convert terrain mesh to height field
BEFORE CODE: terrain_heightfield = scene.add_entity(
morph=gs.morphs.Terrain(
horizontal_scale=horizontal_scale,
vertical... | Remove the norm, it is useless | 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. |
morph=gs.morphs.Terrain(
horizontal_scale=horizontal_scale,
vertical_scale=1.0,
height_field=hf_terrain,
pos=translation,
),
vis_mode="collision",
)
ball = scene.add_entity(
gs.morphs.Sphere(
pos=(10, 15, 10),
... | How can this condition be met if the ground is not horizontal ?! | import sys
import xml.etree.ElementTree as ET
import os
import pytest
import trimesh
import torch
import numpy as np
from huggingface_hub import snapshot_download
import mujoco
import genesis as gs
from .utils import (
init_simulators,
check_mujoco_model_consistency,
check_mujoco_data_consistency,
si... | @@ -1100,3 +1101,57 @@ def test_equality_weld(gs_sim, mj_sim):
qpos = gs_sim.rigid_solver.dofs_state.pos.to_numpy()[:, 0]
qpos[0], qpos[1], qpos[2] = 0.1, 0.1, 0.1
simulate_and_check_mujoco_consistency(gs_sim, mj_sim, qpos, qvel, num_steps=300, atol=atol)
+
+
+@pytest.mark.parametrize("backend", [gs.cpu]... | tests/test_rigid_physics.py | 26 | Python | 0.214 | question | 64 | 27 | 1,156 | false | [FEATURE] Add a function to convert terrain mesh to height field | 1,033 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [FEATURE] Add a function to convert terrain mesh to height field
BEFORE CODE: morph=gs.morphs.Terrain(
horizontal_scale=horizontal_scale,
vertical_scale=1.0,
height_field=hf_terr... | How can this condition be met if the ground is not horizontal ?! | 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. |
qvel = gs_sim.rigid_solver.dofs_state.vel.to_numpy()[:, 0]
qpos = gs_sim.rigid_solver.dofs_state.pos.to_numpy()[:, 0]
qpos[0], qpos[1], qpos[2] = 0.1, 0.1, 0.1
simulate_and_check_mujoco_consistency(gs_sim, mj_sim, qpos, qvel, num_steps=300, atol=atol)
@pytest.mark.parametrize("backend", [gs.cpu])
def ... | Ideally, we could like to automate this process, as for `convexify` but for terrains. So that mesh terrain are automatically converted to heightfield unless specified otherwise. That would be a neat API! | qvel = gs_sim.rigid_solver.dofs_state.vel.to_numpy()[:, 0]
qpos = gs_sim.rigid_solver.dofs_state.pos.to_numpy()[:, 0]
qpos[0], qpos[1], qpos[2] = 0.1, 0.1, 0.1
simulate_and_check_mujoco_consistency(gs_sim, mj_sim, qpos, qvel, num_steps=300, atol=atol)
@pytest.mark.parametrize("backend", [gs.cpu])
def ... | @@ -1100,3 +1101,57 @@ def test_equality_weld(gs_sim, mj_sim):
qpos = gs_sim.rigid_solver.dofs_state.pos.to_numpy()[:, 0]
qpos[0], qpos[1], qpos[2] = 0.1, 0.1, 0.1
simulate_and_check_mujoco_consistency(gs_sim, mj_sim, qpos, qvel, num_steps=300, atol=atol)
+
+
+@pytest.mark.parametrize("backend", [gs.cpu]... | tests/test_rigid_physics.py | 26 | Python | 0.643 | suggestion | 203 | 51 | 51 | false | [FEATURE] Add a function to convert terrain mesh to height field | 1,033 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [FEATURE] Add a function to convert terrain mesh to height field
BEFORE CODE: qvel = gs_sim.rigid_solver.dofs_state.vel.to_numpy()[:, 0]
qpos = gs_sim.rigid_solver.dofs_state.pos.to_numpy()[:, 0]
qpos[0], qpos[... | Ideally, we could like to automate this process, as for `convexify` but for terrains. So that mesh terrain are automatically converted to heightfield unless specified otherwise. That would be a neat API! | 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. |
scaling = torch.tensor([1, -1, -1, -1], device=quat.device)
return quat * scaling
elif isinstance(quat, np.ndarray):
scaling = np.array([1, -1, -1, -1], dtype=quat.dtype)
return quat * scaling
else:
gs.raise_exception(f"the input must be either torch.Tensor or np.ndarray.... | Prefer returning directly without intermediary variable for performance concerns | if isinstance(quat, torch.Tensor):
scaling = torch.tensor([1, -1, -1, -1], device=quat.device)
return quat * scaling
elif isinstance(quat, np.ndarray):
scaling = np.array([1, -1, -1, -1], dtype=quat.dtype)
return quat * scaling
else:
gs.raise_exception(f"the input mus... | @@ -417,6 +418,67 @@ def normalize(x, eps: float = 1e-9):
gs.raise_exception(f"the input must be either torch.Tensor or np.ndarray. got: {type(x)=}")
+def rot6d_to_quat(d6):
+ R = rot6d_to_R(d6)
+ return R_to_quat(R)
+
+
+def quat_to_rot6d(quat):
+ R = quat_to_R(quat) | genesis/utils/geom.py | 26 | Python | 0.429 | performance | 80 | 51 | 51 | false | [FEATURE] rot6d utils | 1,034 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Kashu7100 | Review this pull request change.
Language: Python
File: genesis/utils/geom.py
PR Title: [FEATURE] rot6d utils
BEFORE CODE: scaling = torch.tensor([1, -1, -1, -1], device=quat.device)
return quat * scaling
elif isinstance(quat, np.ndarray):
scaling = np.array([1, -1, -1, -1], dtype=quat.d... | Prefer returning directly without intermediary variable for performance concerns | 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 quat_to_R(quat):
if isinstance(quat, torch.Tensor):
qw, qx, qy, qz = torch.unbind(quat, -1)
# pyre-fixme[58]: `/` is not supported for operand types `float` and `Tensor`.
two_s = 2.0 / (quat * quat).sum(-1)
return torch.stack(
(
1 - two_s * (qy * qy ... | It would be nice to avoid duplicating the whole code between torch and numpy. | gs.raise_exception(f"the input must be either torch.Tensor or np.ndarray. got: {type(x)=}")
def rot6d_to_quat(d6):
R = rot6d_to_R(d6)
return R_to_quat(R)
def quat_to_rot6d(quat):
R = quat_to_R(quat)
return R_to_rot6d(R)
def rot6d_to_R(d6):
"""
Converts 6D rotation representation by... | @@ -417,6 +418,67 @@ def normalize(x, eps: float = 1e-9):
gs.raise_exception(f"the input must be either torch.Tensor or np.ndarray. got: {type(x)=}")
+def rot6d_to_quat(d6):
+ R = rot6d_to_R(d6)
+ return R_to_quat(R)
+
+
+def quat_to_rot6d(quat):
+ R = quat_to_R(quat)
+ return R_to_rot6d(R)
+
+... | genesis/utils/geom.py | 26 | Python | 0.286 | suggestion | 77 | 51 | 51 | false | [FEATURE] rot6d utils | 1,034 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Kashu7100 | Review this pull request change.
Language: Python
File: genesis/utils/geom.py
PR Title: [FEATURE] rot6d utils
BEFORE CODE:
def quat_to_R(quat):
if isinstance(quat, torch.Tensor):
qw, qx, qy, qz = torch.unbind(quat, -1)
# pyre-fixme[58]: `/` is not supported for operand types `float` and `Tenso... | It would be nice to avoid duplicating the whole code between torch and numpy. | 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. |
@pytest.mark.parametrize("backend", [gs.cpu])
def test_equality_weld(gs_sim, mj_sim):
# there is an equality constraint
assert gs_sim.rigid_solver.n_equalities == 1
gs_sim.rigid_solver._enable_collision = False
mj_sim.model.opt.disableflags |= mujoco.mjtDisableBit.mjDSBL_CONTACT
qvel = gs_sim.rigid... | I don't thin you need all these flags here? |
@pytest.mark.xfail(reason="We need to implement rotational invweight")
@pytest.mark.parametrize("xml_path", ["xml/four_bar_linkage_weld.xml"])
@pytest.mark.parametrize("gs_solver", [gs.constraint_solver.CG])
@pytest.mark.parametrize("gs_integrator", [gs.integrator.Euler])
@pytest.mark.parametrize("backend", [gs.cpu])... | @@ -1442,3 +1442,19 @@ def test_equality_weld(gs_sim, mj_sim):
qpos = gs_sim.rigid_solver.dofs_state.pos.to_numpy()[:, 0]
qpos[0], qpos[1], qpos[2] = 0.1, 0.1, 0.1
simulate_and_check_mujoco_consistency(gs_sim, mj_sim, qpos, qvel, num_steps=300, atol=atol)
+
+
+@pytest.mark.parametrize("xml_path", ["xml/o... | tests/test_rigid_physics.py | 26 | Python | 0.071 | question | 43 | 28 | 51 | false | [BUG FIX] Fix time integration for ball joint | 1,078 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [BUG FIX] Fix time integration for ball joint
BEFORE CODE: @pytest.mark.parametrize("backend", [gs.cpu])
def test_equality_weld(gs_sim, mj_sim):
# there is an equality constraint
assert gs_sim.rigid_solver.n_equali... | I don't thin you need all these flags 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. |
l_info = self.links_info[I_l]
if l_info.n_dofs == 0:
continue
dof_start = l_info.dof_start
q_start = l_info.q_start
q_end = l_info.q_end
i_j = l_info.joint_start
I_j = [i_j, i_b] if ti.s... | Could one inlined ? Would look cleaner I would say: `rot_offset = 3 if joint_type == gs.JOINT_TYPE.SPHERICAL else 0` | l_info = self.links_info[I_l]
if l_info.n_dofs == 0:
continue
dof_start = l_info.dof_start
q_start = l_info.q_start
q_end = l_info.q_end
i_j = l_info.joint_start
I_j = [i_j, i_b] if ti.s... | @@ -3347,39 +3347,43 @@ def _func_integrate(self):
joint_type = self.joints_info[I_j].type
if joint_type == gs.JOINT_TYPE.FREE:
+ pos = ti.Vector([self.qpos[q_start, i_b], self.qpos[q_start + 1, i_b], self.qpos[q_start + 2, i_b]])
+ vel = ti.Vect... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.714 | suggestion | 117 | 51 | 51 | false | [BUG FIX] Fix time integration for ball joint | 1,078 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [BUG FIX] Fix time integration for ball joint
BEFORE CODE: l_info = self.links_info[I_l]
if l_info.n_dofs == 0:
continue
dof_star... | Could one inlined ? Would look cleaner I would say: `rot_offset = 3 if joint_type == gs.JOINT_TYPE.SPHERICAL else 0` | 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. |
vertices = state.pos.cpu().numpy()
surface_indices = np.unique(fem.surface_triangles)
# Verify each surface vertex lies on the original surface mesh
for idx in surface_indices:
p = vertices[idx]
assert _point_on_surface(
p, verts, faces
), f"Surface vertex index {idx... | Can you document what this method does? It is not clear to me. | if abs(denom) < tol:
continue
u = (dot11 * dot02 - dot01 * dot12) / denom
v = (dot00 * dot12 - dot01 * dot02) / denom
if u >= -tol and v >= -tol and (u + v) <= 1 + tol:
return True
return False
for idx i... | @@ -53,3 +54,178 @@ def test_multiple_fem_entities(fem_material, show_viewer):
# Run simulation
for _ in range(100):
scene.step()
+
+
+def _write_extruded_box(center, large_length, small_length, filename):
+ cx, cy, cz = center
+ hL = large_length / 2.0
+ hl = small_length / 2.0
+
+ z0 = ... | tests/test_fem.py | 26 | Python | 0.214 | suggestion | 62 | 43 | 49 | false | [BUG FIX] Fix vertex index mismatch when adding tetrahedralized FEM entities. | 1,086 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | kosuke1701 | Review this pull request change.
Language: Python
File: tests/test_fem.py
PR Title: [BUG FIX] Fix vertex index mismatch when adding tetrahedralized FEM entities.
BEFORE CODE: vertices = state.pos.cpu().numpy()
surface_indices = np.unique(fem.surface_triangles)
# Verify each surface vertex lies on the o... | Can you document what this method does? It is not clear to me. | 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. |
nobisect=False,
minratio=1.5,
verbose=1,
),
material=fem_material,
)
scene.build()
state = fem.get_state()
vertices = state.pos.cpu().numpy()
surface_indices = np.unique(fem.surface_triangles)
# Verify each surface vertex lies on the origina... | Just do:
```
(fem_node_primitive,) = fem_node_mesh.primitives
fem_node_vertices = fem_node_primitive.positions
fem_node_faces = fem_node_primitive.indices
``` | # Barycentric coordinates
v0v1 = b - a
v0v2 = c - a
v0p = p - a
dot00 = np.dot(v0v2, v0v2)
dot01 = np.dot(v0v2, v0v1)
dot02 = np.dot(v0v2, v0p)
dot11 = np.dot(v0v1, v0v1)
dot12... | @@ -53,3 +54,178 @@ def test_multiple_fem_entities(fem_material, show_viewer):
# Run simulation
for _ in range(100):
scene.step()
+
+
+def _write_extruded_box(center, large_length, small_length, filename):
+ cx, cy, cz = center
+ hL = large_length / 2.0
+ hl = small_length / 2.0
+
+ z0 = ... | tests/test_fem.py | 26 | Python | 0.714 | suggestion | 164 | 51 | 51 | false | [BUG FIX] Fix vertex index mismatch when adding tetrahedralized FEM entities. | 1,086 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | kosuke1701 | Review this pull request change.
Language: Python
File: tests/test_fem.py
PR Title: [BUG FIX] Fix vertex index mismatch when adding tetrahedralized FEM entities.
BEFORE CODE: nobisect=False,
minratio=1.5,
verbose=1,
),
material=fem_material,
)
scene.build... | Just do:
```
(fem_node_primitive,) = fem_node_mesh.primitives
fem_node_vertices = fem_node_primitive.positions
fem_node_faces = fem_node_primitive.indices
``` | 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.add_entity(
morph=gs.morphs.Sphere(
pos=(0.5, -0.2, 0.3),
radius=0.1,
),
material=fem_material,
)
# Add second FEM entity
scene.add_entity(
morph=gs.morphs.Box(
size=(0.1, 0.1, 0.1),
pos=(0.0, 0.0, 0.5),
),
... | Move these declaration inside the test as you did for `_make_triangle_set` | scene.add_entity(
morph=gs.morphs.Sphere(
pos=(0.5, -0.2, 0.3),
radius=0.1,
),
material=fem_material,
)
# Add second FEM entity
scene.add_entity(
morph=gs.morphs.Box(
size=(0.1, 0.1, 0.1),
pos=(0.0, 0.0, 0.5),
),
... | @@ -53,3 +54,178 @@ def test_multiple_fem_entities(fem_material, show_viewer):
# Run simulation
for _ in range(100):
scene.step()
+
+
+def _write_extruded_box(center, large_length, small_length, filename): | tests/test_fem.py | 26 | Python | 0.429 | suggestion | 74 | 51 | 51 | false | [BUG FIX] Fix vertex index mismatch when adding tetrahedralized FEM entities. | 1,086 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | kosuke1701 | Review this pull request change.
Language: Python
File: tests/test_fem.py
PR Title: [BUG FIX] Fix vertex index mismatch when adding tetrahedralized FEM entities.
BEFORE CODE: scene.add_entity(
morph=gs.morphs.Sphere(
pos=(0.5, -0.2, 0.3),
radius=0.1,
),
material=f... | Move these declaration inside the test as you did for `_make_triangle_set` | 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. |
mesh.visual = trimesh.visual.TextureVisuals(
uv=np.array(
[
[0, 0],
[0, 0],
[0, size],
[0, size],
[size, 0],
[size, 0],
[size, size],
... | `getattr` is not a good approach. `morph` must have these attributes, already set with the right default value. Add some `isinstance` check for the morph and raise an exception if its type is not appropriate. | mesh.visual = trimesh.visual.TextureVisuals(
uv=np.array(
[
[0, 0],
[0, 0],
[0, size],
[0, size],
[size, 0],
[size, 0],
[size, size],
... | @@ -815,12 +815,55 @@ def create_plane(size=1e3, color=None, normal=(0, 0, 1)):
return mesh
+def generate_tetgen_config_from_morph(morph):
+ return dict(
+ order=getattr(morph, "order", 1), | genesis/utils/mesh.py | 26 | Python | 0.714 | suggestion | 208 | 51 | 51 | false | [FEATURE][BREAKING] Add maxvolume support for TetGen-based tetrahedralization, unify TetGen config handling, and add tests | 1,088 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | kosuke1701 | Review this pull request change.
Language: Python
File: genesis/utils/mesh.py
PR Title: [FEATURE][BREAKING] Add maxvolume support for TetGen-based tetrahedralization, unify TetGen config handling, and add tests
BEFORE CODE: mesh.visual = trimesh.visual.TextureVisuals(
uv=np.array(
... | `getattr` is not a good approach. `morph` must have these attributes, already set with the right default value. Add some `isinstance` check for the morph and raise an exception if its type is not appropriate. | 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. |
ls_tolerance=mj_sim.model.opt.ls_tolerance,
),
show_viewer=show_viewer,
show_FPS=False,
)
gs_robot = scene.add_entity(
gs.morphs.MJCF(file=xml_path),
visualize_contact=True,
)
gs_sim = scene.sim
# Force matching Mujoco safety factor for constraint... | I think the scope should be "session" as you expect the same output for all tests? Once this is done, you do not need `uuid` anymore, just call it as you want, e.g. `cube.obj`. It will be created only once anyway so it is perfectly fine. | ),
show_viewer=show_viewer,
show_FPS=False,
)
gs_robot = scene.add_entity(
gs.morphs.MJCF(file=xml_path),
visualize_contact=True,
)
gs_sim = scene.sim
# Force matching Mujoco safety factor for constraint time constant.
# Note that this time constant affec... | @@ -260,3 +261,42 @@ def gs_sim(
scene.build()
return gs_sim
+
+
+@pytest.fixture | tests/conftest.py | 26 | Python | 0.643 | suggestion | 237 | 51 | 51 | false | [FEATURE][BREAKING] Add maxvolume support for TetGen-based tetrahedralization, unify TetGen config handling, and add tests | 1,088 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | kosuke1701 | Review this pull request change.
Language: Python
File: tests/conftest.py
PR Title: [FEATURE][BREAKING] Add maxvolume support for TetGen-based tetrahedralization, unify TetGen config handling, and add tests
BEFORE CODE: ls_tolerance=mj_sim.model.opt.ls_tolerance,
),
show_viewer=show_view... | I think the scope should be "session" as you expect the same output for all tests? Once this is done, you do not need `uuid` anymore, just call it as you want, e.g. `cube.obj`. It will be created only once anyway so it is perfectly fine. | 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. |
Rounds each vertex coordinate to the given tolerance, sorts vertices within each triangle,
and returns all triangles as a sorted tuple, eliminating any dependence on vertex or face order.
"""
tri_set = set()
for tri in faces:
coords = [tuple(round(float(coord), tol) f... | Remove empty options, it is useless. | import numpy as np
import pytest
import genesis as gs
@pytest.fixture(scope="session")
def fem_material():
"""Fixture for common FEM material properties"""
return gs.materials.FEM.Muscle(
E=3.0e4,
nu=0.45,
rho=1000.0,
model="stable_neohooken",
)
@pytest.mark.parametrize(... | @@ -235,3 +235,30 @@ def _make_triangle_set(verts, faces, tol=4):
"FEM entity surface triangles and visualizer mesh triangles do not match.\n"
f"Differences: {set(entity_tris) ^ set(viz_tris)}"
)
+
+
+@pytest.mark.parametrize("backend", [gs.cpu])
+def test_maxvolume(fem_material, show_viewer, box... | tests/test_fem.py | 26 | Python | 0.143 | suggestion | 36 | 47 | 196 | false | [FEATURE][BREAKING] Add maxvolume support for TetGen-based tetrahedralization, unify TetGen config handling, and add tests | 1,088 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | kosuke1701 | Review this pull request change.
Language: Python
File: tests/test_fem.py
PR Title: [FEATURE][BREAKING] Add maxvolume support for TetGen-based tetrahedralization, unify TetGen config handling, and add tests
BEFORE CODE: Rounds each vertex coordinate to the given tolerance, sorts vertices within each triangl... | Remove empty options, it is useless. | 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,
)
gs_robot = scene.add_entity(
gs.morphs.MJCF(file=xml_path),
visualize_contact=True,
)
gs_sim = scene.sim
# Force matching Mujoco safety factor for constraint time constant.
# Note that this time constant affec... | I think you could reuse this fixture in tests that were merged in some of your previous PRs no? To avoid code duplication. | show_viewer=show_viewer,
show_FPS=False,
)
gs_robot = scene.add_entity(
gs.morphs.MJCF(file=xml_path),
visualize_contact=True,
)
gs_sim = scene.sim
# Force matching Mujoco safety factor for constraint time constant.
# Note that this time constant affects the pene... | @@ -260,3 +261,42 @@ def gs_sim(
scene.build()
return gs_sim
+
+
+@pytest.fixture
+def box_obj_path(tmp_path): | tests/conftest.py | 26 | Python | 0.429 | suggestion | 122 | 51 | 51 | false | [FEATURE][BREAKING] Add maxvolume support for TetGen-based tetrahedralization, unify TetGen config handling, and add tests | 1,088 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | kosuke1701 | Review this pull request change.
Language: Python
File: tests/conftest.py
PR Title: [FEATURE][BREAKING] Add maxvolume support for TetGen-based tetrahedralization, unify TetGen config handling, and add tests
BEFORE CODE: ),
show_viewer=show_viewer,
show_FPS=False,
)
gs_robot = scene.a... | I think you could reuse this fixture in tests that were merged in some of your previous PRs no? To avoid code duplication. | 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. |
(cx + h, cy + h, cz - h), # v2
(cx - h, cy + h, cz - h), # v3
(cx - h, cy - h, cz + h), # v4
(cx + h, cy - h, cz + h), # v5
(cx + h, cy + h, cz + h), # v6
(cx - h, cy + h, cz + h), # v7
]
faces = [
(1, 2, 3, 4),
(5, 6, 7, 8),
(1, 2, ... | Do you really need the factory for this? Instead of just `tmp_path`? | (cx + h, cy + h, cz - h), # v2
(cx - h, cy + h, cz - h), # v3
(cx - h, cy - h, cz + h), # v4
(cx + h, cy - h, cz + h), # v5
(cx + h, cy + h, cz + h), # v6
(cx - h, cy + h, cz + h), # v7
]
faces = [
(1, 2, 3, 4),
(5, 6, 7, 8),
(1, 2, ... | @@ -260,3 +260,49 @@ def gs_sim(
scene.build()
return gs_sim
+
+
+@pytest.fixture(scope="session")
+def cube_verts_and_faces():
+ cx, cy, cz = (0.0, 0.0, 0.0)
+ edge_length = 1.0
+
+ h = edge_length / 2.0
+
+ verts = [
+ (cx - h, cy - h, cz - h), # v0
+ (cx + h, cy - h, cz - h), ... | tests/conftest.py | 26 | Python | 0.429 | question | 68 | 35 | 34 | false | [FEATURE][BREAKING] Add maxvolume support for TetGen-based tetrahedralization, unify TetGen config handling, and add tests | 1,088 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | kosuke1701 | Review this pull request change.
Language: Python
File: tests/conftest.py
PR Title: [FEATURE][BREAKING] Add maxvolume support for TetGen-based tetrahedralization, unify TetGen config handling, and add tests
BEFORE CODE: (cx + h, cy + h, cz - h), # v2
(cx - h, cy + h, cz - h), # v3
(cx - h,... | Do you really need the factory for this? Instead of just `tmp_path`? | 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.logger.info("Ignoring corrupted cache.")
if not is_cached_loaded:
gs.logger.info("Remeshing for tetrahedralization...")
ms = pymeshlab.MeshSet()
ms.add_mesh(pymeshlab.Mesh(vertex_matrix=self.verts, face_matrix=self.faces))
if edge_len_abs is no... | Did you make sure the new API for `tetrahedralize` is used everywhere in the codebase? | gs.logger.info("Ignoring corrupted cache.")
if not is_cached_loaded:
gs.logger.info("Remeshing for tetrahedralization...")
ms = pymeshlab.MeshSet()
ms.add_mesh(pymeshlab.Mesh(vertex_matrix=self.verts, face_matrix=self.faces))
if edge_len_abs is no... | @@ -144,17 +144,16 @@ def remesh(self, edge_len_abs=None, edge_len_ratio=0.01, fix=True):
)
self.clear_visuals()
- def tetrahedralize(self, order, mindihedral, minratio, nobisect, quality, verbose):
+ def tetrahedralize(self, tet_cfg): | genesis/engine/mesh.py | 26 | Python | 0.429 | question | 87 | 51 | 51 | false | [FEATURE][BREAKING] Add maxvolume support for TetGen-based tetrahedralization, unify TetGen config handling, and add tests | 1,088 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | kosuke1701 | Review this pull request change.
Language: Python
File: genesis/engine/mesh.py
PR Title: [FEATURE][BREAKING] Add maxvolume support for TetGen-based tetrahedralization, unify TetGen config handling, and add tests
BEFORE CODE: gs.logger.info("Ignoring corrupted cache.")
if not is_cached_loade... | Did you make sure the new API for `tetrahedralize` is used everywhere in the codebase? | 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 multiprocessing
import os
import torch
import genesis as gs
import argparse
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--vis", action="store_true", default=False)
parser.add_argument("-c", "--cpu", action="store_true", default=False)
args = parser.parse_args()
... | The '--cpu' argument is defined but not used anywhere in the script. Remove it or add logic to support CPU execution if intended. | import multiprocessing
import os
import argparse
import torch
import genesis as gs
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--vis", action="store_true", default=False)
args = parser.parse_args()
########################## init ##########################
# get c... | @@ -0,0 +1,70 @@
+import multiprocessing
+import os
+
+import torch
+
+import genesis as gs
+import argparse
+
+
+def main():
+
+ parser = argparse.ArgumentParser()
+ parser.add_argument("-v", "--vis", action="store_true", default=False)
+ parser.add_argument("-c", "--cpu", action="store_true", default=False) | examples/rigid/multi_gpu.py | 14 | Python | 0.429 | suggestion | 129 | 39 | 39 | false | [FEATURE] Add an example for multi-gpu using multi processing | 1,089 | Genesis-Embodied-AI/Genesis | 26,702 | Python | Copilot | YilingQiao | Review this pull request change.
Language: Python
File: examples/rigid/multi_gpu.py
PR Title: [FEATURE] Add an example for multi-gpu using multi processing
BEFORE CODE: import multiprocessing
import os
import torch
import genesis as gs
import argparse
def main():
parser = argparse.ArgumentParser()
pars... | The '--cpu' argument is defined but not used anywhere in the script. Remove it or add logic to support CPU execution if intended. | 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_lookat=(0.0, 0.0, 0.5),
camera_fov=40,
),
show_viewer=args.vis,
rigid_options=gs.options.RigidOptions(
# constraint_solver=gs.constraint_solver.Newton,
),
show_FPS=False,
)
########################## entities ###################... | The parameter 'data_part' is not used in the function. Consider removing it to simplify the function signature or update the function to utilize it if necessary.
```suggestion
def run(gpu_id, func):
``` | camera_fov=40,
),
show_viewer=args.vis,
show_FPS=False,
)
########################## entities ##########################
plane = scene.add_entity(
gs.morphs.Plane(),
)
franka = scene.add_entity(
gs.morphs.MJCF(file="xml/franka_emika_panda/panda.xm... | @@ -0,0 +1,70 @@
+import multiprocessing
+import os
+
+import torch
+
+import genesis as gs
+import argparse
+
+
+def main():
+
+ parser = argparse.ArgumentParser()
+ parser.add_argument("-v", "--vis", action="store_true", default=False)
+ parser.add_argument("-c", "--cpu", action="store_true", default=False)
... | examples/rigid/multi_gpu.py | 26 | Python | 0.857 | refactor | 202 | 45 | 41 | false | [FEATURE] Add an example for multi-gpu using multi processing | 1,089 | Genesis-Embodied-AI/Genesis | 26,702 | Python | Copilot | YilingQiao | Review this pull request change.
Language: Python
File: examples/rigid/multi_gpu.py
PR Title: [FEATURE] Add an example for multi-gpu using multi processing
BEFORE CODE: camera_lookat=(0.0, 0.0, 0.5),
camera_fov=40,
),
show_viewer=args.vis,
rigid_options=gs.options.Rig... | The parameter 'data_part' is not used in the function. Consider removing it to simplify the function signature or update the function to utilize it if necessary.
```suggestion
def run(gpu_id, func):
``` | 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. |
########################## entities ##########################
plane = scene.add_entity(
gs.morphs.Plane(),
)
franka = scene.add_entity(
gs.morphs.MJCF(file="xml/franka_emika_panda/panda.xml"),
visualize_contact=True,
)
########################## build #################... | Consider using torch.cuda.device_count() to dynamically determine the number of available GPUs rather than hardcoding the value.
```suggestion
num_gpus = torch.cuda.device_count()
if num_gpus == 0:
raise RuntimeError("No GPUs available. Please ensure CUDA is properly configured.")
data_partitions = ... | )
franka = scene.add_entity(
gs.morphs.MJCF(file="xml/franka_emika_panda/panda.xml"),
visualize_contact=True,
)
########################## build ##########################
scene.build()
for i in range(1000):
scene.step()
def run(gpu_id, func):
# Set environment arg... | @@ -0,0 +1,70 @@
+import multiprocessing
+import os
+
+import torch
+
+import genesis as gs
+import argparse
+
+
+def main():
+
+ parser = argparse.ArgumentParser()
+ parser.add_argument("-v", "--vis", action="store_true", default=False)
+ parser.add_argument("-c", "--cpu", action="store_true", default=False)
... | examples/rigid/multi_gpu.py | 26 | Python | 1 | suggestion | 345 | 36 | 32 | false | [FEATURE] Add an example for multi-gpu using multi processing | 1,089 | Genesis-Embodied-AI/Genesis | 26,702 | Python | Copilot | YilingQiao | Review this pull request change.
Language: Python
File: examples/rigid/multi_gpu.py
PR Title: [FEATURE] Add an example for multi-gpu using multi processing
BEFORE CODE:
########################## entities ##########################
plane = scene.add_entity(
gs.morphs.Plane(),
)
franka = sce... | Consider using torch.cuda.device_count() to dynamically determine the number of available GPUs rather than hardcoding the value.
```suggestion
num_gpus = torch.cuda.device_count()
if num_gpus == 0:
raise RuntimeError("No GPUs available. Please ensure CUDA is properly configured.")
data_partitions = ... | 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. |
viewer_options=gs.options.ViewerOptions(
camera_pos=(3.5, 0.0, 2.5),
camera_lookat=(0.0, 0.0, 0.5),
camera_fov=40,
),
show_viewer=args.vis,
rigid_options=gs.options.RigidOptions(
# constraint_solver=gs.constraint_solver.Newton,
),
... | I would recommend also setting `EGL_DEVICE_ID` for offscreen rendering | camera_pos=(3.5, 0.0, 2.5),
camera_lookat=(0.0, 0.0, 0.5),
camera_fov=40,
),
show_viewer=args.vis,
show_FPS=False,
)
########################## entities ##########################
plane = scene.add_entity(
gs.morphs.Plane(),
)
fran... | @@ -0,0 +1,70 @@
+import multiprocessing
+import os
+import argparse
+
+import torch
+
+import genesis as gs
+
+
+def main():
+
+ parser = argparse.ArgumentParser()
+ parser.add_argument("-v", "--vis", action="store_true", default=False)
+ parser.add_argument("-c", "--cpu", action="store_true", default=False)
... | examples/rigid/multi_gpu.py | 26 | Python | 0.357 | suggestion | 70 | 47 | 43 | false | [FEATURE] Add an example for multi-gpu using multi processing | 1,089 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: examples/rigid/multi_gpu.py
PR Title: [FEATURE] Add an example for multi-gpu using multi processing
BEFORE CODE: viewer_options=gs.options.ViewerOptions(
camera_pos=(3.5, 0.0, 2.5),
camera_lookat=(0.0, 0.0, 0.5),
cam... | I would recommend also setting `EGL_DEVICE_ID` for offscreen rendering | 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 multiprocessing
import os
import argparse
import torch
import genesis as gs
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--vis", action="store_true", default=False)
parser.add_argument("-c", "--cpu", action="store_true", default=False)
args = parser.parse_args()
... | You should remove this option. It makes no sense here. | import multiprocessing
import os
import argparse
import torch
import genesis as gs
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--vis", action="store_true", default=False)
args = parser.parse_args()
########################## init ##########################
# get c... | @@ -0,0 +1,70 @@
+import multiprocessing
+import os
+import argparse
+
+import torch
+
+import genesis as gs
+
+
+def main():
+
+ parser = argparse.ArgumentParser()
+ parser.add_argument("-v", "--vis", action="store_true", default=False)
+ parser.add_argument("-c", "--cpu", action="store_true", default=False) | examples/rigid/multi_gpu.py | 14 | Python | 0.286 | refactor | 54 | 39 | 39 | false | [FEATURE] Add an example for multi-gpu using multi processing | 1,089 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: examples/rigid/multi_gpu.py
PR Title: [FEATURE] Add an example for multi-gpu using multi processing
BEFORE CODE: import multiprocessing
import os
import argparse
import torch
import genesis as gs
def main():
parser = argparse.ArgumentParser()
pars... | You should remove this option. It makes no sense 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. |
import genesis as gs
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--vis", action="store_true", default=False)
parser.add_argument("-c", "--cpu", action="store_true", default=False)
args = parser.parse_args()
########################## init ##########################... | Just remove this option block, it is not the purpose of this example. |
import genesis as gs
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--vis", action="store_true", default=False)
args = parser.parse_args()
########################## init ##########################
# get current gpu
gpu_id = torch.cuda.current_device()
print("... | @@ -0,0 +1,70 @@
+import multiprocessing
+import os
+import argparse
+
+import torch
+
+import genesis as gs
+
+
+def main():
+
+ parser = argparse.ArgumentParser()
+ parser.add_argument("-v", "--vis", action="store_true", default=False)
+ parser.add_argument("-c", "--cpu", action="store_true", default=False)
... | examples/rigid/multi_gpu.py | 26 | Python | 0.286 | refactor | 69 | 51 | 51 | false | [FEATURE] Add an example for multi-gpu using multi processing | 1,089 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: examples/rigid/multi_gpu.py
PR Title: [FEATURE] Add an example for multi-gpu using multi processing
BEFORE CODE:
import genesis as gs
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--vis", action="store_true", default=Fal... | Just remove this option block, it is not the purpose of this example. | 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. |
########################## entities ##########################
plane = scene.add_entity(
gs.morphs.Plane(),
)
franka = scene.add_entity(
gs.morphs.MJCF(file="xml/franka_emika_panda/panda.xml"),
visualize_contact=True,
)
########################## build #################... | This parameter is useless, and no need to pass main as input argument. | )
franka = scene.add_entity(
gs.morphs.MJCF(file="xml/franka_emika_panda/panda.xml"),
visualize_contact=True,
)
########################## build ##########################
scene.build()
for i in range(1000):
scene.step()
def run(gpu_id, func):
# Set environment arg... | @@ -0,0 +1,70 @@
+import multiprocessing
+import os
+import argparse
+
+import torch
+
+import genesis as gs
+
+
+def main():
+
+ parser = argparse.ArgumentParser()
+ parser.add_argument("-v", "--vis", action="store_true", default=False)
+ parser.add_argument("-c", "--cpu", action="store_true", default=False)
... | examples/rigid/multi_gpu.py | 26 | Python | 0.286 | suggestion | 70 | 36 | 32 | false | [FEATURE] Add an example for multi-gpu using multi processing | 1,089 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: examples/rigid/multi_gpu.py
PR Title: [FEATURE] Add an example for multi-gpu using multi processing
BEFORE CODE:
########################## entities ##########################
plane = scene.add_entity(
gs.morphs.Plane(),
)
franka = sce... | This parameter is useless, and no need to pass main as input argument. | 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. |
euler: Optional[tuple] = None
quat: Optional[tuple] = None
requires_jac_and_IK: bool = True
def __init__(self, **data):
super().__init__(**data)
if not self.file.endswith(".xml"):
gs.raise_exception(f"Expected `.xml` extension for MJCF file: {self.file}")
if isinsta... | It might be nice to print out taking the mean in logger. | euler: Optional[tuple] = None
quat: Optional[tuple] = None
requires_jac_and_IK: bool = True
def __init__(self, **data):
super().__init__(**data)
if not self.file.endswith(".xml"):
gs.raise_exception(f"Expected `.xml` extension for MJCF file: {self.file}")
# What you... | @@ -622,8 +622,23 @@ def __init__(self, **data):
if not self.file.endswith(".xml"):
gs.raise_exception(f"Expected `.xml` extension for MJCF file: {self.file}")
- if isinstance(self.scale, np.ndarray) and self.scale.std() > gs.EPS:
- gs.raise_exception("Anisotropic scaling is no... | genesis/options/morphs.py | 26 | Python | 0.214 | suggestion | 57 | 51 | 51 | false | [BUG FIX] Fix scaling of poly-articulated robots. | 1,108 | Genesis-Embodied-AI/Genesis | 26,702 | Python | Kashu7100 | duburcqa | Review this pull request change.
Language: Python
File: genesis/options/morphs.py
PR Title: [BUG FIX] Fix scaling of poly-articulated robots.
BEFORE CODE: euler: Optional[tuple] = None
quat: Optional[tuple] = None
requires_jac_and_IK: bool = True
def __init__(self, **data):
super().__init__... | It might be nice to print out taking the mean in logger. | 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__(self, **data):
super().__init__(**data)
if isinstance(self.file, str) and not self.file.endswith(".urdf"):
gs.raise_exception(f"Expected `.urdf` extension for URDF file: {self.file}")
if isinstance(self.scale, np.ndarray) and self.scale.std() > gs.EPS:
... | It might be nice to print out taking the mean in logger.
| fixed : bool, optional
Whether the baselink of the entity should be fixed. Defaults to False.
prioritize_urdf_material : bool, optional
Sometimes a geom in a urdf file will be assigned a color, and the geom asset file also contains its own visual material. This parameter controls whether to prio... | @@ -702,8 +717,11 @@ def __init__(self, **data):
if isinstance(self.file, str) and not self.file.endswith(".urdf"):
gs.raise_exception(f"Expected `.urdf` extension for URDF file: {self.file}")
+ # Anisotropic scaling is ill-defined for poly-articulated robots. See related MJCF about this ... | genesis/options/morphs.py | 26 | Python | 0.214 | suggestion | 58 | 51 | 51 | false | [BUG FIX] Fix scaling of poly-articulated robots. | 1,108 | Genesis-Embodied-AI/Genesis | 26,702 | Python | Kashu7100 | duburcqa | Review this pull request change.
Language: Python
File: genesis/options/morphs.py
PR Title: [BUG FIX] Fix scaling of poly-articulated robots.
BEFORE CODE:
def __init__(self, **data):
super().__init__(**data)
if isinstance(self.file, str) and not self.file.endswith(".urdf"):
gs.raise... | It might be nice to print out taking the mean in logger.
| 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. |
tensor = ti_field_to_torch(self.dofs_info.stiffness, envs_idx, dofs_idx, transpose=True, unsafe=unsafe)
return tensor.squeeze(0) if self.n_envs == 0 and self._options.batch_dofs_info else tensor
def get_dofs_invweight(self, dofs_idx=None, envs_idx=None, *, unsafe=False):
if not unsafe and n... | it should be `return tensor.squeeze(0) if self.n_envs == 0 else tensor` |
def get_dofs_position(self, dofs_idx=None, envs_idx=None, *, unsafe=False):
tensor = ti_field_to_torch(self.dofs_state.pos, envs_idx, dofs_idx, transpose=True, unsafe=unsafe)
return tensor.squeeze(0) if self.n_envs == 0 else tensor
@ti.kernel
def _kernel_get_dofs_control_force(
sel... | @@ -4644,6 +4644,12 @@ def get_dofs_damping(self, dofs_idx=None, envs_idx=None, *, unsafe=False):
tensor = ti_field_to_torch(self.dofs_info.damping, envs_idx, dofs_idx, transpose=True, unsafe=unsafe)
return tensor.squeeze(0) if self.n_envs == 0 and self._options.batch_dofs_info else tensor
+ def ... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.429 | suggestion | 72 | 51 | 51 | false | [FEATURE] get mass_mat API | 1,132 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Kashu7100 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [FEATURE] get mass_mat API
BEFORE CODE: tensor = ti_field_to_torch(self.dofs_info.stiffness, envs_idx, dofs_idx, transpose=True, unsafe=unsafe)
return tensor.squeeze(0) if self.n_env... | it should be `return tensor.squeeze(0) if self.n_envs == 0 else tensor` | 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. |
"""
dofs_idx = self._get_idx(dofs_idx_local, self.n_dofs, self._dof_start, unsafe=True)
return self._solver.get_dofs_limit(dofs_idx, envs_idx, unsafe=unsafe)
@gs.assert_built
def get_dofs_stiffness(self, dofs_idx_local=None, envs_idx=None, *, unsafe=False):
dofs_idx = self._get_... | I would advice removing support of the user specified dofs here, and rather systematically return all the ones corresponding to the entity. |
@gs.assert_built
def get_dofs_stiffness(self, dofs_idx_local=None, envs_idx=None, *, unsafe=False):
dofs_idx = self._get_idx(dofs_idx_local, self.n_dofs, self._dof_start, unsafe=True)
return self._solver.get_dofs_stiffness(dofs_idx, envs_idx, unsafe=unsafe)
@gs.assert_built
def get_dof... | @@ -2408,6 +2408,11 @@ def get_dofs_damping(self, dofs_idx_local=None, envs_idx=None, *, unsafe=False):
dofs_idx = self._get_idx(dofs_idx_local, self.n_dofs, self._dof_start, unsafe=True)
return self._solver.get_dofs_damping(dofs_idx, envs_idx, unsafe=unsafe)
+ @gs.assert_built
+ def get_mass_... | genesis/engine/entities/rigid_entity/rigid_entity.py | 26 | Python | 0.429 | suggestion | 139 | 51 | 51 | false | [FEATURE] get mass_mat API | 1,132 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Kashu7100 | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_entity.py
PR Title: [FEATURE] get mass_mat API
BEFORE CODE: """
dofs_idx = self._get_idx(dofs_idx_local, self.n_dofs, self._dof_start, unsafe=True)
return self._solver.get_dofs_limit(dofs_idx, ... | I would advice removing support of the user specified dofs here, and rather systematically return all the ones corresponding to the entity. | 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.raise_exception("`envs_idx` cannot be specified for non-batched dofs info.")
tensor = ti_field_to_torch(self.dofs_info.stiffness, envs_idx, dofs_idx, transpose=True, unsafe=unsafe)
return tensor.squeeze(0) if self.n_envs == 0 and self._options.batch_dofs_info else tensor
def get_dofs... | Set ‘dofs_idx’ to none at this point, then extract the sub-matrix manually afterward both rows and columns must be filtered). | return tensor.squeeze(0) if self.n_envs == 0 else tensor
def get_dofs_position(self, dofs_idx=None, envs_idx=None, *, unsafe=False):
tensor = ti_field_to_torch(self.dofs_state.pos, envs_idx, dofs_idx, transpose=True, unsafe=unsafe)
return tensor.squeeze(0) if self.n_envs == 0 else tensor
... | @@ -4644,6 +4644,12 @@ def get_dofs_damping(self, dofs_idx=None, envs_idx=None, *, unsafe=False):
tensor = ti_field_to_torch(self.dofs_info.damping, envs_idx, dofs_idx, transpose=True, unsafe=unsafe)
return tensor.squeeze(0) if self.n_envs == 0 and self._options.batch_dofs_info else tensor
+ def ... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.429 | refactor | 125 | 51 | 51 | false | [FEATURE] get mass_mat API | 1,132 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Kashu7100 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [FEATURE] get mass_mat API
BEFORE CODE: gs.raise_exception("`envs_idx` cannot be specified for non-batched dofs info.")
tensor = ti_field_to_torch(self.dofs_info.stiffness, envs_... | Set ‘dofs_idx’ to none at this point, then extract the sub-matrix manually afterward both rows and columns must be filtered). | 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 taichi as ti
from ..rigid_entity import RigidEntity
from .avatar_joint import AvatarJoint
from .avatar_link import AvatarLink
@ti.data_oriented
class AvatarEntity(RigidEntity):
def add_link(
self,
name: str,
pos,
quat,
inertial_pos,
inertial_quat,
in... | Are you sure this is float? It should be a vector of 2 elements actually :/ | import numpy as np
import numpy.typing as npt
import taichi as ti
from ..rigid_entity import RigidEntity
from .avatar_joint import AvatarJoint
from .avatar_link import AvatarLink
@ti.data_oriented
class AvatarEntity(RigidEntity):
def add_link(
self,
name: str,
pos,
quat,
... | @@ -9,16 +9,16 @@
class AvatarEntity(RigidEntity):
def add_link(
self,
- name,
+ name: str,
pos,
quat,
inertial_pos,
inertial_quat,
inertial_i,
- inertial_mass,
- parent_idx,
- invweight,
- ):
+ inertial_mass: float... | genesis/engine/entities/avatar_entity/avatar_entity.py | 20 | Python | 0.286 | suggestion | 76 | 45 | 45 | false | [MISC] Add some initial mypy typing | 1,144 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | hughperkins | Review this pull request change.
Language: Python
File: genesis/engine/entities/avatar_entity/avatar_entity.py
PR Title: [MISC] Add some initial mypy typing
BEFORE CODE: import taichi as ti
from ..rigid_entity import RigidEntity
from .avatar_joint import AvatarJoint
from .avatar_link import AvatarLink
@ti.data_o... | Are you sure this is float? It should be a vector of 2 elements actually :/ | 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 time
import numpy as np
import numpy.typing as npt
import taichi as ti
import genesis as gs
from genesis.engine.solvers.rigid.rigid_solver_decomp import RigidSolver
import genesis.utils.geom as gu
from genesis.styles import colors, formats
from .mpr_decomp import MPR
@ti.func
def rotaxis(vecin: ti.Vector, i0... | Plain int is fine? Instead of some Taichi-specific int32 / int34 ? | from typing import TYPE_CHECKING
import numpy as np
import numpy.typing as npt
import taichi as ti
import genesis as gs
import genesis.utils.geom as gu
from genesis.styles import colors, formats
from .mpr_decomp import MPR
if TYPE_CHECKING:
from genesis.engine.solvers.rigid.rigid_solver_decomp import RigidSolver... | @@ -1,16 +1,18 @@
import time
import numpy as np
+import numpy.typing as npt
import taichi as ti
import genesis as gs
+from genesis.engine.solvers.rigid.rigid_solver_decomp import RigidSolver
import genesis.utils.geom as gu
from genesis.styles import colors, formats
from .mpr_decomp import MPR
@ti.func
... | genesis/engine/solvers/rigid/collider_decomp.py | 15 | Python | 0.286 | question | 66 | 40 | 40 | false | [MISC] Add some initial mypy typing | 1,144 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | hughperkins | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/collider_decomp.py
PR Title: [MISC] Add some initial mypy typing
BEFORE CODE: import time
import numpy as np
import numpy.typing as npt
import taichi as ti
import genesis as gs
from genesis.engine.solvers.rigid.rigid_solver_decomp... | Plain int is fine? Instead of some Taichi-specific int32 / int34 ? | 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.logger.warning(
"`use_hibernation` is set to False because `use_contact_island=False`. Please turn on `use_contact_island` if you want to use hibernation"
)
self._hibernation_thresh_vel = options.hibernation_thresh_vel
self._hibernation_thresh_acc = options.hi... | I'm not sure this change is legitimate. This is a reference to a class name, not a declaration nor a definition. | self._use_hibernation = options.use_hibernation and options.use_contact_island
if options.use_hibernation and not options.use_contact_island:
gs.logger.warning(
"`use_hibernation` is set to False because `use_contact_island=False`. Please turn on `use_contact_island` if you w... | @@ -95,23 +102,23 @@ def __init__(self, scene, sim, options):
self._cur_step = -1
- def add_entity(self, idx, material, morph, surface, visualize_contact):
+ def add_entity(self, idx, material, morph, surface, visualize_contact) -> Entity:
if isinstance(material, gs.materials.Avatar):
- ... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.429 | suggestion | 112 | 51 | 51 | false | [MISC] Add some initial mypy typing | 1,144 | 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] Add some initial mypy typing
BEFORE CODE: gs.logger.warning(
"`use_hibernation` is set to False because `use_contact_island=False`. Please turn on `use_contact_isl... | I'm not sure this change is legitimate. This is a reference to a class name, not a declaration nor a definition. | 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. |
pc = np.vstack((world_x, world_y, world_z)).T
point_cloud_h = np.hstack((pc, np.ones((pc.shape[0], 1))))
if world:
point_cloud_world = (pose @ point_cloud_h.T).T
point_cloud_world = point_cloud_world[:, :3].reshape(depth.shape[0],... | Are self.near and self.far defined? | world_y = normalized_y * depth[y, x] / _fy
world_z = depth[y, x]
pc = np.vstack((world_x, world_y, world_z)).T
point_cloud_h = np.hstack((pc, np.ones((pc.shape[0], 1))))
if world:
point_cloud_world = (pose @ point_clou... | @@ -377,7 +379,9 @@ def backproject_depth_to_pointcloud(K: np.ndarray, depth: np.ndarray, pose, worl
T_OPENGL_TO_OPENCV = np.array([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]])
cam_pose = self._rasterizer._camera_nodes[self.uid].matrix @ T_OPENGL_TO_OPENCV
- pc, mask... | genesis/vis/camera.py | 26 | Python | 0.071 | question | 35 | 51 | 51 | false | Fix Point Cloud Rendering valid mask issue | 1,200 | Genesis-Embodied-AI/Genesis | 26,702 | Python | YilingQiao | wangyian-me | Review this pull request change.
Language: Python
File: genesis/vis/camera.py
PR Title: Fix Point Cloud Rendering valid mask issue
BEFORE CODE:
pc = np.vstack((world_x, world_y, world_z)).T
point_cloud_h = np.hstack((pc, np.ones((pc.shape[0], 1))))
if world:
... | Are self.near and self.far defined? | 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 genesis as gs
class TinyMLP(nn.Module):
def __init__(self, obs_dim: int, act_dim: int) -> None:
super().__init__()
self.net = nn.Sequential(
nn.Linear(obs_dim, 128),
nn.ReLU(),
nn.Linear(128, act_dim),
)
def forward(self, x):
return s... | `os.environ["EGL_DEVICE_ID"] = str(local_rank)` for isolated rendering. Good practice even if not used in practice. |
import os, argparse, random, numpy as np
import torch, torch.nn as nn, torch.distributed as dist
from torch.nn.parallel import DistributedDataParallel as DDP
import genesis as gs
class TinyMLP(nn.Module):
def __init__(self, obs_dim: int, act_dim: int) -> None:
super().__init__()
self.net = nn.Seq... | @@ -0,0 +1,110 @@
+#!/usr/bin/env python3
+"""
+Multi-node / multi-GPU Genesis ✕ PyTorch DDP demo
+=================================================
+
+Single machine, 2 GPUs:
+ torchrun --standalone --nnodes=1 --nproc_per_node=2 examples/ddp_multi_gpu.py
+"""
+
+import os, argparse, random, numpy as np
+import torc... | examples/ddp_multi_gpu.py | 26 | Python | 0.571 | suggestion | 115 | 51 | 51 | false | [FEATURE] Add multi gpu example using pytorch ddp | 1,212 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: examples/ddp_multi_gpu.py
PR Title: [FEATURE] Add multi gpu example using pytorch ddp
BEFORE CODE: import genesis as gs
class TinyMLP(nn.Module):
def __init__(self, obs_dim: int, act_dim: int) -> None:
super().__init__()
self.net = nn.Seq... | `os.environ["EGL_DEVICE_ID"] = str(local_rank)` for isolated rendering. Good practice even if not used in practice. | 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 TinyMLP(nn.Module):
def __init__(self, obs_dim: int, act_dim: int) -> None:
super().__init__()
self.net = nn.Sequential(
nn.Linear(obs_dim, 128),
nn.ReLU(),
nn.Linear(128, act_dim),
)
def forward(self, x):
return self.net(x.float())
... | This is not how you should set the seed. Use `gs.init(backend=gs.gpu, seed= local_rank)` | import os, argparse, random, numpy as np
import torch, torch.nn as nn, torch.distributed as dist
from torch.nn.parallel import DistributedDataParallel as DDP
import genesis as gs
class TinyMLP(nn.Module):
def __init__(self, obs_dim: int, act_dim: int) -> None:
super().__init__()
self.net = nn.Sequ... | @@ -0,0 +1,110 @@
+#!/usr/bin/env python3
+"""
+Multi-node / multi-GPU Genesis ✕ PyTorch DDP demo
+=================================================
+
+Single machine, 2 GPUs:
+ torchrun --standalone --nnodes=1 --nproc_per_node=2 examples/ddp_multi_gpu.py
+"""
+
+import os, argparse, random, numpy as np
+import torc... | examples/ddp_multi_gpu.py | 26 | Python | 0.429 | suggestion | 88 | 51 | 51 | false | [FEATURE] Add multi gpu example using pytorch ddp | 1,212 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: examples/ddp_multi_gpu.py
PR Title: [FEATURE] Add multi gpu example using pytorch ddp
BEFORE CODE:
class TinyMLP(nn.Module):
def __init__(self, obs_dim: int, act_dim: int) -> None:
super().__init__()
self.net = nn.Sequential(
... | This is not how you should set the seed. Use `gs.init(backend=gs.gpu, seed= local_rank)` | 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. |
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
# sim
scene = gs.Scene(
viewer_options=gs.options.ViewerOptions(
camera_pos=(3.5, 0.0, 2.5),
camera_lookat=(0.0, 0.0, 0.5),
camera_fov=40,
),
show_viewer=False,
... | Could you make these prints more "professional" or remove them? | gs.init(backend=gs.gpu, seed=local_rank)
# sim
scene = gs.Scene(
viewer_options=gs.options.ViewerOptions(
camera_pos=(3.5, 0.0, 2.5),
camera_lookat=(0.0, 0.0, 0.5),
camera_fov=40,
),
show_viewer=False,
show_FPS=False,
)
scene.add_e... | @@ -0,0 +1,110 @@
+#!/usr/bin/env python3
+"""
+Multi-node / multi-GPU Genesis ✕ PyTorch DDP demo
+=================================================
+
+Single machine, 2 GPUs:
+ torchrun --standalone --nnodes=1 --nproc_per_node=2 examples/ddp_multi_gpu.py
+"""
+
+import os, argparse, random, numpy as np
+import torc... | examples/ddp_multi_gpu.py | 26 | Python | 0.286 | question | 63 | 51 | 51 | false | [FEATURE] Add multi gpu example using pytorch ddp | 1,212 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: examples/ddp_multi_gpu.py
PR Title: [FEATURE] Add multi gpu example using pytorch ddp
BEFORE CODE: np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
# sim
scene = gs.Scene(
viewer_options=gs.options.View... | Could you make these prints more "professional" or remove 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. |
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
# sim
scene = gs.Scene(
viewer_options=gs.options.ViewerOptions(
camera_pos=(3.5, 0.0, 2.5),
camera_lookat=(0.0, 0.0, 0.5),
camera_fov=40,
),
... | Since you did `torch.cuda.set_device(0)`, this is always 0 no? | # os.environ["EGL_DEVICE_ID"] = str(local_rank)
gs.init(backend=gs.gpu, seed=local_rank)
# sim
scene = gs.Scene(
viewer_options=gs.options.ViewerOptions(
camera_pos=(3.5, 0.0, 2.5),
camera_lookat=(0.0, 0.0, 0.5),
camera_fov=40,
),
show_viewer=... | @@ -0,0 +1,110 @@
+#!/usr/bin/env python3
+"""
+Multi-node / multi-GPU Genesis ✕ PyTorch DDP demo
+=================================================
+
+Single machine, 2 GPUs:
+ torchrun --standalone --nnodes=1 --nproc_per_node=2 examples/ddp_multi_gpu.py
+"""
+
+import os, argparse, random, numpy as np
+import torc... | examples/ddp_multi_gpu.py | 26 | Python | 0.357 | question | 62 | 51 | 51 | false | [FEATURE] Add multi gpu example using pytorch ddp | 1,212 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: examples/ddp_multi_gpu.py
PR Title: [FEATURE] Add multi gpu example using pytorch ddp
BEFORE CODE: random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
# sim
scene = gs.Scene(
viewer_o... | Since you did `torch.cuda.set_device(0)`, this is always 0 no? | 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. |
#!/usr/bin/env python3
"""
Multi-node / multi-GPU Genesis ✕ PyTorch DDP demo
=================================================
Single machine, 2 GPUs:
torchrun --standalone --nnodes=1 --nproc_per_node=2 examples/ddp_multi_gpu.py
"""
import os, argparse, random, numpy as np
import torch, torch.nn as nn, torch.dist... | Could you add a description of what this script does, and how to check if it is working as expected? | #!/usr/bin/env python3
"""
Multi-node / multi-GPU Genesis ✕ PyTorch DDP demo
=================================================
Single machine, 2 GPUs:
torchrun --standalone --nnodes=1 --nproc_per_node=2 examples/ddp_multi_gpu.py
Expectation:
- In nvidia-smi, you will see multiple GPUs are being used.
- As... | @@ -0,0 +1,110 @@
+#!/usr/bin/env python3
+"""
+Multi-node / multi-GPU Genesis ✕ PyTorch DDP demo | examples/ddp_multi_gpu.py | 3 | Python | 0.429 | question | 100 | 28 | 28 | false | [FEATURE] Add multi gpu example using pytorch ddp | 1,212 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: examples/ddp_multi_gpu.py
PR Title: [FEATURE] Add multi gpu example using pytorch ddp
BEFORE CODE: #!/usr/bin/env python3
"""
Multi-node / multi-GPU Genesis ✕ PyTorch DDP demo
=================================================
Single machine, 2 GPUs:
torch... | Could you add a description of what this script does, and how to check if it is working as 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. |
manager = multiprocessing.Manager()
motors_position = manager.list([0.0 for _ in motors_dof_idx])
stop_event = multiprocessing.Event()
gui_process = multiprocessing.Process(
target=_start_gui, args=(motors_name, motors_position_limit, motors_position, stop_event), daemon=True... | Right now L199 will give an error
```
local variable 'gui_process' referenced before assignment
```
Change to
```
if motors_dof_idx:
gui_process.join()
``` | manager = multiprocessing.Manager()
motors_position = manager.list([0.0 for _ in motors_dof_idx])
stop_event = multiprocessing.Event()
gui_process = multiprocessing.Process(
target=_start_gui, args=(motors_name, motors_position_limit, motors_position, stop_event), daemon=True... | @@ -185,11 +188,12 @@ def view(filename, collision, rotate, scale=1.0, show_link_frame=False):
t += 1 / FPS
entity.set_quat(gs.utils.geom.xyz_to_quat(np.array([0, 0, t * 50]), rpy=True, degrees=True))
- entity.set_dofs_position(
- position=torch.tensor(motors_position),
- ... | genesis/_main.py | 26 | Python | 0.929 | suggestion | 167 | 51 | 51 | false | [BUG FIX] fix no dof crash | 1,226 | Genesis-Embodied-AI/Genesis | 26,702 | Python | YilingQiao | Kashu7100 | Review this pull request change.
Language: Python
File: genesis/_main.py
PR Title: [BUG FIX] fix no dof crash
BEFORE CODE: manager = multiprocessing.Manager()
motors_position = manager.list([0.0 for _ in motors_dof_idx])
stop_event = multiprocessing.Event()
gui_process = multiprocess... | Right now L199 will give an error
```
local variable 'gui_process' referenced before assignment
```
Change to
```
if motors_dof_idx:
gui_process.join()
``` | 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_contact_info = self._solver.collider.contact_data.to_torch(gs.device)
n_contacts = self._solver.collider.n_contacts.to_torch(gs.device)
if exclude_self_contact:
valid_mask = torch.logical_xor(
torch.logical_and(
scene_contact_info["geom_a"]... | to reduce repeated code, can you do?
```
logical_operation = torch.logical_xor if exclude_self_contact else torch.logical_or
valid_mask = logical_operation(...)
``` | exclude_self_contact: bool
Exclude the self collision from the returning contacts. Defaults to False.
Returns
-------
contact_info : dict
The contact information.
"""
scene_contact_info = self._solver.collider.contact_data.to_torch(gs.device)
... | @@ -2593,16 +2595,28 @@ def get_contacts(self, with_entity=None):
scene_contact_info = self._solver.collider.contact_data.to_torch(gs.device)
n_contacts = self._solver.collider.n_contacts.to_torch(gs.device)
- valid_mask = torch.logical_or(
- torch.logical_and(
- sce... | genesis/engine/entities/rigid_entity/rigid_entity.py | 26 | Python | 0.714 | suggestion | 170 | 51 | 51 | false | [FEATURE] add exclude_self_contact option | 1,229 | Genesis-Embodied-AI/Genesis | 26,702 | Python | YilingQiao | Kashu7100 | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_entity.py
PR Title: [FEATURE] add exclude_self_contact option
BEFORE CODE:
scene_contact_info = self._solver.collider.contact_data.to_torch(gs.device)
n_contacts = self._solver.collider.n_contacts.to_... | to reduce repeated code, can you do?
```
logical_operation = torch.logical_xor if exclude_self_contact else torch.logical_or
valid_mask = logical_operation(...)
``` | 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. |
Detects collision for the entity. This only supports a single environment.
Note
----
This function re-detects real-time collision for the entity, so it doesn't rely on scene.step() and can be used for applications like motion planning, which doesn't require physical simulation during st... | When you are here, skip line to fit 120 chars max per line. | Detects collision for the entity. This only supports a single environment.
Note
----
This function re-detects real-time collision for the entity, so it doesn't rely on scene.step() and can be used for applications like motion planning, which doesn't require physical simulation during st... | @@ -2561,7 +2561,7 @@ def detect_collision(self, env_idx=0):
return collision_pairs
@gs.assert_built
- def get_contacts(self, with_entity=None):
+ def get_contacts(self, with_entity=None, exclude_self_contact=False):
"""
Returns contact information computed during the most recent... | genesis/engine/entities/rigid_entity/rigid_entity.py | 26 | Python | 0.214 | suggestion | 59 | 51 | 51 | false | [FEATURE] add exclude_self_contact option | 1,229 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Kashu7100 | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_entity.py
PR Title: [FEATURE] add exclude_self_contact option
BEFORE CODE: Detects collision for the entity. This only supports a single environment.
Note
----
This function re-detects... | When you are here, skip line to fit 120 chars max per 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. |
break
# Define free joint
j_info = dict()
j_info["name"] = "root_joint"
j_info["type"] = gs.JOINT_TYPE.FREE
j_info["n_qs"] = 7
j_info["n_dofs"] = 6
j_info["init_qpos"] = np.concatenate([gu.zero_pos(), gu.identity_quat()... | Maybe it's better not to use out-of-scope variable, although it's allowed in python | idx -= 1
break
# Define free joint
j_info = dict()
j_info["name"] = "root_joint"
j_info["type"] = gs.JOINT_TYPE.FREE
j_info["n_qs"] = 7
j_info["n_dofs"] = 6
j_info["init_qpos"] = np.concatenate([gu.zero_... | @@ -400,25 +400,38 @@ def _load_scene(self, morph, surface):
j_info["dofs_force_range"] = np.tile([-np.inf, np.inf], (6, 1))
links_j_infos[idx] = [j_info]
+ # Rename root link for clarity if relevant
+ if idx == 0: | genesis/engine/entities/rigid_entity/rigid_entity.py | 26 | Python | 0.286 | suggestion | 83 | 51 | 51 | false | [BUG FIX] Fix urdf support. | 1,235 | Genesis-Embodied-AI/Genesis | 26,702 | Python | YilingQiao | duburcqa | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_entity.py
PR Title: [BUG FIX] Fix urdf support.
BEFORE CODE: break
# Define free joint
j_info = dict()
j_info["name"] = "root_joint"
j_info["type"] = gs... | Maybe it's better not to use out-of-scope variable, although it's allowed in python | 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 tensor, _inputs_idx, envs_idx
def _get_qs_idx(self, qs_idx_local=None):
return self._get_qs_idx_local(qs_idx_local) + self._q_start
def set_links_pos(self, pos, links_idx=None, envs_idx=None, *, skip_forward=False, unsafe=False):
raise DeprecationError("This method has been remo... | why do we change `_kernel_set_links_pos ` to actually `_kernel_set_links_pos_offset` | return tensor, _inputs_idx, envs_idx
def _get_qs_idx(self, qs_idx_local=None):
return self._get_qs_idx_local(qs_idx_local) + self._q_start
def set_links_pos(self, pos, links_idx=None, envs_idx=None, *, skip_forward=False, unsafe=False):
raise DeprecationError("This method has been remo... | @@ -3870,20 +3870,23 @@ def set_base_links_pos(self, pos, links_idx=None, envs_idx=None, *, skip_forward
@ti.kernel
def _kernel_set_links_pos(
self,
- pos: ti.types.ndarray(),
+ pos_offset: ti.types.ndarray(), | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.429 | suggestion | 84 | 51 | 51 | false | [BUG FIX] Fix urdf support. | 1,235 | Genesis-Embodied-AI/Genesis | 26,702 | Python | YilingQiao | duburcqa | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [BUG FIX] Fix urdf support.
BEFORE CODE: return tensor, _inputs_idx, envs_idx
def _get_qs_idx(self, qs_idx_local=None):
return self._get_qs_idx_local(qs_idx_local) + self._q_sta... | why do we change `_kernel_set_links_pos ` to actually `_kernel_set_links_pos_offset` | 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:
q_start = self.links_info[I_l].q_start
for i in ti.static(range(3)):
self.qpos[q_start + i, i_b] = self.qpos0[q_start + i, i_b] + pos_offset[i_b_, i_l_, i]
def set_links_quat(self, quat, links_idx=None, envs_idx=None, *, skip_forward=False, unsa... | Same. Why do we make this change? I think it will change the behaviour? | if self.links_info[I_l].parent_idx == -1 and self.links_info[I_l].is_fixed:
for i in ti.static(range(3)):
self.links_state[i_l, i_b].pos[i] = pos[i_b_, i_l_, i]
if relative:
for i in ti.static(range(3)):
self.lin... | @@ -3905,20 +3908,41 @@ def set_base_links_quat(self, quat, links_idx=None, envs_idx=None, *, skip_forwa
@ti.kernel
def _kernel_set_links_quat(
self,
- quat: ti.types.ndarray(),
+ quat_offset: ti.types.ndarray(), | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.286 | question | 72 | 51 | 51 | false | [BUG FIX] Fix urdf support. | 1,235 | Genesis-Embodied-AI/Genesis | 26,702 | Python | YilingQiao | duburcqa | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [BUG FIX] Fix urdf support.
BEFORE CODE: else:
q_start = self.links_info[I_l].q_start
for i in ti.static(range(3)):
self.qpos[q_start ... | Same. Why do we make this change? I think it will change the behaviour? | 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 test_numpy_round_trip(batch_size):
print(f"Testing numpy implementation with batch size {batch_size}...")
rot = R.random(batch_size)
R_np = rot.as_matrix()
if batch_size == 1:
R_np = R_np[0]
d6 = R_to_rot6d(R_np)
R_recon = rot6d_to_R(d6)
np.testing.assert_allclose(
R_np... | Please add `pytestmark = [pytest.mark.required]` on top of this file, right after the imports, to make sure these tests run systematically on all platforms :) | R_np = rot.as_matrix()
if batch_size == 1:
R_np = R_np[0]
R_torch = torch.tensor(R_np, dtype=torch.float32)
d6 = R_to_rot6d(R_torch)
R_recon = rot6d_to_R(d6)
assert_allclose(R_torch.cpu(), R_recon.cpu(), tol=TOL)
@pytest.mark.parametrize("batch_size", [1, 10, 100])
def test_numpy_rou... | @@ -42,3 +42,91 @@ def test_numpy_round_trip(batch_size):
np.testing.assert_allclose(
R_np, R_recon, rtol=1e-5, atol=1e-6, err_msg=f"NumPy round-trip failed for batch size {batch_size}"
)
+
+
+@pytest.mark.parametrize("batch_size", [0, 1, 100]) | tests/test_utils.py | 26 | Python | 0.5 | suggestion | 158 | 51 | 51 | false | [FEATURE] transform_by_T torch and numpy batched version | 1,237 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Kashu7100 | Review this pull request change.
Language: Python
File: tests/test_utils.py
PR Title: [FEATURE] transform_by_T torch and numpy batched version
BEFORE CODE: def test_numpy_round_trip(batch_size):
print(f"Testing numpy implementation with batch size {batch_size}...")
rot = R.random(batch_size)
R_np = rot.... | Please add `pytestmark = [pytest.mark.required]` on top of this file, right after the imports, to make sure these tests run systematically on all platforms :) | 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. |
(3,), a batch of points (B, 3), or a batched batch of points (B, N, 3).
T: np.ndarray | torch.Tensor
The 4x4 transformation matrix or a batch of B transformation
matrices of shape (B, 4, 4). Must be of the same type as `pos`.
Returns
-------
The transformed points in a shap... | Could you factorize your implementation to share more code between numpy and torch? If you favour `reshape` over `unsqueeze` and `squeeze` it should be possible to remove most of the duplication I think? That would be great ! | (3,), a batch of points (B, 3), or a batched batch of points (B, N, 3).
T: np.ndarray | torch.Tensor
The 4x4 transformation matrix or a batch of B transformation
matrices of shape (B, 4, 4). Must be of the same type as `pos`.
Returns
-------
The transformed points in a shap... | @@ -838,6 +838,77 @@ def transform_pos_quat_by_trans_quat(pos, quat, t_trans, t_quat):
return new_pos, new_quat
+def transform_by_T(pos, T):
+ """
+ Transforms 3D points by a 4x4 transformation matrix or a batch of matrices,
+ supporting both NumPy arrays and PyTorch tensors.
+
+ Parameters
+ --... | genesis/utils/geom.py | 26 | Python | 0.643 | question | 225 | 51 | 51 | false | [FEATURE] transform_by_T torch and numpy batched version | 1,237 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Kashu7100 | Review this pull request change.
Language: Python
File: genesis/utils/geom.py
PR Title: [FEATURE] transform_by_T torch and numpy batched version
BEFORE CODE: (3,), a batch of points (B, 3), or a batched batch of points (B, N, 3).
T: np.ndarray | torch.Tensor
The 4x4 transformation matrix or a b... | Could you factorize your implementation to share more code between numpy and torch? If you favour `reshape` over `unsqueeze` and `squeeze` it should be possible to remove most of the duplication I think? That would be great ! | 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. |
rot = R.random(batch_size)
R_np = rot.as_matrix()
if batch_size == 1:
R_np = R_np[0]
d6 = R_to_rot6d(R_np)
R_recon = rot6d_to_R(d6)
np.testing.assert_allclose(
R_np, R_recon, rtol=1e-5, atol=1e-6, err_msg=f"NumPy round-trip failed for batch size {batch_size}"
)
@pytest.ma... | See my other review:
* No need to do `.numpy()` anywhere
* rather use our own `assert_allclose`
* `tolerance` should be a global constant after the imports.
* You need to jutify your tolerance threshold, why 1e-5 ? It is actually quite bad. And I possible, use `tol` instead of `atol` + `rtol` | d6 = R_to_rot6d(R_torch)
R_recon = rot6d_to_R(d6)
assert_allclose(R_torch.cpu(), R_recon.cpu(), tol=TOL)
@pytest.mark.parametrize("batch_size", [1, 10, 100])
def test_numpy_round_trip(batch_size):
print(f"Testing numpy implementation with batch size {batch_size}...")
rot = R.random(batch_size)
... | @@ -42,3 +45,91 @@ def test_numpy_round_trip(batch_size):
np.testing.assert_allclose(
R_np, R_recon, rtol=1e-5, atol=1e-6, err_msg=f"NumPy round-trip failed for batch size {batch_size}"
)
+
+
+@pytest.mark.parametrize("batch_size", [0, 1, 100])
+def test_torch_identity_transform(batch_size):
+ if ... | tests/test_utils.py | 26 | Python | 0.643 | suggestion | 297 | 51 | 51 | false | [FEATURE] transform_by_T torch and numpy batched version | 1,237 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Kashu7100 | Review this pull request change.
Language: Python
File: tests/test_utils.py
PR Title: [FEATURE] transform_by_T torch and numpy batched version
BEFORE CODE: rot = R.random(batch_size)
R_np = rot.as_matrix()
if batch_size == 1:
R_np = R_np[0]
d6 = R_to_rot6d(R_np)
R_recon = rot6d_to_R(d6)... | See my other review:
* No need to do `.numpy()` anywhere
* rather use our own `assert_allclose`
* `tolerance` should be a global constant after the imports.
* You need to jutify your tolerance threshold, why 1e-5 ? It is actually quite bad. And I possible, use `tol` instead of `atol` + `rtol` | 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. |
@pytest.mark.parametrize("batch_size", [1, 10, 100])
def test_torch_round_trip(batch_size):
print(f"Testing torch implementation with batch size {batch_size}...")
rot = R.random(batch_size)
R_np = rot.as_matrix()
if batch_size == 1:
R_np = R_np[0]
R_torch = torch.tensor(R_np, dtype=torch.f... | A bit of a shame to loose the debugging error messages. You could have extended `assert_allclose` to support optional argument `err_msg`, but it is up to you.
EDIT: Although I have to admit in this case the message was not informative it is good to remove it. |
TOL = 1e-7
pytestmark = [pytest.mark.required]
@pytest.fixture
def clear_seen_fixture():
warnings_mod._seen.clear()
yield
warnings_mod._seen.clear()
@pytest.mark.parametrize("batch_size", [1, 10, 100])
def test_torch_round_trip(batch_size):
print(f"Testing torch implementation with batch size {bat... | @@ -19,13 +26,7 @@ def test_torch_round_trip(batch_size):
d6 = R_to_rot6d(R_torch)
R_recon = rot6d_to_R(d6)
- np.testing.assert_allclose(
- R_torch.cpu().numpy(),
- R_recon.cpu().numpy(),
- rtol=1e-5,
- atol=1e-6,
- err_msg=f"Torch round-trip failed for batch size {batc... | tests/test_utils.py | 26 | Python | 0.786 | bug | 263 | 51 | 51 | false | [FEATURE] transform_by_T torch and numpy batched version | 1,237 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Kashu7100 | Review this pull request change.
Language: Python
File: tests/test_utils.py
PR Title: [FEATURE] transform_by_T torch and numpy batched version
BEFORE CODE:
@pytest.mark.parametrize("batch_size", [1, 10, 100])
def test_torch_round_trip(batch_size):
print(f"Testing torch implementation with batch size {batch_si... | A bit of a shame to loose the debugging error messages. You could have extended `assert_allclose` to support optional argument `err_msg`, but it is up to you.
EDIT: Although I have to admit in this case the message was not informative it is good to remove 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. |
else:
gs.raise_exception(f"invalid input dim for pos: {pos.shape=}")
return new_pos
def transform_by_T(pos, T):
"""
Transforms 3D points by a 4x4 transformation matrix or a batch of matrices,
supporting both NumPy arrays and PyTorch tensors.
Parameters
----------
pos: np.ndarr... | Could you try to factories both implementations in one, for the part that could be shared ? Typically
```python
pos_hom_t = pos_hom.swapaxes(-1, -2) # (..., N, 4) -> (..., 4, N)
transformed_hom = T @ pos_hom_t
transformed_hom = transformed_hom.swapaxes(-1, -2)[..., :3]
if pos.n... | pos_hom = np.concatenate([pos, np.ones(ones_shape, dtype=pos.dtype)], axis=-1)
else:
pos_hom = np.append(pos, 1)
else:
gs.raise_exception(f"Inputs must be both torch.Tensor or both np.ndarray. Got: {type(pos)=} and {type(T)=}")
if pos_hom.ndim == 1:
pos_hom = pos... | @@ -838,6 +838,124 @@ def transform_pos_quat_by_trans_quat(pos, quat, t_trans, t_quat):
return new_pos, new_quat
+def transform_by_R(pos, R):
+ """
+ Transforms 3D points by a 3x3 rotation matrix or a batch of matrices,
+ supporting both NumPy arrays and PyTorch tensors.
+
+ Parameters
+ -------... | genesis/utils/geom.py | 26 | Python | 0.857 | question | 558 | 51 | 51 | false | [FEATURE] transform_by_R, inv_transform_by_T torch and numpy batched version | 1,242 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Kashu7100 | Review this pull request change.
Language: Python
File: genesis/utils/geom.py
PR Title: [FEATURE] transform_by_R, inv_transform_by_T torch and numpy batched version
BEFORE CODE: else:
gs.raise_exception(f"invalid input dim for pos: {pos.shape=}")
return new_pos
def transform_by_T(pos, T):
"""
... | Could you try to factories both implementations in one, for the part that could be shared ? Typically
```python
pos_hom_t = pos_hom.swapaxes(-1, -2) # (..., N, 4) -> (..., 4, N)
transformed_hom = T @ pos_hom_t
transformed_hom = transformed_hom.swapaxes(-1, -2)[..., :3]
if pos.n... | 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:
pos = torch.randn(batch_size, 3)
b_pos = torch.randn(batch_size, 10, 3)
if func == "R":
identity = torch.eye(3)
batched_identity = torch.eye(3).reshape(1, 3, 3).repeat(batch_size, 1, 1)
transform = transform_by_R
elif func == "T":
identity = torch.eye(4... | Why this accuracy?
I should probably disable auto-start of genesis for every single tests. There is no point here. |
@pytest.mark.parametrize("batch_size", [0, 1, 100])
@pytest.mark.parametrize("func", ["T", "R"])
def test_torch_identity_transform(batch_size, func):
if batch_size == 0:
pos = torch.randn(3)
b_pos = torch.randn(10, 3)
else:
pos = torch.randn(batch_size, 3)
b_pos = torch.randn(ba... | @@ -42,3 +45,107 @@ def test_numpy_round_trip(batch_size):
np.testing.assert_allclose(
R_np, R_recon, rtol=1e-5, atol=1e-6, err_msg=f"NumPy round-trip failed for batch size {batch_size}"
)
+
+
+@pytest.mark.parametrize("batch_size", [0, 1, 100])
+@pytest.mark.parametrize("func", ["T", "R"])
+def test... | tests/test_utils.py | 26 | Python | 0.429 | question | 117 | 51 | 51 | false | [FEATURE] transform_by_R, inv_transform_by_T torch and numpy batched version | 1,242 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Kashu7100 | Review this pull request change.
Language: Python
File: tests/test_utils.py
PR Title: [FEATURE] transform_by_R, inv_transform_by_T torch and numpy batched version
BEFORE CODE: else:
pos = torch.randn(batch_size, 3)
b_pos = torch.randn(batch_size, 10, 3)
if func == "R":
identity = to... | Why this accuracy?
I should probably disable auto-start of genesis for every single tests. There is no point 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. |
R_np, R_recon, rtol=1e-5, atol=1e-6, err_msg=f"NumPy round-trip failed for batch size {batch_size}"
)
@pytest.mark.parametrize("batch_size", [0, 1, 100])
@pytest.mark.parametrize("func", ["T", "R"])
def test_torch_identity_transform(batch_size, func):
if batch_size == 0:
pos = torch.randn(3)
... | You don't need `.numpy()` I think. | rot = R.random(batch_size)
R_np = rot.as_matrix()
if batch_size == 1:
R_np = R_np[0]
d6 = R_to_rot6d(R_np)
R_recon = rot6d_to_R(d6)
assert_allclose(R_np, R_recon, tol=TOL)
@pytest.mark.parametrize("batch_size", [0, 1, 100])
@pytest.mark.parametrize("func", ["T", "R"])
def test_torch_... | @@ -42,3 +45,107 @@ def test_numpy_round_trip(batch_size):
np.testing.assert_allclose(
R_np, R_recon, rtol=1e-5, atol=1e-6, err_msg=f"NumPy round-trip failed for batch size {batch_size}"
)
+
+
+@pytest.mark.parametrize("batch_size", [0, 1, 100])
+@pytest.mark.parametrize("func", ["T", "R"])
+def test... | tests/test_utils.py | 26 | Python | 0.214 | suggestion | 34 | 51 | 51 | false | [FEATURE] transform_by_R, inv_transform_by_T torch and numpy batched version | 1,242 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Kashu7100 | Review this pull request change.
Language: Python
File: tests/test_utils.py
PR Title: [FEATURE] transform_by_R, inv_transform_by_T torch and numpy batched version
BEFORE CODE: R_np, R_recon, rtol=1e-5, atol=1e-6, err_msg=f"NumPy round-trip failed for batch size {batch_size}"
)
@pytest.mark.parametrize... | You don't need `.numpy()` 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. |
@pytest.mark.parametrize("batch_size", [0, 1, 100])
@pytest.mark.parametrize("func", ["T", "R"])
def test_torch_identity_transform(batch_size, func):
if batch_size == 0:
pos = torch.randn(3)
b_pos = torch.randn(10, 3)
else:
pos = torch.randn(batch_size, 3)
b_pos = torch.randn(b... | Add a global `TOL` variable on top right after the imports. | if batch_size == 1:
R_np = R_np[0]
d6 = R_to_rot6d(R_np)
R_recon = rot6d_to_R(d6)
assert_allclose(R_np, R_recon, tol=TOL)
@pytest.mark.parametrize("batch_size", [0, 1, 100])
@pytest.mark.parametrize("func", ["T", "R"])
def test_torch_identity_transform(batch_size, func):
if batch_size ==... | @@ -42,3 +45,107 @@ def test_numpy_round_trip(batch_size):
np.testing.assert_allclose(
R_np, R_recon, rtol=1e-5, atol=1e-6, err_msg=f"NumPy round-trip failed for batch size {batch_size}"
)
+
+
+@pytest.mark.parametrize("batch_size", [0, 1, 100])
+@pytest.mark.parametrize("func", ["T", "R"])
+def test... | tests/test_utils.py | 26 | Python | 0.357 | suggestion | 59 | 51 | 51 | false | [FEATURE] transform_by_R, inv_transform_by_T torch and numpy batched version | 1,242 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Kashu7100 | Review this pull request change.
Language: Python
File: tests/test_utils.py
PR Title: [FEATURE] transform_by_R, inv_transform_by_T torch and numpy batched version
BEFORE CODE:
@pytest.mark.parametrize("batch_size", [0, 1, 100])
@pytest.mark.parametrize("func", ["T", "R"])
def test_torch_identity_transform(batch_s... | Add a global `TOL` variable on top right after the imports. | 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. |
@pytest.mark.parametrize("batch_size", [0, 1, 100])
@pytest.mark.parametrize("func", ["T", "R"])
def test_torch_identity_transform(batch_size, func):
if batch_size == 0:
pos = torch.randn(3)
b_pos = torch.randn(10, 3)
else:
pos = torch.randn(batch_size, 3)
b_pos = torch.randn(bat... | Add support of `err_msg` in our own `assert_allclose` implementation. |
d6 = R_to_rot6d(R_np)
R_recon = rot6d_to_R(d6)
assert_allclose(R_np, R_recon, tol=TOL)
@pytest.mark.parametrize("batch_size", [0, 1, 100])
@pytest.mark.parametrize("func", ["T", "R"])
def test_torch_identity_transform(batch_size, func):
if batch_size == 0:
pos = torch.randn(3)
b_pos ... | @@ -42,3 +45,107 @@ def test_numpy_round_trip(batch_size):
np.testing.assert_allclose(
R_np, R_recon, rtol=1e-5, atol=1e-6, err_msg=f"NumPy round-trip failed for batch size {batch_size}"
)
+
+
+@pytest.mark.parametrize("batch_size", [0, 1, 100])
+@pytest.mark.parametrize("func", ["T", "R"])
+def test... | tests/test_utils.py | 26 | Python | 0.357 | suggestion | 69 | 51 | 51 | false | [FEATURE] transform_by_R, inv_transform_by_T torch and numpy batched version | 1,242 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Kashu7100 | Review this pull request change.
Language: Python
File: tests/test_utils.py
PR Title: [FEATURE] transform_by_R, inv_transform_by_T torch and numpy batched version
BEFORE CODE: @pytest.mark.parametrize("batch_size", [0, 1, 100])
@pytest.mark.parametrize("func", ["T", "R"])
def test_torch_identity_transform(batch_siz... | Add support of `err_msg` in our own `assert_allclose` implementation. | 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. |
# Get available memory (RAM & VRAM) and number of physical cores.
physical_core_count = psutil.cpu_count(logical=False)
_, _, ram_memory, _ = gs.utils.get_device(gs.cpu)
_, _, vram_memory, _ = gs.utils.get_device(gs.gpu)
# Compute the default number of workers based on available RAM, VRAM, and numb... | To resolve the following error.
```bash
$ pytest tests/test_utils.py::test_numpy_identity_transform
============================================================================================================================================================== test session starts ====================================... | physical_core_count = psutil.cpu_count(logical=False)
_, _, ram_memory, _ = gs.utils.get_device(gs.cpu)
_, _, vram_memory, _ = gs.utils.get_device(gs.gpu)
# Compute the default number of workers based on available RAM, VRAM, and number of physical cores.
# Note that if `forked` is not enabled, up t... | @@ -80,8 +80,8 @@ def pytest_xdist_auto_num_workers(config):
)
-def pytest_set_filtered_exceptions():
- return (HTTPError,) | tests/conftest.py | 26 | Python | 1 | security | 9,460 | 51 | 51 | false | [FEATURE] transform_by_R, inv_transform_by_T torch and numpy batched version | 1,242 | Genesis-Embodied-AI/Genesis | 26,702 | Python | Kashu7100 | Kashu7100 | Review this pull request change.
Language: Python
File: tests/conftest.py
PR Title: [FEATURE] transform_by_R, inv_transform_by_T torch and numpy batched version
BEFORE CODE: # Get available memory (RAM & VRAM) and number of physical cores.
physical_core_count = psutil.cpu_count(logical=False)
_, _, ram_... | To resolve the following error.
```bash
$ pytest tests/test_utils.py::test_numpy_identity_transform
============================================================================================================================================================== test session starts ====================================... | 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. |
This parameter is deprecated. Please use 'convexify' and 'decompose_(robot|object)_error_threshold' instead.
decompose_object_error_threshold : bool, optional:
For basic rigid objects (mug, table...), skip convex decomposition if the relative difference between the
volume of original mesh an... | As you said, maybe`default_amature` is a more accurate name | sufficient to met the desired accuracy (see 'decompose_(robot|object)_error_threshold' documentation). The
module 'coacd' is used for this decomposition process. If not given, it defaults to `True` for `RigidEntity`
and `False` for other deformable entities.
decompose_nonconvex : bool, optio... | @@ -708,13 +708,16 @@ class URDF(FileMorph):
Whether to merge links connected via a fixed joint. Defaults to True.
links_to_keep : list of str, optional
A list of link names that should not be skipped during link merging. Defaults to [].
+ armature : float, optional | genesis/options/morphs.py | 26 | Python | 0.357 | suggestion | 59 | 51 | 51 | false | [BUG FIX] More robust MJCF / URDF parsing. | 1,262 | Genesis-Embodied-AI/Genesis | 26,702 | Python | YilingQiao | duburcqa | Review this pull request change.
Language: Python
File: genesis/options/morphs.py
PR Title: [BUG FIX] More robust MJCF / URDF parsing.
BEFORE CODE: This parameter is deprecated. Please use 'convexify' and 'decompose_(robot|object)_error_threshold' instead.
decompose_object_error_threshold : bool, option... | As you said, maybe`default_amature` is a more accurate name | 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 .constraint_solver_decomp import ConstraintSolver
from .constraint_solver_decomp_island import ConstraintSolverIsland
from .sdf_decomp import SDF
if TYPE_CHECKING:
from genesis.engine.scene import Scene
from genesis.engine.simulator import Simulator
# minimum constraint impedance
IMP_MIN = 0.0001
# maxi... | It might be unstable / hacky to rely on the logic of checking timeconst == gs.EPS, but I don't have a very strong opinion here. | from .constraint_solver_decomp import ConstraintSolver
from .constraint_solver_decomp_island import ConstraintSolverIsland
from .sdf_decomp import SDF
if TYPE_CHECKING:
from genesis.engine.scene import Scene
from genesis.engine.simulator import Simulator
# minimum constraint impedance
IMP_MIN = 0.0001
# maxi... | @@ -41,7 +41,7 @@ def _sanitize_sol_params(
timeconst, dampratio, dmin, dmax, width, mid, power = sol_params.reshape((-1, 7)).T
if global_timeconst is not None:
timeconst[:] = global_timeconst
- if (timeconst < gs.EPS).any():
+ if (timeconst <= gs.EPS).any(): | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.357 | suggestion | 127 | 51 | 51 | false | [BUG FIX] More robust MJCF / URDF parsing. | 1,262 | Genesis-Embodied-AI/Genesis | 26,702 | Python | YilingQiao | duburcqa | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [BUG FIX] More robust MJCF / URDF parsing.
BEFORE CODE: from .constraint_solver_decomp import ConstraintSolver
from .constraint_solver_decomp_island import ConstraintSolverIsland
from .sdf_decomp im... | It might be unstable / hacky to rely on the logic of checking timeconst == gs.EPS, but I don't have a very strong opinion 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. |
import pytest
import time
from enum import Enum
from pathlib import Path
from typing import Any
import numpy as np
import torch
import wandb
import genesis as gs
from .utils import (
get_hardware_fingerprint,
get_platform_fingerprint,
get_git_commit_timestamp,
get_git_commit_info,
)
BENCHMARK_NAME ... | Will this value be stable on difference device / workload? | import pytest
import time
from enum import Enum
from pathlib import Path
from typing import Any
import numpy as np
import torch
import wandb
import genesis as gs
from .utils import (
get_hardware_fingerprint,
get_platform_fingerprint,
get_git_commit_timestamp,
get_git_commit_info,
)
BENCHMARK_NAME ... | @@ -25,8 +25,8 @@
REPORT_FILE = "speed_test.txt"
STEP_DT = 0.01
-NUM_WARMUP_FRAMES = 9500
-NUM_RECORD_FRAMES = 500
+DURATION_WARMUP = 45.0
+DURATION_RECORD = 15.0 | tests/test_rigid_benchmarks.py | 26 | Python | 0.214 | question | 58 | 51 | 51 | false | [MISC] Optimise benchmark duration. | 1,281 | Genesis-Embodied-AI/Genesis | 26,702 | Python | YilingQiao | duburcqa | Review this pull request change.
Language: Python
File: tests/test_rigid_benchmarks.py
PR Title: [MISC] Optimise benchmark duration.
BEFORE CODE: import pytest
import time
from enum import Enum
from pathlib import Path
from typing import Any
import numpy as np
import torch
import wandb
import genesis as gs
from ... | Will this value be stable on difference device / workload? | 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. |
convexify=convexify,
scale=1.0,
),
vis_mode="collision",
visualize_contact=True,
)
scene.build()
if convexify:
assert all(geom.metadata["decomposed"] for geom in obj.geoms)
# MPR collision detection is significantly less reliable than SDF in term... | Looks like we've been changing this parameter back and forth. I'm curious—why is it sensitive and how does it influnce the simulation? | convexify=convexify,
scale=1.0,
),
vis_mode="collision",
visualize_contact=True,
)
scene.build()
if convexify:
assert all(geom.metadata["decomposed"] for geom in obj.geoms)
# MPR collision detection is significantly less reliable than SDF in term... | @@ -1613,7 +1613,7 @@ def test_mesh_repair(convexify, show_viewer):
@pytest.mark.required
-@pytest.mark.parametrize("euler", [(90, 0, 90), (75, 15, 90)])
+@pytest.mark.parametrize("euler", [(90, 0, 90), (74, 15, 90)]) | tests/test_rigid_physics.py | 26 | Python | 0.357 | security | 134 | 51 | 51 | false | [MISC] Optimise benchmark duration. | 1,281 | Genesis-Embodied-AI/Genesis | 26,702 | Python | YilingQiao | duburcqa | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [MISC] Optimise benchmark duration.
BEFORE CODE: convexify=convexify,
scale=1.0,
),
vis_mode="collision",
visualize_contact=True,
)
scene.build()
if convexify:
... | Looks like we've been changing this parameter back and forth. I'm curious—why is it sensitive and how does it influnce the simulation? | 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. |
subterrain_parameters : dictionary, optional
Lets users pick their own subterrain parameters.
"""
is_free: bool = False
randomize: bool = False # whether to randomize the terrain
n_subterrains: Tuple[int, int] = (3, 3) # number of subterrains in x and y directions
subterrain_size: Tup... | What is this nightmare? Just do `merged = self.default_params | user`.
And merged is not an appropriate name either. | subterrain_types : str or 2D list of str, optional
The types of subterrains to generate. If a string, it will be repeated for all subterrains. If a 2D list, it should have the same shape as `n_subterrains`.
height_field : array-like, optional
The height field to generate the terrain. If specifie... | @@ -909,10 +911,26 @@ class Terrain(Morph):
height_field: Any = None
name: str = "default" # name to store and reuse the terrain
from_stored: Any = None
+ subterrain_parameters: dict[str, dict] | None = None
def __init__(self, **data):
+ user = data.get("subterrain_parameters", {}) or {... | genesis/options/morphs.py | 26 | Python | 0.571 | question | 119 | 51 | 51 | false | [FEATURE] Add optional subterrain parameters. | 1,289 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/options/morphs.py
PR Title: [FEATURE] Add optional subterrain parameters.
BEFORE CODE: subterrain_parameters : dictionary, optional
Lets users pick their own subterrain parameters.
"""
is_free: bool = False
randomize: bool = Fa... | What is this nightmare? Just do `merged = self.default_params | user`.
And merged is not an appropriate name either. | 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. |
name : str, optional
The name of the terrain to save
from_stored : str, optional
The path of the stored terrain to load
subterrain_parameters : dictionary, optional
Lets users pick their own subterrain parameters.
"""
is_free: bool = False
randomize: bool = False # whet... | Just do `user = data.get("subterrain_parameters") or {}`.
By the way, `user` is not an appropriate variable name. | horizontal_scale : float, optional
The size of each cell in the subterrain in meters. Defaults to 0.25.
vertical_scale : float, optional
The height of each step in the subterrain in meters. Defaults to 0.005.
subterrain_types : str or 2D list of str, optional
The types of subterrains... | @@ -909,10 +911,26 @@ class Terrain(Morph):
height_field: Any = None
name: str = "default" # name to store and reuse the terrain
from_stored: Any = None
+ subterrain_parameters: dict[str, dict] | None = None
def __init__(self, **data):
+ user = data.get("subterrain_parameters", {}) or {... | genesis/options/morphs.py | 26 | Python | 0.571 | suggestion | 117 | 51 | 51 | false | [FEATURE] Add optional subterrain parameters. | 1,289 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/options/morphs.py
PR Title: [FEATURE] Add optional subterrain parameters.
BEFORE CODE: name : str, optional
The name of the terrain to save
from_stored : str, optional
The path of the stored terrain to load
subterrain_parame... | Just do `user = data.get("subterrain_parameters") or {}`.
By the way, `user` is not an appropriate variable name. | 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_ref = gs.Scene(show_viewer=show_viewer)
terrain_ref = scene_ref.add_entity(
morph=gs.morphs.Terrain(
n_subterrains=(2, 2),
subterrain_size=(12.0, 12.0),
horizontal_scale=0.25,
subterrain_types="wave_terrain",
)
)
height_ref = terrain... | Remove `.all()`, otherwise this test does nothing. | @pytest.mark.parametrize("model_name", ["collision_edge_cases"])
@pytest.mark.parametrize("gs_solver", [gs.constraint_solver.CG])
@pytest.mark.parametrize("gs_integrator", [gs.integrator.Euler])
@pytest.mark.parametrize("backend", [gs.cpu])
def test_nan_reset(gs_sim, mode):
for _ in range(200):
gs_sim.scene... | @@ -1923,6 +1923,37 @@ def test_terrain_generation(show_viewer):
assert height_balls_max - height_balls_min > 0.5 * (height_field_max - height_field_min)
+@pytest.mark.required
+@pytest.mark.parametrize("backend", [gs.cpu])
+def test_terrain_size(show_viewer, tol):
+ scene_ref = gs.Scene(show_viewer=show_vi... | tests/test_rigid_physics.py | 26 | Python | 0.429 | suggestion | 50 | 51 | 51 | false | [FEATURE] Add optional subterrain parameters. | 1,289 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [FEATURE] Add optional subterrain parameters.
BEFORE CODE: scene_ref = gs.Scene(show_viewer=show_viewer)
terrain_ref = scene_ref.add_entity(
morph=gs.morphs.Terrain(
n_subterrains=(2, 2),
... | Remove `.all()`, otherwise this test does nothing. | 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 terrain to save
from_stored : str, optional
The path of the stored terrain to load
subterrain_parameters : dictionary, optional
Lets users pick their own subterrain parameters.
"""
is_free: bool = False
randomize: bool = False # whether to randomize the terr... | Not great but acceptable now. Avoid creating all these temporaries and use them directly, this would be cleaner I think. `key` is still not a great name, and `effective` is weird (custom or overwritten would be more common). But now it is ok. | The size of each cell in the subterrain in meters. Defaults to 0.25.
vertical_scale : float, optional
The height of each step in the subterrain in meters. Defaults to 0.005.
subterrain_types : str or 2D list of str, optional
The types of subterrains to generate. If a string, it will be r... | @@ -909,10 +911,23 @@ class Terrain(Morph):
height_field: Any = None
name: str = "default" # name to store and reuse the terrain
from_stored: Any = None
+ subterrain_parameters: dict[str, dict] | None = None
def __init__(self, **data):
+ custom_params = data.get("subterrain_parameters")... | genesis/options/morphs.py | 26 | Python | 0.643 | suggestion | 242 | 51 | 51 | false | [FEATURE] Add optional subterrain parameters. | 1,289 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/options/morphs.py
PR Title: [FEATURE] Add optional subterrain parameters.
BEFORE CODE: The name of the terrain to save
from_stored : str, optional
The path of the stored terrain to load
subterrain_parameters : dictionary, option... | Not great but acceptable now. Avoid creating all these temporaries and use them directly, this would be cleaner I think. `key` is still not a great name, and `effective` is weird (custom or overwritten would be more common). But now it is ok. | 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. |
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and relat... | I guess this should be `gs.np_float`? | # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and relat... | @@ -21,7 +21,7 @@ def fractal_terrain(terrain, levels=8, scale=1.0):
"""
width = terrain.width
length = terrain.length
- height = np.zeros((width, length))
+ height = np.zeros((width, length), dtype=np.float32) | genesis/ext/isaacgym/terrain_utils.py | 24 | Python | 0.286 | question | 37 | 49 | 49 | false | [FEATURE] Add optional subterrain parameters. | 1,289 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/ext/isaacgym/terrain_utils.py
PR Title: [FEATURE] Add optional subterrain parameters.
BEFORE CODE: # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary... | I guess this should be `gs.np_float`? | 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. |
y1 = terrain.length // 2 - platform_size
y2 = terrain.length // 2 + platform_size
min_h = min(terrain.height_field_raw[x1, y1], 0)
max_h = max(terrain.height_field_raw[x1, y1], 0)
terrain.height_field_raw = np.clip(terrain.height_field_raw, min_h, max_h)
return terrain
def discrete_obstacles_... | You mixed in the changes from another PR. | y1 = terrain.length // 2 - platform_size
y2 = terrain.length // 2 + platform_size
min_h = min(terrain.height_field_raw[x1, y1], 0)
max_h = max(terrain.height_field_raw[x1, y1], 0)
terrain.height_field_raw = np.clip(terrain.height_field_raw, min_h, max_h)
return terrain
def discrete_obstacles_... | @@ -160,9 +160,9 @@ def discrete_obstacles_terrain(terrain, max_height, min_size, max_size, num_rect
"""
# switch parameters to discrete units
max_height = int(max_height / terrain.vertical_scale)
- min_size = int(min_size / terrain.horizontal_scale)
- max_size = int(max_size / terrain.horizontal_s... | genesis/ext/isaacgym/terrain_utils.py | 26 | Python | 0.143 | suggestion | 41 | 51 | 51 | false | [BUG FIX] Preserve external forces across sub-steps. | 1,290 | Genesis-Embodied-AI/Genesis | 26,702 | Python | YilingQiao | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/ext/isaacgym/terrain_utils.py
PR Title: [BUG FIX] Preserve external forces across sub-steps.
BEFORE CODE: y1 = terrain.length // 2 - platform_size
y2 = terrain.length // 2 + platform_size
min_h = min(terrain.height_field_raw[x1, y1], 0)
... | You mixed in the changes from another PR. | 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. |
# @@@@@@@@@ Composer starts here
# decomposed kernels should happen in the block below. This block will be handled by composer and composed into a single kernel
@ti.func
def _func_forward_dynamics(self):
self._func_compute_mass_matrix(
implicit_damping=ti.static(self._integrator == g... | Those changes are not relevant.
Can you run
```
black --line-length 120 .
```
You can also install a git pre-commit hook to help you do it automatically before every commit.
```
pre-commit install
``` |
@ti.kernel
def _kernel_update_acc(self):
self._func_update_acc(update_cacc=True)
# @@@@@@@@@ Composer starts here
# decomposed kernels should happen in the block below. This block will be handled by composer and composed into a single kernel
@ti.func
def _func_forward_dynamics(self):
... | @@ -1699,11 +1701,11 @@ def substep(self):
timer = create_timer("rigid", level=1, ti_sync=True, skip_first_call=True)
self._kernel_step_1()
timer.stamp("kernel_step_1")
-
+ | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.857 | suggestion | 214 | 51 | 51 | false | [BUG FIX] Preserve external forces across sub-steps. | 1,290 | Genesis-Embodied-AI/Genesis | 26,702 | Python | YilingQiao | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [BUG FIX] Preserve external forces across sub-steps.
BEFORE CODE: # @@@@@@@@@ Composer starts here
# decomposed kernels should happen in the block below. This block will be handled by compos... | Those changes are not relevant.
Can you run
```
black --line-length 120 .
```
You can also install a git pre-commit hook to help you do it automatically before every commit.
```
pre-commit install
``` | 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. |
# switch parameters to discrete units
step_width = int(step_width * pattern_scale / terrain.horizontal_scale)
step_height = int(step_height * pattern_scale / terrain.vertical_scale)
num_steps = terrain.width // step_width
height = step_height
for i in range(num_steps):
terrain.height_fi... | can you remove those changes? They don't belong to this PR. | # switch parameters to discrete units
step_width = int(step_width / terrain.horizontal_scale)
step_height = int(step_height / terrain.vertical_scale)
num_steps = terrain.width // step_width
height = step_height
for i in range(num_steps):
terrain.height_field_raw[i * step_width : (i + 1)... | @@ -245,9 +245,9 @@ def pyramid_stairs_terrain(terrain, step_width, step_height, platform_size=1.0):
terrain (SubTerrain): update terrain
"""
# switch parameters to discrete units
- step_width = int(step_width / terrain.horizontal_scale)
- step_height = int(step_height / terrain.vertical_scale)... | genesis/ext/isaacgym/terrain_utils.py | 26 | Python | 0.286 | suggestion | 59 | 51 | 51 | false | [BUG FIX] Preserve external forces across sub-steps. | 1,290 | Genesis-Embodied-AI/Genesis | 26,702 | Python | YilingQiao | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/ext/isaacgym/terrain_utils.py
PR Title: [BUG FIX] Preserve external forces across sub-steps.
BEFORE CODE: # switch parameters to discrete units
step_width = int(step_width * pattern_scale / terrain.horizontal_scale)
step_height = int(step_h... | can you remove those changes? They don't belong to this PR. | 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._func_forward_dynamics()
@ti.kernel
def _kernel_update_acc(self):
self._func_update_acc(update_cacc=True)
# @@@@@@@@@ Composer starts here
# decomposed kernels should happen in the block below. This block will be handled by composer and composed into a single kernel
@ti.func
... | I don’t think you can change the substep dt like this, because it should also affects all the other solvers in case of hybrid simulation. | for i_b in range(self._B):
self._func_solve_mass_batched(vec, out, i_b)
@ti.kernel
def _kernel_forward_dynamics(self):
self._func_forward_dynamics()
@ti.kernel
def _kernel_update_acc(self):
self._func_update_acc(update_cacc=True)
# @@@@@@@@@ Composer starts her... | @@ -1690,9 +1690,18 @@ def _func_forward_dynamics(self):
# self._func_actuation()
self._func_bias_force()
self._func_compute_qacc()
- # FIXME: External forces should be cleared at the end of the step, not during substeps.
+
+ @ti.kernel
+ def clear_external_forces(self):
... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.429 | suggestion | 137 | 51 | 51 | false | [BUG FIX] Preserve external forces across sub-steps. | 1,290 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [BUG FIX] Preserve external forces across sub-steps.
BEFORE CODE: self._func_forward_dynamics()
@ti.kernel
def _kernel_update_acc(self):
self._func_update_acc(update_cacc=Tr... | I don’t think you can change the substep dt like this, because it should also affects all the other solvers in case of hybrid simulation. | 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._func_torque_and_passive_force()
self._func_update_acc(update_cacc=False)
self._func_update_force()
# self._func_actuation()
self._func_bias_force()
self._func_compute_qacc()
@ti.kernel
def _kernel_clear_external_force(self):
self._func_clear_externa... | why do you delete this function? | def _func_forward_dynamics(self):
self._func_compute_mass_matrix(
implicit_damping=ti.static(self._integrator == gs.integrator.approximate_implicitfast)
)
self._func_factor_mass(implicit_damping=False)
self._func_torque_and_passive_force()
self._func_update_acc(up... | @@ -1704,13 +1706,6 @@ def substep(self):
self._func_constraint_force()
timer.stamp("constraint_force")
- # Position, Velocity and Acceleration data must be consistent when computing links acceleration, otherwise it
- # would not corresponds to anyting physical. There is no other way t... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.071 | question | 32 | 51 | 51 | false | [BUG FIX] Preserve external forces across sub-steps. | 1,290 | Genesis-Embodied-AI/Genesis | 26,702 | Python | YilingQiao | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [BUG FIX] Preserve external forces across sub-steps.
BEFORE CODE: self._func_torque_and_passive_force()
self._func_update_acc(update_cacc=False)
self._func_update_force()
... | why do you delete this function? | 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. |
torque = gu.ti_transform_by_quat(torque, self.links_state[link_idx, env_idx].i_quat)
if ti.static(ref == 2 and local == 1): # link's origin
torque = gu.ti_transform_by_quat(torque, self.links_state[link_idx, env_idx].quat)
self.links_state[link_idx, env_idx].cfrc_applied_ang -=... | what does `local` mean? - oh, I see, whether the force is in the local coordinate | torque: ti.types.ndarray(),
links_idx: ti.types.ndarray(),
envs_idx: ti.types.ndarray(),
ref: ti.template(),
local: ti.template(),
):
ti.loop_config(serialize=self._para_level < gs.PARA_LEVEL.PARTIAL)
for i_l_, i_b_ in ti.ndrange(links_idx.shape[0], envs_idx.s... | @@ -2589,79 +2589,123 @@ def _func_wakeup_entity(self, i_e, i_b):
n_awake_links = ti.atomic_add(self.n_awake_links[i_b], 1)
self.awake_links[n_awake_links, i_b] = i_l
- def apply_links_external_force(self, force, links_idx=None, envs_idx=None, *, unsafe=False):
+ def apply_link... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.357 | question | 81 | 51 | 51 | false | [BUG FIX] Improve external force handling. | 1,292 | Genesis-Embodied-AI/Genesis | 26,702 | Python | YilingQiao | duburcqa | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [BUG FIX] Improve external force handling.
BEFORE CODE: torque = gu.ti_transform_by_quat(torque, self.links_state[link_idx, env_idx].i_quat)
if ti.static(ref == 2 and local == 1)... | what does `local` mean? - oh, I see, whether the force is in the local coordinate | 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 _kernel_detect_collision(self):
self.collider.clear()
self.collider.detection()
# @@@@@@@@@ Composer ends here
def detect_collision(self, env_idx=0):
# TODO: support batching
self._kernel_detect_collision()
n_collision = self.collider.n_contacts.to_numpy()[env_i... | This does not affect performance? | self._func_aggregate_awake_entities()
def _kernel_detect_collision(self):
self.collider.clear()
self.collider.detection()
# @@@@@@@@@ Composer ends here
def detect_collision(self, env_idx=0):
# TODO: support batching
self._kernel_detect_collision()
n_co... | @@ -1787,7 +1781,6 @@ def detect_collision(self, env_idx=0):
@ti.kernel
def _kernel_forward_kinematics_links_geoms(self, envs_idx: ti.types.ndarray()):
- ti.loop_config(serialize=self._para_level < gs.PARA_LEVEL.ALL) | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.214 | performance | 33 | 51 | 51 | false | [MISC] Reduce warning messages. | 1,294 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [MISC] Reduce warning messages.
BEFORE CODE: def _kernel_detect_collision(self):
self.collider.clear()
self.collider.detection()
# @@@@@@@@@ Composer ends here
def dete... | This does not affect performance? | 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. |
with pipes(stdout=stdout_buf, stderr=stderr_buf):
mj = mujoco.MjModel.from_xml_string(data) # C++ code runs here
stderr_text = stderr_buf.getvalue()
stdout_text = stdout_buf.getvalue()
if stderr_text:
gs.logger.debug(f"MuJoCo warnings: {st... | Just remove this piece of code | mj.eq_solref[:, 0] = MIN_TIMECONST
# Set default rotor armature inertia
if default_armature is not None:
mj.dof_armature[:] = default_armature
mj.body_invweight0[:] = 0.0
mj.dof_invweight0[:] = 0.0
elif isin... | @@ -151,9 +172,10 @@ def parse_xml(morph, surface):
# Build model from XML (either URDF or MJCF)
mj = build_model(morph.file, not morph.visualization, morph.default_armature, merge_fixed_links, links_to_keep)
- # Check if there is any tendon. Report a warning if so.
- if mj.ntendon:
- gs.logger... | genesis/utils/mjcf.py | 26 | Python | 0.143 | refactor | 30 | 51 | 51 | false | [MISC] Reduce warning messages. | 1,294 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/utils/mjcf.py
PR Title: [MISC] Reduce warning messages.
BEFORE CODE: with pipes(stdout=stdout_buf, stderr=stderr_buf):
mj = mujoco.MjModel.from_xml_string(data) # C++ code runs here
stderr_text = stderr_buf.getv... | Just remove this piece 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. |
import os
import xml.etree.ElementTree as ET
import contextlib
from pathlib import Path
from itertools import chain
from bisect import bisect_right
import io
import numpy as np
import trimesh
from trimesh.visual.texture import TextureVisuals
from PIL import Image
if os.name != "nt": # POSIX → keep current behaviour
... | You should have a cleaner uniform way of redirecting libc stdout / stderr. I suggest to move all the logic here along with what I already implemented for macOS at least, and use the same cross platform decorator everywhere | import os
import xml.etree.ElementTree as ET
import contextlib
from pathlib import Path
from itertools import chain
from bisect import bisect_right
import io
import numpy as np
import trimesh
from trimesh.visual.texture import TextureVisuals
from PIL import Image
import z3
import mujoco
import genesis as gs
from gene... | @@ -1,15 +1,25 @@
import os
import xml.etree.ElementTree as ET
-from contextlib import redirect_stderr
+import contextlib
from pathlib import Path
from itertools import chain
from bisect import bisect_right
+import io
import numpy as np
import trimesh
from trimesh.visual.texture import TextureVisuals
from PI... | genesis/utils/mjcf.py | 14 | Python | 0.5 | suggestion | 222 | 39 | 39 | false | [MISC] Reduce warning messages. | 1,294 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/utils/mjcf.py
PR Title: [MISC] Reduce warning messages.
BEFORE CODE: import os
import xml.etree.ElementTree as ET
import contextlib
from pathlib import Path
from itertools import chain
from bisect import bisect_right
import io
import numpy as np
impor... | You should have a cleaner uniform way of redirecting libc stdout / stderr. I suggest to move all the logic here along with what I already implemented for macOS at least, and use the same cross platform decorator everywhere | 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 os
import xml.etree.ElementTree as ET
import contextlib
from pathlib import Path
from itertools import chain
from bisect import bisect_right
import io
import numpy as np
import trimesh
from trimesh.visual.texture import TextureVisuals
from PIL import Image
if os.name != "nt": # POSIX → keep current behaviour
... | Is it possible to avoid one extra dependency just for this ? Already written my own redirect for macOS, not so much work. | import os
import xml.etree.ElementTree as ET
import contextlib
from pathlib import Path
from itertools import chain
from bisect import bisect_right
import io
import numpy as np
import trimesh
from trimesh.visual.texture import TextureVisuals
from PIL import Image
import z3
import mujoco
import genesis as gs
from gene... | @@ -1,15 +1,25 @@
import os
import xml.etree.ElementTree as ET
-from contextlib import redirect_stderr
+import contextlib
from pathlib import Path
from itertools import chain
from bisect import bisect_right
+import io
import numpy as np
import trimesh
from trimesh.visual.texture import TextureVisuals
from PI... | genesis/utils/mjcf.py | 15 | Python | 0.429 | suggestion | 121 | 40 | 40 | false | [MISC] Reduce warning messages. | 1,294 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | YilingQiao | Review this pull request change.
Language: Python
File: genesis/utils/mjcf.py
PR Title: [MISC] Reduce warning messages.
BEFORE CODE: import os
import xml.etree.ElementTree as ET
import contextlib
from pathlib import Path
from itertools import chain
from bisect import bisect_right
import io
import numpy as np
impor... | Is it possible to avoid one extra dependency just for this ? Already written my own redirect for macOS, not so much work. | 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 deformation gradient matrix.
actu: ti.Matrix
The activation matrix (not used in linear elasticity).
m_dir: ti.Matrix
The material direction (not used in linear elasticity).
hessian_field: ti.Matrix
The Hessian of the energy with respect to the ... | You should rather just subtract 1.0 from the diagonal terms:
```python
for i in ti.static(range(3)):
eps[i] = eps[I] - 1.0
``` | The deformation gradient matrix.
actu: ti.Matrix
The activation matrix (not used in linear elasticity).
m_dir: ti.Matrix
The material direction (not used in linear elasticity).
hessian_field: ti.Matrix
The Hessian of the energy with respect to the ... | @@ -354,6 +376,147 @@ def compute_energy_stable_neohookean(self, mu, lam, J, F, actu, m_dir):
return energy
+ @ti.func
+ def compute_energy_gradient_hessian_linear_corotated(self, mu, lam, J, F, actu, m_dir, i_e, i_b, hessian_field):
+ """
+ Compute the energy, gradient, and Hessian for... | genesis/engine/materials/FEM/elastic.py | 26 | Python | 0.786 | suggestion | 134 | 51 | 51 | false | [FEATURE] Add linear_corotated elastic material for fem | 1,304 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Libero0809 | Review this pull request change.
Language: Python
File: genesis/engine/materials/FEM/elastic.py
PR Title: [FEATURE] Add linear_corotated elastic material for fem
BEFORE CODE: The deformation gradient matrix.
actu: ti.Matrix
The activation matrix (not used in linear elasticity).
... | You should rather just subtract 1.0 from the diagonal terms:
```python
for i in ti.static(range(3)):
eps[i] = eps[I] - 1.0
``` | 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. |
# given the immediate previous function call is compute_internal_vel --> however, shouldn't
# be done at dv only and need to wait for all elements updated (cannot be in the compute_internal_vel kernel)
# however, this inevitably damp the gravity.
self.el... | `self._mats[mat_idx].pre_compute(J=J, F=F, i_e=i_e, i_b=i_b)` | # given the immediate previous function call is compute_internal_vel --> however, shouldn't
# be done at dv only and need to wait for all elements updated (cannot be in the compute_internal_vel kernel)
# however, this inevitably damp the gravity.
self.el... | @@ -396,6 +399,23 @@ def compute_pos(self, f: ti.i32):
dt * self.elements_v[f + 1, i_v, i_b].vel + self.elements_v[f, i_v, i_b].pos
)
+ @ti.kernel
+ def precompute_material_data(self, f: ti.i32):
+ for i_b, i_e in ti.ndrange(self._B, self.n_elements):
+ if not sel... | genesis/engine/solvers/fem_solver.py | 26 | Python | 0.357 | suggestion | 61 | 51 | 51 | false | [FEATURE] Add linear_corotated elastic material for fem | 1,304 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Libero0809 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/fem_solver.py
PR Title: [FEATURE] Add linear_corotated elastic material for fem
BEFORE CODE: # given the immediate previous function call is compute_internal_vel --> however, shouldn't
# be done at dv ... | `self._mats[mat_idx].pre_compute(J=J, F=F, i_e=i_e, i_b=i_b)` | 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. |
Compute the energy for each element in the batch. Should only be used in linesearch.
"""
for i_b, i_e in ti.ndrange(self._B, self.n_elements):
if not self.batch_linesearch_active[i_b]:
continue
J, F = self._compute_ele_J_F(f + 1, i_e, i_b)
fo... | Why `ti.Matrix.zero` instead of `ti.Vector.zero` like everywhere else? |
J, F = self._compute_ele_J_F(f + 1, i_e, i_b)
for mat_idx in ti.static(self._mats_idx):
if self.elements_i[i_e].mat_idx == mat_idx:
self.elements_el_energy[i_b, i_e].energy = self._mats[mat_idx].compute_energy(
mu=self.elements_i[i_e]... | @@ -483,8 +503,36 @@ def _func_compute_ele_energy(self, f: ti.i32):
F=F,
actu=self.elements_el[f, i_e, i_b].actu,
m_dir=self.elements_i[i_e].muscle_direction,
+ i_e=i_e,
+ i_b=i_b,
+ ... | genesis/engine/solvers/fem_solver.py | 26 | Python | 0.429 | question | 70 | 51 | 51 | false | [FEATURE] Add linear_corotated elastic material for fem | 1,304 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Libero0809 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/fem_solver.py
PR Title: [FEATURE] Add linear_corotated elastic material for fem
BEFORE CODE: Compute the energy for each element in the batch. Should only be used in linesearch.
"""
for i_b, i_e in ti.ndrange(self... | Why `ti.Matrix.zero` instead of `ti.Vector.zero` like everywhere else? | 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. |
material=fem_material_linear,
)
# Build the scene
scene.build()
# Run simulation
for _ in range(200):
scene.step()
for entity in scene.entities:
state = entity.get_state()
pos = state.pos.detach().cpu().numpy()
min_pos_z = np.min(pos[..., 2])
as... | Why forcing GPU? Why not marking this test as required? | ),
material=fem_material_linear,
)
# Build the scene
scene.build()
# Run simulation
for _ in range(200):
scene.step()
for entity in scene.entities:
state = entity.get_state()
pos = state.pos.detach().cpu().numpy()
min_pos_z = np.min(pos[..., 2])... | @@ -287,3 +287,49 @@ def test_sphere_fall_implicit_fem_sap_coupler(fem_material_linear, show_viewer):
assert_allclose(
min_pos_z, 0.0, atol=1e-3
), f"Entity {entity.uid} minimum Z position {min_pos_z} is not close to 0.0."
+
+
+@pytest.fixture(scope="session")
+def fem_material_linear_cor... | tests/test_fem.py | 26 | Python | 0.214 | question | 55 | 51 | 51 | false | [FEATURE] Add linear_corotated elastic material for fem | 1,304 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Libero0809 | Review this pull request change.
Language: Python
File: tests/test_fem.py
PR Title: [FEATURE] Add linear_corotated elastic material for fem
BEFORE CODE: material=fem_material_linear,
)
# Build the scene
scene.build()
# Run simulation
for _ in range(200):
scene.step()
for e... | Why forcing GPU? Why not marking this test as required? | 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. |
),
coupler_options=gs.options.SAPCouplerOptions(),
show_viewer=show_viewer,
show_FPS=False,
)
scene.add_entity(
morph=gs.morphs.Sphere(
pos=(0.5, -0.2, 1.0),
radius=0.1,
),
material=fem_material_linear_corotated,
)
# Build... | This assert is not sufficient. You should detect artifacts and check that the sphere does not get too much distorted. | ),
coupler_options=gs.options.SAPCouplerOptions(),
show_viewer=show_viewer,
show_FPS=False,
)
scene.add_entity(
morph=gs.morphs.Sphere(
pos=(0.5, -0.2, 0.5),
radius=0.1,
),
material=fem_material_linear_corotated,
)
# Build... | @@ -287,3 +287,49 @@ def test_sphere_fall_implicit_fem_sap_coupler(fem_material_linear, show_viewer):
assert_allclose(
min_pos_z, 0.0, atol=1e-3
), f"Entity {entity.uid} minimum Z position {min_pos_z} is not close to 0.0."
+
+
+@pytest.fixture(scope="session")
+def fem_material_linear_cor... | tests/test_fem.py | 26 | Python | 0.429 | suggestion | 117 | 29 | 37 | false | [FEATURE] Add linear_corotated elastic material for fem | 1,304 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Libero0809 | Review this pull request change.
Language: Python
File: tests/test_fem.py
PR Title: [FEATURE] Add linear_corotated elastic material for fem
BEFORE CODE: ),
coupler_options=gs.options.SAPCouplerOptions(),
show_viewer=show_viewer,
show_FPS=False,
)
scene.add_entity(
mo... | This assert is not sufficient. You should detect artifacts and check that the sphere does not get too much distorted. | 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. |
morton_code_z = self.expand_bits(morton_code_z)
morton_code = (morton_code_x << 2) | (morton_code_y << 1) | (morton_code_z)
self.morton_codes[i_b, i_a] = (ti.u64(morton_code) << 32) | ti.u64(i_a)
@ti.func
def expand_bits(self, v):
"""
Expands a 10-bit integer... | I guess `self.hist.fill(0)` should do the trick? | morton_code_z = ti.floor(scaled_center[2] * 1023.0, dtype=ti.u32)
morton_code_x = self.expand_bits(morton_code_x)
morton_code_y = self.expand_bits(morton_code_y)
morton_code_z = self.expand_bits(morton_code_z)
morton_code = (morton_code_x << 2) | (morton_code_... | @@ -223,38 +224,44 @@ def expand_bits(self, v):
v = (v * ti.u32(0x00000005)) & ti.u32(0x49249249)
return v
- @ti.func
def radix_sort_morton_codes(self):
"""
Radix sort the morton codes, using 8 bits at a time.
"""
- for i in ti.static(range(8)):
- ... | genesis/engine/bvh.py | 26 | Python | 0.286 | question | 48 | 51 | 51 | false | [BUG FIX] Fix BVH build's radix sort. | 1,305 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Libero0809 | Review this pull request change.
Language: Python
File: genesis/engine/bvh.py
PR Title: [BUG FIX] Fix BVH build's radix sort.
BEFORE CODE: morton_code_z = self.expand_bits(morton_code_z)
morton_code = (morton_code_x << 2) | (morton_code_y << 1) | (morton_code_z)
self.morton_code... | I guess `self.hist.fill(0)` should do the trick? | 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. |
distance = ti.Vector([0.0, 0.0, 0.0, 0.0])
for i in ti.static(range(4)):
i_v = fem_solver.elements_i[i_e].el2v[i]
pos_v = fem_solver.elements_v[f + 1, i_v, i_b].pos
distance[i] = pos_v.z - fem_solver.floor_height
if distance[i] > 0:... | This is a weird syntax. Is static really necessary here? |
for i_c in range(self.n_fem_floor_contact_pairs[None]):
if pairs[i_c].active == 0:
continue
i_b = pairs[i_c].batch_idx
i_e = pairs[i_c].geom_idx
W = ti.Matrix.zero(gs.ti_float, 3, 3)
# W = sum (JA^-1J^T)
# With floor, J is ... | @@ -952,6 +976,102 @@ def fem_floor_detection(self, f: ti.i32):
self.fem_floor_contact_pairs[i_c].fn0 = rigid_fn0
self.fem_floor_contact_pairs[i_c].taud = self.sim._substep_dt * 1.0 / ti.math.pi
+ @ti.kernel
+ def fem_self_detection(self, f: ti.i32):
+ fem_solver = self.fem_solv... | genesis/engine/coupler.py | 26 | Python | 0.214 | question | 56 | 51 | 51 | false | [BUG FIX] Fix BVH build's radix sort. | 1,305 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Libero0809 | Review this pull request change.
Language: Python
File: genesis/engine/coupler.py
PR Title: [BUG FIX] Fix BVH build's radix sort.
BEFORE CODE: distance = ti.Vector([0.0, 0.0, 0.0, 0.0])
for i in ti.static(range(4)):
i_v = fem_solver.elements_i[i_e].el2v[i]
po... | This is a weird syntax. Is static really 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. |
t = d_v0 / (d_v0 - d_v1)
polygon_vertices[:, i] = pos_v0 + t * (pos_v1 - pos_v0)
# Compute tirangle area and centroid
if i >= 2:
e1 = polygon_vertices[:, i - 1] - polygon_vertices[:, 0]
e2 = ... | What is this? Create a global constant on top of this file with a proper name. | # No need to do this for iter=0 because v=v* and A(v-v*) = 0
if iter > 0:
for i_b, i_v in ti.ndrange(fem_solver._B, fem_solver.n_vertices):
self.gradient[i_b, i_v] = (
fem_solver.elements_v_info[i_v].mass_over_dt2 * self.v_diff[i_b, i_v] * dt2 * damping_al... | @@ -952,6 +976,102 @@ def fem_floor_detection(self, f: ti.i32):
self.fem_floor_contact_pairs[i_c].fn0 = rigid_fn0
self.fem_floor_contact_pairs[i_c].taud = self.sim._substep_dt * 1.0 / ti.math.pi
+ @ti.kernel
+ def fem_self_detection(self, f: ti.i32):
+ fem_solver = self.fem_solv... | genesis/engine/coupler.py | 26 | Python | 0.214 | question | 78 | 51 | 51 | false | [BUG FIX] Fix BVH build's radix sort. | 1,305 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Libero0809 | Review this pull request change.
Language: Python
File: genesis/engine/coupler.py
PR Title: [BUG FIX] Fix BVH build's radix sort.
BEFORE CODE: t = d_v0 / (d_v0 - d_v1)
polygon_vertices[:, i] = pos_v0 + t * (pos_v1 - pos_v0)
# Compute tirangle area and ce... | What is this? Create a global constant on top of this file with a proper name. | 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. |
area = 0.5 * e1.cross(e2).norm()
total_area += area
total_area_weighted_centroid += (
area * (polygon_vertices[:, 0] + polygon_vertices[:, i - 1] + polygon_vertices[:, i]) / 3.0
)
cen... | `rigid_g < gs.EPS` would work just fine if you do `g = deformable_g * rigid_g * ti.rsqrt(deformable_g + rigid_g)` Anyway, it would be more robust numerically and faster to compute (even if it is not really a concern here...). | for i_b, i_e in ti.ndrange(fem_solver._B, fem_solver.n_elements):
V_dt2 = fem_solver.elements_i[i_e].V * dt2
B = fem_solver.elements_i[i_e].B
s = -B[0, :] - B[1, :] - B[2, :] # s is the negative sum of B rows
p9 = ti.Vector([0.0] * 9, dt=gs.ti... | @@ -952,6 +976,102 @@ def fem_floor_detection(self, f: ti.i32):
self.fem_floor_contact_pairs[i_c].fn0 = rigid_fn0
self.fem_floor_contact_pairs[i_c].taud = self.sim._substep_dt * 1.0 / ti.math.pi
+ @ti.kernel
+ def fem_self_detection(self, f: ti.i32):
+ fem_solver = self.fem_solv... | genesis/engine/coupler.py | 26 | Python | 0.571 | suggestion | 225 | 51 | 51 | false | [BUG FIX] Fix BVH build's radix sort. | 1,305 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Libero0809 | Review this pull request change.
Language: Python
File: genesis/engine/coupler.py
PR Title: [BUG FIX] Fix BVH build's radix sort.
BEFORE CODE: area = 0.5 * e1.cross(e2).norm()
total_area += area
total_area_weighted_centroid += (
... | `rigid_g < gs.EPS` would work just fine if you do `g = deformable_g * rigid_g * ti.rsqrt(deformable_g + rigid_g)` Anyway, it would be more robust numerically and faster to compute (even if it is not really a concern 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. |
distance = pair.distance
intersected_edges = ti.static(self.kMarchingTetsEdgeTable)[intersection_code]
tet_vertices = ti.Matrix.zero(gs.ti_float, 3, 4) # 4 vertices
tet_pressures = ti.Vector.zero(gs.ti_float, 4) # pressures at the vertices
for i in ti.stati... | `rigid_g < gs.EPS` should not be an issue mathematically at least (see following comment). |
# Compute tirangle area and centroid
if i >= 2:
e1 = polygon_vertices[:, i - 1] - polygon_vertices[:, 0]
e2 = polygon_vertices[:, i] - polygon_vertices[:, 0]
area = 0.5 * e1.cross(e2).norm()
... | @@ -952,6 +976,102 @@ def fem_floor_detection(self, f: ti.i32):
self.fem_floor_contact_pairs[i_c].fn0 = rigid_fn0
self.fem_floor_contact_pairs[i_c].taud = self.sim._substep_dt * 1.0 / ti.math.pi
+ @ti.kernel
+ def fem_self_detection(self, f: ti.i32):
+ fem_solver = self.fem_solv... | genesis/engine/coupler.py | 26 | Python | 0.429 | suggestion | 90 | 51 | 51 | false | [BUG FIX] Fix BVH build's radix sort. | 1,305 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Libero0809 | Review this pull request change.
Language: Python
File: genesis/engine/coupler.py
PR Title: [BUG FIX] Fix BVH build's radix sort.
BEFORE CODE: distance = pair.distance
intersected_edges = ti.static(self.kMarchingTetsEdgeTable)[intersection_code]
tet_vertices = ti.Matrix.zero(gs.... | `rigid_g < gs.EPS` should not be an issue mathematically at least (see following comment). | 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.compute_energy_gradient_hessian = self.compute_energy_gradient_hessian_stable_neohookean
self.compute_energy_gradient = self.compute_energy_gradient_stable_neohookean
self.compute_energy = self.compute_energy_stable_neohookean
self.hessian_invariant = False
... | Add comment for clarity:
```python
# Computing Polar Decomposition instead of calling `R, P = ti.polar_decompose(F)` since `P` is not needed here
``` | self.compute_energy_gradient_hessian = self.compute_energy_gradient_hessian_stable_neohookean
self.compute_energy_gradient = self.compute_energy_gradient_stable_neohookean
self.compute_energy = self.compute_energy_stable_neohookean
self.hessian_invariant = False
... | @@ -63,11 +64,28 @@ def __init__(
self.hessian_invariant = False
if model == "stable_neohooken":
gs.logger.warning("The 'stable_neohooken' model is deprecated. Use 'stable_neohookean' instead.")
+ elif model == "linear_corotated":
+ self.build = self.build_li... | genesis/engine/materials/FEM/elastic.py | 26 | Python | 0.786 | refactor | 152 | 51 | 51 | false | [BUG FIX] Fix BVH build's radix sort. | 1,305 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Libero0809 | Review this pull request change.
Language: Python
File: genesis/engine/materials/FEM/elastic.py
PR Title: [BUG FIX] Fix BVH build's radix sort.
BEFORE CODE: self.compute_energy_gradient_hessian = self.compute_energy_gradient_hessian_stable_neohookean
self.compute_energy_gradient = self.comp... | Add comment for clarity:
```python
# Computing Polar Decomposition instead of calling `R, P = ti.polar_decompose(F)` since `P` is not needed 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. |
t = d_v0 / (d_v0 - d_v1)
polygon_vertices[:, i] = pos_v0 + t * (pos_v1 - pos_v0)
# Compute tirangle area and centroid
if i >= 2:
e1 = polygon_vertices[:, i - 1] - polygon_vertices[:, 0]
e2 = ... | Removing `C` does not change the fact that `1.0e8` should rather be a global constant defined on top of the file x) | d_v1 = distance[edge[1]]
t = d_v0 / (d_v0 - d_v1)
polygon_vertices[:, i] = pos_v0 + t * (pos_v1 - pos_v0)
# Compute tirangle area and centroid
if i >= 2:
e1 = polygon_vertices[:, i - 1] - polygon... | @@ -934,15 +935,13 @@ def fem_floor_detection(self, f: ti.i32):
)
self.fem_floor_contact_pairs[i_c].barycentric = barycentric
- C = ti.static(1.0e8)
- deformable_g = C
+ deformable_g = ti.static(1.0e8) | genesis/engine/coupler.py | 26 | Python | 0.571 | suggestion | 115 | 51 | 51 | false | [BUG FIX] Fix BVH build's radix sort. | 1,305 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Libero0809 | Review this pull request change.
Language: Python
File: genesis/engine/coupler.py
PR Title: [BUG FIX] Fix BVH build's radix sort.
BEFORE CODE: t = d_v0 / (d_v0 - d_v1)
polygon_vertices[:, i] = pos_v0 + t * (pos_v1 - pos_v0)
# Compute tirangle area and ce... | Removing `C` does not change the fact that `1.0e8` should rather be a global constant defined on top of the file x) | 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. |
result = -1
if j >= 0 and j < self.n_aabbs:
result = 64
x = self.morton_codes[i_b, ti.i32(i)] ^ self.morton_codes[i_b, ti.i32(j)]
for b in range(64):
if x & (ti.u64(1) << (63 - b)):
result = b
break
retur... | `= 0` should be fine, the compiler will do the job, since the variable is already allocated with the right type. | result = -1
if j >= 0 and j < self.n_aabbs:
result = 64
x = self.morton_codes[i_b, ti.i32(i)] ^ self.morton_codes[i_b, ti.i32(j)]
for b in range(64):
if x & (ti.u64(1) << (63 - b)):
result = b
break
retur... | @@ -321,31 +330,53 @@ def delta(self, i, j, i_b):
break
return result
- @ti.func
def compute_bounds(self):
"""
Compute the bounds of the BVH nodes.
- Starts from the leaf nodes and works upwards.
+ Starts from the leaf nodes and works upwards lay... | genesis/engine/bvh.py | 26 | Python | 0.714 | suggestion | 112 | 51 | 51 | false | [BUG FIX] Fix BVH build's radix sort. | 1,305 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Libero0809 | Review this pull request change.
Language: Python
File: genesis/engine/bvh.py
PR Title: [BUG FIX] Fix BVH build's radix sort.
BEFORE CODE: result = -1
if j >= 0 and j < self.n_aabbs:
result = 64
x = self.morton_codes[i_b, ti.i32(i)] ^ self.morton_codes[i_b, ti.i32(j)]
... | `= 0` should be fine, the compiler will do the job, since the variable is already allocated with the right 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. |
t = d_v0 / (d_v0 - d_v1)
polygon_vertices[:, i] = pos_v0 + t * (pos_v1 - pos_v0)
# Compute tirangle area and centroid
if i >= 2:
e1 = polygon_vertices[:, i - 1] - polygon_vertices[:, 0]
e2 = ... | I do not recommend using `ti.static` here, because changing the value would trigger recompilation, which is not undesirable. Moreover, the benefits for making it static is basically zero here. | t = d_v0 / (d_v0 - d_v1)
polygon_vertices[:, i] = pos_v0 + t * (pos_v1 - pos_v0)
# Compute tirangle area and centroid
if i >= 2:
e1 = polygon_vertices[:, i - 1] - polygon_vertices[:, 0]
e2 = ... | @@ -934,15 +936,13 @@ def fem_floor_detection(self, f: ti.i32):
)
self.fem_floor_contact_pairs[i_c].barycentric = barycentric
- C = ti.static(1.0e8)
- deformable_g = C
+ deformable_g = ti.static(self.default_deformable_g) | genesis/engine/coupler.py | 26 | Python | 0.571 | suggestion | 192 | 51 | 51 | false | [BUG FIX] Fix BVH build's radix sort. | 1,305 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Libero0809 | Review this pull request change.
Language: Python
File: genesis/engine/coupler.py
PR Title: [BUG FIX] Fix BVH build's radix sort.
BEFORE CODE: t = d_v0 / (d_v0 - d_v1)
polygon_vertices[:, i] = pos_v0 + t * (pos_v1 - pos_v0)
# Compute tirangle area and ce... | I do not recommend using `ti.static` here, because changing the value would trigger recompilation, which is not undesirable. Moreover, the benefits for making it static is basically zero 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. |
"""
Build the BVH from the axis-aligned bounding boxes (AABBs).
"""
self.compute_aabb_centers_and_scales()
self.compute_morton_codes()
self.radix_sort_morton_codes()
self.build_radix_tree()
self.compute_bounds()
@ti.kernel
def compute_aabb_centers... | I would recommend this instead: `self.scale[i_b][i] = ti.select(scale[i] > gs.EPS, 1.0 / scale[i], 1.0)` | """
Build the BVH from the axis-aligned bounding boxes (AABBs).
"""
self.compute_aabb_centers_and_scales()
self.compute_morton_codes()
self.radix_sort_morton_codes()
self.build_radix_tree()
self.compute_bounds()
@ti.kernel
def compute_aabb_centers... | @@ -186,12 +195,7 @@ def build(self):
for i in ti.static(range(3)):
self.scale[i_b][i] = ti.select(scale[i] > 1e-7, 1.0 / scale[i], 1) | genesis/engine/bvh.py | 26 | Python | 0.571 | suggestion | 104 | 51 | 51 | false | [BUG FIX] Fix BVH build's radix sort. | 1,305 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Libero0809 | Review this pull request change.
Language: Python
File: genesis/engine/bvh.py
PR Title: [BUG FIX] Fix BVH build's radix sort.
BEFORE CODE: """
Build the BVH from the axis-aligned bounding boxes (AABBs).
"""
self.compute_aabb_centers_and_scales()
self.compute_morton_codes()
... | I would recommend this instead: `self.scale[i_b][i] = ti.select(scale[i] > gs.EPS, 1.0 / scale[i], 1.0)` | 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. |
"""
Radix sort the morton codes, using 8 bits at a time.
"""
for i in ti.static(range(8)):
# Clear histogram
for i_b, j in ti.ndrange(self.n_batches, 256):
self.hist[i_b, j] = 0
# Fill histogram
for i_b, i_a in ti.ndrange(s... | Though it has been merged, just to mention there is a built-in parallel prefix sum, which might be useful: https://github.com/taichi-dev/taichi/blob/master/python/taichi/algorithms/_algorithms.py#L42 | return v
def radix_sort_morton_codes(self):
"""
Radix sort the morton codes, using 8 bits at a time.
"""
for i in range(8):
self._kernel_radix_sort_morton_codes_one_round(i)
@ti.kernel
def _kernel_radix_sort_morton_codes_one_round(self, i: int):
... | @@ -223,38 +227,43 @@ def expand_bits(self, v):
v = (v * ti.u32(0x00000005)) & ti.u32(0x49249249)
return v
- @ti.func
def radix_sort_morton_codes(self):
"""
Radix sort the morton codes, using 8 bits at a time.
"""
- for i in ti.static(range(8)):
- ... | genesis/engine/bvh.py | 26 | Python | 0.429 | suggestion | 199 | 51 | 51 | false | [BUG FIX] Fix BVH build's radix sort. | 1,305 | Genesis-Embodied-AI/Genesis | 26,702 | Python | erizmr | Libero0809 | Review this pull request change.
Language: Python
File: genesis/engine/bvh.py
PR Title: [BUG FIX] Fix BVH build's radix sort.
BEFORE CODE: """
Radix sort the morton codes, using 8 bits at a time.
"""
for i in ti.static(range(8)):
# Clear histogram
for i_b, j ... | Though it has been merged, just to mention there is a built-in parallel prefix sum, which might be useful: https://github.com/taichi-dev/taichi/blob/master/python/taichi/algorithms/_algorithms.py#L42 | 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.