NickWaterton / Roomba980-Python

Python program and library to control iRobot Roomba 980 Vacuum Cleaner
MIT License
371 stars 103 forks source link

Map does not contain the full floor #32

Closed fpellicciotti closed 6 years ago

fpellicciotti commented 6 years ago

Hi,

If you have a large floor, the mapping will bot be able to fully map the floor. You will see the irobot icon reach the edge of the "image" and disappear.

The final output of the floor shows that it is missing the top portion of the floor (in my case, missing 2 rooms).

It would be nice the mapping to scale, either dynamically, or set it via a variable, so that the entire floor is displayed.

mapf90dw4ls

NickWaterton commented 6 years ago

The mapping scale is set by a variable. What command line are you using to start the program?

The size of the map is controlled by the -s option:

  -s MAPSIZE, --mapSize MAPSIZE
                        Map Size, Dock offset and skew for the map. (800,1500)
                        is the size, (0,0) is the dock location, in the center
                        of the map, 0 is the rotation of the map, 0 is the
                        rotation of the roomba. use single quotes around the
                        string. (default: '(800,1500,0,0,0,0)')

The size of the map (scale) is controlled by the 800,1500 in the above example - so to make the map higher (to include more rooms) change it to 800,2000. You have to experiment with these numbers to get them to fit your particular layout.

Or is this not what you mean?

fpellicciotti commented 6 years ago

Hi

Yes, I’ve tried that. I have it set to 800 x 2200 and there is no difference. It just stretches out the rooms, so my entire floor is stretched out but will not map more rooms.

Sent from my iPhone.

On Apr 11, 2018, 4:32 PM -0400, Nick Waterton notifications@github.com, wrote:

The mapping scale is set by a variable. What command line are you using to start the program? The size of the map is controlled by the -s option: -s MAPSIZE, --mapSize MAPSIZE Map Size, Dock offset and skew for the map. (800,1500) is the size, (0,0) is the dock location, in the center of the map, 0 is the rotation of the map, 0 is the rotation of the roomba. use single quotes around the string. (default: '(800,1500,0,0,0,0)') The size of the map (scale) is controlled by the 800,1500 in the above example - so to make the map higher (to include more rooms) change it to 800,2000. You have to experiment with these numbers to get them to fit your particular layout. Or is this not what you mean? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

NickWaterton commented 6 years ago

How are you looking at the map? via the web page, or directly to the png file?

Can you give me the command line you use?

The size setting doesn't "stretch" the image - it actually makes the map bigger, so there is more space for the roomba to roam. The size is pixels, ie 800 by 2200 pixels is bigger than 800 by 1500 pixels.

Do you use OpenCV? or is this just using PIL? Can you send me an actual 800x2200 .png file and an 800x1500.png file so that I can see where it is going wrong? it's called map.png.

fpellicciotti commented 6 years ago

I no longer have the 2200 one, however, I have the 1500 and the 1600. As you can see from both, they are "stretched"

Also, I am using PIL.

I am looking at the map via web and also at the png file, they show the same thing.

mapf90dw4ls map

The command that I use, is the following: roomba -R ip -u user -w Password -b brooker -U roomba -P roomba -l /var/www/html/roomba.log -M /var/www/html/ -I /var/www/html/icons/ -s ‘(800,1800,-180,-550,90,180)’

I;ve been messing around with the sizes, all the way to 2200, and it gives me the same thing. You can test this our pretty quickly as when you start the Roomba, and it starts to draw the map, you can see the actual Roomba icon being an oval, and not round.

NickWaterton commented 6 years ago

