Skip to content

Commit 97d5a33

Browse files
committed
Apply ruff format to the showcase runners and mesh ray-cast sensor
1 parent b13b478 commit 97d5a33

8 files changed

Lines changed: 78 additions & 24 deletions

File tree

‎examples/genelab_showcase/src/genelab_showcase/actuators/runner.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,12 @@ def _build_window(self, app: Any) -> None:
175175
slider.setValue(round(current / step_val))
176176

177177
def on_change(
178-
ticks: int, attr: str = attr, label: str = label, step_val: float = step_val,
179-
fmt: str = fmt, tag: QtWidgets.QLabel = tag,
178+
ticks: int,
179+
attr: str = attr,
180+
label: str = label,
181+
step_val: float = step_val,
182+
fmt: str = fmt,
183+
tag: QtWidgets.QLabel = tag,
180184
) -> None:
181185
value = ticks * step_val
182186
setattr(self, attr, value)

‎examples/genelab_showcase/src/genelab_showcase/contact/runner.py‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,16 @@
1919
from genelab.sensor import ContactData
2020

2121
# The leg joints flexed to lift a foot: (hip pitch, knee, ankle pitch), per side.
22-
_LEFT_LEG: tuple[str, str, str] = ("left_hip_pitch_joint", "left_knee_joint", "left_ankle_pitch_joint")
23-
_RIGHT_LEG: tuple[str, str, str] = ("right_hip_pitch_joint", "right_knee_joint", "right_ankle_pitch_joint")
22+
_LEFT_LEG: tuple[str, str, str] = (
23+
"left_hip_pitch_joint",
24+
"left_knee_joint",
25+
"left_ankle_pitch_joint",
26+
)
27+
_RIGHT_LEG: tuple[str, str, str] = (
28+
"right_hip_pitch_joint",
29+
"right_knee_joint",
30+
"right_ankle_pitch_joint",
31+
)
2432
# Per-actuator-group action_scale turns these into a high-knee lift (~70 deg hip, ~60 deg knee
2533
# above default): big enough to clear the ground cleanly so the contact <-> air switch is
2634
# obvious. Hip is negative (pitch flexion).
@@ -44,7 +52,9 @@ def __init__(self, env_cfg: "ManagerBasedRlEnvCfg") -> None:
4452
# PD holds the pelvis up against the planted-leg squat so the body marches tall.
4553
super().__init__(
4654
env_cfg,
47-
spring=SpringCfg(link_name="pelvis", gravity_comp=0.9, stiffness=8000.0, damping=1000.0),
55+
spring=SpringCfg(
56+
link_name="pelvis", gravity_comp=0.9, stiffness=8000.0, damping=1000.0
57+
),
4858
)
4959
self._joint_idx: dict[str, int] | None = None
5060
self._foot_idx: tuple[int, int] = (-1, -1)
@@ -55,7 +65,10 @@ def _ensure_indices(self, env: "ManagerBasedRlEnv") -> None:
5565
return
5666
robot = env.articulations["robot"]
5767
self._joint_idx = {n: robot.joint_names.index(n) for n in (*_LEFT_LEG, *_RIGHT_LEG)}
58-
self._foot_idx = (robot.link_names.index(FOOT_LINKS[0]), robot.link_names.index(FOOT_LINKS[1]))
68+
self._foot_idx = (
69+
robot.link_names.index(FOOT_LINKS[0]),
70+
robot.link_names.index(FOOT_LINKS[1]),
71+
)
5972

6073
def _scripted_action(self, env: "ManagerBasedRlEnv", step: int) -> torch.Tensor:
6174
self._ensure_indices(env)

