Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persistent maps, virtual walls, and forbidden zones #15

Open
JohnRev opened this issue Dec 15, 2018 · 20 comments
Open

Persistent maps, virtual walls, and forbidden zones #15

JohnRev opened this issue Dec 15, 2018 · 20 comments

Comments

@JohnRev
Copy link

JohnRev commented Dec 15, 2018

Hello,

I came upon the following commands on a gen2 vacuum with v001780 firmware:

set_lab_status
start_edit_map
end_edit_map
save_map
reset_map
use_new_map
use_old_map
get_persist_map_v1

mirobo raw-command set_lab_status 1 allows the robot to "remember" maps after a reboot.
The start_edit_map, end_edit_map, and save_map appear to be related to the virtual walls and forbidden zones functionality. I believe a JSON is expected as parameters for the function.
I do not have the xiaomi app, and I was not able to figure out the format of these parameters.

Note that calling start_edit_map, end_edit_map, or save_map without first enabling the lab_status will result in the following response: The Lab Status is disable.

Not sure what the use_new_map, use_old_map, and get_persist_map do.

@cryptomilk
Copy link

I'm also seeing:

get_fresh_map_v2
get_fresh_map
get_persist_map_v2
get_persist_map

It is also possible that persistent maps are stored in the mii cloud and downloaded if requested.

@FeatureExpert
Copy link

3.3.9_001633

Lab mode ON:

