Building a Self-Driving Boat (ArduPilot Rover)
by Basement Engineering in Circuits > Robots
53482 Views, 257 Favorites, 0 Comments
Building a Self-Driving Boat (ArduPilot Rover)
You know what's cool? Unmanned self-driving vehicles. They are so cool in fact that we (my uni colleagues and me) started to build one ourselves back in 2018. That is also why I set out this year to finally finish it in my free time.
In this Instructable I want to share this project with you and get you into building your own self-driving vehicle. I also made a little YouTube Video that scratches the surface of the project and gives you a quick rundown of all the mishaps along the way. This Instructable is the correlating guide that explains how this thing actually works.
Who is this Instructable for and how to read it
This Instructable actually has two purposes. First and foremost, I want to share what I have built and learned and get you guys interested in building self driving vehicles. The secondary purpose is to document the project and most of it's details so the next student group at my old university, that picks up the project knows whats up.
If you are just here for fun, you can ignore details like parameter lists and precise wiring diagrams. I'll try to keep the steps very generic in the beginning, so they can be applied to any ArduPilot RC boat and put the details at the end.
The project was finished in two parts and the Instructable follows the same structure. I'm going to refer to the first part as the "muscles" as it includes all of the power electronics and the boats hull. Then I'm going to go over the "Brain" which is a little box on top of the boat, that contains the main controller and all of the receiver transmitter stuff.
The origins of the Kenterprise
Allright, here ist the backstory to this project, if you haven't heard it in the video already. This project started in 2018 when I was still in university. We were at the end of the 4th semester going towards the 5th. At our university you get to do a team project for about 6 months. You can either choose from a list of prepared projects (good chance of a good grade) or start your own project (no one ever did this before to my knowledge). You also get 12 Credit points for this project, which makes it worth as much as the bachelors thesis. This way failing can really make a difference in your overall grade.
I of course I decided to start a project from scratch and found 4 poor souls to follow me on this journey into a dumpster fire of a team-project. We started of with the minimum required team size of 5 people but 2 of us later left. We were also given 1500€, BUT we were not allowed to spend it on any of those lovely chinese webshops that always have the latest and greatest electronics. Instead we were bound to good old german electronics suppliers. Spoiler: It is kind of impossible to get self driving boat components this way.
The Original Idea
When we thought of an idea for the project, we thought about doing something drone related because drones are just the coolest thing ever. However normal flying drones are already a thing and we wanted to build something more novel. So we decided to build a drone boat. We got this idea because of a nearby lake.
The lake covers an area of 12km^2 and is mostly just 1.5m deep. This means that it heats up in the summer month, while there is also less water in it. You know what lifeform loves warm waters: Cyanobacteria, also referred to as blue algea in germany. Under the right conditions these things can reproduce in no time and cover large areas while producing toxins that can harm humans and animals alike. The purpose of the boat was to regularly sweep the surface of the lake and measure the algea concentration. Then the collected data can be printed to a heatmap to understand under which circumstances algea starts do build up and also to issue real time warnings to locals and tourists.
Another Spoiler: We we were never able to build a measuring assembly for blue algea and fit it onto a boat, as such assemblies are verrrry costly and are usually housed in a 1mx1mx2m rack on a ship, which is an impractical size for a 1m long boat. The new focus is to automatically and cheaply create depth maps off the lake to enable the local biologist to see how the lake bed changes over time. Right now scanning it is very costly due to the necesary manual labor.
A Downwards Spiral
Back to the story. In the first two months of gathering background knowledge and planning we considered what such a boat would need: A hull, an electric drive train, self-driving capabilities, internet controlability, ... . That was when I decided that we should build almost everything ourselves with a focus on autonomous driving. This was a bad idea, an idea that was pretty much doomed to fail and guess what it did? Exactly, 6 months later we had poured our time and sweat into a huge RC boat, the Kenterprise (Infographic in image 4). On the way we struggled with limited money, no available electronics and bad team management, which I take most of the responsibility for.
So there it was, the Kenterprise, an autonomous measuring vehicle that was neither autonomous nor measuring anything. Not much of a success as you can see. We got grilled during our final presentation. Luckily our professor acknowledge our heard work and still gave us an ok grade, worse than any other project group in the past few years but ok.
The 2020 Upgrade
I would consider calling this student project an absolute dumpster fire, but as the old saying goes: "the scars of a dumpster fire make you stronger". This experience really helped me to appropriately scale my goals and stay focused in all of my following projects. I also still love the idea of an unmanned vehicle that can help biologists to do lake surveys and the general appeal of building a self driving boat. That is why now, one year later, I wanted to finish it using my newly gained FPV drone knowledge, the beautiful Open Source Project ArduPilot and the power of cheap electronics sites.
The goal was not to turn it into a fully fledged measuring boat, but to get all the systems up and running and install an autopilot. It does not have to be perfect. I just wanted to see this boat drive itself as a proof of concept.
I am then going to pass the WORKING autonomous boat on to the university for future projects such as mapping the seabed. By the way, I was not alone. My friend Ammar, who was also in the project group back in 2018 helped me with testing the boat.
Without further ado, lets get into it
Muscles: the Hull
The hull is the biggest part of the boat. Not only because of it's huge dimensions (100cm*80cm) but also because it took a lot of time to build this custom structure. If I would do it again, I would definitely go for of the shelf parts. An off the shelf RC boat was unfortinately not in the cards for us, as those boats have a very limited payload capacity. Something like a bodyboard or a surfboard or just a couple of PVC Pipes from the hardware store would have been a much simpler solution that I can only recommend.
Anyways, our hull started with a 3D model in Fusion 360. I made a very detailed model and went through multiple iterations before we actually started building it. I made sure to give each component in the model the appropriate weights and even modeled the interior. This allowed me to know the approximate weight of the boat before building it. I also did a few buoyancy calibrations by inserting a "water line", cutting the vehicle with it and calculating the volume that was underwater. The boat is a catamaran as this kind of vehicle promises a higher stability, then a boat with a single hull.
After a ton of modeling hours we started to bring the boat to life by cutting the basic shape of the two hulls out of polystyrene plates. They were then cut to shape, holes were filled and we performed a lot of sanding. The bridge that connects the two hulls is just a big wooden box.
We covered everything with 3 layers of fibre glass. This step took about 3 weeks and involved days of manual sanding to get a decently smooth surface ( 0/10 would not recommend). After that we painted it in a nice yellow and added the name "Kenterprise". The name is a combination of the German word "kentern" which translates to sinking and the Star Trek Spaceship "USS Enterprise". We all thought that this name is absolutely suitable for the monstrosity that we created.
Downloads
Muscles: Propulsion System
A boat without motors or sails has the driving characteristics of a piece of driftwood. Therefore we needed to add a propulsion system to the empty hull.
I'd like to give you another spoiler: The motors we choose are way too powerful. I'm going to describe the current solution and it's shortcomings and also propose an alternative propulsion system.
The current solution
We did not really know how much thrust the boat needed so we got ourselves two of these racing boat motors. Each of those is meant to power a 1m long RC racing boat and the corresponding electronic speed controller (ESC) can deliver 90A continuously (this consumption would drain a big car battery in an hour).
They also require water cooling. Usually you would simply connect the ESC and the Motor with some tubing, put the inlet to the front of the boat and place the outlet in front of the propeller. This way the propeller pulls the lake water through the cooling system. However, the lake in question is not always clean and this solution may clog the cooling system and cause a motor failure while out on the lake. That's why we decided to go for an internal cooling loop that pumps the water through a heat exchanger on top of the hull (image 3).
For now the boat has two water bottles as reservoirs and no heat exchanger. The reservoirs simply increases the thermal mass so the motors take much longer to heat up.
The motor shaft is connected to the prop through two universal joints, an axel and a so called stern tube, that is meant to keep the water out. You can see a side view of this assembly in the second image. The motor is mounted at an angle with a 3D printed mount and the props are also printed (because i broke the old ones). I was pretty surprised to learn that these props can withstand the forces of the motors. To support their strength I made the blades 2mm thick and printed them with 100% infill. Designing and printing the props is actually a pretty cool opertunity to try out different kinds of props and find the most efficient one. I attached the 3D models of my props.
A possible Alternative
Testing showed that the boat only needs 10-20% of the throttle range to slowly move around (at 1m/s). Going straight to 100% throttle causes an enormous current spike, that completely disables the whole boat. Also the requirement of a cooling system is pretty annoying.
A better solution could be so called thrusters. A thruster has the the motor directly connected to the propeller. The whole assembly is then submerged and therefore cooled. Here is a Link to a small thruster with the corresponding ESC. This can provide a max current of 30 A, which seems like a more appropriate size. It will probably create way smaller current spikes and the throttle does not have to be limited so much.
Muscles: Steering
Propulsion is cool, but a boat also needs to turn. There are multiple ways to achieve that. The two most common solutions are Rudders and differential thrust.
Rudders seemed like an obvious solution so we went for it. I modeled a rudder assembly in Fusion and 3D printed the rudders, hinges and a servo mount. For the servos we choose two big 25kg Servos to make sure that the relatively big rudders were able to withstand the drag of the water. Then the servo was positioned inside the hull and connected to the rudder on the outside through a hole using thin wires. I attached a video of the rudders in action. It is quite pleasing to watch this mechanical assembly move.
Although the rudders were looking great, the first test drives revealed that the turning radius with them is around 10m which is just terrible. Furthermore the rudders tend to disconnect from the servos, making the boat unable to steer. The final weak point is the hole for those wires. This hole was so close to the water, that reversing caused it to be submerged, therefore flooding the interior of the hull.
Instead of trying to fix those issues, i removed the rudders all together, closed the holes and went for a differential thrust solution. With differential thrust, the two motors turn in the opposite direction to make the vehicle turn. As the boat is almost as wide as it is short and the motors are positioned far away from the center this allows turning on the spot. It only requires a little bit of configuration work (programming the ESC's and the main controller). Keep in mind that a boat that uses differential thrust will dirve in circles if one of the motors fails. I might have experienced that once or twice due to the current spike problem described in the step before.
Muscles: Battery
To me it seems like RC Components, such as the ones used in this boat, can be powered by pretty much anything, ranging from a watch battery all the way to a nuclear power plant. Obviously this is a little bit of an exaggeration but they have a fairly wide voltage range. This range is not written into the data sheats, at least not in Volts. It is hidden in the S-rating. This rating describes how many battery cells in series it can handle. In most cases it refers to Lithium Polymere (LiPo) cells. Those have a voltage of 4.2V when fully charged and a voltage of around 3V when empty.
The boats motors claim to be able to handle 2s to 6s which translates to a voltage range of 6V all the way to 25.2V. Although i wouldn't always trust the upper limit, as some manufacturers are known to place components on their boards that can only withstand lower voltages.
This means that there is a wide variety of usable batteries as long as they can deliver the required current. And I actually went through a couple of different batteries before building a proper one. Here is a quick rundown of the three battery iterations that the boat went through (so far).
1. LiPo Battery Pack
When we planned the boat we did not have any clue how much energy it would consume. For the first battery we choose to build a pack out of the well known 18650 Lithium Ion cells. We soldered them into a 4S 10P pack using nickel strips. This pack has a voltage range of 12V to 16.8V. Each cell has 2200mAh and is rated at a maximum discharge rate of 2C (pretty weak) so 2*2200mA. As there is 10 cells in parallel it can deliver peak currents of just 44A and has a capacity of 22Ah. We also equipped the pack with a battery management board (more on BMS later) that takes care of charge balancing and limits the current to 20A.
Upon testing the boat it turned out that 20A of max current is waaaaay less than the motors consume and the BMS was constantly cutting the power if we weren't careful with the trottle stick. That is why I decided do bridge the BMS and connect the Battery straight to the motors to get the full 44Amps. Bad Idea!!! While the batteries managed to deliver slightly more power, the nickel strips, connecting the cells could't handle it. One of the connections melted and caused the wooden interior of the boat to produce smoke.
Yeah, so this battery was not really suitable.
2. Car Battery
For my 2020 proof of concept, I decided to use a bigger battery. However, I did not want to spend any extra money so I used an old car battery. Car batteries are not meant to be fully discharged and recharged, they should always be kept at full charge and only used for short current burst to start an engine. That is why they are called starter batteries. Using them as a battery for an RC vehicle significantly reduces their lifespan. There is another type of lead battery that often has the same form factor and is specially designed to be discharged and recharged multiple times called a Deep Cycle battery.
I was well aware of the short comings of my battery, but I wanted to quickly test the boat and the battery was old anyway. Well, it survived 3 cycles. Now the voltage dips from 12V to 5V whenever I hit the throttle.
3. LiFePo4 Battery Pack
"Third time is a charm" is what they say. As i still didn't want to spend my own money, I asked my university for help. Sure enough they had my dream battery all along. Our Uni takes part in the "Formula Student Electic" competition and therefore has an electric race car. The racing team previously switched from LiFePo4 cells to 18650 LiPo cells as they are lighter. So they have a stash of multiple used LiFePo4 cells that they don't need anymore.
Those cells differ from LiPo or LiIon cells in their voltage range. The have a nominal voltage of 3.2V and it ranges from 2.5V to 3.65V. I assembled 3 of those 60Ah cells into a 3S pack. This pack can deliver Peak currents of 3C aka. 180A and has a max voltage of just 11V. I decided to go for a lower system voltage to decrease the motor current. This pack finally allowed me to drive the boat for more than 5 minutes and test the self driving capabilities.
A word on battery charging ans safety
Batteries concentrate energy. Energy can turn into heat and if this heat takes the shape of a battery fire, you've got a problem on your hand. That's why you should treat batteries with the respect they deserve and equipt them with the right electronics.
Battery cells have 3 ways of dying.
- Discharging them to below their minimum voltage rating (cold death)
- charging them above their maximum rated voltage (may cause swelling, fire and explosions)
- drawing too much current or shorting them (so I really have to explain why this might be bad)
A battery management system prevents all of those things, that is why you should use them.
Muscles: Wiring
The Wiring for the muscle part is shown in the first image. On the bottom we've got the battery which should be fused with an appropriate fuse (right now there is none). I added two external contacts to connect a charger. It would be a good idea to replace those by a proper XT60 connector.
Then we have a big battery switch, that connects the rest of the system to the battery. This switch has an actual key and let me tell you, it is so satisfying to turn it and see the boat come to life.
The brain is connected to the batteries ground while the ESCs and Servos are separated by a shunt resistor. This allows the current to be measured through the little orange connection as it causes a small voltage drop over the shunt resistor. The rest of the wiring is just red to red and black to black. As the servos are not really used anymore, they can just be ignored. The cooling pumps are the only component of the boat that requires exactly 12V and they don't seem to work well if the voltage is higher or lower than that. Therefore they need a Regulator if the battery voltage is above 12V or a step up converter if it is below that.
With rudder steering both of the ESC signal wires would go to the same channel on the brain. However the boat now uses differential thrust aka. skid steering, so each ESC needs to have its own separate channel and the servos aren't needed at all.
Brain: Components
The brain is a big box full of interesting electronics. Many of which can be found in FPV racing drones, and some of them were actually taken out of my own drone. The first image shows all of the electronic modules. They are neatly stacked on top of each other using brass PCB standoffs. That is possible because FPV-components come in special form factors refered to as the stack site. From bottom to top our stack contains the following:
Power Distribution Board (PDB)
This thing does just what the name implies and distributes the power. Two wires from the battery come in and it offers multiple solder pads to connect different modules to the battery. This PDB also offers a 12V and a 5V regulator.
Flight Controller (FC)
The flight controller runs the ArduPilot Rover Firmware. It does a variety of things. It controls the motor controllers through several PWM Outputs, it monitors the battery voltage and current, it connects to the different sensors and input and output devices and it also features a gyroscope. You could say that this little module is the actual brain.
RC Receiver
The receiver is connected to a remote control. In my case it is a FlySky remote for RC planes that has ten channels and even establishes two way communication so the remote can also receive signals from the receiver. It's output signals go straight to the FC through a single wire using the so called I-bus protocol.
Video Transmitter (VTX)
The brain box features a little analog camera. The video signal of the camera is passed to the FC that adds an on screen display (OSD) to the video stream, containing information such as the battery voltage. It is then passed on to the VTX which transmits it to a special 5.8GHz receiver on the other end. This part is not strictly necessary but it is cool to be able to see what the boat sees.
On top of the box are a bunch of antennas. One is from the VTX, two from the RC Receiver. The other two antennas are the following components.
Telemetry Module
The 433MHz antenna belongs to a telemetry module. This little transmitter is an input/output device that connects the flight controller to the ground station (a laptop with a 433MHz USB dongle). This connection allows the operator to remotely change parameters and get data from the internal and external sensors. This link can also be used to remotely control the boat.
GPS and Compass
The big round thing on top of the boat is actually not an antenna. Well it kind of is but it is also a whole GPS module and a compass module. This is what enables the boat to know it's position, speed and orientation.
Thanks to the growth of the drone market there is a wide variety of components to choose from for each module. The most likely that you might want to switch is the FC. If you want to connect more sensors and need more inputs there is a variety of more powerful hardware options. Here is a list of all the FC's that ArduPilot supports, there is even a raspberry pi on there.
And here is a little list of the exact components i used:
- FC: Omnibus F4 V3S Aliexpress
- RC Receiver: Flysky FS-X8B Aliexpress
- Telemetry Transmitter Set: 433MHz 500mW Aliexpress
- VTX: VT5803 Aliexpress
- GPS and Compass: M8N Aliexpress
- Enclosure: 200x200x100 mm IP67 Aliexpress
- Remote Control: FLYSKY FS-i6X Aliexpress
- Video Receiver: Skydroid 5,8 Ghz Aliexpress
Brain: Wiring
The brain gets its operating voltage straight from the battery. It also gets an analog voltage from the current shunt and it outputs the control signals for both of the motors. Those are the external connection that are accessible from the outside of the brain box.
The inside looks much more convoluted. That's why I made the little wiring diagram in the first picture. This shows the connections between all of the different components that I described in the previous step. I also made a couple of extension cords for the PWM output channels and the USB port and routed them to the back of the enclosure (see image 3).
To mount the stack to the box I used a 3D printed base plate. As the components (especially the VTX) produce heat I also attached a 40mm fan with yet another 3D printed adapter. I added 4 black plastic pieces to the edges to screw the box onto the boat without the need to open the lid. The STL files for all of the 3D printed parts are attached. I used epoxy and some hot glue to stick everything to the.
Brain: ArduPilot Setup
The Ardupilot Wiki describes how to setup a rover in great detail. Here is the Rover documentation. I am only going to scratch the surface here. There are basically the following steps to get an ArduPilot Rover up and running after everything is wired up correctly:
- Flash ArduPilot Firmware to FC (Tipp: you can use Betaflight, a common FPV drone software, for that)
- Install a Ground Station software like Mission Planner and connect the board (see mission planner UI in image 1)
- Do a basic hardware setup
- calibrate gyro and compass
- calibrate remote control
- setup output channels
- Do a more advanced setup by going through the parameter list (image 2)
- voltage and current sensor
- channel mapping
- LEDs
- Do a test drive and tune the parameters for throttle and steering (image 3)
And boom, you've got a self-driving rover. Of course all of those steps and settings take some time and things like calibrating the compass can be quite tedious but with the help of the docs, the ArduPilot forums and YouTube tutorials you can eventually get there.
ArduPilot gives you an advanced playground of houndreds of parameters that you can use to build pretty much any self-driving vehicle you can think of. And if you are missing something you can engage with the community to build it as this great project is open source. I can only encourage you to try it, as this is problably the easiest way to get into the world of autonomous vehicles. But here is a little pro tip: Try it with a simple vehicle before building a giant RC boat.
Here is a little list of the Advanced settings that I did for my particular hardware setup:
- Changed Channel mapping in RC MAP
- Pitch 2->3
- Throttle 3->2
- Activated I2C RGB LEDs
- Frame Type = Boat
- Setup Skid Steering
- Channel 1 = ThrottleLeft
- Channel 2 = ThrottleRight
- Channel 8 = FlightMode
- Channel 5 = Arming/Disarming
- Setup Current and Battery Monitor
- BATT_MONITOR=4
- Then reboot. BATT_VOLT_PIN 12
- BATT_CURR_PIN 11
- BATT_VOLT_MULT 11.0
Brain: Custom LED Controller
Let's face it, RGB LED's are very cool. They look good, they have increased performance in gaming PC's for years and in case of an ArduPilot vehicles, they actually serve a purpose. They show you what's going on inside the controller. Green is good, red is bad and there is also a lot of color codes in between here is a full list.
ArduPilot Rover supports a variety of LED types, such as addressable WS2812b RGB LED's aka. NeoPixels. However, it only supports a single LED out of the box. It also supports scripting, so you can write your own LED control script to control more LED's BUT your flight controller has to have at least 2MB of RAM, to support this feature.
My FC does not support scripting but I put 36 addressable LED's on the outside of my brain box and I want to see all of them light up. To achieve that, I put an Arduino Nano in between the FC and the LED's. To the FC it behaves like an I2C RGB LED controller, that is able to make an LED strip light up in a single color. On the other end it controls the 36 WS2812b LED's. My custom LED controller is basically just a translator that turns the smart addressable LED's into a dumb RGB strip. I attached the Arduino sketch.
I am pretty sure that there is a way to make multiple WS2812b LED's work with just the ArduPilot FC. This was just the easiest way for me after googling around for an hour.
Downloads
Doing a Couple of Missions
After all of that hard work, the boat is finally able to drive itself, meaning that I can click on the map in my mission planner software to create a waypoint mission, upload it to the boat and it will drive the pre-configured route. Although the boat is not perfectly tuned and is also not yet well tested (this will hopefully be done by future project groups), it is able to follow simple routes and sends a constant stream of telemetry data to the ground station.
To me it is just a magic moment when I flip the switch on my remote control and the boat just starts moving on its own, without me touching the throttle stick. And the route is highly repeatable. I can just store my waypoint map in a little file and the boat will drive the same route again and again and again. This makes it possible to sample certain points on surface of a lake and generate heatmaps over time. This can make trends, that usually happen too slow or on too big of a scale to notice visible. Therefore the Kenterprise a great survey vehicle that is relatively easy to operate thanks to the great work of all the people involved in the creation of ArduPilot.
I hope you enjoyed this Instructable and I hope that i got you hooked on ArduPilot as well.
Thank you for reading and a big thanks to everyone who supported our project team back in 2019 and me during my 2020 upgrade. A special thanks to Ammar for helping me.
If you have got any questions, that this Instructable didn't answer, feel free to leave them in the comments. I will try my best to respond and expand it if necessary, although it might not be instantly. Also if you build your own ArduPilot rover share it. I would love to take a look at it. And one more thing, if you liked this project, you might want to vote for it in the 2020 Make it Move Contest.
Happy Making