Skip to content

feat: decode Q10 (03 01) saved-map obstacle markers#1

Draft
tubededentifrice wants to merge 2 commits into
q10-map-layersfrom
q10-map-obstacles
Draft

feat: decode Q10 (03 01) saved-map obstacle markers#1
tubededentifrice wants to merge 2 commits into
q10-map-layersfrom
q10-map-obstacles

Conversation

@tubededentifrice

Copy link
Copy Markdown
Owner

Draft / stacked on Python-roborock#848 — builds on the q10-map-layers render pipeline (render_q10_map / MapData placement). Base is q10-map-layers so this diff shows only the obstacle work; retarget to main once Python-roborock#848 merges.

Implements the obstacle-layer follow-up @andrewlyeats offered in #848 (gist: https://gist.github.com/andrewlyeats/6c0c5892ab61e6d1c75d4c42c9202903).

What

Saved-map frames (marker 03 01) share the current-map (01 01) header/grid/room layout but append an obstacle-marker section to the tail, after the carpet block:

erase -> carpet -> obstacles([count:u8] then count × int16-BE (x, y)) -> skip-clean -> path-package
  • Parse 03 01 frames — is_saved_map_packet(); parse_map_packet() now accepts both markers — and decode the obstacle section into Q10MapPacket.obstacles. Obstacles are located immediately after a validated carpet block (same uncompressed_len == w*h guard as the carpet parser), so a frame without one decodes no obstacles rather than misreading the tail.
  • Place obstacles onto MapData.obstacles in render_q10_map, using the fixed header-anchored obstacle scale (col = ox/10 + x/50, row = oy/10 − y/50 → a GridCalibration(resolution=50, origin=header.origin_pixels())). This is independent of the fitted path calibration, so obstacles show up as soon as the saved map arrives (no clean required).
  • Route 03 01 through the protocol dispatch; the map trait needs no change (obstacles flow through the existing Q10MapPacket path).

Provenance / fixtures

Byte-level decode ground-truthed against two real ss07 captures @andrewlyeats shared (map id zeroed, rest as-captured), added as fixtures:

  • b01_q10_saved_map_2obstacles.bin — 2 obstacles; header W=219 H=254 ox=1651 oy=434 res=5
  • b01_q10_saved_map_53obstacles.bin — 53 obstacles

His expected decode reproduces exactly: raw (-4633, -1946) → grid px (72.4, 82.3), raw (-5231, -3852)(60.5, 120.4).

Tests

Parser (marker recognition, 2/53 obstacle decode, synthetic tail, no-carpet defensiveness), render (placement at the expected pixels, keepalive-header no-op), protocol dispatch. pre-commit (ruff + mypy) clean; full suite green.

Not in this PR (follow-ups)

The 03 01 tail also carries the skip-clean section and the trailing path package (17-byte header + int16 (x, y) points, same geometry as 02 01). Left for a follow-up to keep this focused on obstacles.

Saved-map frames (marker `03 01`) share the current-map (`01 01`)
header/grid/room layout but append an obstacle-marker section to the tail,
after the carpet block: `[count:u8]` then `count` int16-BE (x, y) pairs in
raw obstacle coordinates.

- Parse `03 01` frames (`is_saved_map_packet`; `parse_map_packet` now
  accepts both markers) and decode the obstacle section into
  `Q10MapPacket.obstacles`. Located after a validated carpet block, so a
  frame without one decodes no obstacles rather than misreading the tail.
- Place obstacles onto `MapData.obstacles` in `render_q10_map` using a fixed
  header-anchored scale (`col = ox/10 + x/50`, `row = oy/10 - y/50`,
  resolution 50 around the header pixel origin) -- independent of the fitted
  path calibration, so they appear as soon as the saved map arrives.
- Route `03 01` through the protocol dispatch; the map trait needs no change.

Fixtures + byte-level decode ground-truthed against two real ss07 captures
shared by @andrewlyeats (2- and 53-obstacle frames, map id zeroed): obstacle
raw (-4633, -1946) with header origin (1651, 434) lands at grid px
(72.4, 82.3), matching his expected decode.

Follow-ups (not in this PR): the trailing 17-byte-header path package and the
skip-clean section that also live in the `03 01` tail.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant