Any time the plane approached or passed 0 degrees the AP would tell my emulator to turn hard left, then hard right, then hard left and sometimes would get stuck in this cycle (not the sine wave I posted yesterday) but a very tight sine wave only varying about 10 to 40 degrees before snapping back hard the other direction.
Finally, I started looking at the NMEA parsing code in the AP source. It turns out, there are 2 atoi() function calls for ground_speed and ground_course in the GPRMC parsing routine. Simply changing atoi to atof completely solves the problem. I assume it's a rounding issue and since the GPS sends one decimal place after the degrees, this decimal place was getting rounded to an integer and then multiplied by 100. I believe this bug has been there since the very beginning when the NMEA parsing routine was first written. I wouldn't have guessed that one decimal point would make such a difference!
Comments
I had found a earlier rev of this document but the command set but did not have info on "Navigation data message" thats when I gave up and started playing with NMEA.
I hate to abandon the idea of streamlining NMEA parsing to only GPGGA messages but the binary protocol is likely the better choice.
Not sure if it will be any easer to get from ECEF domain to SOG, COG. Will have to ponder that a bit. Cant get away from doing trig can I :)
Thanks again.
Troy
I have been working the NMEA issues with ArduPilot. Troy, you can find the Venus Binary command set here:
http://www.sparkfun.com/datasheets/GPS/Modules/AN0003_v1.4.14_Flash...
The Venus is a nice GPS chip, I am using it as well. If you have a look at the binary protocol you will find that SOG and COG is not included, it is instead ECEF Velocity information and ECEF location information. Also, as you so aptly pointed out, the GPS is operating in a slightly more complex coordinate frame than a plane. The use of RMC is probably a good idea.
Also note that the binary protocol is 59 bytes per packet, not much larger than the NMEA sentence itself. So from a size perspective there is little advantage to using it over the NMEA equivalent. There is additional accuracy information that could be really useful but for practical purposes it is not.
Juampa, note that the maximum size of the NMEA sentence is 82 bytes with the payload a maximum of 79 bytes. So the buffer should be two more bytes larger to ensure compliance with the standard. Multipart sentences have a smaller size.
I also found that the VTG parsing was not correct. The NMEA standard does not mandage spaces after the comma delimited value and this will cause parsing errors.
Logan
Troy, try googling Arduino lat long heading
I'm sure there's some pretty simple math to calculate heading.
http://www.vimeo.com/15788869
I could probably set some scaling factors for longitude and latitude when the GPS first gets a lock and then use a flat rectangle earth assumption from then on. Most flights in local area wouldn't get far off. Can only make short flights in Greenland :) .
Any way I will still log some NIMA data and play with replacing GPRMC with calculated values from GPGGA.
I'm using BUF_LEN 80, more than enough.
I just put this code on the end of fast_loop() to get 5Hz without drops. medium_loop is not fast enough.
#if GPS_PROTOCOL == 0
update_GPS();
#endif
I'll upload a video to show it working on my Easy Star with ailerons mod.