sparkfun / SparkFun_u-blox_GNSS_Arduino_Library

An Arduino library which allows you to communicate seamlessly with the full range of u-blox GNSS modules
Other
225 stars 99 forks source link

getPositionAccuracy() not returning correct values ? #6

Closed Niv1900 closed 3 years ago

Niv1900 commented 3 years ago

Hi @PaulZC,

Thank you for this 2.0.x version. I'm quite a "baby user" here since it's my first issue that I post on github...

I'm having some trouble to use the getPositionAccuracy() function. I'll try to not miss any piece of information.

Workbench

Steps to reproduce

Ok so I'm quite a begginer here, so what I do is that I get all the info I need and put them into a struct for a use in another task, here is my GNSS Task :

void xT_GNSS(void *pvParameters)
{
    TickType_t xLastWakeTime_GNSS;
    xLastWakeTime_GNSS = xTaskGetTickCount();

    while (1)
    {
        vTaskDelayUntil(&xLastWakeTime_GNSS, Tck_GNSS);

        F.GNSS.fix           = myGNSS.getGnssFixOk();
        F.GNSS.latitude      = myGNSS.getLatitude();
        F.GNSS.longitude     = myGNSS.getLongitude();
        F.GNSS.altitude      = myGNSS.getAltitude();
        F.GNSS.fixType       = myGNSS.getFixType();
        F.GNSS.groundSpeed   = myGNSS.getGroundSpeed();
        F.GNSS.heading       = myGNSS.getHeading();
        F.GNSS.PDOP          = myGNSS.getPDOP();
        F.GNSS.SIV           = myGNSS.getSIV();
        F.GNSS.year          = myGNSS.getYear();
        F.GNSS.month         = myGNSS.getMonth();
        F.GNSS.day           = myGNSS.getDay();
        F.GNSS.hour          = myGNSS.getHour();
        F.GNSS.minute        = myGNSS.getMinute();
        F.GNSS.second        = myGNSS.getSecond();
        F.GNSS.millisecond   = myGNSS.getMillisecond();
        F.GNSS.nanosecond    = myGNSS.getNanosecond();
        F.GNSS.PosACC        = myGNSS.getPositionAccuracy(); //? not working :(
    }

    vTaskDelete(NULL);
}

Expected behavior

To have a correct value returned by the getPositionAccuracy() function.

Actual behavior

getPositionAccuracy() function return a very strange result (like 107341414, even if my PDOP is quite near 1).

F.GNSS.PosACC = myGNSS.getPositionAccuracy();

When this line of code is commented I have noticed that everything run faster :

Here it's when getPositionAccuracy() is used : lent

And here it's when getPositionAccuracy() is not being used : rapide

(the delta time between each line is around 18ms for both example)

So does a maxdelay is being triggered and then the operation to get the position accuracy is cancelled ?

Thank you, if the problem is only related to the fact that I'm using the NEO-M8N I'm really sorry for creating this issue...

Niv1900 commented 3 years ago

I'm really sorry to have polluted this repo with a real false issue.

While reading _SparkFun_u-blox_GNSS_ArduinoLibrary.h this function is only valid for NEO-M8P and ZED-F9P.

I need to use getHorizontalAccEst() and getVerticalAccEst() since getHorizontalAccuracy() and getVerticalAccuracy() have the same behaviour as getPositionAccuracy().

PaulZC commented 3 years ago

Hi @Niv1900 ,

(We have a saying: "There is no such thing as a silly question." Please don't worry about asking questions. We are all learning!)

Your main issue is that getPositionAccuracy comes from the NAV-HPPOSECEF message (which is only supported on u-blox "high precision" modules). Likewise getHorizontalAccuracy and getVerticalAccuracy come from NAV-HPPOSLLH (which is also "high precision").

getHorizontalAccEst and getVerticalAccEst come from the standard NAV-PVT message - which your NEO does support.

The reason you were seeing an extra delay in your code, is that NAV-PVT was being requested, then NAV-HPPOSECEF was being requested. The NAV-HPPOSECEF request would be NACK'd (Not ACKnowledged), which would take the extra time.

Please have a look at the NAV-PVT Callback example. You may be able to use the UBX_NAV_PVT_data_t struct directly in your ESP code?

Good luck with your project, Paul

Niv1900 commented 3 years ago

Thank you very much for your answer, everything is crystal clear now.

Oh indeed, the callback system looks nice, I have to play with it !

Looking forward to using this library, thank you @PaulZC.