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

Include live map support #10

Open
boriswerner opened this issue Feb 21, 2020 · 15 comments
Open

Include live map support #10

boriswerner opened this issue Feb 21, 2020 · 15 comments
Labels
Enhancement New feature or request Pinned Pinned issue

Comments

@boriswerner
Copy link
Collaborator

In a bumper issue (wpietri/sucks#78) there are details on the Map messages included:

Using the right base64 text, which in turn produces a well-formed lzma compressed stream, I understood that the map piece binary data is a list of pixels encoded as following:
0x00 is used for empty (undiscovered) pixels
0x01 is used for floor pixels
0x02 is used for wall pixels

Following the python script described there to decode that stream

        # Decode Base64
        data = base64.b64decode(b64)
        
        # Get lzma output size (as done by the Android app)
        len_array = data[5:5+4]
        len_value = ((len_array[0] & 0xFF) | (len_array[1] << 8 & 0xFF00) | (len_array[2] << 16 & 0xFF0000) | (len_array[3] << 24 & 0xFF000000)) 
        
        # Init the LZMA decompressor using the lzma header
        dec = lzma.LZMADecompressor(lzma.FORMAT_RAW, None, [lzma._decode_filter_properties(lzma.FILTER_LZMA1, data[0:5])])
        
        # Decompress the lzma stream to get raw data
        return dec.decompress(data[9:], len_value)

During cleaning the Ozmo 950 sends continuosly infos about the maps that could be processed and drawn.
I will do some more analysis on the topic.

Maybe also parts of the project valetudo-mapper for Xiaomi/Roborock vacs (https://github.com/rand256/valetudo-mapper) can be reused/transferred

@mrbungle64 mrbungle64 added the Enhancement New feature or request label Feb 21, 2020
@And3rsL
Copy link

And3rsL commented Mar 30, 2020

Hi, im currently working on python port:
https://github.com/And3rsL/Deebotozmo

did you get somewhere by decripting the map?

Thank you

@boriswerner
Copy link
Collaborator Author

boriswerner commented Mar 30, 2020

Hi @And3rsL I know your work and got some inspirations already from there ;-)
Thanks for that.
@mrbungle64 was doing some tests on th elive map but both of us were not yet able to translate correctly to coordinates with JavaScript. Currently we are doing some other stuff (basic map info, available maps and spotAreas as you also started in you last commits, see https://github.com/boriswerner/ecovacs-deebot.js for current dev status, will make a pull request into this repository quite soon) as the live map is a bit more challenging (also with regards to performance) and were trying to support all Models (I am only able to support on 950 though).
There is some more detailed description on the map (for the 930 but it works the same for 950):
https://gitlab.com/michael.becker/vacuumclean/-/blob/master/deebot/deebot-core/README.md#map-details
Would be great to share more knowledge in the future. I have gathered quite some documentation, though it is a bit messy currently :-) Just saw that you also implemented the cleanlogs. Thats also on my list although it is not working currently from the app correctly.

@boriswerner
Copy link
Collaborator Author

In the lzma header the length parameter is not correct (lzma format: https://svn.python.org/projects/external/xz-5.0.3/doc/lzma-file-format.txt)
The header needs to be 13 bytes instead of the 9 bytes provided from the API.

The standard node lzma library is not able to decompress without the extra 4 bytes.

Test code to add the bytes and decompress (has to be done in a better way for production use):

const lzma = require('lzma')
let checksum = 537589243;
let p = 'XQAABAAQJwAAAADtfIoOzcCGcQuYi55lkrSZYegaS6yqxcc19OkMqcx8KM9pPfh9ysMpAtA7mwHMiFuCFlBaMqAbPkW9w9K4iRdx9xQq6TUMqHFMlZmmK3uobRIEk2hmiiEp4DoF9fU6hjixxlO2q9BFULeauPnLFQcXt1OefQ4i+ELWYZgvUuB4Z/h0aS6j+b+L5Dt+acPEcP6qZnIY/RYmPRvT+0CnFLyw+bcBME2z6ZKM5hH1R8K8Dgv8EzfZeOO62reIz/QQSKTJLmGYYA3Bs8JpNRmwoPyA+w2OnYyd5ySpiRCjx+TAn1C7mWEhCR4JWKsHEKTbSLd47veQFnt2umKLm+UaRFM0si7jIVBng9gKUIQsACDalCOgwGUbkef5kBBddPKz3FEBNCINvcEw+28srcV466GTB4ufRR4aHdhL4pKe47fTNDGF0EGsV4WL0k0bynQ89b20EpP3prjvNzXrkQ2sQOMf4GyYoQ4FE79F4yBPHfv6Bks2VmLbDKsu2Bf9SHnlYhj2IvX93jLHJlvMBa9aYl6mXXsUf5+o+LsEJcBGXVu0o6uNyNi6ZYjPpejvxrDPq1c3LpHMwUImU8HStbl13XMQ1VBBaagFxaafpkxVeLcUAssleIxwF9Akh8ypozEeCq0r2ETBbdKxmN7T0clmNuHtlxcQ/jj/KbLP6ONnc5cw';
let buff = Buffer.from(p, 'base64');
const int8Array = new Int8Array(buff.buffer, buff.byteOffset, buff.length);

let correctedArray = [];
for (let ind in int8Array) { //add missing 4 bytes of length
    if (ind ==8) {
        correctedArray.push(0);
        correctedArray.push(0);
        correctedArray.push(0);
        correctedArray.push(0);
        
    }
    correctedArray.push(int8Array[ind]);
}

console.log(lzma.decompress(correctedArray));

results in the correct numbers:

[
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 2,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0,
  ... 9900 more items
]

where
0 represents no data
1 represents floor
2 represents a wall
3 represents carpet

The following lib could be used instead (also check performance benchmark in the README for alternatives):
https://github.com/jcmellado/js-lzma

@boriswerner
Copy link
Collaborator Author

Feature suggestion: customize coloring and vac icon similar to mihome-vacuum:
https://github.com/iobroker-community-adapters/ioBroker.mihome-vacuum/blob/master/README.md#map-config)

@rebel1985
Copy link

die karte der letzten reinigung wird nicht aktuel im adapter 1.0.0 angezeigt, es ist bei mir eine alte karte. ich habe den deebot ozmo 900 , meinen tuhe ich den eintrag unter objekte, ecovacs-deebot.0.cleaninglog.lastCleaningMapImageURL

@mrbungle64
Copy link
Owner

die karte der letzten reinigung wird nicht aktuel im adapter 1.0.0 angezeigt, es ist bei mir eine alte karte. ich habe den deebot ozmo 900 , meinen tuhe ich den eintrag unter objekte, ecovacs-deebot.0.cleaninglog.lastCleaningMapImageURL

Hallo @rebel1985

in diesem Issue hier geht es um die Live Map Unterstüzung (nicht die Map vom Reinigungsprotokoll) in der Library (nicht vom ioBroker Adapter).

Kannst Du dafür bitte einen Issue im Repository vom Adapter erstellen ? :)

Im Endeffekt ist es aber bereits bekannt, dass Ecovacs schon länger Probleme mit den Reinigungsprotokollen hat ...

Es wird also eher nicht an der Library oder dem ioBroker Adapter liegen.

@rebel1985
Copy link

erstellt.
mrbungle64/ioBroker.ecovacs-deebot#76

@mrbungle64 mrbungle64 added the Pinned Pinned issue label Feb 21, 2021
@Devirex
Copy link

Devirex commented Jan 10, 2022

Hi, quick question, is this issue still under devlepment? Or is it already working for ioBroker?
I'm using FHEM and I'm aware of And3rsL python port which is working quite well but without livemap support.

@mrbungle64
Copy link
Owner

@Devirex

Hi, quick question, is this issue still under devlepment?

Currently no one is working on live map functionality, but there is already a function to create a map image.

Or is it already working for ioBroker?

In the ioBroker adapter there's also a function for loading the current map image. But this is also not a live map functionality.

@Devirex
Copy link

Devirex commented Jan 10, 2022

@mrbungle64

Currently no one is working on live map functionality, but there is already a function to create a map image.

Thank you so much for your fast reply. Are there any technical showstoppers/big difficulties or is it just not that high in priority?
Just trying to understand if i as a hobby coder would be able to help somehow.

@mrbungle64
Copy link
Owner

@Devirex

@mrbungle64

Currently no one is working on live map functionality, but there is already a function to create a map image.

Thank you so much for your fast reply. Are there any technical showstoppers/big difficulties or is it just not that high in priority? Just trying to understand if i as a hobby coder would be able to help somehow.

Mainly because it's not a priority. But you are welcome to contribute :)

@matrix1233

This comment was marked as off-topic.

@mrbungle64

This comment was marked as off-topic.

@matrix1233

This comment was marked as off-topic.

@mrbungle64
Copy link
Owner

@matrix1233

sorry fi my bad english i means library . I am simply looking for a triks or little hacks to correct the loss of the position of the station and the robot via the commands existing in the library because the default application of ecovacs does not do it. Thanks

As far as I understand, you are looking for a hack that corrects the position of the robot and the charging station in the map that the bot creates. I'm pretty sure that this is not possible.
I think your only option is to contact the official support.

Btw.: Your question is not related to this issue or topic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Pinned Pinned issue
Projects
None yet
Development

No branches or pull requests

6 participants