Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit c60ebc4

Browse files
committed
Adding resetIMUalignment and helper functions for ESF. Correcting initPacketUBXESFSTATUS
1 parent 336a7cd commit c60ebc4

File tree

2 files changed

+58
-32
lines changed

2 files changed

+58
-32
lines changed

src/SparkFun_Ublox_Arduino_Library.cpp

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4180,6 +4180,7 @@ boolean SFE_UBLOX_GPS::resetOdometer(uint16_t maxWait)
41804180
packetCfg.len = 0;
41814181
packetCfg.startingSpot = 0;
41824182

4183+
// This is a special case as we are only expecting an ACK but this is not a CFG message
41834184
return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
41844185
}
41854186

@@ -4239,6 +4240,18 @@ boolean SFE_UBLOX_GPS::isGNSSenabled(sfe_ublox_gnss_ids_e id, uint16_t maxWait)
42394240
return (retVal);
42404241
}
42414242

4243+
//Reset ESF automatic IMU-mount alignment
4244+
boolean SFE_UBLOX_GPS::resetIMUalignment(uint16_t maxWait)
4245+
{
4246+
packetCfg.cls = UBX_CLASS_ESF;
4247+
packetCfg.id = UBX_ESF_RESETALG;
4248+
packetCfg.len = 0;
4249+
packetCfg.startingSpot = 0;
4250+
4251+
// This is a special case as we are only expecting an ACK but this is not a CFG message
4252+
return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
4253+
}
4254+
42424255
// CONFIGURATION INTERFACE (protocol v27 and above)
42434256

42444257
//Form 32-bit key from group/id/size
@@ -4728,7 +4741,6 @@ boolean SFE_UBLOX_GPS::setAutoNAVPOSECEF(boolean enable, boolean implicitUpdate,
47284741
}
47294742