‎examples/genelab_showcase/src/genelab_showcase/curriculum/runner.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,12 @@ def _build_hist_window(self, app: Any) -> None:
129129
plot.setLabel("bottom", "difficulty level (0 = smoothest)")
130130
plot.setLabel("left", "robots")
131131
plot.setYRange(0, 12)
132-
brushes = [pg.mkBrush(int(c[0] * 255), int(c[1] * 255), int(c[2] * 255)) for c in _LEVEL_COLORS]
133-
self._bar = pg.BarGraphItem(x=list(range(_NUM_ROWS)), height=[0] * _NUM_ROWS, width=0.7, brushes=brushes)
132+
brushes = [
133+
pg.mkBrush(int(c[0] * 255), int(c[1] * 255), int(c[2] * 255)) for c in _LEVEL_COLORS
134+
]
135+
self._bar = pg.BarGraphItem(
136+
x=list(range(_NUM_ROWS)), height=[0] * _NUM_ROWS, width=0.7, brushes=brushes
137+
)
134138
plot.addItem(self._bar)
135139

136140
def _update_hist(self) -> None:

‎examples/genelab_showcase/src/genelab_showcase/raycast/env_cfg.py‎

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,30 @@ def raycast_showcase_env_cfg() -> ManagerBasedRlEnvCfg:
3030
# rays read varying distances. ``use_visual_raycasting`` is harmless for these solid
3131
# bodies (their collision faces are in the BVH anyway) but keeps the intent explicit.
3232
props: dict[str, ArticulationCfg | RigidObjectCfg] = {
33-
"box_tall": RigidObjectCfg(morph="box", size=(0.08, 0.08, 0.30), init_pos=(0.45, 0.0, 0.15), use_visual_raycasting=True),
34-
"box_wide": RigidObjectCfg(morph="box", size=(0.12, 0.12, 0.16), init_pos=(0.40, 0.17, 0.08), use_visual_raycasting=True),
35-
"box_low": RigidObjectCfg(morph="box", size=(0.10, 0.10, 0.10), init_pos=(0.52, -0.18, 0.05), use_visual_raycasting=True),
36-
"ball_a": RigidObjectCfg(morph="sphere", size=(0.07,), init_pos=(0.50, 0.10, 0.07), use_visual_raycasting=True),
37-
"ball_b": RigidObjectCfg(morph="sphere", size=(0.05,), init_pos=(0.38, -0.08, 0.05), use_visual_raycasting=True),
33+
"box_tall": RigidObjectCfg(
34+
morph="box",
35+
size=(0.08, 0.08, 0.30),
36+
init_pos=(0.45, 0.0, 0.15),
37+
use_visual_raycasting=True,
38+
),
39+
"box_wide": RigidObjectCfg(
40+
morph="box",
41+
size=(0.12, 0.12, 0.16),
42+
init_pos=(0.40, 0.17, 0.08),
43+
use_visual_raycasting=True,
44+
),
45+
"box_low": RigidObjectCfg(
46+
morph="box",
47+
size=(0.10, 0.10, 0.10),
48+
init_pos=(0.52, -0.18, 0.05),
49+
use_visual_raycasting=True,
50+
),
51+
"ball_a": RigidObjectCfg(
52+
morph="sphere", size=(0.07,), init_pos=(0.50, 0.10, 0.07), use_visual_raycasting=True
53+
),
54+
"ball_b": RigidObjectCfg(
55+
morph="sphere", size=(0.05,), init_pos=(0.38, -0.08, 0.05), use_visual_raycasting=True
56+
),
3857
}
3958

