Shop OBEX P1 Docs P2 Docs Learn Events
GPS Way Point Navigation Routine / Object Needed — Parallax Forums

GPS Way Point Navigation Routine / Object Needed

SteveWoodroughSteveWoodrough Posts: 190
edited 2013-01-08 00:00 in General Discussion
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

Comments

  • dmagnusdmagnus Posts: 271
    edited 2013-01-01 10:36
    This is a cool project and I'm very interested in how it turns out. Many years ago, when I was first investigating GPS (around 1990 or so) I was curious about how to do exactly the same thing. I dug around (no internet yet) and found a friend who gave me the formulas for it. His formulas used spherical trigonometry and it took me awhile to program it in an old Z-80 based computer using a form of Basic.
    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
  • dmagnusdmagnus Posts: 271
    edited 2013-01-01 10:46
    Ok, found these on OBEX. Might be what you need:
    http://obex.parallax.com/objects/405/
    http://obex.parallax.com/objects/406/
    Don
  • max72max72 Posts: 1,155
    edited 2013-01-01 13:38
    Hi,
    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
  • SteveWoodroughSteveWoodrough Posts: 190
    edited 2013-01-01 14:19
    Boy that sounds like the ticket, Integer and cartesian let me check out ASAP. I can understand the need for whiz bang math for real live sperical coordinates, and long range navigation. My batteries will run out before I ever get close to being off plane. As far as I'm concerned the world is flat and possibly square.
  • WBA ConsultingWBA Consulting Posts: 2,934
    edited 2013-01-01 16:45
    Yes, it can be done easily with the Propeller. Great Circle Math is not a cake walk for the Prop, but with the proper objects it muscles its way through just fine. I have a handheld GPS project that has code that provides direction and distance to a hardcoded destination from your current GPS provided position. It can be found on this thread here.

    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.
  • max72max72 Posts: 1,155
    edited 2013-01-02 06:32
    As far as I'm concerned the world is flat and possibly square.

    :-) I'm with you!!

    Massimo
  • ercoerco Posts: 20,259
    edited 2013-01-02 09:43
  • SteveWoodroughSteveWoodrough Posts: 190
    edited 2013-01-07 18:35
    Thanks guys. I got a tip to checkout this thread link below written by Phil Pilgrim, and wrote the attached application to play with it. Phil Pilgrims Arctan code works like a charm!

    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
  • max72max72 Posts: 1,155
    edited 2013-01-08 00:00
    Just a note: when doing the transformation you should scale latitude axis: deltalongitude:=deltalongitude * cos (latitude)
    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
Sign In or Register to comment.