Shop OBEX P1 Docs P2 Docs Learn Events
GPS Direction — Parallax Forums

GPS Direction

halfblinddadohalfblinddado Posts: 59
edited 2008-02-29 19:34 in BASIC Stamp
Hello,

I am building a robot that will allow me to take 2 sets of GPS coordinates and navigate from the current position to a destination position.

So far I have put together a Homework board, Parallax GPS module and a serial LCD and have written the code so that I can walk around and read the GPS coordinates on the serial LCD.

What I would like to do next is to calculate the angle from the first set of coordinates to the second. I have looked at the ATAN command but I don't see how I can make it work?

I saw in another post where a FPU was used to calculate the angle but I was wondering if·this is·possible with just the hardware I have?

Thanks,

Mike

Comments

  • skatjskatj Posts: 88
    edited 2008-02-29 01:27
    What's wrong with using an FPU? It is very easy to setup and use.

    Without one, you will have to perform some tricky calculations to work around integer-only math, and with the FPU, your available variable space is almost doubled. (Trust me, you will need it for a GPS navigation algorithm)

    If you don't want to use the FPU, what you'll want to do is completely omit both the degrees and the integer minutes, and work only with the fractional minutes. This is assuming the area you are working in is not extremely large. You can then multiply the fractional minutes by 10,000 or something and still be able to maintain precision with integer-only math.

    P.S. You'll also want a servo controller as well, because the GPS takes 1 second, I believe, to retrieve data in smart mode, meaning that you'll have to stop the servos while performing calculations.

    Btw, I'm not sure if you can do this with just a Basic Stamp 2. I tried and I had to upgrade to the Basic Stamp 2P for its 16,000 bytes of EEPROM (8 times more) and 128 bytes of Scratchpad RAM, to store a waypoint lookup table. My current program probably takes up around 6,000 bytes of EEPROM, but it does have a few extra features but I still think you won't be able to do it with just 2,000 bytes of EEPROM.

    Post Edited (skatj) : 2/29/2008 1:34:52 AM GMT
  • FranklinFranklin Posts: 4,747
    edited 2008-02-29 03:35
    What was the formula you wanted to use?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • halfblinddadohalfblinddado Posts: 59
    edited 2008-02-29 19:34
    I am not nececcessarily adverse to the FPU but I have not used one before. I'm relatively new to basic stamp programming and so I am trying to keep it as simple as possible.

    I found out that the problem I was having with the ATAN command was because I set the VAR size too low and no matter what value I gave it for the coordinates I ended up with positive integers from 0-255. I changed the VARs from bytes to words and now it works the way I expect it to.

    I see your point in upgrading to the 2p. If all the VAR space is taken up by coordinates that does not leave room for much else.

    My plan for the robot is to find the direction to the target coordinates then go in that direction for a short period of time or until it runs into an obstacle. At this point stop, get the current coordinates, calculate the direction again then go in the that direction. Keep doing this until it reaches the target coordinates.

    Thanks,

    Mike
Sign In or Register to comment.