req: {'from': '4', 'id': ##MESSAGE_ID##, 'method': 'set_lab_status', 'params': [1]}
res: {'id': ##MESSAGE_ID##, 'result': ['ok']}

Lab mode OFF:

req: {'from': '4', 'id': ##MESSAGE_ID##, 'method': 'set_lab_status', 'params': [0]}
res: {'id': ##MESSAGE_ID##, 'result': ['ok']}

Software barrier:

req: {'from': '4', 'id': 666, 'method': 'save_map', 'params': [[1, 33800, 27850, 34900, 28700]]}
res: {'id': ##MESSAGE_ID##, 'result': ['ok']}

No-go zone:

req: {'from': '4', 'id': ##MESSAGE_ID##, 'method': 'save_map', 'params': [[0, 27000, 32000, 30750, 32000, 30750, 30250, 27000, 30250]]}
res: {'id': ##MESSAGE_ID##, 'result': ['ok']}

@JohnRev
Copy link
Author

JohnRev commented Dec 16, 2018

Thanks for sharing these, @FeatureExpert!!
The params of software barrier and no-go zones seem like coordinates?
Software barrier takes a vector of [id, x1,y1,x2,y2]
And no-go zone takes [id, x1,y1,x2,y2,x3,y3,x4,y4], which are the corners of the zone rectangle?
Edit: see @JensBuchta's comment. The first parameter appears to be a type: 0 = zone, 1 = barrier

@dugite-code
Copy link

It looks like these features are yet to be ported to the Gen 1 Firmware. But given the similarities I would hope to see it soon

rytilahti added a commit to rytilahti/python-miio that referenced this issue Dec 17, 2018
Completely untested for now, works only on gen2 and requires a fairly
recent firmware version supporting no-go zones and barriers.

Based on information from marcelrv/XiaomiRobotVacuumProtocol#15
@FeatureExpert
Copy link

I'm not sure these numbers. Some kind of coordinates for sure, but I do not know yet how to calculate them correctly. My image with the map is 900x767, so the coordinates does not match the size. But maybe I generate map incorrectly...

@Youkier
Copy link

Youkier commented Dec 18, 2018

Hi,

This may be a stupid question but how can you get the list of the commands ?
I did not find any explanation of the robot API.

Thanks

@JohnRev
Copy link
Author

JohnRev commented Dec 18, 2018

@FeatureExpert I guess they would be like the zoned_cleanup coordinate system, where the dock is at (2500,2500) or something like that

@FeatureExpert
Copy link

You are probably right. So we can set coords as follows counting from bottom left corner and where the dock is at [25500, 25500]:

[id, barrier_start_x, barrier_start_y, barrier_end_x, barrier_end_y]

or

[id, zone_top_left_x, zone_top_left_y, zone_top_right_x, zone_top_right_y, zone_bottom_right_x, zone_bottom_right_y, zone_bottom_left_x, zone_bottom_left_y]

or even barrier and no-go zone in one command:

[[id, barrier_start_x, barrier_start_y, barrier_end_x, barrier_end_y], [id, zone_top_left_x, zone_top_left_y, zone_top_right_x, zone_top_right_y, zone_bottom_right_x, zone_bottom_right_y, zone_bottom_left_x, zone_bottom_left_y]]

@JensBuchta
Copy link

Seems the first argument of the array is not an id, but rather a type: 0 = zone, 1 = barrier.
I can create multiple zones with 0, one zone 0, next zone 1 didn't work. Tested with FW 1633.

@JohnRev
Copy link
Author

JohnRev commented Dec 20, 2018

@JensBuchta nice find!

rytilahti added a commit to rytilahti/python-miio that referenced this issue Feb 2, 2019
Completely untested for now, works only on gen2 and requires a fairly
recent firmware version supporting no-go zones and barriers.

Based on information from marcelrv/XiaomiRobotVacuumProtocol#15
rytilahti added a commit to rytilahti/python-miio that referenced this issue Feb 2, 2019
* Add some map editing commands

Completely untested for now, works only on gen2 and requires a fairly
recent firmware version supporting no-go zones and barriers.

Based on information from marcelrv/XiaomiRobotVacuumProtocol#15

* Add parameters to no-go zone, fix type handling
@usbdem
Copy link

usbdem commented Feb 15, 2019

You are probably right. So we can set coords as follows counting from bottom left corner and where the dock is at [25500, 25500]:

[id, barrier_start_x, barrier_start_y, barrier_end_x, barrier_end_y]

or

[id, zone_top_left_x, zone_top_left_y, zone_top_right_x, zone_top_right_y, zone_bottom_right_x, zone_bottom_right_y, zone_bottom_left_x, zone_bottom_left_y]

or even barrier and no-go zone in one command:

[[id, barrier_start_x, barrier_start_y, barrier_end_x, barrier_end_y], [id, zone_top_left_x, zone_top_left_y, zone_top_right_x, zone_top_right_y, zone_bottom_right_x, zone_bottom_right_y, zone_bottom_left_x, zone_bottom_left_y]]

sorry for my stupid question : how are no-go zones and barriers removed or how can i see these zones or barriers ?

@cryptomilk
Copy link

cryptomilk commented Apr 7, 2019

Calling get_persistent_map_v1 triggers a map upload. However I'm not sure what the param does. With the new Valetudo which supports map uploading, I've added a log message and it uploads a map each time I call it.

@cryptomilk
Copy link

It looks like it is a slot, it seems you can switch between 0 and 1.

 asn  (e) venv  ~  workspace  rockrobo  miio  mirobo raw-command get_persist_map_v1 1
Sending cmd get_persist_map_v1 with params 1
['retry']
 asn  (e) venv  ~  workspace  rockrobo  miio  mirobo raw-command get_persist_map_v1 0
Sending cmd get_persist_map_v1 with params 0
['map_upload_handler']
 asn  (e) venv  ~  workspace  rockrobo  miio  mirobo raw-command get_persist_map_v1 0
Sending cmd get_persist_map_v1 with params 0
['retry']
 asn  (e) venv  ~  workspace  rockrobo  miio  mirobo raw-command get_persist_map_v1 1
Sending cmd get_persist_map_v1 with params 1
['map_upload_handler']

@cryptomilk
Copy link

cryptomilk commented Apr 7, 2019

get_persist_map_v1 only works after save_map. If you do a reset_map it doesn't work anmyore.

@Hypfer
Copy link
Contributor

Hypfer commented Apr 8, 2019

So how do you remove virtual walls and no-go zones?

@Thyraz
Copy link

Thyraz commented May 20, 2019

Any news on this, did someone figure out how to delete virtual walls or no-go zones,
or how to reset all virtual walls + all no go-zones with some kind of reset (without loosing the peristant map)?

Maybe the original app doesn't delete single entities, but resets all and re-builds the other ones.

@FeatureExpert
Copy link

If you want to remove all walls and zones:

{'from': '4', 'id': 666, 'method': 'save_map', 'params': []}

@cryptomilk
Copy link

If you want to remove one part, you parse the current map file, remove the part you don't want and call save_map with the params you want.

@Shurov
Copy link

Shurov commented Nov 14, 2023

Can we somehow edit map background in a user friendly way?
What I mean is... e,g, when robot scans near a mirror - there are beams drawn on a map that go outside the room\house
image
(the screen taken from Valetudo, but it shouldn't matter).
I'd like to clean up the map for it to look nicer.
I have map json file downloaded, but it's 700kb of text\numbers, so really hard to track each point's coordinates. Thus some app/UI would be nice.

@marcelrv
Copy link
Owner

This is nothing you can simply set in the request, nor is there an obvious way to avoid it.
The Xiaomi cloud offers a basic bitmap with the colors including the reflections you see.

Besides that it offers the location of the various objects & tracks etc.

You might be able to create a client that does some smart things to the bitmap, to determine if it is part of a larger(largest) cloud of pixels or something, but that would be totally client dependent.

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

No branches or pull requests