GPS and compass steering to waypoint

Hello,

Firstly I'm new to the whole programming scene, though have had some luck in the past by following instructions with a little bit of guidance.

I have been researching a ton on the problem that I face, and there are several threads on this site and others that have the same issue, though never have seemed to get working.

I have a boat, and I would like to turn it out, it receives a GPS signal and records this as Waypoint 1. It then takes a heading in the direction that I am pointing the craft with a compass on and records this as a heading.

I would then like some code to calculate a waypoint of a given distance perpendicular from Waypoint 1 and record this as Waypoint 2.

The craft then uses the compass to maintain the heading with a servo connected to the rudder, while navigating to Waypoint 2 also using the servo.

Some guidance and help with the code would be absolutely fantastic.

Im thinking about using the Mega2560, any GPS module, compass and servo powered from a 12 v battery. The whole thing doesnt need to be super accurate, I would however like the craft to go more or less in a straight line from my start point, dealing with currents and tides as it navigates to the waypoint 2.

Cheers,

Zac

I suggest to spend some time on the diydrones.com forum. They have a complete Arduino-compatible navigation package free for download (Arduboat), and lots of knowledgeable people to ask about problems.

Cheers,

Have been reading over their forums, however most are using the APM 2.6 to get what they are after. I couldn't justify an APM 2.6. I would have thought it would be reasonably straight forward working of a mega that I have lying around.

Thank you,

Zac

"Reasonably straightforward" depends on how well you can program in C/C++ and understand basic vector math and navigational principles. You won't find any code on this forum that does everything you want, but (for example) TinyGPS will give you a heading to the next waypoint.

Thanks mate,

Im good with the vector math and navigation, just the programming that will let me down. Ill have a look at Tiny GPS and see if there is other snippets of code that I can learn from and adapt.

This is the function call in TinyGPS (C code version) to which I referred:

float course_to (float lat1, float long1, float lat2, float long2)
{
  // returns course in degrees (North=0, West=270) from position 1 to position 2,
  // both specified as signed decimal-degrees latitude and longitude.
  // Because Earth is no exact sphere, calculated course may be off by a tiny fraction.
  // Courtesy of Maarten Lamers

You will find some very useful navigation code on the following page (see especially Destination point given distance and bearing from start point): Calculate distance and bearing between two Latitude/Longitude points using haversine formula in JavaScript