4059
return ManagerBasedRlEnvCfg(

‎examples/genelab_showcase/src/genelab_showcase/runner.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ def _apply_spring(self, env: ManagerBasedRlEnv) -> None:
204204
world_up = torch.tensor(_WORLD_UP, device=device).expand(n, 3)
205205
up_w = quat_apply(rs.root_quat, world_up) # base up-axis in world
206206
err = torch.cross(up_w, world_up, dim=-1) # rotates up_w back toward world up
207-
torque = (spr.upright_stiffness * err - spr.upright_damping * rs.root_ang_vel_w).unsqueeze(1)
207+
torque = (
208+
spr.upright_stiffness * err - spr.upright_damping * rs.root_ang_vel_w
209+
).unsqueeze(1)
208210
link.solver.apply_links_external_torque(torque, (link.idx,), ref="link_com")
209211

210212
# ------------------------------------------------------------------ play

‎examples/genelab_showcase/src/genelab_showcase/sensors/env_cfg.py‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,24 @@ def sensors_showcase_env_cfg() -> ManagerBasedRlEnvCfg:
7777
# depth streams show real geometry (boxes + spheres at varied size / distance)
7878
# instead of an empty plane as joint1 sweeps the camera across them.
7979
entities={
80-
"prop_box_a": RigidObjectCfg(morph="box", size=(0.08, 0.08, 0.08), init_pos=(0.45, 0.0, 0.04)),
81-
"prop_box_b": RigidObjectCfg(morph="box", size=(0.06, 0.12, 0.10), init_pos=(0.40, 0.22, 0.05)),
82-
"prop_box_c": RigidObjectCfg(morph="box", size=(0.12, 0.06, 0.06), init_pos=(0.52, -0.20, 0.03)),
83-
"prop_tower": RigidObjectCfg(morph="box", size=(0.05, 0.05, 0.16), init_pos=(0.58, -0.04, 0.08)),
84-
"prop_ball_a": RigidObjectCfg(morph="sphere", size=(0.05,), init_pos=(0.55, 0.13, 0.05)),
85-
"prop_ball_b": RigidObjectCfg(morph="sphere", size=(0.035,), init_pos=(0.37, -0.10, 0.035)),
80+
"prop_box_a": RigidObjectCfg(
81+
morph="box", size=(0.08, 0.08, 0.08), init_pos=(0.45, 0.0, 0.04)
82+
),
83+
"prop_box_b": RigidObjectCfg(
84+
morph="box", size=(0.06, 0.12, 0.10), init_pos=(0.40, 0.22, 0.05)
85+
),
86+
"prop_box_c": RigidObjectCfg(
87+
morph="box", size=(0.12, 0.06, 0.06), init_pos=(0.52, -0.20, 0.03)
88+
),
89+
"prop_tower": RigidObjectCfg(
90+
morph="box", size=(0.05, 0.05, 0.16), init_pos=(0.58, -0.04, 0.08)
91+
),
92+
"prop_ball_a": RigidObjectCfg(
93+
morph="sphere", size=(0.05,), init_pos=(0.55, 0.13, 0.05)
94+
),
95+
"prop_ball_b": RigidObjectCfg(
96+
morph="sphere", size=(0.035,), init_pos=(0.37, -0.10, 0.035)
97+
),
8698
},
8799
sensors=(
88100
CameraSensorCfg(

‎examples/genelab_showcase/src/genelab_showcase/terrain/runner.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ def _draw_rays(self, env: "ManagerBasedRlEnv", data: "RayCastData") -> None:
8686
stride = max(1, len(starts) // _MAX_RAY_LINES)
8787
for i in range(0, len(starts), stride):
8888
self._nodes.append(
89-
gs_scene.draw_debug_line(starts[i], hits[i], radius=0.004, color=(0.3, 0.85, 1.0, 0.5))
89+
gs_scene.draw_debug_line(
90+
starts[i], hits[i], radius=0.004, color=(0.3, 0.85, 1.0, 0.5)
91+
)
9092
)
9193

9294
def _build_scan_windows(self, app: Any) -> None:

‎src/genelab/sensor/mesh_ray_cast.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,7 @@ def _resolve_link_idx(handle: Any, link_name: str) -> int:
173173
try:
174174
return names.index(link_name)
175175
except ValueError as exc:
176-
raise ValueError(
177-
f"link {link_name!r} not found on entity; links={names!r}"
178-
) from exc
176+
raise ValueError(f"link {link_name!r} not found on entity; links={names!r}") from exc
179177

180178
def bind(self, env: "EnvContext") -> None:
181179
super().bind(env)

0 commit comments

Comments
 (0)