Roomba980-Python
所属分类:工具库
开发工具:Python
文件大小:0KB
下载次数:0
上传日期:2023-01-12 15:45:47
上 传 者:
sh-1993
说明: Python程序和库,用于控制iRobot Roomba 980真空吸尘器,
(Python program and library to control iRobot Roomba 980 Vacuum Cleaner,)
文件列表:
LICENSE (1069, 2023-10-30)
MANIFEST.in (54, 2023-10-30)
examples/ (0, 2023-10-30)
examples/complicated.py (1702, 2023-10-30)
examples/example_start_roomba (478, 2023-10-30)
examples/simple.py (1140, 2023-10-30)
openhab/ (0, 2023-10-30)
openhab/html/ (0, 2023-10-30)
openhab/html/roomba_map.html (739, 2023-10-30)
openhab/html/style.css (157, 2023-10-30)
openhab/icons/ (0, 2023-10-30)
openhab/icons/angle.png (1036, 2023-10-30)
openhab/icons/angle.svg (1286, 2023-10-30)
openhab/icons/map.png (2136, 2023-10-30)
openhab/icons/map.svg (1711, 2023-10-30)
openhab/icons/msg.png (1744, 2023-10-30)
openhab/icons/msg.svg (2201, 2023-10-30)
openhab/icons/number.png (611, 2023-10-30)
openhab/icons/number.svg (1657, 2023-10-30)
openhab/icons/roomba-charge.png (1500, 2023-10-30)
openhab/icons/roomba-dock.png (1500, 2023-10-30)
openhab/icons/roomba-drop.png (1548, 2023-10-30)
openhab/icons/roomba-eco.png (1529, 2023-10-30)
openhab/icons/roomba-error.png (1523, 2023-10-30)
openhab/icons/roomba-old.png (1982, 2023-10-30)
openhab/icons/roomba-pause.png (1579, 2023-10-30)
openhab/icons/roomba-resume.png (1543, 2023-10-30)
openhab/icons/roomba-run.png (1543, 2023-10-30)
openhab/icons/roomba-start.png (1543, 2023-10-30)
openhab/icons/roomba-stop.png (1510, 2023-10-30)
openhab/icons/roomba-wifi.png (1565, 2023-10-30)
openhab/icons/roomba.png (1510, 2023-10-30)
openhab/icons/roombaerror-off.png (1510, 2023-10-30)
openhab/icons/roombaerror-on.png (1523, 2023-10-30)
openhab/icons/roombaerror.png (1510, 2023-10-30)
openhab/icons/select.png (1979, 2023-10-30)
openhab/icons/select.svg (28536, 2023-10-30)
openhab/icons/trashpresent.png (1588, 2023-10-30)
... ...
Roomba980-Python
================
Unofficial iRobot Roomba python library (SDK).
Thanks to https://github.com/koalazak/dorita980 where much of the inner workings were derived from.
Thanks to Matthew Garrett for figuring out how to get passwords from iRobots aws cloud.
**NEW V2.0c 16/3/2021** All new re-write.
**NEW 9/12/2021** Updated password.py can now get passwords for robots from the cloud
**NOTE: This is an BETA Release - it may have bugs in it - please report them to me**
**NOTE: With the latest release of firmware (3.20.7) Robots are no longer reporting tracking information, therefore realtime maps will not work**
## New Features
* Now re-written as asyncio application
* Only Python 3.6 and above are supported
* supports 600, 900, i, and s series Roombas (all WiFi connected roombas)
* Supports M6 Mop
* new support for all configurations in config file (*config.ini* default)
* better blid and password discovery, supports multiple robots discovery/config
* Supports Multiple Roombas or Mops, any combination
* supports self emptying base
* New web interface for experimenting with real-time mapping
* support V2.XX and 3.XX firmware
* Supports Floor Plans for overlay on map
* Can now get passwords from the cloud
## Important!
Only local connections are supported. The project was written to allow Openhab2 control, so if you integrate Roomba into Openhab2, you can control it from anywhere.
As only **one connection at at time is** allowed to the Roomba local mqtt server, when the library is connected to your Roomba, the app will connect via the cloud.
Tested with Python 3.6/Ubuntu 18.04
* Python 3.6 or above is required
* Python 2.x is not supported, please use the old version of Roomba980 for Python 2.7 compatibility
* I have not tested on Windows, or anything othe than Ubuntu 18.04. use at your own risk on any other platform/OS
* PyPi install is not supported (yet) The version on PyPi is the 1.x version!
## Features
* Get your username/password easily (for multiple robots)
* Auto discovery robot IP (optional)
* Local API control
* Remote API control (via your MQTT broker)
* remote API control via REST interface (with web interface enabled)
* Ability to send command to clean specific rooms (zones)
* Json supported as command (so you can make your own commands)
* **NOT Firmware 1.6.x compatible.**
* Firmware 2.x.x/3.x.x compatible.
* Multiple Roombas/Mops supported
* Live Maps
* Maps show locations of errors, bin full, cancelled runs
* Supports Floor Plans for overlay on map
* designed for openhab2 compatibility
* HA compatibility
* Built in Web Server for interactive control/Mapping
* Simulation mode topic for easier debugging
## Live Maps
Live tracking of Roomba location and track, updated in real time:
![iRobot Roomba cleaning map using roomba lib](https://github.com/roomba/res/map.png)
This is a comparison of the actual Roomba track (left) vs the Rooba app generated map (right):
![iRobot Roomba cleaning map comparison](https://github.com/roomba/res/side_by_side_map.png)
**NOTE:** Later Roombas only update their position every 5 seconds - they can move a long way in this time, so apparent "gaps" in the floor coverage may not be real.
### OpenCV
If you have OpenCV installed, the library will use it to render the final map (on completion/error), it uses PIL for Live Maps, so the final map looks nicer. **This uses a lot of processing power/memory**, I don't know what happens if you try this on a RPi or other limited platform!
Also, if you enable debugging mode (-D), intermediate maps (edges.png, final_map.png and so on) are drawn every time a new co-ordinate is reported (every second or so when running). This consumes a lot of resources **You have been warned!**.
### PIL
Please use the latest version of pillow (V 4.1.1 at least), there are some nasty memory leaks in text processing in earlier versions that will quickly use up all your RAM and make the program unresponsive.
The library will issue a warning if it detects an earlier version of PIL.
If you do not have PIL installed, the system will not draw maps (even if enabled), even if you have OpenCV. PIL is used for basic image manipulations. If you do not specifically enable maps, no maps will be drawn. `roomba.py` uses maps, but the class default is to disable maps, so in your own scripts, if you want maps, you have to enable them (after creating the object).
## Dependencies
The following libraries/modules are used. Some are optional:
* paho-mqtt *optional*
* PIL/pillow *optional*
* openCV *optional*
* numpy *optional (used by openCV)*
* aiohttp *optional (used for optional web server)*
* requests *optinal (used for cloud passwords)*
This script/library is intended to forward roomba data/commands to/from a local MQTT server (this is optional though). In this case, you need paho-mqtt installed
```bash
pip install paho-mqtt
```
If you want the REST interface, or the built in web server, you need aiohttp installed:
```bash
pip install aiohttp
```
For map drawing, you need at least PIL installed (preferably the latest version of pillow)
```bash
pip install pillow
```
For fancy maps, you need openCV installed (V2,3,4). The installation of this can be complex, so I leave that up to you. Maps works without it, but it's nicer with it.
In all cases `pip` may be `pip3` depending on your default python configuration
## Install
First you need python 3.6 or later installed and then:
Clone this repository:
```bash
git clone https://github.com/NickWaterton/Roomba980-Python.git
cd Roomba980-Python/roomba
```
Make sure you have the dependancies listed in `Roomba980-Python/requirements.txt` installed. You can do this by running:
```bash
pip3 install -r ../requirements.txt
```
**Note:** This may be `pip3` depending on your configuration.
run `./roomba -h` (or `python3 ./roomba.py`) to get the available options. This is what you will get:
```bash
usage: roomba.py [-h] [-f CONFIGFILE] [-n ROOMBA_NAME] [-t TOPIC]
[-T BROKER_FEEDBACK] [-C BROKER_COMMAND] [-S BROKER_SETTING]
[-b BROKER] [-p PORT] [-U USER] [-P BROKER_PASSWORD]
[-R ROOMBA_IP] [-u BLID] [-w PASSWORD] [-wp WEBPORT]
[-i INDENT] [-l LOG] [-e] [-D] [-r] [-j] [-m] [-M MAPPATH]
[-sq MAX_SQFT] [-s MAPSIZE] [-fp FLOORPLAN] [-I ICONPATH]
[-o] [-x EXCLUDE] [--version]
Forward MQTT data from Roomba to local MQTT broker
optional arguments:
-h, --help show this help message and exit
-f CONFIGFILE, --configfile CONFIGFILE
config file name (default: ./config.ini)
-n ROOMBA_NAME, --roomba_name ROOMBA_NAME
optional Roomba name (default: "")
-t TOPIC, --topic TOPIC
Roomba MQTT Topic to subscribe to (can use wildcards #
and + default: #)
-T BROKER_FEEDBACK, --broker_feedback BROKER_FEEDBACK
Topic on broker to publish feedback to (default:
/roomba/feedback)
-C BROKER_COMMAND, --broker_command BROKER_COMMAND
Topic on broker to publish commands to (default:
/roomba/command)
-S BROKER_SETTING, --broker_setting BROKER_SETTING
Topic on broker to publish settings to (default:
/roomba/setting)
-b BROKER, --broker BROKER
ipaddress of MQTT broker (default: None)
-p PORT, --port PORT MQTT broker port number (default: 1883)
-U USER, --user USER MQTT broker user name (default: None)
-P BROKER_PASSWORD, --broker_password BROKER_PASSWORD
MQTT broker password (default: None)
-R ROOMBA_IP, --roomba_ip ROOMBA_IP
ipaddress of Roomba (default: 255.255.255.255)
-u BLID, --blid BLID Roomba blid (default: None)
-w PASSWORD, --password PASSWORD
Roomba password (default: None)
-wp WEBPORT, --webport WEBPORT
Optional web server port number (default: None)
-i INDENT, --indent INDENT
Default indentation=auto
-l LOG, --log LOG path/name of log file (default: ./roomba.log)
-e, --echo Echo to Console (default: True)
-D, --debug debug mode
-r, --raw Output raw data to mqtt, no decoding of json data
(default: False)
-j, --pretty_print pretty print json in logs (default: False)
-m, --drawmap Draw Roomba cleaning map (default: True)
-M MAPPATH, --mappath MAPPATH
Location to store maps to (default: .)
-sq MAX_SQFT, --max_sqft MAX_SQFT
Max Square Feet of map (default: 0)
-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)")
-fp FLOORPLAN, --floorplan FLOORPLAN
Floorplan for Map. eg
("res/first_floor.jpg",0,0,(1.0,1.0),0,
0.2)"res/first_floor.jpg" is the file name, 0,0 is the
x,y offset, (1.0, 1.0) is the (x,y) scale (or a single
number eg 1.0 for both), 0 is the rotation of the
floorplan, 0.2 is the transparencyUse single quotes
around the string. (default: None)
-I ICONPATH, --iconpath ICONPATH
location of icons. (default:
"/home/nick/Scripts/Roomba980-Python/roomba/res")
-o, --room_outline Draw room outline (default: True)
-x EXCLUDE, --exclude EXCLUDE
Exclude topics that have this in them (default: "")
--version Display version of this program
```
## quick start
With the roomba on the dock and charged (and connected to wifi), stand by the roomba and run
```bash
./roomba.py
```
or
```bash
python ./roomba.py
```
or
```bash
python3 ./roomba.py
```
Follow the instructions, the script will attempt to find the roomba, obtain the IP, blid, and password - then save these to a local configuration file (*config.ini* by default). If this works, the program will then start displaying messages from your Roomba, and printing the master_state every few seconds. the results are logged to a log file (`roomba.log` by default).
**NOTE:** You will have to press and hold the HOME button on your robot until it plays a series of tones (about 2 seconds). Release the button and your robot will flash WIFI light to discover your Roomba.
On future runs (Once successful), these values will be taken from the configuration file, so you only have to do this once. You can manually specify these on the command line, some example start up bash scripts are supplied.
You can also edit the *config.ini* file, to add options for each defined robot.
I advise you to experiment with the map size (if you are using maps), as that is the one variable that isn't totally automatic. the size, position of the dock etc depend on your house layout.
the syntax of the map layout is (map x,map y, dock x, dock y, map rotation, roomba rotation). you can use the interactive [Web Server](https://github.com#web-interface) to experiment with different settings to se what fits best.
### Example output
Logging is supported with the python standard logging module (the logger is `Roomba`)
```bash
[2021-02-05 12:42:06,718][ INFO](https://github.comRoomba ) *******************
[2021-02-05 12:42:06,719][ INFO](https://github.comRoomba ) * Program Started *
[2021-02-05 12:42:06,719][ INFO](https://github.comRoomba ) *******************
[2021-02-05 12:42:06,719][ INFO](https://github.comRoomba ) Roomba.py Version: 2.0a
[2021-02-05 12:42:06,720][ INFO](https://github.comRoomba ) Python Version: 3.6.9 (default, Oct 8 2020, 12:12:24) [GCC 8.4.0]
[2021-02-05 12:42:06,720][ INFO](https://github.comRoomba ) Paho MQTT Version: 1.5.1
[2021-02-05 12:42:06,720][ INFO](https://github.comRoomba ) CV Version: 3.2.0
[2021-02-05 12:42:06,720][ INFO](https://github.comRoomba ) PIL Version: 8.0.1
[2021-02-05 12:42:06,720][ INFO](https://github.comRoomba ) to Exit
[2021-02-05 12:42:06,721][ INFO](https://github.comRoomba ) Roomba MQTT data Interface
[2021-02-05 12:42:06,721][ INFO](https://github.comRoomba.Password ) Using Password version 2.0a
[2021-02-05 12:42:06,722][ INFO](https://github.comRoomba.Password ) reading/writing info from config file ./config.ini
[2021-02-05 12:42:06,723][ INFO](https://github.comRoomba.Password ) 3 Roombas Found
[2021-02-05 12:42:06,724][ INFO](https://github.comRoomba ) Creating Roomba object 192.168.100.181, Upstairs
[2021-02-05 12:42:06,725][ INFO](https://github.comRoomba.Password ) Using Password version 2.0a
[2021-02-05 12:42:06,949][ INFO](https://github.comRoomba.Upstairs.api ) starting api WEB Server V2.0a on port 8200
[2021-02-05 12:42:06,950][ INFO](https://github.comRoomba.Upstairs ) Posting DECODED data
[2021-02-05 12:42:06,951][ INFO](https://github.comRoomba.Upstairs ) MAP: Maps Enabled
[2021-02-05 12:42:06,953][ INFO](https://github.comRoomba ) Creating Roomba object 192.168.100.206, Downstairs
[2021-02-05 12:42:06,955][ INFO](https://github.comRoomba.Password ) Using Password version 2.0a
[2021-02-05 12:42:06,958][ INFO](https://github.comRoomba.Downstairs.api) starting api WEB Server V2.0a on port 8201
[2021-02-05 12:42:06,960][ INFO](https://github.comRoomba.Downstairs ) Posting DECODED data
[2021-02-05 12:42:06,968][ INFO](https://github.comRoomba.Downstairs ) MAP: Maps Enabled
[2021-02-05 12:42:06,973][ INFO](https://github.comRoomba ) Creating Roomba object 192.168.100.79, Mopster
[2021-02-05 12:42:06,982][ INFO](https://github.comRoomba.Password ) Using Password version 2.0a
[2021-02-05 12:42:06,994][ INFO](https://github.comRoomba.Mopster.api ) starting api WEB Server V2.0a on port 8202
[2021-02-05 12:42:06,997][ INFO](https://github.comRoomba.Mopster ) Posting DECODED data
[2021-02-05 12:42:07,002][ INFO](https://github.comRoomba.Downstairs ) subscribed to /roomba/command/Downstairs/#, /roomba/setting/Downstairs/#
[2021-02-05 12:42:07,003][ INFO](https://github.comRoomba.Mopster ) MAP: Maps Enabled
[2021-02-05 12:42:07,005][ INFO](https://github.comRoomba.Upstairs ) subscribed to /roomba/command/Upstairs/#, /roomba/setting/Upstairs/#
[2021-02-05 12:42:07,016][ INFO](https://github.comRoomba.Downstairs ) Connecting...
[2021-02-05 12:42:07,038][ INFO](https://github.comRoomba.Downstairs ) Setting TLS
[2021-02-05 12:42:07,041][ INFO](https://github.comRoomba.Mopster ) subscribed to /roomba/command/Mopster/#, /roomba/setting/Mopster/#
[2021-02-05 12:42:07,044][ INFO](https://github.comRoomba.Downstairs ) Setting TLS - OK
[2021-02-05 12:42:07,053][ INFO](https://github.comRoomba.Upstairs ) Connecting...
[2021-02-05 12:42:07,061][ INFO](https://github.comRoomba.Upstairs ) Setting TLS
[2021-02-05 12:42:07,063][ INFO](https://github.comRoomba.Upstairs ) Setting TLS - OK
[2021-02-05 12:42:07,072][ INFO](https://github.comRoomba.Mopster ) Connecting...
[2021-02-05 12:42:07,080][ INFO](https://github.comRoomba.Mopster ) Setting TLS
[2021-02-05 12:42:07,083][ INFO](https://github.comRoomba.Mopster ) Setting TLS - OK
[2021-02-05 12:42:07,206][ INFO](https://github.comRoomba.Upstairs ) MAP: opening existing map_notext.png
[2021-02-05 12:42:07,210][ INFO](https://github.comRoomba.Mopster ) MAP: opening existing map_notext.png
[2021-02-05 12:42:07,211][ INFO](https://github.comRoomba.Downstairs ) MAP: opening existing map_notext.png
[2021-02-05 12:42:07,302][ INFO](https://github.comRoomba.Mopster ) MAP: home_pos: (675,80)
[2021-02-05 12:42:07,302][ INFO](https://github.comRoomba.Mopster ) MAP: Initialisation complete
[2021-02-05 12:42:07,308][ INFO](https://github.comRoomba.Downstairs ) MAP: home_pos: (675,800)
[2021-02-05 12:42:07,309][ INFO](https://github.comRoomba.Downstairs ) MAP: Initialisation complete
[2021-02-05 12:42:07,312][ INFO](https://github.comRoomba.Upstairs ) MAP: home_pos: (300,300)
[2021-02-05 12:42:07,312][ INFO](https://github.comRoomba.Upstairs ) MAP: Initialisation complete
[2021-02-05 12:42:07,573][ INFO](https://github.comRoomba.Mopster ) Roomba Connected
[2021-02-05 12:42:07,679][ INFO](https://github.comRoomba.Downstairs ) Roomba Connected
[2021-02-05 12:42:07,788][ INFO](https://github.comRoomba.Mopster ) Received Roomba Data: $aws/things/ABCDEFGHGIXXXXXXXXXXXXXXXXXXXX/shadow/update, b'{"state":{"reported":{"batPct": 100, "batteryType": "F12432784", "batInfo": {"mDate": "2020-7-27", "mName": "F12432784", "mDaySerial": 2482, "mData": "303030393034303200000000000000000000000000", "mLife": "0BD10B64100C0D7F352A000703C3F6660071FEE81D130000000003A700000000", "cCount": 6, "afCount": 0}, "batAuthEnable": true, "bbchg": {"nChatters": 0, "nKnockoffs": 3, "nLithF": 2, "nChgOk": 24, "aborts": [0, 13, 0], "smberr": 0}, "bbchg3": {"estCap": 1913, "nAvail": 49, "hOnDock": 968, "avgMin": 55}, "bbmssn": {"aCycleM": 40, "nMssnF": 4, "nMssnC": 1, "nMssnOk": 31, "aMssnM": 46, "nMssn": 36}, "bbnav": {"aMtrack": 0, "nGoodLmrks": 0, "aGain": 0, "aExpo": 0}, "bbpause": {"pauses": [24, 18, 24, 18, 104, 104, 19, 18, 35, 46]}, "bbrun": {"nOvertemps": 0, "nCBump": 0, "nWStll": 0, "nPanics": 0, "nStuck": 22, "nPicks": 50, "sqft": 41, "min": 55, "hr": 20, "nCliffsF": 1042, "nCliffsR": 0}, "bbswitch": {"nBumper": 22526, "nDrops": 146, "nDock": 0, "nSpot": 0, "nClean": 17}, "bbsys": {"min": 43, "hr": 1009}, "behaviorFwk": true, "cap": {"edge": 0, "maps": 3, "pmaps": 5, "tHold": 1, "tLine": 2, "area": 1, "eco": 1, "multiPass": 2, "pose": 1, "team": 1, "pp": 0, "lang": 2, "5ghz": 1, "prov": 3, "sched": 1, "svcConf": 1, "ota": 2, "log": 2, "langOta": 0, "tileScan": 1}, "carpetBoost": false, "cleanMissionStatus": {"cycle": "none", "phase": "charge", "expireM": 0, "rechrgM": 0, "error": 0, "notReady": 0, "mssnM": 0, "expireTm": 0, "rechrgTm": 0, "mssnStrtTm": 0, "initiator": "none", "nMssn": 36}, "cleanSchedule2": [], "cloudEnv": "prod", "connected": true, "country": "CA", "deploymentState": 0, "detectedPad": "reusableWet", "dock": {"known": true}, "ecoCharge": false, "hwPartsRev": {"mobBrd": 11, "mobBlid": "XXXXXXXXXXXXXXXXXXXX", "navSerialNo": "CD00GHGV", "wlan0HwAddr": "50:14:41:69:c2:5d", "NavBrd": 1}, "hwDbgr": {"swVer": "", "hw": "", "status": 0}, "langs": null, "langs2": {"sVer": "1.0", "dLangs": {"ver": "0.20", "langs": ["cs-CZ", "da-DK", "de-DE", "en-GB", "en-US", "es-ES", "es-XL", "fi-FI", "fr-CA", "fr-FR", "he-IL", "it-IT", "ja-JP", "ko-KR", "nb-NO", "nl-NL", "pl-PL", "pt-BR", "pt-PT", "ru-RU", "sv-SE", "zh-CN", "zh-HK", "zh-TW"]}, "sLang": "en-US", "aSlots": 0}, "language": null, "lastCommand": {"command": null, "time": null, "initiator": null}, "lastDisconnect": 1, "mapUploadAllowed": true, "missionTelemetry": {"aux_comms": 1, "bat_stats": 1, "camera_settings": 1, "map_hypotheses": 1, "map_load": 1, "vital_stats": 1, "vslam_report": 1}, "mopReady": {"tankPresent": true, "lidClosed": true}, "name": "Mopster", "noAutoPasses": false, "noPP": false, "openOnly": false, "padWetness": {"disposable": 2, "reusable": 2}, "pmapLearningAllowed": true, "pmaps": [{"v3R-QnaqSQi3p1LIhEwWRA": "210205T030726"}, {"nL9mAMMXRmiEc1Q5ZWDNZQ": "210131T174925"}], "pmapCL": true, "pmapFmt": "3", "rankOverlap": 67, "sceneRecog": 1, "schedHold": false, "secureBoot": {"log": 2, "flip": 0, "sbl1Ver": "B3.2.02_PPUB", "stublVer": "B3.2.02_PPUB", "efuse": 1, "blType": 1, "enforce": 2, "lastRst": "200000001", "recov": "linux+2.4.2+sanmarino-release-rt320+11", "idSwitch": 0}, "sku": "m611220", "softwareVer": "sanmarino+3.12.8+sanmarino-release-420+12", "subModSwVer": {"nav": "sanmarino-nav+3.12.8+ubuntu-HEAD-09318572a78+12", "mob": "3.12.8+ubuntu-HEAD-09318572a78+12", "pwr": "0.3.0+ubuntu-HEAD-09318572a78+12", "sft": "1.2.0+SanMarino-Builds/SanMarino-Certified-Safety/sanmarino-safety-ca6f27d09c6+26", "mobBtl": "4.3", "linux": "linux+3.8.0.2+sanmarino-release-420+12", "con": "3.8.61-@8419265a/ubuntu"}, "svcEndpoints": {"svcDeplId": "v011"}, "tankLvl": 100, "timezone": "America/Toronto", "tls" ... ...
近期下载者:
相关文件:
收藏者: