NickWaterton / Roomba980-Python

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

enable_map on hassio #67

Open ddppddpp opened 4 years ago

ddppddpp commented 4 years ago

Hi Nick, Thanks for your wonderful work! Trying to get Roomba980-Python generate a cleaning map for my 980 but currently stuck on an error, can you please help with troubleshooting? Here's what I'm doing in my script:

roomba = Roomba( address=host, blid=xxx, password=xxx, cert_name=xxx, continuous=xxx) roomba.enable_map( enable=True, mapSize="(800,1650,-300,-50,2,0)", enableMapWithText=False, roomOutline=False, mapPath="/www/map/", iconPath="/www/res" )`

I get the following error:

TypeError: enable_map() got an unexpected keyword argument 'enableMapWithText'

If I try to comment out the enableMapWithText line I get other errors related to missing freetype support in Pillow which will be more difficult to fix on this platform. Can you suggest how to call enable_map correctly? Thanks in advance!

NickWaterton commented 4 years ago

This is the enable_map definition

    def enable_map(self, enable=False, mapSize="(800,1500,0,0,0,0)",
                   mapPath=".", iconPath = "./", roomOutline=True,
                   enableMapWithText=True,
                   fillColor="lawngreen", 
                   outlineColor=(64,64,64,255),
                   outlineWidth=1,
                   home_icon_file="home.png",
                   roomba_icon_file="roomba.png",
                   roomba_error_file="roombaerror.png",
                   roomba_cancelled_file="roombacancelled.png",
                   roomba_battery_file="roomba-charge.png",
                   bin_full_file="binfull.png",
                   roomba_size=(50,50), draw_edges = 30, auto_rotate=True):

so enableMapWithText should work, what version of Python are you using? can you post the full output? and your full program?

Ok, looked into it further. You must have an old version of roomba.py installed. The latest is V1.2.6 earlier versions did not have the option enableMapWithText in enable_map which is why you are getting this error. I can see V1.2.1 does not have it, but I'm not sure when it was introduced.

What version do you have? (at the top of roomba.py or print(roomba.__version__)) where are you importing it from? how did you install it? (PyPi does not have the latest version, you are better off installing it from github).

ddppddpp commented 4 years ago

I'm using the following to import your package into a docker container REQUIREMENTS = ['https://github.com//NickWaterton/Roomba980-Python/zipball/master#roomba==1.2.6'] so I guess it should be the latest version. Yet I just tried changing this back to i.e 1.2.3 but the error persisted.

Edit: I just tried

bash-5.0# /usr/local/bin/roomba --version `

and got 1.2.1 so I'm obviously doing something wrong here...

ddppddpp commented 4 years ago

Hello, trying to troubleshoot further... Starting with a new container (Alpine based) I did the following:

apk add nodejs nodejs-npm apk add python3 git clone http://github.com/NickWaterton/Roomba980-Python.git pip3 install paho-mqtt apk update apk add make automake gcc g++ subversion python3-dev pip3 install numpy #this takes ages on rpi3, ~8h apk add zlib apk add build-base python-dev py-pip jpeg-dev zlib-dev LIBRARY_PATH=/lib:/usr/lib pip3 install pillow pip3 install six`

then tried to run complicated.py and got this output:

MAP: map no text image problem: [Errno 2] No such file or directory: './/map_notext.png': set to None Traceback (most recent call last): File "complicated.py", line 74, in myroomba.enable_map(enable=True, mapSize="(800,1650,-300,-50,2,0)", mapPath="./", iconPath="./") #enable live maps, class default is no maps File "/root/Roomba980-Python/roomba/roomba.py", line 535, in enable_map self.initialise_map(roomba_size) File "/root/Roomba980-Python/roomba/roomba.py", line 935, in initialise_map self.fnt = ImageFont.truetype('FreeMono.ttf', 40) File "/usr/lib/python3.7/site-packages/PIL/ImageFont.py", line 640, in truetype return freetype(font) File "/usr/lib/python3.7/site-packages/PIL/ImageFont.py", line 637, in freetype return FreeTypeFont(font, size, index, encoding, layout_engine) File "/usr/lib/python3.7/site-packages/PIL/ImageFont.py", line 161, in init if core.HAVE_RAQM: File "/usr/lib/python3.7/site-packages/PIL/ImageFont.py", line 41, in getattr raise ImportError("The _imagingft C module is not installed") ImportError: The _imagingft C module is not installed`

Any idea how to continue?

ddppddpp commented 4 years ago

finally was able to draw a map by adding

apk add freetype-dev `

before installing pillow. So the environment supports the usage of enable_map, sort of.. now need to focus on the original error I was getting.