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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
or not (
self._solver._enable_multi_contact
and self._solver.geoms_info[i_ga].type == gs.GEOM_TYPE.PLANE
and self._solver.geoms_info[i_gb].type == gs.GEOM_TYPE.BOX
)
)
... | Interesting. We cannot run _func_plane_box_multi_contact on Mac? (not blocking mergeing) | and self._solver.geoms_info[i_ga].type == gs.GEOM_TYPE.PLANE
and self._solver.geoms_info[i_gb].type == gs.GEOM_TYPE.BOX
)
and not (
self._solver._box_box_detection
and self._solver.geo... | @@ -891,7 +895,7 @@ def _func_narrow_phase_convex_specializations(self):
if self._solver.geoms_info[i_ga].type > self._solver.geoms_info[i_gb].type:
i_ga, i_gb = i_gb, i_ga
- if ti.static(self._solver._enable_multi_contact):
+ if ti.static(self._solv... | genesis/engine/solvers/rigid/collider_decomp.py | 26 | Python | 0.214 | suggestion | 88 | 51 | 51 | false | [BUG FIX] Get around MacOS Metal GPU taichi compiler bug. | 1,308 | Genesis-Embodied-AI/Genesis | 26,702 | Python | YilingQiao | duburcqa | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/collider_decomp.py
PR Title: [BUG FIX] Get around MacOS Metal GPU taichi compiler bug.
BEFORE CODE: or not (
self._solver._enable_multi_contact
and sel... | Interesting. We cannot run _func_plane_box_multi_contact on Mac? (not blocking mergeing) | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
ind0 = i * num_cols + num_cols - 1
ind1 = (i + 1) * num_cols + num_cols - 1
ind2 = ind0 + num_rows * num_cols
ind3 = ind1 + num_rows * num_cols
triangles_side_2[2 * i] = [ind0, ind1, ind2]
triangles_side_2[2 * i + 1] = [ind1, ind3, ind2]
triangles_side_3 = np.zeros([... | Why are you removing this? Moreover, you left the comment but it makes no sense anymore. | triangles_side_2 = np.zeros([2 * (num_rows - 1), 3], dtype=np.uint32)
for i in range(num_rows - 1):
ind0 = i * num_cols + num_cols - 1
ind1 = (i + 1) * num_cols + num_cols - 1
ind2 = ind0 + num_rows * num_cols
ind3 = ind1 + num_rows * num_cols
triangles_side_2[2 * i] = [i... | @@ -342,15 +348,18 @@ def convert_heightfield_to_watertight_trimesh(height_field_raw, horizontal_scale
[triangles_top, triangles_bottom, triangles_side_0, triangles_side_1, triangles_side_2, triangles_side_3],
axis=0,
)
-
+ uvs = np.concatenate(
+ [uv_top, uv_top],
+ axis=0,
+ ... | genesis/utils/terrain.py | 26 | Python | 0.214 | question | 88 | 51 | 51 | false | [Feature] Terrain texture user option | 1,311 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/utils/terrain.py
PR Title: [Feature] Terrain texture user option
BEFORE CODE: ind0 = i * num_cols + num_cols - 1
ind1 = (i + 1) * num_cols + num_cols - 1
ind2 = ind0 + num_rows * num_cols
ind3 = ind1 + num_rows * num_col... | Why are you removing this? Moreover, you left the comment but it makes no sense anymore. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
class Solver(RBC):
def __init__(self, scene: "Scene", sim: "Simulator", options):
self._uid = gs.UID()
self._sim = sim
self._scene = scene
self._dt: float = options.dt
self._substep_dt: float = options.dt / sim.substeps
if hasattr(options, "gravity"):
s... | This is definitely not the right way to check if something is a taichi field. Just do
`isinstance(obj, taichi.Field)` and remove this method entirely. I checked myself and it works perfectly on both `ti.Vector`, `ti.Matrix` and `ti.types.struct` instances. | from genesis.engine.scene import Scene
from genesis.engine.simulator import Simulator
class Solver(RBC):
def __init__(self, scene: "Scene", sim: "Simulator", options):
self._uid = gs.UID()
self._sim = sim
self._scene = scene
self._dt: float = options.dt
self._subste... | @@ -34,6 +34,45 @@ def __init__(self, scene: "Scene", sim: "Simulator", options):
def _add_force_field(self, force_field):
self._ffs.append(force_field)
+ @staticmethod
+ def _is_ti_field(obj) -> bool: | genesis/engine/solvers/base_solver.py | 26 | Python | 0.786 | refactor | 257 | 51 | 51 | false | [FEATURE] Scene saver | 1,315 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/base_solver.py
PR Title: [FEATURE] Scene saver
BEFORE CODE:
class Solver(RBC):
def __init__(self, scene: "Scene", sim: "Simulator", options):
self._uid = gs.UID()
self._sim = sim
self._scene = scene
... | This is definitely not the right way to check if something is a taichi field. Just do
`isinstance(obj, taichi.Field)` and remove this method entirely. I checked myself and it works perfectly on both `ti.Vector`, `ti.Matrix` and `ti.types.struct` instances. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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._scene = scene
self._dt: float = options.dt
self._substep_dt: float = options.dt / sim.substeps
if hasattr(options, "gravity"):
self._gravity = ti.field(dtype=gs.ti_vec3, shape=())
self._gravity.from_numpy(np.array(options.gravity, dtype=gs.np_float))
... | What are you trying to achieve here? I don't understand and it does not work on my machine if I do:
```python
val = scene.sim.rigid_solver.__dict__['links_T']
val[tag] = val[None]
``` | self._uid = gs.UID()
self._sim = sim
self._scene = scene
self._dt: float = options.dt
self._substep_dt: float = options.dt / sim.substeps
if hasattr(options, "gravity"):
self._gravity = ti.field(dtype=gs.ti_vec3, shape=())
self._gravity.from_numpy... | @@ -34,6 +34,45 @@ def __init__(self, scene: "Scene", sim: "Simulator", options):
def _add_force_field(self, force_field):
self._ffs.append(force_field)
+ @staticmethod
+ def _is_ti_field(obj) -> bool:
+ return callable(getattr(obj, "to_numpy", None)) and callable(getattr(obj, "from_numpy",... | genesis/engine/solvers/base_solver.py | 26 | Python | 0.714 | question | 187 | 51 | 51 | false | [FEATURE] Scene saver | 1,315 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/base_solver.py
PR Title: [FEATURE] Scene saver
BEFORE CODE: self._scene = scene
self._dt: float = options.dt
self._substep_dt: float = options.dt / sim.substeps
if hasattr(options, "gravity"):
... | What are you trying to achieve here? I don't understand and it does not work on my machine if I do:
```python
val = scene.sim.rigid_solver.__dict__['links_T']
val[tag] = val[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. |
def _add_force_field(self, force_field):
self._ffs.append(force_field)
@staticmethod
def _is_ti_field(obj) -> bool:
return callable(getattr(obj, "to_numpy", None)) and callable(getattr(obj, "from_numpy", None))
def save_ckpt(self, tag: str = "0"):
for val in self.__dict__.valu... | * Prefer `".".join((self.__class__.__name__, name))`
* Making a copy is useless here | # force fields
self._ffs = list()
def _add_force_field(self, force_field):
self._ffs.append(force_field)
def dump_ckpt_to_numpy(self) -> dict[str, np.ndarray]:
arrays: dict[str, np.ndarray] = {}
for attr_name, field in self.__dict__.items():
if not isinstan... | @@ -34,6 +34,45 @@ def __init__(self, scene: "Scene", sim: "Simulator", options):
def _add_force_field(self, force_field):
self._ffs.append(force_field)
+ @staticmethod
+ def _is_ti_field(obj) -> bool:
+ return callable(getattr(obj, "to_numpy", None)) and callable(getattr(obj, "from_numpy",... | genesis/engine/solvers/base_solver.py | 26 | Python | 0.429 | suggestion | 85 | 51 | 51 | false | [FEATURE] Scene saver | 1,315 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/base_solver.py
PR Title: [FEATURE] Scene saver
BEFORE CODE:
def _add_force_field(self, force_field):
self._ffs.append(force_field)
@staticmethod
def _is_ti_field(obj) -> bool:
return callable(getattr(obj, "t... | * Prefer `".".join((self.__class__.__name__, name))`
* Making a copy is useless here | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
self._ffs = list()
def _add_force_field(self, force_field):
self._ffs.append(force_field)
@staticmethod
def _is_ti_field(obj) -> bool:
return callable(getattr(obj, "to_numpy", None)) and callable(getattr(obj, "from_numpy", None))
def save_ckpt(self, tag: str = "0"):
fo... | Remove this condition. it is useless I think. Just do the same in both cases. |
# force fields
self._ffs = list()
def _add_force_field(self, force_field):
self._ffs.append(force_field)
def dump_ckpt_to_numpy(self) -> dict[str, np.ndarray]:
arrays: dict[str, np.ndarray] = {}
for attr_name, field in self.__dict__.items():
if not isinsta... | @@ -34,6 +34,45 @@ def __init__(self, scene: "Scene", sim: "Simulator", options):
def _add_force_field(self, force_field):
self._ffs.append(force_field)
+ @staticmethod
+ def _is_ti_field(obj) -> bool:
+ return callable(getattr(obj, "to_numpy", None)) and callable(getattr(obj, "from_numpy",... | genesis/engine/solvers/base_solver.py | 26 | Python | 0.286 | refactor | 77 | 51 | 51 | false | [FEATURE] Scene saver | 1,315 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/base_solver.py
PR Title: [FEATURE] Scene saver
BEFORE CODE: self._ffs = list()
def _add_force_field(self, force_field):
self._ffs.append(force_field)
@staticmethod
def _is_ti_field(obj) -> bool:
retu... | Remove this condition. it is useless I think. Just do the same in both cases. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
self._ffs.append(force_field)
@staticmethod
def _is_ti_field(obj) -> bool:
return callable(getattr(obj, "to_numpy", None)) and callable(getattr(obj, "from_numpy", None))
def save_ckpt(self, tag: str = "0"):
for val in self.__dict__.values():
if self._is_ti_field(val):
... | Why encapsulating the dict as a numpy array? |
def _add_force_field(self, force_field):
self._ffs.append(force_field)
def dump_ckpt_to_numpy(self) -> dict[str, np.ndarray]:
arrays: dict[str, np.ndarray] = {}
for attr_name, field in self.__dict__.items():
if not isinstance(field, ti.Field):
continue
... | @@ -34,6 +34,45 @@ def __init__(self, scene: "Scene", sim: "Simulator", options):
def _add_force_field(self, force_field):
self._ffs.append(force_field)
+ @staticmethod
+ def _is_ti_field(obj) -> bool:
+ return callable(getattr(obj, "to_numpy", None)) and callable(getattr(obj, "from_numpy",... | genesis/engine/solvers/base_solver.py | 26 | Python | 0.071 | question | 44 | 51 | 51 | false | [FEATURE] Scene saver | 1,315 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/base_solver.py
PR Title: [FEATURE] Scene saver
BEFORE CODE: self._ffs.append(force_field)
@staticmethod
def _is_ti_field(obj) -> bool:
return callable(getattr(obj, "to_numpy", None)) and callable(getattr(obj, "fr... | Why encapsulating the dict as a numpy array? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# force fields
self._ffs = list()
def _add_force_field(self, force_field):
self._ffs.append(force_field)
@staticmethod
def _is_ti_field(obj) -> bool:
return callable(getattr(obj, "to_numpy", None)) and callable(getattr(obj, "from_numpy", None))
def save_ckpt(self, tag:... | You should rather use `ti_field_to_torch` I think. It would be faster and more consistent with the whole codebase. | self._entities: list[Entity] = gs.List()
# force fields
self._ffs = list()
def _add_force_field(self, force_field):
self._ffs.append(force_field)
def dump_ckpt_to_numpy(self) -> dict[str, np.ndarray]:
arrays: dict[str, np.ndarray] = {}
for attr_name, field in ... | @@ -34,6 +34,45 @@ def __init__(self, scene: "Scene", sim: "Simulator", options):
def _add_force_field(self, force_field):
self._ffs.append(force_field)
+ @staticmethod
+ def _is_ti_field(obj) -> bool:
+ return callable(getattr(obj, "to_numpy", None)) and callable(getattr(obj, "from_numpy",... | genesis/engine/solvers/base_solver.py | 26 | Python | 0.571 | suggestion | 114 | 51 | 51 | false | [FEATURE] Scene saver | 1,315 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/base_solver.py
PR Title: [FEATURE] Scene saver
BEFORE CODE: # force fields
self._ffs = list()
def _add_force_field(self, force_field):
self._ffs.append(force_field)
@staticmethod
def _is_ti_field(obj... | You should rather use `ti_field_to_torch` I think. It would be faster and more consistent with the whole codebase. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
for val in self.__dict__.values():
if self._is_ti_field(val):
val[None] = val[tag]
def dump_ckpt_to_numpy(self) -> dict[str, np.ndarray]:
arrays, prefix = {}, self.__class__.__name__ + "/"
for name, val in self.__dict__.items():
if not self._is_ti_fie... | This edge-case should be removed. | data = field.to_numpy()
# StructField → data is a dict: flatten each member
if isinstance(data, dict):
for sub_name, sub_arr in data.items():
arrays[f"{key_base}.{sub_name}"] = (
sub_arr if isinstance(sub_arr, np.ndarray) e... | @@ -34,6 +34,45 @@ def __init__(self, scene: "Scene", sim: "Simulator", options):
def _add_force_field(self, force_field):
self._ffs.append(force_field)
+ @staticmethod
+ def _is_ti_field(obj) -> bool:
+ return callable(getattr(obj, "to_numpy", None)) and callable(getattr(obj, "from_numpy",... | genesis/engine/solvers/base_solver.py | 26 | Python | 0.143 | suggestion | 33 | 51 | 51 | false | [FEATURE] Scene saver | 1,315 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/base_solver.py
PR Title: [FEATURE] Scene saver
BEFORE CODE: for val in self.__dict__.values():
if self._is_ti_field(val):
val[None] = val[tag]
def dump_ckpt_to_numpy(self) -> dict[str, np.ndarray]... | This edge-case should be removed. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# create and build the scene
scene = gs.Scene(
show_viewer=show_viewer,
)
hand = scene.add_entity(
gs.morphs.URDF(
file="urdf/panda_bullet/hand.urdf",
fixed=True,
),
)
scene.build()
assert scene.rigid_solver.n_equalities == 1
qvel = scene.... | Just pick the usual franka robot example for this. No need to use a drone and franka is the go-to robot for this kind of generic tests. | # Check that `set_qpos` applies the same absolute transform in all cases
door_angle = np.array([1.1])
for i, key in enumerate(((False, False), (False, True))):
qpos = np.concatenate(
((0.0, (i - 1.5) * POS_OFFSET, 0.0), tuple(WOLRD_QUAT / np.linalg.norm(WOLRD_QUAT)), door_angle)
... | @@ -2153,6 +2156,34 @@ def test_urdf_mimic(show_viewer, tol):
assert_allclose(gs_qpos[-1], gs_qpos[-2], tol=tol)
+@pytest.mark.required
+@pytest.mark.parametrize("backend", [gs.cpu])
+def test_scene_saver(show_viewer, tol): | tests/test_rigid_physics.py | 26 | Python | 0.429 | suggestion | 135 | 51 | 51 | false | [FEATURE] Scene saver | 1,315 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [FEATURE] Scene saver
BEFORE CODE: # create and build the scene
scene = gs.Scene(
show_viewer=show_viewer,
)
hand = scene.add_entity(
gs.morphs.URDF(
file="urdf/panda_bullet/hand... | Just pick the usual franka robot example for this. No need to use a drone and franka is the go-to robot for this kind of generic tests. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if not self._backward_ready:
gs.raise_exception("Multiple backward calls not allowed.")
# backward pass through time
while self._t > 0:
self._step_grad()
self._backward_ready = False
self._forward_ready = False
def dump_ckpt_to_numpy(self) -> dict[s... | What about `".".join((self.__class__.__name__, name))` | if not self._backward_ready:
gs.raise_exception("Multiple backward calls not allowed.")
# backward pass through time
while self._t > 0:
self._step_grad()
self._backward_ready = False
self._forward_ready = False
def dump_ckpt_to_numpy(self) -> dict[s... | @@ -1057,6 +1060,71 @@ def _backward(self):
self._backward_ready = False
self._forward_ready = False
+ def dump_ckpt_to_numpy(self) -> dict[str, np.ndarray]:
+ """
+ Collect every Taichi field in the **scene and its active solvers** and
+ return them as a flat ``{key: ndarray... | genesis/engine/scene.py | 26 | Python | 0.357 | suggestion | 54 | 51 | 51 | false | [FEATURE] Scene saver | 1,315 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/scene.py
PR Title: [FEATURE] Scene saver
BEFORE CODE: if not self._backward_ready:
gs.raise_exception("Multiple backward calls not allowed.")
# backward pass through time
while self._t > 0:
self._... | What about `".".join((self.__class__.__name__, name))` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
state = {
"timestamp": time.time(),
"step_index": self.t,
"arrays": self.dump_ckpt_to_numpy(),
}
with open(path, "wb") as f:
pickle.dump(state, f, protocol=pickle.HIGHEST_PROTOCOL)
def load_checkpoint(self, path: str | os.PathLike) -> None:
... | `key = ".".join((self.__class__.__name__, name))` | "timestamp": time.time(),
"step_index": self.t,
"arrays": self.dump_ckpt_to_numpy(),
}
with open(path, "wb") as f:
pickle.dump(state, f, protocol=pickle.HIGHEST_PROTOCOL)
def load_checkpoint(self, path: str | os.PathLike) -> None:
"""
... | @@ -1057,6 +1060,71 @@ def _backward(self):
self._backward_ready = False
self._forward_ready = False
+ def dump_ckpt_to_numpy(self) -> dict[str, np.ndarray]:
+ """
+ Collect every Taichi field in the **scene and its active solvers** and
+ return them as a flat ``{key: ndarray... | genesis/engine/scene.py | 26 | Python | 0.214 | suggestion | 49 | 51 | 51 | false | [FEATURE] Scene saver | 1,315 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/scene.py
PR Title: [FEATURE] Scene saver
BEFORE CODE: state = {
"timestamp": time.time(),
"step_index": self.t,
"arrays": self.dump_ckpt_to_numpy(),
}
with open(path, "wb") as f:
... | `key = ".".join((self.__class__.__name__, name))` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
self._gravity = ti.field(dtype=gs.ti_vec3, shape=())
self._gravity.from_numpy(np.array(options.gravity, dtype=gs.np_float))
else:
self._gravity = None
self._entities: list[Entity] = gs.List()
# force fields
self._ffs = list()
def _add_force_fiel... | Just do `field.to_numpy()` if working with `torch.Tensor` directly is not working out for some reason. | self._gravity = ti.field(dtype=gs.ti_vec3, shape=())
self._gravity.from_numpy(np.array(options.gravity, dtype=gs.np_float))
else:
self._gravity = None
self._entities: list[Entity] = gs.List()
# force fields
self._ffs = list()
def _add_force_fiel... | @@ -34,6 +36,75 @@ def __init__(self, scene: "Scene", sim: "Simulator", options):
def _add_force_field(self, force_field):
self._ffs.append(force_field)
+ def dump_ckpt_to_numpy(self) -> dict[str, np.ndarray]:
+ arrays: dict[str, np.ndarray] = {}
+ cls_prefix = f"{self.__class__.__name_... | genesis/engine/solvers/base_solver.py | 26 | Python | 0.5 | suggestion | 102 | 51 | 51 | false | [FEATURE] Scene saver | 1,315 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/base_solver.py
PR Title: [FEATURE] Scene saver
BEFORE CODE: self._gravity = ti.field(dtype=gs.ti_vec3, shape=())
self._gravity.from_numpy(np.array(options.gravity, dtype=gs.np_float))
else:
sel... | Just do `field.to_numpy()` if working with `torch.Tensor` directly is not working out for some reason. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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._dt: float = options.dt
self._substep_dt: float = options.dt / sim.substeps
if hasattr(options, "gravity"):
self._gravity = ti.field(dtype=gs.ti_vec3, shape=())
self._gravity.from_numpy(np.array(options.gravity, dtype=gs.np_float))
else:
self._gr... | `key_base = ".".join((self.__class__.__name__, attr_name))` | self._dt: float = options.dt
self._substep_dt: float = options.dt / sim.substeps
if hasattr(options, "gravity"):
self._gravity = ti.field(dtype=gs.ti_vec3, shape=())
self._gravity.from_numpy(np.array(options.gravity, dtype=gs.np_float))
else:
self._gr... | @@ -34,6 +36,75 @@ def __init__(self, scene: "Scene", sim: "Simulator", options):
def _add_force_field(self, force_field):
self._ffs.append(force_field)
+ def dump_ckpt_to_numpy(self) -> dict[str, np.ndarray]:
+ arrays: dict[str, np.ndarray] = {}
+ cls_prefix = f"{self.__class__.__name_... | genesis/engine/solvers/base_solver.py | 26 | Python | 0.357 | suggestion | 59 | 51 | 51 | false | [FEATURE] Scene saver | 1,315 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/base_solver.py
PR Title: [FEATURE] Scene saver
BEFORE CODE: self._dt: float = options.dt
self._substep_dt: float = options.dt / sim.substeps
if hasattr(options, "gravity"):
self._gravity = ti.field(dt... | `key_base = ".".join((self.__class__.__name__, attr_name))` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
self._gravity = None
self._entities: list[Entity] = gs.List()
# force fields
self._ffs = list()
def _add_force_field(self, force_field):
self._ffs.append(force_field)
def dump_ckpt_to_numpy(self) -> dict[str, np.ndarray]:
arrays: dict[str, np.ndarray] = {}... | Add a comment to explain in which cases it may fail. | self._gravity = None
self._entities: list[Entity] = gs.List()
# force fields
self._ffs = list()
def _add_force_field(self, force_field):
self._ffs.append(force_field)
def dump_ckpt_to_numpy(self) -> dict[str, np.ndarray]:
arrays: dict[str, np.ndarray] = {}... | @@ -34,6 +36,75 @@ def __init__(self, scene: "Scene", sim: "Simulator", options):
def _add_force_field(self, force_field):
self._ffs.append(force_field)
+ def dump_ckpt_to_numpy(self) -> dict[str, np.ndarray]:
+ arrays: dict[str, np.ndarray] = {}
+ cls_prefix = f"{self.__class__.__name_... | genesis/engine/solvers/base_solver.py | 26 | Python | 0.214 | bug | 52 | 51 | 51 | false | [FEATURE] Scene saver | 1,315 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/base_solver.py
PR Title: [FEATURE] Scene saver
BEFORE CODE: self._gravity = None
self._entities: list[Entity] = gs.List()
# force fields
self._ffs = list()
def _add_force_field(self, force_field... | Add a comment to explain in which cases it may fail. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if hasattr(options, "gravity"):
self._gravity = ti.field(dtype=gs.ti_vec3, shape=())
self._gravity.from_numpy(np.array(options.gravity, dtype=gs.np_float))
else:
self._gravity = None
self._entities: list[Entity] = gs.List()
# force fields
sel... | You can remove the fallback if using `to_torch` or `to_numpy` directly.
Ignore my comment about using `ti_field_to_torch`. That was a bad idea. Sorry about that... | if hasattr(options, "gravity"):
self._gravity = ti.field(dtype=gs.ti_vec3, shape=())
self._gravity.from_numpy(np.array(options.gravity, dtype=gs.np_float))
else:
self._gravity = None
self._entities: list[Entity] = gs.List()
# force fields
sel... | @@ -34,6 +36,75 @@ def __init__(self, scene: "Scene", sim: "Simulator", options):
def _add_force_field(self, force_field):
self._ffs.append(force_field)
+ def dump_ckpt_to_numpy(self) -> dict[str, np.ndarray]:
+ arrays: dict[str, np.ndarray] = {}
+ cls_prefix = f"{self.__class__.__name_... | genesis/engine/solvers/base_solver.py | 26 | Python | 0.571 | suggestion | 166 | 51 | 51 | false | [FEATURE] Scene saver | 1,315 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/base_solver.py
PR Title: [FEATURE] Scene saver
BEFORE CODE: if hasattr(options, "gravity"):
self._gravity = ti.field(dtype=gs.ti_vec3, shape=())
self._gravity.from_numpy(np.array(options.gravity, dtype=gs.... | You can remove the fallback if using `to_torch` or `to_numpy` directly.
Ignore my comment about using `ti_field_to_torch`. That was a bad idea. Sorry about 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. |
continue
key_base = cls_prefix + attr_name
member_prefix = key_base + "."
# ---- StructField: gather its members -----------------------------
member_items = {}
for saved_key, saved_arr in arr_dict.items():
if saved_key.starts... | Why not just `field.from_numpy(arr)` ? | if member_items: # we found at least one sub-member
field.from_numpy(member_items)
continue
# ---- Ordinary field ---------------------------------------------
if key_base not in arr_dict:
continue # nothing saved for this attribute
... | @@ -34,6 +36,75 @@ def __init__(self, scene: "Scene", sim: "Simulator", options):
def _add_force_field(self, force_field):
self._ffs.append(force_field)
+ def dump_ckpt_to_numpy(self) -> dict[str, np.ndarray]:
+ arrays: dict[str, np.ndarray] = {}
+ cls_prefix = f"{self.__class__.__name_... | genesis/engine/solvers/base_solver.py | 26 | Python | 0.214 | question | 38 | 51 | 51 | false | [FEATURE] Scene saver | 1,315 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/base_solver.py
PR Title: [FEATURE] Scene saver
BEFORE CODE: continue
key_base = cls_prefix + attr_name
member_prefix = key_base + "."
# ---- StructField: gather its members ----------... | Why not just `field.from_numpy(arr)` ? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
The resolution of the viewer. If not set, will auto-compute using resolution of the connected display.
run_in_thread: bool
Whether to run the viewer in a background thread. This option is not supported on MacOS. True by default if available.
refresh_rate : int
The refresh rate of the vie... | Why not just `enable_interaction`? It is actually the same viewer no? | The resolution of the viewer. If not set, will auto-compute using resolution of the connected display.
run_in_thread: bool
Whether to run the viewer in a background thread. This option is not supported on MacOS. True by default if available.
refresh_rate : int
The refresh rate of the vie... | @@ -41,6 +41,7 @@ class ViewerOptions(Options):
camera_lookat: tuple = (0.0, 0.0, 0.5)
camera_up: tuple = (0.0, 0.0, 1.0)
camera_fov: float = 40
+ use_viewer_interaction: bool = False | genesis/options/vis.py | 26 | Python | 0.357 | question | 69 | 51 | 51 | false | [MISC] Add stub code for mouse interaction | 1,321 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | gasnica | Review this pull request change.
Language: Python
File: genesis/options/vis.py
PR Title: [MISC] Add stub code for mouse interaction
BEFORE CODE: The resolution of the viewer. If not set, will auto-compute using resolution of the connected display.
run_in_thread: bool
Whether to run the viewer in... | Why not just `enable_interaction`? It is actually the same viewer no? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if self._default_persp_cam is None:
self._default_persp_cam = PerspectiveCamera(yfov=np.pi / 3.0, znear=znear, zfar=zfar)
if self._default_orth_cam is None:
xmag = ymag = self.scene.scale
if self.scene.scale == 0:
xmag = ymag = 1.0
self._d... | Just use relative import and move them back on top (after all non-relative imports). It should work:
```python
from .interaction.viewer_interaction import ViewerInteraction
from .interaction.viewer_interaction_base import ViewerInteractionBase
``` | if self._default_persp_cam is None:
self._default_persp_cam = PerspectiveCamera(yfov=np.pi / 3.0, znear=znear, zfar=zfar)
if self._default_orth_cam is None:
xmag = ymag = self.scene.scale
if self.scene.scale == 0:
xmag = ymag = 1.0
self._de... | @@ -376,6 +381,20 @@ def __init__(
self.scene.main_camera_node = self._camera_node
self._reset_view()
+ # Setup mouse interaction
+
+ # Note: can't import ViewerIntaction at file scope while genesis.engine.scene is still being imported
+ from genesis.ext.pyrender.interaction.vie... | genesis/ext/pyrender/viewer.py | 26 | Python | 0.857 | suggestion | 251 | 51 | 51 | false | [MISC] Add stub code for mouse interaction | 1,321 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | gasnica | Review this pull request change.
Language: Python
File: genesis/ext/pyrender/viewer.py
PR Title: [MISC] Add stub code for mouse interaction
BEFORE CODE:
if self._default_persp_cam is None:
self._default_persp_cam = PerspectiveCamera(yfov=np.pi / 3.0, znear=znear, zfar=zfar)
if self._def... | Just use relative import and move them back on top (after all non-relative imports). It should work:
```python
from .interaction.viewer_interaction import ViewerInteraction
from .interaction.viewer_interaction_base import ViewerInteractionBase
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 moviepy.video.io.ffmpeg_writer import FFMPEG_VideoWriter
from pyglet import clock
from .camera import IntrinsicsCamera, OrthographicCamera, PerspectiveCamera
from .constants import (
DEFAULT_SCENE_SCALE,
DEFAULT_Z_FAR,
DEFAULT_Z_NEAR,
MIN_OPEN_GL_MAJOR,
MIN_OPEN_GL_MINOR,
TARGET_OPEN_GL_MA... | Move this import after `from pyglet import clock` | from pyglet import clock
from pyglet.event import EVENT_HANDLE_STATE
from .camera import IntrinsicsCamera, OrthographicCamera, PerspectiveCamera
from .constants import (
DEFAULT_SCENE_SCALE,
DEFAULT_Z_FAR,
DEFAULT_Z_NEAR,
MIN_OPEN_GL_MAJOR,
MIN_OPEN_GL_MINOR,
TARGET_OPEN_GL_MAJOR,
TARGET_OP... | @@ -64,6 +64,10 @@
pyglet.options["shadow_window"] = False
+# Used for type checking:
+from pyglet.event import EVENT_HANDLE_STATE | genesis/ext/pyrender/viewer.py | 26 | Python | 0.286 | refactor | 49 | 51 | 51 | false | [MISC] Add stub code for mouse interaction | 1,321 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | gasnica | Review this pull request change.
Language: Python
File: genesis/ext/pyrender/viewer.py
PR Title: [MISC] Add stub code for mouse interaction
BEFORE CODE: from moviepy.video.io.ffmpeg_writer import FFMPEG_VideoWriter
from pyglet import clock
from .camera import IntrinsicsCamera, OrthographicCamera, PerspectiveCamera... | Move this import after `from pyglet import clock` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 pyglet import clock
from .camera import IntrinsicsCamera, OrthographicCamera, PerspectiveCamera
from .constants import (
DEFAULT_SCENE_SCALE,
DEFAULT_Z_FAR,
DEFAULT_Z_NEAR,
MIN_OPEN_GL_MAJOR,
MIN_OPEN_GL_MINOR,
TARGET_OPEN_GL_MAJOR,
TARGET_OPEN_GL_MINOR,
TEXT_PADDING,
RenderFla... | Move this import before relative imports.
Here is the rule: You should first import standards libraries, skip line, then ubiquitous third-party libraries (torch, numpy, tqdm...etc), skip line, then random third-party libraries, skip line, then our own custom libraries, skip line, then relative genesis imports. For e... | from pyglet.event import EVENT_HANDLE_STATE
from .camera import IntrinsicsCamera, OrthographicCamera, PerspectiveCamera
from .constants import (
DEFAULT_SCENE_SCALE,
DEFAULT_Z_FAR,
DEFAULT_Z_NEAR,
MIN_OPEN_GL_MAJOR,
MIN_OPEN_GL_MINOR,
TARGET_OPEN_GL_MAJOR,
TARGET_OPEN_GL_MINOR,
TEXT_PAD... | @@ -64,6 +64,10 @@
pyglet.options["shadow_window"] = False
+# Used for type checking:
+from pyglet.event import EVENT_HANDLE_STATE
+from genesis.vis.rasterizer_context import RasterizerContext | genesis/ext/pyrender/viewer.py | 26 | Python | 0.5 | refactor | 371 | 51 | 51 | false | [MISC] Add stub code for mouse interaction | 1,321 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | gasnica | Review this pull request change.
Language: Python
File: genesis/ext/pyrender/viewer.py
PR Title: [MISC] Add stub code for mouse interaction
BEFORE CODE: from pyglet import clock
from .camera import IntrinsicsCamera, OrthographicCamera, PerspectiveCamera
from .constants import (
DEFAULT_SCENE_SCALE,
DEFAULT... | Move this import before relative imports.
Here is the rule: You should first import standards libraries, skip line, then ubiquitous third-party libraries (torch, numpy, tqdm...etc), skip line, then random third-party libraries, skip line, then our own custom libraries, skip line, then relative genesis imports. For e... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 pyglet.event import EVENT_HANDLE_STATE
# Notes:
# Viewer window is based on pyglet.window.Window, mouse events are defined in pyglet.window.BaseWindow
class ViewerInteractionBase():
"""Base class for handling pyglet.window.Window events.
"""
log_events: bool
def __init__(self, log_events: bool ... | Use `gs.logger`. No in-line `if` statements. | from pyglet.event import EVENT_HANDLE_STATE
import genesis as gs
# Note: Viewer window is based on pyglet.window.Window, mouse events are defined in pyglet.window.BaseWindow
class ViewerInteractionBase():
"""Base class for handling pyglet.window.Window events.
"""
log_events: bool
def __init__(self... | @@ -0,0 +1,34 @@
+from pyglet.event import EVENT_HANDLE_STATE
+
+# Notes:
+# Viewer window is based on pyglet.window.Window, mouse events are defined in pyglet.window.BaseWindow
+
+class ViewerInteractionBase():
+ """Base class for handling pyglet.window.Window events.
+ """
+
+ log_events: bool
+
+ def __i... | genesis/ext/pyrender/interaction/viewer_interaction_base.py | 16 | Python | 0.286 | suggestion | 44 | 35 | 41 | false | [MISC] Add stub code for mouse interaction | 1,321 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | gasnica | Review this pull request change.
Language: Python
File: genesis/ext/pyrender/interaction/viewer_interaction_base.py
PR Title: [MISC] Add stub code for mouse interaction
BEFORE CODE: from pyglet.event import EVENT_HANDLE_STATE
# Notes:
# Viewer window is based on pyglet.window.Window, mouse events are defined in py... | Use `gs.logger`. No in-line `if` statements. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 pyglet.event import EVENT_HANDLE_STATE
# Notes:
# Viewer window is based on pyglet.window.Window, mouse events are defined in pyglet.window.BaseWindow
class ViewerInteractionBase():
"""Base class for handling pyglet.window.Window events.
"""
log_events: bool
def __init__(self, log_events: bool ... | This flag is unnecessary. Remove it and always log at "DEBUG" level. (See next comment) | from pyglet.event import EVENT_HANDLE_STATE
import genesis as gs
# Note: Viewer window is based on pyglet.window.Window, mouse events are defined in pyglet.window.BaseWindow
class ViewerInteractionBase():
"""Base class for handling pyglet.window.Window events.
"""
log_events: bool
def __init__(self... | @@ -0,0 +1,34 @@
+from pyglet.event import EVENT_HANDLE_STATE
+
+# Notes:
+# Viewer window is based on pyglet.window.Window, mouse events are defined in pyglet.window.BaseWindow
+
+class ViewerInteractionBase():
+ """Base class for handling pyglet.window.Window events.
+ """
+
+ log_events: bool
+
+ def __i... | genesis/ext/pyrender/interaction/viewer_interaction_base.py | 13 | Python | 0.429 | bug | 87 | 35 | 38 | false | [MISC] Add stub code for mouse interaction | 1,321 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | gasnica | Review this pull request change.
Language: Python
File: genesis/ext/pyrender/interaction/viewer_interaction_base.py
PR Title: [MISC] Add stub code for mouse interaction
BEFORE CODE: from pyglet.event import EVENT_HANDLE_STATE
# Notes:
# Viewer window is based on pyglet.window.Window, mouse events are defined in py... | This flag is unnecessary. Remove it and always log at "DEBUG" level. (See next comment) | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# Note: ignoring pixel aspect ratio
mtx = self.camera.matrix
position = Vec3(mtx[:3, 3])
forward = Vec3(-mtx[:3, 2])
right = Vec3(mtx[:3, 0])
up = Vec3(mtx[:3, 1])
direction = forward + right * x + up * y
return Ray(position, direction)
def get_cam... | one line would do fine. No need to split on multiple line in this case it is already very readable. | else:
# alternative way
projection_matrix = self.camera.camera.get_projection_matrix(*self.viewport_size)
x = x - 0.5 * self.viewport_size[0]
y = y - 0.5 * self.viewport_size[1]
x = 2.0 * x / self.viewport_size[0] / projection_matrix[0, 0]
... | @@ -0,0 +1,115 @@
+from typing import override
+from pyglet.event import EVENT_HANDLE_STATE
+import numpy as np
+
+from genesis.engine.scene import Scene
+from genesis.ext.pyrender.node import Node
+from genesis.ext.pyrender.interaction.ray import Plane, Ray, RayHit
+from genesis.ext.pyrender.interaction.vec3 import Ve... | genesis/ext/pyrender/interaction/viewer_interaction.py | 26 | Python | 0.214 | suggestion | 99 | 35 | 35 | false | [MISC] Add stub code for mouse interaction | 1,321 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | gasnica | Review this pull request change.
Language: Python
File: genesis/ext/pyrender/interaction/viewer_interaction.py
PR Title: [MISC] Add stub code for mouse interaction
BEFORE CODE:
# Note: ignoring pixel aspect ratio
mtx = self.camera.matrix
position = Vec3(mtx[:3, 3])
forward = Vec3(-... | one line would do fine. No need to split on multiple line in this case it is already very 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. |
y = y - 0.5 * self.viewport_size[1]
x = 2.0 * x / self.viewport_size[0] / projection_matrix[0, 0]
y = 2.0 * y / self.viewport_size[1] / projection_matrix[1, 1]
# Note: ignoring pixel aspect ratio
mtx = self.camera.matrix
position = Vec3(mtx[:3, 3])
f... | `tuple[float, float, float, float] = (1, 1, 1, 1)`. Typing is wrong since you specify ints x) | y = y - 0.5 * self.viewport_size[1]
x = 2.0 * x / self.viewport_size[1] * self.tan_half_fov
y = 2.0 * y / self.viewport_size[1] * self.tan_half_fov
else:
# alternative way
projection_matrix = self.camera.camera.get_projection_matrix(*self.viewport_size... | @@ -0,0 +1,115 @@
+from typing import override
+from pyglet.event import EVENT_HANDLE_STATE
+import numpy as np
+
+from genesis.engine.scene import Scene
+from genesis.ext.pyrender.node import Node
+from genesis.ext.pyrender.interaction.ray import Plane, Ray, RayHit
+from genesis.ext.pyrender.interaction.vec3 import Ve... | genesis/ext/pyrender/interaction/viewer_interaction.py | 26 | Python | 0.357 | bug | 93 | 38 | 38 | false | [MISC] Add stub code for mouse interaction | 1,321 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | gasnica | Review this pull request change.
Language: Python
File: genesis/ext/pyrender/interaction/viewer_interaction.py
PR Title: [MISC] Add stub code for mouse interaction
BEFORE CODE: y = y - 0.5 * self.viewport_size[1]
x = 2.0 * x / self.viewport_size[0] / projection_matrix[0, 0]
y = 2... | `tuple[float, float, float, float] = (1, 1, 1, 1)`. Typing is wrong since you specify ints x) | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
import numpy as np
from numpy.typing import NDArray
class Vec3:
v: NDArray[np.float32]
def __init__(self, v: NDArray[np.float32]):
assert v.shape == (3,), f"Vec3 must be initialized with a 3-element array, got {v.shape}"
self.v = v
def __add__(self, other: 'Vec3') -> 'Vec3': return Vec3(s... | I'm not convinced by the relevant of this class. It just add one extra layer of indirection that is hindering performance will not really making code much clearer. This kind of approach is rarely used in Python. | import numpy as np
from numpy.typing import NDArray
class Vec3:
"""
Use this wrapper around np.array if you want to ensure adherence to float32 arithmethic
with runtime checks, and avoid hidden and costly conversions between float32 and float64.
This also makes vector dimensionality explicit for lint... | @@ -0,0 +1,31 @@
+import numpy as np
+from numpy.typing import NDArray
+
+class Vec3: | genesis/ext/pyrender/interaction/vec3.py | 5 | Python | 0.643 | performance | 211 | 30 | 30 | false | [MISC] Add stub code for mouse interaction | 1,321 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | gasnica | Review this pull request change.
Language: Python
File: genesis/ext/pyrender/interaction/vec3.py
PR Title: [MISC] Add stub code for mouse interaction
BEFORE CODE: import numpy as np
from numpy.typing import NDArray
class Vec3:
v: NDArray[np.float32]
def __init__(self, v: NDArray[np.float32]):
asse... | I'm not convinced by the relevant of this class. It just add one extra layer of indirection that is hindering performance will not really making code much clearer. This kind of approach is rarely used in Python. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
import numpy as np
from numpy.typing import NDArray
class Vec3:
v: NDArray[np.float32]
def __init__(self, v: NDArray[np.float32]):
assert v.shape == (3,), f"Vec3 must be initialized with a 3-element array, got {v.shape}"
self.v = v
def __add__(self, other: 'Vec3') -> 'Vec3': return Vec3(s... | Personally I prefer `self.v / max(np.linalg.norm(self.v), gs.EPS)` | import numpy as np
from numpy.typing import NDArray
class Vec3:
"""
Use this wrapper around np.array if you want to ensure adherence to float32 arithmethic
with runtime checks, and avoid hidden and costly conversions between float32 and float64.
This also makes vector dimensionality explicit for lint... | @@ -0,0 +1,31 @@
+import numpy as np
+from numpy.typing import NDArray
+
+class Vec3:
+ v: NDArray[np.float32]
+
+ def __init__(self, v: NDArray[np.float32]):
+ assert v.shape == (3,), f"Vec3 must be initialized with a 3-element array, got {v.shape}"
+ self.v = v
+
+ def __add__(self, other: 'Vec... | genesis/ext/pyrender/interaction/vec3.py | 18 | Python | 0.429 | suggestion | 66 | 32 | 43 | false | [MISC] Add stub code for mouse interaction | 1,321 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | gasnica | Review this pull request change.
Language: Python
File: genesis/ext/pyrender/interaction/vec3.py
PR Title: [MISC] Add stub code for mouse interaction
BEFORE CODE: import numpy as np
from numpy.typing import NDArray
class Vec3:
v: NDArray[np.float32]
def __init__(self, v: NDArray[np.float32]):
asse... | Personally I prefer `self.v / max(np.linalg.norm(self.v), 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. |
# ray_hit = self._raycast_against_ground(self.get_camera_ray())
ray_hit = self._raycast_against_ground(self.screen_position_to_ray(*self.prev_mouse_pos))
if ray_hit.is_hit:
self.scene.draw_debug_sphere(ray_hit.position.v, 0.01, (0, 1, 0, 1))
s... | @YilingQiao @duburcqa On the topic of strong typing.
I just realized, that here, in code, we still use an incorrect dtype, cos camera.matrix returns an array of float64's -- And while the expected type is linted in Vec3 constructor, it was not asserted at runtime.
So, just having an alias for types is not suffici... | mouse_ray = self.screen_position_to_ray(x, y)
# print(f"mouse_ray: {mouse_ray}")
@override
def on_draw(self) -> None:
super().on_draw()
if self.scene._visualizer is not None and self.scene._visualizer.viewer_lock is not None:
self.scene.clear_debug_objects()
... | @@ -0,0 +1,115 @@
+from typing import override
+from pyglet.event import EVENT_HANDLE_STATE
+import numpy as np
+
+from genesis.engine.scene import Scene
+from genesis.ext.pyrender.node import Node
+from genesis.ext.pyrender.interaction.ray import Plane, Ray, RayHit
+from genesis.ext.pyrender.interaction.vec3 import Ve... | genesis/ext/pyrender/interaction/viewer_interaction.py | 26 | Python | 0.643 | bug | 601 | 51 | 51 | false | [MISC] Add stub code for mouse interaction | 1,321 | Genesis-Embodied-AI/Genesis | 26,702 | Python | gasnica | gasnica | Review this pull request change.
Language: Python
File: genesis/ext/pyrender/interaction/viewer_interaction.py
PR Title: [MISC] Add stub code for mouse interaction
BEFORE CODE:
# ray_hit = self._raycast_against_ground(self.get_camera_ray())
ray_hit = self._raycast_against_ground(sel... | @YilingQiao @duburcqa On the topic of strong typing.
I just realized, that here, in code, we still use an incorrect dtype, cos camera.matrix returns an array of float64's -- And while the expected type is linted in Vec3 constructor, it was not asserted at runtime.
So, just having an alias for types is not suffici... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 override, TYPE_CHECKING
import numpy as np
from pyglet.event import EVENT_HANDLE_STATE
from genesis.ext.pyrender.interaction.ray import Plane, Ray, RayHit
from genesis.ext.pyrender.interaction.vec3 import Vec3
from genesis.ext.pyrender.interaction.viewer_interaction_base import ViewerInteractionBa... | Could you switch to relative import? | from typing import TYPE_CHECKING
from typing_extensions import override
import numpy as np
from pyglet.event import EVENT_HANDLE_STATE
from .ray import Plane, Ray, RayHit
from .vec3 import Vec3
from .viewer_interaction_base import ViewerInteractionBase
if TYPE_CHECKING:
from genesis.engine.scene import Scene
... | @@ -0,0 +1,114 @@
+from typing import override, TYPE_CHECKING
+
+import numpy as np
+
+from pyglet.event import EVENT_HANDLE_STATE
+
+from genesis.ext.pyrender.interaction.ray import Plane, Ray, RayHit | genesis/ext/pyrender/interaction/viewer_interaction.py | 7 | Python | 0.143 | question | 36 | 32 | 32 | false | [MISC] Add stub code for mouse interaction | 1,321 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | gasnica | Review this pull request change.
Language: Python
File: genesis/ext/pyrender/interaction/viewer_interaction.py
PR Title: [MISC] Add stub code for mouse interaction
BEFORE CODE: from typing import override, TYPE_CHECKING
import numpy as np
from pyglet.event import EVENT_HANDLE_STATE
from genesis.ext.pyrender.inte... | Could you switch to relative import? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
"""A pyglet-based interactive 3D scene viewer."""
import copy
import os
import shutil
import sys
import time
import threading
from threading import Event, RLock, Semaphore, Thread
import imageio
import numpy as np
import OpenGL
from OpenGL.GL import *
import genesis as gs
from genesis.ext.pyrender.interaction.viewer... | Same. Use relative import here. | """A pyglet-based interactive 3D scene viewer."""
import copy
import os
import shutil
import sys
import time
import threading
from threading import Event, RLock, Semaphore, Thread
import imageio
import numpy as np
import OpenGL
from OpenGL.GL import *
import genesis as gs
from genesis.vis.rasterizer_context import R... | @@ -14,6 +14,9 @@
from OpenGL.GL import *
import genesis as gs
+from genesis.ext.pyrender.interaction.viewer_interaction import ViewerInteraction | genesis/ext/pyrender/viewer.py | 17 | Python | 0.143 | suggestion | 31 | 42 | 42 | false | [MISC] Add stub code for mouse interaction | 1,321 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | gasnica | Review this pull request change.
Language: Python
File: genesis/ext/pyrender/viewer.py
PR Title: [MISC] Add stub code for mouse interaction
BEFORE CODE: """A pyglet-based interactive 3D scene viewer."""
import copy
import os
import shutil
import sys
import time
import threading
from threading import Event, RLock, ... | Same. Use relative import here. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
"""A pyglet-based interactive 3D scene viewer."""
import copy
import os
import shutil
import sys
import time
import threading
from threading import Event, RLock, Semaphore, Thread
import imageio
import numpy as np
import OpenGL
from OpenGL.GL import *
import genesis as gs
from genesis.ext.pyrender.interaction.viewer... | But not for this one of course | """A pyglet-based interactive 3D scene viewer."""
import copy
import os
import shutil
import sys
import time
import threading
from threading import Event, RLock, Semaphore, Thread
import imageio
import numpy as np
import OpenGL
from OpenGL.GL import *
import genesis as gs
from genesis.vis.rasterizer_context import R... | @@ -14,6 +14,9 @@
from OpenGL.GL import *
import genesis as gs
+from genesis.ext.pyrender.interaction.viewer_interaction import ViewerInteraction
+from genesis.ext.pyrender.interaction.viewer_interaction_base import ViewerInteractionBase
+from genesis.vis.rasterizer_context import RasterizerContext | genesis/ext/pyrender/viewer.py | 17 | Python | 0.071 | suggestion | 30 | 42 | 42 | false | [MISC] Add stub code for mouse interaction | 1,321 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | gasnica | Review this pull request change.
Language: Python
File: genesis/ext/pyrender/viewer.py
PR Title: [MISC] Add stub code for mouse interaction
BEFORE CODE: """A pyglet-based interactive 3D scene viewer."""
import copy
import os
import shutil
import sys
import time
import threading
from threading import Event, RLock, ... | But not for this one of course | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
from dataclasses import dataclass
from genesis.ext.pyrender.interaction.vec3 import Vec3
EPSILON = 1e-6
class Ray:
origin: Vec3
direction: Vec3
def __init__(self, origin: Vec3, direction: Vec3):
self.origin = origin
self.direction = direction.normalized()
def __repr__(self) -> str:... | Skip one line and relative import:
```python
from dataclasses import dataclass
from .vec3 import Vec3
``` | from dataclasses import dataclass
from .vec3 import Vec3
EPSILON = 1e-6
class Ray:
origin: Vec3
direction: Vec3
def __init__(self, origin: Vec3, direction: Vec3):
self.origin = origin
self.direction = direction.normalized()
def __repr__(self) -> str:
return f"Ray(origin={s... | @@ -0,0 +1,53 @@
+from dataclasses import dataclass
+from genesis.ext.pyrender.interaction.vec3 import Vec3 | genesis/ext/pyrender/interaction/ray.py | 2 | Python | 0.714 | suggestion | 111 | 27 | 27 | false | [MISC] Add stub code for mouse interaction | 1,321 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | gasnica | Review this pull request change.
Language: Python
File: genesis/ext/pyrender/interaction/ray.py
PR Title: [MISC] Add stub code for mouse interaction
BEFORE CODE: from dataclasses import dataclass
from genesis.ext.pyrender.interaction.vec3 import Vec3
EPSILON = 1e-6
class Ray:
origin: Vec3
direction: Vec... | Skip one line and relative import:
```python
from dataclasses import dataclass
from .vec3 import Vec3
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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(3):
assert_allclose(steps_rgb_arrays[0][i], steps_rgb_arrays[1][i], tol=tol)
@pytest.mark.required
@pytest.mark.skipif(sys.platform == "darwin", reason="Segfault inside 'shadow_mapping_pass' on MacOS VM.")
@pytest.mark.xfail(reason="This test is not passing on all platforms for now.... | Are you sure you need this many entities on the scene, with all these fancy materials?? | robots_rgb_arrays.append(rgb_array)
steps_rgb_arrays.append(robots_rgb_arrays)
for i in range(3):
assert_allclose(steps_rgb_arrays[0][i], steps_rgb_arrays[1][i], tol=tol)
@pytest.mark.required
@pytest.mark.skipif(sys.platform == "darwin", reason="Segfault inside 'shad... | @@ -1034,6 +1035,183 @@ def test_batched_offscreen_rendering(show_viewer, tol):
assert_allclose(steps_rgb_arrays[0][i], steps_rgb_arrays[1][i], tol=tol)
+@pytest.mark.required
+@pytest.mark.skipif(sys.platform == "darwin", reason="Segfault inside 'shadow_mapping_pass' on MacOS VM.")
+@pytest.mark.xfail... | tests/test_rigid_physics.py | 26 | Python | 0.214 | question | 87 | 51 | 51 | false | [FEATURE] Allow mounted cameras to be run in parallel simulations | 1,323 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | abhijitmajumdar | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [FEATURE] Allow mounted cameras to be run in parallel simulations
BEFORE CODE: for i in range(3):
assert_allclose(steps_rgb_arrays[0][i], steps_rgb_arrays[1][i], tol=tol)
@pytest.mark.required
@pytest... | Are you sure you need this many entities on the scene, with all these fancy materials?? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 scene.rigid_solver.n_equalities == 1
qvel = scene.rigid_solver.dofs_state.vel.to_numpy()
qvel[-1] = 1
scene.rigid_solver.dofs_state.vel.from_numpy(qvel)
for i in range(200):
scene.step()
gs_qpos = scene.rigid_solver.qpos.to_numpy()[:, 0]
assert_allclose(gs_qpos[-1], gs_qpos[... | Just simulate a dropping sphere. A drone is way too complex for this. | morph=gs.morphs.URDF(
file=f"{asset_path}/microwave/microwave.urdf",
fixed=fixed,
merge_fixed_links=merge_fixed_links,
pos=(0.0, (i - 1.5) * POS_OFFSET, 0.0),
quat=tuple(WOLRD_QUAT / np.linalg.norm(WOLRD_QUAT)),
),
... | @@ -2200,6 +2200,36 @@ def test_urdf_mimic(show_viewer, tol):
assert_allclose(gs_qpos[-1], gs_qpos[-2], tol=tol)
+@pytest.mark.required
+@pytest.mark.parametrize("backend", [gs.cpu])
+def test_gravity(show_viewer):
+ base_rpm = 14468.429183500699
+ scene = gs.Scene(
+ show_viewer=show_viewer,
+ ... | tests/test_rigid_physics.py | 26 | Python | 0.214 | refactor | 69 | 51 | 51 | false | [FEATURE] Environment-wise gravity | 1,324 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [FEATURE] Environment-wise gravity
BEFORE CODE: assert scene.rigid_solver.n_equalities == 1
qvel = scene.rigid_solver.dofs_state.vel.to_numpy()
qvel[-1] = 1
scene.rigid_solver.dofs_state.vel.from_numpy(qve... | Just simulate a dropping sphere. A drone is way too complex 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. |
scene.step()
gs_qpos = scene.rigid_solver.qpos.to_numpy()[:, 0]
assert_allclose(gs_qpos[-1], gs_qpos[-2], tol=tol)
@pytest.mark.required
@pytest.mark.parametrize("backend", [gs.cpu])
def test_gravity(show_viewer):
base_rpm = 14468.429183500699
scene = gs.Scene(
show_viewer=show_viewer... | This is too long. 200 steps should be fine. | ),
vis_mode="collision",
)
entities[(fixed, merge_fixed_links)] = entity
scene.build()
def _check_entity_positions(relative, tol):
nonlocal entities
AABB_all = []
for key in ((False, False), (False, True), (True, False), (True, True)):
... | @@ -2200,6 +2200,36 @@ def test_urdf_mimic(show_viewer, tol):
assert_allclose(gs_qpos[-1], gs_qpos[-2], tol=tol)
+@pytest.mark.required
+@pytest.mark.parametrize("backend", [gs.cpu])
+def test_gravity(show_viewer):
+ base_rpm = 14468.429183500699
+ scene = gs.Scene(
+ show_viewer=show_viewer,
+ ... | tests/test_rigid_physics.py | 26 | Python | 0.143 | refactor | 43 | 51 | 51 | false | [FEATURE] Environment-wise gravity | 1,324 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [FEATURE] Environment-wise gravity
BEFORE CODE: scene.step()
gs_qpos = scene.rigid_solver.qpos.to_numpy()[:, 0]
assert_allclose(gs_qpos[-1], gs_qpos[-2], tol=tol)
@pytest.mark.required
@pytest.mark.param... | This is too long. 200 steps should be fine. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@pytest.mark.required
@pytest.mark.parametrize("backend", [gs.cpu])
def test_gravity(show_viewer):
base_rpm = 14468.429183500699
scene = gs.Scene(
show_viewer=show_viewer,
sim_options=gs.options.SimOptions(
dt=0.01,
substeps=1,
gravity=[(0.0, 0.0, -9.8), (0.0,... | For the dropping sphere, you should be able to check analytically that the positions match the theory. | def _check_entity_positions(relative, tol):
nonlocal entities
AABB_all = []
for key in ((False, False), (False, True), (True, False), (True, True)):
AABB = np.array(
[
[np.inf, np.inf, np.inf],
[-np.inf, -np.inf, -np.inf],
... | @@ -2200,6 +2200,36 @@ def test_urdf_mimic(show_viewer, tol):
assert_allclose(gs_qpos[-1], gs_qpos[-2], tol=tol)
+@pytest.mark.required
+@pytest.mark.parametrize("backend", [gs.cpu])
+def test_gravity(show_viewer):
+ base_rpm = 14468.429183500699
+ scene = gs.Scene(
+ show_viewer=show_viewer,
+ ... | tests/test_rigid_physics.py | 26 | Python | 0.429 | suggestion | 102 | 51 | 51 | false | [FEATURE] Environment-wise gravity | 1,324 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [FEATURE] Environment-wise gravity
BEFORE CODE: @pytest.mark.required
@pytest.mark.parametrize("backend", [gs.cpu])
def test_gravity(show_viewer):
base_rpm = 14468.429183500699
scene = gs.Scene(
show_viewer... | For the dropping sphere, you should be able to check analytically that the positions match the theory. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
sf_options: SFOptions,
pbd_options: PBDOptions,
):
self._scene = scene
# options
self.options = options
self.coupler_options = coupler_options
self.tool_options = tool_options
self.rigid_options = rigid_options
self.avatar_options = avatar_opt... | All of this seems over complicated. Only store gravity as a torch tensor at this point. Then check in the attribute getter if the simulation has been built already. If so, then fetch the value from the solver, otherwise return the local value.
| sf_options: SFOptions,
pbd_options: PBDOptions,
):
self._scene = scene
# options
self.options = options
self.coupler_options = coupler_options
self.tool_options = tool_options
self.rigid_options = rigid_options
self.avatar_options = avatar_opt... | @@ -106,7 +106,8 @@ def __init__(
self._steps_local = options._steps_local
self._cur_substep_global = 0
- self._gravity = np.array(options.gravity)
+ self._g_np = np.asarray(options.gravity, dtype=np.float32) | genesis/engine/simulator.py | 26 | Python | 0.429 | suggestion | 245 | 51 | 51 | false | [FEATURE] Environment-wise gravity | 1,324 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/simulator.py
PR Title: [FEATURE] Environment-wise gravity
BEFORE CODE: sf_options: SFOptions,
pbd_options: PBDOptions,
):
self._scene = scene
# options
self.options = options
self.coupler_opti... | All of this seems over complicated. Only store gravity as a torch tensor at this point. Then check in the attribute getter if the simulation has been built already. If so, then fetch the value from the solver, otherwise return the local value.
| You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if TYPE_CHECKING:
from genesis.engine.scene import Scene
from genesis.engine.simulator import Simulator
class Solver(RBC):
def __init__(self, scene: "Scene", sim: "Simulator", options):
self._uid = gs.UID()
self._sim = sim
self._scene = scene
self._dt: float = options.dt
... | Remove this method and move its content line 23. | from genesis.repr_base import RBC
if TYPE_CHECKING:
from genesis.engine.scene import Scene
from genesis.engine.simulator import Simulator
class Solver(RBC):
def __init__(self, scene: "Scene", sim: "Simulator", options):
self._uid = gs.UID()
self._sim = sim
self._scene = scene
... | @@ -34,6 +31,15 @@ def __init__(self, scene: "Scene", sim: "Simulator", options):
def _add_force_field(self, force_field):
self._ffs.append(force_field)
+ def _finalize_batch(self, B: int): | genesis/engine/solvers/base_solver.py | 26 | Python | 0.143 | refactor | 48 | 51 | 51 | false | [FEATURE] Environment-wise gravity | 1,324 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/base_solver.py
PR Title: [FEATURE] Environment-wise gravity
BEFORE CODE:
if TYPE_CHECKING:
from genesis.engine.scene import Scene
from genesis.engine.simulator import Simulator
class Solver(RBC):
def __init__(self, scene: ... | Remove this method and move its content line 23. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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.repr_base import RBC
if TYPE_CHECKING:
from genesis.engine.scene import Scene
from genesis.engine.simulator import Simulator
class Solver(RBC):
def __init__(self, scene: "Scene", sim: "Simulator", options):
self._uid = gs.UID()
self._sim = sim
self._scene = scene
... | What about removing `B: int` from the input arguments and just do `self._B = self._sim._B` inside this method? Then call `super.build()` in all derived implementations of `Solver`. | from genesis.repr_base import RBC
if TYPE_CHECKING:
from genesis.engine.scene import Scene
from genesis.engine.simulator import Simulator
class Solver(RBC):
def __init__(self, scene: "Scene", sim: "Simulator", options):
self._uid = gs.UID()
self._sim = sim
self._scene = scene
... | @@ -36,6 +30,22 @@ def __init__(self, scene: "Scene", sim: "Simulator", options):
def _add_force_field(self, force_field):
self._ffs.append(force_field)
+
+ def build(self, B: int): | genesis/engine/solvers/base_solver.py | 26 | Python | 0.5 | question | 180 | 51 | 51 | false | [FEATURE] Environment-wise gravity | 1,324 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/base_solver.py
PR Title: [FEATURE] Environment-wise gravity
BEFORE CODE: from genesis.repr_base import RBC
if TYPE_CHECKING:
from genesis.engine.scene import Scene
from genesis.engine.simulator import Simulator
class Solver(R... | What about removing `B: int` from the input arguments and just do `self._B = self._sim._B` inside this method? Then call `super.build()` in all derived implementations of `Solver`. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 taichi as ti
import torch
from genesis.utils.misc import ti_field_to_torch
import genesis as gs
from genesis.engine.entities.base_entity import Entity
from genesis.repr_base import RBC
if TYPE_CHECKING:
from genesis.engine.scene import Scene
from gen... | You need to keep track of the solver-specific gravity:
```python
self._init_gravity = getattr(options, "gravity")
``` | from typing import TYPE_CHECKING
import numpy as np
import taichi as ti
import torch
from genesis.utils.misc import ti_field_to_torch
import genesis as gs
from genesis.engine.entities.base_entity import Entity
from genesis.repr_base import RBC
if TYPE_CHECKING:
from genesis.engine.scene import Scene
from gen... | @@ -21,13 +21,7 @@ def __init__(self, scene: "Scene", sim: "Simulator", options):
self._scene = scene
self._dt: float = options.dt
self._substep_dt: float = options.dt / sim.substeps
-
- if hasattr(options, "gravity"):
- self._gravity = ti.field(dtype=gs.ti_vec3, shape=())
-... | genesis/engine/solvers/base_solver.py | 23 | Python | 0.714 | suggestion | 120 | 48 | 48 | false | [FEATURE] Environment-wise gravity | 1,324 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/base_solver.py
PR Title: [FEATURE] Environment-wise gravity
BEFORE CODE: from typing import TYPE_CHECKING
import numpy as np
import taichi as ti
import torch
from genesis.utils.misc import ti_field_to_torch
import genesis as gs
from gen... | You need to keep track of the solver-specific gravity:
```python
self._init_gravity = getattr(options, "gravity")
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 TYPE_CHECKING:
from genesis.engine.scene import Scene
from genesis.engine.simulator import Simulator
class Solver(RBC):
def __init__(self, scene: "Scene", sim: "Simulator", options):
self._uid = gs.UID()
self._sim = sim
self._scene = scene
self._dt: float = options.dt
... | ```python
if self._init_gravity is not None:
gravity = np.asarray(self._init_gravity, dtype=gs.np_float)
[...]
``` |
if TYPE_CHECKING:
from genesis.engine.scene import Scene
from genesis.engine.simulator import Simulator
class Solver(RBC):
def __init__(self, scene: "Scene", sim: "Simulator", options):
self._uid = gs.UID()
self._sim = sim
self._scene = scene
self._dt: float = options.dt
... | @@ -36,6 +30,22 @@ def __init__(self, scene: "Scene", sim: "Simulator", options):
def _add_force_field(self, force_field):
self._ffs.append(force_field)
+
+ def build(self, B: int):
+ self._B = B
+ g_np = np.asarray(self._sim._gravity) | genesis/engine/solvers/base_solver.py | 26 | Python | 0.857 | suggestion | 126 | 51 | 51 | false | [FEATURE] Environment-wise gravity | 1,324 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/base_solver.py
PR Title: [FEATURE] Environment-wise gravity
BEFORE CODE:
if TYPE_CHECKING:
from genesis.engine.scene import Scene
from genesis.engine.simulator import Simulator
class Solver(RBC):
def __init__(self, scene: ... | ```python
if self._init_gravity is not None:
gravity = np.asarray(self._init_gravity, dtype=gs.np_float)
[...]
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
show_viewer=show_viewer,
sim_options=gs.options.SimOptions(
dt=0.002,
substeps=1,
),
)
drone_ref = scene_ref.add_entity(
morph=gs.morphs.Drone(
file="urdf/drones/cf2x.urdf",
pos=(0, 0, 1.0),
),
)
scene_ref.build()
... | Just do:
```python
scene = gs.Scene(
show_viewer=show_viewer,
)
``` | scene = gs.Scene(
show_viewer=show_viewer,
)
hand = scene.add_entity(
gs.morphs.URDF(
file="urdf/panda_bullet/hand.urdf",
fixed=True,
),
)
scene.build()
assert scene.rigid_solver.n_equalities == 1
qvel = scene.rigid_solver.dofs_state.vel.to_nu... | @@ -2210,6 +2210,33 @@ def test_urdf_mimic(show_viewer, tol):
@pytest.mark.required
@pytest.mark.parametrize("backend", [gs.cpu])
+def test_gravity(show_viewer, tol):
+ scene = gs.Scene( | tests/test_rigid_physics.py | 26 | Python | 0.571 | suggestion | 83 | 51 | 51 | false | [FEATURE] Environment-wise gravity | 1,324 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [FEATURE] Environment-wise gravity
BEFORE CODE: show_viewer=show_viewer,
sim_options=gs.options.SimOptions(
dt=0.002,
substeps=1,
),
)
drone_ref = scene_ref.add_entit... | Just do:
```python
scene = gs.Scene(
show_viewer=show_viewer,
)
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if TYPE_CHECKING:
from genesis.engine.scene import Scene
from genesis.engine.simulator import Simulator
class Solver(RBC):
def __init__(self, scene: "Scene", sim: "Simulator", options):
self._uid = gs.UID()
self._sim = sim
self._scene = scene
self._dt: float = options.dt
... | If think you should rather completely ignore gravity if `self._init_gravity` is None:
```python
if self._init_gravity is not None:
gravity = np.asarray(self._init_gravity, dtype=np.float32)
gravity = np.repeat(g_np[None], self._B, axis=0)
self._gravity = ti.Vector.field(3, dtype=gs.ti_float, shape=... | if TYPE_CHECKING:
from genesis.engine.scene import Scene
from genesis.engine.simulator import Simulator
class Solver(RBC):
def __init__(self, scene: "Scene", sim: "Simulator", options):
self._uid = gs.UID()
self._sim = sim
self._scene = scene
self._dt: float = options.dt
... | @@ -36,6 +31,29 @@ def __init__(self, scene: "Scene", sim: "Simulator", options):
def _add_force_field(self, force_field):
self._ffs.append(force_field)
+ def build(self):
+ self._B = self._sim._B
+
+ g_np = np.asarray( | genesis/engine/solvers/base_solver.py | 26 | Python | 1 | suggestion | 372 | 51 | 51 | false | [FEATURE] Environment-wise gravity | 1,324 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/base_solver.py
PR Title: [FEATURE] Environment-wise gravity
BEFORE CODE: if TYPE_CHECKING:
from genesis.engine.scene import Scene
from genesis.engine.simulator import Simulator
class Solver(RBC):
def __init__(self, scene: "... | If think you should rather completely ignore gravity if `self._init_gravity` is None:
```python
if self._init_gravity is not None:
gravity = np.asarray(self._init_gravity, dtype=np.float32)
gravity = np.repeat(g_np[None], self._B, axis=0)
self._gravity = ti.Vector.field(3, dtype=gs.ti_float, 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. |
self._dt: float = options.dt
self._substep_dt: float = options.dt / sim.substeps
self._init_gravity = getattr(options, "gravity", None)
self._gravity = None
self._entities: list[Entity] = gs.List()
# force fields
self._ffs = list()
def _add_force_field(self,... | You cannot do that. Overwriting instance methods is very hacky and should only be used in last resort. Why would this be required in the first place? It is required by `set_gravity`, then just update `set_gravity` accordingly to avoid relying on this mechanism. | self._dt: float = options.dt
self._substep_dt: float = options.dt / sim.substeps
self._init_gravity = getattr(options, "gravity", None)
self._gravity = None
self._entities: list[Entity] = gs.List()
# force fields
self._ffs = list()
def _add_force_field(self,... | @@ -36,6 +31,29 @@ def __init__(self, scene: "Scene", sim: "Simulator", options):
def _add_force_field(self, force_field):
self._ffs.append(force_field)
+ def build(self):
+ self._B = self._sim._B
+
+ g_np = np.asarray(
+ self._init_gravity if self._init_gravity is not None e... | genesis/engine/solvers/base_solver.py | 26 | Python | 0.643 | suggestion | 261 | 51 | 51 | false | [FEATURE] Environment-wise gravity | 1,324 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/base_solver.py
PR Title: [FEATURE] Environment-wise gravity
BEFORE CODE: self._dt: float = options.dt
self._substep_dt: float = options.dt / sim.substeps
self._init_gravity = getattr(options, "gravity", None)
... | You cannot do that. Overwriting instance methods is very hacky and should only be used in last resort. Why would this be required in the first place? It is required by `set_gravity`, then just update `set_gravity` accordingly to avoid relying on this mechanism. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
def __init__(self, scene: "Scene", sim: "Simulator", options):
self._uid = gs.UID()
self._sim = sim
self._scene = scene
self._dt: float = options.dt
self._substep_dt: float = options.dt / sim.substeps
self._init_gravity = getattr(options, "gravity", None)
self... | Add `@gs.assert_built` decorator. | def __init__(self, scene: "Scene", sim: "Simulator", options):
self._uid = gs.UID()
self._sim = sim
self._scene = scene
self._dt: float = options.dt
self._substep_dt: float = options.dt / sim.substeps
self._init_gravity = getattr(options, "gravity", None)
self... | @@ -36,6 +31,29 @@ def __init__(self, scene: "Scene", sim: "Simulator", options):
def _add_force_field(self, force_field):
self._ffs.append(force_field)
+ def build(self):
+ self._B = self._sim._B
+
+ g_np = np.asarray(
+ self._init_gravity if self._init_gravity is not None e... | genesis/engine/solvers/base_solver.py | 26 | Python | 0.214 | suggestion | 33 | 51 | 51 | false | [FEATURE] Environment-wise gravity | 1,324 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/base_solver.py
PR Title: [FEATURE] Environment-wise gravity
BEFORE CODE: def __init__(self, scene: "Scene", sim: "Simulator", options):
self._uid = gs.UID()
self._sim = sim
self._scene = scene
self._dt... | Add `@gs.assert_built` decorator. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
class Solver(RBC):
def __init__(self, scene: "Scene", sim: "Simulator", options):
self._uid = gs.UID()
self._sim = sim
self._scene = scene
self._dt: float = options.dt
self._substep_dt: float = options.dt / sim.substeps
self._init_gravity = getattr(options, "gravity",... | It is already None. No need to set it again. | class Solver(RBC):
def __init__(self, scene: "Scene", sim: "Simulator", options):
self._uid = gs.UID()
self._sim = sim
self._scene = scene
self._dt: float = options.dt
self._substep_dt: float = options.dt / sim.substeps
self._init_gravity = getattr(options, "gravity",... | @@ -36,6 +31,28 @@ def __init__(self, scene: "Scene", sim: "Simulator", options):
def _add_force_field(self, force_field):
self._ffs.append(force_field)
+ def build(self):
+ self._B = self._sim._B
+ if self._init_gravity is not None:
+ g_np = np.asarray(self._init_gravity, dt... | genesis/engine/solvers/base_solver.py | 26 | Python | 0.071 | suggestion | 44 | 51 | 51 | false | [FEATURE] Environment-wise gravity | 1,324 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/base_solver.py
PR Title: [FEATURE] Environment-wise gravity
BEFORE CODE: class Solver(RBC):
def __init__(self, scene: "Scene", sim: "Simulator", options):
self._uid = gs.UID()
self._sim = sim
self._scene = sce... | It is already None. No need to set it again. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
r_max = ti.min(self._solver.terrain_rc[0] - 1, r_max)
c_max = ti.min(self._solver.terrain_rc[1] - 1, c_max)
cnt = 0
for r in range(r_min, r_max):
nvert = 0
for c in range(c_min, c_max + 1):
f... | ahh... surprised it did not cause error before |
cnt = 0
for r in range(r_min, r_max):
nvert = 0
for c in range(c_min, c_max + 1):
for i in range(2):
if cnt < self._n_contacts_per_pair:
nvert = nvert + 1
... | @@ -622,24 +620,27 @@ def _func_contact_mpr_terrain(self, i_ga, i_gb, i_b):
or self.prism[4, i_b][2] >= self.xyz_max_min[5, i_b]
or self.prism[5, i_b][2] >= self.xyz_max_min[5, i_b]
):
- ... | genesis/engine/solvers/rigid/collider_decomp.py | 26 | Python | 0.286 | suggestion | 46 | 51 | 51 | false | [BUG FIX] Fix terrain collision detection. | 1,338 | Genesis-Embodied-AI/Genesis | 26,702 | Python | YilingQiao | duburcqa | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/collider_decomp.py
PR Title: [BUG FIX] Fix terrain collision detection.
BEFORE CODE: r_max = ti.min(self._solver.terrain_rc[0] - 1, r_max)
c_max = ti.min(self._solver.terrain_rc[1] - 1, c_max)
... | ahh... surprised it did not cause error before | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
mesh_name = gs_usd_mesh.metadata["name"].split("/")[-1]
gs_glb_mesh = gs_glb_mesh_dict[mesh_name]
check_gs_meshes(gs_glb_mesh, gs_usd_mesh, mesh_name)
gs_glb_material = gs_glb_mesh.surface
gs_usd_material = gs_usd_mesh.surface
material_name = gs_glb_mesh.metadata["name"]... | Could you add several glb, including one requiring support of "support non-uint8 + 1/2-channel textures" ? | gs_glb_mesh = gs_glb_mesh_dict[mesh_name]
check_gs_meshes(gs_glb_mesh, gs_usd_mesh, mesh_name)
gs_glb_material = gs_glb_mesh.surface
gs_usd_material = gs_usd_mesh.surface
material_name = gs_glb_mesh.metadata["name"]
check_gs_textures(gs_glb_material.get_texture(), gs_usd... | @@ -292,3 +293,24 @@ def test_usd_parse(usd_filename):
check_gs_textures(
gs_glb_material.emissive_texture, gs_usd_material.emissive_texture, 0.0, material_name, "emissive"
)
+
+
+@pytest.mark.required
+def test_urdf_with_existing_glb():
+ assets = Path(gs.utils.get_assets_dir())
+ ... | tests/test_mesh.py | 26 | Python | 0.429 | question | 106 | 43 | 51 | false | [FEATURE] URDF-GLB import: support non-uint8 + 1/2-channel textures | 1,343 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_mesh.py
PR Title: [FEATURE] URDF-GLB import: support non-uint8 + 1/2-channel textures
BEFORE CODE: mesh_name = gs_usd_mesh.metadata["name"].split("/")[-1]
gs_glb_mesh = gs_glb_mesh_dict[mesh_name]
check_gs_meshes(gs_glb_mesh,... | Could you add several glb, including one requiring support of "support non-uint8 + 1/2-channel textures" ? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 gs_usd_mesh in gs_usd_meshes:
mesh_name = gs_usd_mesh.metadata["name"].split("/")[-1]
gs_glb_mesh = gs_glb_mesh_dict[mesh_name]
check_gs_meshes(gs_glb_mesh, gs_usd_mesh, mesh_name)
gs_glb_material = gs_glb_mesh.surface
gs_usd_material = gs_usd_mesh.surface
materi... | `def test_urdf_with_existing_glb(tmp_path, show_viewer):` | mesh_name = gs_usd_mesh.metadata["name"].split("/")[-1]
gs_glb_mesh = gs_glb_mesh_dict[mesh_name]
check_gs_meshes(gs_glb_mesh, gs_usd_mesh, mesh_name)
gs_glb_material = gs_glb_mesh.surface
gs_usd_material = gs_usd_mesh.surface
material_name = gs_glb_mesh.metadata["name"]... | @@ -292,3 +293,24 @@ def test_usd_parse(usd_filename):
check_gs_textures(
gs_glb_material.emissive_texture, gs_usd_material.emissive_texture, 0.0, material_name, "emissive"
)
+
+
+@pytest.mark.required
+def test_urdf_with_existing_glb(): | tests/test_mesh.py | 26 | Python | 0.357 | suggestion | 57 | 44 | 51 | false | [FEATURE] URDF-GLB import: support non-uint8 + 1/2-channel textures | 1,343 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_mesh.py
PR Title: [FEATURE] URDF-GLB import: support non-uint8 + 1/2-channel textures
BEFORE CODE: for gs_usd_mesh in gs_usd_meshes:
mesh_name = gs_usd_mesh.metadata["name"].split("/")[-1]
gs_glb_mesh = gs_glb_mesh_dict[mesh_name... | `def test_urdf_with_existing_glb(tmp_path, show_viewer):` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
gs_glb_material = gs_glb_mesh.surface
gs_usd_material = gs_usd_mesh.surface
material_name = gs_glb_mesh.metadata["name"]
check_gs_textures(gs_glb_material.get_texture(), gs_usd_material.get_texture(), 1.0, material_name, "color")
check_gs_textures(
gs_glb_material.opa... | `urdf_path = tmp_path / "model.urdf"` | gs_usd_material = gs_usd_mesh.surface
material_name = gs_glb_mesh.metadata["name"]
check_gs_textures(gs_glb_material.get_texture(), gs_usd_material.get_texture(), 1.0, material_name, "color")
check_gs_textures(
gs_glb_material.opacity_texture, gs_usd_material.opacity_texture,... | @@ -292,3 +293,24 @@ def test_usd_parse(usd_filename):
check_gs_textures(
gs_glb_material.emissive_texture, gs_usd_material.emissive_texture, 0.0, material_name, "emissive"
)
+
+
+@pytest.mark.required
+def test_urdf_with_existing_glb():
+ assets = Path(gs.utils.get_assets_dir())
+ ... | tests/test_mesh.py | 26 | Python | 0.214 | suggestion | 37 | 39 | 51 | false | [FEATURE] URDF-GLB import: support non-uint8 + 1/2-channel textures | 1,343 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_mesh.py
PR Title: [FEATURE] URDF-GLB import: support non-uint8 + 1/2-channel textures
BEFORE CODE: gs_glb_material = gs_glb_mesh.surface
gs_usd_material = gs_usd_mesh.surface
material_name = gs_glb_mesh.metadata["name"]
... | `urdf_path = tmp_path / "model.urdf"` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
check_gs_textures(
gs_glb_material.metallic_texture, gs_usd_material.metallic_texture, 0.0, material_name, "metallic"
)
check_gs_textures(gs_glb_material.normal_texture, gs_usd_material.normal_texture, 0.0, material_name, "normal")
check_gs_textures(
gs_glb_materi... | ```python
scene = gs.Scene(
show_viewer= show_viewer,
show_FPS=False,
)
``` | gs_glb_material.metallic_texture, gs_usd_material.metallic_texture, 0.0, material_name, "metallic"
)
check_gs_textures(gs_glb_material.normal_texture, gs_usd_material.normal_texture, 0.0, material_name, "normal")
check_gs_textures(
gs_glb_material.emissive_texture, gs_usd... | @@ -292,3 +293,24 @@ def test_usd_parse(usd_filename):
check_gs_textures(
gs_glb_material.emissive_texture, gs_usd_material.emissive_texture, 0.0, material_name, "emissive"
)
+
+
+@pytest.mark.required
+def test_urdf_with_existing_glb():
+ assets = Path(gs.utils.get_assets_dir())
+ ... | tests/test_mesh.py | 26 | Python | 0.571 | suggestion | 88 | 29 | 51 | false | [FEATURE] URDF-GLB import: support non-uint8 + 1/2-channel textures | 1,343 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_mesh.py
PR Title: [FEATURE] URDF-GLB import: support non-uint8 + 1/2-channel textures
BEFORE CODE: check_gs_textures(
gs_glb_material.metallic_texture, gs_usd_material.metallic_texture, 0.0, material_name, "metallic"
)
... | ```python
scene = gs.Scene(
show_viewer= show_viewer,
show_FPS=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. |
gs_glb_material.roughness_texture, gs_usd_material.roughness_texture, 1.0, material_name, "roughness"
)
check_gs_textures(
gs_glb_material.metallic_texture, gs_usd_material.metallic_texture, 0.0, material_name, "metallic"
)
check_gs_textures(gs_glb_material.normal... | Skip line:
```python
</robot>
"""
``` | )
check_gs_textures(
gs_glb_material.metallic_texture, gs_usd_material.metallic_texture, 0.0, material_name, "metallic"
)
check_gs_textures(gs_glb_material.normal_texture, gs_usd_material.normal_texture, 0.0, material_name, "normal")
check_gs_textures(
gs_... | @@ -292,3 +293,24 @@ def test_usd_parse(usd_filename):
check_gs_textures(
gs_glb_material.emissive_texture, gs_usd_material.emissive_texture, 0.0, material_name, "emissive"
)
+
+
+@pytest.mark.required
+def test_urdf_with_existing_glb():
+ assets = Path(gs.utils.get_assets_dir())
+ ... | tests/test_mesh.py | 26 | Python | 0.429 | suggestion | 44 | 31 | 51 | false | [FEATURE] URDF-GLB import: support non-uint8 + 1/2-channel textures | 1,343 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_mesh.py
PR Title: [FEATURE] URDF-GLB import: support non-uint8 + 1/2-channel textures
BEFORE CODE: gs_glb_material.roughness_texture, gs_usd_material.roughness_texture, 1.0, material_name, "roughness"
)
check_gs_textures(... | Skip line:
```python
</robot>
"""
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 exr_header["compression"].v > Imath.Compression.PIZ_COMPRESSION:
new_image_path = f"{self.image_path[:-4]}_ZIP.exr"
gs.logger.warning(
f"EXR image {self.image_path}'s compression type {exr_header['compression']} is not s... | `if np.issubdtype(value.dtype, np.floating):` |
if exr_header["compression"].v > Imath.Compression.PIZ_COMPRESSION:
new_image_path = f"{self.image_path[:-4]}_ZIP.exr"
gs.logger.warning(
f"EXR image {self.image_path}'s compression type {exr_header['compression']} is not s... | @@ -141,6 +141,30 @@ def __init__(self, **data):
elif self.image_array is not None:
if not isinstance(self.image_array, np.ndarray):
gs.raise_exception("`image_array` needs to be an numpy array.")
+ if self.image_array.dtype != np.uint8:
+ if self.image_a... | genesis/options/textures.py | 26 | Python | 0.357 | suggestion | 45 | 51 | 51 | false | [FEATURE] URDF-GLB import: support non-uint8 + 1/2-channel textures | 1,343 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/options/textures.py
PR Title: [FEATURE] URDF-GLB import: support non-uint8 + 1/2-channel textures
BEFORE CODE:
if exr_header["compression"].v > Imath.Compression.PIZ_COMPRESSION:
new_image_path = f"{self.ima... | `if np.issubdtype(value.dtype, np.floating):` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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_urdf_with_existing_glb(tmp_path, show_viewer):
assets = Path(gs.utils.get_assets_dir())
glb_path = assets / "usd" / "sneaker_airforce.glb"
urdf_path = tmp_path / "model.urdf"
urdf_path.write_text(
f"""<robot name="shoe">
<link name="base">
... | Could you merge this test with the next one and use `@pytest.mark.parametrize("float_type", [np.float32, np.float64])` decorate to run it for both? This would avoid a lot of code duplication. | @pytest.mark.required
def test_urdf_with_existing_glb(tmp_path, show_viewer):
assets = Path(gs.utils.get_assets_dir())
glb_path = assets / "usd" / "sneaker_airforce.glb"
urdf_path = tmp_path / "model.urdf"
urdf_path.write_text(
f"""<robot name="shoe">
<link name="base">
... | @@ -292,3 +293,95 @@ def test_usd_parse(usd_filename):
check_gs_textures(
gs_glb_material.emissive_texture, gs_usd_material.emissive_texture, 0.0, material_name, "emissive"
)
+
+
+@pytest.mark.required
+def test_urdf_with_existing_glb(tmp_path, show_viewer):
+ assets = Path(gs.utils.ge... | tests/test_mesh.py | 26 | Python | 0.714 | question | 191 | 51 | 51 | false | [FEATURE] URDF-GLB import: support non-uint8 + 1/2-channel textures | 1,343 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_mesh.py
PR Title: [FEATURE] URDF-GLB import: support non-uint8 + 1/2-channel textures
BEFORE CODE:
@pytest.mark.required
def test_urdf_with_existing_glb(tmp_path, show_viewer):
assets = Path(gs.utils.get_assets_dir())
glb_path = assets / "u... | Could you merge this test with the next one and use `@pytest.mark.parametrize("float_type", [np.float32, np.float64])` decorate to run it for both? This would avoid a lot of code duplication. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
)
check_gs_textures(
gs_glb_material.roughness_texture, gs_usd_material.roughness_texture, 1.0, material_name, "roughness"
)
check_gs_textures(
gs_glb_material.metallic_texture, gs_usd_material.metallic_texture, 0.0, material_name, "metallic"
)
che... | Your indentation is shifted by one on the right. | check_gs_textures(
gs_glb_material.roughness_texture, gs_usd_material.roughness_texture, 1.0, material_name, "roughness"
)
check_gs_textures(
gs_glb_material.metallic_texture, gs_usd_material.metallic_texture, 0.0, material_name, "metallic"
)
check_gs_text... | @@ -292,3 +293,95 @@ def test_usd_parse(usd_filename):
check_gs_textures(
gs_glb_material.emissive_texture, gs_usd_material.emissive_texture, 0.0, material_name, "emissive"
)
+
+
+@pytest.mark.required
+def test_urdf_with_existing_glb(tmp_path, show_viewer):
+ assets = Path(gs.utils.ge... | tests/test_mesh.py | 26 | Python | 0.071 | style | 48 | 51 | 51 | false | [FEATURE] URDF-GLB import: support non-uint8 + 1/2-channel textures | 1,343 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_mesh.py
PR Title: [FEATURE] URDF-GLB import: support non-uint8 + 1/2-channel textures
BEFORE CODE: )
check_gs_textures(
gs_glb_material.roughness_texture, gs_usd_material.roughness_texture, 1.0, material_name, "roughness"... | Your indentation is shifted by one on the right. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
import pytest
import trimesh
import numpy as np
import os
from huggingface_hub import snapshot_download
from pathlib import Path
import genesis as gs
import genesis.utils.mesh as mu
import genesis.utils.gltf as gltf_utils
import genesis.utils.usda as usda_utils
from .utils import get_hf_assets, assert_allclose, asser... | This import is useless and can be removed: `from huggingface_hub import snapshot_download`
While you are here, can you fix all import ordering? Here is the rule: You should first import standards libraries, skip line, then ubiquitous third-party libraries (torch, numpy, tqdm...etc), skip line, then random third-part... | import os
from pathlib import Path
import numpy as np
import pytest
import trimesh
import genesis as gs
import genesis.utils.gltf as gltf_utils
import genesis.utils.mesh as mu
import genesis.utils.usda as usda_utils
from .utils import assert_allclose, assert_array_equal, get_hf_assets
VERTICES_TOL = 1e-05 # Transfo... | @@ -3,6 +3,7 @@
import numpy as np
import os
from huggingface_hub import snapshot_download | tests/test_mesh.py | 5 | Python | 0.643 | style | 479 | 30 | 30 | false | [FEATURE] URDF-GLB import: support non-uint8 + 1/2-channel textures | 1,343 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_mesh.py
PR Title: [FEATURE] URDF-GLB import: support non-uint8 + 1/2-channel textures
BEFORE CODE: import pytest
import trimesh
import numpy as np
import os
from huggingface_hub import snapshot_download
from pathlib import Path
import genesis as gs... | This import is useless and can be removed: `from huggingface_hub import snapshot_download`
While you are here, can you fix all import ordering? Here is the rule: You should first import standards libraries, skip line, then ubiquitous third-party libraries (torch, numpy, tqdm...etc), skip line, then random third-part... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
import numpy as np
import skimage
import taichi as ti
import torch
import trimesh
import genesis as gs
import genesis.utils.geom as gu
import genesis.utils.mesh as mu
from genesis.repr_base import RBC
from genesis.utils.misc import tensor_to_array
if TYPE_CHECKING:
from genesis.engine.entities.rigid_entity.rigid_... | This is unnecessary. Just add the typing information directly where the variable is defined. | import numpy as np
import skimage
import taichi as ti
import torch
import trimesh
import genesis as gs
import genesis.utils.geom as gu
import genesis.utils.mesh as mu
from genesis.repr_base import RBC
from genesis.utils.misc import tensor_to_array
if TYPE_CHECKING:
from genesis.engine.materials.rigid import Rigid... | @@ -14,13 +15,23 @@
from genesis.repr_base import RBC
from genesis.utils.misc import tensor_to_array
+if TYPE_CHECKING:
+ from genesis.engine.entities.rigid_entity.rigid_entity import RigidEntity
+ from genesis.engine.entities.rigid_entity.rigid_link import RigidLink
+ from genesis.engine.materials.rigid i... | genesis/engine/entities/rigid_entity/rigid_geom.py | 26 | Python | 0.214 | style | 92 | 51 | 51 | false | [MISC] Add raycasting against box-entities in the scene | 1,346 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | gasnica | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_geom.py
PR Title: [MISC] Add raycasting against box-entities in the scene
BEFORE CODE: import numpy as np
import skimage
import taichi as ti
import torch
import trimesh
import genesis as gs
import genesis.utils.geom ... | This is unnecessary. Just add the typing information directly where the variable is defined. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
import numpy as np
from numpy.typing import NDArray
from .ray import Ray, RayHit, EPSILON2
from .vec3 import Pose, Vec3
class Aabb:
v: NDArray[np.float32]
def __init__(self, v: NDArray[np.float32]):
assert v.shape == (2, 3,), f"Aabb must be initialized with a (2,3)-element array, got {v.shape}"
... | `AABB` would be more appropriate.
| import numpy as np
from numpy.typing import NDArray
from .ray import Ray, RayHit, EPSILON
from .vec3 import Pose, Vec3
class AABB:
v: NDArray[np.float32]
def __init__(self, v: NDArray[np.float32]):
assert v.shape == (2, 3,), f"Aabb must be initialized with a (2,3)-element array, got {v.shape}"
... | @@ -0,0 +1,81 @@
+import numpy as np
+from numpy.typing import NDArray
+
+from .ray import Ray, RayHit, EPSILON2
+from .vec3 import Pose, Vec3
+
+class Aabb: | genesis/ext/pyrender/interaction/aabb.py | 7 | Python | 0.214 | suggestion | 37 | 32 | 32 | false | [MISC] Add raycasting against box-entities in the scene | 1,346 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | gasnica | Review this pull request change.
Language: Python
File: genesis/ext/pyrender/interaction/aabb.py
PR Title: [MISC] Add raycasting against box-entities in the scene
BEFORE CODE: import numpy as np
from numpy.typing import NDArray
from .ray import Ray, RayHit, EPSILON2
from .vec3 import Pose, Vec3
class Aabb:
v:... | `AABB` would be more appropriate.
| You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
class Aabb:
v: NDArray[np.float32]
def __init__(self, v: NDArray[np.float32]):
assert v.shape == (2, 3,), f"Aabb must be initialized with a (2,3)-element array, got {v.shape}"
assert v.dtype == np.float32, f"Aabb must be initialized with a float32 array, got {v.dtype}"
self.v = v
@... | `(ray.direction.v < EPSILON).any()` | class AABB:
v: NDArray[np.float32]
def __init__(self, v: NDArray[np.float32]):
assert v.shape == (2, 3,), f"Aabb must be initialized with a (2,3)-element array, got {v.shape}"
assert v.dtype == np.float32, f"Aabb must be initialized with a float32 array, got {v.dtype}"
self.v = v
@... | @@ -0,0 +1,81 @@
+import numpy as np
+from numpy.typing import NDArray
+
+from .ray import Ray, RayHit, EPSILON2
+from .vec3 import Pose, Vec3
+
+class Aabb:
+ v: NDArray[np.float32]
+
+ def __init__(self, v: NDArray[np.float32]):
+ assert v.shape == (2, 3,), f"Aabb must be initialized with a (2,3)-element... | genesis/ext/pyrender/interaction/aabb.py | 26 | Python | 0.214 | suggestion | 35 | 51 | 51 | false | [MISC] Add raycasting against box-entities in the scene | 1,346 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | gasnica | Review this pull request change.
Language: Python
File: genesis/ext/pyrender/interaction/aabb.py
PR Title: [MISC] Add raycasting against box-entities in the scene
BEFORE CODE: class Aabb:
v: NDArray[np.float32]
def __init__(self, v: NDArray[np.float32]):
assert v.shape == (2, 3,), f"Aabb must be in... | `(ray.direction.v < EPSILON).any()` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
from typing import TYPE_CHECKING
import numpy as np
import taichi as ti
import torch
import genesis as gs
from genesis.options.solvers import CouplerOptions, SAPCouplerOptions
from genesis.repr_base import RBC
if TYPE_CHECKING:
from genesis.engine.simulator import Simulator
@ti.data_oriented
class Coupler(RBC):
... | Can you fix import formatting / ordering while you are here.
Here is the rule: You should first import standards libraries, skip line, then ubiquitous third-party libraries (torch, numpy, tqdm...etc), skip line, then random third-party libraries, skip line, then our own custom libraries, skip line, then relative ge... | from typing import TYPE_CHECKING
import numpy as np
import taichi as ti
import genesis as gs
from genesis.options.solvers import CouplerOptions, SAPCouplerOptions
from genesis.repr_base import RBC
if TYPE_CHECKING:
from genesis.engine.simulator import Simulator
@ti.data_oriented
class Coupler(RBC):
"""
... | @@ -1,7 +1,7 @@
from typing import TYPE_CHECKING
import numpy as np
import taichi as ti
-
+import torch
import genesis as gs | genesis/engine/coupler.py | 5 | Python | 0.5 | style | 393 | 30 | 30 | false | [MISC] Improve reset | 1,350 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Kashu7100 | Review this pull request change.
Language: Python
File: genesis/engine/coupler.py
PR Title: [MISC] Improve reset
BEFORE CODE: from typing import TYPE_CHECKING
import numpy as np
import taichi as ti
import torch
import genesis as gs
from genesis.options.solvers import CouplerOptions, SAPCouplerOptions
from genesis.r... | Can you fix import formatting / ordering while you are here.
Here is the rule: You should first import standards libraries, skip line, then ubiquitous third-party libraries (torch, numpy, tqdm...etc), skip line, then random third-party libraries, skip line, then our own custom libraries, skip line, then relative ge... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
"""
Notes:
- When using gpu
- for non-batched env, we only parallelize certain loops that have big loop size
- for batched env, we parallelize all loops
- When using cpu, we serialize everything.
- This is emprically as fast as parallel loops even with... | `gs.logger.debug(f"Resetting Scene ~~~<{self._uid}>~~~.")` | """
Notes:
- When using gpu
- for non-batched env, we only parallelize certain loops that have big loop size
- for batched env, we parallelize all loops
- When using cpu, we serialize everything.
- This is emprically as fast as parallel loops even with... | @@ -695,23 +696,26 @@ def _parallelize(
self._para_level = gs.PARA_LEVEL.ALL
@gs.assert_built
- def reset(self, state: dict | None = None, envs_idx=None):
+ def reset(self, state: SimState | None = None, envs_idx=None):
"""
Resets the scene to its initial state.
Pa... | genesis/engine/scene.py | 26 | Python | 0.5 | bug | 58 | 51 | 51 | false | [MISC] Improve reset | 1,350 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | Kashu7100 | Review this pull request change.
Language: Python
File: genesis/engine/scene.py
PR Title: [MISC] Improve reset
BEFORE CODE: """
Notes:
- When using gpu
- for non-batched env, we only parallelize certain loops that have big loop size
- for batched env, we parallelize a... | `gs.logger.debug(f"Resetting Scene ~~~<{self._uid}>~~~.")` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
scene = gs.Scene(
show_viewer=show_viewer,
)
hand = scene.add_entity(
gs.morphs.URDF(
file="urdf/panda_bullet/hand.urdf",
fixed=True,
),
)
scene.build()
assert scene.rigid_solver.n_equalities == 1
qvel = scene.rigid_solver.dofs_state.vel.to_nu... | We already have a simple pendulum model, and this kind of inline URDF model is not aligned with the rest of the unit tests. | for i, key in enumerate(((False, False), (False, True))):
qpos = np.concatenate(
((0.0, (i - 1.5) * POS_OFFSET, 0.0), tuple(WOLRD_QUAT / np.linalg.norm(WOLRD_QUAT)), door_angle)
)
entities[key].set_qpos(qpos)
for i, key in enumerate(((True, False), (True, True))):
ent... | @@ -2299,6 +2299,56 @@ def test_urdf_mimic(show_viewer, tol):
assert_allclose(gs_qpos[-1], gs_qpos[-2], tol=tol)
+@pytest.mark.required
+@pytest.mark.parametrize("backend", [gs.cpu])
+def test_jacobian_arbitrary_point(tmp_path, show_viewer, tol):
+ urdf_path = tmp_path / "one_link.urdf" | tests/test_rigid_physics.py | 26 | Python | 0.357 | nitpick | 123 | 51 | 51 | false | [FEATURE] Add point-specific Jacobian support | 1,353 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [FEATURE] Add point-specific Jacobian support
BEFORE CODE: scene = gs.Scene(
show_viewer=show_viewer,
)
hand = scene.add_entity(
gs.morphs.URDF(
file="urdf/panda_bullet/hand.urdf",
... | We already have a simple pendulum model, and this kind of inline URDF model is not aligned with the rest of the unit tests. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
def _func_get_jacobian(self, tgt_link_idx, i_b, p_local, pos_mask, rot_mask):
for i_row, i_d in ti.ndrange(6, self.n_dofs):
self._jacobian[i_row, i_d, i_b] = 0.0
tgt_link_state = self._solver.links_state[tgt_link_idx, i_b]
tgt_link_pos = tgt_link_state.pos + gu.ti_transform_by_q... | The Jacobian was wrong before? | @ti.kernel
def _kernel_get_jacobian_zero(self, tgt_link_idx: ti.i32):
for i_b in range(self._solver._B):
self._impl_get_jacobian(tgt_link_idx, i_b, ti.Vector.zero(gs.ti_float, 3))
@ti.func
def _func_get_jacobian(self, tgt_link_idx, i_b, p_local, pos_mask, rot_mask):
for i_ro... | @@ -864,7 +878,7 @@ def _func_get_jacobian(self, tgt_link_idx, i_b, pos_mask, rot_mask):
I_d = [i_d, i_b] if ti.static(self.solver._options.batch_dofs_info) else i_d
i_d_jac = i_d + dof_offset - self._dof_start
rotation = gu.ti_transform_by_quat(self._solve... | genesis/engine/entities/rigid_entity/rigid_entity.py | 26 | Python | 0.071 | bug | 30 | 51 | 51 | false | [FEATURE] Add point-specific Jacobian support | 1,353 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_entity.py
PR Title: [FEATURE] Add point-specific Jacobian support
BEFORE CODE: def _func_get_jacobian(self, tgt_link_idx, i_b, p_local, pos_mask, rot_mask):
for i_row, i_d in ti.ndrange(6, self.n_dofs):
... | The Jacobian was wrong before? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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_jacobian(self, link, local_point=None):
"""
Get the spatial Jacobian for a point on a target link.
Parameters
----------
link : RigidLink
The target link.
local_point : torch.Tensor or None, shape (3,)
Coordinates of the point in the l... | Allocating memory for torch tensors and ti.field on the fly in python-scope is inefficient and should be avoided in possible.
Just create another kernel not taking `p_local` as input arguments, that would just call the more generic one with `ti.Vector.zero(gs.ti_float, 3)`. | def get_jacobian(self, link, local_point=None):
"""
Get the spatial Jacobian for a point on a target link.
Parameters
----------
link : RigidLink
The target link.
local_point : torch.Tensor or None, shape (3,)
Coordinates of the point in the l... | @@ -820,7 +823,16 @@ def get_jacobian(self, link):
if self.n_dofs == 0:
gs.raise_exception("Entity has zero dofs.")
- self._kernel_get_jacobian(link.idx)
+ if local_point is None: | genesis/engine/entities/rigid_entity/rigid_entity.py | 26 | Python | 0.786 | performance | 277 | 51 | 51 | false | [FEATURE] Add point-specific Jacobian support | 1,353 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_entity.py
PR Title: [FEATURE] Add point-specific Jacobian support
BEFORE CODE: def get_jacobian(self, link, local_point=None):
"""
Get the spatial Jacobian for a point on a target link.
Pa... | Allocating memory for torch tensors and ti.field on the fly in python-scope is inefficient and should be avoided in possible.
Just create another kernel not taking `p_local` as input arguments, that would just call the more generic one with `ti.Vector.zero(gs.ti_float, 3)`. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Parameters
----------
link : RigidLink
The target link.
local_point : torch.Tensor or None, shape (3,)
Coordinates of the point in the link’s *local* frame.
If None, the link origin is used (back-compat).
Returns
-------
jacob... | Just call `local_point = torch.as_tensor(local_point, device=gs.device, dtype=torch.float32)` systematically if not None. Take inspiration from `RigidSolver._sanitize_1D_io_variables`. |
Parameters
----------
link : RigidLink
The target link.
local_point : torch.Tensor or None, shape (3,)
Coordinates of the point in the link’s *local* frame.
If None, the link origin is used (back-compat).
Returns
-------
jacob... | @@ -820,7 +823,16 @@ def get_jacobian(self, link):
if self.n_dofs == 0:
gs.raise_exception("Entity has zero dofs.")
- self._kernel_get_jacobian(link.idx)
+ if local_point is None:
+ local_point = torch.zeros(3, device=gs.device, dtype=torch.float32)
+ elif isinsta... | genesis/engine/entities/rigid_entity/rigid_entity.py | 26 | Python | 0.643 | security | 184 | 51 | 51 | false | [FEATURE] Add point-specific Jacobian support | 1,353 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_entity.py
PR Title: [FEATURE] Add point-specific Jacobian support
BEFORE CODE:
Parameters
----------
link : RigidLink
The target link.
local_point : torch.Tensor or None, s... | Just call `local_point = torch.as_tensor(local_point, device=gs.device, dtype=torch.float32)` systematically if not None. Take inspiration from `RigidSolver._sanitize_1D_io_variables`. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
scene = gs.Scene(
show_viewer=show_viewer,
)
hand = scene.add_entity(
gs.morphs.URDF(
file="urdf/panda_bullet/hand.urdf",
fixed=True,
),
)
scene.build()
assert scene.rigid_solver.n_equalities == 1
qvel = scene.rigid_solver.dofs_state.vel.to_nu... | You should rather do this:
```python
@pytest.mark.required
@pytest.mark.merge_fixed_links(False)
@pytest.mark.parametrize("model_name", ["pendulum"])
def test_pendulum_links_acc(gs_sim, tol):
[...]
```
`gs_sim` is the same as `scene.sim`. You can access entities by doing `gs_sim.entities`. | for i, key in enumerate(((False, False), (False, True))):
qpos = np.concatenate(
((0.0, (i - 1.5) * POS_OFFSET, 0.0), tuple(WOLRD_QUAT / np.linalg.norm(WOLRD_QUAT)), door_angle)
)
entities[key].set_qpos(qpos)
for i, key in enumerate(((True, False), (True, True))):
ent... | @@ -2299,6 +2299,41 @@ def test_urdf_mimic(show_viewer, tol):
assert_allclose(gs_qpos[-1], gs_qpos[-2], tol=tol)
+@pytest.mark.required
+@pytest.mark.parametrize("backend", [gs.cpu])
+def test_jacobian_arbitrary_point(tmp_path, show_viewer, tol):
+ urdf_root = _build_multi_pendulum(n=1) | tests/test_rigid_physics.py | 26 | Python | 0.857 | suggestion | 307 | 51 | 51 | false | [FEATURE] Add point-specific Jacobian support | 1,353 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [FEATURE] Add point-specific Jacobian support
BEFORE CODE: scene = gs.Scene(
show_viewer=show_viewer,
)
hand = scene.add_entity(
gs.morphs.URDF(
file="urdf/panda_bullet/hand.urdf",
... | You should rather do this:
```python
@pytest.mark.required
@pytest.mark.merge_fixed_links(False)
@pytest.mark.parametrize("model_name", ["pendulum"])
def test_pendulum_links_acc(gs_sim, tol):
[...]
```
`gs_sim` is the same as `scene.sim`. You can access entities by doing `gs_sim.entities`. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Returns
-------
jacobian : torch.Tensor
The Jacobian matrix of shape (n_envs, 6, entity.n_dofs) or (6, entity.n_dofs) if n_envs == 0.
"""
if not self._requires_jac_and_IK:
gs.raise_exception(
"Inverse kinematics and jacobian are disabled f... | Converting as tensor to finally convert back to list is useless. Anyway, just pass vector.
By the way, you should prefer this signature:
```python
def _kernel_get_jacobian(self, tgt_link_idx: ti.i32, p_local: ti.template()):
```
To support both `ti.types.ndarray()` and `ti.Vector` as input argument (hopefully... |
Returns
-------
jacobian : torch.Tensor
The Jacobian matrix of shape (n_envs, 6, entity.n_dofs) or (6, entity.n_dofs) if n_envs == 0.
"""
if not self._requires_jac_and_IK:
gs.raise_exception(
"Inverse kinematics and jacobian are disabled f... | @@ -820,7 +823,19 @@ def get_jacobian(self, link):
if self.n_dofs == 0:
gs.raise_exception("Entity has zero dofs.")
- self._kernel_get_jacobian(link.idx)
+ if local_point is None:
+ self._kernel_get_jacobian(link.idx, 0.0, 0.0, 0.0)
+ else:
+ local_poin... | genesis/engine/entities/rigid_entity/rigid_entity.py | 26 | Python | 1 | suggestion | 382 | 51 | 51 | false | [FEATURE] Add point-specific Jacobian support | 1,353 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_entity.py
PR Title: [FEATURE] Add point-specific Jacobian support
BEFORE CODE:
Returns
-------
jacobian : torch.Tensor
The Jacobian matrix of shape (n_envs, 6, entity.n_dofs) or (6... | Converting as tensor to finally convert back to list is useless. Anyway, just pass vector.
By the way, you should prefer this signature:
```python
def _kernel_get_jacobian(self, tgt_link_idx: ti.i32, p_local: ti.template()):
```
To support both `ti.types.ndarray()` and `ti.Vector` as input argument (hopefully... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Parameters
----------
link : RigidLink
The target link.
local_point : torch.Tensor or None, shape (3,)
Coordinates of the point in the link’s *local* frame.
If None, the link origin is used (back-compat).
Returns
-------
jacob... | You are being overly restrictive. `torch.Tensor` should be supported. |
Parameters
----------
link : RigidLink
The target link.
local_point : torch.Tensor or None, shape (3,)
Coordinates of the point in the link’s *local* frame.
If None, the link origin is used (back-compat).
Returns
-------
jacob... | @@ -820,31 +823,50 @@ def get_jacobian(self, link):
if self.n_dofs == 0:
gs.raise_exception("Entity has zero dofs.")
- self._kernel_get_jacobian(link.idx)
+ if local_point is None:
+ self._kernel_get_jacobian_zero(link.idx)
+ else:
+ if not isinstance(l... | genesis/engine/entities/rigid_entity/rigid_entity.py | 26 | Python | 0.429 | suggestion | 69 | 51 | 51 | false | [FEATURE] Add point-specific Jacobian support | 1,353 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_entity.py
PR Title: [FEATURE] Add point-specific Jacobian support
BEFORE CODE:
Parameters
----------
link : RigidLink
The target link.
local_point : torch.Tensor or None, s... | You are being overly restrictive. `torch.Tensor` should be 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. |
The target link.
local_point : torch.Tensor or None, shape (3,)
Coordinates of the point in the link’s *local* frame.
If None, the link origin is used (back-compat).
Returns
-------
jacobian : torch.Tensor
The Jacobian matrix of shape (n_e... | Do not create taichi fields in Python scope except at init. This is inefficient. | The target link.
local_point : torch.Tensor or None, shape (3,)
Coordinates of the point in the link’s *local* frame.
If None, the link origin is used (back-compat).
Returns
-------
jacobian : torch.Tensor
The Jacobian matrix of shape (n_e... | @@ -820,31 +823,50 @@ def get_jacobian(self, link):
if self.n_dofs == 0:
gs.raise_exception("Entity has zero dofs.")
- self._kernel_get_jacobian(link.idx)
+ if local_point is None:
+ self._kernel_get_jacobian_zero(link.idx)
+ else:
+ if not isinstance(l... | genesis/engine/entities/rigid_entity/rigid_entity.py | 26 | Python | 0.214 | performance | 80 | 51 | 51 | false | [FEATURE] Add point-specific Jacobian support | 1,353 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_entity.py
PR Title: [FEATURE] Add point-specific Jacobian support
BEFORE CODE: The target link.
local_point : torch.Tensor or None, shape (3,)
Coordinates of the point in the link’s *lo... | Do not create taichi fields in Python scope except at init. This is inefficient. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
link : RigidLink
The target link.
local_point : torch.Tensor or None, shape (3,)
Coordinates of the point in the link’s *local* frame.
If None, the link origin is used (back-compat).
Returns
-------
jacobian : torch.Tensor
The Jaco... | Define a kernel that accepts `ti.types.ndarray()` directly so that you don't need to allocate a `ti.Vector` in Python-scope, which is slow. | link : RigidLink
The target link.
local_point : torch.Tensor or None, shape (3,)
Coordinates of the point in the link’s *local* frame.
If None, the link origin is used (back-compat).
Returns
-------
jacobian : torch.Tensor
The Jaco... | @@ -820,31 +823,48 @@ def get_jacobian(self, link):
if self.n_dofs == 0:
gs.raise_exception("Entity has zero dofs.")
- self._kernel_get_jacobian(link.idx)
+ if local_point is None:
+ self._kernel_get_jacobian_zero(link.idx)
+ else:
+ p_local = torch.as_... | genesis/engine/entities/rigid_entity/rigid_entity.py | 26 | Python | 0.643 | performance | 139 | 51 | 51 | false | [FEATURE] Add point-specific Jacobian support | 1,353 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_entity.py
PR Title: [FEATURE] Add point-specific Jacobian support
BEFORE CODE: link : RigidLink
The target link.
local_point : torch.Tensor or None, shape (3,)
Coordinates of th... | Define a kernel that accepts `ti.types.ndarray()` directly so that you don't need to allocate a `ti.Vector` in Python-scope, which is slow. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
----------
link : RigidLink
The target link.
local_point : torch.Tensor or None, shape (3,)
Coordinates of the point in the link’s *local* frame.
If None, the link origin is used (back-compat).
Returns
-------
jacobian : torch.Tensor
... | `must be a vector of length 3` | ----------
link : RigidLink
The target link.
local_point : torch.Tensor or None, shape (3,)
Coordinates of the point in the link’s *local* frame.
If None, the link origin is used (back-compat).
Returns
-------
jacobian : torch.Tensor
... | @@ -820,31 +823,48 @@ def get_jacobian(self, link):
if self.n_dofs == 0:
gs.raise_exception("Entity has zero dofs.")
- self._kernel_get_jacobian(link.idx)
+ if local_point is None:
+ self._kernel_get_jacobian_zero(link.idx)
+ else:
+ p_local = torch.as_... | genesis/engine/entities/rigid_entity/rigid_entity.py | 26 | Python | 0.214 | suggestion | 30 | 51 | 51 | false | [FEATURE] Add point-specific Jacobian support | 1,353 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_entity.py
PR Title: [FEATURE] Add point-specific Jacobian support
BEFORE CODE: ----------
link : RigidLink
The target link.
local_point : torch.Tensor or None, shape (3,)
... | `must be a vector of length 3` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
jacobian = self._jacobian.to_torch(gs.device).permute(2, 0, 1)
if self._solver.n_envs == 0:
jacobian = jacobian.squeeze(0)
return jacobian
@ti.func
def _impl_get_jacobian(self, tgt_link_idx, i_b, p_vec: ti.types.vector(3, ti.f64)):
self._func_get_jacobian(
... | Replace `ti.f64` by `gs.ti_float` | jacobian = self._jacobian.to_torch(gs.device).permute(2, 0, 1)
if self._solver.n_envs == 0:
jacobian = jacobian.squeeze(0)
return jacobian
@ti.func
def _impl_get_jacobian(self, tgt_link_idx, i_b, p_vec):
self._func_get_jacobian(
tgt_link_idx,
... | @@ -820,31 +823,48 @@ def get_jacobian(self, link):
if self.n_dofs == 0:
gs.raise_exception("Entity has zero dofs.")
- self._kernel_get_jacobian(link.idx)
+ if local_point is None:
+ self._kernel_get_jacobian_zero(link.idx)
+ else:
+ p_local = torch.as_... | genesis/engine/entities/rigid_entity/rigid_entity.py | 26 | Python | 0.286 | suggestion | 33 | 51 | 51 | false | [FEATURE] Add point-specific Jacobian support | 1,353 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_entity.py
PR Title: [FEATURE] Add point-specific Jacobian support
BEFORE CODE: jacobian = self._jacobian.to_torch(gs.device).permute(2, 0, 1)
if self._solver.n_envs == 0:
jacobian = jacobia... | Replace `ti.f64` by `gs.ti_float` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
self._kernel_get_jacobian_zero(link.idx)
else:
p_local = torch.as_tensor(local_point, dtype=torch.float64, device="cpu").numpy()
if p_local.shape != (3,):
gs.raise_exception("Must be a vector of length 3")
self._kernel_get_jacobian(link.idx, p_loca... | Replace `ti.f64` by `gs.ti_float` | self._kernel_get_jacobian_zero(link.idx)
else:
p_local = torch.as_tensor(local_point, dtype=gs.tc_float, device=gs.device)
if p_local.shape != (3,):
gs.raise_exception("Must be a vector of length 3")
self._kernel_get_jacobian(link.idx, p_local)
... | @@ -820,31 +823,48 @@ def get_jacobian(self, link):
if self.n_dofs == 0:
gs.raise_exception("Entity has zero dofs.")
- self._kernel_get_jacobian(link.idx)
+ if local_point is None:
+ self._kernel_get_jacobian_zero(link.idx)
+ else:
+ p_local = torch.as_... | genesis/engine/entities/rigid_entity/rigid_entity.py | 26 | Python | 0.286 | suggestion | 33 | 51 | 51 | false | [FEATURE] Add point-specific Jacobian support | 1,353 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_entity.py
PR Title: [FEATURE] Add point-specific Jacobian support
BEFORE CODE: self._kernel_get_jacobian_zero(link.idx)
else:
p_local = torch.as_tensor(local_point, dtype=torch.float64,... | Replace `ti.f64` by `gs.ti_float` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
The Jacobian matrix of shape (n_envs, 6, entity.n_dofs) or (6, entity.n_dofs) if n_envs == 0.
"""
if not self._requires_jac_and_IK:
gs.raise_exception(
"Inverse kinematics and jacobian are disabled for this entity. Set `morph.requires_jac_and_IK` to True if you ne... | Remove `: ti.types.vector(3, ti.f64)` typing information. | The Jacobian matrix of shape (n_envs, 6, entity.n_dofs) or (6, entity.n_dofs) if n_envs == 0.
"""
if not self._requires_jac_and_IK:
gs.raise_exception(
"Inverse kinematics and jacobian are disabled for this entity. Set `morph.requires_jac_and_IK` to True if you ne... | @@ -820,31 +823,48 @@ def get_jacobian(self, link):
if self.n_dofs == 0:
gs.raise_exception("Entity has zero dofs.")
- self._kernel_get_jacobian(link.idx)
+ if local_point is None:
+ self._kernel_get_jacobian_zero(link.idx)
+ else:
+ p_local = torch.as_... | genesis/engine/entities/rigid_entity/rigid_entity.py | 26 | Python | 0.571 | style | 57 | 51 | 51 | false | [FEATURE] Add point-specific Jacobian support | 1,353 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_entity.py
PR Title: [FEATURE] Add point-specific Jacobian support
BEFORE CODE: The Jacobian matrix of shape (n_envs, 6, entity.n_dofs) or (6, entity.n_dofs) if n_envs == 0.
"""
if not self.... | Remove `: ti.types.vector(3, ti.f64)` typing information. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Parameters
----------
link : RigidLink
The target link.
local_point : torch.Tensor or None, shape (3,)
Coordinates of the point in the link’s *local* frame.
If None, the link origin is used (back-compat).
Returns
-------
jacob... | `p_local = torch.as_tensor(local_point, dtype=gs.tc_float, device=gs.device)` |
Parameters
----------
link : RigidLink
The target link.
local_point : torch.Tensor or None, shape (3,)
Coordinates of the point in the link’s *local* frame.
If None, the link origin is used (back-compat).
Returns
-------
jacob... | @@ -820,31 +823,48 @@ def get_jacobian(self, link):
if self.n_dofs == 0:
gs.raise_exception("Entity has zero dofs.")
- self._kernel_get_jacobian(link.idx)
+ if local_point is None:
+ self._kernel_get_jacobian_zero(link.idx)
+ else:
+ p_local = torch.as_... | genesis/engine/entities/rigid_entity/rigid_entity.py | 26 | Python | 0.5 | suggestion | 77 | 51 | 51 | false | [FEATURE] Add point-specific Jacobian support | 1,353 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_entity.py
PR Title: [FEATURE] Add point-specific Jacobian support
BEFORE CODE:
Parameters
----------
link : RigidLink
The target link.
local_point : torch.Tensor or None, s... | `p_local = torch.as_tensor(local_point, dtype=gs.tc_float, device=gs.device)` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
subterrain_size=(12.0, 12.0),
horizontal_scale=0.25,
subterrain_types="wave_terrain",
)
)
height_ref = terrain_ref.geoms[0].metadata["height_field"]
scene_test = gs.Scene(show_viewer=show_viewer)
terrain_test = scene_test.add_entity(
morph=gs.morphs.... | You can keep the unit test for weld constraints since it is missing, but add back the unit test for the Jacobian that has been removed for some reason. | subterrain_size=(12.0, 12.0),
horizontal_scale=0.25,
subterrain_types="wave_terrain",
)
)
height_ref = terrain_ref.geoms[0].metadata["height_field"]
scene_test = gs.Scene(show_viewer=show_viewer)
terrain_test = scene_test.add_entity(
morph=gs.morphs.... | @@ -2169,6 +2169,37 @@ def test_terrain_size(show_viewer, tol):
assert_allclose((height_ref * 2.0), height_test, tol=tol)
+@pytest.mark.required
+@pytest.mark.parametrize("backend", [gs.cpu]) | tests/test_rigid_physics.py | 26 | Python | 0.429 | suggestion | 151 | 51 | 51 | false | [FEATURE] Add point-specific Jacobian support | 1,353 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [FEATURE] Add point-specific Jacobian support
BEFORE CODE: subterrain_size=(12.0, 12.0),
horizontal_scale=0.25,
subterrain_types="wave_terrain",
)
)
height_ref = terrain... | You can keep the unit test for weld constraints since it is missing, but add back the unit test for the Jacobian that has been removed for some reason. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
dofs_state: array_class.DofsState,
# we will use RigidGlobalInfo as typing after Hugh adds array_struct feature to taichi
rigid_global_info: ti.template(),
static_rigid_sim_config: ti.template(),
):
n_dofs = dofs_state.shape[0]
_B = dofs_state.shape[1]
for I i... | This is inconsistent. Sometimes flagged as ti.static and sometimes not. | dofs_state: array_class.DofsState,
# we will use RigidGlobalInfo as typing after Hugh adds array_struct feature to taichi
rigid_global_info: ti.template(),
static_rigid_sim_config: ti.template(),
):
n_dofs = dofs_state.shape[0]
_B = dofs_state.shape[1]
for I i... | @@ -490,38 +518,46 @@ def _kernel_init_dof_fields(
dofs_kp: ti.types.ndarray(),
dofs_kv: ti.types.ndarray(),
dofs_force_range: ti.types.ndarray(),
+ # taichi variables
+ dofs_info: array_class.DofsInfo,
+ dofs_state: array_class.DofsState,
+ # we will use RigidGlob... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.214 | suggestion | 71 | 51 | 51 | false | [Migration] Initial template for migration | 1,361 | 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: [Migration] Initial template for migration
BEFORE CODE: dofs_state: array_class.DofsState,
# we will use RigidGlobalInfo as typing after Hugh adds array_struct feature to taichi
... | This is inconsistent. Sometimes flagged as ti.static and sometimes not. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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_b = envs_idx[i_b_]
for i_e in range(self.n_equalities, self.constraint_solver.ti_n_equalities[i_b]):
if (
self.equalities_info[i_e, i_b].eq_type == gs.EQUALITY_TYPE.WELD
and self.equalities_info[i_e, i_b].eq_obj1id == link1_idx[i_b]
... | Just use `gs.EQUALITY_TYPE.WELD` directly. | rigid_global_info.n_awake_dofs.fill(0)
ti.loop_config(serialize=static_rigid_sim_config.para_level < gs.PARA_LEVEL.PARTIAL)
for i_e, i_b in ti.ndrange(n_entities, _B):
if entities_state.hibernated[i_e, i_b] or entities_info.n_dofs[i_e] == 0:
continue
n_awake_entities = ti.atomic_... | @@ -5002,6 +5002,41 @@ def _kernel_delete_weld_constraint(
]
self.constraint_solver.ti_n_equalities[i_b] = self.constraint_solver.ti_n_equalities[i_b] - 1
+ def get_weld_constraints(self, envs_idx=None):
+ if envs_idx is None:
+ envs_idx = np.arange(s... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.429 | suggestion | 42 | 51 | 51 | false | [FEATURE] Add 'get_weld_constraints' API. | 1,370 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [FEATURE] Add 'get_weld_constraints' API.
BEFORE CODE: i_b = envs_idx[i_b_]
for i_e in range(self.n_equalities, self.constraint_solver.ti_n_equalities[i_b]):
... | Just use `gs.EQUALITY_TYPE.WELD` directly. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
):
if i_e < self.constraint_solver.ti_n_equalities[i_b] - 1:
self.equalities_info[i_e, i_b] = self.equalities_info[
self.constraint_solver.ti_n_equalities[i_b] - 1, i_b
]
self.constraint_s... | Move all of this in a taichi kernel. | rigid_global_info.awake_entities[n_awake_entities, i_b] = i_e
for i_d in range(entities_info.dof_start[i_e], entities_info.dof_end[i_e]):
n_awake_dofs = ti.atomic_add(rigid_global_info.n_awake_dofs[i_b], 1)
rigid_global_info.awake_dofs[n_awake_dofs, i_b] = i_d
for i_l i... | @@ -5002,6 +5002,41 @@ def _kernel_delete_weld_constraint(
]
self.constraint_solver.ti_n_equalities[i_b] = self.constraint_solver.ti_n_equalities[i_b] - 1
+ def get_weld_constraints(self, envs_idx=None):
+ if envs_idx is None:
+ envs_idx = np.arange(s... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.143 | suggestion | 36 | 51 | 51 | false | [FEATURE] Add 'get_weld_constraints' API. | 1,370 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [FEATURE] Add 'get_weld_constraints' API.
BEFORE CODE: ):
if i_e < self.constraint_solver.ti_n_equalities[i_b] - 1:
self.equalities_info[i... | Move all of this in a taichi kernel. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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_weld_constraints(self, envs_idx=None):
if envs_idx is None:
envs_idx = np.arange(self.n_envs, dtype=np.int32)
envs_idx = np.atleast_1d(envs_idx)
env_col, obj_a_col, obj_b_col = [], [], []
WELD = gs.EQUALITY_TYPE.WELD
for env in envs_idx:
n_e... | You took inspiration from the wrong function. It was supposed to be `Collider.get_contacts`, not `RigidEntity.get_contacts`, sorry about that. Which mean that the API should be `def get_weld_constraints(self, as_tensor: bool = True, to_torch: bool = True):`
Then you could also add its counterpart in `RigidEntity` if... | for i_l in range(entities_info.link_start[i_e], entities_info.link_end[i_e]):
n_awake_links = ti.atomic_add(rigid_global_info.n_awake_links[i_b], 1)
rigid_global_info.awake_links[n_awake_links, i_b] = i_l
@ti.func
def func_hibernate_entity(
i_e,
i_b,
entities_state,
ent... | @@ -5002,6 +5002,41 @@ def _kernel_delete_weld_constraint(
]
self.constraint_solver.ti_n_equalities[i_b] = self.constraint_solver.ti_n_equalities[i_b] - 1
+ def get_weld_constraints(self, envs_idx=None):
+ if envs_idx is None:
+ envs_idx = np.arange(s... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.643 | bug | 346 | 51 | 51 | false | [FEATURE] Add 'get_weld_constraints' API. | 1,370 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [FEATURE] Add 'get_weld_constraints' API.
BEFORE CODE:
def get_weld_constraints(self, envs_idx=None):
if envs_idx is None:
envs_idx = np.arange(self.n_envs, dtype=np.int32)
... | You took inspiration from the wrong function. It was supposed to be `Collider.get_contacts`, not `RigidEntity.get_contacts`, sorry about that. Which mean that the API should be `def get_weld_constraints(self, as_tensor: bool = True, to_torch: bool = True):`
Then you could also add its counterpart in `RigidEntity` if... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if n_envs == 1:
buf = buf[buf[:, 1] != -1]
return {"obj_a": buf[:, 1], "obj_b": buf[:, 2]}
buf = buf.reshape(n_envs, stride, 3)
env_arr = buf[..., 0]
obj_a = buf[..., 1]
obj_b = buf[..., 2]
valid = env_arr != -1
if not as_tensor:
... | Use hard-code stride it is fine. This method is private and only called once, and it should crash anyway if the buffer shape is not correct. | dofs_state.acc[i_d, i_b] = 0.0
for i_l in range(entities_info.link_start[i_e], entities_info.link_end[i_e]):
links_state.hibernated[i_l, i_b] = True
for i_g in range(entities_info.geom_start[i_e], entities_info.geom_end[i_e]):
geoms_state.hibernated[i_g, i_b] = True
@ti.func
def func... | @@ -4998,6 +4998,69 @@ def _kernel_delete_weld_constraint(
]
self.constraint_solver.ti_n_equalities[i_b] = self.constraint_solver.ti_n_equalities[i_b] - 1
+ @gs.assert_built
+ def get_weld_constraints(self, as_tensor: bool = True, to_torch: bool = True):
+ n_... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.429 | bug | 140 | 51 | 51 | false | [FEATURE] Add 'get_weld_constraints' API. | 1,370 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [FEATURE] Add 'get_weld_constraints' API.
BEFORE CODE: if n_envs == 1:
buf = buf[buf[:, 1] != -1]
return {"obj_a": buf[:, 1], "obj_b": buf[:, 2]}
buf = buf.r... | Use hard-code stride it is fine. This method is private and only called once, and it should crash anyway if the buffer shape is not correct. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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._kernel_delete_weld_constraint(int(link1_idx), int(link2_idx), envs_idx)
@ti.kernel
def _kernel_delete_weld_constraint(
self,
link1_idx: ti.i32,
link2_idx: ti.i32,
envs_idx: ti.types.ndarray(),
):
ti.loop_config(serialize=self._para_level < gs.PARA_LEVEL... | This is still wrong. If you look more closely, there is no such thing as `valid_mask` in `RigidSolver.get_contacts`, only in `RigidEntity.get_contacts`. You should do the same here. | for j in ti.static(range(4)):
rigid_global_info.qpos[q_start + j + 3, i_b] = rot[j]
elif joint_type == gs.JOINT_TYPE.FIXED:
pass
elif joint_type == gs.JOINT_TYPE.SPHERICAL:
rot = t... | @@ -5715,6 +5715,68 @@ def _kernel_delete_weld_constraint(
]
self.constraint_solver.ti_n_equalities[i_b] = self.constraint_solver.ti_n_equalities[i_b] - 1
+ @gs.assert_built
+ def get_weld_constraints(self, as_tensor: bool = True, to_torch: bool = True): | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.571 | bug | 181 | 51 | 51 | false | [FEATURE] Add 'get_weld_constraints' API. | 1,370 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [FEATURE] Add 'get_weld_constraints' API.
BEFORE CODE: self._kernel_delete_weld_constraint(int(link1_idx), int(link2_idx), envs_idx)
@ti.kernel
def _kernel_delete_weld_constraint(
... | This is still wrong. If you look more closely, there is no such thing as `valid_mask` in `RigidSolver.get_contacts`, only in `RigidEntity.get_contacts`. You should do the same here. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
buf = np.full(shape3, -1, dtype=np.int32)
self._kernel_collect_welds(buf)
if n_envs == 1:
sub = buf[0]
sub = sub[sub[:, 1] != -1]
return {"obj_a": sub[:, 1], "obj_b": sub[:, 2]}
env_arr = buf[..., 0]
obj_a = buf[..., 1]
obj_b = buf... | Remove all these variables and use their value directly in the implementation. | continue
dof_start = links_info.dof_start[I_l]
q_start = links_info.q_start[I_l]
q_end = links_info.q_end[I_l]
i_j = links_info.joint_start[I_l]
I_j = [i_j, i_b] if ti.static(static_rigid_sim_config.batch_joints_info) else i_j
joi... | @@ -5715,6 +5715,68 @@ def _kernel_delete_weld_constraint(
]
self.constraint_solver.ti_n_equalities[i_b] = self.constraint_solver.ti_n_equalities[i_b] - 1
+ @gs.assert_built
+ def get_weld_constraints(self, as_tensor: bool = True, to_torch: bool = True):
+ n_... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.286 | suggestion | 78 | 51 | 51 | false | [FEATURE] Add 'get_weld_constraints' API. | 1,370 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [FEATURE] Add 'get_weld_constraints' API.
BEFORE CODE: buf = np.full(shape3, -1, dtype=np.int32)
self._kernel_collect_welds(buf)
if n_envs == 1:
sub = buf[0]
... | Remove all these variables and use their value directly in the implementation. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
):
if i_e < self.constraint_solver.ti_n_equalities[i_b] - 1:
self.equalities_info[i_e, i_b] = self.equalities_info[
self.constraint_solver.ti_n_equalities[i_b] - 1, i_b
]
self.constraint_s... | Could you follow more strictly the pattern in `RigidSolver.get_contacts`? You should not pass a 3D tensor because it would allocate more memory than necessary but most importantly, it will break "C"-contiguity, which would be problematic if forwarded as input argument of another taichi kernel. | dofs_state.vel[dof_start + 4, i_b],
dofs_state.vel[dof_start + 5, i_b],
]
)
* static_rigid_sim_config.substep_dt
)
... | @@ -5715,6 +5715,68 @@ def _kernel_delete_weld_constraint(
]
self.constraint_solver.ti_n_equalities[i_b] = self.constraint_solver.ti_n_equalities[i_b] - 1
+ @gs.assert_built
+ def get_weld_constraints(self, as_tensor: bool = True, to_torch: bool = True):
+ n_... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.786 | question | 294 | 51 | 51 | false | [FEATURE] Add 'get_weld_constraints' API. | 1,370 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [FEATURE] Add 'get_weld_constraints' API.
BEFORE CODE: ):
if i_e < self.constraint_solver.ti_n_equalities[i_b] - 1:
self.equalities_info[i... | Could you follow more strictly the pattern in `RigidSolver.get_contacts`? You should not pass a 3D tensor because it would allocate more memory than necessary but most importantly, it will break "C"-contiguity, which would be problematic if forwarded as input argument of another taichi kernel. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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.build(n_envs=1)
rigid = scene.sim.rigid_solver
link_a = torch.tensor([cube1.base_link.idx], dtype=gs.tc_int, device=gs.device)
link_b = torch.tensor([cube2.base_link.idx], dtype=gs.tc_int, device=gs.device)
rigid.add_weld_constraint(link_a, link_b)
scene.step()
welds = rigid.get_wel... | No need to call `np.asarray` here | scene.build()
for drone in drones:
chain_dofs = range(6, drone.n_dofs)
drone.set_dofs_armature(drone.get_dofs_armature(chain_dofs) + 1e-3, chain_dofs)
# Wait for the drones to land on the ground and hold straight
for i in range(400):
for drone in drones:
drone.set_p... | @@ -2342,6 +2342,75 @@ def test_drone_advanced(show_viewer):
assert abs(quat_1[2] - quat_2[2]) < tol
+@pytest.mark.required
+@pytest.mark.parametrize("backend", [gs.cpu])
+def test_get_weld_constraints_basic(show_viewer, tol):
+ scene = gs.Scene(
+ sim_options=gs.options.SimOptions(gravity=(0.0, 0.0,... | tests/test_rigid_physics.py | 26 | Python | 0.214 | suggestion | 33 | 51 | 51 | false | [FEATURE] Add 'get_weld_constraints' API. | 1,370 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [FEATURE] Add 'get_weld_constraints' API.
BEFORE CODE: scene.build(n_envs=1)
rigid = scene.sim.rigid_solver
link_a = torch.tensor([cube1.base_link.idx], dtype=gs.tc_int, device=gs.device)
link_b = torch.te... | No need to call `np.asarray` here | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
link_a = torch.tensor([cube1.base_link.idx], dtype=gs.tc_int, device=gs.device)
link_b = torch.tensor([cube2.base_link.idx], dtype=gs.tc_int, device=gs.device)
rigid.add_weld_constraint(link_a, link_b)
scene.step()
welds = rigid.get_weld_constraints(as_tensor=True, to_torch=False)
env_id = 0 i... | Just do `assert_allclose(cube1.get_vel(), cube2.get_vel(), tol=1e-7)` | chain_dofs = range(6, drone.n_dofs)
drone.set_dofs_armature(drone.get_dofs_armature(chain_dofs) + 1e-3, chain_dofs)
# Wait for the drones to land on the ground and hold straight
for i in range(400):
for drone in drones:
drone.set_propellels_rpm(torch.full((4,), 50000.0))
... | @@ -2342,6 +2342,75 @@ def test_drone_advanced(show_viewer):
assert abs(quat_1[2] - quat_2[2]) < tol
+@pytest.mark.required
+@pytest.mark.parametrize("backend", [gs.cpu])
+def test_get_weld_constraints_basic(show_viewer, tol):
+ scene = gs.Scene(
+ sim_options=gs.options.SimOptions(gravity=(0.0, 0.0,... | tests/test_rigid_physics.py | 26 | Python | 0.357 | suggestion | 69 | 51 | 51 | false | [FEATURE] Add 'get_weld_constraints' API. | 1,370 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [FEATURE] Add 'get_weld_constraints' API.
BEFORE CODE: link_a = torch.tensor([cube1.base_link.idx], dtype=gs.tc_int, device=gs.device)
link_b = torch.tensor([cube2.base_link.idx], dtype=gs.tc_int, device=gs.device)... | Just do `assert_allclose(cube1.get_vel(), cube2.get_vel(), tol=1e-7)` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
cube1.set_dofs_velocity(
velocity=np.array([1.0, 0.0, 0.0], dtype=np.float32),
dofs_idx_local=np.array([0, 1, 2], dtype=np.int32),
envs_idx=None,
)
for _ in range(200):
scene.step()
vel1 = np.asarray(cube1.get_vel())
vel2 = np.asarray(cube2.get_vel())
assert_al... | Do not define this alias. This is useless here. | drones[0].set_dofs_velocity([0.2], [1])
drones[1].set_dofs_velocity([-0.2], [1])
for i in range(150):
for drone in drones:
drone.set_propellels_rpm(torch.full((4,), 50000.0))
scene.step()
if scene.rigid_solver.collider._collider_state.n_contacts.to_numpy()[0] > 2:
... | @@ -2342,6 +2342,75 @@ def test_drone_advanced(show_viewer):
assert abs(quat_1[2] - quat_2[2]) < tol
+@pytest.mark.required
+@pytest.mark.parametrize("backend", [gs.cpu])
+def test_get_weld_constraints_basic(show_viewer, tol):
+ scene = gs.Scene(
+ sim_options=gs.options.SimOptions(gravity=(0.0, 0.0,... | tests/test_rigid_physics.py | 26 | Python | 0.143 | suggestion | 47 | 51 | 51 | false | [FEATURE] Add 'get_weld_constraints' API. | 1,370 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [FEATURE] Add 'get_weld_constraints' API.
BEFORE CODE: cube1.set_dofs_velocity(
velocity=np.array([1.0, 0.0, 0.0], dtype=np.float32),
dofs_idx_local=np.array([0, 1, 2], dtype=np.int32),
envs_idx... | Do not define this alias. This is useless here. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if (
self.equalities_info[i_e, i_b].eq_type == gs.EQUALITY_TYPE.WELD
and self.equalities_info[i_e, i_b].eq_obj1id == link1_idx
and self.equalities_info[i_e, i_b].eq_obj2id == link2_idx
):
if i_e < self.constr... | This branch should be useless. Just skip `self._kernel_collect_welds(buf)` if `max_welds == 0` | links_state.pos[i_l, envs_idx[i_b_]][i] = links_pos[envs_idx[i_b_], i_l, i]
links_state.i_pos_shift[i_l, envs_idx[i_b_]][i] = i_pos_shift[envs_idx[i_b_], i_l, i]
for i in ti.static(range(4)):
links_state.quat[i_l, envs_idx[i_b_]][i] = links_quat[envs_idx[i_b_], i_l, i]
... | @@ -6005,6 +6005,61 @@ def _kernel_delete_weld_constraint(
]
self.constraint_solver.ti_n_equalities[i_b] = self.constraint_solver.ti_n_equalities[i_b] - 1
+ @gs.assert_built
+ def get_weld_constraints(self, as_tensor: bool = True, to_torch: bool = True):
+ n_... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.429 | suggestion | 94 | 51 | 51 | false | [FEATURE] Add 'get_weld_constraints' API. | 1,370 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [FEATURE] Add 'get_weld_constraints' API.
BEFORE CODE: if (
self.equalities_info[i_e, i_b].eq_type == gs.EQUALITY_TYPE.WELD
and self.equalitie... | This branch should be useless. Just skip `self._kernel_collect_welds(buf)` if `max_welds == 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. |
and self.equalities_info[i_e, i_b].eq_obj1id == link1_idx
and self.equalities_info[i_e, i_b].eq_obj2id == link2_idx
):
if i_e < self.constraint_solver.ti_n_equalities[i_b] - 1:
self.equalities_info[i_e, i_b] = self.equal... | This is wrong. See my previous comment:
> Could you follow more strictly the pattern in RigidSolver.get_contacts? You should not pass a 3D tensor because it would allocate more memory than necessary but most importantly, it will break "C"-contiguity, which would be problematic if forwarded as input argument of anoth... | for i in ti.static(range(4)):
links_state.quat[i_l, envs_idx[i_b_]][i] = links_quat[envs_idx[i_b_], i_l, i]
links_state.mass_shift[i_l, envs_idx[i_b_]] = mass_shift[envs_idx[i_b_], i_l]
ti.loop_config(serialize=static_rigid_sim_config.para_level < gs.PARA_LEVEL.ALL)
for i_l, i_b_ in... | @@ -6005,6 +6005,61 @@ def _kernel_delete_weld_constraint(
]
self.constraint_solver.ti_n_equalities[i_b] = self.constraint_solver.ti_n_equalities[i_b] - 1
+ @gs.assert_built
+ def get_weld_constraints(self, as_tensor: bool = True, to_torch: bool = True):
+ n_... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.643 | bug | 337 | 51 | 51 | false | [FEATURE] Add 'get_weld_constraints' API. | 1,370 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [FEATURE] Add 'get_weld_constraints' API.
BEFORE CODE: and self.equalities_info[i_e, i_b].eq_obj1id == link1_idx
and self.equalities_info[i_e, i_b].eq_obj2id ... | This is wrong. See my previous comment:
> Could you follow more strictly the pattern in RigidSolver.get_contacts? You should not pass a 3D tensor because it would allocate more memory than necessary but most importantly, it will break "C"-contiguity, which would be problematic if forwarded as input argument of anoth... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
else:
cumsum = np.cumsum(n_eqs, dtype=np.int32)
splits = list(cumsum[:-1])
out_size = int(cumsum[-1]) if n_envs else 0
if to_torch:
buf = torch.full((out_size, 3), -1, dtype=gs.tc_int, device=gs.device)
else:
buf = np.full((out_size, 3... | Move this return on the top, right after `n_eqs = ...` | if to_torch:
buf = torch.full((out_size, 3), -1, dtype=gs.tc_int, device=gs.device)
else:
buf = np.full((out_size, 3), -1, dtype=np.int32)
if n_max > 0:
kernel_collect_welds(
as_tensor,
buf,
self.constraint_solv... | @@ -2296,6 +2296,49 @@ def update_verts_for_geom(self, i_g):
self.fixed_verts_state,
)
+ def get_weld_constraints(self, as_tensor: bool = True, to_torch: bool = True):
+ n_eqs = tuple(self.constraint_solver.constraint_state.ti_n_equalities.to_numpy())
+ n_envs = len(n_eqs)
+ ... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.429 | refactor | 54 | 51 | 51 | false | [FEATURE] Add 'get_weld_constraints' API. | 1,370 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [FEATURE] Add 'get_weld_constraints' API.
BEFORE CODE: else:
cumsum = np.cumsum(n_eqs, dtype=np.int32)
splits = list(cumsum[:-1])
out_size = int(cumsum[-1... | Move this return on the top, right after `n_eqs = ...` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
propellers_rpm,
propellers_spin,
KF,
KM,
invert,
self.links_state,
)
def update_verts_for_geom(self, i_g):
kernel_update_verts_for_geom(
i_g,
self.geoms_state,
self.geoms_info,
se... | Do not define `splits` in this case, it is useless. | KM,
invert,
self.links_state,
)
def update_verts_for_geom(self, i_g):
kernel_update_verts_for_geom(
i_g,
self.geoms_state,
self.geoms_info,
self.verts_info,
self.free_verts_state,
self.fixed_... | @@ -2296,6 +2296,49 @@ def update_verts_for_geom(self, i_g):
self.fixed_verts_state,
)
+ def get_weld_constraints(self, as_tensor: bool = True, to_torch: bool = True):
+ n_eqs = tuple(self.constraint_solver.constraint_state.ti_n_equalities.to_numpy())
+ n_envs = len(n_eqs)
+ ... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.429 | suggestion | 51 | 51 | 51 | false | [FEATURE] Add 'get_weld_constraints' API. | 1,370 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [FEATURE] Add 'get_weld_constraints' API.
BEFORE CODE: propellers_rpm,
propellers_spin,
KF,
KM,
invert,
self.links_state,
... | Do not define `splits` in this case, it is useless. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
out_size = int(cumsum[-1]) if n_envs else 0
if to_torch:
buf = torch.full((out_size, 3), -1, dtype=gs.tc_int, device=gs.device)
else:
buf = np.full((out_size, 3), -1, dtype=np.int32)
if n_max > 0:
kernel_collect_welds(
as_tensor,
... | `data_chunks` is more common name. | buf = np.full((out_size, 3), -1, dtype=np.int32)
if n_max > 0:
kernel_collect_welds(
as_tensor,
buf,
self.constraint_solver.constraint_state,
self.equalities_info,
self._static_rigid_sim_config,
... | @@ -2296,6 +2296,49 @@ def update_verts_for_geom(self, i_g):
self.fixed_verts_state,
)
+ def get_weld_constraints(self, as_tensor: bool = True, to_torch: bool = True):
+ n_eqs = tuple(self.constraint_solver.constraint_state.ti_n_equalities.to_numpy())
+ n_envs = len(n_eqs)
+ ... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.214 | suggestion | 34 | 51 | 51 | false | [FEATURE] Add 'get_weld_constraints' API. | 1,370 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [FEATURE] Add 'get_weld_constraints' API.
BEFORE CODE: out_size = int(cumsum[-1]) if n_envs else 0
if to_torch:
buf = torch.full((out_size, 3), -1, dtype=gs.tc_int, ... | `data_chunks` is more common name. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if to_torch:
buf = torch.full((out_size, 3), -1, dtype=gs.tc_int, device=gs.device)
else:
buf = np.full((out_size, 3), -1, dtype=np.int32)
if n_max > 0:
kernel_collect_welds(
as_tensor,
buf,
self.constraint_sol... | `a` and `b` are not suitable variable names. Just use `obj_a, obj_b`.
Create tuple to keep the data immutable. And generate both output at once:
```python
obj_a, obj_b = tuple(zip(*((data[:, 1], data[:, 2]) for data in data_chunks)))
``` |
if n_max > 0:
kernel_collect_welds(
as_tensor,
buf,
self.constraint_solver.constraint_state,
self.equalities_info,
self._static_rigid_sim_config,
)
if n_envs > 0:
if as_tensor:
... | @@ -2296,6 +2296,49 @@ def update_verts_for_geom(self, i_g):
self.fixed_verts_state,
)
+ def get_weld_constraints(self, as_tensor: bool = True, to_torch: bool = True):
+ n_eqs = tuple(self.constraint_solver.constraint_state.ti_n_equalities.to_numpy())
+ n_envs = len(n_eqs)
+ ... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.857 | suggestion | 243 | 51 | 51 | false | [FEATURE] Add 'get_weld_constraints' API. | 1,370 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [FEATURE] Add 'get_weld_constraints' API.
BEFORE CODE:
if to_torch:
buf = torch.full((out_size, 3), -1, dtype=gs.tc_int, device=gs.device)
else:
buf = np.ful... | `a` and `b` are not suitable variable names. Just use `obj_a, obj_b`.
Create tuple to keep the data immutable. And generate both output at once:
```python
obj_a, obj_b = tuple(zip(*((data[:, 1], data[:, 2]) for data in data_chunks)))
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
out_size = n_envs * n_max
splits = None
else:
cumsum = np.cumsum(n_eqs, dtype=np.int32)
splits = list(cumsum[:-1])
out_size = int(cumsum[-1]) if n_envs else 0
if to_torch:
buf = torch.full((out_size, 3), -1, dtype=gs.tc_int, device... | Adding key `"env"` should not be necessary. It was not there in `Collider.get_contacts`. | out_size = int(cumsum[-1]) if n_envs else 0
if to_torch:
buf = torch.full((out_size, 3), -1, dtype=gs.tc_int, device=gs.device)
else:
buf = np.full((out_size, 3), -1, dtype=np.int32)
if n_max > 0:
kernel_collect_welds(
as_tensor,
... | @@ -2296,6 +2296,49 @@ def update_verts_for_geom(self, i_g):
self.fixed_verts_state,
)
+ def get_weld_constraints(self, as_tensor: bool = True, to_torch: bool = True):
+ n_eqs = tuple(self.constraint_solver.constraint_state.ti_n_equalities.to_numpy())
+ n_envs = len(n_eqs)
+ ... | genesis/engine/solvers/rigid/rigid_solver_decomp.py | 26 | Python | 0.429 | suggestion | 88 | 51 | 51 | false | [FEATURE] Add 'get_weld_constraints' API. | 1,370 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/solvers/rigid/rigid_solver_decomp.py
PR Title: [FEATURE] Add 'get_weld_constraints' API.
BEFORE CODE: out_size = n_envs * n_max
splits = None
else:
cumsum = np.cumsum(n_eqs, dtype=np.int32)
... | Adding key `"env"` should not be necessary. It was not there in `Collider.get_contacts`. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Whether the position to set is absolute or relative to the initial (not current!) position. Defaults to
False.
zero_velocity : bool, optional
Whether to zero the velocity of all the entity's dofs. Defaults to True. This is a safety measure after a
sudden change in... | Remove the options `as_tensor: bool = True, to_torch: bool = True`. It should be enforced in this public method. No need for this level of flexibility here. This will simplify a lot the implementation. | pos : array_like
The position to set.
relative : bool, optional
Whether the position to set is absolute or relative to the initial (not current!) position. Defaults to
False.
zero_velocity : bool, optional
Whether to zero the velocity of all the en... | @@ -1834,6 +1834,32 @@ def set_pos(self, pos, envs_idx=None, *, relative=False, zero_velocity=True, uns
if zero_velocity:
self.zero_all_dofs_velocity(envs_idx, unsafe=unsafe)
+ @gs.assert_built
+ def get_weld_constraints(self, as_tensor: bool = True, to_torch: bool = True): | genesis/engine/entities/rigid_entity/rigid_entity.py | 26 | Python | 0.643 | refactor | 201 | 51 | 51 | false | [FEATURE] Add 'get_weld_constraints' API. | 1,370 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_entity.py
PR Title: [FEATURE] Add 'get_weld_constraints' API.
BEFORE CODE: Whether the position to set is absolute or relative to the initial (not current!) position. Defaults to
False.
... | Remove the options `as_tensor: bool = True, to_torch: bool = True`. It should be enforced in this public method. No need for this level of flexibility here. This will simplify a lot the implementation. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if _pos is not pos:
gs.logger.debug(ALLOCATE_TENSOR_WARNING)
pos = _pos
self._solver.set_base_links_pos(
pos.unsqueeze(-2),
self._base_links_idx,
envs_idx,
relative=relative,
unsafe=unsafe,
skip_forwa... | Optional keys should be avoided unless strictly necessary. Why do you need this? | """
if not unsafe:
_pos = torch.as_tensor(pos, dtype=gs.tc_float, device=gs.device).contiguous()
if _pos is not pos:
gs.logger.debug(ALLOCATE_TENSOR_WARNING)
pos = _pos
self._solver.set_base_links_pos(
pos.unsqueeze(-2),
... | @@ -1834,6 +1834,32 @@ def set_pos(self, pos, envs_idx=None, *, relative=False, zero_velocity=True, uns
if zero_velocity:
self.zero_all_dofs_velocity(envs_idx, unsafe=unsafe)
+ @gs.assert_built
+ def get_weld_constraints(self, as_tensor: bool = True, to_torch: bool = True):
+ welds ... | genesis/engine/entities/rigid_entity/rigid_entity.py | 26 | Python | 0.286 | question | 80 | 51 | 51 | false | [FEATURE] Add 'get_weld_constraints' API. | 1,370 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: genesis/engine/entities/rigid_entity/rigid_entity.py
PR Title: [FEATURE] Add 'get_weld_constraints' API.
BEFORE CODE: if _pos is not pos:
gs.logger.debug(ALLOCATE_TENSOR_WARNING)
pos = _pos
self._solver.set_base_... | Optional keys should be avoided unless strictly necessary. Why do you need 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. |
assert abs(pos_1[2] - pos_2[2]) < tol
quat_1 = drones[0].get_quat()
quat_2 = drones[1].get_quat()
assert abs(quat_1[1] + quat_2[1]) < tol
assert abs(quat_1[2] - quat_2[2]) < tol
assert abs(quat_1[2] - quat_2[2]) < tol
@pytest.mark.required
@pytest.mark.parametrize("backend", [gs.cpu])
def test... | You should check the 4 possible combinations. | morph=gs.morphs.Drone(
file=f"{asset_path}/drone_sus/drone_sus.urdf",
merge_fixed_links=merge_fixed_links,
pos=(0.0, offset, 1.5),
),
vis_mode="collision",
visualize_contact=True,
)
drones.append(drone)
s... | @@ -2352,6 +2352,62 @@ def test_drone_advanced(show_viewer):
assert abs(quat_1[2] - quat_2[2]) < tol
+@pytest.mark.required
+@pytest.mark.parametrize("backend", [gs.cpu])
+def test_get_weld_constraints_basic(show_viewer, tol):
+ scene = gs.Scene(
+ sim_options=gs.options.SimOptions(gravity=(0.0, 0.0,... | tests/test_rigid_physics.py | 26 | Python | 0.143 | suggestion | 45 | 51 | 51 | false | [FEATURE] Add 'get_weld_constraints' API. | 1,370 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [FEATURE] Add 'get_weld_constraints' API.
BEFORE CODE: assert abs(pos_1[2] - pos_2[2]) < tol
quat_1 = drones[0].get_quat()
quat_2 = drones[1].get_quat()
assert abs(quat_1[1] + quat_2[1]) < tol
assert ab... | You should check the 4 possible combinations. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 abs(quat_1[1] + quat_2[1]) < tol
assert abs(quat_1[2] - quat_2[2]) < tol
assert abs(quat_1[2] - quat_2[2]) < tol
@pytest.mark.required
@pytest.mark.parametrize("backend", [gs.cpu])
def test_get_weld_constraints_basic(show_viewer, tol):
scene = gs.Scene(
sim_options=gs.options.SimOptions... | Why converting to int is necessary ? It should be int already, and anyway, you are enforcing dtype. | pos=(0.0, offset, 1.5),
),
vis_mode="collision",
visualize_contact=True,
)
drones.append(drone)
scene.build()
for drone in drones:
chain_dofs = range(6, drone.n_dofs)
drone.set_dofs_armature(drone.get_dofs_armature(chain_dofs) ... | @@ -2352,6 +2352,62 @@ def test_drone_advanced(show_viewer):
assert abs(quat_1[2] - quat_2[2]) < tol
+@pytest.mark.required
+@pytest.mark.parametrize("backend", [gs.cpu])
+def test_get_weld_constraints_basic(show_viewer, tol):
+ scene = gs.Scene(
+ sim_options=gs.options.SimOptions(gravity=(0.0, 0.0,... | tests/test_rigid_physics.py | 26 | Python | 0.429 | question | 99 | 51 | 51 | false | [FEATURE] Add 'get_weld_constraints' API. | 1,370 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [FEATURE] Add 'get_weld_constraints' API.
BEFORE CODE: assert abs(quat_1[1] + quat_2[1]) < tol
assert abs(quat_1[2] - quat_2[2]) < tol
assert abs(quat_1[2] - quat_2[2]) < tol
@pytest.mark.required
@pytest.mar... | Why converting to int is necessary ? It should be int already, and anyway, you are enforcing dtype. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
quat_1 = drones[0].get_quat()
quat_2 = drones[1].get_quat()
assert abs(quat_1[1] + quat_2[1]) < tol
assert abs(quat_1[2] - quat_2[2]) < tol
assert abs(quat_1[2] - quat_2[2]) < tol
@pytest.mark.required
@pytest.mark.parametrize("backend", [gs.cpu])
def test_get_weld_constraints_basic(show_viewer, t... | Same. Casting to int should not be necessary. | file=f"{asset_path}/drone_sus/drone_sus.urdf",
merge_fixed_links=merge_fixed_links,
pos=(0.0, offset, 1.5),
),
vis_mode="collision",
visualize_contact=True,
)
drones.append(drone)
scene.build()
for drone in dron... | @@ -2352,6 +2352,62 @@ def test_drone_advanced(show_viewer):
assert abs(quat_1[2] - quat_2[2]) < tol
+@pytest.mark.required
+@pytest.mark.parametrize("backend", [gs.cpu])
+def test_get_weld_constraints_basic(show_viewer, tol):
+ scene = gs.Scene(
+ sim_options=gs.options.SimOptions(gravity=(0.0, 0.0,... | tests/test_rigid_physics.py | 26 | Python | 0.286 | suggestion | 45 | 51 | 51 | false | [FEATURE] Add 'get_weld_constraints' API. | 1,370 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [FEATURE] Add 'get_weld_constraints' API.
BEFORE CODE: quat_1 = drones[0].get_quat()
quat_2 = drones[1].get_quat()
assert abs(quat_1[1] + quat_2[1]) < tol
assert abs(quat_1[2] - quat_2[2]) < tol
assert ... | Same. Casting to int should not be 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. |
)
cube1 = scene.add_entity(gs.morphs.Box(size=(0.05,) * 3, pos=(0.0, 0.0, 0.05)))
cube2 = scene.add_entity(gs.morphs.Box(size=(0.05,) * 3, pos=(0.2, 0.0, 0.05)))
scene.build(n_envs=1)
link_a = torch.tensor([cube1.base_link.idx], dtype=gs.tc_int, device=gs.device)
link_b = torch.tensor([cube2.ba... | What is the point of this ? You are only validating API, not physics. This is done in another test? Just remove it. |
# Wait for the drones to land on the ground and hold straight
for i in range(400):
for drone in drones:
drone.set_propellels_rpm(torch.full((4,), 50000.0))
scene.step()
if i > 350:
assert scene.rigid_solver.collider._collider_state.n_contacts.to_numpy()[0] == 2
... | @@ -2352,6 +2352,62 @@ def test_drone_advanced(show_viewer):
assert abs(quat_1[2] - quat_2[2]) < tol
+@pytest.mark.required
+@pytest.mark.parametrize("backend", [gs.cpu])
+def test_get_weld_constraints_basic(show_viewer, tol):
+ scene = gs.Scene(
+ sim_options=gs.options.SimOptions(gravity=(0.0, 0.0,... | tests/test_rigid_physics.py | 26 | Python | 0.429 | question | 115 | 51 | 51 | false | [FEATURE] Add 'get_weld_constraints' API. | 1,370 | Genesis-Embodied-AI/Genesis | 26,702 | Python | duburcqa | LeonLiu4 | Review this pull request change.
Language: Python
File: tests/test_rigid_physics.py
PR Title: [FEATURE] Add 'get_weld_constraints' API.
BEFORE CODE: )
cube1 = scene.add_entity(gs.morphs.Box(size=(0.05,) * 3, pos=(0.0, 0.0, 0.05)))
cube2 = scene.add_entity(gs.morphs.Box(size=(0.05,) * 3, pos=(0.2, 0.0, 0... | What is the point of this ? You are only validating API, not physics. This is done in another test? Just remove it. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.