I am trying to use the auto pvt and auto ODO callbacks to preocess speed, heading, altitude, and also odometer readings from the ublox max-M10. The callback for auto PVT works as expected, however the Odometer callback rarely gets called. It does eventually get called, and updates my readings locally, but it is random when it updates. Do i need to call checkUblox twice and specify the Class ID when calling checkUblox(), once for PVT, and once for ODO? any help would be appreciated.
setup
GPS.begin();
GPS.setI2COutput(COM_TYPE_UBX);
GPS.setNavigationFrequency(5);
GPS.enableOdometer();
GPS.resetOdometer();
GPS.setAutoPVTcallbackPtr(&PVT_callback);
GPS.setAutoNAVODOcallbackPtr(&ODO_callback);
…
loop
if (millis() - gps_check > 50) {
gps_check = millis();
GPS.checkUblox(); // Check for the arrival of new data and process it.
GPS.checkCallbacks(); // Check if any callbacks are waiting to be processed.
…
callbacks
void PVT_callback(UBX_NAV_PVT_data_t *ubxDataStruct) {
update_local_data = true;
int32_t speed_raw = ubxDataStruct->gSpeed;
int32_t heading_raw = ubxDataStruct->headMot;
int32_t altitude_raw = ubxDataStruct->hMSL;
altitude = (float)altitude_raw * 0.00328084;
speed = (float)speed_raw * 0.00223694;
heading = (float)heading_raw * 0.00001; }
void ODO_callback(UBX_NAV_ODO_data_t *ubxDataStruct) {
unsigned long distance = ubxDataStruct->distance; // Print the distance
miles = (float)distance * 0.0006213712;
odometer = (previous_odometer + miles);
trip_meter = (previous_trip_meter + miles);
}