Skip to content

Commit 432b7a1

Browse files
committed
style: fix gym warning and path obj in cli
1 parent 5f14c3a commit 432b7a1

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

‎extensions/rcs_zed/src/rcs_zed/__main__.py‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
logger = logging.getLogger(__name__)
1212
zed_app = typer.Typer(help="CLI tools for the ZED camera module of rcs.")
1313

14-
DEFAULT_RGB_SNAPSHOT_OUTPUT_OPTION = typer.Option(Path("zed_latest.png"), "--output", "-o", help="PNG file to write.")
15-
1614

1715
def _display_frame(window_name: str, frame):
1816
cv2.imshow(window_name, frame.camera.color.data[:, :, ::-1])
@@ -97,17 +95,18 @@ def rgb_view(
9795
@zed_app.command("rgb-snapshot")
9896
def rgb_snapshot(
9997
serial: str | None = typer.Argument(None, help="Optional ZED serial number. Uses the first device if omitted."),
100-
output: Path = DEFAULT_RGB_SNAPSHOT_OUTPUT_OPTION,
98+
output: str = typer.Option("zed_latest.png", "--output", "-o", help="PNG file to write."),
10199
width: int = typer.Option(1280, help="Requested capture width."),
102100
height: int = typer.Option(720, help="Requested capture height."),
103101
fps: int = typer.Option(30, help="Requested capture frame rate."),
104102
duration: float = typer.Option(1.0, "--duration", "-d", help="Seconds to read frames before saving."),
105103
):
106104
"""Open a ZED camera briefly and save the latest RGB frame as a PNG."""
105+
output_path = Path(output)
107106
if duration <= 0:
108107
msg = "Duration must be greater than zero."
109108
raise typer.BadParameter(msg)
110-
if output.suffix.lower() != ".png":
109+
if output_path.suffix.lower() != ".png":
111110
msg = "Output path must end in .png."
112111
raise typer.BadParameter(msg)
113112

@@ -131,11 +130,11 @@ def rgb_snapshot(
131130
camera.close()
132131

133132
assert latest_frame is not None
134-
output.parent.mkdir(parents=True, exist_ok=True)
133+
output_path.parent.mkdir(parents=True, exist_ok=True)
135134
image_bgr = latest_frame.camera.color.data[:, :, ::-1]
136135
print(latest_frame.camera.color.intrinsics)
137-
if not cv2.imwrite(str(output), image_bgr):
138-
msg = f"Could not write PNG to {output}."
136+
if not cv2.imwrite(str(output_path), image_bgr):
137+
msg = f"Could not write PNG to {output_path}."
139138
raise typer.BadParameter(msg)
140139

141140
typer.echo(f"Saved {output} from ZED {serial} after reading {frames_read} frame(s).")

‎python/rcs/envs/base.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ def reset(
283283
self.np_random, _ = seeding.np_random(seed)
284284
re = super().reset(seed=None, options=options)
285285
if self.env.get_wrapper_attr("PLATFORM") == RobotPlatform.SIMULATION:
286-
self.sim.step(30) # apply reset state
286+
sim = cast(simulation.Sim, self.get_wrapper_attr("sim"))
287+
sim.step(30) # apply reset state
287288
return re
288289

289290

0 commit comments

Comments
 (0)