# Steering between waypoints

I am a beginner at Arduino & programming and need some help please. I would like to steer a model boat to a waypoint then return to the start point. I have written a sketch to work out the waypoint lat & long, from any starting point given the distance required to travel (from a potentiometer), and a reading from a hmc6352 compas. Now I need the following: 1/ How to identify when the GPS has a valid lock (before the waypoint calculations are started). 2/ How to steer to the waypoint. 3/ How to set the waypoint recognition radius (ie just have to a few meters away is OK).

I am using some of the tiny GPS code. Is this able to get the required valid lock data from the GPS? Thanks.

1/ How to identify when the GPS has a valid lock (before the waypoint calculations are started).

Typically, the GPS doesn't begin sending data until it has a lock. Of course, we don't know whether that is the case with your GPS, since you said nothing about it.

2/ How to steer to the waypoint.

You know where you are. You know where you need to go. From that, you know the direction you need to go. From the compass, you know which way you are going. It should be relatively simple to set the appropriate pins high(er) or low(er) to make that happen. Of course, you told us nothing about the mechanism for steering the boat, so no specifics can't be provided.

3/ How to set the waypoint recognition radius (ie just have to a few meters away is OK).

Only you know how close is close enough, and whether going beyond the waypoint is required. The GPS will continue to provide actual position information, so you should know how far you are from the waypoint.

The GPS I am using is an EM406. I expected to only use the compas in order to calculate the waypoint. The waypoint lat & long is calculated while the boat is sitting on the shore. This part is working OK. I do not think using the compas when the boat is under way would be practical because there will be a lot of tilting of the compas due to wave motion.

I thought the steering could be done just from the GPS data & the waypoint co ordinates. The steering will be by a standard RC servo.

What I need is a sketch that will take GPS data, and create a servo signal for steering. I understand what needs to be done but my (lack of) programming skill make it a difficult task. Thanks for your interest.

GPS will not tell you which way you're heading until you get a few readings from it and calculate for yourself. I think the compass is still useful for "which way to go" type of question. I would concentrate on a routine that takes a required direction to head and read compass then steer towards that direction. Once you have it, you can try to use GPS to to tell you how far away you are and calculate a dynamic orientation your boat needs to head and update that routine with the new angle.

But overall I think it's very difficult. The GPS is not accurate possible +-2m range error at least and you have to travel on large open water (lake) in order to accept the error in position determination. If the boat is under motion, you can always average your compass. It's like if you were on the boat yourself and read an actual compass, you would be averaging with your estimates as well.

I thought the steering could be done just from the GPS data & the waypoint co ordinates.
The steering will be by a standard RC servo.

I suppose it depends on how accurate and responsive you want to be. What is the resolution of your GPS? How close to the waypoint do you need to be?

Given just the two lat/lon values - waypoint and current position - you can determine the direction the boat needs to go. You can get heading from the GPS, I guess, though it might suffer the same issue as the compass, from the wave action.

What I need is a sketch that will take GPS data, and create a servo signal for steering.

How is the servo mounted? What kind of servo is it? What does the servo move? Only you know these details, so only you can convert actual heading vs. desired heading into data to make the servo move the boat in the desired direction.