darrenbrown

ProjectsPersonal

Self-driving zero turn lawnmower v1

An Arduino, an IMU and a pair of linear actuators on the handlebars — the first version, which cut one strip of grass

Equipment used

Troy Bilt Mustang 50 XPZero turn lawnmower
Arduino UnoMain controller
MPU-9250Inertial measurement unit for compass heading guidance
DROK 200206 2-channel motor controllerUsed to position the linear actuators
PMW3901 Optical Flow Sensor
U-Blox M8 GNSS ReceiverLocation from GPS and GLONASS satellites
Progressive Automations linear actuatorsUsed to control handlebars on the lawnmower

This is version 1, frozen as it stood. The work continued in Self-driving zero turn lawnmower v2, which replaced the controller, the heading pipeline and most of the code with something that actually holds a line.

The full setup so far
The full setup so far
Small scaled model for rapid development
Small scaled model for rapid development
The quick release mechanism
The quick release mechanism
Close-up of the sensors and controllers
Close-up of the sensors and controllers
The first strip of grass ever cut with this autonomous lawnmower!
The first strip of grass ever cut with this autonomous lawnmower!
The first strip of grass ever cut with this autonomous lawnmower!
The first strip of grass ever cut with this autonomous lawnmower!

General theory

Steering is controlled almost entirely by the inertial compass. A nice stable heading can be achieved by using a built-in fusion filter to combine data from the accelerometer, gyroscope, and magnetic compass. Location is from the GNSS receiver. The current receiver supplies latitude and longitude every 100ms in NMEA format over TTL serial.

Actuator control is achieved with a 2-channel PWM servo controller. Each actuator has position feedback using a 10 kOhm potentiometer. The resistance signal is configured as a voltage divider and connected to one of the analog input pins on the Uno. A small capacitor was added to help filter some high-frequency noise on this pin. Positioning of the actuators is via a simple PID loop. During startup, the actuators are driven all the way retracted to record the minimum position feedback voltage, then driven all the way extended to record the maximum position feedback voltage and the range is divided as 0-100%. Then a position command is compared to the current position and a PID loop controls the PWM output to the motor driver. This achieves the commanded position in the shortest amount of time with minimal overshoot.

The “position command” to the actuators is a combination of the desired bearing, current bearing, and desired forward or reverse speed.

What is working now

  • NMEA (location) messages are received, validated, and interpreted from the GNSS unit at 10 Hz
  • The IMU data is being filtered and interpreted
  • The position control of the actuators works very well
  • The optical flow sensor is able to see the ground and calculate very stable yaw and distance values in real units (degrees and mm, respectively)

What still needs work

  • The IMU suffers from magnetic interference and simple calibration does not seem to be able to remove it
  • The optical flow sensor is very easily “distracted” by light and shadows - it really only works well on cloudy days
  • The GNSS data is not doing anything yet
  • There is basically no obstacle avoidance!

What about safety, you say?

Good question!

For the purpose of this project, a risk assessment was performed involving the entire engineering team. Based on the current use case (no unsupervised operation), we decided to add an emergency pull cord around the mower (see photos) that kills the engine and a remote kill switch that can operate up to 1500m away. We also added remote start capability and remote mower blade engagement via one of these clever little things.

Where it went next

Most of the “still needs work” list above is what version 2 set out to fix. The magnetic interference turned out to be solvable with a proper ellipsoid calibration, the optical flow sensor was dropped rather than fought, and the GNSS data finally started steering something.

Self-driving zero turn lawnmower v2 →