Autonomous sail boat part three. Simulation

This is the third update about my attempts to build an autonomous sailboat with the goal to have it sail by itself next spring.

My first plan for simulation and hardware in the loop simulation was to use the Sail simulator game.You can read more about that in my last blog post. This solution works but the setup with two computers and a number of small programs working together was not a solution to use when you do most of your test on the subway to and from work (Yes with small children you need to use all free time). 

The solution was to write a simple sailboat simulator myself. I am using processing for the task. One reason is it's portability between operation systems and another is the similarities to Arduino. 

The simulator also act as a network server sending NMEA data and receiving boat control commands from my autopilot application also written in processing. When my algorithms are robust enough i will implement them in the APM and use the simulator for HIL simulations. the screen shot shows the boat beating to reach the waypoint. distance between waypoints is about 70 meters.

The simulator

The simulator implements a really simple model for simulating a sailboat. The target speed for the boat is generated from a simple polar chart. the boat will accelerate to the giver target speed and if the wind disagrees or the boat points into the wind it will slow down until it stops. The simulator uses google maps for backdrop.

The wind is always blowing at the same speed but varies a little in direction over time. 

It is really simple but it works for my purposes. 

The autopilot

The boat is controlled by an autopilot program that actually manages to sail the boat between waypoints even if it requires beating against the wind. there is much work to be done in optimizing the navigation and sometimes it shows almost scary behaviors  i really can't explain. Not AI, but more likely bugs in the navigation algorithms...

The autopilot receives SOG, COG, position, boat heading, apparent wind speed (AWS) and apparent wind angle (AWA) from the simulator. this is the same sensor data i get from my RC-boat. 

This is still early stages but it is quite amazing to see the boat tack to get to the next mark... 


Views: 2019

Comment by Georacer on October 22, 2013 at 12:13pm

I love autopilot simulators!

Have you considered implementing (or even having already done so) Dryden functions to model wind gusts? I think they are a really fun way to do it. I'm not sure if they apply to wind over seas, though.

Comment by Magnus on October 22, 2013 at 12:28pm

That look cool, but at the same time to advanced for my math skills. I really need some more "randomness" to make the simulation more realistic. Next step is to add current and drift to the model. 

Comment by Miguel Martín Mateo on October 22, 2013 at 1:52pm

Nice work Magnus.

You measure wind intensity or only direction to compute the sail position and or ruder position?

Comment by Magnus on October 22, 2013 at 2:47pm


On my real boat i am currently measuring wind angle but in my simulator i "measure" wind speed and use it to calculate wind direction. I will see what i can find out this winter before i decide to put a wind speed meter on the boat.

Comment by Matthew Coleman on October 24, 2013 at 6:08am

Magnus,  Can you estimate water currents or do you need a water speed sensor to do that?

Comment by Magnus on October 24, 2013 at 9:50am

Mathtew. I think it is possible if i use a theoretical speed of the boat. A boat my size will never go very fast and reach maximum speed at a relatively low wind speed. For my simulator i am using a simple polar chart to predict the boat speed and it's probably possible to create one for the real boat and use that to "guess" the speed based on wind speed, end wind angle. It might even be possible to use heel to estimate wind speed and thereby current. Actually i will estimate the sum of drift and current.

Comment by Matthew Coleman on October 24, 2013 at 5:39pm

The aircraft windspeed estimate algorithms use the delta groundspeed with a change in direction.  Your boat sideslips which a fixed wing doesn't.  Could be tricky.  Interesting stuff :-)

Comment by Kay Fricke on February 21, 2014 at 2:33pm

@Magnus, @Matthew

Just a few thoughts from my navigation Lessons and sailing experience.

True Wind estimation may be not of great influence in shallow conditions.

But considering the fact that the apparent Wind changes are strong in gusty conditions, when also the boat starts to react with speed and direction changes, it might be of great significance to have a good algorithm, else you wouldn't be able to sail a course beat to the wind. 
Wind astern isn't such a big matter under heavy conditions too, because the vectors just add to each other.

Found this paper, which might be of some interest when developing an algorithm:

Comment by Kay Fricke on February 21, 2014 at 3:33pm

Found some example code for truewind calculation on the same site too:

Comment by Matthew Ward on February 25, 2014 at 10:42am

This is awesome. What is your objective in terms of making hte boat run? Does it need to complete a course or just sail without crashing? If you need an info on RC Boats you might find this site beneficial


You need to be a member of DIY Drones to add comments!

Join DIY Drones


Season Two of the Trust Time Trial (T3) Contest 
A list of all T3 contests is here. The current round, the Vertical Horizontal one, is here

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service