ecovacs-deebot.js icon indicating copy to clipboard operation
ecovacs-deebot.js copied to clipboard

Include live map support

Open boriswerner opened this issue 5 years ago • 15 comments

In a bumper issue (https://github.com/wpietri/sucks/issues/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

boriswerner avatar Feb 21 '20 17:02 boriswerner

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

did you get somewhere by decripting the map?

Thank you

And3rsL avatar Mar 30 '20 13:03 And3rsL

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 avatar Mar 30 '20 14:03 boriswerner

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 avatar Apr 21 '20 09:04 boriswerner

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)

boriswerner avatar May 11 '20 12:05 boriswerner

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

rebel1985 avatar Jun 07 '20 11:06 rebel1985

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 ...

  • https://www.roboter-forum.com/index.php?thread/40009-reinigungsprotokoll-wird-nicht-gespeichert/
  • https://github.com/mrbungle64/ioBroker.ecovacs-deebot/issues/69

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

mrbungle64 avatar Jun 07 '20 12:06 mrbungle64

erstellt. https://github.com/mrbungle64/ioBroker.ecovacs-deebot/issues/76

rebel1985 avatar Jun 09 '20 05:06 rebel1985

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.

Devirex avatar Jan 10 '22 16:01 Devirex

@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.

mrbungle64 avatar Jan 10 '22 16:01 mrbungle64

@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.

Devirex avatar Jan 10 '22 23:01 Devirex

@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 :)

mrbungle64 avatar Jan 11 '22 22:01 mrbungle64

Hi, I have a problem on my robot, it loosing the map or the position one time per week .. am testing your script and i want to found a solution .. So to restore a Maps it's possible but the position of robot and the charging station is moved and am trying to set it manually. It's possible to do that ? i think is ChargePosition and DeebotPosition that have to be fixed .. any idea ?

This problem is present in many robots and this future could be very interesting !

Thanks.

matrix1233 avatar Dec 09 '22 22:12 matrix1233

@matrix1233

Hi, I have a problem on my robot, it loosing the map or the position one time per week .. am testing your script and i want to found a solution ..

This is a library. What script do you mean?

So to restore a Maps it's possible but the position of robot and the charging station is moved and am trying to set it manually.

It is not possible to correct or set the position of the robot or the charging station

It's possible to do that ? i think is ChargePosition and DeebotPosition that have to be fixed .. any idea ?

This problem is present in many robots and this future could be very interesting !

What exactly do you mean by that?

Thanks.

mrbungle64 avatar Dec 10 '22 08:12 mrbungle64

HI,

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

matrix1233 avatar Dec 10 '22 09:12 matrix1233

@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

mrbungle64 avatar Dec 11 '22 09:12 mrbungle64