Home

Weedkiller Robot

Fun intro to electronics for me. The robot was made by me and my dodgy engineering skills and was built to a budget. The robot doesn't quite achieve its goal of killing weeds as the weed identification model isn't quite there and I haven't got round to adding perimeter wire. An MVP that kills weeds but doesn't do it systematically i.e. goes in random directions, wouldn't be too far away but I don't currently have the time to pursue this.

Interesting Things

Autonomous driving

The main source of inspiration for this project was autonomous lawnmowers. The have a similar high level goal but are just missing the identification and targeted shooting. Autonomous lawnmowers are a relatively modern thing with only the newer ones being able to follow routes (TODO check) but these use GPS RTK which is a bit out of my budget. As my domain of operation was more limited (a relatively flat patio), I thought that I could get away with dead reckoning. Turns out I couldn't. Dead reckoning is notoriously rubbish but I thought that with enough sensors it would be close enough. The robot used: wheel encoders, a magnemometer, a gyroscope and ultrasound. It fused these measurements together to calculate heading and distance travelled via a Kalman filter TODO check and rewrite Treats readings as samples from a normal distribution, multiplies together the distributions + reliability to get best estimate of true distribution . Based on these measurements, to go to a specific location, it uses PID Proportional, integral, derivative. Smoothly (e.g. no overshooting) achieves a desired outcome value by changing input values After much fiddling (changing motors, changing wheels, tuning constants), I couldn't get reliable turns and so the error accumulates and the robot can no longer go in straight lines. Pictures of highlighters.

Machine learning on custom dataset

I needed an algorithm that could identify the positions of weeds. A simple checking of green pixel doesn't work as all the grass ends up dead and so I needed a machine learning model. As it's relatively complex and image-based, a CNN was probably the right tool and handily I have my own https://alistair.hanlonhome.co.uk/cnn (which this does use). I couldn't find a weed-on-patio dataset and so I made by own by driving the robot around manually and taking photos. The dataset is relatively sensible, it doesn't expect anything out of reach for a human and it includes a mix of weed and non-weed containing photos along with important non-weed cases e.g. lawn. I had around 2,000 photos of my patio and used extensive image augmentation. However, I think the patterns were too complex for the limited number of unique weeds (my patio isn't that bad) in the dataset. I managed to make the model overfit but couldn't ever get it to generalise to the test dataset. The model could easily do a simpler "plant vs outdoor patio area" dataset but couldn't do my garden. I also tried transfer learning from this dataset and this didn't help. The main takeaway is that a machine learning model aims to minimise its loss. If learning what you what it to learn is not the easiest way to minimise loss, it will not do this.

Android app on BLE

To control the robot, I made an Android app which connects to the Pi Pico via BLE. On Android this isn't too hard but trying to it on the Pico in C with limited documentation was a bit of a pain. The app has throttle controls for the motors, commands for the robot e.g. autonomous mode, and a livestream of the onboard camera. The Pi Zero streams the video through RTSP and then also hosts a HTTP server which allows the app to send requests to save photos on the Pi (useful for dataset collection).
(This is before I realised you had to manually focus the camera)

It's quite fun actually making stuff

Having something tangible is quite nice. Especially fun if you're under a budget as you end up with some funny bodges:
You also learn stuff that you wouldn't encounter from just writing software. Some of the interesting things I learnt from doing more hardware stuff was: I2C, SPI, pull up resistors, PWM, soldering, magnetometer calibration, It is a bit more expensive than software and cost around £106.54 (I thought it was cheaper than that) but if you didn't have to prototype, it could be done for cheaper. But it does have two computers, motors, and a camera on it along with other gizmos.
I don't currently have the time to pursue this but if I did, the steps needed to make it work would be