GPS Way Point Navigation Routine / Object Needed
SteveWoodrough
Posts: 190
Hello and Happy New Year.
Good progress is being made on my Magellan Project. See attachements below. Since you all have provided such sound advice in the past, I'm back at the well of knowledge.
I need guidance on an algorithim / method / object that allows me to calculate the required heading to get from one GPS way point to another. I looked on the OBEX, and I'm not even sure what you would call this.
What I'm looking for is a simple, reliable routine that says, "Based on the current GPS data, I am here and I need to go this far in this direction to get where I want to be."
Thanks for your help!
Steve
http://forums.parallax.com/showthread.php?144101-Robo-Magellan-**New-Video**
http://www.youtube.com/watch?v=ft1SFeAYVuI
Good progress is being made on my Magellan Project. See attachements below. Since you all have provided such sound advice in the past, I'm back at the well of knowledge.
I need guidance on an algorithim / method / object that allows me to calculate the required heading to get from one GPS way point to another. I looked on the OBEX, and I'm not even sure what you would call this.
What I'm looking for is a simple, reliable routine that says, "Based on the current GPS data, I am here and I need to go this far in this direction to get where I want to be."
Thanks for your help!
Steve
http://forums.parallax.com/showthread.php?144101-Robo-Magellan-**New-Video**
http://www.youtube.com/watch?v=ft1SFeAYVuI
Comments
I believe the formulas are available with a fairly easy search.
Here is an example I found right away: http://www.flightgear.org/forums/viewtopic.php?t=13415
And, here is an example of a whole program written in C that does exactly what you want: http://www.acroname.com/examples/10071/10071.html#e16
However, I don't think we have the trig functions in spin (I could be wrong), or the necessary floating point math (I think I've seen references to that, though).
What we need to do is:
determine the heading to the waypoint from our current position provided by the on board GPS.
steer to that point using the compass to continually correct our heading (which you already have) to match the calculated one, while continually re-calculating the heading using the formula. It really isn't that hard - heck I did it 20+ years ago and I'm not a math guy. I have to think that someone on here has already done something similar and you might just find something on OBEX
I'm going to do some more searching and see what I can find. I'll come back here with anything I come up with.
Good Luck,
Don
http://obex.parallax.com/objects/405/
http://obex.parallax.com/objects/406/
Don
It really depends on your navigation needs.
I posted in the past an object doing integer navigation using a cartesian planar projection.
The integer conversion is probably not really nice, but this way you are not loosing anything in the first conversions.
The formulas for the planar projection are very easy, and in you prefer you can probably use a float object to do the math.
forums.parallax.com/showthread.php?128884-integer-only-GPS-navigation-object
Massimo
Also, I started another project called the Shackable Scavenger Hunt that has cleaned up code and allows for multiple locations to be loaded and targeted. However, that code only does distance from two points, not direction, so it won't give you want you are looking for. When that project is finished (someday) it will utilize mostly Parallax authored objects to streamline learning for others. My code currently originated from a few different custom objects that were created by others but never released as formal objects.
:-) I'm with you!!
Massimo
http://forums.parallax.com/showthread.php?122260-Quick-and-dirty-four-quadrant-integer-only-arctangent-in-Spin&highlight=atan2
I'm basically assuming that the world is flat and square, and therefore each degree minute is just a point on a cartesian plane.
Direction comes from Phil and the range to the target comes from Pythagoras.
I had to do a little trick to align the unit circle with the compass, and some algrebra since the unit circle goes one way and the compass the other. That's documented in the attachment.
I just drive like heck along an azimuth until the range gets to within some acceptable level.
The pureist may cringe, but it works, see video below.
https://www.youtube.com/watch?v=M8u0VsNM0II
Thanks!!
Steve
A prime angle difference in latitude is a nautical mile, while this is true for longitude only as long as you are on the equator, otherwise the distance reduces.
Massimo