Skip to content

Commit deaf791

Browse files
fix: preserve Q10 dock heading
1 parent a3bba13 commit deaf791

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

roborock/map/b01_q10_render.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,11 @@ def _place_charger_from_header(
259259
map_data: MapData,
260260
packet: Q10MapPacket,
261261
) -> bool:
262-
"""Place the saved dock using its absolute header pixel coordinates.
263-
264-
The Q10 header angle follows the dock axis, while the shared V1 marker
265-
expects the outward-facing normal, so rotate it by 90 degrees.
266-
"""
262+
"""Place the saved dock using its absolute header pixel coordinates."""
267263
header = packet.header_calibration
268264
if header is None or (position := header.charger_pixels()) is None:
269265
return False
270-
map_data.charger = Point(*position, 90 - header.charger_phi)
266+
map_data.charger = Point(*position, header.charger_phi)
271267
return True
272268

273269

tests/map/test_b01_q10_render.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,13 @@ def test_render_draws_dock_from_header_without_trace() -> None:
164164

165165

166166
def test_place_charger_uses_absolute_header_pixels() -> None:
167-
"""The dock uses absolute pixels and converts its axis to a V1 heading."""
167+
"""The dock coordinates do not receive the world origin a second time."""
168168
packet = replace(_packet(), header_calibration=HEADER)
169169
map_data = MapData()
170170

171171
assert _place_charger_from_header(map_data, packet)
172172

173-
assert map_data.charger == Point(3, 3, 0)
173+
assert map_data.charger == Point(3, 3, 90)
174174

175175

176176
def test_place_docked_robot_uses_shared_v1_marker_geometry() -> None:
@@ -188,6 +188,22 @@ def test_place_docked_robot_uses_shared_v1_marker_geometry() -> None:
188188
assert map_data.path is None
189189

190190

191+
def test_q10_zero_degree_dock_places_robot_to_its_right() -> None:
192+
"""The Q10 dock heading is already its outward-facing direction."""
193+
packet = replace(_packet(), header_calibration=replace(HEADER, charger_phi=0))
194+
map_data = MapData()
195+
196+
assert _place_charger_from_header(map_data, packet)
197+
assert _place_docked_robot(map_data)
198+
199+
assert map_data.charger == Point(3, 3, 0)
200+
assert map_data.vacuum_position == Point(
201+
3 + Sizes.SIZES[Size.CHARGER_RADIUS],
202+
3,
203+
0,
204+
)
205+
206+
191207
def test_render_applies_erase_zones() -> None:
192208
"""With a calibration, erase-zone cells are blanked from the image."""
193209
packet, trace = _calibrated_inputs()

0 commit comments

Comments
 (0)