I'll check it out, maybe it's something to do with the PIL code, as I use OpenCV (so the PIL code doesn't get the same testing).

NickWaterton commented 6 years ago

Can you give me the version you are using? maybe the output of the first lines of the log (the ones that give the versions of everything) because I just tried it with openCV disabled, and it doesn't do what you describe, the map size changes as it's supposed to (on my set up).

So there must be something different about your configuration.

NickWaterton commented 6 years ago

OK something is odd. I have tested this out on my Ubuntu 14.04 system, and it works just as expected. I then spun up an Ubuntu 16.04 VM, and installed from scratch - and it does what you are getting - ie the map.png is distorted.

I compared the code, and it is identical on both machines. I will try spinning up an Ubuntu 14.04 VM to see if it's something that I have configured on my machine that I have missed.

What is your environment?

NickWaterton commented 6 years ago

I just tried 14.04 (clean install) and it works fine without openCV, went back to 16.04 - and now that works fine as well.

Your maps are not supposed to look like what you have, there is something wrong with your set up (probably PIL) - I would try removing pillow and reinstalling it with the latest - see if that helps.

fpellicciotti commented 6 years ago

Very weird.

I’ve reinstalled this many times and gives me the same thing. I even switched to Debian, which works better, but I was still getting the stretched maps.

Which version of PIL are you using?

Sent from my iPhone.

On Apr 12, 2018, 11:16 AM -0400, Nick Waterton notifications@github.com, wrote:

I just tried 14.04 (clean install) and it works fine without openCV, went back to 16.04 - and now that works fine as well. Your maps are not supposed to look like what you have, there is something wrong with your set up (probably PIL) - I would try removing pillow and reinstalling it with the latest - see if that helps. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

fpellicciotti commented 6 years ago

I will try to reinstall everything tonight and get back to you.

Thanks.

Sent from my iPhone.

On Apr 12, 2018, 11:16 AM -0400, Nick Waterton notifications@github.com, wrote:

I just tried 14.04 (clean install) and it works fine without openCV, went back to 16.04 - and now that works fine as well. Your maps are not supposed to look like what you have, there is something wrong with your set up (probably PIL) - I would try removing pillow and reinstalling it with the latest - see if that helps. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

fpellicciotti commented 6 years ago

Last thing, the command that I have, is that ok or should it be different?

Sent from my iPhone.

On Apr 12, 2018, 11:16 AM -0400, Nick Waterton notifications@github.com, wrote:

I just tried 14.04 (clean install) and it works fine without openCV, went back to 16.04 - and now that works fine as well. Your maps are not supposed to look like what you have, there is something wrong with your set up (probably PIL) - I would try removing pillow and reinstalling it with the latest - see if that helps. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

NickWaterton commented 6 years ago

Currently 5.1.0 but it works with V 4 as well. Don't understand why I got your issue with the clean 16.04 install at first - but then didn't when I went back to it. Maybe I'll try that again...

NickWaterton commented 6 years ago

It should be fine, it's what I used (except I use roomba_direct.py) not roomba.

Maybe I should start a development branch with my code, I don't use the branch on github as it got updated with all sorts of stuff that I'm not using...

NickWaterton commented 6 years ago

OK, Found something. I was wrong about the command line. You used ‘(800,1800,-180,-550,90,180)’ and this is the problem. if you use ‘(800,1800,-180,-550,0,180)’ it works just fine. I had accidentally changed to using my values at some point - not yours!

So the difference is using 90 or 0 (in my case I use -3). So there is a bug here somewhere in the map rotation variable. I'll track it down.

NickWaterton commented 6 years ago

OK, found it. Line 1244 in 'roomba.py', expand should be False. I haven't tested extensively, but I checked with my development version, and this change was already made (so maybe I found it and fixed it in the dev version a while back).

You may have to switch your x and y values over on the command line (as it rotates the map within the rectangle defined by x and y).

I have pushed the fix to github, try downloading it again, and see what happens, or just leave rotation at 0 if you want the map up and down the screen.

Let me know if this resolves it, and what you have to use for the command line, or if I've screwed something else up by doing this...

fpellicciotti commented 6 years ago

Thank you for the quick response. I’ll test it out tonight and get back to you tomorrow morning.

Thanks again.

Sent from my iPhone.

On Apr 12, 2018, 1:29 PM -0400, Nick Waterton notifications@github.com, wrote:

OK, found it. Line 1244 in 'roomba.py', expand should be False. I haven't tested extensively, but I checked with my development version, and this change was already made (so maybe I found it and fixed it in the dev version a while back). You may have to switch your x and y values over on the command line (as it rotates the map within the rectangle defined by x and y). I have pushed the fix to github, try downloading it again, and see what happens, or just leave rotation at 0 if you want the map up and down the screen. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

NickWaterton commented 6 years ago

I have done some more testing, what was happening is that your x was 800, y 1800, but you had rotation set to 90, so it rotated the 800x1800 image 90 degrees (so it's now 1800x800), then tried to fit it in an 800x1800 box - so it ends up squashed horizontally, and expanded vertically.

I've taken the resizing out, and moved the rotation to later in the program. So you should use the same size as previously, the 90 degree rotation is applied after everything else (except text).

The idea behind the resizing was to avoid cropping on small rotations (ie -3), but I think leaving the resizing out makes more sense. What will happen now is that the image will get larger to fit whatever rotation you have selected - so if you set the size as 800x1800, but rotate by 90, the final image will be 1800x800, but if the rotation is say 45 degrees, then the image will get bigger to fit (so the actual image will look smaller).

Hope this all makes sense. Let me know if it works.

fpellicciotti commented 6 years ago

Hi.

I’ve tried it multiple times and even reinstall the OS, unfortunately I still get the same thing. I do need to rotate it by 180 so that it maps my place from top to down. If I do not rotate it it goes from right to left but the width is too small to fit my the space.

I guess there is something in my config, I will keep messing around with it.

I’ve attached to screen shots of the mapping in action and you can see that the map is stretched out.

Sent from my iPhone.

On Apr 12, 2018, 5:02 PM -0400, Nick Waterton notifications@github.com, wrote:

I have done some more testing, what was happening is that your x was 800, y 1800, but you had rotation set to 90, so it rotated the 800x1800 image 90 degrees (so it's now 1800x800), then tried to fit it in an 800x1800 box - so it ends up squashed horizontally, and expanded vertically. I've taken the resizing out, and moved the rotation to later in the program. So you should use the same size as previously, the 90 degree rotation is applied after everything else (except text). The idea behind the resizing was to avoid cropping on small rotations (ie -3), but I think leaving the resizing out makes more sense. What will happen now is that the image will get larger to fit whatever rotation you have selected - so if you set the size as 800x1800, but rotate by 90, the final image will be 1800x800, but if the rotation is say 45 degrees, then the image will get bigger to fit (so the actual image will look smaller). Hope this all makes sense. Let me know if it works. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

fpellicciotti commented 6 years ago

I think I found the issue. I am unable to re-download the updates.

I've used: pip install git+https://github.com/NickWaterton/Roomba980-Python.git to install.. How do I force a re-download and re-install to get the lastest updates?