47304743
//Enable automatic navigation message generation by the GNSS.
4731-
//Data is passed to the callback in packetUBXNAVPOSECEFcopy.
47324744
boolean SFE_UBLOX_GPS::setAutoNAVPOSECEFcallback(void (*callbackPointer)(UBX_NAV_POSECEF_data_t), uint16_t maxWait)
47334745
{
47344746
// Enable auto messages. Set implicitUpdate to false as we expect the user to call checkUblox manually.
@@ -4877,7 +4889,6 @@ boolean SFE_UBLOX_GPS::setAutoNAVSTATUS(boolean enable, boolean implicitUpdate,
48774889
}
48784890

48794891
//Enable automatic navigation message generation by the GNSS.
4880-
//Data is passed to the callback in packetUBXNAVSTATUScopy.
48814892
boolean SFE_UBLOX_GPS::setAutoNAVSTATUScallback(void (*callbackPointer)(UBX_NAV_STATUS_data_t), uint16_t maxWait)
48824893
{
48834894
// Enable auto messages. Set implicitUpdate to false as we expect the user to call checkUblox manually.
@@ -5048,7 +5059,6 @@ boolean SFE_UBLOX_GPS::setAutoDOP(boolean enable, boolean implicitUpdate, uint16
50485059
}
50495060

50505061
//Enable automatic navigation message generation by the GNSS.
5051-
//Data is passed to the callback in packetUBXNAVDOPcopy.
50525062
boolean SFE_UBLOX_GPS::setAutoDOPcallback(void (*callbackPointer)(UBX_NAV_DOP_data_t), uint16_t maxWait)
50535063
{
50545064
// Enable auto messages. Set implicitUpdate to false as we expect the user to call checkUblox manually.
@@ -5198,7 +5208,6 @@ boolean SFE_UBLOX_GPS::setAutoNAVATT(boolean enable, boolean implicitUpdate, uin
51985208
}
51995209

52005210
//Enable automatic navigation message generation by the GNSS.
5201-
//Data is passed to the callback in packetUBXNAVATTcopy.
52025211
boolean SFE_UBLOX_GPS::setAutoNAVATTcallback(void (*callbackPointer)(UBX_NAV_ATT_data_t), uint16_t maxWait)
52035212
{
52045213
// Enable auto messages. Set implicitUpdate to false as we expect the user to call checkUblox manually.
@@ -5520,7 +5529,6 @@ boolean SFE_UBLOX_GPS::setAutoNAVODO(boolean enable, boolean implicitUpdate, uin
55205529
}
55215530

55225531
//Enable automatic navigation message generation by the GNSS.
5523-
//Data is passed to the callback in packetUBXNAVODOcopy.
55245532
boolean SFE_UBLOX_GPS::setAutoNAVODOcallback(void (*callbackPointer)(UBX_NAV_ODO_data_t), uint16_t maxWait)
55255533
{
55265534
// Enable auto messages. Set implicitUpdate to false as we expect the user to call checkUblox manually.
@@ -5668,7 +5676,6 @@ boolean SFE_UBLOX_GPS::setAutoNAVVELECEF(boolean enable, boolean implicitUpdate,
56685676
}
56695677

56705678
//Enable automatic navigation message generation by the GNSS.
5671-
//Data is passed to the callback in packetUBXNAVVELECEFcopy.
56725679
boolean SFE_UBLOX_GPS::setAutoNAVVELECEFcallback(void (*callbackPointer)(UBX_NAV_VELECEF_data_t), uint16_t maxWait)
56735680
{
56745681
// Enable auto messages. Set implicitUpdate to false as we expect the user to call checkUblox manually.
@@ -5816,7 +5823,6 @@ boolean SFE_UBLOX_GPS::setAutoNAVVELNED(boolean enable, boolean implicitUpdate,
58165823
}
58175824

58185825
//Enable automatic navigation message generation by the GNSS.
5819-
//Data is passed to the callback in packetUBXNAVVELNEDcopy.
58205826
boolean SFE_UBLOX_GPS::setAutoNAVVELNEDcallback(void (*callbackPointer)(UBX_NAV_VELNED_data_t), uint16_t maxWait)
58215827
{
58225828
// Enable auto messages. Set implicitUpdate to false as we expect the user to call checkUblox manually.
@@ -5964,7 +5970,6 @@ boolean SFE_UBLOX_GPS::setAutoNAVHPPOSECEF(boolean enable, boolean implicitUpdat
59645970
}
59655971

59665972
//Enable automatic navigation message generation by the GNSS.
5967-
//Data is passed to the callback in packetUBXNAVHPPOSECEFcopy.
59685973
boolean SFE_UBLOX_GPS::setAutoNAVHPPOSECEFcallback(void (*callbackPointer)(UBX_NAV_HPPOSECEF_data_t), uint16_t maxWait)
59695974
{
59705975
// Enable auto messages. Set implicitUpdate to false as we expect the user to call checkUblox manually.
@@ -6134,7 +6139,6 @@ boolean SFE_UBLOX_GPS::setAutoHPPOSLLH(boolean enable, boolean implicitUpdate, u
61346139
}
61356140

61366141
//Enable automatic navigation message generation by the GNSS.
6137-
//Data is passed to the callback in packetUBXNAVHPPOSLLHcopy.
61386142
boolean SFE_UBLOX_GPS::setAutoHPPOSLLHcallback(void (*callbackPointer)(UBX_NAV_HPPOSLLH_data_t), uint16_t maxWait)
61396143
{
61406144
// Enable auto messages. Set implicitUpdate to false as we expect the user to call checkUblox manually.
@@ -6282,7 +6286,6 @@ boolean SFE_UBLOX_GPS::setAutoNAVCLOCK(boolean enable, boolean implicitUpdate, u
62826286
}
62836287

62846288
//Enable automatic navigation message generation by the GNSS.
6285-
//Data is passed to the callback in packetUBXNAVCLOCKcopy.
62866289
boolean SFE_UBLOX_GPS::setAutoNAVCLOCKcallback(void (*callbackPointer)(UBX_NAV_CLOCK_data_t), uint16_t maxWait)
62876290
{
62886291
// Enable auto messages. Set implicitUpdate to false as we expect the user to call checkUblox manually.
@@ -6482,7 +6485,6 @@ boolean SFE_UBLOX_GPS::setAutoRELPOSNED(boolean enable, boolean implicitUpdate,
64826485
}
64836486

64846487
//Enable automatic navigation message generation by the GNSS.
6485-
//Data is passed to the callback in packetUBXNAVRELPOSNEDcopy.
64866488
boolean SFE_UBLOX_GPS::setAutoRELPOSNEDcallback(void (*callbackPointer)(UBX_NAV_RELPOSNED_data_t), uint16_t maxWait)
64876489
{
64886490
// Enable auto messages. Set implicitUpdate to false as we expect the user to call checkUblox manually.
@@ -6630,7 +6632,6 @@ boolean SFE_UBLOX_GPS::setAutoRXMSFRBX(boolean enable, boolean implicitUpdate, u
66306632
}
66316633

66326634
//Enable automatic navigation message generation by the GNSS.
6633-
//Data is passed to the callback in packetUBXRXMSFRBXcopy.
66346635
boolean SFE_UBLOX_GPS::setAutoRXMSFRBXcallback(void (*callbackPointer)(UBX_RXM_SFRBX_data_t), uint16_t maxWait)
66356636
{
66366637
// Enable auto messages. Set implicitUpdate to false as we expect the user to call checkUblox manually.
@@ -6778,7 +6779,6 @@ boolean SFE_UBLOX_GPS::setAutoRXMRAWX(boolean enable, boolean implicitUpdate, ui
67786779
}
67796780

67806781
//Enable automatic navigation message generation by the GNSS.
6781-
//Data is passed to the callback in packetUBXRXMRAWXcopy.
67826782
boolean SFE_UBLOX_GPS::setAutoRXMRAWXcallback(void (*callbackPointer)(UBX_RXM_RAWX_data_t), uint16_t maxWait)
67836783
{
67846784
// Enable auto messages. Set implicitUpdate to false as we expect the user to call checkUblox manually.
@@ -6986,7 +6986,6 @@ boolean SFE_UBLOX_GPS::setAutoTIMTM2(boolean enable, boolean implicitUpdate, uin
69866986
}
69876987

69886988
//Enable automatic navigation message generation by the GNSS.
6989-
//Data is passed to the callback in packetUBXTIMTM2copy.
69906989
boolean SFE_UBLOX_GPS::setAutoTIMTM2callback(void (*callbackPointer)(UBX_TIM_TM2_data_t), uint16_t maxWait)
69916990
{
69926991
// Enable auto messages. Set implicitUpdate to false as we expect the user to call checkUblox manually.
@@ -7061,6 +7060,11 @@ void SFE_UBLOX_GPS::logTIMTM2(boolean enabled)
70617060
// ***** ESF ALG automatic support
70627061

70637062
boolean SFE_UBLOX_GPS::getEsfAlignment(uint16_t maxWait)
7063+
{
7064+
return (getESFALG(maxWait));
7065+
}
7066+
7067+
boolean SFE_UBLOX_GPS::getESFALG(uint16_t maxWait)
70647068
{
70657069
if (packetUBXESFALG == NULL) initPacketUBXESFALG(); //Check that RAM has been allocated for the ESF alignment data
70667070
if (packetUBXESFALG == NULL) //Only attempt this if RAM allocation was successful
@@ -7158,7 +7162,6 @@ boolean SFE_UBLOX_GPS::setAutoESFALG(boolean enable, boolean implicitUpdate, uin
71587162
}
71597163

71607164
//Enable automatic navigation message generation by the GNSS.
7161-
//Data is passed to the callback in packetUBXESFALGcopy.
71627165
boolean SFE_UBLOX_GPS::setAutoESFALGcallback(void (*callbackPointer)(UBX_ESF_ALG_data_t), uint16_t maxWait)
71637166
{
71647167
// Enable auto messages. Set implicitUpdate to false as we expect the user to call checkUblox manually.
@@ -7233,6 +7236,11 @@ void SFE_UBLOX_GPS::logESFALG(boolean enabled)
72337236
// ***** ESF STATUS automatic support
72347237

72357238
boolean SFE_UBLOX_GPS::getEsfInfo(uint16_t maxWait)
7239+
{
7240+
return (getESFSTATUS(maxWait));
7241+
}
7242+
7243+
boolean SFE_UBLOX_GPS::getESFSTATUS(uint16_t maxWait)
72367244
{
72377245
if (packetUBXESFSTATUS == NULL) initPacketUBXESFSTATUS(); //Check that RAM has been allocated for the ESF status data
72387246
if (packetUBXESFSTATUS == NULL) //Only attempt this if RAM allocation was successful
@@ -7330,7 +7338,6 @@ boolean SFE_UBLOX_GPS::setAutoESFSTATUS(boolean enable, boolean implicitUpdate,
73307338
}
73317339

73327340
//Enable automatic navigation message generation by the GNSS.
7333-
//Data is passed to the callback in packetUBXESFSTATUScopy.
73347341
boolean SFE_UBLOX_GPS::setAutoESFSTATUScallback(void (*callbackPointer)(UBX_ESF_STATUS_data_t), uint16_t maxWait)
73357342
{
73367343
// Enable auto messages. Set implicitUpdate to false as we expect the user to call checkUblox manually.
@@ -7375,15 +7382,16 @@ boolean SFE_UBLOX_GPS::assumeAutoESFSTATUS(boolean enabled, boolean implicitUpda
73757382
boolean SFE_UBLOX_GPS::initPacketUBXESFSTATUS()
73767383
{
73777384
packetUBXESFSTATUS = new UBX_ESF_STATUS_t; //Allocate RAM for the main struct
7385+
73787386
if (packetUBXESFSTATUS == NULL)
73797387
{
73807388
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
73817389
_debugSerial->println(F("initPacketUBXESFSTATUS: PANIC! RAM allocation failed! This will end _very_ badly..."));
73827390
return (false);
73837391
}
73847392
packetUBXESFSTATUS->automaticFlags.flags.all = 0;
7385-
packetUBXNAVSTATUS->callbackPointer = NULL;
7386-
packetUBXNAVSTATUS->callbackData = NULL;
7393+
packetUBXESFSTATUS->callbackPointer = NULL;
7394+
packetUBXESFSTATUS->callbackData = NULL;
73877395
packetUBXESFSTATUS->moduleQueried.moduleQueried.all = 0;
73887396
return (true);
73897397
}
@@ -7405,6 +7413,11 @@ void SFE_UBLOX_GPS::logESFSTATUS(boolean enabled)
74057413
// ***** ESF INS automatic support
74067414

74077415
boolean SFE_UBLOX_GPS::getEsfIns(uint16_t maxWait)
7416+
{
7417+
return (getESFINS(maxWait));
7418+
}
7419+
7420+
boolean SFE_UBLOX_GPS::getESFINS(uint16_t maxWait)
74087421
{
74097422
if (packetUBXESFINS == NULL) initPacketUBXESFINS(); //Check that RAM has been allocated for the ESF INS data
74107423
if (packetUBXESFINS == NULL) //Only attempt this if RAM allocation was successful
@@ -7502,7 +7515,6 @@ boolean SFE_UBLOX_GPS::setAutoESFINS(boolean enable, boolean implicitUpdate, uin
75027515
}
75037516

75047517
//Enable automatic navigation message generation by the GNSS.
7505-
//Data is passed to the callback in packetUBXESFINScopy.
75067518
boolean SFE_UBLOX_GPS::setAutoESFINScallback(void (*callbackPointer)(UBX_ESF_INS_data_t), uint16_t maxWait)
75077519
{
75087520
// Enable auto messages. Set implicitUpdate to false as we expect the user to call checkUblox manually.
@@ -7577,6 +7589,11 @@ void SFE_UBLOX_GPS::logESFINS(boolean enabled)
75777589
// ***** ESF MEAS automatic support
75787590

75797591
boolean SFE_UBLOX_GPS::getEsfDataInfo(uint16_t maxWait)
7592+
{
7593+
return (getESFMEAS(maxWait));
7594+
}
7595+
7596+
boolean SFE_UBLOX_GPS::getESFMEAS(uint16_t maxWait)
75807597
{
75817598
if (packetUBXESFMEAS == NULL) initPacketUBXESFMEAS(); //Check that RAM has been allocated for the ESF MEAS data
75827599
if (packetUBXESFMEAS == NULL) //Only attempt this if RAM allocation was successful
@@ -7674,7 +7691,6 @@ boolean SFE_UBLOX_GPS::setAutoESFMEAS(boolean enable, boolean implicitUpdate, ui
76747691
}
76757692

76767693
//Enable automatic navigation message generation by the GNSS.
7677-
//Data is passed to the callback in packetUBXESFMEAScopy.
76787694
boolean SFE_UBLOX_GPS::setAutoESFMEAScallback(void (*callbackPointer)(UBX_ESF_MEAS_data_t), uint16_t maxWait)
76797695
{
76807696
// Enable auto messages. Set implicitUpdate to false as we expect the user to call checkUblox manually.
@@ -7749,6 +7765,11 @@ void SFE_UBLOX_GPS::logESFMEAS(boolean enabled)
77497765
// ***** ESF RAW automatic support
77507766

77517767
boolean SFE_UBLOX_GPS::getEsfRawDataInfo(uint16_t maxWait)
7768+
{
7769+
return (getESFRAW(maxWait));
7770+
}
7771+
7772+
boolean SFE_UBLOX_GPS::getESFRAW(uint16_t maxWait)
77527773
{
77537774
if (packetUBXESFRAW == NULL) initPacketUBXESFRAW(); //Check that RAM has been allocated for the ESF RAW data
77547775
if (packetUBXESFRAW == NULL) //Only attempt this if RAM allocation was successful
@@ -7846,7 +7867,6 @@ boolean SFE_UBLOX_GPS::setAutoESFRAW(boolean enable, boolean implicitUpdate, uin
78467867
}
78477868

78487869
//Enable automatic navigation message generation by the GNSS.
7849-
//Data is passed to the callback in packetUBXESFRAWcopy.
78507870
boolean SFE_UBLOX_GPS::setAutoESFRAWcallback(void (*callbackPointer)(UBX_ESF_RAW_data_t), uint16_t maxWait)
78517871
{
78527872
// Enable auto messages. Set implicitUpdate to false as we expect the user to call checkUblox manually.
@@ -8023,7 +8043,6 @@ boolean SFE_UBLOX_GPS::setAutoHNRAtt(boolean enable, boolean implicitUpdate, uin
80238043
}
80248044

80258045
//Enable automatic navigation message generation by the GNSS.
8026-
//Data is passed to the callback in packetUBXHNRATTcopy.
80278046
boolean SFE_UBLOX_GPS::setAutoHNRAttcallback(void (*callbackPointer)(UBX_HNR_ATT_data_t), uint16_t maxWait)
80288047
{
80298048
// Enable auto messages. Set implicitUpdate to false as we expect the user to call checkUblox manually.
@@ -8201,7 +8220,6 @@ boolean SFE_UBLOX_GPS::setAutoHNRDyn(boolean enable, boolean implicitUpdate, uin
82018220
}
82028221

82038222
//Enable automatic navigation message generation by the GNSS.
8204-
//Data is passed to the callback in packetUBXHNRINScopy.
82058223
boolean SFE_UBLOX_GPS::setAutoHNRDyncallback(void (*callbackPointer)(UBX_HNR_INS_data_t), uint16_t maxWait)
82068224
{
82078225
// Enable auto messages. Set implicitUpdate to false as we expect the user to call checkUblox manually.
@@ -8378,7 +8396,6 @@ boolean SFE_UBLOX_GPS::setAutoHNRPVT(boolean enable, boolean implicitUpdate, uin
83788396
}
83798397

83808398
//Enable automatic navigation message generation by the GNSS.
8381-
//Data is passed to the callback in packetUBXHNRPVTcopy.
83828399
boolean SFE_UBLOX_GPS::setAutoHNRPVTcallback(void (*callbackPointer)(UBX_HNR_PVT_data_t), uint16_t maxWait)
83838400
{
83848401
// Enable auto messages. Set implicitUpdate to false as we expect the user to call checkUblox manually.
@@ -9411,7 +9428,7 @@ boolean SFE_UBLOX_GPS::getSensorFusionMeasurement(UBX_ESF_MEAS_sensorData_t *sen
94119428
return (false);
94129429

94139430
if (packetUBXESFMEAS->moduleQueried.moduleQueried.bits.data & (1 << sensor) == 0)
9414-
getEsfDataInfo(maxWait);
9431+
getESFMEAS(maxWait);
94159432
packetUBXESFMEAS->moduleQueried.moduleQueried.bits.data &= ~(1 << sensor); //Since we are about to give this to user, mark this data as stale
94169433
packetUBXESFMEAS->moduleQueried.moduleQueried.bits.all = false;
94179434
sensorData->data.all = packetUBXESFMEAS->data.data[sensor].data.all;
@@ -9431,7 +9448,7 @@ boolean SFE_UBLOX_GPS::getRawSensorMeasurement(UBX_ESF_RAW_sensorData_t *sensorD
94319448
return (false);
94329449

94339450
if (packetUBXESFRAW->moduleQueried.moduleQueried.bits.data & (1 << sensor) == 0)
9434-
getEsfRawDataInfo(maxWait);
9451+
getESFRAW(maxWait);
94359452
packetUBXESFRAW->moduleQueried.moduleQueried.bits.data &= ~(1 << sensor); //Since we are about to give this to user, mark this data as stale
94369453
packetUBXESFRAW->moduleQueried.moduleQueried.bits.all = false;
94379454
sensorData->data.all = packetUBXESFRAW->data.data[sensor].data.all;
@@ -9453,7 +9470,7 @@ boolean SFE_UBLOX_GPS::getSensorFusionStatus(UBX_ESF_STATUS_sensorStatus_t *sens
94539470
return (false);
94549471

94559472
if (packetUBXESFSTATUS->moduleQueried.moduleQueried.bits.status & (1 << sensor) == 0)
9456-
getEsfInfo(maxWait);
9473+
getESFSTATUS(maxWait);
94579474
packetUBXESFSTATUS->moduleQueried.moduleQueried.bits.status &= ~(1 << sensor); //Since we are about to give this to user, mark this data as stale
94589475
packetUBXESFSTATUS->moduleQueried.moduleQueried.bits.all = false;
94599476
sensorStatus->sensStatus1.all = packetUBXESFSTATUS->data.status[sensor].sensStatus1.all;

0 commit comments

Comments
 (0)