I’ve posted some time ago on the topic of our own custom Python client (https://github.com/xebia/farmbot-py). Since one of us had to go off and get married our project was on hold for a while, but we’re on a roll again!
The client has been refined a bit more, and runs well against the 7.0.1 version (we can’t get version 8 to work - more about that later). The library is still for people who know their way around a Python IDE, we’ll look at easy deployment and install at a later time.
- added logging
- can check if a tool is mounted based on what is returned in the /logs channel
- some API improvements, like:
- watering a zone based on a set of rectangular coordinates,
- single reset command to reset lights, pumps and go home in one go,
- fixed unit tests, may add more
I’m somewhat proud of the simplicity of the scripts at the moment. To water all 6 zones in our bed all we need is this, combined with settings in the config file:
from farmbot.bot import create_farmbot, Axis from farmbot.config import ToolBay from farmbot.log import configure_logger bot = create_farmbot('./config.json') cfg = bot.cfg configure_logger(cfg) try: bot.set_lights(True) bot.go_home(Axis.all) if not bot.tool_mounted(): bot.pick_up_tool(ToolBay.Watering_Nozzle) bot.water_zone(cfg.zones["6"], -250) bot.water_zone(cfg.zones["5"], -200) bot.water_zone(cfg.zones["3"], -200) bot.water_zone(cfg.zones["4"], -250) bot.water_zone(cfg.zones["2"], -250) bot.water_zone(cfg.zones["1"], 0) bot.return_tool(ToolBay.Watering_Nozzle) bot.reset() bot.blink_lights(3) finally: bot.stop()
Now for the challenges.
The biggest one is robustness in the face of communications- or any other failure.
1a) The farmbot sometimes just stops responding and needs a restart, or messages get lost or don’t get sent. In one instance this happened just when the water was turned on, so it was good we were around to shut it down or we’d have flooded the plant bed …
1b) The other issue is re-entrance. When a sequence is half way, on a restart we need to recover from that point in some way. Redoing the whole program is not always feasible. As of yet we still have to figure out what information we can use to determine the current status and position of the bot and base any further actions from that point forward.
1c) On returning to work with the bot we found that there now is a flooding protection on the MQTT server because of frequent reconnects… which unfortunately is done by the Farmbot OS itself when it borks and restarts. We’ll need to talk this over with the Farmbot pplz, but it’s a good case of what a client needs to be robust against. Whatever the solution, robustness means dealing with situations like this. Reality will always throw a spanner in somewhere
Planting seeds is still currently more a hardware challenge than it is a software issue, so testing that is still a bit iffy.
A general challenge for all farmbot users is better detection and optical recognition stuff to allow the bot to make smarter decisions. I’ve personally looked at OpenCV and it’s a bit above my mathematical experience, so it would be great if someone in the community could just provide easily usable algorithms for plant detection etc.
Height detection. In our experience the bot kills little plants when it waters because the water stream is so powerful. We’ve found that short bursts from the lowest possible height works pretty well, but we need to code the height in the scripts at the moment: there is no “height of whatever is under the tool mount” sensor at the moment. Other options would be a diffferent shower head or a lower power pump, but that’s a bit more involved than we have time for at the moment: our expertise is software, not hardware
Getting version 8 to run. As far as we can see version 8 borks on us because it can’t find the update server. Needs looking into.
If anyone ever wants to use our code, please contact us directly so we can support you in setting things up. I’m aware that the documentation still needs work