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
floor_height : float, optional Height of the floor in meters. If none, it will inherit from `SimOptions`. Defaults to None. use_implicit_solver : bool, optional Whether to use the implicit solver. Defaults to False. Implicit solver is a more stable solver for FEM. It can be used with a l...
Skile space before note. Ideally notes should be moved before parameters.
Parameters ---------- dt : float, optional Time duration for each simulation step in seconds. If none, it will inherit from `SimOptions`. Defaults to None. gravity : tuple, optional Gravity force in N/kg. If none, it will inherit from `SimOptions`. Defaults to None. damping : float, ...
@@ -612,7 +612,8 @@ class FEMOptions(Options): Rayleigh Damping factor for the implicit solver. Defaults to 0.5. Only used when `use_implicit_solver` is True. damping_beta : float, optional Rayleigh Damping factor for the implicit solver. Defaults to 5e-4. Only used when `use_implicit_solver` is ...
genesis/options/solvers.py
26
Python
0.286
suggestion
73
51
51
false
[FEATURE] Add Fem fixed constraint for implicit solver
1,562
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Libero0809
Review this pull request change. Language: Python File: genesis/options/solvers.py PR Title: [FEATURE] Add Fem fixed constraint for implicit solver BEFORE CODE: floor_height : float, optional Height of the floor in meters. If none, it will inherit from `SimOptions`. Defaults to None. use_implicit_so...
Skile space before note. Ideally notes should be moved before parameters.
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.array([0.0, 0.0, 0.2], dtype=np.float32), atol=0.2, err_msg=f"Sphere center {center} moves too far from [0.0, 0.0, 0.2].", ) link_verts = link.get_verts() center = link_verts.mean(axis=0) min_pos_z = link_verts[..., 2].min() assert_allclose( min_pos_z, -1....
Only break line when reaching 120 chars line width limit.
np.array([0.0, 0.0, 0.2], dtype=np.float32), atol=0.2, err_msg=f"Sphere center {center} moves too far from [0.0, 0.0, 0.2].", ) link_verts = link.get_verts() center = link_verts.mean(axis=0) min_pos_z = link_verts[..., 2].min() assert_allclose( min_pos_z, -1....
@@ -582,3 +582,139 @@ def test_fem_articulated(fem_material_linear_corotated_soft, show_viewer): atol=0.2, err_msg=f"Link center {center} moves too far from [-0.5, -0.5, 0.04].", ) + + +def test_implicit_hard_vertex_constraint(fem_material_linear_corotated, show_viewer): + """ + Test if a b...
tests/test_fem.py
26
Python
0.214
suggestion
57
51
51
false
[FEATURE] Add Fem fixed constraint for implicit solver
1,562
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 Fem fixed constraint for implicit solver BEFORE CODE: np.array([0.0, 0.0, 0.2], dtype=np.float32), atol=0.2, err_msg=f"Sphere center {center} moves too far from [0.0, 0.0, 0.2].", ) lin...
Only break line when reaching 120 chars line width limit.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
if show_viewer: sphere = scene.draw_debug_spheres(poss=initial_target_poss, radius=0.02, color=(1, 0, 1, 0.8)) cube.set_vertex_constraints(verts_idx=verts_idx, target_poss=initial_target_poss) for _ in range(100): scene.step() positions = cube.get_state().pos[0][verts_idx] assert...
Using `gs.EPS` as tolerance. We do not have stricter requirement.
if show_viewer: sphere = scene.draw_debug_spheres(poss=initial_target_poss, radius=0.02, color=(1, 0, 1, 0.8)) cube.set_vertex_constraints(verts_idx=verts_idx, target_poss=initial_target_poss) for _ in range(100): scene.step() positions = cube.get_state().pos[0][verts_idx] assert...
@@ -582,3 +582,139 @@ def test_fem_articulated(fem_material_linear_corotated_soft, show_viewer): atol=0.2, err_msg=f"Link center {center} moves too far from [-0.5, -0.5, 0.04].", ) + + +def test_implicit_hard_vertex_constraint(fem_material_linear_corotated, show_viewer): + """ + Test if a b...
tests/test_fem.py
26
Python
0.357
suggestion
65
51
51
false
[FEATURE] Add Fem fixed constraint for implicit solver
1,562
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 Fem fixed constraint for implicit solver BEFORE CODE: if show_viewer: sphere = scene.draw_debug_spheres(poss=initial_target_poss, radius=0.02, color=(1, 0, 1, 0.8)) cube.set_vertex_constraints(verts_i...
Using `gs.EPS` as tolerance. We do not have stricter requirement.
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.
file=f"{asset_path}/meshes/cube8.obj", scale=0.1, pos=np.array([0.0, 0.0, 0.6], dtype=np.float32), ), material=fem_material_linear_corotated, ) verts_idx = [0] initial_target_poss = cube.init_positions[verts_idx] scene.build() if show_viewer: ...
`gs.tensor` instead of `torch.tensor`?
file=f"{asset_path}/meshes/cube8.obj", scale=0.1, pos=np.array([0.0, 0.0, 0.6], dtype=np.float32), ), material=fem_material_linear_corotated, ) verts_idx = [0] initial_target_poss = cube.init_positions[verts_idx] scene.build() if show_viewer: ...
@@ -582,3 +582,139 @@ def test_fem_articulated(fem_material_linear_corotated_soft, show_viewer): atol=0.2, err_msg=f"Link center {center} moves too far from [-0.5, -0.5, 0.04].", ) + + +def test_implicit_hard_vertex_constraint(fem_material_linear_corotated, show_viewer): + """ + Test if a b...
tests/test_fem.py
26
Python
0.286
question
38
51
51
false
[FEATURE] Add Fem fixed constraint for implicit solver
1,562
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 Fem fixed constraint for implicit solver BEFORE CODE: file=f"{asset_path}/meshes/cube8.obj", scale=0.1, pos=np.array([0.0, 0.0, 0.6], dtype=np.float32), ), material=f...
`gs.tensor` instead of `torch.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.
pos=(0.0, 0.0, 0.1), radius=0.1, ), material=fem_material_linear_corotated, ) scene.build() # return if show_viewer: sphere_debug = scene.draw_debug_spheres(poss=initial_target_poss, radius=0.02, color=(1, 0, 1, 0.8)) cube.set_vertex_constraints(vert...
Nothing to check of `x` and `y`? and/or the final velocity?
asset_path = get_hf_dataset(pattern="meshes/cube8.obj") cube = scene.add_entity( morph=gs.morphs.Mesh( file=f"{asset_path}/meshes/cube8.obj", scale=0.1, pos=np.array([0.0, 0.0, 0.35], dtype=np.float32), ), material=fem_material_linear_corotated, ) ...
@@ -582,3 +582,139 @@ def test_fem_articulated(fem_material_linear_corotated_soft, show_viewer): atol=0.2, err_msg=f"Link center {center} moves too far from [-0.5, -0.5, 0.04].", ) + + +def test_implicit_hard_vertex_constraint(fem_material_linear_corotated, show_viewer): + """ + Test if a b...
tests/test_fem.py
26
Python
0.357
question
59
27
51
false
[FEATURE] Add Fem fixed constraint for implicit solver
1,562
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 Fem fixed constraint for implicit solver BEFORE CODE: pos=(0.0, 0.0, 0.1), radius=0.1, ), material=fem_material_linear_corotated, ) scene.build() # return if sho...
Nothing to check of `x` and `y`? and/or the final velocity?
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.
new_target_poss = initial_target_poss + gs.tensor( [[0.1, 0.1, 0.1]], ) cube.update_constraint_targets(verts_idx=verts_idx, target_poss=new_target_poss) if show_viewer: scene.clear_debug_object(sphere) sphere = scene.draw_debug_spheres(poss=new_target_poss, radius=0.02, color=(1,...
Nothing to check for `x` and `y`? and/or the final velocity?
new_target_poss = initial_target_poss + gs.tensor( [[0.1, 0.1, 0.1]], ) cube.update_constraint_targets(verts_idx=verts_idx, target_poss=new_target_poss) if show_viewer: scene.clear_debug_object(sphere) sphere = scene.draw_debug_spheres(poss=new_target_poss, radius=0.02, color=(1,...
@@ -582,3 +582,139 @@ def test_fem_articulated(fem_material_linear_corotated_soft, show_viewer): atol=0.2, err_msg=f"Link center {center} moves too far from [-0.5, -0.5, 0.04].", ) + + +def test_implicit_hard_vertex_constraint(fem_material_linear_corotated, show_viewer): + """ + Test if a b...
tests/test_fem.py
26
Python
0.357
question
60
51
51
false
[FEATURE] Add Fem fixed constraint for implicit solver
1,562
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 Fem fixed constraint for implicit solver BEFORE CODE: new_target_poss = initial_target_poss + gs.tensor( [[0.1, 0.1, 0.1]], ) cube.update_constraint_targets(verts_idx=verts_idx, target_poss=new_targ...
Nothing to check for `x` and `y`? and/or the final velocity?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
from typing import TYPE_CHECKING import numpy as np import numpy.typing as npt import gstaichi as ti import torch import genesis as gs import genesis.utils.geom as gu import genesis.utils.array_class as array_class import genesis.engine.solvers.rigid.rigid_solver_decomp as rigid_solver from .... import maybe_pure fro...
I would prefer using `gs.maybe_pure` everywhere if you are fine with it.
from typing import TYPE_CHECKING import numpy as np import numpy.typing as npt import gstaichi as ti import torch import genesis as gs import genesis.utils.geom as gu import genesis.utils.array_class as array_class import genesis.engine.solvers.rigid.rigid_solver_decomp as rigid_solver from genesis.engine.solvers.rig...
@@ -9,6 +9,7 @@ import genesis.utils.geom as gu import genesis.utils.array_class as array_class import genesis.engine.solvers.rigid.rigid_solver_decomp as rigid_solver +from .... import maybe_pure
genesis/engine/solvers/rigid/constraint_solver_decomp.py
12
Python
0.429
suggestion
72
37
37
false
[FEATURE] Add initial experimental support of gstaichi fast cache feature.
1,631
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
hughperkins
Review this pull request change. Language: Python File: genesis/engine/solvers/rigid/constraint_solver_decomp.py PR Title: [FEATURE] Add initial experimental support of gstaichi fast cache feature. BEFORE CODE: from typing import TYPE_CHECKING import numpy as np import numpy.typing as npt import gstaichi as ti imp...
I would prefer using `gs.maybe_pure` everywhere if you are fine with 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.
import importlib import io import os import sys import site import atexit import logging as _logging import traceback from platform import system from contextlib import redirect_stdout from typing import Callable, TypeVar, ParamSpec # Import gstaichi while collecting its output without printing directly _ti_outputs = ...
As discussed in DM, I will move the reloading logic in unit test, because it is too fragile and only relevant in this context.
import io import os import sys import site import atexit import logging as _logging import traceback from platform import system from contextlib import redirect_stdout from typing import Callable, TypeVar, ParamSpec # Import gstaichi while collecting its output without printing directly _ti_outputs = io.StringIO() os...
genesis/__init__.py
1
Python
0.429
nitpick
126
26
26
false
[FEATURE] Add initial experimental support of gstaichi fast cache feature.
1,631
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
hughperkins
Review this pull request change. Language: Python File: genesis/__init__.py PR Title: [FEATURE] Add initial experimental support of gstaichi fast cache feature. BEFORE CODE: import importlib import io import os import sys import site import atexit import logging as _logging import traceback from platform import sys...
As discussed in DM, I will move the reloading logic in unit test, because it is too fragile and only relevant in this context.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
ti.loop_config(serialize=static_rigid_sim_config.para_level < gs.PARA_LEVEL.ALL) for i_l_ in range(rigid_global_info.n_awake_links[i_b]): i_l = rigid_global_info.awake_links[i_l_, i_b] links_state.root_COM[i_l, i_b].fill(0.0) links_state.mass_sum[i_l, i_b] = 0.0 ...
I don't think storing `link_COM` is useful because it is basically `i_pos`. Having multiple aliases for the same quantity is a bad practice and not memory friendly.
n_links = links_info.root_idx.shape[0] if ti.static(static_rigid_sim_config.use_hibernation): ti.loop_config(serialize=static_rigid_sim_config.para_level < gs.PARA_LEVEL.ALL) for i_l_ in range(rigid_global_info.n_awake_links[i_b]): i_l = rigid_global_info.awake_links[i_l_, i_b] ...
@@ -4253,7 +4272,8 @@ def func_COM_links( i_r = links_info.root_idx[I_l] links_state.mass_sum[i_r, i_b] += mass - links_state.COM[i_r, i_b] += mass * links_state.i_pos[i_l, i_b] + links_state.link_COM[i_l, i_b] = links_state.i_pos[i_l, i_b]
genesis/engine/solvers/rigid/rigid_solver_decomp.py
26
Python
0.714
suggestion
164
51
51
false
[BUG FIX, CHANGING] Fix primitive and mesh's COM. Add 'ref' optional argument to 'get_links_pos'.
1,638
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, CHANGING] Fix primitive and mesh's COM. Add 'ref' optional argument to 'get_links_pos'. BEFORE CODE: ti.loop_config(serialize=static_rigid_sim_config.para_level < gs.PARA_LEVEL.ALL...
I don't think storing `link_COM` is useful because it is basically `i_pos`. Having multiple aliases for the same quantity is a bad practice and not memory friendly.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
pos=(0.4, 0.0, -0.54), fixed=True, ), vis_mode="collision", ) asset_path = get_hf_dataset(pattern="spoon.glb") obj = scene.add_entity( gs.morphs.Mesh( file=f"{asset_path}/spoon.glb", pos=(0.3, 0, 0.015), quat=(0.707, 0.707, ...
Why did you have to change the tolerance so much? It looks wrong.
), rigid_options=gs.options.RigidOptions( use_gjk_collision=gjk_collision, ), show_viewer=show_viewer, show_FPS=False, ) asset_path = get_hf_dataset(pattern="work_table.glb") table = scene.add_entity( gs.morphs.Mesh( file=f"{asset_path}...
@@ -1686,8 +1691,9 @@ def test_mesh_repair(convexify, show_viewer, gjk_collision): assert all(geom.metadata["decomposed"] for geom in obj.geoms) # MPR collision detection is significantly less reliable than SDF in terms of penetration depth estimation. - tol_pos = 0.05 if convexify else 1e-6 - tol...
tests/test_rigid_physics.py
26
Python
0.286
bug
65
51
51
false
[BUG FIX, CHANGING] Fix primitive and mesh's COM. Add 'ref' optional argument to 'get_links_pos'.
1,638
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, CHANGING] Fix primitive and mesh's COM. Add 'ref' optional argument to 'get_links_pos'. BEFORE CODE: pos=(0.4, 0.0, -0.54), fixed=True, ), vis_mode="collision", ) a...
Why did you have to change the tolerance so much? It looks wrong.
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 get_entities_state(solver): shape = solver._batch_shape(solver.n_entities_) kwargs = { "hibernated": V(dtype=gs.ti_int, shape=shape), } if use_ndarray: return StructEntitiesState(**kwargs) else: @ti.data_oriented class ClassEntitiesState: def __init...
I can see why you're going to ask me to make it possible to set `FIELD_METADATA_CACHE_VALUE` conceptually on an entire dataclass at some point :)
def get_entities_state(solver): shape = solver._batch_shape(solver.n_entities_) kwargs = { "hibernated": V(dtype=gs.ti_int, shape=shape), } if use_ndarray: return StructEntitiesState(**kwargs) else: @ti.data_oriented class ClassEntitiesState: def __init...
@@ -2004,6 +2005,70 @@ def __init__(self): return ClassEntitiesState() +# =========================================== StaticRigidSimConfig =========================================== + + +@dataclasses.dataclass +class StaticRigidSimDummy: + para_level: int = dataclasses.field(metadata={FIELD_METADATA_CA...
genesis/utils/array_class.py
26
Python
0.5
performance
145
51
51
false
[FEATURE] Use FIELD_METADATA_CACHE_VALUE for static config
1,639
Genesis-Embodied-AI/Genesis
26,702
Python
hughperkins
YilingQiao
Review this pull request change. Language: Python File: genesis/utils/array_class.py PR Title: [FEATURE] Use FIELD_METADATA_CACHE_VALUE for static config BEFORE CODE: def get_entities_state(solver): shape = solver._batch_shape(solver.n_entities_) kwargs = { "hibernated": V(dtype=gs.ti_int, shape=sh...
I can see why you're going to ask me to make it possible to set `FIELD_METADATA_CACHE_VALUE` conceptually on an entire dataclass at some point :)
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.
para_level: int = dataclasses.field(metadata={FIELD_METADATA_CACHE_VALUE: True}) use_hibernation: bool = dataclasses.field(metadata={FIELD_METADATA_CACHE_VALUE: True}) use_contact_island: bool = dataclasses.field(metadata={FIELD_METADATA_CACHE_VALUE: True}) batch_links_info: bool = dataclasses.field(met...
There was no request ot support floats, only ints and bools. Whilst it seems plausible tht it might work with floats, note that this is not tested. Please consider creating a PR onto gstaichi to add a test for floats. Something like https://github.com/Genesis-Embodied-AI/gstaichi/blob/a00b3aa5154b4b983df0c181cba3d60e20...
@dataclasses.dataclass class StaticRigidSimCacheKey: para_level: int = cache_value() use_hibernation: bool = cache_value() batch_links_info: bool = cache_value() batch_dofs_info: bool = cache_value() batch_joints_info: bool = cache_value() enable_mujoco_compatibility: bool = cache_value() en...
@@ -2004,6 +2005,70 @@ def __init__(self): return ClassEntitiesState() +# =========================================== StaticRigidSimConfig =========================================== + + +@dataclasses.dataclass +class StaticRigidSimDummy: + para_level: int = dataclasses.field(metadata={FIELD_METADATA_CA...
genesis/utils/array_class.py
26
Python
0.5
suggestion
526
51
51
false
[FEATURE] Use FIELD_METADATA_CACHE_VALUE for static config
1,639
Genesis-Embodied-AI/Genesis
26,702
Python
hughperkins
YilingQiao
Review this pull request change. Language: Python File: genesis/utils/array_class.py PR Title: [FEATURE] Use FIELD_METADATA_CACHE_VALUE for static config BEFORE CODE: para_level: int = dataclasses.field(metadata={FIELD_METADATA_CACHE_VALUE: True}) use_hibernation: bool = dataclasses.field(metadata={FIELD_ME...
There was no request ot support floats, only ints and bools. Whilst it seems plausible tht it might work with floats, note that this is not tested. Please consider creating a PR onto gstaichi to add a test for floats. Something like https://github.com/Genesis-Embodied-AI/gstaichi/blob/a00b3aa5154b4b983df0c181cba3d60e20...
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 get_entities_state(solver): shape = solver._batch_shape(solver.n_entities_) kwargs = { "hibernated": V(dtype=gs.ti_int, shape=shape), } if use_ndarray: return StructEntitiesState(**kwargs) else: @ti.data_oriented class ClassEntitiesState: def __init_...
Why do we have both `StaticRigidSimConfig` and `StaticRigidSimDummy`. We should get rid of the former? Besides, the name is not quite right. `StaticRigidSimDummy` does not mean anything. What is this class all about? If it is used for kernel caching disambiguation only, then it should rather be called `RigidSimMetad...
def get_entities_state(solver): shape = solver._batch_shape(solver.n_entities_) kwargs = { "hibernated": V(dtype=gs.ti_int, shape=shape), } if use_ndarray: return StructEntitiesState(**kwargs) else: @ti.data_oriented class ClassEntitiesState: def __init_...
@@ -2004,6 +2005,51 @@ def __init__(self): return ClassEntitiesState() +# =========================================== StaticRigidSimConfig =========================================== + +cache_value = partial(dataclasses.field, metadata={FIELD_METADATA_CACHE_VALUE: True}) + + +@dataclasses.dataclass +class ...
genesis/utils/array_class.py
26
Python
0.643
performance
398
51
51
false
[FEATURE] Use FIELD_METADATA_CACHE_VALUE for static config
1,639
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/utils/array_class.py PR Title: [FEATURE] Use FIELD_METADATA_CACHE_VALUE for static config BEFORE CODE: def get_entities_state(solver): shape = solver._batch_shape(solver.n_entities_) kwargs = { "hibernated": V(dtype=gs.ti_int, shape=sha...
Why do we have both `StaticRigidSimConfig` and `StaticRigidSimDummy`. We should get rid of the former? Besides, the name is not quite right. `StaticRigidSimDummy` does not mean anything. What is this class all about? If it is used for kernel caching disambiguation only, then it should rather be called `RigidSimMetad...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# note that using `backend` instead of `test_backend`, breaks genesis pytest... @pytest.mark.parametrize("test_backend", ["cpu", "gpu"]) # should not affect result @pytest.mark.parametrize("use_ndarray", [False, True]) def test_gs_num_envs(use_ndarray: bool, enable_pure: bool, test_backend: str, tmp_path: pathlib.Path...
we have fe-ll-cache? Is it newly added?
@pytest.mark.parametrize("test_backend", ["cpu", "gpu"]) # should not affect result @pytest.mark.parametrize("use_ndarray", [False, True]) def test_gs_num_envs(use_ndarray: bool, enable_pure: bool, test_backend: str, tmp_path: pathlib.Path) -> None: if sys.platform == "Darwin" and test_backend == "gpu" and use_nda...
@@ -92,7 +93,92 @@ def test_gs_static( env = dict(os.environ) env["GS_BETA_PURE"] = "1" if enable_pure else "0" env["TI_OFFLINE_CACHE_FILE_PATH"] = str(tmp_path) + + +def gs_num_envs_child(args: list[str]): + parser = argparse.ArgumentParser() + parser.add_argument("--test-backend", typ...
tests/test_fastcache_unified.py
26
Python
0.071
performance
39
51
51
false
[MISC] Add test of num envs versus recompilation
1,655
Genesis-Embodied-AI/Genesis
26,702
Python
YilingQiao
hughperkins
Review this pull request change. Language: Python File: tests/test_fastcache_unified.py PR Title: [MISC] Add test of num envs versus recompilation BEFORE CODE: # note that using `backend` instead of `test_backend`, breaks genesis pytest... @pytest.mark.parametrize("test_backend", ["cpu", "gpu"]) # should not affec...
we have fe-ll-cache? Is it newly added?
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( gs.morphs.Box( size=(0.4, 0.4, 0.4), pos=(0.0, 0.0, 0.18), ) ) scene.build(n_envs=args.num_env, env_spacing=(0.5, 0.5)) scene.rigid_solver.collider.detection() gs.ti.sync() from genesis.engine.solvers.rigid.rigid_solver_decomp imp...
```python pytest.skip( "fast cache not supported on mac gpus when using ndarray, because mac gpu only supports up to 31 kernel" " parameters, and we need more than that." ) ```
scene.add_entity( gs.morphs.Box( size=(0.4, 0.4, 0.4), pos=(0.0, 0.0, 0.18), ) ) scene.build(n_envs=args.num_env, env_spacing=(0.5, 0.5)) scene.rigid_solver.collider.detection() gs.ti.sync() from genesis.engine.solvers.rigid.rigid_solver_decomp import ke...
@@ -92,7 +93,92 @@ def test_gs_static( env = dict(os.environ) env["GS_BETA_PURE"] = "1" if enable_pure else "0" env["TI_OFFLINE_CACHE_FILE_PATH"] = str(tmp_path) + + +def gs_num_envs_child(args: list[str]): + parser = argparse.ArgumentParser() + parser.add_argument("--test-backend", typ...
tests/test_fastcache_unified.py
26
Python
0.857
performance
222
51
51
false
[MISC] Add test of num envs versus recompilation
1,655
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
hughperkins
Review this pull request change. Language: Python File: tests/test_fastcache_unified.py PR Title: [MISC] Add test of num envs versus recompilation BEFORE CODE: ) scene.add_entity( gs.morphs.Box( size=(0.4, 0.4, 0.4), pos=(0.0, 0.0, 0.18), ) ) scene.build(n_en...
```python pytest.skip( "fast cache not supported on mac gpus when using ndarray, because mac gpu only supports up to 31 kernel" " parameters, and we need more than that." ) ```
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( gs.morphs.Box( size=(0.4, 0.4, 0.4), pos=(0.0, 0.0, 0.18), ) ) scene.build(n_envs=args.num_env, env_spacing=(0.5, 0.5)) scene.rigid_solver.collider.detection() gs.ti.sync() from genesis.engine.solvers.rigid.rigid_solver_decomp imp...
We use `sys.platform != "darwin"` everywhere else.
scene.add_entity( gs.morphs.Box( size=(0.4, 0.4, 0.4), pos=(0.0, 0.0, 0.18), ) ) scene.build(n_envs=args.num_env, env_spacing=(0.5, 0.5)) scene.rigid_solver.collider.detection() gs.ti.sync() from genesis.engine.solvers.rigid.rigid_solver_decomp import ke...
@@ -92,7 +93,92 @@ def test_gs_static( env = dict(os.environ) env["GS_BETA_PURE"] = "1" if enable_pure else "0" env["TI_OFFLINE_CACHE_FILE_PATH"] = str(tmp_path) + + +def gs_num_envs_child(args: list[str]): + parser = argparse.ArgumentParser() + parser.add_argument("--test-backend", typ...
tests/test_fastcache_unified.py
26
Python
0.429
suggestion
50
51
51
false
[MISC] Add test of num envs versus recompilation
1,655
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
hughperkins
Review this pull request change. Language: Python File: tests/test_fastcache_unified.py PR Title: [MISC] Add test of num envs versus recompilation BEFORE CODE: ) scene.add_entity( gs.morphs.Box( size=(0.4, 0.4, 0.4), pos=(0.0, 0.0, 0.18), ) ) scene.build(n_en...
We use `sys.platform != "darwin"` 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.
euler : tuple, shape (3,), optional The euler angle of the entity in degrees. This follows scipy's extrinsic x-y-z rotation convention. Defaults to (0.0, 0.0, 0.0). quat : tuple, shape (4,), optional The quaternion (w-x-y-z convention) of the entity. If specified, `euler` will be ignored...
`tile_size` would make more sense?
euler : tuple, shape (3,), optional The euler angle of the entity in degrees. This follows scipy's extrinsic x-y-z rotation convention. Defaults to (0.0, 0.0, 0.0). quat : tuple, shape (4,), optional The quaternion (w-x-y-z convention) of the entity. If specified, `euler` will be ignored...
@@ -429,10 +429,16 @@ class Plane(Primitive): conaffinity : int, optional The 32-bit integer bitmasks used for contact filtering of contact pairs. When the conaffinity of one geom and the contype of the other geom share a common bit set to 1, two geoms can collide. Defaults to 0xFFFF. + size: ...
genesis/options/morphs.py
26
Python
0.214
question
34
51
51
false
[MISC] Expose parameters for ground plane tiling.
1,657
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
yuhongyi
Review this pull request change. Language: Python File: genesis/options/morphs.py PR Title: [MISC] Expose parameters for ground plane tiling. BEFORE CODE: euler : tuple, shape (3,), optional The euler angle of the entity in degrees. This follows scipy's extrinsic x-y-z rotation convention. Defau...
`tile_size` would make more sense?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
pos : tuple, shape (3,), optional The center position of the plane in meters. Defaults to (0.0, 0.0, 0.0). euler : tuple, shape (3,), optional The euler angle of the entity in degrees. This follows scipy's extrinsic x-y-z rotation convention. Defaults to (0.0, 0.0, 0.0). quat : tuple...
`plane_size` may be? `size` is not very clear.
pos : tuple, shape (3,), optional The center position of the plane in meters. Defaults to (0.0, 0.0, 0.0). euler : tuple, shape (3,), optional The euler angle of the entity in degrees. This follows scipy's extrinsic x-y-z rotation convention. Defaults to (0.0, 0.0, 0.0). quat : tuple...
@@ -429,10 +429,16 @@ class Plane(Primitive): conaffinity : int, optional The 32-bit integer bitmasks used for contact filtering of contact pairs. When the conaffinity of one geom and the contype of the other geom share a common bit set to 1, two geoms can collide. Defaults to 0xFFFF. + size: ...
genesis/options/morphs.py
26
Python
0.214
suggestion
46
51
51
false
[MISC] Expose parameters for ground plane tiling.
1,657
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
yuhongyi
Review this pull request change. Language: Python File: genesis/options/morphs.py PR Title: [MISC] Expose parameters for ground plane tiling. BEFORE CODE: pos : tuple, shape (3,), optional The center position of the plane in meters. Defaults to (0.0, 0.0, 0.0). euler : tuple, shape (3,), optional ...
`plane_size` may be? `size` is not very clear.
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.
face_normals.append(sphere_face_normals) n_verts += len(sphere_vertices) vertices = np.concatenate(vertices) faces = np.concatenate(faces) face_normals = np.concatenate(face_normals) else: vertices, faces, face_normals = _create_unit_box_impl() vertic...
extract `half_x, half_y = (size[0] * 0.5, size[1] * 0.5)`
face_normals.append(sphere_face_normals) n_verts += len(sphere_vertices) vertices = np.concatenate(vertices) faces = np.concatenate(faces) face_normals = np.concatenate(face_normals) else: vertices, faces, face_normals = _create_unit_box_impl() vertic...
@@ -889,21 +889,21 @@ def create_box(extents=None, color=(1.0, 1.0, 1.0, 1.0), bounds=None, wireframe= return mesh -def create_plane(size=1e3, color=None, normal=(0.0, 0.0, 1.0)): +def create_plane(normal=(0.0, 0.0, 1.0), size=(1e3, 1e3), n_tiles=(1e3, 1e3), color=None): thickness = 1e-2 # for safety - ...
genesis/utils/mesh.py
26
Python
0.429
refactor
57
51
51
false
[MISC] Expose parameters for ground plane tiling.
1,657
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
yuhongyi
Review this pull request change. Language: Python File: genesis/utils/mesh.py PR Title: [MISC] Expose parameters for ground plane tiling. BEFORE CODE: face_normals.append(sphere_face_normals) n_verts += len(sphere_vertices) vertices = np.concatenate(vertices) faces = np.conc...
extract `half_x, half_y = (size[0] * 0.5, size[1] * 0.5)`
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.
half = (size[0] * 0.5, size[1] * 0.5) verts = np.array( [ [-half[0], -half[1], 0.0], [half[0], -half[1], 0.0], [half[0], half[1], 0.0], [-half[0], -half[1], 0.0], [half[0], half[1], 0.0], [-half[0], half[1], 0.0], ], ...
Same. I would rather export `x` and `y` components. More readable I think.
half_x, half_y = (plane_size[0] * 0.5, plane_size[1] * 0.5) verts = np.array( [ [-half_x, -half_y, 0.0], [half_x, -half_y, 0.0], [half_x, half_y, 0.0], [-half_x, -half_y, 0.0], [half_x, half_y, 0.0], [-half_x, half_y, 0.0], ...
@@ -916,11 +916,11 @@ def create_plane(size=1e3, color=None, normal=(0.0, 0.0, 1.0)): uv=np.array( [ [0, 0], - [size, 0], - [size, size], + [n_tiles[0], 0], + [n_tiles[0], n_tiles[1]], ...
genesis/utils/mesh.py
26
Python
0.357
suggestion
74
51
51
false
[MISC] Expose parameters for ground plane tiling.
1,657
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
yuhongyi
Review this pull request change. Language: Python File: genesis/utils/mesh.py PR Title: [MISC] Expose parameters for ground plane tiling. BEFORE CODE: half = (size[0] * 0.5, size[1] * 0.5) verts = np.array( [ [-half[0], -half[1], 0.0], [half[0], -half[1], 0.0], [h...
Same. I would rather export `x` and `y` components. More readable 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.
for i in range(100): if is_done: is_done = False break time.sleep(0.1) else: raise AssertionError("Keyboard event not processed before timeout") else: pyrender_viewer.dispatch_pending_events() pyrender_viewer.dispatc...
Do not mark this test as required, it is too long: <img width="997" height="131" alt="image" src="https://github.com/user-attachments/assets/6789beca-a9d2-4f6f-91db-7ef661b679dd" />
for i in range(100): if is_done: is_done = False break time.sleep(0.1) else: raise AssertionError("Keyboard event not processed before timeout") else: pyrender_viewer.dispatch_pending_events() pyrender_viewer.dispatc...
@@ -777,3 +777,55 @@ def on_key_press(self, symbol: int, modifiers: int): # Make sure that the result is valid with open(IMAGE_FILENAME, "rb") as f: assert f.read() == png_snapshot + + +@pytest.mark.required
tests/test_render.py
26
Python
0.429
refactor
184
51
51
false
[MISC] Expose parameters for ground plane tiling.
1,657
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
yuhongyi
Review this pull request change. Language: Python File: tests/test_render.py PR Title: [MISC] Expose parameters for ground plane tiling. BEFORE CODE: for i in range(100): if is_done: is_done = False break time.sleep(0.1) else: raise...
Do not mark this test as required, it is too long: <img width="997" height="131" alt="image" src="https://github.com/user-attachments/assets/6789beca-a9d2-4f6f-91db-7ef661b679dd" />
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.
lookat=(0.0, 0.0, 0.5), fov=45, GUI=False, ) scene.add_light( pos=[0.0, 0.0, 1.5], dir=[1.0, 1.0, -2.0], directional=1, castshadow=1, cutoff=45.0, intensity=0.5, ) scene.build() ...
Remove all the comments. This test is simple. No need to explain what is going on.
import itertools import os import re import sys import time import enum import numpy as np import pyglet import pytest import torch import genesis as gs import genesis.utils.geom as gu from genesis.utils import set_random_seed from genesis.utils.image_exporter import FrameImageExporter from genesis.utils.misc import ...
@@ -777,3 +777,55 @@ def on_key_press(self, symbol: int, modifiers: int): # Make sure that the result is valid with open(IMAGE_FILENAME, "rb") as f: assert f.read() == png_snapshot + + +@pytest.mark.required +@pytest.mark.parametrize( + "renderer_type", + [RENDERER_TYPE.BATCHRENDER_RASTERIZER],...
tests/test_render.py
26
Python
0.286
suggestion
82
29
817
false
[MISC] Expose parameters for ground plane tiling.
1,657
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
yuhongyi
Review this pull request change. Language: Python File: tests/test_render.py PR Title: [MISC] Expose parameters for ground plane tiling. BEFORE CODE: lookat=(0.0, 0.0, 0.5), fov=45, GUI=False, ) scene.add_light( pos=[0.0, 0.0, 1.5], dir=[1....
Remove all the comments. This test is simple. No need to explain what is going on.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
camera = scene.add_camera( res=CAM_RES, pos=(1.5, 0.5, 1.5), lookat=(0.0, 0.0, 0.5), fov=45, GUI=False, ) scene.add_light( pos=[0.0, 0.0, 1.5], dir=[1.0, 1.0, -2.0], directional=1, castsha...
Remove for loop and do not call `scene.step` at all. It is not necessary and useful in this context.
import itertools import os import re import sys import time import enum import numpy as np import pyglet import pytest import torch import genesis as gs import genesis.utils.geom as gu from genesis.utils import set_random_seed from genesis.utils.image_exporter import FrameImageExporter from genesis.utils.misc import ...
@@ -777,3 +777,55 @@ def on_key_press(self, symbol: int, modifiers: int): # Make sure that the result is valid with open(IMAGE_FILENAME, "rb") as f: assert f.read() == png_snapshot + + +@pytest.mark.required +@pytest.mark.parametrize( + "renderer_type", + [RENDERER_TYPE.BATCHRENDER_RASTERIZER],...
tests/test_render.py
26
Python
0.571
suggestion
100
32
817
false
[MISC] Expose parameters for ground plane tiling.
1,657
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
yuhongyi
Review this pull request change. Language: Python File: tests/test_render.py PR Title: [MISC] Expose parameters for ground plane tiling. BEFORE CODE: camera = scene.add_camera( res=CAM_RES, pos=(1.5, 0.5, 1.5), lookat=(0.0, 0.0, 0.5), fov=45, GUI=F...
Remove for loop and do not call `scene.step` at all. It is not necessary and useful in this context.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
break time.sleep(0.1) else: raise AssertionError("Keyboard event not processed before timeout") else: pyrender_viewer.dispatch_pending_events() pyrender_viewer.dispatch_events() # Skip the rest of the test if necessary if sys.platform == "linu...
Use `RENDERER_TYPE.RASTERIZER` if possible, because it works on all platforms unlike `RENDERER_TYPE.BATCHRENDER_*`
break time.sleep(0.1) else: raise AssertionError("Keyboard event not processed before timeout") else: pyrender_viewer.dispatch_pending_events() pyrender_viewer.dispatch_events() # Skip the rest of the test if necessary if sys.platform == "linu...
@@ -777,3 +777,55 @@ def on_key_press(self, symbol: int, modifiers: int): # Make sure that the result is valid with open(IMAGE_FILENAME, "rb") as f: assert f.read() == png_snapshot + + +@pytest.mark.required +@pytest.mark.parametrize( + "renderer_type", + [RENDERER_TYPE.BATCHRENDER_RASTERIZER],
tests/test_render.py
26
Python
0.714
performance
114
51
51
false
[MISC] Expose parameters for ground plane tiling.
1,657
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
yuhongyi
Review this pull request change. Language: Python File: tests/test_render.py PR Title: [MISC] Expose parameters for ground plane tiling. BEFORE CODE: break time.sleep(0.1) else: raise AssertionError("Keyboard event not processed before timeout") else: pyre...
Use `RENDERER_TYPE.RASTERIZER` if possible, because it works on all platforms unlike `RENDERER_TYPE.BATCHRENDER_*`
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.
# Skip the rest of the test if necessary if sys.platform == "linux": glinfo = pyrender_viewer.context.get_info() renderer = glinfo.get_renderer() if "llvmpipe" in renderer: llvm_version = re.search(r"LLVM\s+([\d.]+)", renderer).group(1) if llvm_version < "20": ...
Are you sure you need a full grid? What about: ``` for test_idx, (size, n_tiles) in enumerate(( ((1.5, 1.8), (0.5, 0.75)), ((10.0, 7.0), (5.0, 3.0)), ((10.0, 7.0), None), )): ```
# Skip the rest of the test if necessary if sys.platform == "linux": glinfo = pyrender_viewer.context.get_info() renderer = glinfo.get_renderer() if "llvmpipe" in renderer: llvm_version = re.search(r"LLVM\s+([\d.]+)", renderer).group(1) if llvm_version < "20": ...
@@ -777,3 +777,55 @@ def on_key_press(self, symbol: int, modifiers: int): # Make sure that the result is valid with open(IMAGE_FILENAME, "rb") as f: assert f.read() == png_snapshot + + +@pytest.mark.required +@pytest.mark.parametrize( + "renderer_type", + [RENDERER_TYPE.BATCHRENDER_RASTERIZER],...
tests/test_render.py
26
Python
0.714
suggestion
197
51
51
false
[MISC] Expose parameters for ground plane tiling.
1,657
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
yuhongyi
Review this pull request change. Language: Python File: tests/test_render.py PR Title: [MISC] Expose parameters for ground plane tiling. BEFORE CODE: # Skip the rest of the test if necessary if sys.platform == "linux": glinfo = pyrender_viewer.context.get_info() renderer = glinfo.get_render...
Are you sure you need a full grid? What about: ``` for test_idx, (size, n_tiles) in enumerate(( ((1.5, 1.8), (0.5, 0.75)), ((10.0, 7.0), (5.0, 3.0)), ((10.0, 7.0), None), )): ```
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.required @pytest.mark.parametrize( "renderer_type", [RENDERER_TYPE.BATCHRENDER_RASTERIZER], ) def test_render_planes(tmp_path, png_snapshot, renderer): # Manually run this test with different parameters to make sure they run sequentially # Running in parallel may crash the test OOM. siz...
What about using a "perfect" top view camera angle? It would make more sense. It would even be possible to check if tiling it right based on the RGB data.
@pytest.mark.parametrize( "renderer_type", [RENDERER_TYPE.RASTERIZER], ) def test_render_planes(tmp_path, png_snapshot, renderer): for test_idx, (plane_size, tile_size) in enumerate( ( ((3, 4.5), (0.5, 0.75)), ((3.0, 5.0), (5.0, 3.0)), ((4.0, 4.0), (1.0, 1.0)), ...
@@ -777,3 +777,55 @@ def on_key_press(self, symbol: int, modifiers: int): # Make sure that the result is valid with open(IMAGE_FILENAME, "rb") as f: assert f.read() == png_snapshot + + +@pytest.mark.required +@pytest.mark.parametrize( + "renderer_type", + [RENDERER_TYPE.BATCHRENDER_RASTERIZER],...
tests/test_render.py
26
Python
0.357
question
154
51
36
false
[MISC] Expose parameters for ground plane tiling.
1,657
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
yuhongyi
Review this pull request change. Language: Python File: tests/test_render.py PR Title: [MISC] Expose parameters for ground plane tiling. BEFORE CODE: @pytest.mark.required @pytest.mark.parametrize( "renderer_type", [RENDERER_TYPE.BATCHRENDER_RASTERIZER], ) def test_render_planes(tmp_path, png_snapshot, rend...
What about using a "perfect" top view camera angle? It would make more sense. It would even be possible to check if tiling it right based on the RGB data.
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.
# Skip the rest of the test if necessary if sys.platform == "linux": glinfo = pyrender_viewer.context.get_info() renderer = glinfo.get_renderer() if "llvmpipe" in renderer: llvm_version = re.search(r"LLVM\s+([\d.]+)", renderer).group(1) if llvm_version < "20": ...
`CAM_RES = (256, 256)` would be faster to render and good enough for this.
# Skip the rest of the test if necessary if sys.platform == "linux": glinfo = pyrender_viewer.context.get_info() renderer = glinfo.get_renderer() if "llvmpipe" in renderer: llvm_version = re.search(r"LLVM\s+([\d.]+)", renderer).group(1) if llvm_version < "20": ...
@@ -777,3 +777,55 @@ def on_key_press(self, symbol: int, modifiers: int): # Make sure that the result is valid with open(IMAGE_FILENAME, "rb") as f: assert f.read() == png_snapshot + + +@pytest.mark.required +@pytest.mark.parametrize( + "renderer_type", + [RENDERER_TYPE.BATCHRENDER_RASTERIZER],...
tests/test_render.py
26
Python
0.357
suggestion
74
51
50
false
[MISC] Expose parameters for ground plane tiling.
1,657
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
yuhongyi
Review this pull request change. Language: Python File: tests/test_render.py PR Title: [MISC] Expose parameters for ground plane tiling. BEFORE CODE: # Skip the rest of the test if necessary if sys.platform == "linux": glinfo = pyrender_viewer.context.get_info() renderer = glinfo.get_rendere...
`CAM_RES = (256, 256)` would be faster to render and good enough for this.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# Running in parallel may crash the test OOM. sizes = [(1.5, 1.8), (10.0, 7.0)] n_tiles = [(0.5, 0.75), (5.0, 3.0), None] for test_idx, (size, n_tiles) in enumerate(itertools.product(sizes, n_tiles)): CAM_RES = (512, 512) NUM_STEPS = 1 scene = gs.Scene( renderer=rende...
This is not good enough I think. You should ideally check that the pattern is correct, or at least that all the images are different. (this is done in advanced render api test).
((3, 4.5), (0.5, 0.75)), ((3.0, 5.0), (5.0, 3.0)), ((4.0, 4.0), (1.0, 1.0)), ) ): CAM_RES = (256, 256) scene = gs.Scene( renderer=renderer, ) plane = scene.add_entity( gs.morphs.Plane(plane_size=plane_size, tile_size...
@@ -777,3 +777,55 @@ def on_key_press(self, symbol: int, modifiers: int): # Make sure that the result is valid with open(IMAGE_FILENAME, "rb") as f: assert f.read() == png_snapshot + + +@pytest.mark.required +@pytest.mark.parametrize( + "renderer_type", + [RENDERER_TYPE.BATCHRENDER_RASTERIZER],...
tests/test_render.py
26
Python
0.429
suggestion
177
44
29
false
[MISC] Expose parameters for ground plane tiling.
1,657
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
yuhongyi
Review this pull request change. Language: Python File: tests/test_render.py PR Title: [MISC] Expose parameters for ground plane tiling. BEFORE CODE: # Running in parallel may crash the test OOM. sizes = [(1.5, 1.8), (10.0, 7.0)] n_tiles = [(0.5, 0.75), (5.0, 3.0), None] for test_idx, (size, n_tiles...
This is not good enough I think. You should ideally check that the pattern is correct, or at least that all the images are different. (this is done in advanced render api test).
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.morphs.Box(size=(0.1, 0.1, 0.1), pos=(0.5, 0, 0.05)), material=gs.materials.Rigid(), ) sphere = scene.add_entity( gs.morphs.Sphere(radius=0.05, pos=(-0.5, 0, 0.05)), material=gs.materials.Rigid(), ) scene.build() all_aabbs = scene.sim.rigid_solver.get_aabb() ...
Can you also check the actual value of the aabbs for box and sphere since you already know their pos and size?
gs.morphs.Box(size=(0.1, 0.1, 0.1), pos=(0.5, 0, 0.05)), material=gs.materials.Rigid(), ) sphere = scene.add_entity( gs.morphs.Sphere(radius=0.05, pos=(-0.5, 0, 0.05)), material=gs.materials.Rigid(), ) scene.build() all_aabbs = scene.sim.rigid_solver.get_aabb() ...
@@ -2910,3 +2910,46 @@ def test_mesh_primitive_COM(show_viewer, tol): # root and link COM should be the same for single link assert_allclose(root_bunny_z, bunny_z, atol=tol) assert_allclose(root_cube_z, cube_z, atol=tol) + + +@pytest.mark.required +@pytest.mark.parametrize("backend", [gs.cpu]) +def test_...
tests/test_rigid_physics.py
26
Python
0.357
question
110
29
39
false
[FEATURE] Batched AABB
1,658
Genesis-Embodied-AI/Genesis
26,702
Python
YilingQiao
LeonLiu4
Review this pull request change. Language: Python File: tests/test_rigid_physics.py PR Title: [FEATURE] Batched AABB BEFORE CODE: gs.morphs.Box(size=(0.1, 0.1, 0.1), pos=(0.5, 0, 0.05)), material=gs.materials.Rigid(), ) sphere = scene.add_entity( gs.morphs.Sphere(radius=0.05, pos=(-0...
Can you also check the actual value of the aabbs for box and sphere since you already know their pos and size?
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 math import os import sys import tempfile import xml.etree.ElementTree as ET from pathlib import Path import mujoco import numpy as np import pytest import torch import trimesh import genesis as gs import genesis.utils.geom as gu from genesis.utils.misc import get_assets_dir, tensor_to_array from .utils impor...
I’m wondering if it is possible to write a simpler unit test without robot that only focuses on assuming noslip. What about considering 2 cubes touching each over on one side, with one of them being fixed but not the other, then you apply a “strong” normal force on the moving one and you check that it does not fall.
import math import os import sys import tempfile from typing import cast import xml.etree.ElementTree as ET from pathlib import Path import mujoco import numpy as np import pytest import torch import trimesh import genesis as gs import genesis.utils.geom as gu from genesis.utils.misc import get_assets_dir, tensor_to_...
tests/test_rigid_physics.py
1
Python
0.5
suggestion
320
26
26
false
[FEATURE] Add noslip solver
1,669
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 noslip solver BEFORE CODE: import math import os import sys import tempfile import xml.etree.ElementTree as ET from pathlib import Path import mujoco import numpy as np import pytest import torch import trim...
I’m wondering if it is possible to write a simpler unit test without robot that only focuses on assuming noslip. What about considering 2 cubes touching each over on one side, with one of them being fixed but not the other, then you apply a “strong” normal force on the moving one and you check that it does not fall.
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.
Integrator type. Current supported integrators are 'gs.integrator.Euler', 'gs.integrator.implicitfast' and 'gs.integrator.approximate_implicitfast'. 'Euler' and 'implicitfast' are consistent with their Mujoco counterpart. 'approximate_implicitfast' is an even faster approximation of 'implicitfas...
I don't think we should say that. Maybe something like ``` This option should only be enabled if necessary because it is still experimental and it will slow down the simulation. ```
Integrator type. Current supported integrators are 'gs.integrator.Euler', 'gs.integrator.implicitfast' and 'gs.integrator.approximate_implicitfast'. 'Euler' and 'implicitfast' are consistent with their Mujoco counterpart. 'approximate_implicitfast' is an even faster approximation of 'implicitfas...
@@ -248,6 +248,13 @@ class RigidOptions(Options): Number of line search iterations for the constraint solver. Defaults to 50. ls_tolerance : float, optional Tolerance for the line search. Defaults to 1e-2. + noslip_iterations : int, optional + Number of iterations for the noslip solver....
genesis/options/solvers.py
26
Python
0.786
performance
184
51
51
false
[FEATURE] Add noslip solver
1,669
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/options/solvers.py PR Title: [FEATURE] Add noslip solver BEFORE CODE: Integrator type. Current supported integrators are 'gs.integrator.Euler', 'gs.integrator.implicitfast' and 'gs.integrator.approximate_implicitfast'. 'Euler' and 'impl...
I don't think we should say that. Maybe something like ``` This option should only be enabled if necessary because it is still experimental and it will slow down 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.
cg_beta: V_ANNOTATION cg_pg_dot_pMg: V_ANNOTATION # Optional Newton fields nt_H: V_ANNOTATION nt_vec: V_ANNOTATION def get_constraint_state(constraint_solver, solver): f_batch = solver._batch_shape len_constraints = constraint_solver.len_constraints len_constraints_ = constraint_solver...
Only move to new line if necessary: ```python gs.logger.warning( f"efc_AR shape {len_constraints_}x{len_constraints_}x{f_batch()[0]} is very large. Consider manually " f"set a smaller 'max_collision_pairs' in RigidOptions to reduce the size of reserved memory. " ...
cg_beta: V_ANNOTATION cg_pg_dot_pMg: V_ANNOTATION # Optional Newton fields nt_H: V_ANNOTATION nt_vec: V_ANNOTATION def get_constraint_state(constraint_solver, solver): f_batch = solver._batch_shape len_constraints = constraint_solver.len_constraints len_constraints_ = constraint_solver...
@@ -169,6 +171,19 @@ def get_constraint_state(constraint_solver, solver): "Consider reducing the number of constraints or the number of degrees of freedom." ) + if solver._static_rigid_sim_config.noslip_iterations > 0: + if len_constraints_ * len_constraints_ * f_batch()[0] > 2 * 10**9...
genesis/utils/array_class.py
26
Python
1
performance
330
51
51
false
[FEATURE] Add noslip solver
1,669
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/utils/array_class.py PR Title: [FEATURE] Add noslip solver BEFORE CODE: cg_beta: V_ANNOTATION cg_pg_dot_pMg: V_ANNOTATION # Optional Newton fields nt_H: V_ANNOTATION nt_vec: V_ANNOTATION def get_constraint_state(constraint_solver,...
Only move to new line if necessary: ```python gs.logger.warning( f"efc_AR shape {len_constraints_}x{len_constraints_}x{f_batch()[0]} is very large. Consider manually " f"set a smaller 'max_collision_pairs' in RigidOptions to reduce the size of reserved memory. " ...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
assert_allclose(cube_z, cube.get_links_pos(links_idx_local=[0], ref="link_com")[0, 2], atol=gs.EPS) assert_allclose(root_bunny_z, bunny.get_links_pos(links_idx_local=[0], ref="root_com")[0, 2], atol=gs.EPS) assert_allclose(root_cube_z, cube.get_links_pos(links_idx_local=[0], ref="root_com")[0, 2], atol=gs.E...
Are these options really useful?
scene.step() assert_allclose(box2.get_pos(), box3.get_pos(), atol=1e-3) assert_allclose(box1.get_pos(), np.array([0.0, 0.0, 0.25]), atol=1e-3) assert_allclose(box2.get_pos(), np.array([0.0, 0.0, 0.75]), atol=1e-3) assert_allclose(box3.get_pos(), np.array([0.0, 0.0, 0.75]), atol=1e-3) @pytest....
@@ -2928,6 +2928,52 @@ def test_mesh_primitive_COM(show_viewer, tol): assert_allclose(root_cube_z, cube_z, atol=tol) +@pytest.mark.required +@pytest.mark.parametrize("scale", [0.1, 10.0]) +@pytest.mark.parametrize("backend", [gs.cpu, gs.gpu]) +def test_noslip_iterations(scale, show_viewer, tol): + scene = g...
tests/test_rigid_physics.py
26
Python
0.143
question
32
51
51
false
[FEATURE] Add noslip solver
1,669
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 noslip solver BEFORE CODE: assert_allclose(cube_z, cube.get_links_pos(links_idx_local=[0], ref="link_com")[0, 2], atol=gs.EPS) assert_allclose(root_bunny_z, bunny.get_links_pos(links_idx_local=[0], re...
Are these options really useful?
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.required def test_batched_aabb(tol): scene = gs.Scene() plane = scene.add_entity( gs.morphs.Plane( normal=(0, 0, 1), pos=(0, 0, 0), ), ) box = scene.add_entity( gs.morphs.Box( size=(0.1, 0.1, 0.1), pos=(0.5, 0, 0.05),...
Use floats for floats: `(i * scale, 0.0, 0.0)`
assert_allclose(root_bunny_z, bunny_z, atol=tol) assert_allclose(root_cube_z, cube_z, atol=tol) @pytest.mark.required @pytest.mark.parametrize("scale", [0.1, 10.0]) @pytest.mark.parametrize("backend", [gs.cpu, gs.gpu]) def test_noslip_iterations(scale, show_viewer, tol): scene = gs.Scene( sim_opti...
@@ -2928,6 +2928,52 @@ def test_mesh_primitive_COM(show_viewer, tol): assert_allclose(root_cube_z, cube_z, atol=tol) +@pytest.mark.required +@pytest.mark.parametrize("scale", [0.1, 10.0]) +@pytest.mark.parametrize("backend", [gs.cpu, gs.gpu]) +def test_noslip_iterations(scale, show_viewer, tol): + scene = g...
tests/test_rigid_physics.py
26
Python
0.286
suggestion
46
44
51
false
[FEATURE] Add noslip solver
1,669
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 noslip solver BEFORE CODE: @pytest.mark.required def test_batched_aabb(tol): scene = gs.Scene() plane = scene.add_entity( gs.morphs.Plane( normal=(0, 0, 1), pos=(0, 0...
Use floats for floats: `(i * scale, 0.0, 0.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.
scene = gs.Scene( viewer_options=gs.options.ViewerOptions( camera_pos=(2.8, -1, 1.3), camera_lookat=(0.0, 0.0, 0.5), camera_fov=30, res=(960, 640), max_FPS=600, ), sim_options=gs.options.SimOptions( dt=0.01, ), ...
I would recommend adding parentheses: `fixed=(i == 0)`
gs.morphs.Plane(), ) bunny = scene.add_entity( gs.morphs.Mesh( file="meshes/bunny.obj", pos=(-1.0, -1.0, 1.0), ), vis_mode="collision", ) cube = scene.add_entity( gs.morphs.Box( size=(0.5, 0.5, 0.5), pos=(1.0, 1.0, 1...
@@ -2928,6 +2928,52 @@ def test_mesh_primitive_COM(show_viewer, tol): assert_allclose(root_cube_z, cube_z, atol=tol) +@pytest.mark.required +@pytest.mark.parametrize("scale", [0.1, 10.0]) +@pytest.mark.parametrize("backend", [gs.cpu, gs.gpu]) +def test_noslip_iterations(scale, show_viewer, tol): + scene = g...
tests/test_rigid_physics.py
26
Python
0.357
suggestion
54
51
51
false
[FEATURE] Add noslip solver
1,669
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 noslip solver BEFORE CODE: scene = gs.Scene( viewer_options=gs.options.ViewerOptions( camera_pos=(2.8, -1, 1.3), camera_lookat=(0.0, 0.0, 0.5), camera_fov=30, ...
I would recommend adding parentheses: `fixed=(i == 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.
boxes = [] for i in range(3): boxes.append( scene.add_entity( gs.morphs.Box( size=(1 * scale, 1 * scale, 1 * scale), pos=(i * scale, 0, 0), fixed=i == 0, ), ) ) scene.build() ...
I'm ok with using 3 boxes, but 2 boxes should be enough.
scene.build() rigid = scene.sim.rigid_solver for i in range(500): scene.step() link_COM = rigid.get_links_pos(ref="link_com") root_COM = rigid.get_links_pos(ref="root_com") bunny_z = link_COM[1, 2] cube_z = link_COM[2, 2] root_bunny_z = root_COM[1, 2] root_cube_z = root_COM[...
@@ -2928,6 +2928,52 @@ def test_mesh_primitive_COM(show_viewer, tol): assert_allclose(root_cube_z, cube_z, atol=tol) +@pytest.mark.required +@pytest.mark.parametrize("scale", [0.1, 10.0]) +@pytest.mark.parametrize("backend", [gs.cpu, gs.gpu]) +def test_noslip_iterations(scale, show_viewer, tol): + scene = g...
tests/test_rigid_physics.py
26
Python
0.286
suggestion
56
51
51
false
[FEATURE] Add noslip solver
1,669
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 noslip solver BEFORE CODE: boxes = [] for i in range(3): boxes.append( scene.add_entity( gs.morphs.Box( size=(1 * scale, 1 * scale, 1 * scale),...
I'm ok with using 3 boxes, but 2 boxes should be enough.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
), sim_options=gs.options.SimOptions( dt=0.01, ), profiling_options=gs.options.ProfilingOptions(show_FPS=False), rigid_options=gs.options.RigidOptions( noslip_iterations=5, ), show_viewer=show_viewer, ) boxes = [] for i in rang...
Ideally you should set the friction coefficient yourself, and set the normal force so that to box does not slip (with some safety factor, i.e. `F_n = 2.0 * box_mass * g / friction_coef`, make sure that the box does not move, then decrease the normal force using `F_n = 0.5 * box_mass * g / friction_coef` and check that...
vis_mode="collision", ) cube = scene.add_entity( gs.morphs.Box( size=(0.5, 0.5, 0.5), pos=(1.0, 1.0, 1.0), ), vis_mode="collision", ) ############# build ########################## scene.build() rigid = scene.sim.rigid_solver for i in r...
@@ -2928,6 +2928,52 @@ def test_mesh_primitive_COM(show_viewer, tol): assert_allclose(root_cube_z, cube_z, atol=tol) +@pytest.mark.required +@pytest.mark.parametrize("scale", [0.1, 10.0]) +@pytest.mark.parametrize("backend", [gs.cpu, gs.gpu]) +def test_noslip_iterations(scale, show_viewer, tol): + scene = g...
tests/test_rigid_physics.py
26
Python
0.643
performance
340
51
51
false
[FEATURE] Add noslip solver
1,669
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 noslip solver BEFORE CODE: ), sim_options=gs.options.SimOptions( dt=0.01, ), profiling_options=gs.options.ProfilingOptions(show_FPS=False), rigid_options=gs...
Ideally you should set the friction coefficient yourself, and set the normal force so that to box does not slip (with some safety factor, i.e. `F_n = 2.0 * box_mass * g / friction_coef`, make sure that the box does not move, then decrease the normal force using `F_n = 0.5 * box_mass * g / friction_coef` and check that...
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 import genesis.utils.array_class as array_class import genesis.engine.solvers.rigid.rigid_solver_decomp as rigid_solver @gs.maybe_pure @ti.kernel def kernel_build_efc_AR_b( dofs_state: array_class.DofsState, entities_info: array_class.EntitiesInfo, rigid_global_info: array_class.Rigi...
I would suggest to use either `i, j` or `i_r, i_c` instead of `r, c`
import genesis as gs import genesis.utils.array_class as array_class import genesis.engine.solvers.rigid.rigid_solver_decomp as rigid_solver @gs.maybe_pure @ti.kernel def kernel_build_efc_AR_b( dofs_state: array_class.DofsState, entities_info: array_class.EntitiesInfo, rigid_global_info: array_class.Rigi...
@@ -0,0 +1,331 @@ +import gstaichi as ti + +import genesis as gs +import genesis.utils.array_class as array_class + +import genesis.engine.solvers.rigid.rigid_solver_decomp as rigid_solver + + +@gs.maybe_pure +@ti.kernel +def kernel_build_efc_AR_b( + dofs_state: array_class.DofsState, + entities_info: array_class...
genesis/engine/solvers/rigid/constraint_noslip.py
26
Python
0.429
suggestion
68
51
51
false
[FEATURE] Add noslip solver
1,669
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/engine/solvers/rigid/constraint_noslip.py PR Title: [FEATURE] Add noslip solver BEFORE CODE: import genesis as gs import genesis.utils.array_class as array_class import genesis.engine.solvers.rigid.rigid_solver_decomp as rigid_solver @gs.maybe_pure ...
I would suggest to use either `i, j` or `i_r, i_c` instead of `r, c`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
ti.loop_config(serialize=static_rigid_sim_config.para_level < gs.PARA_LEVEL.PARTIAL) for i_b in range(_B): nefc = constraint_state.n_constraints[i_b] # zero AR for r in range(nefc): for c in range(nefc): constraint_state.efc_AR[r, c, i_b] = gs.ti_float(0.0) ...
replace `dot` by `*` for consistency with the above formula (even though it should probably be `@` everywhere instead)
ti.loop_config(serialize=static_rigid_sim_config.para_level < gs.PARA_LEVEL.PARTIAL) for i_b in range(_B): nefc = constraint_state.n_constraints[i_b] # zero AR for i_row in range(nefc): for i_col in range(nefc): constraint_state.efc_AR[i_row, i_col, i_b] = gs...
@@ -0,0 +1,331 @@ +import gstaichi as ti + +import genesis as gs +import genesis.utils.array_class as array_class + +import genesis.engine.solvers.rigid.rigid_solver_decomp as rigid_solver + + +@gs.maybe_pure +@ti.kernel +def kernel_build_efc_AR_b( + dofs_state: array_class.DofsState, + entities_info: array_class...
genesis/engine/solvers/rigid/constraint_noslip.py
26
Python
0.571
suggestion
118
51
51
false
[FEATURE] Add noslip solver
1,669
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/engine/solvers/rigid/constraint_noslip.py PR Title: [FEATURE] Add noslip solver BEFORE CODE: ti.loop_config(serialize=static_rigid_sim_config.para_level < gs.PARA_LEVEL.PARTIAL) for i_b in range(_B): nefc = constraint_state.n_constrain...
replace `dot` by `*` for consistency with the above formula (even though it should probably be `@` everywhere instead)
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 AR = J * inv(M) * J^T # do it row-by-row: for each row r, tmp = inv(M) * J[r]^T, then AR[r,:] = J * tmp for r in range(nefc): # tmp = M^{-1} * Jr^T for i_d in range(n_dofs): constraint_state.Mgrad[i_d, i_b] = constraint_state.jac[r, i_d, i_b] ...
Remove this comment if it is irrelevant. Do you think we will support other methods?
# build AR = J * inv(M) * J^T # do it row-by-row: for each row r, tmp = inv(M) * J[r]^T, then AR[r,:] = J * tmp for i_row in range(nefc): # tmp = M^{-1} * Jr^T for i_d in range(n_dofs): constraint_state.Mgrad[i_d, i_b] = constraint_state.jac[i_row, i_d, i_...
@@ -0,0 +1,331 @@ +import gstaichi as ti + +import genesis as gs +import genesis.utils.array_class as array_class + +import genesis.engine.solvers.rigid.rigid_solver_decomp as rigid_solver + + +@gs.maybe_pure +@ti.kernel +def kernel_build_efc_AR_b( + dofs_state: array_class.DofsState, + entities_info: array_class...
genesis/engine/solvers/rigid/constraint_noslip.py
26
Python
0.286
refactor
84
51
51
false
[FEATURE] Add noslip solver
1,669
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/engine/solvers/rigid/constraint_noslip.py PR Title: [FEATURE] Add noslip solver BEFORE CODE: # build AR = J * inv(M) * J^T # do it row-by-row: for each row r, tmp = inv(M) * J[r]^T, then AR[r,:] = J * tmp for r in range(nefc): ...
Remove this comment if it is irrelevant. Do you think we will support other methods?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
for i_d in range(n_dofs): s += constraint_state.jac[c, i_d, i_b] * constraint_state.Mgrad[i_d, i_b] constraint_state.efc_AR[r, c, i_b] = s # we don't need this term if we only use PGS for noslip # for r in range(nefc): # constraint_state.e...
Use `n_dofs = constraint_state.jac.shape[1]` for consistency.
for i_d in range(n_dofs): s += constraint_state.jac[i_col, i_d, i_b] * constraint_state.Mgrad[i_d, i_b] constraint_state.efc_AR[i_row, i_col, i_b] = s for i_c in range(constraint_state.n_constraints[i_b]): v = -constraint_state.aref[i_c, i_b] ...
@@ -0,0 +1,331 @@ +import gstaichi as ti + +import genesis as gs +import genesis.utils.array_class as array_class + +import genesis.engine.solvers.rigid.rigid_solver_decomp as rigid_solver + + +@gs.maybe_pure +@ti.kernel +def kernel_build_efc_AR_b( + dofs_state: array_class.DofsState, + entities_info: array_class...
genesis/engine/solvers/rigid/constraint_noslip.py
26
Python
0.429
style
61
51
51
false
[FEATURE] Add noslip solver
1,669
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/engine/solvers/rigid/constraint_noslip.py PR Title: [FEATURE] Add noslip solver BEFORE CODE: for i_d in range(n_dofs): s += constraint_state.jac[c, i_d, i_b] * constraint_state.Mgrad[i_d, i_b] constra...
Use `n_dofs = constraint_state.jac.shape[1]` for consistency.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
ti.loop_config(serialize=static_rigid_sim_config.para_level < gs.PARA_LEVEL.ALL) for i_b in range(_B): # temp variables res = ti.Vector.zero(gs.ti_float, 5) old_force = ti.Vector.zero(gs.ti_float, 5) bc = ti.Vector.zero(gs.ti_float, 5) Ac = ti.Vector.zero(gs.ti_float, 9...
just use `constraint_state.efc_force[i_c, i_b] ** 2`, it will be fine. You may use `* constraint_state.diag[i_c, i_b]` in place of `/ constraint_state.efc_D[i_c, i_b]` to avoid division, which is much slower than multiplication.
res = ti.Vector.zero(gs.ti_float, 5) old_force = ti.Vector.zero(gs.ti_float, 5) bc = ti.Vector.zero(gs.ti_float, 5) Ac = ti.Vector.zero(gs.ti_float, 9) n_con = collider_state.n_contacts[i_b] ne = constraint_state.n_constraints_equality[i_b] nf = constraint_state....
@@ -0,0 +1,331 @@ +import gstaichi as ti + +import genesis as gs +import genesis.utils.array_class as array_class + +import genesis.engine.solvers.rigid.rigid_solver_decomp as rigid_solver + + +@gs.maybe_pure +@ti.kernel +def kernel_build_efc_AR_b( + dofs_state: array_class.DofsState, + entities_info: array_class...
genesis/engine/solvers/rigid/constraint_noslip.py
26
Python
0.643
performance
231
51
51
false
[FEATURE] Add noslip solver
1,669
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/engine/solvers/rigid/constraint_noslip.py PR Title: [FEATURE] Add noslip solver BEFORE CODE: ti.loop_config(serialize=static_rigid_sim_config.para_level < gs.PARA_LEVEL.ALL) for i_b in range(_B): # temp variables res = ti.Vect...
just use `constraint_state.efc_force[i_c, i_b] ** 2`, it will be fine. You may use `* constraint_state.diag[i_c, i_b]` in place of `/ constraint_state.efc_D[i_c, i_b]` to avoid division, which is much slower than multiplication.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
for i_c in range(constraint_state.n_constraints[i_b]): constraint_state.qfrc_constraint[i_d, i_b] = ( constraint_state.qfrc_constraint[i_d, i_b] + constraint_state.jac[i_c, i_d, i_b] * constraint_state.efc_force[i_c, i_b] ) ri...
You should rename these two functions to be more specific.
for i_d in range(n_dofs): constraint_state.qacc[i_d, i_b] = constraint_state.qacc[i_d, i_b] + dofs_state.acc_smooth[i_d, i_b] dofs_state.acc[i_d, i_b] = constraint_state.qacc[i_d, i_b] dofs_state.qf_constraint[i_d, i_b] = constraint_state.qfrc_constraint[i_d, i_b] ...
@@ -0,0 +1,331 @@ +import gstaichi as ti + +import genesis as gs +import genesis.utils.array_class as array_class + +import genesis.engine.solvers.rigid.rigid_solver_decomp as rigid_solver + + +@gs.maybe_pure +@ti.kernel +def kernel_build_efc_AR_b( + dofs_state: array_class.DofsState, + entities_info: array_class...
genesis/engine/solvers/rigid/constraint_noslip.py
26
Python
0.286
suggestion
58
51
51
false
[FEATURE] Add noslip solver
1,669
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/engine/solvers/rigid/constraint_noslip.py PR Title: [FEATURE] Add noslip solver BEFORE CODE: for i_c in range(constraint_state.n_constraints[i_b]): constraint_state.qfrc_constraint[i_d, i_b] = ( constrai...
You should rename these two functions to be more specific.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
for j2 in range(2): j_efc = base + j2 * 2 res = func_residual( res=res, i_b=i_b, i_efc=j_efc, dim=2, flg_subR=True, cons...
Remove ` + 0`, I don't think it brings any value in this context.
Ac = func_extract_block_matrix_from_AR( Ac=Ac, i_b=i_b, start=j_efc, n=2, constraint_state=constraint_state, ) for j in ti.static(range(2)):...
@@ -0,0 +1,331 @@ +import gstaichi as ti + +import genesis as gs +import genesis.utils.array_class as array_class + +import genesis.engine.solvers.rigid.rigid_solver_decomp as rigid_solver + + +@gs.maybe_pure +@ti.kernel +def kernel_build_efc_AR_b( + dofs_state: array_class.DofsState, + entities_info: array_class...
genesis/engine/solvers/rigid/constraint_noslip.py
26
Python
0.429
suggestion
65
51
51
false
[FEATURE] Add noslip solver
1,669
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/engine/solvers/rigid/constraint_noslip.py PR Title: [FEATURE] Add noslip solver BEFORE CODE: for j2 in range(2): j_efc = base + j2 * 2 res = func_residual( res=res, ...
Remove ` + 0`, I don't think it brings any value in this context.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
base = const_start + i_col * 4 mu = collider_state.contact_data.friction[i_col, i_b] for j2 in range(2): j_efc = base + j2 * 2 res = func_residual( res=res, i_b=i_b, ...
Prefer `i, j, k, l, ...` over `i1, i2, i3, i4, ...`
for i2 in ti.static(range(2)): old_force[i2] = constraint_state.efc_force[j_efc + i2, i_b] Ac = func_extract_block_matrix_from_AR( Ac=Ac, i_b=i_b, start=j_efc, ...
@@ -0,0 +1,331 @@ +import gstaichi as ti + +import genesis as gs +import genesis.utils.array_class as array_class + +import genesis.engine.solvers.rigid.rigid_solver_decomp as rigid_solver + + +@gs.maybe_pure +@ti.kernel +def kernel_build_efc_AR_b( + dofs_state: array_class.DofsState, + entities_info: array_class...
genesis/engine/solvers/rigid/constraint_noslip.py
26
Python
0.429
suggestion
52
51
51
false
[FEATURE] Add noslip solver
1,669
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/engine/solvers/rigid/constraint_noslip.py PR Title: [FEATURE] Add noslip solver BEFORE CODE: base = const_start + i_col * 4 mu = collider_state.contact_data.friction[i_col, i_b] for j2 in range(2): ...
Prefer `i, j, k, l, ...` over `i1, i2, i3, i4, ...`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
) rigid_solver.func_solve_mass_batched( vec=constraint_state.qfrc_constraint, out=constraint_state.qacc, i_b=i_b, entities_info=entities_info, rigid_global_info=rigid_global_info, static_rigid_sim_config=static_rigid_sim_co...
Remove this parameter if unused. I can add it back later if necessary.
dofs_state.qf_constraint[i_d, i_b] = constraint_state.qfrc_constraint[i_d, i_b] dofs_state.force[i_d, i_b] = dofs_state.qf_smooth[i_d, i_b] + constraint_state.qfrc_constraint[i_d, i_b] @ti.func def func_extract_block_matrix_from_AR( Ac, i_b: int, start: int, n: int, constra...
@@ -0,0 +1,331 @@ +import gstaichi as ti + +import genesis as gs +import genesis.utils.array_class as array_class + +import genesis.engine.solvers.rigid.rigid_solver_decomp as rigid_solver + + +@gs.maybe_pure +@ti.kernel +def kernel_build_efc_AR_b( + dofs_state: array_class.DofsState, + entities_info: array_class...
genesis/engine/solvers/rigid/constraint_noslip.py
26
Python
0.286
refactor
70
51
51
false
[FEATURE] Add noslip solver
1,669
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/engine/solvers/rigid/constraint_noslip.py PR Title: [FEATURE] Add noslip solver BEFORE CODE: ) rigid_solver.func_solve_mass_batched( vec=constraint_state.qfrc_constraint, out=constraint_state.qacc, ...
Remove this parameter if unused. I can add it back later if necessary.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
return res @ti.func def func_cost_change( i_b: int, Ac, force: array_class.V_ANNOTATION, force_start: int, old_force, res, dim: int, ): change = gs.ti_float(0.0) if dim == 1: delta = force[force_start + 0, i_b] - old_force[0] change = 0.5 * Ac[0] * delta * delta...
Avoid hard-coded constant in the implementation. What is this supposed to be? It should either be some exposed parameter, `gs.EPS`, or at least some global constant defined in uppercase right after the imports.
change += delta[i] * res[i] if change > gs.EPS: for i in range(dim): force[force_start + i, i_b] = old_force[i] change = 0.0 return change @gs.maybe_pure @ti.kernel def compute_A_diag( rigid_global_info: array_class.RigidGlobalInfo, constraint_state: array_class...
@@ -0,0 +1,331 @@ +import gstaichi as ti + +import genesis as gs +import genesis.utils.array_class as array_class + +import genesis.engine.solvers.rigid.rigid_solver_decomp as rigid_solver + + +@gs.maybe_pure +@ti.kernel +def kernel_build_efc_AR_b( + dofs_state: array_class.DofsState, + entities_info: array_class...
genesis/engine/solvers/rigid/constraint_noslip.py
26
Python
0.643
suggestion
210
51
46
false
[FEATURE] Add noslip solver
1,669
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/engine/solvers/rigid/constraint_noslip.py PR Title: [FEATURE] Add noslip solver BEFORE CODE: return res @ti.func def func_cost_change( i_b: int, Ac, force: array_class.V_ANNOTATION, force_start: int, old_force, res, di...
Avoid hard-coded constant in the implementation. What is this supposed to be? It should either be some exposed parameter, `gs.EPS`, or at least some global constant defined in uppercase 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("n_cubes", [5]) @pytest.mark.parametrize("enable_island", [False]) @pytest.mark.parametrize("n_envs", [2048]) @pytest.mark.parametrize( "gjk, enable_mujoco_compatibility", [ (False, True), # MPR (False, False), # MPR+SDF (True, False), # GJK ], ) def test_...
* Why are you adding this in benchmarks? * You should mark this test as required * You should explicitly check for something, or document why it is not necessary * Are you sure doing one step is necessary? Build is not enough?
import hashlib import numbers import os import time from enum import Enum from pathlib import Path from typing import Any import numpy as np import pytest import torch import wandb import genesis as gs from .utils import ( get_hardware_fingerprint, get_platform_fingerprint, get_git_commit_timestamp, ...
@@ -684,3 +684,20 @@ def test_box_pyramid(factory_logger, request, n_cubes, solver, enable_island, n_ } ) as logger: logger.write(request.getfixturevalue("box_pyramid")) + + +@pytest.mark.parametrize("batch_links_info", [False, True])
tests/test_rigid_benchmarks.py
26
Python
0.5
question
229
41
687
false
[BUG FIX] Fix entity idx to be always int when loading terrain with batch_links_info.
1,691
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Kashu7100
Review this pull request change. Language: Python File: tests/test_rigid_benchmarks.py PR Title: [BUG FIX] Fix entity idx to be always int when loading terrain with batch_links_info. BEFORE CODE: @pytest.mark.parametrize("n_cubes", [5]) @pytest.mark.parametrize("enable_island", [False]) @pytest.mark.parametrize("n_...
* Why are you adding this in benchmarks? * You should mark this test as required * You should explicitly check for something, or document why it is not necessary * Are you sure doing one step is necessary? Build is not enough?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import pathlib import pytest import subprocess import sys import os import argparse import genesis as gs TEST_RAN = "test ran" def gs_static_child(args: list[str]): parser = argparse.ArgumentParser() parser.add_argument("--enable-multi-contact", action="store_true") parser.add_argument("--expected-num-...
Cross-referencing my comment here: https://github.com/Genesis-Embodied-AI/gstaichi/pull/177/files#r2337243300
import pathlib import pytest import subprocess import sys import os import argparse import genesis as gs RET_SUCCESS = 42 def gs_static_child(args: list[str]): parser = argparse.ArgumentParser() parser.add_argument("--enable-multi-contact", action="store_true") parser.add_argument("--expected-num-conta...
tests/test_fastcache_unified.py
1
Python
0.357
suggestion
109
26
26
false
[BUG FIX] Improve robustness of gstaichi fast-cache unit tests.
1,709
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
hughperkins
Review this pull request change. Language: Python File: tests/test_fastcache_unified.py PR Title: [BUG FIX] Improve robustness of gstaichi fast-cache unit tests. BEFORE CODE: import pathlib import pytest import subprocess import sys import os import argparse import genesis as gs TEST_RAN = "test ran" def gs_st...
Cross-referencing my comment here: https://github.com/Genesis-Embodied-AI/gstaichi/pull/177/files#r2337243300
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.
""" Copy the tensor into the next position of the ring buffer, and advance the index pointer. Parameters ---------- tensor : torch.Tensor The tensor to copy into the ring buffer. """ self.buffer[self._idx_ptr.value].copy_(tensor) self._idx_ptr...
I need to figure this out still.. It works when i do arange.. When using :batch_size and reshapes or squeeze(1) or having ifs i could not get it to work for both batched/unbatched case. I was tired when I tried last night though. Help is appreciated 🥲
def append(self, tensor: torch.Tensor): """ Copy the tensor into the next position of the ring buffer, and advance the index pointer. Parameters ---------- tensor : torch.Tensor The tensor to copy into the ring buffer. """ self.buffer[self._idx].c...
@@ -67,7 +67,8 @@ def at(self, idx: int | torch.Tensor) -> torch.Tensor: rel_idx = (self._idx_ptr.value - idx) % self.N if isinstance(idx, torch.Tensor): batch_size = len(idx) if idx.ndim > 0 else 1 - return self.buffer[rel_idx, :batch_size] + batch_indices = torch.a...
genesis/utils/ring_buffer.py
26
Python
0.5
performance
251
51
51
false
[BUG FIX] Add tests for adding multiple sensors and envs.
1,726
Genesis-Embodied-AI/Genesis
26,702
Python
Milotrince
Milotrince
Review this pull request change. Language: Python File: genesis/utils/ring_buffer.py PR Title: [BUG FIX] Add tests for adding multiple sensors and envs. BEFORE CODE: """ Copy the tensor into the next position of the ring buffer, and advance the index pointer. Parameters ---------- ...
I need to figure this out still.. It works when i do arange.. When using :batch_size and reshapes or squeeze(1) or having ifs i could not get it to work for both batched/unbatched case. I was tired when I tried last night though. Help is appreciated 🥲
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.
""" Copy the tensor into the next position of the ring buffer, and advance the index pointer. Parameters ---------- tensor : torch.Tensor The tensor to copy into the ring buffer. """ self.buffer[self._idx_ptr.value].copy_(tensor) self._idx_ptr...
I think there is still something funky going on with the indexing and/or delay handling. I will try to add another test tomorrow.
def append(self, tensor: torch.Tensor): """ Copy the tensor into the next position of the ring buffer, and advance the index pointer. Parameters ---------- tensor : torch.Tensor The tensor to copy into the ring buffer. """ self.buffer[self._idx].c...
@@ -67,7 +67,8 @@ def at(self, idx: int | torch.Tensor) -> torch.Tensor: rel_idx = (self._idx_ptr.value - idx) % self.N if isinstance(idx, torch.Tensor): batch_size = len(idx) if idx.ndim > 0 else 1 - return self.buffer[rel_idx, :batch_size] + # using [tensor_indices...
genesis/utils/ring_buffer.py
26
Python
0.357
suggestion
129
51
51
false
[BUG FIX] Add tests for adding multiple sensors and envs.
1,726
Genesis-Embodied-AI/Genesis
26,702
Python
Milotrince
Milotrince
Review this pull request change. Language: Python File: genesis/utils/ring_buffer.py PR Title: [BUG FIX] Add tests for adding multiple sensors and envs. BEFORE CODE: """ Copy the tensor into the next position of the ring buffer, and advance the index pointer. Parameters ---------- ...
I think there is still something funky going on with the indexing and/or delay handling. I will try to add another test tomorrow.
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._shared_metadata.expanded_links_idx = concat_with_tensor( self._shared_metadata.expanded_links_idx, self._options.entity_idx + self._options.link_idx_local, expand=(self._manager._sim._B, 1, -1), dim=-1, ) def _get_return_format(self) -> tuple[i...
Concatenating is probably less efficient that loop over the two arrays separately I think.
link_start = self._shared_metadata.solver.entities[self._options.entity_idx].link_start self._shared_metadata.expanded_links_idx = concat_with_tensor( self._shared_metadata.expanded_links_idx, link_start + self._options.link_idx_local, expand=(1,), dim=0,...
@@ -127,9 +123,12 @@ def _update_shared_ground_truth_cache( cls, shared_metadata: ContactSensorMetadata, shared_ground_truth_cache: torch.Tensor ): all_contacts = shared_metadata.solver.collider.get_contacts(as_tensor=True, to_torch=True) - contact_links = torch.cat([all_contacts["link_a"]...
genesis/sensors/contact_force.py
26
Python
0.214
performance
90
51
51
false
[BUG FIX] Add tests for adding multiple sensors and envs.
1,726
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/contact_force.py PR Title: [BUG FIX] Add tests for adding multiple sensors and envs. BEFORE CODE: self._shared_metadata.expanded_links_idx = concat_with_tensor( self._shared_metadata.expanded_links_idx, self._op...
Concatenating is probably less efficient that loop over the two arrays separately 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.
codec_options: dict[str, str] Additional low-level codec options that will be pass to ffmpeg. Empty by default. save_on_reset: bool, optional Whether to save the data on reset. If True, a counter will be added to the filename and incremented on each reset. Defaults to False. """ ...
this line will run during import time, which will trigger error if `IS_PYAV_AVAILABLE=False`
codec_options: dict[str, str] Additional low-level codec options that will be pass to ffmpeg. Empty by default. save_on_reset: bool, optional Whether to save the data on reset. If True, a counter will be added to the filename and incremented on each reset. Defaults to False. """ ...
@@ -119,19 +119,14 @@ def validate(self): @register_recording(VideoFileWriterOptions) class VideoFileWriter(BaseFileWriter): - video_container: av.container.OutputContainer | None
genesis/recorders/file_writers.py
26
Python
0.5
suggestion
92
51
51
false
[BUG FIX] fix single_franka_envs example
1,743
Genesis-Embodied-AI/Genesis
26,702
Python
YilingQiao
YilingQiao
Review this pull request change. Language: Python File: genesis/recorders/file_writers.py PR Title: [BUG FIX] fix single_franka_envs example BEFORE CODE: codec_options: dict[str, str] Additional low-level codec options that will be pass to ffmpeg. Empty by default. save_on_reset: bool, optional ...
this line will run during import time, which will trigger error if `IS_PYAV_AVAILABLE=False`
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 gs.logger.timer("Running convex decomposition."): mesh = coacd.Mesh(mesh.vertices, mesh.faces) args = coacd_options result = coacd.run_coacd( mesh, threshold=args.threshold, max_convex_hull=args.max_convex_hull, ...
I don't know what you are trying to do here, but this is clearly invalid code.
with gs.logger.timer("Running convex decomposition."): mesh = coacd.Mesh(mesh.vertices, mesh.faces) args = coacd_options result = coacd.run_coacd( mesh, threshold=args.threshold, max_convex_hull=args.max_convex_hull, ...
@@ -300,6 +333,7 @@ def convex_decompose(mesh, coacd_options): mesh_parts = [] for vs, fs in result: mesh_parts.append(trimesh.Trimesh(vs, fs)) + mesh_parts.append(mesh_scale)
genesis/utils/mesh.py
26
Python
0.214
suggestion
78
51
51
false
[FEATURE] Make convex decomposition cache scale-invariant.
1,810
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
SonSang
Review this pull request change. Language: Python File: genesis/utils/mesh.py PR Title: [FEATURE] Make convex decomposition cache scale-invariant. BEFORE CODE: with gs.logger.timer("Running convex decomposition."): mesh = coacd.Mesh(mesh.vertices, mesh.faces) args = coacd_options ...
I don't know what you are trying to do here, but this is clearly invalid 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.
file="meshes/duck.obj", scale=second_scale, pos=(1.0, 0, 1.0), quat=(1, 0, 0, 0), ), ) scene.build() assert len(seen_paths) == 2, "Expected 2 cache paths, got %d" % len(seen_paths) assert len(seen_results) == 2, "Expected 2 convex decomposition re...
You have `assert_array_equal` for this but no big deal.
import os import sys import numpy as np import pytest import trimesh import genesis as gs import genesis.utils.gltf as gltf_utils import genesis.utils.usda as usda_utils import genesis.utils.mesh as mesh_utils from .utils import assert_allclose, assert_array_equal, get_hf_dataset VERTICES_TOL = 1e-05 # Transforma...
@@ -510,3 +511,79 @@ def test_splashsurf_surface_reconstruction(show_viewer): ) scene.build() cam.render(rgb=True, depth=False, segmentation=False, colorize_seg=False, normal=False) + + +@pytest.mark.required +def test_convex_decompose_cache(monkeypatch): + # Check if the convex decomposition cache is...
tests/test_mesh.py
26
Python
0.357
suggestion
55
27
587
false
[FEATURE] Make convex decomposition cache scale-invariant.
1,810
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
SonSang
Review this pull request change. Language: Python File: tests/test_mesh.py PR Title: [FEATURE] Make convex decomposition cache scale-invariant. BEFORE CODE: file="meshes/duck.obj", scale=second_scale, pos=(1.0, 0, 1.0), quat=(1, 0, 0, 0), ), ) scene.bu...
You have `assert_array_equal` for this but no big deal.
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.
second_scale = 4.0 duck = scene.add_entity( morph=gs.morphs.Mesh( file="meshes/duck.obj", scale=second_scale, pos=(1.0, 0, 1.0), quat=(1, 0, 0, 0), ), ) scene.build() assert len(seen_paths) == 2, "Expected 2 cache paths, got %d" % len(...
I don't think it is necessary to add this assert comments. It is self-explanatory here, and right and left side values of equality checks while be displayed automatically by pytest.
second_scale = 4.0 duck = scene.add_entity( morph=gs.morphs.Mesh( file="meshes/duck.obj", scale=second_scale, pos=(1.0, 0, 1.0), quat=(1, 0, 0, 0), ), ) scene.build() assert len(seen_paths) == 2 assert len(seen_results) == 2 #...
@@ -510,3 +511,79 @@ def test_splashsurf_surface_reconstruction(show_viewer): ) scene.build() cam.render(rgb=True, depth=False, segmentation=False, colorize_seg=False, normal=False) + + +@pytest.mark.required +def test_convex_decompose_cache(monkeypatch): + # Check if the convex decomposition cache is...
tests/test_mesh.py
26
Python
0.357
suggestion
181
30
27
false
[FEATURE] Make convex decomposition cache scale-invariant.
1,810
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
SonSang
Review this pull request change. Language: Python File: tests/test_mesh.py PR Title: [FEATURE] Make convex decomposition cache scale-invariant. BEFORE CODE: second_scale = 4.0 duck = scene.add_entity( morph=gs.morphs.Mesh( file="meshes/duck.obj", scale=second_scale, ...
I don't think it is necessary to add this assert comments. It is self-explanatory here, and right and left side values of equality checks while be displayed automatically by pytest.
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.
d, i_g, i_b, ): """ Count the number of valid support points for the given world direction. """ d_mesh = gu.ti_transform_by_quat(d, gu.ti_inv_quat(geoms_state.quat[i_g, i_b])) return _func_count_supports_mesh( geoms_state, geoms_info, support_field_info, support_field_static_conf...
changing comments are not necessary
d, i_g, i_b, ): """ Count the number of valid support points for the given world direction. """ d_mesh = gu.ti_transform_by_quat(d, gu.ti_inv_quat(geoms_state.quat[i_g, i_b])) return _func_count_supports_mesh( geoms_state, geoms_info, support_field_info, support_field_static_conf...
@@ -350,14 +350,14 @@ def _func_count_supports_mesh( """ Count the number of valid support points for a mesh in the given direction. """ - theta = ti.atan2(d_mesh[1], d_mesh[0]) # [-pi, pi] - phi = ti.acos(d_mesh[2]) # [0, pi] + theta = ti.atan2(d_mesh[1], d_mesh[0]) # [-math.pi, math.pi]
genesis/engine/solvers/rigid/support_field_decomp.py
26
Python
0.071
suggestion
35
51
51
false
[MISC] Import math module instead of constants to avoid violating gstaichi pure checker.
1,812
Genesis-Embodied-AI/Genesis
26,702
Python
YilingQiao
hughperkins
Review this pull request change. Language: Python File: genesis/engine/solvers/rigid/support_field_decomp.py PR Title: [MISC] Import math module instead of constants to avoid violating gstaichi pure checker. BEFORE CODE: d, i_g, i_b, ): """ Count the number of valid support points for the given ...
changing comments are not necessary
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
i_g, i_b, ): """ support position for a world direction """ g_pos = geoms_state.pos[i_g, i_b] g_quat = geoms_state.quat[i_g, i_b] d_mesh = gu.ti_transform_by_quat(d, gu.ti_inv_quat(g_quat)) v_, vid = _func_support_mesh(support_field_info, support_field_static_config, d_mesh, i_g) ...
changing comments are not necessary
i_g, i_b, ): """ support position for a world direction """ g_pos = geoms_state.pos[i_g, i_b] g_quat = geoms_state.quat[i_g, i_b] d_mesh = gu.ti_transform_by_quat(d, gu.ti_inv_quat(g_quat)) v_, vid = _func_support_mesh(support_field_info, support_field_static_config, d_mesh, i_g) ...
@@ -154,16 +154,16 @@ def _func_support_mesh( """ support point at mesh frame coordinate. """ - theta = ti.atan2(d_mesh[1], d_mesh[0]) # [-pi, pi] - phi = ti.acos(d_mesh[2]) # [0, pi] + theta = ti.atan2(d_mesh[1], d_mesh[0]) # [-math.pi, math.pi]
genesis/engine/solvers/rigid/support_field_decomp.py
26
Python
0.071
suggestion
35
51
51
false
[MISC] Import math module instead of constants to avoid violating gstaichi pure checker.
1,812
Genesis-Embodied-AI/Genesis
26,702
Python
YilingQiao
hughperkins
Review this pull request change. Language: Python File: genesis/engine/solvers/rigid/support_field_decomp.py PR Title: [MISC] Import math module instead of constants to avoid violating gstaichi pure checker. BEFORE CODE: i_g, i_b, ): """ support position for a world direction """ g_pos = ge...
changing comments are not necessary
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# 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 else: # Apply only those defaults th...
I don't like this entire logic duplication. I hope there should be a better way. We put a lot of effort into unifying URDF and MJCF loading, it would be a shame to do a step back.
mj.body_invweight0[:] = 0.0 mj.dof_invweight0[:] = 0.0 elif isinstance(xml, mujoco.MjModel): mj = xml else: raise gs.raise_exception(f"'{xml}' is not a valid MJCF file.") return mj def parse_xml(morph, surface): # Always merge fixed links unless...
@@ -138,6 +145,26 @@ def build_model(xml, discard_visual, default_armature=None, merge_fixed_links=Fa mj.dof_armature[:] = default_armature mj.body_invweight0[:] = 0.0 mj.dof_invweight0[:] = 0.0 + else: + # Apply only those default...
genesis/utils/mjcf.py
26
Python
0.429
suggestion
179
51
51
false
[BUG FIX] Fix loading MJCF file with includes.
1,838
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/utils/mjcf.py PR Title: [BUG FIX] Fix loading MJCF file with includes. BEFORE CODE: # Set default rotor armature inertia if default_armature is not None: mj.dof_armature[:] = default_armature ...
I don't like this entire logic duplication. I hope there should be a better way. We put a lot of effort into unifying URDF and MJCF loading, it would be a shame to do a step back.
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 .patterns import DepthCameraPattern from .raycaster import RaycasterData, RaycasterOptions, RaycasterSensor, RaycasterSharedMetadata class DepthCameraOptions(RaycasterOptions): """ Depth camera that uses ray casting to obtain depth images. Parameters ---------- pattern: DepthCameraPattern ...
This is not readable. You should rather do: ```python batch_shape = (self._manager._sim._B,) if self._manager._sim.n_envs > 0 else () self._shape = (*batch_shape, self._options.pattern.height, self._options.pattern.width) ```
from .patterns import DepthCameraPattern from .raycaster import RaycasterData, RaycasterOptions, RaycasterSensor, RaycasterSharedMetadata class DepthCameraOptions(RaycasterOptions): """ Depth camera that uses ray casting to obtain depth images. Parameters ---------- pattern: DepthCameraPattern ...
@@ -21,6 +21,14 @@ class DepthCameraOptions(RaycasterOptions): @register_sensor(DepthCameraOptions, RaycasterSharedMetadata, RaycasterData) class DepthCameraSensor(RaycasterSensor): + + def build(self): + super().build() + self._shape = ((self._manager._sim._B,) if self._manager._sim.n_envs > 0 els...
genesis/sensors/raycaster/depth_camera.py
26
Python
0.857
performance
225
40
38
false
[BUG FIX] Fix DepthCamera sensor.
1,842
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/raycaster/depth_camera.py PR Title: [BUG FIX] Fix DepthCamera sensor. BEFORE CODE: from .patterns import DepthCameraPattern from .raycaster import RaycasterData, RaycasterOptions, RaycasterSensor, RaycasterSharedMetadata class DepthCameraOpti...
This is not readable. You should rather do: ```python batch_shape = (self._manager._sim._B,) if self._manager._sim.n_envs > 0 else () self._shape = (*batch_shape, self._options.pattern.height, self._options.pattern.width) ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# Update the differentiable contact data. gjk_state.contact_pos[i_b, insert_id] = contact_pos gjk_state.normal[i_b, insert_id] = contact_normal gjk_state.diff_penetration[i_b, insert_id] = diff_penetration # Update the non-differentiable contact data for the backward pass. ...
`gjk_state.is_col[i_b] = n_contacts > 0`
# Update the differentiable contact data. gjk_state.contact_pos[i_b, insert_id] = contact_pos gjk_state.normal[i_b, insert_id] = contact_normal gjk_state.diff_penetration[i_b, insert_id] = diff_penetration # Update the non-differentiable contact data for the backward pass. ...
@@ -342,7 +342,7 @@ def func_gjk_contact( break gjk_state.n_contacts[i_b] = n_contacts - gjk_state.is_col[i_b] = 1 if n_contacts > 0 else 0 + gjk_state.is_col[i_b] = True if n_contacts > 0 else False
genesis/engine/solvers/rigid/diff_gjk_decomp.py
26
Python
0.214
suggestion
40
51
51
false
[BUG FIX] Fixed minor bug in differentiable contact detection.
1,864
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
SonSang
Review this pull request change. Language: Python File: genesis/engine/solvers/rigid/diff_gjk_decomp.py PR Title: [BUG FIX] Fixed minor bug in differentiable contact detection. BEFORE CODE: # Update the differentiable contact data. gjk_state.contact_pos[i_b, insert_id] = contact_pos gjk_stat...
`gjk_state.is_col[i_b] = n_contacts > 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.
gjk_state.contact_pos[i_b, insert_id] = contact_pos gjk_state.normal[i_b, insert_id] = contact_normal gjk_state.diff_penetration[i_b, insert_id] = diff_penetration # Update the non-differentiable contact data for the backward pass. gjk_state.diff_contact_input.local_pos1_a[i_b, ...
This one should also be a boolean.
gjk_state.contact_pos[i_b, insert_id] = contact_pos gjk_state.normal[i_b, insert_id] = contact_normal gjk_state.diff_penetration[i_b, insert_id] = diff_penetration # Update the non-differentiable contact data for the backward pass. gjk_state.diff_contact_input.local_pos1_a[i_b, ...
@@ -342,7 +342,7 @@ def func_gjk_contact( break gjk_state.n_contacts[i_b] = n_contacts - gjk_state.is_col[i_b] = 1 if n_contacts > 0 else 0 + gjk_state.is_col[i_b] = True if n_contacts > 0 else False gjk_state.multi_contact_flag[i_b] = 1
genesis/engine/solvers/rigid/diff_gjk_decomp.py
26
Python
0.143
suggestion
34
51
51
false
[BUG FIX] Fixed minor bug in differentiable contact detection.
1,864
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
SonSang
Review this pull request change. Language: Python File: genesis/engine/solvers/rigid/diff_gjk_decomp.py PR Title: [BUG FIX] Fixed minor bug in differentiable contact detection. BEFORE CODE: gjk_state.contact_pos[i_b, insert_id] = contact_pos gjk_state.normal[i_b, insert_id] = contact_normal ...
This one should also be a boolean.
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.
E=3.0e4, nu=0.45, rho=1000.0, model="stable_neohookean", ), ) scene.build(n_envs=2) mpm_cube_pos = mpm_cube.get_particles_pos() cloth_pos = cloth.get_particles_pos() water_pos = water.get_particles_pos() mpm_cube_active = mpm_cube.get_par...
It is not checking much, just that the API is available. Not really useful. The optional arguments are not tested and the returned value is completely ignored. It would be nice to check that the value is correct, and if too complicated, at least checking that it makes sense (i.e. non-zero and in valid range). You shoul...
) scene.build(n_envs=2) init_mpm_cube_pos = mpm_cube.get_particles_pos() init_cloth_pos = cloth.get_particles_pos() init_water_pos = water.get_particles_pos() scene.get_state() for i in range(1500): scene.step() final_mpm_cube_pos = mpm_cube.get_particles_pos() final_cloth...
@@ -191,6 +191,25 @@ def test_deformable_parallel(show_viewer): ) scene.build(n_envs=2) + mpm_cube_pos = mpm_cube.get_particles_pos() + cloth_pos = cloth.get_particles_pos() + water_pos = water.get_particles_pos() + + mpm_cube_active = mpm_cube.get_particles_active() + cloth_active = cloth.ge...
tests/test_deformable_physics.py
26
Python
0.5
suggestion
476
51
51
false
[MISC] Add get_particles_pos to sph
1,871
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: tests/test_deformable_physics.py PR Title: [MISC] Add get_particles_pos to sph BEFORE CODE: E=3.0e4, nu=0.45, rho=1000.0, model="stable_neohookean", ), ) scene.build(n_envs=2) mpm_cube_pos = ...
It is not checking much, just that the API is available. Not really useful. The optional arguments are not tested and the returned value is completely ignored. It would be nice to check that the value is correct, and if too complicated, at least checking that it makes sense (i.e. non-zero and in valid range). You shoul...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
assert_allclose(state.vel, 0.0, tol=2e-2) # Landed vertically pos = tensor_to_array(state.pos.squeeze(0)) BV, *_ = igl.bounding_box(pos) entity_center = 0.5 * (BV[0] + BV[-1]) if coupler_type == gs.options.SAPCouplerOptions: tol = 1e-2 if material_model == "l...
hope we can reduce the time and mark them required in the near future
assert_allclose(state.vel, 0.0, tol=2e-2) # Landed vertically pos = tensor_to_array(state.pos.squeeze(0)) BV, *_ = igl.bounding_box(pos) entity_center = 0.5 * (BV[0] + BV[-1]) if coupler_type == gs.options.SAPCouplerOptions: tol = 1e-2 if material_model == "l...
@@ -255,7 +255,8 @@ def test_implicit_falling_sphere_box(coupler_type, material_model, show_viewer): assert_allclose(-state.pos[..., 2].min(), penetration_depth_ref, tol=tol) -@pytest.mark.required +# This test cannot be flagged as required because it takes 250s to run on CPU.
tests/test_fem.py
26
Python
0.214
suggestion
69
51
51
false
[BUG FIX] Fix sensor recorder Matplotlib plotter on Linux and Windows.
1,894
Genesis-Embodied-AI/Genesis
26,702
Python
YilingQiao
duburcqa
Review this pull request change. Language: Python File: tests/test_fem.py PR Title: [BUG FIX] Fix sensor recorder Matplotlib plotter on Linux and Windows. BEFORE CODE: assert_allclose(state.vel, 0.0, tol=2e-2) # Landed vertically pos = tensor_to_array(state.pos.squeeze(0)) BV, *_ = ...
hope we can reduce the time and mark them required in the near future
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.
mass_mat_L, mass_mat_D_inv = franka1.get_mass_mat(decompose=True) mass_mat = mass_mat_L.T @ torch.diag(1.0 / mass_mat_D_inv) @ mass_mat_L assert_allclose(mass_mat, mass_mat_1, tol=tol) @pytest.mark.required @pytest.mark.parametrize("model_name", ["hinge_slide"]) @pytest.mark.parametrize("gs_solver", [gs.c...
You must use our custom `assert_allclose`
mass_mat_L, mass_mat_D_inv = franka1.get_mass_mat(decompose=True) mass_mat = mass_mat_L.T @ torch.diag(1.0 / mass_mat_D_inv) @ mass_mat_L assert_allclose(mass_mat, mass_mat_1, tol=tol) @pytest.mark.required @pytest.mark.parametrize("model_name", ["hinge_slide"]) @pytest.mark.parametrize("gs_solver", [gs.c...
@@ -1692,12 +1692,16 @@ def test_set_dofs_frictionloss_physics(gs_sim, tol): robot.set_dofs_velocity(initial_velocity) robot.set_dofs_frictionloss(np.array([0.0, 0.0])) + frictionloss = robot.get_dofs_frictionloss() + np.testing.assert_allclose(frictionloss, np.array([0.0, 0.0]), atol=tol) for _ ...
tests/test_rigid_physics.py
26
Python
0.286
suggestion
41
51
51
false
[FEATURE] Add Rigid ‘get_dofs_frictionloss’ public API method.
1,904
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
ax-anoop
Review this pull request change. Language: Python File: tests/test_rigid_physics.py PR Title: [FEATURE] Add Rigid ‘get_dofs_frictionloss’ public API method. BEFORE CODE: mass_mat_L, mass_mat_D_inv = franka1.get_mass_mat(decompose=True) mass_mat = mass_mat_L.T @ torch.diag(1.0 / mass_mat_D_inv) @ mass_mat_L ...
You must use our custom `assert_allclose`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
(robot,) = gs_sim.entities initial_velocity = np.array([1.0, 0.0]) robot.set_dofs_velocity(initial_velocity) robot.set_dofs_frictionloss(np.array([0.0, 0.0])) frictionloss = robot.get_dofs_frictionloss().cpu().numpy() np.testing.assert_allclose(frictionloss, np.array([0.0, 0.0]), atol=tol) ...
No need to apply `.cpu().numpy()` if you use `assert_allclose`
(robot,) = gs_sim.entities initial_velocity = np.array([1.0, 0.0]) robot.set_dofs_velocity(initial_velocity) robot.set_dofs_frictionloss(np.array([0.0, 0.0])) frictionloss = robot.get_dofs_frictionloss() assert_allclose(frictionloss, np.array([0.0, 0.0]), atol=tol) for _ in range(10): ...
@@ -1707,6 +1711,8 @@ def test_set_dofs_frictionloss_physics(gs_sim, tol): robot.set_dofs_velocity(initial_velocity) robot.set_dofs_frictionloss(np.array([0.5]), dofs_idx_local=[0]) + frictionloss = robot.get_dofs_frictionloss(dofs_idx_local=[0]).cpu().numpy()
tests/test_rigid_physics.py
26
Python
0.429
suggestion
62
51
51
false
[FEATURE] Add Rigid ‘get_dofs_frictionloss’ public API method.
1,904
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
ax-anoop
Review this pull request change. Language: Python File: tests/test_rigid_physics.py PR Title: [FEATURE] Add Rigid ‘get_dofs_frictionloss’ public API method. BEFORE CODE: (robot,) = gs_sim.entities initial_velocity = np.array([1.0, 0.0]) robot.set_dofs_velocity(initial_velocity) robot.set_dofs_fric...
No need to apply `.cpu().numpy()` if you use `assert_allclose`
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.
# Support field used for mpr and gjk. Rather than having separate support fields for each algorithm, keep only # one copy here to save memory and maintain cleaner code. self._support_field = SupportField(rigid_solver) def _init_static_config(self) -> None: # Identify the convex col...
when you have time, can you take a look @SonSang
# Support field used for mpr and gjk. Rather than having separate support fields for each algorithm, keep only # one copy here to save memory and maintain cleaner code. self._support_field = SupportField(rigid_solver) def _init_static_config(self) -> None: # Identify the convex coll...
@@ -86,7 +86,9 @@ def _init_static_config(self) -> None: geom.is_convex or geom.type == gs.GEOM_TYPE.TERRAIN for geom in self._solver.geoms ), has_terrain=any(geom.type == gs.GEOM_TYPE.TERRAIN for geom in self._solver.geoms), - n_contacts_per_pair=20 if self._solver...
genesis/engine/solvers/rigid/collider_decomp.py
26
Python
0.071
suggestion
49
51
51
false
[MISC] Reduce memory usage due to diff constraint solver.
1,930
Genesis-Embodied-AI/Genesis
26,702
Python
YilingQiao
YilingQiao
Review this pull request change. Language: Python File: genesis/engine/solvers/rigid/collider_decomp.py PR Title: [MISC] Reduce memory usage due to diff constraint solver. BEFORE CODE: # Support field used for mpr and gjk. Rather than having separate support fields for each algorithm, keep only # o...
when you have time, can you take a look @SonSang
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 math import dataclasses from functools import partial import gstaichi as ti import numpy as np import genesis as gs if not gs._initialized: gs.raise_exception("Genesis hasn't been initialized. Did you call `gs.init()`?") V_ANNOTATION = ti.types.ndarray() if gs.use_ndarray else ti.template V = ti.ndarra...
I'm not in favour of using cryptic helpers. It just makes everything harder to read.
import math import dataclasses from functools import partial import gstaichi as ti import numpy as np import genesis as gs if not gs._initialized: gs.raise_exception("Genesis hasn't been initialized. Did you call `gs.init()`?") V_ANNOTATION = ti.types.ndarray() if gs.use_ndarray else ti.template V = ti.ndarra...
@@ -20,6 +20,10 @@ DATA_ORIENTED = partial(dataclasses.dataclass, frozen=True) if gs.use_ndarray else ti.data_oriented +def _s(shape, is_on): + return shape if is_on else (1,) + +
genesis/utils/array_class.py
26
Python
0.214
refactor
84
51
51
false
[MISC] Reduce memory usage due to diff constraint solver.
1,930
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/utils/array_class.py PR Title: [MISC] Reduce memory usage due to diff constraint solver. BEFORE CODE: import math import dataclasses from functools import partial import gstaichi as ti import numpy as np import genesis as gs if not gs._initialized:...
I'm not in favour of using cryptic helpers. It just makes everything harder to read.
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 math import dataclasses from functools import partial import gstaichi as ti import numpy as np import genesis as gs if not gs._initialized: gs.raise_exception("Genesis hasn't been initialized. Did you call `gs.init()`?") V_ANNOTATION = ti.types.ndarray() if gs.use_ndarray else ti.template V = ti.ndarra...
Besides, if you want to avoid memory allocation for unused variables, you should rather use shape `()` instead of `(1,)`.
import math import dataclasses from functools import partial import gstaichi as ti import numpy as np import genesis as gs if not gs._initialized: gs.raise_exception("Genesis hasn't been initialized. Did you call `gs.init()`?") V_ANNOTATION = ti.types.ndarray() if gs.use_ndarray else ti.template V = ti.ndarra...
@@ -20,6 +20,10 @@ DATA_ORIENTED = partial(dataclasses.dataclass, frozen=True) if gs.use_ndarray else ti.data_oriented +def _s(shape, is_on): + return shape if is_on else (1,)
genesis/utils/array_class.py
24
Python
0.714
suggestion
121
49
49
false
[MISC] Reduce memory usage due to diff constraint solver.
1,930
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/utils/array_class.py PR Title: [MISC] Reduce memory usage due to diff constraint solver. BEFORE CODE: import math import dataclasses from functools import partial import gstaichi as ti import numpy as np import genesis as gs if not gs._initialized:...
Besides, if you want to avoid memory allocation for unused variables, you should rather use shape `()` instead of `(1,)`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
geom_a: V_ANNOTATION geom_b: V_ANNOTATION # Local positions of the 3 vertices from the two geometries that define the face on the Minkowski difference local_pos1_a: V_ANNOTATION local_pos1_b: V_ANNOTATION local_pos1_c: V_ANNOTATION local_pos2_a: V_ANNOTATION local_pos2_b: V_ANNOTATION ...
Define `requires_grad = solver._requires_grad` to reduce line width. It would be more readable.
geom_a: V_ANNOTATION geom_b: V_ANNOTATION # Local positions of the 3 vertices from the two geometries that define the face on the Minkowski difference local_pos1_a: V_ANNOTATION local_pos1_b: V_ANNOTATION local_pos1_c: V_ANNOTATION local_pos2_a: V_ANNOTATION local_pos2_b: V_ANNOTATION ...
@@ -356,19 +358,21 @@ def get_diff_contact_input(solver, max_contacts_per_pair): _B = solver._B return StructDiffContactInput( - geom_a=V(dtype=gs.ti_int, shape=(_B, max_contacts_per_pair)), - geom_b=V(dtype=gs.ti_int, shape=(_B, max_contacts_per_pair)), - local_pos1_a=V_VEC(3, dtype=gs...
genesis/utils/array_class.py
26
Python
0.357
suggestion
95
51
51
false
[MISC] Reduce memory usage due to diff constraint solver.
1,930
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/utils/array_class.py PR Title: [MISC] Reduce memory usage due to diff constraint solver. BEFORE CODE: geom_a: V_ANNOTATION geom_b: V_ANNOTATION # Local positions of the 3 vertices from the two geometries that define the face on the Minkowsk...
Define `requires_grad = solver._requires_grad` to reduce line width. It would be more readable.
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 math import dataclasses from functools import partial import gstaichi as ti import numpy as np import genesis as gs if not gs._initialized: gs.raise_exception("Genesis hasn't been initialized. Did you call `gs.init()`?") V_ANNOTATION = ti.types.ndarray() if gs.use_ndarray else ti.template V = ti.ndarra...
I would be better to have a more explicit name if you want to keep this pattern. Like `optional_shape` or `cond_shape` or `maybe_shape`.
import math import dataclasses from functools import partial import gstaichi as ti import numpy as np import genesis as gs if not gs._initialized: gs.raise_exception("Genesis hasn't been initialized. Did you call `gs.init()`?") V_ANNOTATION = ti.types.ndarray() if gs.use_ndarray else ti.template V = ti.ndarra...
@@ -20,6 +20,10 @@ DATA_ORIENTED = partial(dataclasses.dataclass, frozen=True) if gs.use_ndarray else ti.data_oriented +def _shape(shape, is_on):
genesis/utils/array_class.py
23
Python
0.571
suggestion
136
48
48
false
[MISC] Reduce memory usage due to diff constraint solver.
1,930
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/utils/array_class.py PR Title: [MISC] Reduce memory usage due to diff constraint solver. BEFORE CODE: import math import dataclasses from functools import partial import gstaichi as ti import numpy as np import genesis as gs if not gs._initialized:...
I would be better to have a more explicit name if you want to keep this pattern. Like `optional_shape` or `cond_shape` or `maybe_shape`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
for shape_arg in (*shape_args, shape_args[0]): if tuple(shape_arg) == (3, 3): np_arg = gu.rotvec_to_R(np.random.randn(*batch_shape, 3).clip(-1.0, 1.0).astype(gs.np_float)) else: np_arg = np.random.randn(*batch_shape, *shape_arg).clip(-1.0, 1.0).astype(gs.n...
Do not check this. It is not part of our spec.
for shape_arg in (*shape_args, shape_args[0]): if tuple(shape_arg) == (3, 3): np_arg = gu.rotvec_to_R(np.random.randn(*batch_shape, 3).clip(-1.0, 1.0).astype(gs.np_float)) else: np_arg = np.random.randn(*batch_shape, *shape_arg).clip(-1.0, 1.0).astype(gs.n...
@@ -292,3 +292,145 @@ def test_utils_geom_tensor_identity(batch_shape): np.testing.assert_allclose(np_args[0], np_args[-1], atol=1e2 * gs.EPS) np.testing.assert_allclose(tensor_to_array(tc_args[0]), tensor_to_array(tc_args[-1]), atol=1e2 * gs.EPS) + + +@pytest.mark.required +def test_pyrender_vec3()...
tests/test_utils.py
26
Python
0.071
suggestion
46
51
51
false
[BUG FIX] Fix interactive viewer 'Vec3'.
1,931
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: tests/test_utils.py PR Title: [BUG FIX] Fix interactive viewer 'Vec3'. BEFORE CODE: for shape_arg in (*shape_args, shape_args[0]): if tuple(shape_arg) == (3, 3): np_arg = gu.rotvec_to_R(np.random.randn(*batch_shape, 3).clip(...
Do not check this. It is not part of our spec.
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_arg = np.random.randn(*batch_shape, *shape_arg).clip(-1.0, 1.0).astype(gs.np_float) tc_arg = torch.as_tensor(np_arg, dtype=gs.tc_float, device=gs.device) np_args.append(np_arg) tc_args.append(tc_arg) num_funcs = len(py_funcs) for i, py_func in enum...
Same: `assert_allclose((v.x, v.y, v.z), (1.0, 2.0, 3.0), tol=gs.EPS)`
np_arg = np.random.randn(*batch_shape, *shape_arg).clip(-1.0, 1.0).astype(gs.np_float) tc_arg = torch.as_tensor(np_arg, dtype=gs.tc_float, device=gs.device) np_args.append(np_arg) tc_args.append(tc_arg) num_funcs = len(py_funcs) for i, py_func in enum...
@@ -292,3 +292,145 @@ def test_utils_geom_tensor_identity(batch_shape): np.testing.assert_allclose(np_args[0], np_args[-1], atol=1e2 * gs.EPS) np.testing.assert_allclose(tensor_to_array(tc_args[0]), tensor_to_array(tc_args[-1]), atol=1e2 * gs.EPS) + + +@pytest.mark.required +def test_pyrender_vec3()...
tests/test_utils.py
26
Python
0.357
suggestion
69
51
51
false
[BUG FIX] Fix interactive viewer 'Vec3'.
1,931
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: tests/test_utils.py PR Title: [BUG FIX] Fix interactive viewer 'Vec3'. BEFORE CODE: np_arg = np.random.randn(*batch_shape, *shape_arg).clip(-1.0, 1.0).astype(gs.np_float) tc_arg = torch.as_tensor(np_arg, dtype=gs.tc_float, device=gs...
Same: `assert_allclose((v.x, v.y, v.z), (1.0, 2.0, 3.0), tol=gs.EPS)`
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.
num_funcs = len(py_funcs) for i, py_func in enumerate(py_funcs): np_args[i + 1][:] = py_func(np_args[i]) tc_args[i + 1][:] = py_func(tc_args[i]) np.testing.assert_allclose(np_args[0], np_args[-1], atol=1e2 * gs.EPS) np.testing.assert_allclose(tensor_to_array(tc_...
Do not assert dtype, we don't care.
num_funcs = len(py_funcs) for i, py_func in enumerate(py_funcs): np_args[i + 1][:] = py_func(np_args[i]) tc_args[i + 1][:] = py_func(tc_args[i]) np.testing.assert_allclose(np_args[0], np_args[-1], atol=1e2 * gs.EPS) np.testing.assert_allclose(tensor_to_array(tc_...
@@ -292,3 +292,145 @@ def test_utils_geom_tensor_identity(batch_shape): np.testing.assert_allclose(np_args[0], np_args[-1], atol=1e2 * gs.EPS) np.testing.assert_allclose(tensor_to_array(tc_args[0]), tensor_to_array(tc_args[-1]), atol=1e2 * gs.EPS) + + +@pytest.mark.required +def test_pyrender_vec3()...
tests/test_utils.py
26
Python
0.214
suggestion
35
51
51
false
[BUG FIX] Fix interactive viewer 'Vec3'.
1,931
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: tests/test_utils.py PR Title: [BUG FIX] Fix interactive viewer 'Vec3'. BEFORE CODE: num_funcs = len(py_funcs) for i, py_func in enumerate(py_funcs): np_args[i + 1][:] = py_func(np_args[i]) tc_args[i + 1][:] = py_func(tc...
Do not assert dtype, we don't care.
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.
# construction helpers enforce shape and dtype v = Vec3.from_xyz(1.0, 2.0, 3.0) assert v.v.shape == (3,) assert v.v.dtype == np.float32 assert np.allclose(v.v, np.array([1.0, 2.0, 3.0], dtype=np.float32)) assert v.x == pytest.approx(1.0) assert v.y == pytest.approx(2.0) assert v.z == pyt...
`assert_allclose(Vec3.full(5.5).v, 5.5, tol=gs.EPS)`
tol = 1e-6 # construction helpers enforce shape and dtype v = Vec3.from_xyz(1.0, 2.0, 3.0) assert v.v.shape == (3,) assert_allclose(v.v, np.array([1.0, 2.0, 3.0]), tol=gs.EPS) assert_allclose((v.x, v.y, v.z), (1.0, 2.0, 3.0), tol=gs.EPS) # from_array converts various dtypes to float32 v...
@@ -292,3 +292,145 @@ def test_utils_geom_tensor_identity(batch_shape): np.testing.assert_allclose(np_args[0], np_args[-1], atol=1e2 * gs.EPS) np.testing.assert_allclose(tensor_to_array(tc_args[0]), tensor_to_array(tc_args[-1]), atol=1e2 * gs.EPS) + + +@pytest.mark.required +def test_pyrender_vec3()...
tests/test_utils.py
26
Python
0.357
suggestion
52
51
51
false
[BUG FIX] Fix interactive viewer 'Vec3'.
1,931
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: tests/test_utils.py PR Title: [BUG FIX] Fix interactive viewer 'Vec3'. BEFORE CODE: # construction helpers enforce shape and dtype v = Vec3.from_xyz(1.0, 2.0, 3.0) assert v.v.shape == (3,) assert v.v.dtype == np.float32 assert np.allclose(v...
`assert_allclose(Vec3.full(5.5).v, 5.5, tol=gs.EPS)`
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.
# construction helpers enforce shape and dtype v = Vec3.from_xyz(1.0, 2.0, 3.0) assert v.v.shape == (3,) assert v.v.dtype == np.float32 assert np.allclose(v.v, np.array([1.0, 2.0, 3.0], dtype=np.float32)) assert v.x == pytest.approx(1.0) assert v.y == pytest.approx(2.0) assert v.z == py...
`assert_allclose(Vec3.zero().v, 0.0, tol=gs.EPS)` `assert_allclose(Vec3.one().v, 1.0, tol=gs.EPS)`
tol = 1e-6 # construction helpers enforce shape and dtype v = Vec3.from_xyz(1.0, 2.0, 3.0) assert v.v.shape == (3,) assert_allclose(v.v, np.array([1.0, 2.0, 3.0]), tol=gs.EPS) assert_allclose((v.x, v.y, v.z), (1.0, 2.0, 3.0), tol=gs.EPS) # from_array converts various dtypes to float32 ...
@@ -292,3 +292,145 @@ def test_utils_geom_tensor_identity(batch_shape): np.testing.assert_allclose(np_args[0], np_args[-1], atol=1e2 * gs.EPS) np.testing.assert_allclose(tensor_to_array(tc_args[0]), tensor_to_array(tc_args[-1]), atol=1e2 * gs.EPS) + + +@pytest.mark.required +def test_pyrender_vec3()...
tests/test_utils.py
26
Python
0.357
suggestion
98
51
51
false
[BUG FIX] Fix interactive viewer 'Vec3'.
1,931
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: tests/test_utils.py PR Title: [BUG FIX] Fix interactive viewer 'Vec3'. BEFORE CODE: # construction helpers enforce shape and dtype v = Vec3.from_xyz(1.0, 2.0, 3.0) assert v.v.shape == (3,) assert v.v.dtype == np.float32 assert np.allclose(...
`assert_allclose(Vec3.zero().v, 0.0, tol=gs.EPS)` `assert_allclose(Vec3.one().v, 1.0, tol=gs.EPS)`
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 genesis.ext.pyrender.interaction.vec3 import Vec3, Quat # construction helpers enforce shape and dtype v = Vec3.from_xyz(1.0, 2.0, 3.0) assert v.v.shape == (3,) assert v.v.dtype == np.float32 assert np.allclose(v.v, np.array([1.0, 2.0, 3.0], dtype=np.float32)) assert v.x == pytest.appr...
Do not check dtype preservation.
from genesis.ext.pyrender.interaction.vec3 import Vec3, Quat tol = 1e-6 # construction helpers enforce shape and dtype v = Vec3.from_xyz(1.0, 2.0, 3.0) assert v.v.shape == (3,) assert_allclose(v.v, np.array([1.0, 2.0, 3.0]), tol=gs.EPS) assert_allclose((v.x, v.y, v.z), (1.0, 2.0, 3.0), tol=...
@@ -292,3 +292,145 @@ def test_utils_geom_tensor_identity(batch_shape): np.testing.assert_allclose(np_args[0], np_args[-1], atol=1e2 * gs.EPS) np.testing.assert_allclose(tensor_to_array(tc_args[0]), tensor_to_array(tc_args[-1]), atol=1e2 * gs.EPS) + + +@pytest.mark.required +def test_pyrender_vec3()...
tests/test_utils.py
26
Python
0.214
suggestion
32
51
51
false
[BUG FIX] Fix interactive viewer 'Vec3'.
1,931
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: tests/test_utils.py PR Title: [BUG FIX] Fix interactive viewer 'Vec3'. BEFORE CODE: from genesis.ext.pyrender.interaction.vec3 import Vec3, Quat # construction helpers enforce shape and dtype v = Vec3.from_xyz(1.0, 2.0, 3.0) assert v.v.shape =...
Do not check dtype preservation.
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.
v_t = Vec3.from_tensor(torch.tensor([4.0, 5.0, 6.0], dtype=torch.float32)) assert np.allclose(v_t.v, [4.0, 5.0, 6.0]) # constants assert np.allclose(Vec3.zero().v, np.zeros(3, dtype=np.float32)) assert np.allclose(Vec3.one().v, np.ones(3, dtype=np.float32)) assert np.allclose(Vec3.full(5.5).v, ...
This is not part of our spec. Or is it? It should be clarified.
assert_allclose(Vec3.zero().v, 0.0, tol=gs.EPS) assert_allclose(Vec3.one().v, 1.0, tol=gs.EPS) assert_allclose(Vec3.full(5.5).v, 5.5, tol=gs.EPS) # arithmetic ops and dtype preservation a = Vec3.from_xyz(1, 2, 3) b = Vec3.from_xyz(4, 5, 6) c = a + b d = b - a assert_allclose(c.v, np...
@@ -292,3 +292,145 @@ def test_utils_geom_tensor_identity(batch_shape): np.testing.assert_allclose(np_args[0], np_args[-1], atol=1e2 * gs.EPS) np.testing.assert_allclose(tensor_to_array(tc_args[0]), tensor_to_array(tc_args[-1]), atol=1e2 * gs.EPS) + + +@pytest.mark.required +def test_pyrender_vec3()...
tests/test_utils.py
26
Python
0.286
suggestion
63
51
51
false
[BUG FIX] Fix interactive viewer 'Vec3'.
1,931
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: tests/test_utils.py PR Title: [BUG FIX] Fix interactive viewer 'Vec3'. BEFORE CODE: v_t = Vec3.from_tensor(torch.tensor([4.0, 5.0, 6.0], dtype=torch.float32)) assert np.allclose(v_t.v, [4.0, 5.0, 6.0]) # constants assert np.allclose(Vec3.zero(...
This is not part of our spec. Or is it? It should be clarified.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
assert np.allclose(m2.v, [2, 4, 6]) assert m1.v.dtype == np.float32 and m2.v.dtype == np.float32 assert np.allclose((-a).v, [-1, -2, -3]) # dot and cross dot_ab = a.dot(b) assert isinstance(dot_ab, float) assert dot_ab == pytest.approx(1 * 4 + 2 * 5 + 3 * 6) cross_ab = a.cross(b) a...
As everywhere else, use our helpers, and do not checks stuffs that are not part of your spec. `assert_allclose(cp.v, 0.0, tol=gs.EPS)`
assert_allclose(dot_ab, 1 * 4 + 2 * 5 + 3 * 6, tol=gs.EPS) cross_ab = a.cross(b) assert_allclose(cross_ab.v, np.array([-3.0, 6.0, -3.0]), tol=gs.EPS) # norms assert_allclose(a.sqr_magnitude(), 1.0 + 4.0 + 9.0, tol=gs.EPS) assert_allclose(a.magnitude(), np.sqrt(a.sqr_magnitude()), tol=gs.EPS) ...
@@ -292,3 +292,145 @@ def test_utils_geom_tensor_identity(batch_shape): np.testing.assert_allclose(np_args[0], np_args[-1], atol=1e2 * gs.EPS) np.testing.assert_allclose(tensor_to_array(tc_args[0]), tensor_to_array(tc_args[-1]), atol=1e2 * gs.EPS) + + +@pytest.mark.required +def test_pyrender_vec3()...
tests/test_utils.py
26
Python
0.571
refactor
134
51
51
false
[BUG FIX] Fix interactive viewer 'Vec3'.
1,931
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: tests/test_utils.py PR Title: [BUG FIX] Fix interactive viewer 'Vec3'. BEFORE CODE: assert np.allclose(m2.v, [2, 4, 6]) assert m1.v.dtype == np.float32 and m2.v.dtype == np.float32 assert np.allclose((-a).v, [-1, -2, -3]) # dot and cross d...
As everywhere else, use our helpers, and do not checks stuffs that are not part of your spec. `assert_allclose(cp.v, 0.0, tol=gs.EPS)`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
assert a.sqr_magnitude() == pytest.approx(1.0 + 4.0 + 9.0) assert a.magnitude() == pytest.approx(np.sqrt(a.sqr_magnitude())) na = a.normalized() assert na.v.dtype == np.float32 assert na.magnitude() == pytest.approx(1.0, rel=1e-6, abs=1e-6) assert np.allclose(Vec3.zero().normalized().v, [0.0, 0....
This restriction is useless. I would not assert it. It would be better to do `self.v = np.asarray(v, dtype=np.float32)`
cp = a.copy() assert cp is not a cp.v[...] = 0.0 assert_allclose(a.v, np.array([1.0, 2.0, 3.0]), tol=gs.EPS) assert_allclose(cp.v, 0.0, tol=gs.EPS) # repr and tensor conversion t = a.as_tensor() assert isinstance(t, torch.Tensor) assert_allclose(t.cpu().numpy(), a.v, tol=gs.EPS) ...
@@ -292,3 +292,145 @@ def test_utils_geom_tensor_identity(batch_shape): np.testing.assert_allclose(np_args[0], np_args[-1], atol=1e2 * gs.EPS) np.testing.assert_allclose(tensor_to_array(tc_args[0]), tensor_to_array(tc_args[-1]), atol=1e2 * gs.EPS) + + +@pytest.mark.required +def test_pyrender_vec3()...
tests/test_utils.py
26
Python
0.714
suggestion
119
51
51
false
[BUG FIX] Fix interactive viewer 'Vec3'.
1,931
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: tests/test_utils.py PR Title: [BUG FIX] Fix interactive viewer 'Vec3'. BEFORE CODE: assert a.sqr_magnitude() == pytest.approx(1.0 + 4.0 + 9.0) assert a.magnitude() == pytest.approx(np.sqrt(a.sqr_magnitude())) na = a.normalized() assert na.v.dty...
This restriction is useless. I would not assert it. It would be better to do `self.v = np.asarray(v, dtype=np.float32)`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
assert cp is not a cp.v[...] = 0.0 assert np.allclose(a.v, [1.0, 2.0, 3.0]) assert np.allclose(cp.v, [0.0, 0.0, 0.0]) # repr and tensor conversion assert "Vec3(" in repr(a) t = a.as_tensor() assert isinstance(t, torch.Tensor) assert t.dtype == torch.float32 assert np.allclose(t....
`assert_allclose((q.w, q.x, q.y, q.z), (1, 0, 0, 0))`
assert_allclose(t.cpu().numpy(), a.v, tol=gs.EPS) # --- Quat tests --- q = Quat.from_wxyz(1.0, 0.0, 0.0, 0.0) # identity assert q.v.shape == (4,) assert_allclose(np.array([q.w, q.x, q.y, q.z]), np.array([1.0, 0.0, 0.0, 0.0]), tol=gs.EPS) # from_array converts dtype and enforces shape q_ar...
@@ -292,3 +292,145 @@ def test_utils_geom_tensor_identity(batch_shape): np.testing.assert_allclose(np_args[0], np_args[-1], atol=1e2 * gs.EPS) np.testing.assert_allclose(tensor_to_array(tc_args[0]), tensor_to_array(tc_args[-1]), atol=1e2 * gs.EPS) + + +@pytest.mark.required +def test_pyrender_vec3()...
tests/test_utils.py
26
Python
0.357
suggestion
53
51
47
false
[BUG FIX] Fix interactive viewer 'Vec3'.
1,931
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: tests/test_utils.py PR Title: [BUG FIX] Fix interactive viewer 'Vec3'. BEFORE CODE: assert cp is not a cp.v[...] = 0.0 assert np.allclose(a.v, [1.0, 2.0, 3.0]) assert np.allclose(cp.v, [0.0, 0.0, 0.0]) # repr and tensor conversion asse...
`assert_allclose((q.w, q.x, q.y, q.z), (1, 0, 0, 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.
for _ in range(50): scene.step() # Check that the sphere did not move, and the slightly squished state = sphere.get_state() center = state.pos.mean(axis=(0, 1)) assert_allclose(center[:2], 0.0, tol=0.01) assert center[2] < SPHERE_RADIUS - 0.02 # Check that the ant is laying on top ...
let's see how long will this test run.
# Run the simulation for _ in range(50): scene.step() # Check that the sphere did not move, and the slightly squished state = sphere.get_state() center = state.pos.mean(axis=(0, 1)) assert_allclose(center[:2], 0.0, tol=0.01) assert center[2] < SPHERE_RADIUS - 0.02 # Check that ...
@@ -278,3 +278,74 @@ def test_sap_fem_vs_robot(show_viewer): # Check that the legs of the ants are resting on the sphere assert_allclose(robot.get_qpos()[-4:].abs(), 1.0, tol=0.1) + + +@pytest.mark.required +@pytest.mark.parametrize("substeps", [1, 10]) +def test_rigid_mpm_legacy_coupling(substeps, show_vie...
tests/test_hybrid.py
26
Python
0.071
suggestion
38
51
51
false
[CHANGING][BUG FIX] Fix external coupling forces from other solvers not affecting rigid bodies.
1,941
Genesis-Embodied-AI/Genesis
26,702
Python
YilingQiao
SonSang
Review this pull request change. Language: Python File: tests/test_hybrid.py PR Title: [CHANGING][BUG FIX] Fix external coupling forces from other solvers not affecting rigid bodies. BEFORE CODE: for _ in range(50): scene.step() # Check that the sphere did not move, and the slightly squished st...
let's see how long will this test run.
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.
color=(1.0, 0.4, 0.4), vis_mode="visual", ), ) obj_sand = scene.add_entity( material=gs.materials.MPM.Liquid(), morph=gs.morphs.Box( pos=(0.0, 0.0, 0.25), size=(0.3, 0.3, 0.3), ), surface=gs.surfaces.Default( co...
why is this target_pos the expected pos? Does this mean the sand push the objects in the -y direction?
color=(1.0, 0.4, 0.4), vis_mode="visual", ), ) obj_sand = scene.add_entity( material=gs.materials.MPM.Liquid(), morph=gs.morphs.Box( pos=(0.0, 0.0, 0.2), size=(0.3, 0.3, 0.3), ), surface=gs.surfaces.Default( col...
@@ -278,3 +278,74 @@ def test_sap_fem_vs_robot(show_viewer): # Check that the legs of the ants are resting on the sphere assert_allclose(robot.get_qpos()[-4:].abs(), 1.0, tol=0.1) + + +@pytest.mark.required +@pytest.mark.parametrize("substeps", [1, 10]) +def test_rigid_mpm_legacy_coupling(substeps, show_vie...
tests/test_hybrid.py
26
Python
0.357
question
102
29
27
false
[CHANGING][BUG FIX] Fix external coupling forces from other solvers not affecting rigid bodies.
1,941
Genesis-Embodied-AI/Genesis
26,702
Python
YilingQiao
SonSang
Review this pull request change. Language: Python File: tests/test_hybrid.py PR Title: [CHANGING][BUG FIX] Fix external coupling forces from other solvers not affecting rigid bodies. BEFORE CODE: color=(1.0, 0.4, 0.4), vis_mode="visual", ), ) obj_sand = scene.add_entity( ...
why is this target_pos the expected pos? Does this mean the sand push the objects in the -y direction?
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.
geoms_state=geoms_state, rigid_global_info=rigid_global_info, static_rigid_sim_config=static_rigid_sim_config, contact_island_state=contact_island_state, ) func_update_acc( update_cacc=False, dofs_state=dofs_state, links_info=links_info, links_stat...
Do not add dedicated clear ingredients kernel. This will significantly affect simulation performance. Just add the clearing code in `func_update_force` kernel, at the very end.
entities_info=entities_info, dofs_state=dofs_state, dofs_info=dofs_info, links_state=links_state, links_info=links_info, joints_info=joints_info, geoms_state=geoms_state, rigid_global_info=rigid_global_info, static_rigid_sim_config=static_rigid_sim...
@@ -3810,6 +3810,11 @@ def func_forward_dynamics( rigid_global_info=rigid_global_info, static_rigid_sim_config=static_rigid_sim_config, ) + func_clear_coupling_force( + links_state=links_state, + rigid_global_info=rigid_global_info, + static_rigid_sim_config=static_rigid_s...
genesis/engine/solvers/rigid/rigid_solver_decomp.py
26
Python
0.643
performance
176
51
51
false
[CHANGING][BUG FIX] Fix external coupling forces from other solvers not affecting rigid bodies.
1,941
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
SonSang
Review this pull request change. Language: Python File: genesis/engine/solvers/rigid/rigid_solver_decomp.py PR Title: [CHANGING][BUG FIX] Fix external coupling forces from other solvers not affecting rigid bodies. BEFORE CODE: geoms_state=geoms_state, rigid_global_info=rigid_global_info, sta...
Do not add dedicated clear ingredients kernel. This will significantly affect simulation performance. Just add the clearing code in `func_update_force` kernel, at the very end.
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.step() # Check that the sphere did not move, and the slightly squished state = sphere.get_state() center = state.pos.mean(axis=(0, 1)) assert_allclose(center[:2], 0.0, tol=0.01) assert center[2] < SPHERE_RADIUS - 0.02 # Check that the ant is laying on top of the sphere robot_...
If it is only used once, inline the value on the assert itself. This will improve readability.
for _ in range(50): scene.step() # Check that the sphere did not move, and the slightly squished state = sphere.get_state() center = state.pos.mean(axis=(0, 1)) assert_allclose(center[:2], 0.0, tol=0.01) assert center[2] < SPHERE_RADIUS - 0.02 # Check that the ant is laying on top ...
@@ -278,3 +278,74 @@ def test_sap_fem_vs_robot(show_viewer): # Check that the legs of the ants are resting on the sphere assert_allclose(robot.get_qpos()[-4:].abs(), 1.0, tol=0.1) + + +@pytest.mark.required +@pytest.mark.parametrize("substeps", [1, 10]) +def test_rigid_mpm_legacy_coupling(substeps, show_vie...
tests/test_hybrid.py
26
Python
0.286
suggestion
94
51
51
false
[CHANGING][BUG FIX] Fix external coupling forces from other solvers not affecting rigid bodies.
1,941
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
SonSang
Review this pull request change. Language: Python File: tests/test_hybrid.py PR Title: [CHANGING][BUG FIX] Fix external coupling forces from other solvers not affecting rigid bodies. BEFORE CODE: scene.step() # Check that the sphere did not move, and the slightly squished state = sphere.get_state()...
If it is only used once, inline the value on the assert itself. This will improve readability.
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.
CAPSULE = 4 BOX = 5 MESH = 6 TERRAIN = 7 # joint type in rigid solver, ranked by number of dofs class JOINT_TYPE(IntEnum): FIXED = 0 REVOLUTE = 1 PRISMATIC = 2 SPHERICAL = 3 FREE = 4 class EQUALITY_TYPE(IntEnum): CONNECT = 0 WELD = 1 JOINT = 2 class CTRL_MODE(IntEnu...
I don't think internally you need this extra mode. I would just remove `POSITION` and use `POSITION_VELOCITY` everywhere instead.
CAPSULE = 4 BOX = 5 MESH = 6 TERRAIN = 7 # joint type in rigid solver, ranked by number of dofs class JOINT_TYPE(IntEnum): FIXED = 0 REVOLUTE = 1 PRISMATIC = 2 SPHERICAL = 3 FREE = 4 class EQUALITY_TYPE(IntEnum): CONNECT = 0 WELD = 1 JOINT = 2 class CTRL_MODE(IntEnu...
@@ -47,6 +47,7 @@ class CTRL_MODE(IntEnum): FORCE = 0 VELOCITY = 1 POSITION = 2 + POSITION_VELOCITY = 3
genesis/constants.py
26
Python
0.571
suggestion
129
51
51
false
[FEATURE] Implement position-velocity controller.
1,948
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
matthieuvigne
Review this pull request change. Language: Python File: genesis/constants.py PR Title: [FEATURE] Implement position-velocity controller. BEFORE CODE: CAPSULE = 4 BOX = 5 MESH = 6 TERRAIN = 7 # joint type in rigid solver, ranked by number of dofs class JOINT_TYPE(IntEnum): FIXED = 0 REVOLUT...
I don't think internally you need this extra mode. I would just remove `POSITION` and use `POSITION_VELOCITY` everywhere instead.
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.
velocity = velocity.unsqueeze(0) has_gains = kernel_control_dofs_position_velocity( position, velocity, dofs_idx, envs_idx, self.dofs_state, self.dofs_info, self._static_rigid_sim_config ) if not unsafe and not has_gains: raise gs.raise_exception( ...
`kernel_control_dofs_velocity` should be modified to only consider `kv` and ignore `kp`
dofs_info=self.dofs_info, geoms_state=self.geoms_state, geoms_info=self.geoms_info, entities_info=self.entities_info, rigid_global_info=self._rigid_global_info, static_rigid_sim_config=self._static_rigid_sim_config, ...
@@ -1824,7 +1824,7 @@ def control_dofs_velocity(self, velocity, dofs_idx=None, envs_idx=None, *, unsaf ) if not unsafe and not has_gains:
genesis/engine/solvers/rigid/rigid_solver_decomp.py
26
Python
0.429
suggestion
87
51
51
false
[FEATURE] Implement position-velocity controller.
1,948
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
matthieuvigne
Review this pull request change. Language: Python File: genesis/engine/solvers/rigid/rigid_solver_decomp.py PR Title: [FEATURE] Implement position-velocity controller. BEFORE CODE: velocity = velocity.unsqueeze(0) has_gains = kernel_control_dofs_position_velocity( position, velocity,...
`kernel_control_dofs_velocity` should be modified to only consider `kv` and ignore `kp`
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.
wave_width = (columns - logger.INFO_length - 11) // 2 if wave_width % 2 == 0: wave_width -= 1 wave_width = max(0, min(38, wave_width)) bar_width = wave_width * 2 + 9 wave = ("┈┉" * wave_width)[:wave_width] logger.info(f"~<╭{'─'*(bar_width)}╮>~") logger.info(f"~<│{wave}>~ ~~~~<Genesis...
if env var has GS_ENABLE_NDARRAY, `is_ndarray_disabled=True`?
wave_width = (columns - logger.INFO_length - 11) // 2 if wave_width % 2 == 0: wave_width -= 1 wave_width = max(0, min(38, wave_width)) bar_width = wave_width * 2 + 9 wave = ("┈┉" * wave_width)[:wave_width] logger.info(f"~<╭{'─'*(bar_width)}╮>~") logger.info(f"~<│{wave}>~ ~~~~<Genesis...
@@ -118,8 +118,7 @@ def init( # Configure GsTaichi fast cache and array type global use_ndarray, use_fastcache - # is_ndarray_disabled = (os.environ.get("GS_ENABLE_NDARRAY") or ("0" if sys.platform == "darwin" else "1")) == "0" - is_ndarray_disabled = os.environ.get("GS_ENABLE_NDARRAY", "0") == "0" + ...
genesis/__init__.py
26
Python
0.357
question
62
51
51
false
[MISC] Enable back GsTaichi dynamic array mode by default except for MacOS.
1,977
Genesis-Embodied-AI/Genesis
26,702
Python
YilingQiao
duburcqa
Review this pull request change. Language: Python File: genesis/__init__.py PR Title: [MISC] Enable back GsTaichi dynamic array mode by default except for MacOS. BEFORE CODE: wave_width = (columns - logger.INFO_length - 11) // 2 if wave_width % 2 == 0: wave_width -= 1 wave_width = max(0, min(38,...
if env var has GS_ENABLE_NDARRAY, `is_ndarray_disabled=True`?
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 collections import defaultdict import csv import subprocess import time import argparse def grep(contents: list[str], target): return [l for l in contents if target in l] def get_cuda_usage() -> dict[int, int]: output = subprocess.check_output(["nvidia-smi"]).decode("utf-8") section = 0 subsec ...
Interesting. Is this the best practice? Can we use pynvml? (asked ChatGPT. I did not try myself)
from collections import defaultdict import csv import subprocess import time import os import argparse import psutil def grep(contents: list[str], target): return [l for l in contents if target in l] def get_cuda_usage() -> dict[int, int]: output = subprocess.check_output(["nvidia-smi"]).decode("utf-8") ...
@@ -0,0 +1,94 @@ +from collections import defaultdict +import csv +import subprocess +import time +import argparse + + +def grep(contents: list[str], target): + return [l for l in contents if target in l] + + +def get_cuda_usage() -> dict[int, int]: + output = subprocess.check_output(["nvidia-smi"]).decode("utf-8...
tests/monitor_test_mem.py
19
Python
0.286
suggestion
96
44
44
false
[MISC] Add benchmark test memory monitoring.
1,981
Genesis-Embodied-AI/Genesis
26,702
Python
YilingQiao
hughperkins
Review this pull request change. Language: Python File: tests/monitor_test_mem.py PR Title: [MISC] Add benchmark test memory monitoring. BEFORE CODE: from collections import defaultdict import csv import subprocess import time import argparse def grep(contents: list[str], target): return [l for l in contents ...
Interesting. Is this the best practice? Can we use pynvml? (asked ChatGPT. I did not try myself)
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.
6D rotation representation, of size (*, 6) [1] http://arxiv.org/abs/1812.07035 """ if isinstance(R, torch.Tensor): return R[..., :2, :].flatten(start_dim=-2) elif isinstance(R, np.ndarray): return R[..., :2, :].reshape((*R.shape[:-2], 6)) else: gs.raise_exception(f"t...
Can you explain why this change is necessary?
6D rotation representation, of size (*, 6) [1] http://arxiv.org/abs/1812.07035 """ if isinstance(R, torch.Tensor): return R[..., :2, :].flatten(start_dim=-2) elif isinstance(R, np.ndarray): return R[..., :2, :].reshape((*R.shape[:-2], 6)) else: gs.raise_exception(f"t...
@@ -500,9 +500,10 @@ def _np_xyz_to_quat(xyz: np.ndarray, rpy: bool = False, out: np.ndarray | None = """ assert xyz.ndim >= 1 if out is None: - out_ = np.empty((*xyz.shape[:-1], 4), dtype=xyz.dtype) + out_ = np.empty(xyz.shape[:-1] + (4,), dtype=xyz.dtype)
genesis/utils/geom.py
26
Python
0.143
question
45
51
51
false
[MISC] Add benchmark test memory monitoring.
1,981
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
hughperkins
Review this pull request change. Language: Python File: genesis/utils/geom.py PR Title: [MISC] Add benchmark test memory monitoring. BEFORE CODE: 6D rotation representation, of size (*, 6) [1] http://arxiv.org/abs/1812.07035 """ if isinstance(R, torch.Tensor): return R[..., :2, :].flatt...
Can you explain why this change is necessary?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
if T is None: T = torch.zeros((*B, 4, 4), dtype=trans.dtype, device=trans.device) elif is_numpy: if T is None: T = np.zeros((*B, 4, 4), dtype=trans.dtype) else: gs.raise_exception( f"both of the inputs must be torch.Tensor or np.ndarray. got: {type(tra...
I don’t think changing this is necessary because the assert is already self explanatory. But as you want.
T = np.zeros((*B, 4, 4), dtype=trans.dtype) else: gs.raise_exception( f"both of the inputs must be torch.Tensor or np.ndarray. got: {type(trans)=} and {type(quat)=}" ) if B: assert T.shape == (*B, 4, 4) T[..., 3, 3] = 1.0 if trans is not None: T[....
@@ -924,7 +928,8 @@ def T_to_trans_quat(T, *, out=None): @nb.jit(nopython=True, cache=True) def _np_quat_mul(u, v, out=None): - assert u.shape == v.shape
genesis/utils/geom.py
26
Python
0.429
suggestion
105
51
51
false
[MISC] Add benchmark test memory monitoring.
1,981
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
hughperkins
Review this pull request change. Language: Python File: genesis/utils/geom.py PR Title: [MISC] Add benchmark test memory monitoring. BEFORE CODE: if T is None: T = torch.zeros((*B, 4, 4), dtype=trans.dtype, device=trans.device) elif is_numpy: if T is None: T = np.zeros((*...
I don’t think changing this is necessary because the assert is already self explanatory. But as you want.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
assert rotvec.ndim >= 1 B = rotvec.shape[:-1] if out is None: out_ = np.empty(B + (4,), dtype=rotvec.dtype) else: if out.shape != B + (4,): raise ValueError("Shape mismatch") out_ = out # Split unit axis and positive angle angle = np.sqrt(np.sum(np.square(rot...
Well, it is just obvious shape mismatch between cos_theta and axis.
# FIXME: Taylor expansion should be used to handle angle ~ 0.0 axis = rotvec / np.maximum(angle[..., None], gs.EPS) # Compute the quaternion representation out_[..., 0] = np.cos(0.5 * angle) out_[..., 1:] = np.sin(0.5 * angle[..., None]) * axis return out_ @nb.jit(nopython=True, cache=True) ...
@@ -1429,13 +1440,16 @@ def rotvec_to_quat(rotvec: np.ndarray, out: np.ndarray | None = None) -> np.ndar @nb.jit(nopython=True, cache=True) def _np_axis_cos_angle_to_R(axis: np.ndarray, cos_theta: np.ndarray, out: np.ndarray | None = None) -> np.ndarray: if isinstance(cos_theta, (float, np.float32, np.float64)):...
genesis/utils/geom.py
26
Python
0.214
suggestion
67
51
51
false
[MISC] Add benchmark test memory monitoring.
1,981
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
hughperkins
Review this pull request change. Language: Python File: genesis/utils/geom.py PR Title: [MISC] Add benchmark test memory monitoring. BEFORE CODE: assert rotvec.ndim >= 1 B = rotvec.shape[:-1] if out is None: out_ = np.empty(B + (4,), dtype=rotvec.dtype) else: if out.shape != B + (4,)...
Well, it is just obvious shape mismatch between cos_theta and axis.
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.
os.environ["PYGLET_HEADLESS"] = "1" IS_INTERACTIVE_VIEWER_AVAILABLE = has_display or has_egl TOL_SINGLE = 5e-5 TOL_DOUBLE = 1e-9 IMG_STD_ERR_THR = 1.0 IMG_NUM_ERR_THR = 0.001 def pytest_make_parametrize_id(config, val, argname): if isinstance(val, Enum): return val.name if isinstance(val, type):...
I would rather only add the option if supported.
pyglet.options["headless"] = True os.environ["PYGLET_HEADLESS"] = "1" IS_INTERACTIVE_VIEWER_AVAILABLE = has_display or has_egl TOL_SINGLE = 5e-5 TOL_DOUBLE = 1e-9 IMG_STD_ERR_THR = 1.0 IMG_NUM_ERR_THR = 0.001 def is_mem_monitoring_supported(): try: assert sys.platform.startswith("linux") ...
@@ -64,7 +65,23 @@ def pytest_make_parametrize_id(config, val, argname): return f"{val}" -@pytest.hookimpl +# @pytest.hookimpl(tryfirst=True) +# def pytest_runtest_setup(item): +# # Include test name in process title +# test_name = item.nodeid.replace(" ", "") +# setproctitle.setproctitle(f"pytest:...
tests/conftest.py
26
Python
0.071
suggestion
48
51
51
false
[MISC] Add benchmark test memory monitoring.
1,981
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
hughperkins
Review this pull request change. Language: Python File: tests/conftest.py PR Title: [MISC] Add benchmark test memory monitoring. BEFORE CODE: os.environ["PYGLET_HEADLESS"] = "1" IS_INTERACTIVE_VIEWER_AVAILABLE = has_display or has_egl TOL_SINGLE = 5e-5 TOL_DOUBLE = 1e-9 IMG_STD_ERR_THR = 1.0 IMG_NUM_ERR_THR =...
I would rather only add the option if supported.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# def pytest_runtest_setup(item): # # Include test name in process title # test_name = item.nodeid.replace(" ", "") # setproctitle.setproctitle(f"pytest: {test_name}") def validate_mem_option() -> None: try: assert sys.platform.startswith("linux") nvidia_out = subprocess.check_output([...
If think you should check if xdist is enabled or not. If so, you can start it right away. If not, run this command in the main process. See what is done at the very end of the function for benchmarks.
def pytest_make_parametrize_id(config, val, argname): if isinstance(val, Enum): return val.name if isinstance(val, type): return ".".join((val.__module__, val.__name__)) return f"{val}" @pytest.hookimpl(tryfirst=True) def pytest_cmdline_main(config: pytest.Config) -> None: # Make sure...
@@ -73,6 +90,19 @@ def pytest_cmdline_main(config: pytest.Config) -> None: except NameError as e: raise pytest.UsageError(f"Unknown marker in CLI expression: '{e.name}'") + # Only launch memory monitor from the main process, not from xdist workers + if config.getoption("--mem-monitoring-filepath")...
tests/conftest.py
26
Python
0.5
suggestion
200
51
51
false
[MISC] Add benchmark test memory monitoring.
1,981
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
hughperkins
Review this pull request change. Language: Python File: tests/conftest.py PR Title: [MISC] Add benchmark test memory monitoring. BEFORE CODE: # def pytest_runtest_setup(item): # # Include test name in process title # test_name = item.nodeid.replace(" ", "") # setproctitle.setproctitle(f"pytest: {test_na...
If think you should check if xdist is enabled or not. If so, you can start it right away. If not, run this command in the main process. See what is done at the very end of the function for benchmarks.
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.
global use_ndarray, use_fastcache, use_zerocopy is_ndarray_disabled = (os.environ.get("GS_ENABLE_NDARRAY") or ("0" if sys.platform == "darwin" else "1")) == "0" if use_ndarray is None: _use_ndarray = not (is_ndarray_disabled or performance_mode) else: _use_ndarray = use_ndarray i...
ti.field won't support zero copy?
global use_ndarray, use_fastcache, use_zerocopy is_ndarray_disabled = (os.environ.get("GS_ENABLE_NDARRAY") or ("0" if backend == gs_backend.metal else "1")) == "0" if use_ndarray is None: _use_ndarray = not (is_ndarray_disabled or performance_mode) else: _use_ndarray = use_ndarray ...
@@ -136,6 +137,15 @@ def init( raise_exception("Genesis previous initialized. GsTaichi fast cache mode cannot be disabled anymore.") use_ndarray, use_fastcache = _use_ndarray, _use_fastcache + # Unlike dynamic vs static array mode, and fastcache, zero-copy can be toggle on/off between init withou...
genesis/__init__.py
26
Python
0.071
question
33
51
51
false
[FEATURE] Leverage GsTaichi zero-copy in data accessors.
2,011
Genesis-Embodied-AI/Genesis
26,702
Python
YilingQiao
duburcqa
Review this pull request change. Language: Python File: genesis/__init__.py PR Title: [FEATURE] Leverage GsTaichi zero-copy in data accessors. BEFORE CODE: global use_ndarray, use_fastcache, use_zerocopy is_ndarray_disabled = (os.environ.get("GS_ENABLE_NDARRAY") or ("0" if sys.platform == "darwin" else "1")...
ti.field won't support zero copy?
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.
mass2, com2 = 1.0, np.array([0.0, 0.0, 0.0]) inertia2 = np.array([[1.0, 0.0, 0.0], [0.0, 2.0, 0.0], [0.0, 0.0, 1.0]]) combined_mass, combined_com, combined_inertia = compose_inertial_properties( mass1, com1, inertia1, mass2, com2, inertia2 ) expected_inertia = np.array([[3.0, 0.0, 0.0], [0...
Just implement a single test case that combines all the effects at once.
import math from unittest.mock import patch import pytest import torch import numpy as np import genesis as gs import genesis.utils.geom as gu from genesis.utils.tools import FPSTracker from genesis.utils.misc import tensor_to_array from genesis.utils import warnings as warnings_mod from genesis.utils.warnings import...
@@ -435,3 +436,78 @@ def test_fps_tracker(): fps = tracker.step(current_time=10.45) # num envs * [num steps] / (delta time) assert math.isclose(fps, n_envs * 4 / 0.14) + + +@pytest.mark.required +def test_compose_inertial_properties(): + """Test composition of inertial properties of two bodies.""" + +...
tests/test_utils.py
26
Python
0.214
suggestion
72
27
469
false
[CHANGING][FEATURE] Improve inertial estimation if undefined.
2,100
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: tests/test_utils.py PR Title: [CHANGING][FEATURE] Improve inertial estimation if undefined. BEFORE CODE: mass2, com2 = 1.0, np.array([0.0, 0.0, 0.0]) inertia2 = np.array([[1.0, 0.0, 0.0], [0.0, 2.0, 0.0], [0.0, 0.0, 1.0]]) combined_mass, combined_...
Just implement a single test case that combines all the effects at once.
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.
"""Rotate inertia tensor I by rotation matrix R.""" return R @ I @ R.T def compose_inertial_properties(mass1, com1, inertia1, mass2, com2, inertia2): """ Compose inertial properties of two bodies. Args: mass1: Mass of first body com1: Center of mass of first body (3,) array ...
Just raise an exception is both masses are not `> gs.EPS`
"""Rotate inertia tensor I by rotation matrix R.""" return R @ I @ R.T def compose_inertial_properties(mass1, com1, inertia1, mass2, com2, inertia2): """ Compose inertial properties of two bodies. Args: mass1: Mass of first body com1: Center of mass of first body (3,) array ...
@@ -419,6 +419,39 @@ def rotate_inertia(I, R): return R @ I @ R.T +def compose_inertial_properties(mass1, com1, inertia1, mass2, com2, inertia2): + """ + Compose inertial properties of two bodies. + + Args: + mass1: Mass of first body + com1: Center of mass of first body (3,) array + ...
genesis/utils/urdf.py
26
Python
0.5
suggestion
57
51
51
false
[CHANGING][FEATURE] Improve inertial estimation if undefined.
2,100
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/utils/urdf.py PR Title: [CHANGING][FEATURE] Improve inertial estimation if undefined. BEFORE CODE: """Rotate inertia tensor I by rotation matrix R.""" return R @ I @ R.T def compose_inertial_properties(mass1, com1, inertia1, mass2, com2, iner...
Just raise an exception is both masses are not `> gs.EPS`
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._invweight: float | None = invweight self._visualize_contact = visualize_contact self._geoms: list[RigidGeom] = gs.List() self._vgeoms: list[RigidVisGeom] = gs.List() def _build(self): for geom in self._geoms: geom._build() for vgeom in self._vgeo...
Avoid doing this. Just inline these function calls directly where they are used.
self._invweight: float | None = invweight self._visualize_contact = visualize_contact self._geoms: list[RigidGeom] = gs.List() self._vgeoms: list[RigidVisGeom] = gs.List() def _build(self): for geom in self._geoms: geom._build() for vgeom in self._vgeo...
@@ -121,82 +122,88 @@ def _build(self): for vgeom in self._vgeoms: vgeom._build() - self._init_mesh = self._compose_init_mesh() - - # inertial_mass and inertia_i - if self._inertial_mass is None: - if len(self._geoms) == 0 and len(self._vgeoms) == 0: - ...
genesis/engine/entities/rigid_entity/rigid_link.py
26
Python
0.286
suggestion
80
51
51
false
[CHANGING][FEATURE] Improve inertial estimation if undefined.
2,100
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/engine/entities/rigid_entity/rigid_link.py PR Title: [CHANGING][FEATURE] Improve inertial estimation if undefined. BEFORE CODE: self._invweight: float | None = invweight self._visualize_contact = visualize_contact self._geoms:...
Avoid doing this. Just inline these function calls directly where they are 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.
self._geoms: list[RigidGeom] = gs.List() self._vgeoms: list[RigidVisGeom] = gs.List() def _build(self): for geom in self._geoms: geom._build() for vgeom in self._vgeoms: vgeom._build() if self._inertial_mass is None or self._inertial_pos is None or...
Use 0.0. There is no reason to add some random mass in the kinematic tree.
self._geoms: list[RigidGeom] = gs.List() self._vgeoms: list[RigidVisGeom] = gs.List() def _build(self): for geom in self._geoms: geom._build() for vgeom in self._vgeoms: vgeom._build() if self._inertial_mass is None or self._inertial_pos is None or...
@@ -121,82 +122,88 @@ def _build(self): for vgeom in self._vgeoms: vgeom._build() - self._init_mesh = self._compose_init_mesh() - - # inertial_mass and inertia_i - if self._inertial_mass is None: - if len(self._geoms) == 0 and len(self._vgeoms) == 0: - ...
genesis/engine/entities/rigid_entity/rigid_link.py
26
Python
0.286
suggestion
74
51
51
false
[CHANGING][FEATURE] Improve inertial estimation if undefined.
2,100
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/engine/entities/rigid_entity/rigid_link.py PR Title: [CHANGING][FEATURE] Improve inertial estimation if undefined. BEFORE CODE: self._geoms: list[RigidGeom] = gs.List() self._vgeoms: list[RigidVisGeom] = gs.List() def _build(self)...
Use 0.0. There is no reason to add some random mass in the kinematic tree.
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._visualize_contact = visualize_contact self._geoms: list[RigidGeom] = gs.List() self._vgeoms: list[RigidVisGeom] = gs.List() def _build(self): for geom in self._geoms: geom._build() for vgeom in self._vgeoms: vgeom._build() if self._in...
This is not a fallback. It is the right solution where there is no geometry attached to a link.
self._visualize_contact = visualize_contact self._geoms: list[RigidGeom] = gs.List() self._vgeoms: list[RigidVisGeom] = gs.List() def _build(self): for geom in self._geoms: geom._build() for vgeom in self._vgeoms: vgeom._build() if self._in...
@@ -121,82 +122,88 @@ def _build(self): for vgeom in self._vgeoms: vgeom._build() - self._init_mesh = self._compose_init_mesh() - - # inertial_mass and inertia_i - if self._inertial_mass is None: - if len(self._geoms) == 0 and len(self._vgeoms) == 0: - ...
genesis/engine/entities/rigid_entity/rigid_link.py
26
Python
0.214
suggestion
95
51
51
false
[CHANGING][FEATURE] Improve inertial estimation if undefined.
2,100
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/engine/entities/rigid_entity/rigid_link.py PR Title: [CHANGING][FEATURE] Improve inertial estimation if undefined. BEFORE CODE: self._visualize_contact = visualize_contact self._geoms: list[RigidGeom] = gs.List() self._vgeoms: ...
This is not a fallback. It is the right solution where there is no geometry attached to a link.
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.