Hi,
I need to extract the lat/long from the gps string $GPGGA and be able to set them directly to variables

any suggestions how to do this?

-as in all i want is to be able to say A=3124.3312 and B=11544.4337

Thanks, Justin

Views: 124

Reply to This

Replies to This Discussion

Would TinyGPS be of use here?

I wrote a split() routine that is similar to C strtok() and perl split so that I could read in parameters from a config file:

http://mbed.org/users/shimniok/code/AVC_2012/file/826c6171fc1b/util.c

Examples of using split() here: 

http://mbed.org/users/shimniok/code/AVC_2012/file/826c6171fc1b/Conf...

ive been looking at the tinyGPS code, but it doesnt seem to work for my use in my project.

Um, ok, sure. How about the code snippets I posted? Will those work?

I havent tested it, but from what i can see, it looks fairly clear and i might use some of it (the split code).

thanks, although, is there any other possible suggestions you can think of how to do it? because im not the most fluent in programming, and i might struggle to get it working correctly.

Well... now's a good time to learn :)  I think you'll be fine getting it to work. Just post more questions here and I'll do what I can to help.

What's the ultimate goal here? What are you working on? What are you trying to accomplish with the lat/lon parsing?

I need a little context to be able to help you a little better.

Im building essentially an ardurover, but im using an 'offtheshelf' purchased arduino mega2560.

It includes a gps and compass... so what im trying to do by finding these lat and long values is mathematically work out heading and steer until the rover faces exactly the desired heading then accelerate. -resulting in basic navigation between two points.

So yeh, essentially the maths coding needs the values only of the
lat and long of its current location, extracted from the nmea string, to give bearing from current location to desired location.

Ok, gotcha.

If you are programming using Arduino environment one option is to use TinyGPS. It parses NMEA output and you can then query lat/lon and ignore the rest.

Otherwise, you have to work out how to get the string into memory to parse, then run the parsing code to split it up. What I posted assumed the string was in memory already (which is a separate problem).

It's best to take baby steps, working on a tiny chunk of the problem at a time. Set a variable equal to a test string, then work on the function to parse it and return back lat and lon.

There's a lot to talk through to roll your own when you have minimal programming experience. Not sure if this is the right place to have that chat. So if you want we can talk through email: http://www.bot-thoughts.com/2007/01/contact-me.html

hi, just letting you know i got it working, and i have the exact value printing out on my serial connection. thanks

RSS

Social Networking

Contests

Season Two of the Trust Time Trial (T3) Contest has now begun. The fourth round is an accuracy round for multicopters, which requires contestants to fly a cube. The deadline is April 14th.

A list of all T3 contests is here

Groups

Advertisement

© 2013   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service