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
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) scene.sim.rigid_solver.add_weld_constraint(link_a, link_b) scene.step() welds = scene.sim.rigid_solver.get_weld_constraints(as_tensor=True...
Just keep them both in the same test. An call the test `test_get_weld_constraints_api`
scene.step() if i > 350: assert scene.rigid_solver.collider._collider_state.n_contacts.to_numpy()[0] == 2 assert_allclose(scene.rigid_solver.get_dofs_velocity(), 0, tol=2e-3) # Push the drones symmetrically and wait for them to collide drones[0].set_dofs_velocity([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.357
suggestion
86
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 keep them both in the same test. An call the test `test_get_weld_constraints_api`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@override def on_mouse_motion(self, x: int, y: int, dx: int, dy: int) -> EVENT_HANDLE_STATE: super().on_mouse_motion(x, y, dx, dy) self.prev_mouse_pos = (x, y) @override def on_mouse_drag(self, x: int, y: int, dx: int, dy: int, buttons: int, modifiers: int) -> EVENT_HANDLE_STATE: ...
You should rather use `tensor_to_array`.
def on_mouse_motion(self, x: int, y: int, dx: int, dy: int) -> EVENT_HANDLE_STATE: super().on_mouse_motion(x, y, dx, dy) self.prev_mouse_pos = (x, y) @override def on_mouse_drag(self, x: int, y: int, dx: int, dy: int, buttons: int, modifiers: int) -> EVENT_HANDLE_STATE: super().on_m...
@@ -60,17 +56,55 @@ def on_mouse_motion(self, x: int, y: int, dx: int, dy: int) -> EVENT_HANDLE_STAT def on_mouse_drag(self, x: int, y: int, dx: int, dy: int, buttons: int, modifiers: int) -> EVENT_HANDLE_STATE: super().on_mouse_drag(x, y, dx, dy, buttons, modifiers) self.prev_mouse_pos = (x, y) ...
genesis/ext/pyrender/interaction/viewer_interaction.py
26
Python
0.286
suggestion
40
51
51
false
[MISC] Add viewer code to handle moving objects
1,378
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 viewer code to handle moving objects BEFORE CODE: @override def on_mouse_motion(self, x: int, y: int, dx: int, dy: int) -> EVENT_HANDLE_STATE: super().on_mouse_motion(...
You should rather use `tensor_to_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.
from typing import TYPE_CHECKING from typing_extensions import override import numpy as np from numpy.typing import NDArray import torch import genesis as gs from genesis.engine.entities.rigid_entity.rigid_entity import RigidEntity from .aabb import AABB from .ray import Plane, Ray, RayHit from .vec3 import Pose, Qu...
Could you delay torch import inside the function using it? Because it will initialise CUDA runtime, which depends on environment variables, so the later it is imported the more leeway it gives to the end-user for modifying these environment variables at runtime.
from typing import TYPE_CHECKING from typing_extensions import override import numpy as np import genesis as gs from genesis.engine.entities.rigid_entity.rigid_entity import RigidEntity from .aabb import AABB from .ray import Plane, Ray, RayHit from .vec3 import Pose, Quat, Vec3, Color from .viewer_interaction_base ...
@@ -3,16 +3,15 @@ import numpy as np from numpy.typing import NDArray - -from pyglet.event import EVENT_HANDLE_STATE +import torch
genesis/ext/pyrender/interaction/viewer_interaction.py
6
Python
0.5
question
262
31
31
false
[MISC] Add viewer code to handle moving objects
1,378
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 viewer code to handle moving objects BEFORE CODE: from typing import TYPE_CHECKING from typing_extensions import override import numpy as np from numpy.typing import NDArray import to...
Could you delay torch import inside the function using it? Because it will initialise CUDA runtime, which depends on environment variables, so the later it is imported the more leeway it gives to the end-user for modifying these environment variables at runtime.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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.engine.scene import Scene from genesis.ext.pyrender.node import Node class ViewerInteraction(ViewerInteractionBase): """Functionalities to be implemented: - mouse picking - mouse dragging """ def __init__(self, camera: 'Node', scene: 'Scene', viewpo...
I would recommend `(0.5 * viewport_size[0], 0.5 * viewport_size[1])`
class ViewerInteraction(ViewerInteractionBase): """Functionalities to be implemented: - mouse picking - mouse dragging """ def __init__(self, camera: 'Node', scene: 'Scene', viewport_size: tuple[int, int], camera_yfov: float, log_events: bool = False, ...
@@ -43,13 +34,18 @@ def __init__(self, camera_fov: float = 60.0, ): super().__init__(log_events) - self.camera = camera - self.scene = scene - self.viewport_size = viewport_size - self.camera_yfov = camera_yfov + self.camera: 'Node' = camera + self.scene:...
genesis/ext/pyrender/interaction/viewer_interaction.py
26
Python
0.357
suggestion
68
51
51
false
[MISC] Add viewer code to handle moving objects
1,378
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 viewer code to handle moving objects BEFORE CODE: from genesis.engine.scene import Scene from genesis.ext.pyrender.node import Node class ViewerInteraction(ViewerInteractionB...
I would recommend `(0.5 * viewport_size[0], 0.5 * viewport_size[1])`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
closest_hit = None hit_entity: RigidEntity | None = None ray_hit = self._raycast_against_ground_plane(mouse_ray) if ray_hit.is_hit: closest_hit = ray_hit for entity in self.get_entities(): ray_hit = self.raycast_against_entity...
Why not just store pre-defined colours in a frozen dict of tuples whose keys would be some `IntEnum` (e.g. `COLOR.RED`) ? That would be more pythonic.
ray_hit = self._raycast_against_ground_plane(mouse_ray) if ray_hit.is_hit: closest_hit = ray_hit for entity in self.get_entities(): ray_hit = self.raycast_against_entity_obb(entity, mouse_ray) if ray_hit.is_hit: if...
@@ -91,6 +125,20 @@ def on_draw(self) -> None: if hit_entity: self._draw_entity_unrotated_oobb(hit_entity) + if self.picked_entity: + assert self.mouse_drag_plane is not None + assert self.picked_point_in_local is not None + + # dra...
genesis/ext/pyrender/interaction/viewer_interaction.py
26
Python
0.5
question
150
51
51
false
[MISC] Add viewer code to handle moving objects
1,378
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 viewer code to handle moving objects BEFORE CODE: closest_hit = None hit_entity: RigidEntity | None = None ray_hit = self._raycast_against_ground_p...
Why not just store pre-defined colours in a frozen dict of tuples whose keys would be some `IntEnum` (e.g. `COLOR.RED`) ? That would be more pythonic.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
x = x - 0.5 * self.viewport_size[0] 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....
`Vec3.from_float64` is confusing, this is an array. Why not `from_array` or `from_tensor`? Why `float64` matters here ? You would do the same in both cases?
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) x = x - 0.5 * self.viewport_size[0...
@@ -117,6 +165,10 @@ def screen_position_to_ray(self, x: float, y: float) -> Ray: direction = forward + right * x + up * y return Ray(position, direction) + def get_camera_forward(self) -> Vec3: + mtx = self.camera.matrix + return Vec3.from_float64(-mtx[:3, 2])
genesis/ext/pyrender/interaction/viewer_interaction.py
26
Python
0.5
question
156
51
51
false
[MISC] Add viewer code to handle moving objects
1,378
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 viewer code to handle moving objects BEFORE CODE: x = x - 0.5 * self.viewport_size[0] y = y - 0.5 * self.viewport_size[1] x = 2.0 * x / self.viewpor...
`Vec3.from_float64` is confusing, this is an array. Why not `from_array` or `from_tensor`? Why `float64` matters here ? You would 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.
from dataclasses import dataclass from typing import Union import numpy as np from numpy.typing import NDArray from genesis.utils.misc import tensor_to_array # If not needing runtime checks, we can just use annotated types: # Vec3 = Annotated[npt.NDArray[np.float32], (3,)] # Aabb = Annotated[npt.NDArray[np.float32],...
You don't need to do this I think, you may just call `import torch` or `import genesis as gs`, it will be crazy fast if already imported before. ```python In [19]: %timeit import torch 48.2 ns ± 0.452 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each) ``` I doubt you are chasing 50ns for now :p
from dataclasses import dataclass from typing import Union import numpy as np from numpy.typing import NDArray from genesis.utils.misc import tensor_to_array # If not needing runtime checks, we can just use annotated types: # Vec3 = Annotated[npt.NDArray[np.float32], (3,)] # Aabb = Annotated[npt.NDArray[np.float32],...
@@ -4,10 +4,23 @@ import numpy as np from numpy.typing import NDArray +from genesis.utils.misc import tensor_to_array + # If not needing runtime checks, we can just use annotated types: # Vec3 = Annotated[npt.NDArray[np.float32], (3,)] # Aabb = Annotated[npt.NDArray[np.float32], (2, 3)] +_is_torch_imported: bo...
genesis/ext/pyrender/interaction/vec3.py
14
Python
0.786
suggestion
320
39
39
false
[MISC] Add viewer code to handle moving objects
1,378
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 viewer code to handle moving objects BEFORE CODE: from dataclasses import dataclass from typing import Union import numpy as np from numpy.typing import NDArray from genesis.utils.misc import tens...
You don't need to do this I think, you may just call `import torch` or `import genesis as gs`, it will be crazy fast if already imported before. ```python In [19]: %timeit import torch 48.2 ns ± 0.452 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each) ``` I doubt you are chasing 50ns for now :p
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
return NotImplemented def copy(self) -> 'Quat': return Quat(self.v.copy()) def __repr__(self) -> str: return f"Quat({self.v[0]}, {self.v[1]}, {self.v[2]}, {self.v[3]})" @property def w(self) -> float: return self.v[0] @property def x(self) -> float: ...
I don't like the idea of making this a proper instead of a classic method, because the result is a copy and not a reference, which is confusing for a property I think.
def __repr__(self) -> str: return f"Quat({self.v[0]}, {self.v[1]}, {self.v[2]}, {self.v[3]})" def as_tensor(self) -> 'torch.Tensor': _ensure_torch_imported() return torch.tensor(self.v, dtype=gs.tc_float) @property def w(self) -> float: return self.v[0] @property ...
@@ -158,16 +166,27 @@ def y(self) -> float: def z(self) -> float: return self.v[3] + @property + def as_tensor(self) -> 'torch.Tensor':
genesis/ext/pyrender/interaction/vec3.py
26
Python
0.429
suggestion
167
51
51
false
[MISC] Add viewer code to handle moving objects
1,378
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 viewer code to handle moving objects BEFORE CODE: return NotImplemented def copy(self) -> 'Quat': return Quat(self.v.copy()) def __repr__(self) -> str: return f...
I don't like the idea of making this a proper instead of a classic method, because the result is a copy and not a reference, which is confusing for a property I think.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
Morph defined by a plane shape. Note ---- Plane is a primitive with infinite size. Note that the `pos` is the center of the plane, but essetially only defines a point where the plane passes through. Parameters ---------- pos : tuple, shape (3,), optional The center position of the ...
Why 2 flags ? Only define one or the other. Moreover, I think it should be one-sided by default.
Morph defined by a plane shape. Note ---- Plane is a primitive with infinite size. Note that the `pos` is the center of the plane, but essetially only defines a point where the plane passes through. Parameters ---------- pos : tuple, shape (3,), optional The center position of the ...
@@ -331,10 +331,14 @@ class Plane(Primitive): Whether the entity needs to be visualized. Set it to False if you need a invisible object only for collision purposes. Defaults to True. `visualization` and `collision` cannot both be False. **This is only used for RigidEntity.** collision : bool, optional ...
genesis/options/morphs.py
26
Python
0.286
question
96
51
51
false
[FEATURE] Enabling rendering plane geometry one-sided.
1,396
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
LeonLiu4
Review this pull request change. Language: Python File: genesis/options/morphs.py PR Title: [FEATURE] Enabling rendering plane geometry one-sided. BEFORE CODE: Morph defined by a plane shape. Note ---- Plane is a primitive with infinite size. Note that the `pos` is the center of the plane, but esse...
Why 2 flags ? Only define one or the other. Moreover, I think it should be one-sided by default.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
The normal normal of the plane in its local frame. Defaults to (0, 0, 1). visualization : bool, optional Whether the entity needs to be visualized. Set it to False if you need a invisible object only for collision purposes. Defaults to True. `visualization` and `collision` cannot both be False. **Th...
This is useless. It will be done automatically.
The normal normal of the plane in its local frame. Defaults to (0, 0, 1). visualization : bool, optional Whether the entity needs to be visualized. Set it to False if you need a invisible object only for collision purposes. Defaults to True. `visualization` and `collision` cannot both be False. **Th...
@@ -348,6 +351,8 @@ def __init__(self, **data): if self.requires_jac_and_IK: gs.raise_exception("`requires_jac_and_IK` must be False for `Plane`.") + self.double_sided = self.double_sided
genesis/options/morphs.py
26
Python
0.143
suggestion
47
51
51
false
[FEATURE] Enabling rendering plane geometry one-sided.
1,396
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
LeonLiu4
Review this pull request change. Language: Python File: genesis/options/morphs.py PR Title: [FEATURE] Enabling rendering plane geometry one-sided. BEFORE CODE: The normal normal of the plane in its local frame. Defaults to (0, 0, 1). visualization : bool, optional Whether the entity needs to be ...
This is useless. It will be done automatically.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
radius: float = 0.5 class Plane(Primitive): """ Morph defined by a plane shape. Note ---- Plane is a primitive with infinite size. Note that the `pos` is the center of the plane, but essetially only defines a point where the plane passes through. Parameters ---------- pos : tuple...
Terrain morph should also have this option.
radius: float = 0.5 class Plane(Primitive): """ Morph defined by a plane shape. Note ---- Plane is a primitive with infinite size. Note that the `pos` is the center of the plane, but essetially only defines a point where the plane passes through. Parameters ---------- pos : tuple...
@@ -331,10 +331,13 @@ class Plane(Primitive): Whether the entity needs to be visualized. Set it to False if you need a invisible object only for collision purposes. Defaults to True. `visualization` and `collision` cannot both be False. **This is only used for RigidEntity.** collision : bool, optional ...
genesis/options/morphs.py
26
Python
0.143
suggestion
43
51
51
false
[FEATURE] Enabling rendering plane geometry one-sided.
1,396
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
LeonLiu4
Review this pull request change. Language: Python File: genesis/options/morphs.py PR Title: [FEATURE] Enabling rendering plane geometry one-sided. BEFORE CODE: radius: float = 0.5 class Plane(Primitive): """ Morph defined by a plane shape. Note ---- Plane is a primitive with infinite size...
Terrain morph should also have this option.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
dtype=np.float32, ) def on_rigid(self): if self.sim.rigid_solver.is_active(): # TODO: support dynamic switching in GUI later for rigid_entity in self.sim.rigid_solver.entities: if rigid_entity.surface.vis_mode == "visual": geom...
I don't think this change is a good idea.
pose = gu.trans_quat_to_T(tool_entity.init_pos, tool_entity.init_quat) double_sided = tool_entity.surface.double_sided self.add_static_node( tool_entity, pyrender.Mesh.from_trimesh(mesh, double_sided=double_sided), pose=pose ...
@@ -296,9 +296,7 @@ def on_rigid(self): mesh=mesh, poses=geom_T, smooth=geom.surface.smooth if "collision" not in rigid_entity.surface.vis_mode else False, - double_sided=( - ...
genesis/vis/rasterizer_context.py
26
Python
0.143
suggestion
41
51
51
false
[FEATURE] Enabling rendering plane geometry one-sided.
1,396
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
LeonLiu4
Review this pull request change. Language: Python File: genesis/vis/rasterizer_context.py PR Title: [FEATURE] Enabling rendering plane geometry one-sided. BEFORE CODE: dtype=np.float32, ) def on_rigid(self): if self.sim.rigid_solver.is_active(): # TODO: support dynamic s...
I don't think this change is a good idea.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
visual = trimesh.visual.ColorVisuals() visual._data["vertex_colors"] = np.tile((np.asarray(color) * 255).astype(np.uint8), (len(vertices), 1)) mesh = trimesh.Trimesh(vertices=vertices, faces=faces, visual=visual, process=False) mesh._cache.id_set() mesh._cache.cache["face_normals"] = face_normals ...
Move back `uv` where it was initially defined.
visual = trimesh.visual.ColorVisuals() visual._data["vertex_colors"] = np.tile((np.asarray(color) * 255).astype(np.uint8), (len(vertices), 1)) mesh = trimesh.Trimesh(vertices=vertices, faces=faces, visual=visual, process=False) mesh._cache.id_set() mesh._cache.cache["face_normals"] = face_normals ...
@@ -860,24 +860,36 @@ def create_box(extents=None, color=(1.0, 1.0, 1.0, 1.0), bounds=None, wireframe= def create_plane(size=1e3, color=None, normal=(0.0, 0.0, 1.0)): thickness = 1e-2 # for safety - mesh = trimesh.creation.box(extents=[size, size, thickness]) + half = size * 0.5 + verts = np.array( + ...
genesis/utils/mesh.py
26
Python
0.286
suggestion
46
51
51
false
[FEATURE] Enabling rendering plane geometry one-sided.
1,396
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
LeonLiu4
Review this pull request change. Language: Python File: genesis/utils/mesh.py PR Title: [FEATURE] Enabling rendering plane geometry one-sided. BEFORE CODE: visual = trimesh.visual.ColorVisuals() visual._data["vertex_colors"] = np.tile((np.asarray(color) * 255).astype(np.uint8), (len(vertices), 1)) mesh...
Move back `uv` where it was initially 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.
j = i + l * d delta_node = self.delta(i, j, i_b) s = ti.u32(0) t = (l + 1) // 2 while t > 0: if self.delta(i, i + (s + t) * d, i_b) > delta_node: s += t t = ti.select(t > 1, (t + 1) // 2, 0) gamm...
I wonder if the performance will be slower than the original u64.
j = i + l * d delta_node = self.delta(i, j, i_b) s = ti.u32(0) t = (l + 1) // 2 while t > 0: if self.delta(i, i + (s + t) * d, i_b) > delta_node: s += t t = ti.select(t > 1, (t + 1) // 2, 0) gamm...
@@ -318,10 +318,13 @@ def delta(self, i, j, i_b): result = -1 if j >= 0 and j < self.n_aabbs: result = 64 - x = self.morton_codes[i_b, ti.i32(i)] ^ self.morton_codes[i_b, ti.i32(j)] - for b in range(64): - if x & (ti.u64(1) << (63 - b)): - ...
genesis/engine/bvh.py
26
Python
0.357
performance
65
51
51
false
[BUG FIX] Fix support of Apple Metal.
1,404
Genesis-Embodied-AI/Genesis
26,702
Python
YilingQiao
duburcqa
Review this pull request change. Language: Python File: genesis/engine/bvh.py PR Title: [BUG FIX] Fix support of Apple Metal. BEFORE CODE: j = i + l * d delta_node = self.delta(i, j, i_b) s = ti.u32(0) t = (l + 1) // 2 while t > 0: if self....
I wonder if the performance will be slower than the original u64.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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.held_geom = None def apply_force(self, control_point: Vec3, delta_time: float): _ensure_torch_imported() # works ok: # delta: Vec3 = control_point - self.prev_control_point # pos = Vec3.from_tensor(self.held_geom.entity.get_pos()) # pos = pos + delta ...
Do not hardcode parameters in the middle of functions. Define global constant (FULL_UPPERCASE) right after imports.
self.prev_control_point = control_point def detach(self): self.held_geom = None def apply_force(self, control_point: Vec3, delta_time: float): _ensure_torch_imported() # works ok: # delta: Vec3 = control_point - self.prev_control_point # pos = Vec3.from...
@@ -0,0 +1,82 @@ + +from genesis.engine.entities.rigid_entity.rigid_entity import RigidEntity +from genesis.engine.entities.rigid_entity.rigid_geom import RigidGeom + +from .ray import Plane, Ray, RayHit +from .vec3 import Pose, Quat, Vec3, Color + +from genesis.engine.entities.rigid_entity.rigid_link import RigidLink ...
genesis/ext/pyrender/interaction/mouse_spring.py
26
Python
0.357
suggestion
115
51
51
false
[MISC] Stub code for physical object dragging
1,411
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
gasnica
Review this pull request change. Language: Python File: genesis/ext/pyrender/interaction/mouse_spring.py PR Title: [MISC] Stub code for physical object dragging BEFORE CODE: self.held_geom = None def apply_force(self, control_point: Vec3, delta_time: float): _ensure_torch_imported() ...
Do not hardcode parameters in the middle of functions. Define global constant (FULL_UPPERCASE) right after imports.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
pose: Pose = Pose.from_geom(self.held_geom) self.held_point_in_local = pose.inverse_transform_point(control_point) self.prev_control_point = control_point def detach(self): self.held_geom = None def apply_force(self, control_point: Vec3, delta_time: float): _ensure_torc...
I don't know why, but `0.0 < link.get_mass()` is confusing to me. I would use `link.get_mass() > 0.0`
def attach(self, picked_entity: RigidEntity, control_point: Vec3): # for now, we just pick the first geometry self.held_geom = picked_entity.geoms[0] pose: Pose = Pose.from_geom(self.held_geom) self.held_point_in_local = pose.inverse_transform_point(control_point) self.prev_c...
@@ -0,0 +1,82 @@ + +from genesis.engine.entities.rigid_entity.rigid_entity import RigidEntity +from genesis.engine.entities.rigid_entity.rigid_geom import RigidGeom + +from .ray import Plane, Ray, RayHit +from .vec3 import Pose, Quat, Vec3, Color + +from genesis.engine.entities.rigid_entity.rigid_link import RigidLink ...
genesis/ext/pyrender/interaction/mouse_spring.py
26
Python
0.571
suggestion
101
51
51
false
[MISC] Stub code for physical object dragging
1,411
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
gasnica
Review this pull request change. Language: Python File: genesis/ext/pyrender/interaction/mouse_spring.py PR Title: [MISC] Stub code for physical object dragging BEFORE CODE: pose: Pose = Pose.from_geom(self.held_geom) self.held_point_in_local = pose.inverse_transform_point(control_point) sel...
I don't know why, but `0.0 < link.get_mass()` is confusing to me. I would use `link.get_mass() > 0.0`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
dir: Vec3 = Vec3.zero() dir.v[i] = 1.0 pos_err: float = dir.dot(pos_err_v) vel_err: float = dir.dot(vel_err_v) err: float = tau * pos_err * inv_dt + damp * vel_err vm: float = inv_mass imp: float = err * vm lin_vel += imp *...
Skip line at the end of the line.
from genesis.engine.entities.rigid_entity.rigid_entity import RigidEntity from genesis.engine.entities.rigid_entity.rigid_geom import RigidGeom from .ray import Plane, Ray, RayHit from .vec3 import Pose, Quat, Vec3, Color from genesis.engine.entities.rigid_entity.rigid_link import RigidLink MOUSE_SPRING_POSITION_CO...
@@ -0,0 +1,82 @@ + +from genesis.engine.entities.rigid_entity.rigid_entity import RigidEntity +from genesis.engine.entities.rigid_entity.rigid_geom import RigidGeom + +from .ray import Plane, Ray, RayHit +from .vec3 import Pose, Quat, Vec3, Color + +from genesis.engine.entities.rigid_entity.rigid_link import RigidLink ...
genesis/ext/pyrender/interaction/mouse_spring.py
26
Python
0.071
suggestion
33
26
81
false
[MISC] Stub code for physical object dragging
1,411
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
gasnica
Review this pull request change. Language: Python File: genesis/ext/pyrender/interaction/mouse_spring.py PR Title: [MISC] Stub code for physical object dragging BEFORE CODE: dir: Vec3 = Vec3.zero() dir.v[i] = 1.0 pos_err: float = dir.dot(pos_err_v) vel_err: float = di...
Skip line at the end of the line.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@pytest.mark.required @pytest.mark.parametrize("model_name", ["box_plan"]) @pytest.mark.parametrize("gs_solver", [gs.constraint_solver.CG, gs.constraint_solver.Newton]) @pytest.mark.parametrize("gs_integrator", [gs.integrator.implicitfast, gs.integrator.Euler]) @pytest.mark.parametrize("backend", [gs.cpu]) def test_bo...
What was the original tolerance? (I tried to print it out, but don't know how to get prints to show when run with pytest)
@pytest.mark.required @pytest.mark.parametrize("model_name", ["box_plan"]) @pytest.mark.parametrize("gs_solver", [gs.constraint_solver.CG, gs.constraint_solver.Newton]) @pytest.mark.parametrize("gs_integrator", [gs.integrator.implicitfast, gs.integrator.Euler]) @pytest.mark.parametrize("backend", [gs.cpu]) def test_bo...
@@ -329,6 +329,9 @@ def test_box_plane_dynamics(gs_sim, mj_sim, tol): @pytest.mark.parametrize("gjk_collision", [True, False]) @pytest.mark.parametrize("backend", [gs.cpu]) def test_simple_kinematic_chain(gs_sim, mj_sim, tol): + # after PR #1423, I need to relax the tolerance. It should not affect the test result...
tests/test_rigid_physics.py
26
Python
0.357
question
125
51
51
false
[BUG FIX] Move forward_kinematics to the end of a step.
1,423
Genesis-Embodied-AI/Genesis
26,702
Python
gasnica
YilingQiao
Review this pull request change. Language: Python File: tests/test_rigid_physics.py PR Title: [BUG FIX] Move forward_kinematics to the end of a step. BEFORE CODE: @pytest.mark.required @pytest.mark.parametrize("model_name", ["box_plan"]) @pytest.mark.parametrize("gs_solver", [gs.constraint_solver.CG, gs.constraint...
What was the original tolerance? (I tried to print it out, but don't know how to get prints to show when run with pytest)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
self._rasterizer = None if self._raytracer is not None: self._raytracer.destroy() self._raytracer = None if self._context is not None: self._context.destroy() del self._context self._context = None self._renderer = None ...
Is this correct? viewer_lock is either a real viewer lock or a DummyViewerLock. It will never be None unless it is not built.
self._rasterizer = None if self._raytracer is not None: self._raytracer.destroy() self._raytracer = None if self._context is not None: self._context.destroy() del self._context self._context = None self._renderer = None ...
@@ -130,15 +130,16 @@ def reset(self): self._context.reset() - # Need to update viewer once here, because otherwise camera will update scene if render is called right after - # build, which will lead to segfault. - if self._viewer is not None: - if self._viewer.is_alive(): -...
genesis/vis/visualizer.py
26
Python
0.357
question
127
51
51
false
[BUG FIX] Fix broken interactive viewer.
1,426
Genesis-Embodied-AI/Genesis
26,702
Python
yuhongyi
duburcqa
Review this pull request change. Language: Python File: genesis/vis/visualizer.py PR Title: [BUG FIX] Fix broken interactive viewer. BEFORE CODE: self._rasterizer = None if self._raytracer is not None: self._raytracer.destroy() self._raytracer = None if self._cont...
Is this correct? viewer_lock is either a real viewer lock or a DummyViewerLock. It will never be None unless it is not built.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 argparse import genesis as gs def main(): parser = argparse.ArgumentParser() parser.add_argument("-v", "--vis", action="store_true", default=False) args = parser.parse_args() gs.init() scene = gs.Scene( viewer_options=gs.options.ViewerOptions( camera_pos=(0.0, -2, 1.5...
Move this comment on the very top of this file.
""" NOTE: contype and conaffinity are 32-bit integer bitmasks used for contact filtering of contact pairs. When the contype of one geom and the conaffinity of the other geom share a common bit set to 1, two geoms can collide. Plane: contype=0xFFFF, conaffinity=0xFFFF (1111 1111 1111 1111) Red Cube: contype=1, co...
@@ -0,0 +1,90 @@ +import argparse + +import genesis as gs + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("-v", "--vis", action="store_true", default=False) + args = parser.parse_args() + + gs.init() + + scene = gs.Scene( + viewer_options=gs.options.ViewerOptions( + ...
examples/collision/contype.py
25
Python
0.143
refactor
47
50
50
false
[FEATURE] Add support of 'contype'/'conaffinity' for primitive and mesh entities.
1,438
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Kashu7100
Review this pull request change. Language: Python File: examples/collision/contype.py PR Title: [FEATURE] Add support of 'contype'/'conaffinity' for primitive and mesh entities. BEFORE CODE: import argparse import genesis as gs def main(): parser = argparse.ArgumentParser() parser.add_argument("-v", "--v...
Move this comment on the very top of this file.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
show_viewer=args.vis, ) scene.add_entity(gs.morphs.Plane()) # NOTE: contype and conaffinity are 32-bit integer bitmasks used for contact filtering of contact pairs. # When the contype of one geom and the conaffinity of the other geom share a common bit set to 1, two geoms can collide. # Pl...
Do not skip line between each `add_entity`
gs.init() scene = gs.Scene( viewer_options=gs.options.ViewerOptions( camera_pos=(0.0, -2, 1.5), camera_lookat=(0.0, 0.0, 0.5), camera_fov=40, max_FPS=200, ), show_viewer=args.vis, ) scene.add_entity(gs.morphs.Plane()) scene....
@@ -0,0 +1,90 @@ +import argparse + +import genesis as gs + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("-v", "--vis", action="store_true", default=False) + args = parser.parse_args() + + gs.init() + + scene = gs.Scene( + viewer_options=gs.options.ViewerOptions( + ...
examples/collision/contype.py
26
Python
0.214
suggestion
42
51
51
false
[FEATURE] Add support of 'contype'/'conaffinity' for primitive and mesh entities.
1,438
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Kashu7100
Review this pull request change. Language: Python File: examples/collision/contype.py PR Title: [FEATURE] Add support of 'contype'/'conaffinity' for primitive and mesh entities. BEFORE CODE: show_viewer=args.vis, ) scene.add_entity(gs.morphs.Plane()) # NOTE: contype and conaffinity are 32-bit ...
Do not skip line between each `add_entity`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
dt: Optional[float] = None gravity: Optional[tuple] = None enable_collision: bool = True enable_joint_limit: bool = True enable_self_collision: bool = True enable_adjacent_collision: bool = False disable_constraint: bool = False max_collision_pairs: int = 300 integrator: gs.integrat...
can we change it to 0.01 to be safer?
""" dt: Optional[float] = None gravity: Optional[tuple] = None enable_collision: bool = True enable_joint_limit: bool = True enable_self_collision: bool = True enable_adjacent_collision: bool = False disable_constraint: bool = False max_collision_pairs: int = 300 integrator: gs....
@@ -292,7 +291,7 @@ class RigidOptions(Options): ls_tolerance: float = 1e-2 sparse_solve: bool = False contact_resolve_time: Optional[float] = None - constraint_timeconst: Optional[float] = None + constraint_timeconst_min: float = 0.004
genesis/options/solvers.py
26
Python
0.143
question
37
51
51
false
[MISC] Enable GJK collision detection algorithm by default.
1,439
Genesis-Embodied-AI/Genesis
26,702
Python
YilingQiao
duburcqa
Review this pull request change. Language: Python File: genesis/options/solvers.py PR Title: [MISC] Enable GJK collision detection algorithm by default. BEFORE CODE: dt: Optional[float] = None gravity: Optional[tuple] = None enable_collision: bool = True enable_joint_limit: bool = True enable_s...
can we change it to 0.01 to be safer?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# Calculate enter point and normal enter = tnear # if 0 <= tnear else tfar normal = Vec3.zero() normal.v[min_idx] = -np.sign(ray.direction.v[min_idx]) hit_pos = ray.origin + ray.direction * enter return RayHit(enter, hit_pos, normal) def __repr__(self) -> str: ...
Does not make sense. You should probably have some `BaseBoundingBox` abstraction.
if tfar < tnear or tnear < 0: # tfar < 0 return RayHit.no_hit() # Calculate enter point and normal enter = tnear # if 0 <= tnear else tfar normal = Vec3.zero() normal.v[min_idx] = -np.sign(ray.direction.v[min_idx]) hit_pos = ray.origin + ray.direction * en...
@@ -79,3 +72,33 @@ def from_center_and_size(cls, center: Vec3, size: Vec3) -> 'AABB': max = center + 0.5 * size bounds = np.stack((min.v, max.v)) return cls(bounds) + + +class OBB(AABB):
genesis/ext/pyrender/interaction/aabb.py
26
Python
0.429
refactor
81
51
46
false
[MISC] Picking boxes and Panda links with a MouseSpring
1,443
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] Picking boxes and Panda links with a MouseSpring BEFORE CODE: # Calculate enter point and normal enter = tnear # if 0 <= tnear else tfar normal = Vec3.zero() normal.v[m...
Does not make sense. You should probably have some `BaseBoundingBox` abstraction.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 __repr__(self) -> str: return f"AABB: Min({self.min.x}, {self.min.y}, {self.min.z}) Max({self.max.x}, {self.max.y}, {self.max.z})" @classmethod def from_min_max(cls, min: Vec3, max: Vec3) -> 'AABB': bounds = np.stack((min.v, max.v)) return cls(bounds) @classmethod def ...
Do not compute inverse explicit. This is slow. You should rather implement `inv_transform_point`, `inv_transform_direction`
hit_pos = ray.origin + ray.direction * enter return RayHit(enter, hit_pos, normal) def __repr__(self) -> str: return f"AABB: Min({self.min.x}, {self.min.y}, {self.min.z}) Max({self.max.x}, {self.max.y}, {self.max.z})" @classmethod def from_min_max(cls, min: Vec3, max: Vec3) -> 'AAB...
@@ -79,3 +72,33 @@ def from_center_and_size(cls, center: Vec3, size: Vec3) -> 'AABB': max = center + 0.5 * size bounds = np.stack((min.v, max.v)) return cls(bounds) + + +class OBB(AABB): + pose: Pose + + def __init__(self, v: NDArray[np.float32], pose: Pose): + super().__init__(v...
genesis/ext/pyrender/interaction/aabb.py
26
Python
0.571
performance
123
46
38
false
[MISC] Picking boxes and Panda links with a MouseSpring
1,443
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] Picking boxes and Panda links with a MouseSpring BEFORE CODE: def __repr__(self) -> str: return f"AABB: Min({self.min.x}, {self.min.y}, {self.min.z}) Max({self.max.x}, {self.max.y}, {self.m...
Do not compute inverse explicit. This is slow. You should rather implement `inv_transform_point`, `inv_transform_direction`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
pose: Pose def __init__(self, v: NDArray[np.float32], pose: Pose): super().__init__(v) self.pose = pose def raycast(self, ray: Ray) -> RayHit: inv_pose = self.pose.get_inverse() origin2 = inv_pose.transform_point(ray.origin) direction2 = inv_pose.transform_direction...
Always specify on which access you stack for readability.
from dataclasses import dataclass 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)-e...
@@ -79,3 +72,33 @@ def from_center_and_size(cls, center: Vec3, size: Vec3) -> 'AABB': max = center + 0.5 * size bounds = np.stack((min.v, max.v)) return cls(bounds) + + +class OBB(AABB): + pose: Pose + + def __init__(self, v: NDArray[np.float32], pose: Pose): + super().__init__(v...
genesis/ext/pyrender/interaction/aabb.py
26
Python
0.214
suggestion
57
28
97
false
[MISC] Picking boxes and Panda links with a MouseSpring
1,443
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] Picking boxes and Panda links with a MouseSpring BEFORE CODE: pose: Pose def __init__(self, v: NDArray[np.float32], pose: Pose): super().__init__(v) self.pose = pose def ra...
Always specify on which access you stack for readability.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
MOUSE_SPRING_VELOCITY_CORRECTION_FACTOR = 1.0 def _ensure_torch_imported() -> None: global torch import torch class MouseSpring: def __init__(self): self.held_link: RigidLink | None = None self.held_point_in_local: Vec3 | None = None self.prev_control_point: Vec3 | None = None ...
Could you confirm if it is fixed and clean these notes (which does NOT mean removing them entirely!)
MOUSE_SPRING_VELOCITY_CORRECTION_FACTOR = 1.0 def _ensure_torch_imported() -> None: global torch import torch class MouseSpring: def __init__(self) -> None: self.held_link: RigidLink | None = None self.held_point_in_local: Vec3 | None = None self.prev_control_point: Vec3 | None = N...
@@ -16,65 +16,84 @@ def _ensure_torch_imported() -> None: class MouseSpring: def __init__(self): - self.held_geom: RigidGeom | None = None + self.held_link: RigidLink | None = None self.held_point_in_local: Vec3 | None = None self.prev_control_point: Vec3 | None = None - def...
genesis/ext/pyrender/interaction/mouse_spring.py
26
Python
0.429
suggestion
100
51
51
false
[MISC] Picking boxes and Panda links with a MouseSpring
1,443
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
gasnica
Review this pull request change. Language: Python File: genesis/ext/pyrender/interaction/mouse_spring.py PR Title: [MISC] Picking boxes and Panda links with a MouseSpring BEFORE CODE: MOUSE_SPRING_VELOCITY_CORRECTION_FACTOR = 1.0 def _ensure_torch_imported() -> None: global torch import torch class MouseS...
Could you confirm if it is fixed and clean these notes (which does NOT mean removing them entirely!)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
self.held_point_in_local: Vec3 | None = None self.prev_control_point: Vec3 | None = None def attach(self, picked_link: RigidLink, control_point: Vec3): # for now, we just pick the first geometry self.held_link = picked_link pose: Pose = Pose.from_link(self.held_link) ...
This makes no sense if the type of link is `RigidLink`. Either the assert should be removed or typing should be replaced by `RigidLink | None`
self.held_point_in_local: Vec3 | None = None self.prev_control_point: Vec3 | None = None def attach(self, picked_link: RigidLink, control_point: Vec3) -> None: # for now, we just pick the first geometry self.held_link = picked_link pose: Pose = Pose.from_link(self.held_link)...
@@ -16,65 +16,84 @@ def _ensure_torch_imported() -> None: class MouseSpring: def __init__(self): - self.held_geom: RigidGeom | None = None + self.held_link: RigidLink | None = None self.held_point_in_local: Vec3 | None = None self.prev_control_point: Vec3 | None = None - def...
genesis/ext/pyrender/interaction/mouse_spring.py
26
Python
0.714
suggestion
142
51
51
false
[MISC] Picking boxes and Panda links with a MouseSpring
1,443
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
gasnica
Review this pull request change. Language: Python File: genesis/ext/pyrender/interaction/mouse_spring.py PR Title: [MISC] Picking boxes and Panda links with a MouseSpring BEFORE CODE: self.held_point_in_local: Vec3 | None = None self.prev_control_point: Vec3 | None = None def attach(self, picke...
This makes no sense if the type of link is `RigidLink`. Either the assert should be removed or typing should be replaced by `RigidLink | 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.
self.held_link = picked_link pose: Pose = Pose.from_link(self.held_link) self.held_point_in_local = pose.inverse_transform_point(control_point) self.prev_control_point = control_point def detach(self): self.held_link = None def apply_force(self, control_point: Vec3, del...
If the simulation is built, `inertial_pos` and `inertial_quat` should not be none. We should update these property getters to read values from taichi field if the simulation is already built. See `sol_params` implementation: https://github.com/Genesis-Embodied-AI/Genesis/blob/767d536b8689cba5f382fe184df8bd270f889ea2/ge...
self.held_link = picked_link pose: Pose = Pose.from_link(self.held_link) self.held_point_in_local = pose.inverse_transform_point(control_point) self.prev_control_point = control_point def detach(self) -> None: self.held_link = None def apply_force(self, control_point: V...
@@ -16,65 +16,84 @@ def _ensure_torch_imported() -> None: class MouseSpring: def __init__(self): - self.held_geom: RigidGeom | None = None + self.held_link: RigidLink | None = None self.held_point_in_local: Vec3 | None = None self.prev_control_point: Vec3 | None = None - def...
genesis/ext/pyrender/interaction/mouse_spring.py
26
Python
0.643
suggestion
374
51
51
false
[MISC] Picking boxes and Panda links with a MouseSpring
1,443
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
gasnica
Review this pull request change. Language: Python File: genesis/ext/pyrender/interaction/mouse_spring.py PR Title: [MISC] Picking boxes and Panda links with a MouseSpring BEFORE CODE: self.held_link = picked_link pose: Pose = Pose.from_link(self.held_link) self.held_point_in_local = pose.inv...
If the simulation is built, `inertial_pos` and `inertial_quat` should not be none. We should update these property getters to read values from taichi field if the simulation is already built. See `sol_params` implementation: https://github.com/Genesis-Embodied-AI/Genesis/blob/767d536b8689cba5f382fe184df8bd270f889ea2/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.
self.held_link = None def apply_force(self, control_point: Vec3, delta_time: float): _ensure_torch_imported() # note when threaded: apply_force is called before attach! # note2: that was before we added a lock to ViewerInteraction; this migth be fixed now if not self.held_l...
Same. No `get_inverse`, this is slow due to memory allocation. What about overloading operation "/" to multiply by inverse, à-la-Matlab.
self.held_link = None def apply_force(self, control_point: Vec3, delta_time: float) -> None: _ensure_torch_imported() # note when threaded: apply_force is called before attach! # note2: that was before we added a lock to ViewerInteraction; this migth be fixed now if not sel...
@@ -16,65 +16,84 @@ def _ensure_torch_imported() -> None: class MouseSpring: def __init__(self): - self.held_geom: RigidGeom | None = None + self.held_link: RigidLink | None = None self.held_point_in_local: Vec3 | None = None self.prev_control_point: Vec3 | None = None - def...
genesis/ext/pyrender/interaction/mouse_spring.py
26
Python
0.643
performance
139
51
51
false
[MISC] Picking boxes and Panda links with a MouseSpring
1,443
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
gasnica
Review this pull request change. Language: Python File: genesis/ext/pyrender/interaction/mouse_spring.py PR Title: [MISC] Picking boxes and Panda links with a MouseSpring BEFORE CODE: self.held_link = None def apply_force(self, control_point: Vec3, delta_time: float): _ensure_torch_imported() ...
Same. No `get_inverse`, this is slow due to memory allocation. What about overloading operation "/" to multiply by inverse, à-la-Matlab.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 when threaded: apply_force is called before attach! # note2: that was before we added a lock to ViewerInteraction; this migth be fixed now if not self.held_link: return self.prev_control_point = control_point # do simple force on COM only: li...
`inv_spherical_inertia = 0.0` make sense ?
# note when threaded: apply_force is called before attach! # note2: that was before we added a lock to ViewerInteraction; this migth be fixed now if not self.held_link: return self.prev_control_point = control_point # do simple force on COM only: li...
@@ -16,65 +16,84 @@ def _ensure_torch_imported() -> None: class MouseSpring: def __init__(self): - self.held_geom: RigidGeom | None = None + self.held_link: RigidLink | None = None self.held_point_in_local: Vec3 | None = None self.prev_control_point: Vec3 | None = None - def...
genesis/ext/pyrender/interaction/mouse_spring.py
26
Python
0.214
question
42
51
51
false
[MISC] Picking boxes and Panda links with a MouseSpring
1,443
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
gasnica
Review this pull request change. Language: Python File: genesis/ext/pyrender/interaction/mouse_spring.py PR Title: [MISC] Picking boxes and Panda links with a MouseSpring BEFORE CODE: # note when threaded: apply_force is called before attach! # note2: that was before we added a lock to ViewerIntera...
`inv_spherical_inertia = 0.0` make sense ?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# do simple force on COM only: link: RigidLink = self.held_link assert link lin_vel: Vec3 = Vec3.from_tensor(link.get_vel()) ang_vel: Vec3 = Vec3.from_tensor(link.get_ang()) link_pose: Pose = Pose.from_link(link) held_point_in_world: Vec3 = link_pose.transform_po...
I suggest to remove typing when it is irrelevant. We already know that `Vec3.zero()` has type `Vec3`.
# do simple force on COM only: link: RigidLink = self.held_link lin_vel: Vec3 = Vec3.from_tensor(link.get_vel()) ang_vel: Vec3 = Vec3.from_tensor(link.get_ang()) link_pose: Pose = Pose.from_link(link) held_point_in_world: Vec3 = link_pose.transform_point(self.held_point_...
@@ -16,65 +16,84 @@ def _ensure_torch_imported() -> None: class MouseSpring: def __init__(self): - self.held_geom: RigidGeom | None = None + self.held_link: RigidLink | None = None self.held_point_in_local: Vec3 | None = None self.prev_control_point: Vec3 | None = None - def...
genesis/ext/pyrender/interaction/mouse_spring.py
26
Python
0.714
suggestion
101
51
51
false
[MISC] Picking boxes and Panda links with a MouseSpring
1,443
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
gasnica
Review this pull request change. Language: Python File: genesis/ext/pyrender/interaction/mouse_spring.py PR Title: [MISC] Picking boxes and Panda links with a MouseSpring BEFORE CODE: # do simple force on COM only: link: RigidLink = self.held_link assert link lin_vel: Vec3 = Vec3.fr...
I suggest to remove typing when it is irrelevant. We already know that `Vec3.zero()` has type `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.
@override def on_resize(self, width: int, height: int) -> EVENT_HANDLE_STATE: super().on_resize(width, height) self.viewport_size = (width, height) self.tan_half_fov = np.tan(0.5 * self.camera_yfov) @override def update_on_sim_step(self) -> None: with self.lock: ...
`pos += delta_3d_pos` is more efficient.
@override def on_resize(self, width: int, height: int) -> EVENT_HANDLE_STATE: super().on_resize(width, height) self.viewport_size = (width, height) self.tan_half_fov = np.tan(0.5 * self.camera_yfov) @override def update_on_sim_step(self) -> None: with self.lock: ...
@@ -96,64 +106,58 @@ def on_resize(self, width: int, height: int) -> EVENT_HANDLE_STATE: @override def update_on_sim_step(self) -> None: - if self.picked_entity: - mouse_ray: Ray = self.screen_position_to_ray(*self.prev_mouse_pos) - ray_hit: RayHit = self.mouse_drag_plane.raycas...
genesis/ext/pyrender/interaction/viewer_interaction.py
26
Python
0.214
performance
40
51
51
false
[MISC] Picking boxes and Panda links with a MouseSpring
1,443
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] Picking boxes and Panda links with a MouseSpring BEFORE CODE: @override def on_resize(self, width: int, height: int) -> EVENT_HANDLE_STATE: super().on_resize(width, height)...
`pos += delta_3d_pos` is more efficient.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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.picked_link = None self.picked_point_in_local = None self.mouse_drag_plane = None self.prev_mouse_3d_pos = None self.mouse_spring.detach() @override def on_resize(self, width: int, height: int) -> EVENT_HANDLE_STATE: ...
same. But you can keep them if you like them x)
self.picked_link = None self.picked_point_in_local = None self.mouse_drag_plane = None self.prev_mouse_3d_pos = None self.mouse_spring.detach() @override def on_resize(self, width: int, height: int) -> EVENT_HANDLE_STATE: ...
@@ -96,64 +106,58 @@ def on_resize(self, width: int, height: int) -> EVENT_HANDLE_STATE: @override def update_on_sim_step(self) -> None: - if self.picked_entity: - mouse_ray: Ray = self.screen_position_to_ray(*self.prev_mouse_pos) - ray_hit: RayHit = self.mouse_drag_plane.raycas...
genesis/ext/pyrender/interaction/viewer_interaction.py
26
Python
0.071
suggestion
47
51
51
false
[MISC] Picking boxes and Panda links with a MouseSpring
1,443
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] Picking boxes and Panda links with a MouseSpring BEFORE CODE: self.picked_link = None self.picked_point_in_local = None self.mouse_drag_plan...
same. But you can keep them if you like them 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.
def get_camera_ray(self) -> Ray: mtx = self.camera.matrix position = Vec3.from_array(mtx[:3, 3]) forward = Vec3.from_array(-mtx[:3, 2]) return Ray(position, forward) def _raycast_against_ground_plane(self, ray: Ray) -> RayHit: ground_plane = Plane(Vec3.from_xyz(0, 0, 1)...
`if link.get_mass() > 0.0:` is more natural for me.
def get_camera_ray(self) -> Ray: mtx = self.camera.matrix position = Vec3.from_array(mtx[:3, 3]) forward = Vec3.from_array(-mtx[:3, 2]) return Ray(position, forward) def _raycast_against_ground_plane(self, ray: Ray) -> RayHit: ground_plane = Plane(Vec3.from_xyz(0, 0, 1)...
@@ -197,53 +201,62 @@ def _raycast_against_ground_plane(self, ray: Ray) -> RayHit: def raycast_against_entity_obb(self, entity: RigidEntity, ray: Ray) -> RayHit: if isinstance(entity.morph, gs.morphs.Box): - box: gs.morphs.Box = entity.morph - size = Vec3.from_xyz(*box.size) - ...
genesis/ext/pyrender/interaction/viewer_interaction.py
26
Python
0.357
suggestion
51
51
51
false
[MISC] Picking boxes and Panda links with a MouseSpring
1,443
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] Picking boxes and Panda links with a MouseSpring BEFORE CODE: def get_camera_ray(self) -> Ray: mtx = self.camera.matrix position = Vec3.from_array(mtx[:3, 3]) ...
`if link.get_mass() > 0.0:` is more natural for me.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
return Vec3.from_array(-mtx[:3, 2]) def get_camera_ray(self) -> Ray: mtx = self.camera.matrix position = Vec3.from_array(mtx[:3, 3]) forward = Vec3.from_array(-mtx[:3, 2]) return Ray(position, forward) def _raycast_against_ground_plane(self, ray: Ray) -> RayHit: ...
What does this comment means? Whether it can move ? If so, you need to change for its parent index. If it is "-1", then it is fixed wrt world (95% sure). Another option is to check the value of `is_fixed`, which is arguably much clearer.
return Vec3.from_array(-mtx[:3, 2]) def get_camera_ray(self) -> Ray: mtx = self.camera.matrix position = Vec3.from_array(mtx[:3, 3]) forward = Vec3.from_array(-mtx[:3, 2]) return Ray(position, forward) def _raycast_against_ground_plane(self, ray: Ray) -> RayHit: ...
@@ -197,53 +201,62 @@ def _raycast_against_ground_plane(self, ray: Ray) -> RayHit: def raycast_against_entity_obb(self, entity: RigidEntity, ray: Ray) -> RayHit: if isinstance(entity.morph, gs.morphs.Box): - box: gs.morphs.Box = entity.morph - size = Vec3.from_xyz(*box.size) - ...
genesis/ext/pyrender/interaction/viewer_interaction.py
26
Python
0.643
question
237
51
51
false
[MISC] Picking boxes and Panda links with a MouseSpring
1,443
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] Picking boxes and Panda links with a MouseSpring BEFORE CODE: return Vec3.from_array(-mtx[:3, 2]) def get_camera_ray(self) -> Ray: mtx = self.camera.matrix pos...
What does this comment means? Whether it can move ? If so, you need to change for its parent index. If it is "-1", then it is fixed wrt world (95% sure). Another option is to check the value of `is_fixed`, which is arguably much clearer.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 geom in link.geoms: obb: OBB = self._get_geom_placeholder_obb(geom) ray_hit = obb.raycast(ray) if ray_hit.distance < closest_hit.distance: ray_hit.geom = geom closest_h...
Could you add `def full(fill_value):` ? That would be more convenient and efficient.
obb: OBB = self._get_geom_placeholder_obb(geom) ray_hit = obb.raycast(ray) if ray_hit.distance < closest_hit.distance: ray_hit.geom = geom closest_hit = ray_hit return closest_hit ...
@@ -197,53 +201,62 @@ def _raycast_against_ground_plane(self, ray: Ray) -> RayHit: def raycast_against_entity_obb(self, entity: RigidEntity, ray: Ray) -> RayHit: if isinstance(entity.morph, gs.morphs.Box): - box: gs.morphs.Box = entity.morph - size = Vec3.from_xyz(*box.size) - ...
genesis/ext/pyrender/interaction/viewer_interaction.py
26
Python
0.429
performance
84
47
45
false
[MISC] Picking boxes and Panda links with a MouseSpring
1,443
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] Picking boxes and Panda links with a MouseSpring BEFORE CODE: for geom in link.geoms: obb: OBB = self._get_geom_placeholder_obb(geom) ...
Could you add `def full(fill_value):` ? That would be more convenient and efficient.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
box: gs.morphs.Box = box_entity.morph pose = Pose.from_link(box_entity.links[0]) size = Vec3.from_xyz(*box.size) return OBB.from_center_and_size(size, pose) def _get_geom_placeholder_obb(self, geom: 'RigidGeom') -> OBB: pose = Pose.from_geom(geom) size = 0.125 * Vec3...
Use keyword arguments when passing constants to methods. This makes the code more self-explanatory.
pose = Pose.from_link(box_entity.links[0]) half_extents = 0.5 * Vec3.from_xyz(*box.size) return OBB(pose, half_extents) def _get_geom_placeholder_obb(self, geom: 'RigidGeom') -> OBB: pose = Pose.from_geom(geom) half_extents = Vec3.full(0.5 * 0.125) return OBB(pose, h...
@@ -197,53 +201,62 @@ def _raycast_against_ground_plane(self, ray: Ray) -> RayHit: def raycast_against_entity_obb(self, entity: RigidEntity, ray: Ray) -> RayHit: if isinstance(entity.morph, gs.morphs.Box): - box: gs.morphs.Box = entity.morph - size = Vec3.from_xyz(*box.size) - ...
genesis/ext/pyrender/interaction/viewer_interaction.py
26
Python
0.286
suggestion
99
29
27
false
[MISC] Picking boxes and Panda links with a MouseSpring
1,443
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] Picking boxes and Panda links with a MouseSpring BEFORE CODE: box: gs.morphs.Box = box_entity.morph pose = Pose.from_link(box_entity.links[0]) size = Vec3.from_xyz(...
Use keyword arguments when passing constants to methods. This makes the code more self-explanatory.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@staticmethod def _get_trimesh_props(mesh, smooth=False, material=None): """Gets the vertex colors, texture coordinates, and material properties from a :class:`~trimesh.base.Trimesh`. """ colors = None texcoords = None # If the trimesh visual is undefined, retur...
not sure if this is a correct fix. Basically, we will get an error if the color argument in draw_debug_arrow takes (r,g,b) instead of (r,g,b,a). You can reproduce it by reverting this change and running @duburcqa ``` pytest -s -v tests/test_rigid_physics.py::test_examples_api ```
@staticmethod def _get_trimesh_props(mesh, smooth=False, material=None): """Gets the vertex colors, texture coordinates, and material properties from a :class:`~trimesh.base.Trimesh`. """ colors = None texcoords = None # If the trimesh visual is undefined, retur...
@@ -266,7 +266,7 @@ def _get_trimesh_props(mesh, smooth=False, material=None): else: colors = vc[mesh.faces].reshape((3 * len(mesh.faces), vc.shape[1])) material = MetallicRoughnessMaterial( - alphaMode="OPAQUE" if (colors[..., 3] == 255)...
genesis/ext/pyrender/mesh.py
26
Python
1
bug
288
51
51
false
[BUG FIX] Fix errors in APIs that are used by rigid examples
1,471
Genesis-Embodied-AI/Genesis
26,702
Python
YilingQiao
SonSang
Review this pull request change. Language: Python File: genesis/ext/pyrender/mesh.py PR Title: [BUG FIX] Fix errors in APIs that are used by rigid examples BEFORE CODE: @staticmethod def _get_trimesh_props(mesh, smooth=False, material=None): """Gets the vertex colors, texture coordinates, and mater...
not sure if this is a correct fix. Basically, we will get an error if the color argument in draw_debug_arrow takes (r,g,b) instead of (r,g,b,a). You can reproduce it by reverting this change and running @duburcqa ``` pytest -s -v tests/test_rigid_physics.py::test_examples_api ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
scale=0.05, ), surface=gs.surfaces.Default(color=(0.5, 0.5, 1.0, 1)), ) ########################## entities ########################## robot = scene.add_entity( morph=gs.morphs.URDF( scale=1.0, file="urdf/shadow_hand/shadow_hand.urdf", ), ...
do you know how to fix this non-continuous memory? Although it's not a breaking bug @duburcqa
scale=0.05, ), surface=gs.surfaces.Default(color=(0.5, 0.5, 1.0, 1)), ) ########################## entities ########################## robot = scene.add_entity( morph=gs.morphs.URDF( scale=1.0, file="urdf/shadow_hand/shadow_hand.urdf", ), ...
@@ -66,24 +66,27 @@ def main(): target_quat = np.array([1, 0, 0, 0]) index_finger_distal = robot.get_link("index_finger_distal") middle_finger_distal = robot.get_link("middle_finger_distal") - forearm = robot.get_link("forearm") + wrist = robot.get_link("wrist") # there is no link named "forearm" ...
examples/rigid/ik_shadow_hand.py
26
Python
0.357
bug
94
47
50
false
[BUG FIX] Fix errors in APIs that are used by rigid examples
1,471
Genesis-Embodied-AI/Genesis
26,702
Python
YilingQiao
SonSang
Review this pull request change. Language: Python File: examples/rigid/ik_shadow_hand.py PR Title: [BUG FIX] Fix errors in APIs that are used by rigid examples BEFORE CODE: scale=0.05, ), surface=gs.surfaces.Default(color=(0.5, 0.5, 1.0, 1)), ) ########################## entities...
do you know how to fix this non-continuous memory? Although it's not a breaking bug @duburcqa
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
horizontal_scale=horizontal_scale, vertical_scale=vertical_scale, subterrain_types=[ ["flat_terrain", "random_uniform_terrain"], ["pyramid_sloped_terrain", "discrete_obstacles_terrain"], ], ), ) ball = scene.add_entity( ...
You should rather specify the device argument to torch.tensor
horizontal_scale=horizontal_scale, vertical_scale=vertical_scale, subterrain_types=[ ["flat_terrain", "random_uniform_terrain"], ["pyramid_sloped_terrain", "discrete_obstacles_terrain"], ], ), ) ball = scene.add_entity( ...
@@ -64,8 +64,8 @@ def main(): ).unsqueeze(-1) cols = horizontal_scale * torch.range(0, height_field.shape[1] - 1, 1).unsqueeze(0).repeat( height_field.shape[0], 1 - ).unsqueeze(-1) - heights = vertical_scale * torch.tensor(height_field).unsqueeze(-1) + ).unsqueeze(-1).to(rows.device)
examples/rigid/terrain_subterrain.py
26
Python
0.286
suggestion
61
37
37
false
[BUG FIX] Fix errors in APIs that are used by rigid examples
1,471
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
SonSang
Review this pull request change. Language: Python File: examples/rigid/terrain_subterrain.py PR Title: [BUG FIX] Fix errors in APIs that are used by rigid examples BEFORE CODE: horizontal_scale=horizontal_scale, vertical_scale=vertical_scale, subterrain_types=[ ["...
You should rather specify the device argument to torch.tensor
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import math import os import sys import tempfile import xml.etree.ElementTree as ET from pathlib import Path import mujoco import numpy as np import pytest import torch import trimesh import genesis as gs import genesis.utils.geom as gu from genesis.utils.misc import get_assets_dir, tensor_to_array from .utils impor...
This unit test is not great, there is too much noise and the name is not clear. It should fit in 10 lines at most.
pos=(0.0, 0.0, 1.0), contype=2, conaffinity=2, ) ) box3 = scene.add_entity( gs.morphs.Box( size=(0.5, 0.5, 0.5), pos=(0.0, 0.0, 1.5), contype=1, conaffinity=1, ) ) scene.build() for _ in rang...
@@ -2751,3 +2751,101 @@ def test_contype_conaffinity(show_viewer, tol): assert_allclose(box1.get_pos(), np.array([0.0, 0.0, 0.25]), atol=1e-3) assert_allclose(box2.get_pos(), np.array([0.0, 0.0, 0.75]), atol=1e-3) assert_allclose(box3.get_pos(), np.array([0.0, 0.0, 0.75]), atol=1e-3) + + +@pytest.mark.pa...
tests/test_rigid_physics.py
26
Python
0.429
nitpick
114
2,754
51
false
[BUG FIX] Fix errors in APIs that are used by rigid examples
1,471
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
SonSang
Review this pull request change. Language: Python File: tests/test_rigid_physics.py PR Title: [BUG FIX] Fix errors in APIs that are used by rigid examples BEFORE CODE: import math import os import sys import tempfile import xml.etree.ElementTree as ET from pathlib import Path import mujoco import numpy as np impor...
This unit test is not great, there is too much noise and the name is not clear. It should fit in 10 lines at most.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
else: gs.raise_exception(f"Unsupported MJCF joint type: {mj_type}") j_info["type"], j_info["n_qs"], j_info["n_dofs"] = gs_type, n_qs, n_dofs # Parsing joint parameters that are type-agnostic mj_dof_offset = mj.jnt_dofadr[i_j] if i_j != -1 else 0 mj_qpos_offset = mj.j...
Just delete this instead of commenting out.
else: gs.raise_exception(f"Unsupported MJCF joint type: {mj_type}") j_info["type"], j_info["n_qs"], j_info["n_dofs"] = gs_type, n_qs, n_dofs # Parsing joint parameters that are type-agnostic mj_dof_offset = mj.jnt_dofadr[i_j] if i_j != -1 else 0 mj_qpos_offset = mj.j...
@@ -234,13 +234,14 @@ def parse_link(mj, i_l, scale): j_info["dofs_damping"] = mj.dof_damping[mj_dof_offset : (mj_dof_offset + n_dofs)] j_info["dofs_invweight"] = mj.dof_invweight0[mj_dof_offset : (mj_dof_offset + n_dofs)] j_info["dofs_armature"] = mj.dof_armature[mj_dof_offset : (mj_dof_offs...
genesis/utils/mjcf.py
26
Python
0.143
suggestion
43
51
51
false
[Feature] Joint friction / frictionloss
1,479
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/utils/mjcf.py PR Title: [Feature] Joint friction / frictionloss BEFORE CODE: else: gs.raise_exception(f"Unsupported MJCF joint type: {mj_type}") j_info["type"], j_info["n_qs"], j_info["n_dofs"] = gs_type, n_qs, n_dofs ...
Just delete this instead of commenting out.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
gs.morphs.Box( size=(0.5, 0.5, 0.5), pos=(0.0, 0.0, 1.5), contype=1, conaffinity=1, ) ) scene.build() for _ in range(100): scene.step() assert_allclose(box2.get_pos(), box3.get_pos(), atol=1e-3) assert_allclose(box1.get_pos(),...
Yes, that would be great to find out what is happening here.
size=(1.0, 1.0, 1.0), pos=(0.0, 0.0, 2.0), ) ) scene.build() for link in box.links: for vgeom, geom in zip(link.vgeoms, link.geoms): assert_allclose(geom.get_pos(), vgeom.get_pos(), atol=tol) assert_allclose(geom.get_quat(), vgeom.get_quat(), ...
@@ -2806,3 +2806,14 @@ def test_contype_conaffinity(show_viewer, tol): assert_allclose(box1.get_pos(), np.array([0.0, 0.0, 0.25]), atol=1e-3) assert_allclose(box2.get_pos(), np.array([0.0, 0.0, 0.75]), atol=1e-3) assert_allclose(box3.get_pos(), np.array([0.0, 0.0, 0.75]), atol=1e-3) + + +@pytest.mark.par...
tests/test_rigid_physics.py
26
Python
0.214
suggestion
60
28
51
false
[Feature] Joint friction / frictionloss
1,479
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: tests/test_rigid_physics.py PR Title: [Feature] Joint friction / frictionloss BEFORE CODE: gs.morphs.Box( size=(0.5, 0.5, 0.5), pos=(0.0, 0.0, 1.5), contype=1, conaffinity=1, ) ) scene.bui...
Yes, that would be great to find out what is happening here.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
size=(0.5, 0.5, 0.5), pos=(0.0, 0.0, 1.0), contype=2, conaffinity=2, ) ) box3 = scene.add_entity( gs.morphs.Box( size=(0.5, 0.5, 0.5), pos=(0.0, 0.0, 1.5), contype=1, conaffinity=1, ) ) ...
I would prefer a procedurally generated XML model for something this simple.
gravity=(0.0, 0.0, -10.0), ), show_viewer=show_viewer, ) box = scene.add_entity( gs.morphs.Box( size=(1.0, 1.0, 1.0), pos=(0.0, 0.0, 2.0), ) ) scene.build() for link in box.links: for vgeom, geom in zip(link.vgeoms, link.g...
@@ -2806,3 +2806,14 @@ def test_contype_conaffinity(show_viewer, tol): assert_allclose(box1.get_pos(), np.array([0.0, 0.0, 0.25]), atol=1e-3) assert_allclose(box2.get_pos(), np.array([0.0, 0.0, 0.75]), atol=1e-3) assert_allclose(box3.get_pos(), np.array([0.0, 0.0, 0.75]), atol=1e-3) + + +@pytest.mark.par...
tests/test_rigid_physics.py
26
Python
0.286
suggestion
76
35
51
false
[Feature] Joint friction / frictionloss
1,479
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: tests/test_rigid_physics.py PR Title: [Feature] Joint friction / frictionloss BEFORE CODE: size=(0.5, 0.5, 0.5), pos=(0.0, 0.0, 1.0), contype=2, conaffinity=2, ) ) box3 = scene.add_entity( ...
I would prefer a procedurally generated XML model for something this simple.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
box3 = scene.add_entity( gs.morphs.Box( size=(0.5, 0.5, 0.5), pos=(0.0, 0.0, 1.5), contype=1, conaffinity=1, ) ) scene.build() for _ in range(100): scene.step() assert_allclose(box2.get_pos(), box3.get_pos(), atol=1e-3) as...
Some initial velocity would be better.
gs.morphs.Box( size=(1.0, 1.0, 1.0), pos=(0.0, 0.0, 2.0), ) ) scene.build() for link in box.links: for vgeom, geom in zip(link.vgeoms, link.geoms): assert_allclose(geom.get_pos(), vgeom.get_pos(), atol=tol) assert_allclose(geom.get_qua...
@@ -2806,3 +2806,14 @@ def test_contype_conaffinity(show_viewer, tol): assert_allclose(box1.get_pos(), np.array([0.0, 0.0, 0.25]), atol=1e-3) assert_allclose(box2.get_pos(), np.array([0.0, 0.0, 0.75]), atol=1e-3) assert_allclose(box3.get_pos(), np.array([0.0, 0.0, 0.75]), atol=1e-3) + + +@pytest.mark.par...
tests/test_rigid_physics.py
26
Python
0.143
suggestion
38
29
51
false
[Feature] Joint friction / frictionloss
1,479
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: tests/test_rigid_physics.py PR Title: [Feature] Joint friction / frictionloss BEFORE CODE: box3 = scene.add_entity( gs.morphs.Box( size=(0.5, 0.5, 0.5), pos=(0.0, 0.0, 1.5), contype=1, conaffinity=1, ...
Some initial velocity would be better.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
) box3 = scene.add_entity( gs.morphs.Box( size=(0.5, 0.5, 0.5), pos=(0.0, 0.0, 1.5), contype=1, conaffinity=1, ) ) scene.build() for _ in range(100): scene.step() assert_allclose(box2.get_pos(), box3.get_pos(), atol=1e-3) ...
No need to specify qpos if it is zero.
box = scene.add_entity( gs.morphs.Box( size=(1.0, 1.0, 1.0), pos=(0.0, 0.0, 2.0), ) ) scene.build() for link in box.links: for vgeom, geom in zip(link.vgeoms, link.geoms): assert_allclose(geom.get_pos(), vgeom.get_pos(), atol=tol) ...
@@ -2806,3 +2806,14 @@ def test_contype_conaffinity(show_viewer, tol): assert_allclose(box1.get_pos(), np.array([0.0, 0.0, 0.25]), atol=1e-3) assert_allclose(box2.get_pos(), np.array([0.0, 0.0, 0.75]), atol=1e-3) assert_allclose(box3.get_pos(), np.array([0.0, 0.0, 0.75]), atol=1e-3) + + +@pytest.mark.par...
tests/test_rigid_physics.py
26
Python
0.071
suggestion
38
30
51
false
[Feature] Joint friction / frictionloss
1,479
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: tests/test_rigid_physics.py PR Title: [Feature] Joint friction / frictionloss BEFORE CODE: ) box3 = scene.add_entity( gs.morphs.Box( size=(0.5, 0.5, 0.5), pos=(0.0, 0.0, 1.5), contype=1, conaffini...
No need to specify qpos if it is zero.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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_update_constraint( i_b, qacc: array_class.V_ANNOTATION, Ma: array_class.V_ANNOTATION, cost: array_class.V_ANNOTATION, dofs_state: array_class.DofsState, constraint_state: array_class.ConstraintState, static_rigid_sim_config: ti.template(), ): n_dofs = constraint_state.qfrc_const...
What about defining 'rf' as you did above ?
cost: array_class.V_ANNOTATION, dofs_state: array_class.DofsState, constraint_state: array_class.ConstraintState, static_rigid_sim_config: ti.template(), ): n_dofs = constraint_state.qfrc_constraint.shape[0] constraint_state.prev_cost[i_b] = cost[i_b] cost[i_b] = gs.ti_float(0.0) constr...
@@ -1681,9 +1716,23 @@ def func_update_constraint( if ti.static(static_rigid_sim_config.solver_type == gs.constraint_solver.Newton): constraint_state.prev_active[i_c, i_b] = constraint_state.active[i_c, i_b] constraint_state.active[i_c, i_b] = 1 - if i_c >= constraint_state.n_const...
genesis/engine/solvers/rigid/constraint_solver_decomp.py
26
Python
0.071
question
43
51
51
false
[Feature] Joint friction / frictionloss
1,479
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/engine/solvers/rigid/constraint_solver_decomp.py PR Title: [Feature] Joint friction / frictionloss BEFORE CODE: def func_update_constraint( i_b, qacc: array_class.V_ANNOTATION, Ma: array_class.V_ANNOTATION, cost: array_class.V_ANNOTATIO...
What about defining 'rf' as you did above ?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
cost: array_class.V_ANNOTATION, dofs_state: array_class.DofsState, constraint_state: array_class.ConstraintState, static_rigid_sim_config: ti.template(), ): n_dofs = constraint_state.qfrc_constraint.shape[0] constraint_state.prev_cost[i_b] = cost[i_b] cost[i_b] = gs.ti_float(0.0) constr...
Move 'f' outside for efficiency and consistency.
): n_dofs = constraint_state.qfrc_constraint.shape[0] constraint_state.prev_cost[i_b] = cost[i_b] cost[i_b] = gs.ti_float(0.0) constraint_state.gauss[i_b] = gs.ti_float(0.0) for i_c in range(constraint_state.n_constraints[i_b]): if ti.static(static_rigid_sim_config.solver_type == gs.constr...
@@ -1681,9 +1716,23 @@ def func_update_constraint( if ti.static(static_rigid_sim_config.solver_type == gs.constraint_solver.Newton): constraint_state.prev_active[i_c, i_b] = constraint_state.active[i_c, i_b] constraint_state.active[i_c, i_b] = 1 - if i_c >= constraint_state.n_const...
genesis/engine/solvers/rigid/constraint_solver_decomp.py
26
Python
0.143
style
48
51
51
false
[Feature] Joint friction / frictionloss
1,479
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/engine/solvers/rigid/constraint_solver_decomp.py PR Title: [Feature] Joint friction / frictionloss BEFORE CODE: cost: array_class.V_ANNOTATION, dofs_state: array_class.DofsState, constraint_state: array_class.ConstraintState, static_rig...
Move 'f' outside for efficiency and consistency.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
tmp_quad_total0 = constraint_state.quad_gauss[_i0 + 0, i_b] tmp_quad_total1 = constraint_state.quad_gauss[_i0 + 1, i_b] tmp_quad_total2 = constraint_state.quad_gauss[_i0 + 2, i_b] for i_c in range(constraint_state.n_constraints[i_b]): x = constraint_state.Jaref[i_c, i_b] + al...
You are setting value equal to zero. Just do this directly. Moreover, I don't this it is worth making `qf` a vector. Just define `qf_1` and `qf_2`. That would be more efficient.
tmp_quad_total1 = constraint_state.quad_gauss[1, i_b] tmp_quad_total2 = constraint_state.quad_gauss[2, i_b] for i_c in range(constraint_state.n_constraints[i_b]): x = constraint_state.Jaref[i_c, i_b] + alpha * constraint_state.jv[i_c, i_b] active = 1 ne = constraint_state.n_constrain...
@@ -1295,9 +1307,32 @@ def func_ls_point_fn( tmp_quad_total1 = constraint_state.quad_gauss[_i0 + 1, i_b] tmp_quad_total2 = constraint_state.quad_gauss[_i0 + 2, i_b] for i_c in range(constraint_state.n_constraints[i_b]): + x = constraint_state.Jaref[i_c, i_b] + alpha * constraint_st...
genesis/engine/solvers/rigid/constraint_solver_decomp.py
26
Python
0.5
performance
177
51
51
false
[Feature] Joint friction / frictionloss
1,479
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
YilingQiao
Review this pull request change. Language: Python File: genesis/engine/solvers/rigid/constraint_solver_decomp.py PR Title: [Feature] Joint friction / frictionloss BEFORE CODE: tmp_quad_total0 = constraint_state.quad_gauss[_i0 + 0, i_b] tmp_quad_total1 = constraint_state.quad_gauss[_i0 + 1, i_b] ...
You are setting value equal to zero. Just do this directly. Moreover, I don't this it is worth making `qf` a vector. Just define `qf_1` and `qf_2`. That would be more efficient.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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._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._gravity = None self._entities: list[Entity] = gs.List() # force fields ...
`gs.logger.debug` should be enough. "Gravity is not defined, skipping 'set_gravity'." would be more appropriate.
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._gravity = None self._entities: list[Entity] = gs.List() # force fields ...
@@ -42,14 +42,26 @@ def build(self): @gs.assert_built def set_gravity(self, gravity, envs_idx=None): if self._gravity is None: + gs.logger.warning("Gravity is not initialized, skipping set_gravity.")
genesis/engine/solvers/base_solver.py
26
Python
0.714
bug
115
51
51
false
[BUG FIX] Fix gravity setters.
1,498
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/engine/solvers/base_solver.py PR Title: [BUG FIX] Fix gravity setters. BEFORE CODE: self._sim = sim self._scene = scene self._dt: float = options.dt self._substep_dt: float = options.dt / sim.substeps self._init_...
`gs.logger.debug` should be enough. "Gravity is not defined, skipping 'set_gravity'." 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.
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_numpy() qvel[-1] = 1 scene.rigid_solver.dofs_state.vel.from_numpy(qvel) for i in range(200): sce...
Prefer `n_envs=2`, or `n_envs=3`, it should be enough.
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_numpy() qvel[-1] = 1 scene.rigid_solver.dofs_state.vel.from_numpy(qvel) for i in range(200): sce...
@@ -2177,18 +2177,38 @@ def test_gravity(show_viewer, tol): ) sphere = scene.add_entity(gs.morphs.Sphere()) - scene.build(n_envs=2) + scene.build(n_envs=7)
tests/test_rigid_physics.py
26
Python
0.429
suggestion
54
51
51
false
[BUG FIX] Fix gravity setters.
1,498
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: tests/test_rigid_physics.py PR Title: [BUG FIX] Fix gravity setters. BEFORE CODE: file="urdf/panda_bullet/hand.urdf", fixed=True, ), ) scene.build() assert scene.rigid_solver.n_equalities == 1 qvel = scene.rigid...
Prefer `n_envs=2`, or `n_envs=3`, it should be enough.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
scene.sim.set_gravity(torch.tensor([0.0, 0.0, 0.0]), envs_idx=[0, 1]) scene.sim.set_gravity(torch.tensor([0.0, 0.0, 100.0]), envs_idx=3) scene.sim.set_gravity(torch.tensor([[0.0, 0.0, -10.0], [0.0, 0.0, -1.0]]), envs_idx=[2, 4]) with np.testing.assert_raises(AssertionError): scene.sim.set_gravi...
You should probably check the acceleration instead.
scene.sim.set_gravity(torch.tensor([0.0, 0.0, 3.0]), envs_idx=2) with np.testing.assert_raises(AssertionError): scene.sim.set_gravity(torch.tensor([0.0, -10.0])) with np.testing.assert_raises(AssertionError): scene.sim.set_gravity(torch.tensor([[0.0, 0.0, -10.0], [0.0, 0.0, -10.0]]), envs_...
@@ -2177,18 +2177,38 @@ def test_gravity(show_viewer, tol): ) sphere = scene.add_entity(gs.morphs.Sphere()) - scene.build(n_envs=2) + scene.build(n_envs=7) - scene.sim.set_gravity(torch.tensor([0.0, 0.0, -9.8]), envs_idx=0) - scene.sim.set_gravity(torch.tensor([0.0, 0.0, 9.8]), envs_idx=1) + ...
tests/test_rigid_physics.py
26
Python
0.286
suggestion
51
51
51
false
[BUG FIX] Fix gravity setters.
1,498
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: tests/test_rigid_physics.py PR Title: [BUG FIX] Fix gravity setters. BEFORE CODE: scene.sim.set_gravity(torch.tensor([0.0, 0.0, 0.0]), envs_idx=[0, 1]) scene.sim.set_gravity(torch.tensor([0.0, 0.0, 100.0]), envs_idx=3) scene.sim.set_gravity(torch.t...
You should probably check the acceleration instead.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
scene.sim.set_gravity(torch.tensor([[-2.0, 0.0, 0.0]] * 10)) scene.sim.set_gravity(torch.tensor([0.0, 0.0, 0.0]), envs_idx=[0, 1]) scene.sim.set_gravity(torch.tensor([0.0, 0.0, 100.0]), envs_idx=3) scene.sim.set_gravity(torch.tensor([[0.0, 0.0, -10.0], [0.0, 0.0, -1.0]]), envs_idx=[2, 4]) with np.t...
Are you sure squeezing is necessary?
scene.sim.set_gravity(torch.tensor([[1.0, 0.0, 0.0], [0.0, 2.0, 0.0]]), envs_idx=[0, 1]) scene.sim.set_gravity(torch.tensor([0.0, 0.0, 3.0]), envs_idx=2) with np.testing.assert_raises(AssertionError): scene.sim.set_gravity(torch.tensor([0.0, -10.0])) with np.testing.assert_raises(AssertionErro...
@@ -2177,18 +2177,37 @@ def test_gravity(show_viewer, tol): ) sphere = scene.add_entity(gs.morphs.Sphere()) - scene.build(n_envs=2) + scene.build(n_envs=7) - scene.sim.set_gravity(torch.tensor([0.0, 0.0, -9.8]), envs_idx=0) - scene.sim.set_gravity(torch.tensor([0.0, 0.0, 9.8]), envs_idx=1) + ...
tests/test_rigid_physics.py
26
Python
0.071
question
36
51
51
false
[BUG FIX] Fix gravity setters.
1,498
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: tests/test_rigid_physics.py PR Title: [BUG FIX] Fix gravity setters. BEFORE CODE: scene.sim.set_gravity(torch.tensor([[-2.0, 0.0, 0.0]] * 10)) scene.sim.set_gravity(torch.tensor([0.0, 0.0, 0.0]), envs_idx=[0, 1]) scene.sim.set_gravity(torch.tensor(...
Are you sure squeezing is necessary?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
self._idx: int = sensor_idx self._manager: SensorManager = sensor_manager self._cache_idx: int = -1 # cache_idx is set by the SensorManager during the scene build phase # =============================== implementable methods =============================== @gs.assert_unbuilt def b...
0 by default; something like lidar have `n`, and imu has `0` (special return processing)
# initialized by SensorManager during build self._read_delay_steps: int = 0 self._shape_indices: list[tuple[int, int]] = [] self._shared_metadata: dict[str, Any] | None = None self._cache: "TensorRingBuffer" | None = None # =============================== implementable meth...
@@ -12,10 +17,62 @@ class Sensor(RBC): A sensor must have a read() method that returns the sensor data. """ + # These class variables are used by SensorManager to determine the cache metadata for the sensor. + # Sensor implementations should override these class variable values. + CACHE_DTYPE: torc...
genesis/sensors/base_sensor.py
26
Python
0.357
suggestion
88
51
51
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
Milotrince
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/base_sensor.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: self._idx: int = sensor_idx self._manager: SensorManager = sensor_manager self._cache_idx: int = -1 # cache_idx is set by the SensorManager d...
0 by default; something like lidar have `n`, and imu has `0` (special return processing)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): self._options: "SensorOptions" = sensor_options self._idx: int = sensor_idx self._manager: "SensorManager" = sensor_manager self._cache_idx: int = -1 # cache_idx is set by...
I don' think it is the right way to do it. The cache buffer length should be the same for all sensors, and the sensor manager should use `read_delay_step = max(sensor._read_delay_steps for sensor in self._sensors)` to determine how many data mush be stored in cache. It will make everything much easier to implement and ...
def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): self._options: "SensorOptions" = sensor_options self._idx: int = sensor_idx self._manager: "SensorManager" = sensor_manager # initialized by SensorManager during build sel...
@@ -12,10 +21,127 @@ class Sensor(RBC): A sensor must have a read() method that returns the sensor data. """ + def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): + self._options: "SensorOptions" = sensor_options + self._idx: int = sensor_i...
genesis/sensors/base_sensor.py
26
Python
0.786
performance
377
51
51
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/base_sensor.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: """ def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): self._options: "SensorOptions" = sensor_op...
I don' think it is the right way to do it. The cache buffer length should be the same for all sensors, and the sensor manager should use `read_delay_step = max(sensor._read_delay_steps for sensor in self._sensors)` to determine how many data mush be stored in cache. It will make everything much easier to implement and ...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 build(self): """ This method is called by the SensorManager during the scene build phase to initialize the sensor. This is where any shared metadata should be initialized. """ delay_steps_float = self._options.read_delay / self._manager._sim.dt self._read_delay_st...
`gt` is not a great acronym because it usually means "greater than". What about 'true' or 'raw' ? Or just 'ground_truth'
def build(self): """ This method is called by the SensorManager during the scene build phase to initialize the sensor. This is where any shared metadata should be initialized. """ raise NotImplementedError("Sensors must implement `build()`.") def _get_return_format(self...
@@ -12,10 +21,127 @@ class Sensor(RBC): A sensor must have a read() method that returns the sensor data. """ + def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): + self._options: "SensorOptions" = sensor_options + self._idx: int = sensor_i...
genesis/sensors/base_sensor.py
26
Python
0.571
suggestion
120
51
51
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/base_sensor.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: def build(self): """ This method is called by the SensorManager during the scene build phase to initialize the sensor. This is where any s...
`gt` is not a great acronym because it usually means "greater than". What about 'true' or 'raw' ? Or just 'ground_truth'
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 np.isclose(delay_steps_float, self._read_delay_steps): gs.logger.warn( f"Read delay should be a multiple of the simulation time step. Got {self._options.read_delay} and " f"{self._manager._sim.dt}. Actual read delay will be {1/self._read_delay_steps}." ...
No need to assert build for private methods I think but as you want.
def _get_return_format(self) -> dict[str, tuple[int, ...]] | tuple[int, ...]: """ Data format of the read() return value. Returns ------- return_format : dict | tuple - If tuple, the final shape of the read() return value. e.g. (2, 3) means read(...
@@ -12,10 +21,127 @@ class Sensor(RBC): A sensor must have a read() method that returns the sensor data. """ + def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): + self._options: "SensorOptions" = sensor_options + self._idx: int = sensor_i...
genesis/sensors/base_sensor.py
26
Python
0.214
suggestion
68
51
51
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/base_sensor.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: if not np.isclose(delay_steps_float, self._read_delay_steps): gs.logger.warn( f"Read delay should be a multiple of the simulation ...
No need to assert build for private methods I think but as you want.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
def _get_return_format(self) -> dict[str, tuple[int, int]] | tuple[int, int] | None: """ Data format of the read() return value. dict: a dictionary with string keys and tensor values will be returned. The tuple (start_idx, end_idx) will be used to get a slice of the values from...
You should describe what the cache length means, eventually with examples.
return_format : dict | tuple - If tuple, the final shape of the read() return value. e.g. (2, 3) means read() will return a tensor of shape (2, 3). - If dict a dictionary with string keys and tensor values will be returned. e.g. {"pos": (3,), "quat": (4,)}...
@@ -12,10 +21,127 @@ class Sensor(RBC): A sensor must have a read() method that returns the sensor data. """ + def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): + self._options: "SensorOptions" = sensor_options + self._idx: int = sensor_i...
genesis/sensors/base_sensor.py
26
Python
0.286
performance
74
51
51
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/base_sensor.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: def _get_return_format(self) -> dict[str, tuple[int, int]] | tuple[int, int] | None: """ Data format of the read() return value. dict: a d...
You should describe what the cache length means, eventually with examples.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): self._options: "SensorOptions" = sensor_options self._idx: int = sensor_idx self._manager: "SensorManager" = sensor_manager self._cache_idx: int = -1 # cache_idx is set by the Sens...
You should provide some concrete examples. Besides, the formatting of your docstring is not correct.
self._options: "SensorOptions" = sensor_options self._idx: int = sensor_idx self._manager: "SensorManager" = sensor_manager # initialized by SensorManager during build self._read_delay_steps: int = 0 self._shape_indices: list[tuple[int, int]] = [] self._shared_me...
@@ -12,10 +21,127 @@ class Sensor(RBC): A sensor must have a read() method that returns the sensor data. """ + def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): + self._options: "SensorOptions" = sensor_options + self._idx: int = sensor_i...
genesis/sensors/base_sensor.py
26
Python
0.429
style
103
51
51
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/base_sensor.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): self._options: "SensorOptions" = sensor_options ...
You should provide some concrete examples. Besides, the formatting of your docstring 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.
This is where any shared metadata should be initialized. """ delay_steps_float = self._options.read_delay / self._manager._sim.dt self._read_delay_steps = round(delay_steps_float) if not np.isclose(delay_steps_float, self._read_delay_steps): gs.logger.warn( ...
Skip line between short documentation and "details".
This method is called by the SensorManager during the scene build phase to initialize the sensor. This is where any shared metadata should be initialized. """ raise NotImplementedError("Sensors must implement `build()`.") def _get_return_format(self) -> dict[str, tuple[int, ...]] | ...
@@ -12,10 +21,127 @@ class Sensor(RBC): A sensor must have a read() method that returns the sensor data. """ + def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): + self._options: "SensorOptions" = sensor_options + self._idx: int = sensor_i...
genesis/sensors/base_sensor.py
26
Python
0.214
suggestion
52
51
51
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/base_sensor.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: This is where any shared metadata should be initialized. """ delay_steps_float = self._options.read_delay / self._manager._sim.dt self...
Skip line between short documentation and "details".
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
raise NotImplementedError("Sensors must implement `return_format()`.") @gs.assert_built def _update_shared_gt_cache(self): """ Update the shared sensor ground truth cache for all sensors of this class. Shared information is stored in SensorManager """ raise NotIm...
Having 'get_cache_size', 'get_cache_length', and 'get_return_format' is too much. Let's discuss this together.
def _get_cache_length(self) -> int: """ The length of the cache for this sensor instance, e.g. number of points for a Lidar point cloud. """ raise NotImplementedError("Sensors must implement `cache_length()`.") @classmethod def _update_shared_ground_truth_cache( cls,...
@@ -12,10 +21,127 @@ class Sensor(RBC): A sensor must have a read() method that returns the sensor data. """ + def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): + self._options: "SensorOptions" = sensor_options + self._idx: int = sensor_i...
genesis/sensors/base_sensor.py
26
Python
0.357
performance
110
51
51
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/base_sensor.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: raise NotImplementedError("Sensors must implement `return_format()`.") @gs.assert_built def _update_shared_gt_cache(self): """ Update...
Having 'get_cache_size', 'get_cache_length', and 'get_return_format' is too much. Let's discuss this together.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 Any, Type, TYPE_CHECKING import torch from genesis.utils.ring_buffer import TensorRingBuffer if TYPE_CHECKING: from genesis.options.sensors import SensorOptions from .base_sensor import Sensor class SensorManager: SENSOR_TYPES_MAP: dict[Type["SensorOptions"], Type["Sensor"]] = {} ...
For cache could be global, and sensor-type based. it is the big advantage of storing data flattened. But you need one cache per datatype still.
from typing import TYPE_CHECKING, Any, Type import numpy as np import torch import genesis as gs from genesis.utils.ring_buffer import TensorRingBuffer if TYPE_CHECKING: from genesis.options.sensors import SensorOptions from .base_sensor import Sensor class SensorManager: SENSOR_TYPES_MAP: dict[Type["...
@@ -0,0 +1,63 @@ +from typing import Any, Type, TYPE_CHECKING + +import torch + +from genesis.utils.ring_buffer import TensorRingBuffer + +if TYPE_CHECKING: + from genesis.options.sensors import SensorOptions + from .base_sensor import Sensor + + +class SensorManager: + SENSOR_TYPES_MAP: dict[Type["SensorOptio...
genesis/sensors/sensor_manager.py
19
Python
0.571
performance
143
44
44
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/sensor_manager.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: from typing import Any, Type, TYPE_CHECKING import torch from genesis.utils.ring_buffer import TensorRingBuffer if TYPE_CHECKING: from genesis.options.senso...
For cache could be global, and sensor-type based. it is the big advantage of storing data flattened. But you need one cache per datatype still.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
""" Base class for all types of sensors. A sensor must have a read() method that returns the sensor data. """ def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): self._options: "SensorOptions" = sensor_options self._idx: int = senso...
You should probably set the absolute tolerance yourself.
""" Base class for all types of sensors. """ def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): self._options: "SensorOptions" = sensor_options self._idx: int = sensor_idx self._manager: "SensorManager" = sensor_manager ...
@@ -12,10 +21,138 @@ class Sensor(RBC): A sensor must have a read() method that returns the sensor data. """ + def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): + self._options: "SensorOptions" = sensor_options + self._idx: int = sensor_i...
genesis/sensors/base_sensor.py
26
Python
0.286
suggestion
56
51
51
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/base_sensor.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: """ Base class for all types of sensors. A sensor must have a read() method that returns the sensor data. """ def __init__(self, sensor_options: ...
You should probably set the absolute tolerance yourself.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): self._options: "SensorOptions" = sensor_options self._idx: int = sensor_idx self._manager: "SensorManager" = sensor_manager # initialized during build self._cache_...
`self._read_delay_steps * self._manager._sim.dt` instead of `1/self._read_delay_steps` ?
def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): self._options: "SensorOptions" = sensor_options self._idx: int = sensor_idx self._manager: "SensorManager" = sensor_manager # initialized by SensorManager during build sel...
@@ -12,10 +21,138 @@ class Sensor(RBC): A sensor must have a read() method that returns the sensor data. """ + def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): + self._options: "SensorOptions" = sensor_options + self._idx: int = sensor_i...
genesis/sensors/base_sensor.py
26
Python
0.429
question
88
51
51
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/base_sensor.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: """ def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): self._options: "SensorOptions" = sensor_op...
`self._read_delay_steps * self._manager._sim.dt` instead of `1/self._read_delay_steps` ?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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._idx: int = sensor_idx self._manager: "SensorManager" = sensor_manager # initialized during build self._cache_idx: int = -1 # set by the SensorManager during build self._read_delay_steps: int = 0 self._cache_size: int = 0 # =============================== impl...
Usually the number of elements of an array is called `size`, not `length`
self._manager: "SensorManager" = sensor_manager # initialized by SensorManager during build self._read_delay_steps: int = 0 self._shape_indices: list[tuple[int, int]] = [] self._shared_metadata: dict[str, Any] | None = None self._cache: "TensorRingBuffer" | None = None ...
@@ -12,10 +21,138 @@ class Sensor(RBC): A sensor must have a read() method that returns the sensor data. """ + def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): + self._options: "SensorOptions" = sensor_options + self._idx: int = sensor_i...
genesis/sensors/base_sensor.py
26
Python
0.357
suggestion
73
51
51
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/base_sensor.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: self._idx: int = sensor_idx self._manager: "SensorManager" = sensor_manager # initialized during build self._cache_idx: int = -1 # s...
Usually the number of elements of an array is called `size`, not `length`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 _update_shared_cache(self): """ Update the shared sensor cache for all sensors of this class using metadata in SensorManager. """ raise NotImplementedError("Sensors must implement `update_shared_cache()`.") def _get_cache_length(self) -> int: """ The length o...
This is weird. What is `self._cache` ? It is not declared anywhere.
@classmethod def _get_cache_dtype(cls) -> torch.dtype: """ The dtype of the cache for this sensor. """ raise NotImplementedError("Sensors must implement `get_cache_dtype()`.") # =============================== shared methods =============================== @gs.assert_bu...
@@ -12,10 +21,138 @@ class Sensor(RBC): A sensor must have a read() method that returns the sensor data. """ + def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): + self._options: "SensorOptions" = sensor_options + self._idx: int = sensor_i...
genesis/sensors/base_sensor.py
26
Python
0.357
performance
67
51
51
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/base_sensor.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: def _update_shared_cache(self): """ Update the shared sensor cache for all sensors of this class using metadata in SensorManager. """ ...
This is weird. What is `self._cache` ? It is not declared anywhere.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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_cache_dtype(self) -> torch.dtype: """ The dtype of the cache for this sensor. """ raise NotImplementedError("Sensors must implement `get_cache_dtype()`.") # =============================== shared methods =============================== @gs.assert_built def rea...
Could you preallocate the full vector of environment as it is done in `Scene` ? For maximum efficiency is should be a torch tensor on device if not a scalar.
""" Read the sensor data (with noise applied if applicable). """ return self._get_formatted_data(self._cache.get(self._read_delay_steps), envs_idx) @gs.assert_built def read_ground_truth(self, envs_idx: List[int] | None = None): """ Read the ground truth sensor d...
@@ -12,10 +21,138 @@ class Sensor(RBC): A sensor must have a read() method that returns the sensor data. """ + def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): + self._options: "SensorOptions" = sensor_options + self._idx: int = sensor_i...
genesis/sensors/base_sensor.py
26
Python
0.571
performance
157
51
40
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/base_sensor.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: def _get_cache_dtype(self) -> torch.dtype: """ The dtype of the cache for this sensor. """ raise NotImplementedError("Sensors mus...
Could you preallocate the full vector of environment as it is done in `Scene` ? For maximum efficiency is should be a torch tensor on device if not a scalar.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
envs_idx = 0 if self._manager._sim.n_envs == 0 else np.arange(tensor.shape[0]) return_format = self._get_return_format() if isinstance(return_format, tuple): return ( tensor[envs_idx, self._cache_idx : self._cache_idx + self._cache_size] .clone()...
Remove this. You already know that the format is valid at the point. it was checked at build time.
from typing import TYPE_CHECKING, Any, List, Type import numpy as np import taichi as ti import torch import genesis as gs from genesis.repr_base import RBC if TYPE_CHECKING: from genesis.options.sensors import SensorOptions from genesis.utils.ring_buffer import TensorRingBuffer from .sensor_manager imp...
@@ -12,10 +21,138 @@ class Sensor(RBC): A sensor must have a read() method that returns the sensor data. """ + def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): + self._options: "SensorOptions" = sensor_options + self._idx: int = sensor_i...
genesis/sensors/base_sensor.py
26
Python
0.286
refactor
98
43
131
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/base_sensor.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: envs_idx = 0 if self._manager._sim.n_envs == 0 else np.arange(tensor.shape[0]) return_format = self._get_return_format() if isinstance(r...
Remove this. You already know that the format is valid at the point. it was checked at build time.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
""" raise NotImplementedError("Sensors must implement `cache_length()`.") def _get_cache_dtype(self) -> torch.dtype: """ The dtype of the cache for this sensor. """ raise NotImplementedError("Sensors must implement `get_cache_dtype()`.") # ======================...
This is basically `_get_unflattened` ? More common terminology.
@gs.assert_built def read(self, envs_idx: List[int] | None = None): """ Read the sensor data (with noise applied if applicable). """ return self._get_formatted_data(self._cache.get(self._read_delay_steps), envs_idx) @gs.assert_built def read_ground_truth(self, envs_idx: ...
@@ -12,10 +21,138 @@ class Sensor(RBC): A sensor must have a read() method that returns the sensor data. """ + def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): + self._options: "SensorOptions" = sensor_options + self._idx: int = sensor_i...
genesis/sensors/base_sensor.py
26
Python
0.357
suggestion
63
51
42
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/base_sensor.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: """ raise NotImplementedError("Sensors must implement `cache_length()`.") def _get_cache_dtype(self) -> torch.dtype: """ The dtyp...
This is basically `_get_unflattened` ? More common terminology.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# =============================== shared methods =============================== @gs.assert_built def read(self, envs_idx: List[int] | None = None): """ Read the sensor data (with noise applied if applicable). """ return self._get_return_data_from_tensor(self._cache.get(self...
Just assume that the input data was cloned before calling this function. (and add this detail in the documentation)
""" Read the ground truth sensor data (without noise). """ return self._get_formatted_data(self._manager.get_cloned_from_ground_truth_cache(self), envs_idx) def _get_formatted_data( self, tensor: torch.Tensor, envs_idx: list[int] | None ) -> torch.Tensor | dict[str, torc...
@@ -12,10 +21,138 @@ class Sensor(RBC): A sensor must have a read() method that returns the sensor data. """ + def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): + self._options: "SensorOptions" = sensor_options + self._idx: int = sensor_i...
genesis/sensors/base_sensor.py
26
Python
0.357
suggestion
115
51
33
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/base_sensor.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: # =============================== shared methods =============================== @gs.assert_built def read(self, envs_idx: List[int] | None = None): ...
Just assume that the input data was cloned before calling this function. (and add this detail in the documentation)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@gs.assert_built def read(self, envs_idx: List[int] | None = None): """ Read the sensor data (with noise applied if applicable). """ return self._get_return_data_from_tensor(self._cache.get(self._read_delay_steps), envs_idx) @gs.assert_built def read_ground_truth(self, e...
You should not squeeze unconditionally.
""" return self._get_formatted_data(self._manager.get_cloned_from_ground_truth_cache(self), envs_idx) def _get_formatted_data( self, tensor: torch.Tensor, envs_idx: list[int] | None ) -> torch.Tensor | dict[str, torch.Tensor]: # Note: This method does not clone the data tensor, ...
@@ -12,10 +21,138 @@ class Sensor(RBC): A sensor must have a read() method that returns the sensor data. """ + def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): + self._options: "SensorOptions" = sensor_options + self._idx: int = sensor_i...
genesis/sensors/base_sensor.py
26
Python
0.143
suggestion
39
51
31
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/base_sensor.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: @gs.assert_built def read(self, envs_idx: List[int] | None = None): """ Read the sensor data (with noise applied if applicable). """ ...
You should not squeeze unconditionally.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
""" raise NotImplementedError("Sensors must implement `get_cache_dtype()`.") # =============================== shared methods =============================== @gs.assert_built def read(self, envs_idx: List[int] | None = None): """ Read the sensor data (with noise applied if ...
Avoid code duplication by doing: ```python return_shapes = return_format.values() if isinstance(return_format, dict) else (return_format,) return_values = [] for shape in return_shapes: value = ... return_values.append(value) if isinstance(return_format, dict): return dict(zip(return_format.keys()...
@gs.assert_built def read_ground_truth(self, envs_idx: List[int] | None = None): """ Read the ground truth sensor data (without noise). """ return self._get_formatted_data(self._manager.get_cloned_from_ground_truth_cache(self), envs_idx) def _get_formatted_data( sel...
@@ -12,10 +21,138 @@ class Sensor(RBC): A sensor must have a read() method that returns the sensor data. """ + def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): + self._options: "SensorOptions" = sensor_options + self._idx: int = sensor_i...
genesis/sensors/base_sensor.py
26
Python
0.857
style
367
51
36
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/base_sensor.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: """ raise NotImplementedError("Sensors must implement `get_cache_dtype()`.") # =============================== shared methods ===================...
Avoid code duplication by doing: ```python return_shapes = return_format.values() if isinstance(return_format, dict) else (return_format,) return_values = [] for shape in return_shapes: value = ... return_values.append(value) if isinstance(return_format, dict): return dict(zip(return_format.keys()...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
""" Read the ground truth sensor data (without noise). """ return self._get_return_data_from_tensor(self._ground_truth_cache, envs_idx) def _get_return_data_from_tensor(self, tensor: torch.Tensor, envs_idx: List[int] | None) -> torch.Tensor: if envs_idx is None: ...
You should precompute your exact start-stop indices for each value instead of doing it at runtime.
from typing import TYPE_CHECKING, Any, List, Type import numpy as np import taichi as ti import torch import genesis as gs from genesis.repr_base import RBC if TYPE_CHECKING: from genesis.options.sensors import SensorOptions from genesis.utils.ring_buffer import TensorRingBuffer from .sensor_manager imp...
@@ -12,10 +21,138 @@ class Sensor(RBC): A sensor must have a read() method that returns the sensor data. """ + def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): + self._options: "SensorOptions" = sensor_options + self._idx: int = sensor_i...
genesis/sensors/base_sensor.py
26
Python
0.286
suggestion
98
50
131
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/base_sensor.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: """ Read the ground truth sensor data (without noise). """ return self._get_return_data_from_tensor(self._ground_truth_cache, envs_idx...
You should precompute your exact start-stop indices for each value instead of doing it at runtime.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 read_ground_truth(self, envs_idx: List[int] | None = None): """ Read the ground truth sensor data (without noise). """ return self._get_return_data_from_tensor(self._ground_truth_cache, envs_idx) def _get_return_data_from_tensor(self, tensor: torch.Tensor, envs_idx: List[int...
Start by extracting `tensor[envs_idx, self._cache_idx : self._cache_idx + self._cache_size]` once, instead of doing it repeatedly.
from typing import TYPE_CHECKING, Any, List, Type import numpy as np import taichi as ti import torch import genesis as gs from genesis.repr_base import RBC if TYPE_CHECKING: from genesis.options.sensors import SensorOptions from genesis.utils.ring_buffer import TensorRingBuffer from .sensor_manager imp...
@@ -12,10 +21,138 @@ class Sensor(RBC): A sensor must have a read() method that returns the sensor data. """ + def __init__(self, sensor_options: "SensorOptions", sensor_idx: int, sensor_manager: "SensorManager"): + self._options: "SensorOptions" = sensor_options + self._idx: int = sensor_i...
genesis/sensors/base_sensor.py
26
Python
0.571
performance
130
51
131
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/base_sensor.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: def read_ground_truth(self, envs_idx: List[int] | None = None): """ Read the ground truth sensor data (without noise). """ return ...
Start by extracting `tensor[envs_idx, self._cache_idx : self._cache_idx + self._cache_size]` once, instead of doing it repeatedly.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 .base_sensor import Sensor class SensorManager: SENSOR_TYPES_MAP: dict[Type["SensorOptions"], Type["Sensor"]] = {} def __init__(self, sim): self._sim = sim self._sensors: list["Sensor"] = [] self._sensors_metadata: dict[Type["Sensor"], dict[str, Any]] = {} self._grou...
Define variable `sensor_type = type(sensor)` instead of using `sensor.__class__` everywhere.
if TYPE_CHECKING: from genesis.options.sensors import SensorOptions from .base_sensor import Sensor class SensorManager: SENSOR_TYPES_MAP: dict[Type["SensorOptions"], Type["Sensor"]] = {} def __init__(self, sim): self._sim = sim self._sensors_by_type: dict[Type["Sensor"], list["Senso...
@@ -0,0 +1,69 @@ +from typing import TYPE_CHECKING, Any, Type + +import torch + +from genesis.utils.ring_buffer import TensorRingBuffer + +if TYPE_CHECKING: + from genesis.options.sensors import SensorOptions + + from .base_sensor import Sensor + + +class SensorManager: + SENSOR_TYPES_MAP: dict[Type["SensorOpt...
genesis/sensors/sensor_manager.py
26
Python
0.571
suggestion
92
51
51
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/sensor_manager.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: from .base_sensor import Sensor class SensorManager: SENSOR_TYPES_MAP: dict[Type["SensorOptions"], Type["Sensor"]] = {} def __init__(self, sim): ...
Define variable `sensor_type = type(sensor)` instead of using `sensor.__class__` everywhere.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
class SensorManager: SENSOR_TYPES_MAP: dict[Type["SensorOptions"], Type["Sensor"]] = {} def __init__(self, sim): self._sim = sim self._sensors: list["Sensor"] = [] self._sensors_metadata: dict[Type["Sensor"], dict[str, Any]] = {} self._ground_truth_cache: dict[Type[torch.dtype]...
Just use `setdefault`: ```python self._sensors_metadata.setdefault(sensor_type, {}) self._first_sensor_per_type.setdefault(sensor_type, sensor) ```
from .base_sensor import Sensor class SensorManager: SENSOR_TYPES_MAP: dict[Type["SensorOptions"], Type["Sensor"]] = {} def __init__(self, sim): self._sim = sim self._sensors_by_type: dict[Type["Sensor"], list["Sensor"]] = {} self._sensors_metadata: dict[Type["Sensor"], dict[str, ...
@@ -0,0 +1,69 @@ +from typing import TYPE_CHECKING, Any, Type + +import torch + +from genesis.utils.ring_buffer import TensorRingBuffer + +if TYPE_CHECKING: + from genesis.options.sensors import SensorOptions + + from .base_sensor import Sensor + + +class SensorManager: + SENSOR_TYPES_MAP: dict[Type["SensorOpt...
genesis/sensors/sensor_manager.py
26
Python
0.929
suggestion
151
51
51
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/sensor_manager.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: class SensorManager: SENSOR_TYPES_MAP: dict[Type["SensorOptions"], Type["Sensor"]] = {} def __init__(self, sim): self._sim = sim self._se...
Just use `setdefault`: ```python self._sensors_metadata.setdefault(sensor_type, {}) self._first_sensor_per_type.setdefault(sensor_type, sensor) ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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._sim = sim self._sensors: list["Sensor"] = [] self._sensors_metadata: dict[Type["Sensor"], dict[str, Any]] = {} self._ground_truth_cache: dict[Type[torch.dtype], torch.Tensor] = {} self._cache: dict[Type[torch.dtype], TensorRingBuffer] = {} self._first_sensor_per_typ...
Same. ```python cache_size_per_dtype.set_default(sensor._get_cache_dtype(), 0) ```
def __init__(self, sim): self._sim = sim self._sensors_by_type: dict[Type["Sensor"], list["Sensor"]] = {} self._sensors_metadata: dict[Type["Sensor"], dict[str, Any]] = {} self._ground_truth_cache: dict[Type[torch.dtype], torch.Tensor] = {} self._cache: dict[Type[torch.dtype...
@@ -0,0 +1,69 @@ +from typing import TYPE_CHECKING, Any, Type + +import torch + +from genesis.utils.ring_buffer import TensorRingBuffer + +if TYPE_CHECKING: + from genesis.options.sensors import SensorOptions + + from .base_sensor import Sensor + + +class SensorManager: + SENSOR_TYPES_MAP: dict[Type["SensorOpt...
genesis/sensors/sensor_manager.py
26
Python
0.714
performance
85
51
51
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/sensor_manager.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: self._sim = sim self._sensors: list["Sensor"] = [] self._sensors_metadata: dict[Type["Sensor"], dict[str, Any]] = {} self._ground_t...
Same. ```python cache_size_per_dtype.set_default(sensor._get_cache_dtype(), 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.
self._sensors_metadata: dict[Type["Sensor"], dict[str, Any]] = {} self._ground_truth_cache: dict[Type[torch.dtype], torch.Tensor] = {} self._cache: dict[Type[torch.dtype], TensorRingBuffer] = {} self._first_sensor_per_type: dict[Type["Sensor"], "Sensor"] = {} def create_sensor(self,...
Create a variable for `dtype`: ```python dtype = sensor._get_cache_dtype() ```
self._sim = sim self._sensors_by_type: dict[Type["Sensor"], list["Sensor"]] = {} self._sensors_metadata: dict[Type["Sensor"], dict[str, Any]] = {} self._ground_truth_cache: dict[Type[torch.dtype], torch.Tensor] = {} self._cache: dict[Type[torch.dtype], TensorRingBuffer] = {} ...
@@ -0,0 +1,69 @@ +from typing import TYPE_CHECKING, Any, Type + +import torch + +from genesis.utils.ring_buffer import TensorRingBuffer + +if TYPE_CHECKING: + from genesis.options.sensors import SensorOptions + + from .base_sensor import Sensor + + +class SensorManager: + SENSOR_TYPES_MAP: dict[Type["SensorOpt...
genesis/sensors/sensor_manager.py
26
Python
0.714
performance
81
51
51
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/sensor_manager.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: self._sensors_metadata: dict[Type["Sensor"], dict[str, Any]] = {} self._ground_truth_cache: dict[Type[torch.dtype], torch.Tensor] = {} self...
Create a variable for `dtype`: ```python dtype = sensor._get_cache_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.
if sensor.__class__ not in self._first_sensor_per_type: self._first_sensor_per_type[sensor.__class__] = sensor sensor.build() if sensor._get_cache_dtype() not in cache_size_per_dtype: cache_size_per_dtype[sensor._get_cache_dtype()] = 0 s...
`self._sensors_by_type` is not define.
def build(self): max_cache_buf_len = 0 cache_size_per_dtype = {} for sensor_cls, sensors in self._sensors_by_type.items(): self._sensors_metadata[sensor_cls] = {} dtype = sensor_cls._get_cache_dtype() cache_size_per_dtype.setdefault(dtype, 0) c...
@@ -0,0 +1,69 @@ +from typing import TYPE_CHECKING, Any, Type + +import torch + +from genesis.utils.ring_buffer import TensorRingBuffer + +if TYPE_CHECKING: + from genesis.options.sensors import SensorOptions + + from .base_sensor import Sensor + + +class SensorManager: + SENSOR_TYPES_MAP: dict[Type["SensorOpt...
genesis/sensors/sensor_manager.py
26
Python
0.357
suggestion
38
35
51
false
[FEATURE] Add dedicated sensor manager.
1,518
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Milotrince
Review this pull request change. Language: Python File: genesis/sensors/sensor_manager.py PR Title: [FEATURE] Add dedicated sensor manager. BEFORE CODE: if sensor.__class__ not in self._first_sensor_per_type: self._first_sensor_per_type[sensor.__class__] = sensor sensor.buil...
`self._sensors_by_type` is not define.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
texture = texture.astype(np.uint8) else: raise TypeError("Invalid type {} for texture".format(type(texture))) # Format array by picking out correct texture channels or padding if texture.ndim == 2: texture = texture[:, :, np.newaxis] if target_channel...
Just do `texture = texture[:, :, (0, 0, 0)]`. Plus add a comment to explain what it does (as you did in the description of the PR).
texture = texture.astype(np.uint8) else: raise TypeError("Invalid type {} for texture".format(type(texture))) # Format array by picking out correct texture channels or padding if texture.ndim == 2: texture = texture[:, :, np.newaxis] if target_channel...
@@ -87,15 +87,23 @@ def format_texture_source(texture, target_channels="RGB"): if texture.shape[2] == 1: texture = np.repeat(texture, 3, axis=2) elif texture.shape[2] == 2: - raise ValueError("Cannot reformat 2-channel texture into RGB") + l = tex...
genesis/ext/pyrender/utils.py
26
Python
0.5
suggestion
134
51
51
false
[FEATURE] Support 2-channel (LA) textures in Rasterizer.
1,519
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
LeonLiu4
Review this pull request change. Language: Python File: genesis/ext/pyrender/utils.py PR Title: [FEATURE] Support 2-channel (LA) textures in Rasterizer. BEFORE CODE: texture = texture.astype(np.uint8) else: raise TypeError("Invalid type {} for texture".format(type(texture))) ...
Just do `texture = texture[:, :, (0, 0, 0)]`. Plus add a comment to explain what it does (as you did in the description of the PR).
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
texture = texture[:, :, 0] texture = texture.squeeze() elif target_channels == "RG": if texture.shape[2] == 1: texture = np.repeat(texture, 2, axis=2) else: texture = texture[:, :, (0, 1)] elif target_channels == "GB": ...
`l` and `a` are not a good variable names. Try to be more explicit.
texture = texture[:, :, 0] texture = texture.squeeze() elif target_channels == "RG": if texture.shape[2] == 1: texture = np.repeat(texture, 2, axis=2) else: texture = texture[:, :, (0, 1)] elif target_channels == "GB": ...
@@ -87,15 +87,23 @@ def format_texture_source(texture, target_channels="RGB"): if texture.shape[2] == 1: texture = np.repeat(texture, 3, axis=2) elif texture.shape[2] == 2: - raise ValueError("Cannot reformat 2-channel texture into RGB") + l = tex...
genesis/ext/pyrender/utils.py
26
Python
0.357
suggestion
67
45
43
false
[FEATURE] Support 2-channel (LA) textures in Rasterizer.
1,519
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
LeonLiu4
Review this pull request change. Language: Python File: genesis/ext/pyrender/utils.py PR Title: [FEATURE] Support 2-channel (LA) textures in Rasterizer. BEFORE CODE: texture = texture[:, :, 0] texture = texture.squeeze() elif target_channels == "RG": if texture.shape[2] =...
`l` and `a` are not a good variable names. Try to be more explicit.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
elif target_channels == "RG": if texture.shape[2] == 1: texture = np.repeat(texture, 2, axis=2) else: texture = texture[:, :, (0, 1)] elif target_channels == "GB": if texture.shape[2] == 1: texture = np.repeat(texture, 2...
Same `tx` us not a good variable name.
elif target_channels == "RG": if texture.shape[2] == 1: texture = np.repeat(texture, 2, axis=2) else: texture = texture[:, :, (0, 1)] elif target_channels == "GB": if texture.shape[2] == 1: texture = np.repeat(texture, 2...
@@ -87,15 +87,23 @@ def format_texture_source(texture, target_channels="RGB"): if texture.shape[2] == 1: texture = np.repeat(texture, 3, axis=2) elif texture.shape[2] == 2: - raise ValueError("Cannot reformat 2-channel texture into RGB") + l = tex...
genesis/ext/pyrender/utils.py
26
Python
0.214
suggestion
38
43
41
false
[FEATURE] Support 2-channel (LA) textures in Rasterizer.
1,519
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
LeonLiu4
Review this pull request change. Language: Python File: genesis/ext/pyrender/utils.py PR Title: [FEATURE] Support 2-channel (LA) textures in Rasterizer. BEFORE CODE: elif target_channels == "RG": if texture.shape[2] == 1: texture = np.repeat(texture, 2, axis=2) else: ...
Same `tx` us not a good variable name.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
else: texture = texture[:, :, (0, 1)] elif target_channels == "GB": if texture.shape[2] == 1: texture = np.repeat(texture, 2, axis=2) elif texture.shape[2] > 2: texture = texture[:, :, (1, 2)] elif target_channels == "RG...
What about just calling it `texture` at this point ? You already exacted the values so it should be fine.
else: texture = texture[:, :, (0, 1)] elif target_channels == "GB": if texture.shape[2] == 1: texture = np.repeat(texture, 2, axis=2) elif texture.shape[2] > 2: texture = texture[:, :, (1, 2)] elif target_channels == "RG...
@@ -87,15 +87,21 @@ def format_texture_source(texture, target_channels="RGB"): if texture.shape[2] == 1: texture = np.repeat(texture, 3, axis=2) elif texture.shape[2] == 2: - raise ValueError("Cannot reformat 2-channel texture into RGB") + # Conve...
genesis/ext/pyrender/utils.py
26
Python
0.571
question
105
38
38
false
[FEATURE] Support 2-channel (LA) textures in Rasterizer.
1,519
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
LeonLiu4
Review this pull request change. Language: Python File: genesis/ext/pyrender/utils.py PR Title: [FEATURE] Support 2-channel (LA) textures in Rasterizer. BEFORE CODE: else: texture = texture[:, :, (0, 1)] elif target_channels == "GB": if texture.shape[2] == 1: ...
What about just calling it `texture` at this point ? You already exacted the values so it 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.
if texture.shape[2] == 1: texture = np.repeat(texture, 2, axis=2) else: texture = texture[:, :, (0, 1)] elif target_channels == "GB": if texture.shape[2] == 1: texture = np.repeat(texture, 2, axis=2) elif texture.sha...
`rgba[:, :, :3] = luminance` does not work? I think it should.
if texture.shape[2] == 1: texture = np.repeat(texture, 2, axis=2) else: texture = texture[:, :, (0, 1)] elif target_channels == "GB": if texture.shape[2] == 1: texture = np.repeat(texture, 2, axis=2) elif texture.sha...
@@ -87,15 +87,21 @@ def format_texture_source(texture, target_channels="RGB"): if texture.shape[2] == 1: texture = np.repeat(texture, 3, axis=2) elif texture.shape[2] == 2: - raise ValueError("Cannot reformat 2-channel texture into RGB") + # Conve...
genesis/ext/pyrender/utils.py
26
Python
0.429
suggestion
62
40
40
false
[FEATURE] Support 2-channel (LA) textures in Rasterizer.
1,519
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
LeonLiu4
Review this pull request change. Language: Python File: genesis/ext/pyrender/utils.py PR Title: [FEATURE] Support 2-channel (LA) textures in Rasterizer. BEFORE CODE: if texture.shape[2] == 1: texture = np.repeat(texture, 2, axis=2) else: texture = texture[:, :...
`rgba[:, :, :3] = luminance` does not work? I think it should.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
texture = texture.squeeze() elif target_channels == "RG": if texture.shape[2] == 1: texture = np.repeat(texture, 2, axis=2) else: texture = texture[:, :, (0, 1)] elif target_channels == "GB": if texture.shape[2] == 1: ...
A small comment as you did right above would be nice.
texture = texture.squeeze() elif target_channels == "RG": if texture.shape[2] == 1: texture = np.repeat(texture, 2, axis=2) else: texture = texture[:, :, (0, 1)] elif target_channels == "GB": if texture.shape[2] == 1: ...
@@ -87,15 +87,21 @@ def format_texture_source(texture, target_channels="RGB"): if texture.shape[2] == 1: texture = np.repeat(texture, 3, axis=2) elif texture.shape[2] == 2: - raise ValueError("Cannot reformat 2-channel texture into RGB") + # Conve...
genesis/ext/pyrender/utils.py
26
Python
0.214
suggestion
53
42
42
false
[FEATURE] Support 2-channel (LA) textures in Rasterizer.
1,519
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
LeonLiu4
Review this pull request change. Language: Python File: genesis/ext/pyrender/utils.py PR Title: [FEATURE] Support 2-channel (LA) textures in Rasterizer. BEFORE CODE: texture = texture.squeeze() elif target_channels == "RG": if texture.shape[2] == 1: texture = np.repea...
A small comment as you did right above would be nice.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
env_idx : int, optional The index of the environment to track the camera. camera_type : CAMERA_TYPE The type of camera. Options are CAMERA_TYPE.RASTERIZER, CAMERA_TYPE.RAYTRACER, CAMERA_TYPE.BATCH_RENDERER. """ def __init__( self, visualizer, idx=0, model...
What about defaulting to None, then replace None using the same logic as we are currently using in `render`, basically BatchRenderer if applicable, if not, RayTracer, if not Rasterizer ?
env_idx : int, optional The index of the environment to track the camera. debug : bool, optional Whether to use the debug camera. It enables to create cameras that can used to monitor / debug the simulation without being part of the "sensors". Their output is rendered by the usual simple...
@@ -87,6 +92,7 @@ def __init__( far=100.0, transform=None, env_idx=None, + camera_type=CAMERA_TYPE.RASTERIZER,
genesis/vis/camera.py
26
Python
0.571
performance
186
51
51
false
[FEATURE] Add debug camera for monitoring.
1,521
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Kashu7100
Review this pull request change. Language: Python File: genesis/vis/camera.py PR Title: [FEATURE] Add debug camera for monitoring. BEFORE CODE: env_idx : int, optional The index of the environment to track the camera. camera_type : CAMERA_TYPE The type of camera. Options are CAMERA_TYPE.RAST...
What about defaulting to None, then replace None using the same logic as we are currently using in `render`, basically BatchRenderer if applicable, if not, RayTracer, if not Rasterizer ?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
env_idx : int, optional The index of the environment to track the camera. camera_type : CAMERA_TYPE The type of camera. Options are CAMERA_TYPE.RASTERIZER, CAMERA_TYPE.RAYTRACER, CAMERA_TYPE.BATCH_RENDERER. """ def __init__( self, visualizer, idx=0, model...
What about a simple boolean flag like `debug`, `force_rasterizer` or `is_sensor` ? Do you think there is an actual use case for mixing multiple rendering backends except rasterizer + anything else ? If so, your approve is definitely the right one.
env_idx : int, optional The index of the environment to track the camera. debug : bool, optional Whether to use the debug camera. It enables to create cameras that can used to monitor / debug the simulation without being part of the "sensors". Their output is rendered by the usual simple...
@@ -87,6 +92,7 @@ def __init__( far=100.0, transform=None, env_idx=None, + camera_type=CAMERA_TYPE.RASTERIZER,
genesis/vis/camera.py
26
Python
0.786
bug
250
51
51
false
[FEATURE] Add debug camera for monitoring.
1,521
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Kashu7100
Review this pull request change. Language: Python File: genesis/vis/camera.py PR Title: [FEATURE] Add debug camera for monitoring. BEFORE CODE: env_idx : int, optional The index of the environment to track the camera. camera_type : CAMERA_TYPE The type of camera. Options are CAMERA_TYPE.RAST...
What about a simple boolean flag like `debug`, `force_rasterizer` or `is_sensor` ? Do you think there is an actual use case for mixing multiple rendering backends except rasterizer + anything else ? If so, your approve is definitely the right one.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
cam_idx = len(self._cameras) camera = Camera( self, cam_idx, model, res, pos, lookat, up, fov, aperture, focus_dist, GUI, spp, denoise, ...
Are you sure that this is a good idea? Does it pop a warning for every single simulation now or only if the user is calling `add_light` ? In the latter case, what about raising an exception instead?
self, cam_idx, model, res, pos, lookat, up, fov, aperture, focus_dist, GUI, spp, denoise, env_idx=env_idx, debug=debug, ) se...
@@ -127,17 +127,35 @@ def destroy(self): self.viewer_lock = None self._renderer = None - def add_camera(self, res, pos, lookat, up, model, fov, aperture, focus_dist, GUI, spp, denoise, env_idx): + def add_camera( + self, res, pos, lookat, up, model, fov, aperture, focus_dist, GUI, spp, ...
genesis/vis/visualizer.py
26
Python
0.714
question
198
51
51
false
[FEATURE] Add debug camera for monitoring.
1,521
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Kashu7100
Review this pull request change. Language: Python File: genesis/vis/visualizer.py PR Title: [FEATURE] Add debug camera for monitoring. BEFORE CODE: cam_idx = len(self._cameras) camera = Camera( self, cam_idx, model, res, pos, lo...
Are you sure that this is a good idea? Does it pop a warning for every single simulation now or only if the user is calling `add_light` ? In the latter case, what about raising an exception instead?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
model : str Specifies the camera model. Options are 'pinhole' or 'thinlens'. res : tuple of int, shape (2,) The resolution of the camera, specified as a tuple (width, height). pos : tuple of float, shape (3,) The position of the camera in the scene, specified ...
Can you clarify the documentation? At this point I have no clue what it is supposed to do. You should explain that it enables to create cameras that can used to monitor / debug the simulation without being part of the that are not officially considered as part of the "sensors". Their output is rendered by the usual ...
---------- model : str Specifies the camera model. Options are 'pinhole' or 'thinlens'. res : tuple of int, shape (2,) The resolution of the camera, specified as a tuple (width, height). pos : tuple of float, shape (3,) The position of the camera in th...
@@ -566,14 +567,16 @@ def add_camera( Whether to denoise the camera's rendered image. Only available when using the RayTracer renderer. Defaults to True. If OptiX denoiser is not available in your platform, consider enabling the OIDN denoiser option when building the RayTracer. + ...
genesis/engine/scene.py
26
Python
0.786
bug
574
51
51
false
[FEATURE] Add debug camera for monitoring.
1,521
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Kashu7100
Review this pull request change. Language: Python File: genesis/engine/scene.py PR Title: [FEATURE] Add debug camera for monitoring. BEFORE CODE: model : str Specifies the camera model. Options are 'pinhole' or 'thinlens'. res : tuple of int, shape (2,) The resolution of the ...
Can you clarify the documentation? At this point I have no clue what it is supposed to do. You should explain that it enables to create cameras that can used to monitor / debug the simulation without being part of the that are not officially considered as part of the "sensors". Their output is rendered by the usual ...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 rendered RGB image(s). depth_arr : np.ndarray The rendered depth image(s). seg_arr : np.ndarray The rendered segmentation mask(s). normal_arr : np.ndarray The rendered surface normal(s). """ rgb_arr, depth_arr, seg_arr, seg_colo...
Remove this message, or using debug logging.
depth : bool, optional Whether to render depth image(s). segmentation : bool, optional Whether to render the segmentation mask(s). colorize_seg : bool, optional If True, the segmentation mask will be colorized. normal : bool, optional Wheth...
@@ -388,6 +395,7 @@ def render( self, False, depth, segmentation, normal=normal ) else: + print("Camera is debug camera")
genesis/vis/camera.py
26
Python
0.286
bug
44
51
51
false
[FEATURE] Add debug camera for monitoring.
1,521
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Kashu7100
Review this pull request change. Language: Python File: genesis/vis/camera.py PR Title: [FEATURE] Add debug camera for monitoring. BEFORE CODE: The rendered RGB image(s). depth_arr : np.ndarray The rendered depth image(s). seg_arr : np.ndarray The rendered segment...
Remove this message, or using debug logging.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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_transform(self, env_idx=None): """ The current transform matrix of the camera. """ env_idx = () if env_idx is None else env_idx transform = self._multi_env_transform_tensor[env_idx] if self._batch_renderer is None: transform = transform.clone() ...
I would rather keep this inside `_batch_render` rather than make it an official property at camera level. This kind of circular dependency is not great. Besides, I don't think caching the result is relevant for something as simple as finding an index in a list.
if self._batch_renderer is None: transform = transform.clone() transform[..., :3, 3] += self._envs_offset[env_idx] return transform def _repr_brief(self): return f"{self._repr_type()}: idx: {self._idx}, pos: {self.pos}, lookat: {self.lookat}" @property def i...
@@ -763,9 +771,18 @@ def is_built(self): @property def idx(self): - """The integer index of the camera.""" + """The global integer index of the camera.""" return self._idx + @property + @lru_cache(maxsize=1)
genesis/vis/camera.py
26
Python
0.571
performance
264
51
51
false
[FEATURE] Add debug camera for monitoring.
1,521
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Kashu7100
Review this pull request change. Language: Python File: genesis/vis/camera.py PR Title: [FEATURE] Add debug camera for monitoring. BEFORE CODE: def get_transform(self, env_idx=None): """ The current transform matrix of the camera. """ env_idx = () if env_idx is None else env_idx ...
I would rather keep this inside `_batch_render` rather than make it an official property at camera level. This kind of circular dependency is not great. Besides, I don't think caching the result is relevant for something as simple as finding an index in a list.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 rendered RGB image(s). depth_arr : np.ndarray The rendered depth image(s). seg_arr : np.ndarray The rendered segmentation mask(s). normal_arr : np.ndarray The rendered surface normal(s). """ rgb_arr, depth_arr, seg_arr, seg_colo...
Is the print message correct? How about ``` if self._debug: print(...) ```
depth : bool, optional Whether to render depth image(s). segmentation : bool, optional Whether to render the segmentation mask(s). colorize_seg : bool, optional If True, the segmentation mask will be colorized. normal : bool, optional Wheth...
@@ -388,6 +395,7 @@ def render( self, False, depth, segmentation, normal=normal ) else: + print("Camera is debug camera")
genesis/vis/camera.py
26
Python
0.714
bug
83
51
51
false
[FEATURE] Add debug camera for monitoring.
1,521
Genesis-Embodied-AI/Genesis
26,702
Python
yuhongyi
Kashu7100
Review this pull request change. Language: Python File: genesis/vis/camera.py PR Title: [FEATURE] Add debug camera for monitoring. BEFORE CODE: The rendered RGB image(s). depth_arr : np.ndarray The rendered depth image(s). seg_arr : np.ndarray The rendered segment...
Is the print message correct? How about ``` if self._debug: print(...) ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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._raytracer.destroy() self._raytracer = None if self._context is not None: self._context.destroy() del self._context self._context = None self.viewer_lock = None self._renderer = None def add_camera(self, res, pos, lookat, up, ...
Why are you actively ignoring env_idx. It seems weird.
self._raytracer.destroy() self._raytracer = None if self._context is not None: self._context.destroy() del self._context self._context = None self.viewer_lock = None self._renderer = None def add_camera(self, res, pos, lookat, up, ...
@@ -127,17 +127,33 @@ def destroy(self): self.viewer_lock = None self._renderer = None - def add_camera(self, res, pos, lookat, up, model, fov, aperture, focus_dist, GUI, spp, denoise, env_idx): + def add_camera(self, res, pos, lookat, up, model, fov, aperture, focus_dist, GUI, spp, denoise, e...
genesis/vis/visualizer.py
26
Python
0.214
suggestion
54
51
51
false
[FEATURE] Add debug camera for monitoring.
1,521
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Kashu7100
Review this pull request change. Language: Python File: genesis/vis/visualizer.py PR Title: [FEATURE] Add debug camera for monitoring. BEFORE CODE: self._raytracer.destroy() self._raytracer = None if self._context is not None: self._context.destroy() del self....
Why are you actively ignoring env_idx. It seems weird.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
pos : tuple of float, shape (3,) The position of the camera in the scene, specified as (x, y, z). lookat : tuple of float, shape (3,) The point in the scene that the camera is looking at, specified as (x, y, z). up : tuple of float, shape (3,) The up vector of...
Do not skip line unless it would exceed 120 linewidth otherwise.
The resolution of the camera, specified as a tuple (width, height). pos : tuple of float, shape (3,) The position of the camera in the scene, specified as (x, y, z). lookat : tuple of float, shape (3,) The point in the scene that the camera is looking at, specified as...
@@ -566,14 +567,20 @@ def add_camera( Whether to denoise the camera's rendered image. Only available when using the RayTracer renderer. Defaults to True. If OptiX denoiser is not available in your platform, consider enabling the OIDN denoiser option when building the RayTracer. + ...
genesis/engine/scene.py
26
Python
0.214
suggestion
65
51
51
false
[FEATURE] Add debug camera for monitoring.
1,521
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Kashu7100
Review this pull request change. Language: Python File: genesis/engine/scene.py PR Title: [FEATURE] Add debug camera for monitoring. BEFORE CODE: pos : tuple of float, shape (3,) The position of the camera in the scene, specified as (x, y, z). lookat : tuple of float, shape (3,) ...
Do not skip line unless it would exceed 120 linewidth otherwise.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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.viewer_lock = None self._renderer = None def add_camera(self, res, pos, lookat, up, model, fov, aperture, focus_dist, GUI, spp, denoise, env_idx, debug): cam_idx = len(self._cameras) if not debug else len(self._debug_cameras) camera = Camera( self, cam_i...
I'm not a great fan of managing cameras and "debug cameras" separately. They are inherently the same things. Just the debug camera are not considered real sensors but only used to monitor the progress of the agent / debugging. Having `camera` getting hiding debug camera by default, and keeping them accessible via `_cam...
self._renderer = None def add_camera(self, res, pos, lookat, up, model, fov, aperture, focus_dist, GUI, spp, denoise, env_idx, debug): cam_idx = len([camera for camera in self._cameras if camera.debug == debug]) camera = Camera( self, cam_idx, model, ...
@@ -127,17 +128,36 @@ def destroy(self): self.viewer_lock = None self._renderer = None - def add_camera(self, res, pos, lookat, up, model, fov, aperture, focus_dist, GUI, spp, denoise, env_idx): - cam_idx = len(self._cameras) + def add_camera(self, res, pos, lookat, up, model, fov, aper...
genesis/vis/visualizer.py
26
Python
0.786
bug
368
51
51
false
[FEATURE] Add debug camera for monitoring.
1,521
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Kashu7100
Review this pull request change. Language: Python File: genesis/vis/visualizer.py PR Title: [FEATURE] Add debug camera for monitoring. BEFORE CODE: self.viewer_lock = None self._renderer = None def add_camera(self, res, pos, lookat, up, model, fov, aperture, focus_dist, GUI, spp, denoise, env_i...
I'm not a great fan of managing cameras and "debug cameras" separately. They are inherently the same things. Just the debug camera are not considered real sensors but only used to monitor the progress of the agent / debugging. Having `camera` getting hiding debug camera by default, and keeping them accessible via `_cam...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
B = z.shape[:-1] if out is None: out_ = np.empty((*B, 3, 3), dtype=z.dtype) else: assert out.shape == (*B, 3, 3) out_ = out z_norm = np.sqrt(np.sum(np.square(z.reshape((-1, 3))), -1)).reshape(B) out_[..., 2] = z for i in np.ndindex(B): z_norm_i = z_norm[i] ...
Remove this change. You just need to update the special case: ```python else: x[0] = z[2] x[1] = 0.0 x[2] = -z[0] ```
B = z.shape[:-1] if out is None: out_ = np.empty((*B, 3, 3), dtype=z.dtype) else: assert out.shape == (*B, 3, 3) out_ = out z_norm = np.sqrt(np.sum(np.square(z.reshape((-1, 3))), -1)).reshape(B) out_[..., 2] = z for i in np.ndindex(B): z_norm_i = z_norm[i] ...
@@ -1162,18 +1162,20 @@ def _np_z_up_to_R(z, up=None, out=None): z[:] = 0.0, 1.0, 0.0 if up is not None: - x[:] = np.cross(up[i], z) + a = up[i] else: - x[0] = z[1] - x[1] = -z[0] - x[2] = 0.0 + a = np.array([0.0, 1.0, 0....
genesis/utils/geom.py
26
Python
0.786
refactor
167
51
51
false
[BUG FIX] Correct -Z orientation & vertex color
1,540
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
ceasor-mao
Review this pull request change. Language: Python File: genesis/utils/geom.py PR Title: [BUG FIX] Correct -Z orientation & vertex color BEFORE CODE: B = z.shape[:-1] if out is None: out_ = np.empty((*B, 3, 3), dtype=z.dtype) else: assert out.shape == (*B, 3, 3) out_ = out z...
Remove this change. You just need to update the special case: ```python else: x[0] = z[2] x[1] = 0.0 x[2] = -z[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.
z_norm = np.sqrt(np.sum(np.square(z.reshape((-1, 3))), -1)).reshape(B) out_[..., 2] = z for i in np.ndindex(B): z_norm_i = z_norm[i] R = out_[i] x, y, z = R.T if z_norm_i > gs.EPS: z /= z_norm_i else: z[:] = 0.0, 1.0, 0.0 if up is n...
You should rather adapt the special case to detect whether `x_norm < gs.EPS` before setting it. Basically, you just need to check `z[1] > math.sqrt(1.0 - gs.EPS ** 2)`, then use `axis = (1.0, 0.0, 0.0)` otherwise (virtually, without actually cross product).
z_norm = np.sqrt(np.sum(np.square(z.reshape((-1, 3))), -1)).reshape(B) out_[..., 2] = z for i in np.ndindex(B): z_norm_i = z_norm[i] R = out_[i] x, y, z = R.T if z_norm_i > gs.EPS: z /= z_norm_i else: if up is None or abs(up[i][1]) < 0.5: ...
@@ -1162,18 +1162,20 @@ def _np_z_up_to_R(z, up=None, out=None): z[:] = 0.0, 1.0, 0.0 if up is not None: - x[:] = np.cross(up[i], z) + a = up[i] else: - x[0] = z[1] - x[1] = -z[0] - x[2] = 0.0 + a = np.array([0.0, 1.0, 0....
genesis/utils/geom.py
26
Python
0.643
suggestion
257
51
51
false
[BUG FIX] Correct -Z orientation & vertex color
1,540
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
ceasor-mao
Review this pull request change. Language: Python File: genesis/utils/geom.py PR Title: [BUG FIX] Correct -Z orientation & vertex color BEFORE CODE: z_norm = np.sqrt(np.sum(np.square(z.reshape((-1, 3))), -1)).reshape(B) out_[..., 2] = z for i in np.ndindex(B): z_norm_i = z_norm[i] R =...
You should rather adapt the special case to detect whether `x_norm < gs.EPS` before setting it. Basically, you just need to check `z[1] > math.sqrt(1.0 - gs.EPS ** 2)`, then use `axis = (1.0, 0.0, 0.0)` otherwise (virtually, without actually cross product).
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 self.rigid_state_dof[i_b, i_d].impulse = 0.0 def compute_preconditioner(self): if self.fem_solver.is_active(): self.compute_fem_preconditioner() @ti.kernel def compute_fem_preconditioner(self): for i_b, i_v in ti.ndrange(self.fem_solver._B, ...
use `I_v` or `i_vs` to indicate that they are several.
continue self.rigid_state_dof[i_b, i_d].impulse = 0.0 def compute_preconditioner(self): if self.fem_solver.is_active(): self.compute_fem_preconditioner() @ti.kernel def compute_fem_preconditioner(self): for i_b, i_v in ti.ndrange(self.fem_solver._B, ...
@@ -729,18 +729,16 @@ def compute_rigid_pcg_matrix_vector_product(self): ) @ti.func - def compute_elastic_products(self, i_b, i_e, B, s, i_v0, i_v1, i_v2, i_v3, src): + def compute_elastic_products(self, i_b, i_e, S, i_v, src):
genesis/engine/couplers/sap_coupler.py
26
Python
0.429
suggestion
54
51
51
false
[FEATURE] Add Fem fixed constraint for implicit solver
1,562
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Libero0809
Review this pull request change. Language: Python File: genesis/engine/couplers/sap_coupler.py PR Title: [FEATURE] Add Fem fixed constraint for implicit solver BEFORE CODE: continue self.rigid_state_dof[i_b, i_d].impulse = 0.0 def compute_preconditioner(self): if self.fem_so...
use `I_v` or `i_vs` to indicate that they are several.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
damping_alpha_dt = self._damping_alpha * self._substep_dt damping_alpha_factor = damping_alpha_dt + 1.0 damping_beta_over_dt = self._damping_beta / self._substep_dt damping_beta_factor = damping_beta_over_dt + 1.0 # inertia for i_b, i_v in ti.ndrange(self._B, self.n_verti...
same. `i_v` is not ideal for something that is a vector.
H_St_x_diff[i * 3 : i * 3 + 3] += ( self.elements_el_hessian[i_b, i, j, i_e] @ St_x_diff[j * 3 : j * 3 + 3] ) self.elements_el_energy[i_b, i_e].energy += 0.5 * damping_beta_over_dt * St_x_diff.dot(H_St_x_diff) @ti.kernel def accum...
@@ -682,18 +677,22 @@ def accumulate_vertex_force_preconditioner(self, f: ti.i32): V = self.elements_i[i_e].V B = self.elements_i[i_e].B gradient = self.elements_el_energy[i_b, i_e].gradient - force = -V * gradient @ B.transpose() i_v = self.elements_i[i_e]...
genesis/engine/solvers/fem_solver.py
26
Python
0.357
suggestion
56
51
51
false
[FEATURE] Add Fem fixed constraint for implicit solver
1,562
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Libero0809
Review this pull request change. Language: Python File: genesis/engine/solvers/fem_solver.py PR Title: [FEATURE] Add Fem fixed constraint for implicit solver BEFORE CODE: damping_alpha_dt = self._damping_alpha * self._substep_dt damping_alpha_factor = damping_alpha_dt + 1.0 damping_beta_over...
same. `i_v` is not ideal for something that is a vector.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, 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 compute_Ap(self): damping_alpha_dt = self._damping_alpha * self._substep_dt damping_alpha_factor = damping_alpha_dt + 1.0 damping_beta_over_dt = self._damping_beta / self._substep_dt damping_beta_factor = damping_beta_over_dt + 1.0 for i_b, i_v in ti.ndrange(self._B, self...
You have multiple duplication of this pattern. Could this be factored in some private ti.func?
def compute_Ap(self): damping_alpha_dt = self._damping_alpha * self._substep_dt damping_alpha_factor = damping_alpha_dt + 1.0 damping_beta_over_dt = self._damping_beta / self._substep_dt damping_beta_factor = damping_beta_over_dt + 1.0 for i_b, i_v in ti.ndrange(self._B, self...
@@ -758,40 +757,33 @@ def compute_Ap(self): continue V = self.elements_i[i_e].V B = self.elements_i[i_e].B - s = -B[0, :] - B[1, :] - B[2, :] # s is the negative sum of B rows + i_v = self.elements_i[i_e].el2v + S = ti.Matrix.zero(gs.ti_float,...
genesis/engine/solvers/fem_solver.py
26
Python
0.286
question
94
51
51
false
[FEATURE] Add Fem fixed constraint for implicit solver
1,562
Genesis-Embodied-AI/Genesis
26,702
Python
duburcqa
Libero0809
Review this pull request change. Language: Python File: genesis/engine/solvers/fem_solver.py PR Title: [FEATURE] Add Fem fixed constraint for implicit solver BEFORE CODE: def compute_Ap(self): damping_alpha_dt = self._damping_alpha * self._substep_dt damping_alpha_factor = damping_alpha_dt + 1.0...
You have multiple duplication of this pattern. Could this be factored in some private ti.func?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.