Close

Need Input!

A project log for Lawnny Five

A heavy-duty robotic lawn tractor with interchangeable implements

jim-heisingJim Heising 03/15/2024 at 22:580 Comments

We've taken the first steps towards autonomy!

Microcontroller and IP-Based Control

As most of you know by now, the ultimate goal for Lawnny is to provide some amount of autonomous functionality. But even though I want to automate as much as possible I don't want to lose the ability to control him manually, so a hybrid control system would have to be implemented.

The easiest way to accomplish this would probably be to leverage an off-the-shelf flight/rover controller— something like an Ardupilot. With this, I could control Lawnny autonomously with the flight controller, but then maintain the RC transmitter/receiver combo to override the FC when I wanted to control it manually. I did a lot of research into flight controllers, and long-range data links, but ultimately decided to start simple— control the robot directly from the Raspberry Pi through standard wifi.

Here are a few of the reasons I chose this route:

  1. I thought it'd be nice to manually control the robot with something most people already carry with them— a mobile phone. This means I don't have to lug around a bulky RC transmitter.
  2. To gain high accuracy GPS positioning, I'll most likely have to leverage RTK, which will require some sort of realtime data link to a base-station. With standard wifi this should be easy without any additional data modem hardware.
  3. Sending video over a wifi IP connection is common and well understood, and does not require additional FPV equipment.
  4. I don't have to spend additional money to purchase a drone/rover flight controller, but I'm also not excluded from integrating one in the future.

So with all of this in mind, I figured that a standard wifi connection would be the cheapest and easiest solution. But it does have some drawbacks— mainly relatively low range.

Dealing with Range Anxiety

Because out-of-the-box wifi has relatively low range, I figured I would have to deal with potentially two bad scenarios:

  1. The Bad: I lose connectivity and Lawnny just stops. He weighs hundreds of pounds, so he's not exactly easy to pick up and bring back into range.
  2. The Downright Ugly: I lose connectivity and Lawnny just keeps moving in a straight line until something gets in his way. With a weight of hundreds of pounds and two mower blades, this is not something I want to ever experience.

Addressing the Bad

The way I'm addressing this is to implement two wifi radios. I've added a wifi dongle to the Raspberry Pi with a removable antenna. This antenna will be extended to run outside of the metal enclosure box and should provide a relatively stable connection to the wifi in my house. Obviously this wouldn't work if you had many acres of land, but my home wifi reaches most parts of my yard without any problem.

That being said, there is the chance that the wifi connection for this main USB-based radio could become weak or non-existent in certain parts of the yard, so that is where the second wifi radio comes in. The onboard wifi radio on the RPI is set to be a wifi hotspot. So if for some reason I lose connectivity on the shared wifi, I can just walk up near Lawnny with my phone and connect to its built-in access point and control it directly from there. This should work in theory, but only time and testing will tell.

Addressing the Downright Ugly

Out of the two problems this is by far the worse, so I had to go deep into "brain stem" of Lawnny to address this. The way I solved this was to employ the timeout functionality in the Sabertooth motor controller.

By default, the Sabertooth motor controller will continue to run the motors at the speed of the last command it was sent. For obvious reasons this would not be optimal if the controller became disconnected from manual control via wifi. So to address this, the controller has what is called a timeout mode. The timeout mode will continue to run the motors for only a short amount of time and will automatically stop unless it receives another command. So it acts a bit like a deadman's switch.

So as it stands now, Lawnny will only move if/when it receives a command to move once every 150 milliseconds— if the wifi connection stops for any reason, this would cause Lawnny to stop dead in his tracks.

The Brain

After a lot of back and forth on deciding how I wanted to build Lawnny's brain, I made the probably obvious choice of using ROS. Honestly, I think ROS is probably overkill for what I need, but it felt like a cool opportunity to learn something new. I will fill in more detail on this as I build out more and more of the functionality.

The Controller

As I mentioned before, I wanted to leverage my mobile phone as the primary manual controller, but how would this work in practice? I do have a bit of experience building native mobile apps, so this was an obvious choice, but since we're now using standard off-the-shelf wifi there are other options available to us— mainly a simple web app.

As it stands now, I've built a simple react-based static web app that uses websockets to connect directly to the ROS system running on the RPI. While the HTML app could technically be hosted anywhere, I've also allowed Lawnny to act as a simple web server. So to control Lawnny, all I have to do is point my browser to http://lawnny5.local:8000 and I can control him from any device with a web browser on the same network.

But I also wanted more precise control than what a touch-based controller might give, so as you might notice from the video above, I've also made it so you can use any bluetooth gamepad (Xbox, PS, mobile, etc) through the amazing magic of the HTML5 Gamepad API. The gamepad controller wrapped around my iPhone in the video can be found at https://www.amazon.com/dp/B0CQKS59MH.

All of this can now be downloaded as open source at https://github.com/jheising/lawnny5.

And Finally!

I have a quick video of Lawnny's first manually controlled mow of the entire yard! Unfortunately my wife lost the first video that was a lot longer, but she was able to capture this short clip to give you the idea. I'll hopefully have some better videos in the near future as the lawn comes out of winter hibernation.

The great news is that Lawnny was able to mow the entire yard (0.65 acres) while barely making a dent in the battery! So power and battery life are now crossed off as concerns.

Although the entire episode was not entirely without incident. While making a tight turn, one of the treads flipped over and became derailed from the wheels. Normally it'd be an easy fix, but since the whole bot weighs so much, it was actually quite difficult to get get it jacked up enough to retread the track. Although I'm not too concerned— I think I have some quick and easy solutions to solve for the future. Stay tuned!

Discussions