Repository navigation
feat: add Q7 zone cleaning - #1038
ramon-angosto wants to merge 1 commit into
Conversation
Lash-L
left a comment
There was a problem hiding this comment.
Automated code review by Gemini 4 Argon in Antigravity using our /review (/code-review) skill (.agents/skills/code-review/SKILL.md / AGENTS.md).
Summary by Layer
roborock/data/b01_q7/(Q7RoborockPoint):- Cleanly encapsulates the conversion between the common Roborock millimetre coordinate frame (origin at
(25500, 25500)) and Q7 world coordinates in meters ((x - 25500) / 1000,(y - 25500) / 1000, with y-up matching Q7 map coordinates). - Exported in
roborock/data/b01_q7/__init__.py,roborock/data/__init__.py, androborock/devices/traits/b01/q7/__init__.py.
- Cleanly encapsulates the conversion between the common Roborock millimetre coordinate frame (origin at
roborock/devices/traits/b01/q7/(Q7PropertiesApi.clean_zone/clean_zones):- Accurately implements the 3-step Q7 zone cleaning command sequence:
service.set_preference_type({"prefer_type": 4}),service.set_zone_points({"zone_points": [...]}with 8 world-meter floats per rectangular zone), andservice.set_zone_clean({"ctrl_value": 1}). - Validates non-empty zone lists and rejects degenerate zero-width/zero-height rectangles before issuing any RPC commands.
- Minor suggestion: Reuse the already-imported
CleanTaskTypeMapping.AREA.code(4) instead of defining a duplicate_ZONE_PREFERENCE_TYPE = 4constant.
- Accurately implements the 3-step Q7 zone cleaning command sequence:
tests/:- Good unit test coverage in
tests/data/b01_q7/test_b01_q7_containers.pyandtests/devices/traits/b01/q7/test_init.pycovering coordinate round-trips, single-zone and multi-zone command payloads, and pre-send validation errors.
- Good unit test coverage in
| ] | ||
|
|
||
| # ``service.set_preference_type`` value that selects zone cleaning (``custom_type`` 4). | ||
| _ZONE_PREFERENCE_TYPE = 4 |
There was a problem hiding this comment.
CleanTaskTypeMapping is already imported in this module (line 14) and defines CleanTaskTypeMapping.AREA = ("zones", 4) in b01_q7_code_mappings.py. Using CleanTaskTypeMapping.AREA.code in clean_zones (similar to CleanTaskTypeMapping.ALL.code and CleanTaskTypeMapping.ROOM.code in start_clean and clean_segments above) avoids duplicating the constant here.
There was a problem hiding this comment.
Done in ad3991f: clean_zones now uses CleanTaskTypeMapping.AREA.code and the duplicated _ZONE_PREFERENCE_TYPE constant is gone.
| min_x, max_x = sorted((x1, x2)) | ||
| min_y, max_y = sorted((y1, y2)) | ||
| zone_points += [min_x, min_y, max_x, min_y, max_x, max_y, min_x, max_y] | ||
| await self.send(RoborockB01Q7Methods.SET_PREFERENCE_TYPE, {"prefer_type": _ZONE_PREFERENCE_TYPE}) |
There was a problem hiding this comment.
| await self.send(RoborockB01Q7Methods.SET_PREFERENCE_TYPE, {"prefer_type": _ZONE_PREFERENCE_TYPE}) | |
| await self.send(RoborockB01Q7Methods.SET_PREFERENCE_TYPE, {"prefer_type": CleanTaskTypeMapping.AREA.code}) |
|
Hi @ramon-angosto - please take a look at the automated feedback. Once you're done, mark the PR as ready for review and I will take a look myself! Going ahead and doing this for all your PRs |
Add `clean_zone` and `clean_zones` to the Q7 properties API. Zones are given as two opposite corners in the common Roborock millimetre coordinate space through a new `Q7RoborockPoint`, which converts to and from the Q7 world coordinates (meters, origin next to the dock). The device expects the zone preference type to be selected first (`service.set_preference_type`), then the zone corners as a flat list (`service.set_zone_points`), and finally `service.set_zone_clean` to start. Several zones are concatenated into a single task.
67ce5a1 to
ad3991f
Compare
Summary
Adds zone cleaning to the Q7 (B01) properties API:
Q7PropertiesApi.clean_zone(first_corner, second_corner)cleans one rectangle.Q7PropertiesApi.clean_zones([(first, second), ...])cleans several rectangles in a single task.Q7RoborockPoint(common Roborock millimetre coordinates, map origin at(25500, 25500)) withfrom_world()/to_world()conversions to the Q7 world coordinates (meters, origin next to the dock, y pointing up). This keeps the public API in the same coordinate space as other Roborock devices.Device protocol
The device needs three commands, in this order:
service.set_preference_type {"prefer_type": 4}selects zone cleaning.service.set_zone_points {"zone_points": [x1, y1, x2, y1, x2, y2, x1, y2, ...]}sends the corners of each rectangle in world meters. Multiple rectangles are concatenated.service.set_zone_clean {"ctrl_value": 1}starts the task.ctrl_value: 0stops it.While the zone task runs, the device reports
work_mode30 (PLAN_AREA).Testing
roborock.vacuum.sc05, firmware 03.01.80) with one and two zones.