Skip to content

Commit 3416a31

Browse files
authoredMar 20, 2023
Merge pull request #186 from sparkfun/release_candidate
Version 2.2.22
2 parents 2ae7289 + 4195674 commit 3416a31

File tree

7 files changed

+319
-8
lines changed

7 files changed

+319
-8
lines changed
 

‎examples/Callbacks/CallbackExample2_NAV_ODO/CallbackExample2_NAV_ODO.ino

+27-6
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
Configuring the GNSS to automatically send odometer reports over I2C and display the data using a callback
33
By: Paul Clark
44
SparkFun Electronics
5-
Date: December 30th, 2020
6-
License: MIT. See license file for more information but you can
7-
basically do whatever you want with this code.
5+
Date: March 20th, 2023
6+
License: MIT. See license file for more information.
87
98
This example shows how to configure the u-blox GNSS to send odometer reports automatically
109
and display the data via a callback. No more polling!
@@ -55,6 +54,8 @@ void printODOdata(UBX_NAV_ODO_data_t *ubxDataStruct)
5554

5655
void setup()
5756
{
57+
delay(1000);
58+
5859
Serial.begin(115200);
5960
while (!Serial); //Wait for user to open terminal
6061
Serial.println("SparkFun u-blox Example");
@@ -63,17 +64,37 @@ void setup()
6364

6465
//myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
6566

66-
if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
67+
while (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
6768
{
68-
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
69-
while (1);
69+
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring."));
7070
}
7171

7272
myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
7373
myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
7474

7575
myGNSS.setNavigationFrequency(1); //Produce one solution per second
7676

77+
//By default, the odometer is disabled. We need to enable it.
78+
//We can enable it using the default settings:
79+
myGNSS.enableOdometer();
80+
81+
//Or we can configure it using our own settings, by performing a read-modify-write:
82+
uint8_t flags; // Odometer/Low-speed COG filter flags
83+
uint8_t odoCfg; // Odometer filter settings
84+
uint8_t cogMaxSpeed; // Speed below which course-over-ground (COG) is computed with the low-speed COG filter : m/s * 0.1
85+
uint8_t cogMaxPosAcc; // Maximum acceptable position accuracy for computing COG with the low-speed COG filter
86+
uint8_t velLpGain; // Velocity low-pass filter level
87+
uint8_t cogLpGain; // COG low-pass filter level
88+
89+
if (myGNSS.getOdometerConfig(&flags, &odoCfg, &cogMaxSpeed, &cogMaxPosAcc, &velLpGain, &cogLpGain))
90+
{
91+
flags = UBX_CFG_ODO_USE_ODO; // Enable the odometer
92+
odoCfg = UBX_CFG_ODO_CAR; // Use the car profile (others are RUN, CYCLE, SWIM, CUSTOM)
93+
myGNSS.setOdometerConfig(flags, odoCfg, cogMaxSpeed, cogMaxPosAcc, velLpGain, cogLpGain); // Set the configuration
94+
}
95+
else
96+
Serial.println("Could not read odometer config!");
97+
7798
//myGNSS.resetOdometer(); //Uncomment this line to reset the odometer
7899

79100
myGNSS.setAutoNAVODOcallbackPtr(&printODOdata); // Enable automatic NAV ODO messages with callback to printODOdata
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
Configure the NEO-M8P-2 as a "moving base"
3+
By: Paul Clark
4+
SparkFun Electronics
5+
Date: March 20th, 2023
6+
License: MIT. See license file for more information.
7+
8+
This example configures the NEO-M8P-2 as a moving base.
9+
It will output RTCM3 1077, 1087, 1230 and 4072.0 messages on UART1.
10+
Connect UART1 TX to UART1 RX on a NEO-M8P rover. Also connect GND to GND.
11+
The next example shows how to display the relative position of the rover.
12+
13+
Feel like supporting open source hardware?
14+
Buy a board from SparkFun!
15+
NEO-M8P RTK: https://www.sparkfun.com/products/15005
16+
17+
Hardware Connections:
18+
Plug a Qwiic cable into the GNSS and a BlackBoard
19+
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
20+
Connect UART1 TX to UART1 RX on a NEO-M8P rover. Also connect GND to GND.
21+
Open the serial monitor at 115200 baud to see the output
22+
*/
23+
24+
#include <Wire.h> //Needed for I2C to GNSS
25+
26+
#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
27+
SFE_UBLOX_GNSS myGNSS;
28+
29+
void setup()
30+
{
31+
delay(1000);
32+
33+
Serial.begin(115200);
34+
while(!Serial); //Wait for user to open terminal
35+
Serial.println(F("u-blox NEO-M8P Moving Base Example"));
36+
37+
Wire.begin();
38+
39+
while (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
40+
{
41+
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring."));
42+
}
43+
44+
// Uncomment the next line if you want to reset your module back to the default settings with 1Hz navigation rate
45+
//myGNSS.factoryDefault(); delay(5000);
46+
47+
myGNSS.setUART1Output(COM_TYPE_RTCM3); // Configure UART1 to output RTCM3 only. Disable NMEA.
48+
myGNSS.saveConfiguration(); //Save the current settings to flash and BBR
49+
50+
bool response = true;
51+
52+
response &= myGNSS.enableRTCMmessage(UBX_RTCM_1077, COM_PORT_UART1, 1); //Enable message 1077 on UART1
53+
response &= myGNSS.enableRTCMmessage(UBX_RTCM_1087, COM_PORT_UART1, 1); //Enable message 1087 on UART1
54+
response &= myGNSS.enableRTCMmessage(UBX_RTCM_1230, COM_PORT_UART1, 1); //Enable message 1230 on UART1
55+
response &= myGNSS.enableRTCMmessage(UBX_RTCM_4072_0, COM_PORT_UART1, 1); //Enable message 4072.0 on UART1
56+
57+
response &= myGNSS.disableSurveyMode(); //Essential - we need to set TMODE3 to Disabled to allow 4072.0 to be output
58+
59+
if (response == true)
60+
{
61+
Serial.println(F("RTCM messages enabled"));
62+
}
63+
else
64+
{
65+
Serial.println(F("RTCM failed to enable. Are you sure you have an NEO-M8P?"));
66+
}
67+
}
68+
69+
void loop()
70+
{
71+
myGNSS.checkUblox(); //See if new data is available. Process bytes as they come in.
72+
73+
delay(250); //Don't pound too hard on the I2C bus
74+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
Display the relative position of a NEO-M8P-2 rover
3+
By: Paul Clark
4+
SparkFun Electronics
5+
Date: March 20th, 2023
6+
License: MIT. See license file for more information.
7+
8+
This example shows how to query the module for RELPOS information in the NED frame.
9+
It assumes you already have RTCM correction data being fed to the receiver on UART1.
10+
Connect UART1 TX on the base to UART1 RX on the rover. Also connect GND to GND.
11+
12+
Feel like supporting open source hardware?
13+
Buy a board from SparkFun!
14+
NEO-M8P RTK: https://www.sparkfun.com/products/15005
15+
16+
Hardware Connections:
17+
Plug a Qwiic cable into the GNSS and a RedBoard Qwiic or BlackBoard
18+
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
19+
Connect UART1 TX on the base to UART1 RX on the rover. Also connect GND to GND.
20+
Open the serial monitor at 115200 baud to see the output
21+
*/
22+
23+
#include <Wire.h> //Needed for I2C to GNSS
24+
25+
#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
26+
SFE_UBLOX_GNSS myGNSS;
27+
28+
void setup()
29+
{
30+
delay(1000);
31+
32+
Serial.begin(115200);
33+
while (!Serial); //Wait for user to open terminal
34+
Serial.println("u-blox NEO-M8P Rover Example");
35+
36+
Wire.begin();
37+
38+
while (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
39+
{
40+
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring."));
41+
}
42+
43+
// Uncomment the next line if you want to reset your module back to the default settings with 1Hz navigation rate
44+
//myGNSS.factoryDefault(); delay(5000);
45+
46+
// By default, UART1 Protocol In is set to NMEA + UBX + RTCM3. No changes are necessary. But we can manually configure the port if required.
47+
Serial.print(myGNSS.setPortInput(COM_PORT_UART1, COM_TYPE_UBX | COM_TYPE_RTCM3)); //Enable UBX and RTCM3 input on UART1
48+
myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save the communications port settings to flash and BBR
49+
}
50+
51+
void loop()
52+
{
53+
// The data from getRELPOSNED (UBX-NAV-RELPOSNED) is returned in UBX_NAV_RELPOSNED_t packetUBXNAVRELPOSNED
54+
// Please see u-blox_structs.h for the full definition of UBX_NAV_RELPOSNED_t
55+
// You can either read the data from packetUBXNAVRELPOSNED directly
56+
// or can use the helper functions: getRelPosN/E/D; getRelPosAccN/E/D
57+
// Note that NEO-M8P RELPOSNED is different to ZED-F9P. It does not contain the relative length and heading.
58+
if (myGNSS.getRELPOSNED() == true)
59+
{
60+
Serial.print("relPosN: ");
61+
Serial.println(myGNSS.getRelPosN(), 4); // Use the helper functions to get the rel. pos. as m
62+
Serial.print("relPosE: ");
63+
Serial.println(myGNSS.getRelPosE(), 4);
64+
Serial.print("relPosD: ");
65+
Serial.println(myGNSS.getRelPosD(), 4);
66+
67+
Serial.print("relPosHPN: ");
68+
Serial.println((float)myGNSS.packetUBXNAVRELPOSNED->data.relPosHPN / 10, 1); //High-precision component. Convert to mm
69+
Serial.print("relPosHPE: ");
70+
Serial.println((float)myGNSS.packetUBXNAVRELPOSNED->data.relPosHPE / 10, 1);
71+
Serial.print("relPosHPD: ");
72+
Serial.println((float)myGNSS.packetUBXNAVRELPOSNED->data.relPosHPD / 10, 1);
73+
74+
Serial.print("accN: ");
75+
Serial.println(myGNSS.getRelPosAccN(), 4); // Use the helper functions to get the rel. pos. accuracy as m
76+
Serial.print("accE: ");
77+
Serial.println(myGNSS.getRelPosAccE(), 4);
78+
Serial.print("accD: ");
79+
Serial.println(myGNSS.getRelPosAccD(), 4);
80+
81+
Serial.print("gnssFixOk: ");
82+
if (myGNSS.packetUBXNAVRELPOSNED->data.flags.bits.gnssFixOK == true)
83+
Serial.println("x");
84+
else
85+
Serial.println("");
86+
87+
Serial.print("diffSolution: ");
88+
if (myGNSS.packetUBXNAVRELPOSNED->data.flags.bits.diffSoln == true)
89+
Serial.println("x");
90+
else
91+
Serial.println("");
92+
93+
Serial.print("relPosValid: ");
94+
if (myGNSS.packetUBXNAVRELPOSNED->data.flags.bits.relPosValid == true)
95+
Serial.println("x");
96+
else
97+
Serial.println("");
98+
99+
Serial.print("carrier Solution Type: ");
100+
if (myGNSS.packetUBXNAVRELPOSNED->data.flags.bits.carrSoln == 0)
101+
Serial.println("None");
102+
else if (myGNSS.packetUBXNAVRELPOSNED->data.flags.bits.carrSoln == 1)
103+
Serial.println("Float");
104+
else if (myGNSS.packetUBXNAVRELPOSNED->data.flags.bits.carrSoln == 2)
105+
Serial.println("Fixed");
106+
107+
Serial.print("isMoving: ");
108+
if (myGNSS.packetUBXNAVRELPOSNED->data.flags.bits.isMoving == true)
109+
Serial.println("x");
110+
else
111+
Serial.println("");
112+
}
113+
else
114+
Serial.println("RELPOS request failed");
115+
116+
Serial.println("");
117+
}

‎keywords.txt

+14
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ setDynamicModel KEYWORD2
193193
getDynamicModel KEYWORD2
194194

195195
resetOdometer KEYWORD2
196+
enableOdometer KEYWORD2
197+
getOdometerConfig KEYWORD2
198+
setOdometerConfig KEYWORD2
196199

197200
enableGNSS KEYWORD2
198201
isGNSSenabled KEYWORD2
@@ -831,6 +834,17 @@ VAL_CFG_SUBSEC_ANTCONF LITERAL1
831834
VAL_CFG_SUBSEC_LOGCONF LITERAL1
832835
VAL_CFG_SUBSEC_FTSCONF LITERAL1
833836

837+
UBX_CFG_ODO_USE_ODO LITERAL1
838+
UBX_CFG_ODO_USE_COG LITERAL1
839+
UBX_CFG_ODO_OUT_LP_VEL LITERAL1
840+
UBX_CFG_ODO_OUT_LP_COG LITERAL1
841+
842+
UBX_CFG_ODO_RUN LITERAL1
843+
UBX_CFG_ODO_CYCLE LITERAL1
844+
UBX_CFG_ODO_SWIM LITERAL1
845+
UBX_CFG_ODO_CAR LITERAL1
846+
UBX_CFG_ODO_CUSTOM LITERAL1
847+
834848
DYN_MODEL_PORTABLE LITERAL1
835849
DYN_MODEL_STATIONARY LITERAL1
836850
DYN_MODEL_PEDESTRIAN LITERAL1

‎library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SparkFun u-blox GNSS Arduino Library
2-
version=2.2.21
2+
version=2.2.22
33
author=SparkFun Electronics <techsupport@sparkfun.com>
44
maintainer=SparkFun Electronics <sparkfun.com>
55
sentence=Library for I2C, Serial and SPI Communication with u-blox GNSS modules<br/><br/>

‎src/SparkFun_u-blox_GNSS_Arduino_Library.cpp

+66
Original file line numberDiff line numberDiff line change
@@ -8207,6 +8207,70 @@ bool SFE_UBLOX_GNSS::resetOdometer(uint16_t maxWait)
82078207
return (sendCommand(&packetCfg, maxWait, true) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
82088208
}
82098209

8210+
// Enable / disable the odometer
8211+
bool SFE_UBLOX_GNSS::enableOdometer(bool enable, uint16_t maxWait)
8212+
{
8213+
packetCfg.cls = UBX_CLASS_CFG;
8214+
packetCfg.id = UBX_CFG_ODO;
8215+
packetCfg.len = 0;
8216+
packetCfg.startingSpot = 0;
8217+
8218+
// Ask module for the current odometer configuration. Loads into payloadCfg.
8219+
if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
8220+
return (false);
8221+
8222+
if (enable)
8223+
payloadCfg[4] = payloadCfg[4] | UBX_CFG_ODO_USE_ODO;
8224+
else
8225+
payloadCfg[4] = payloadCfg[4] & ~UBX_CFG_ODO_USE_ODO;
8226+
8227+
return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
8228+
}
8229+
8230+
// Read the odometer configuration
8231+
bool SFE_UBLOX_GNSS::getOdometerConfig(uint8_t *flags, uint8_t *odoCfg, uint8_t *cogMaxSpeed, uint8_t *cogMaxPosAcc, uint8_t *velLpGain, uint8_t *cogLpGain, uint16_t maxWait)
8232+
{
8233+
packetCfg.cls = UBX_CLASS_CFG;
8234+
packetCfg.id = UBX_CFG_ODO;
8235+
packetCfg.len = 0;
8236+
packetCfg.startingSpot = 0;
8237+
8238+
// Ask module for the current odometer configuration. Loads into payloadCfg.
8239+
if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
8240+
return (false);
8241+
8242+
*flags = payloadCfg[4];
8243+
*odoCfg = payloadCfg[5];
8244+
*cogMaxSpeed = payloadCfg[12];
8245+
*cogMaxPosAcc = payloadCfg[13];
8246+
*velLpGain = payloadCfg[16];
8247+
*cogLpGain = payloadCfg[17];
8248+
8249+
return true;
8250+
}
8251+
8252+
// Configure the odometer
8253+
bool SFE_UBLOX_GNSS::setOdometerConfig(uint8_t flags, uint8_t odoCfg, uint8_t cogMaxSpeed, uint8_t cogMaxPosAcc, uint8_t velLpGain, uint8_t cogLpGain, uint16_t maxWait)
8254+
{
8255+
packetCfg.cls = UBX_CLASS_CFG;
8256+
packetCfg.id = UBX_CFG_ODO;
8257+
packetCfg.len = 0;
8258+
packetCfg.startingSpot = 0;
8259+
8260+
// Ask module for the current odometer configuration. Loads into payloadCfg.
8261+
if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
8262+
return (false);
8263+
8264+
payloadCfg[4] = flags;
8265+
payloadCfg[5] = odoCfg;
8266+
payloadCfg[12] = cogMaxSpeed;
8267+
payloadCfg[13] = cogMaxPosAcc;
8268+
payloadCfg[16] = velLpGain;
8269+
payloadCfg[17] = cogLpGain;
8270+
8271+
return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
8272+
}
8273+
82108274
// Enable/Disable individual GNSS systems using UBX-CFG-GNSS
82118275
bool SFE_UBLOX_GNSS::enableGNSS(bool enable, sfe_ublox_gnss_ids_e id, uint16_t maxWait)
82128276
{
@@ -17402,6 +17466,8 @@ int32_t SFE_UBLOX_GNSS::getAltitude(uint16_t maxWait)
1740217466
// Get the current altitude in mm according to mean sea level
1740317467
// Ellipsoid model: https://www.esri.com/news/arcuser/0703/geoid1of3.html
1740417468
// Difference between Ellipsoid Model and Mean Sea Level: https://eos-gnss.com/elevation-for-beginners/
17469+
// Also see: https://portal.u-blox.com/s/question/0D52p00008HKDSkCAP/what-geoid-model-is-used-and-where-is-this-calculated
17470+
// and: https://cddis.nasa.gov/926/egm96/egm96.html on 10x10 degree grid
1740517471
int32_t SFE_UBLOX_GNSS::getAltitudeMSL(uint16_t maxWait)
1740617472
{
1740717473
if (packetUBXNAVPVT == NULL)

‎src/SparkFun_u-blox_GNSS_Arduino_Library.h

+20-1
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,22 @@ const uint8_t COM_TYPE_NMEA = (1 << 1);
465465
const uint8_t COM_TYPE_RTCM3 = (1 << 5);
466466
const uint8_t COM_TYPE_SPARTN = (1 << 6);
467467

468+
// Odometer configuration - flags
469+
const uint8_t UBX_CFG_ODO_USE_ODO = (1 << 0);
470+
const uint8_t UBX_CFG_ODO_USE_COG = (1 << 1);
471+
const uint8_t UBX_CFG_ODO_OUT_LP_VEL = (1 << 2);
472+
const uint8_t UBX_CFG_ODO_OUT_LP_COG = (1 << 3);
473+
474+
// Odometer configuration - odoCfg
475+
enum odoCfg_e
476+
{
477+
UBX_CFG_ODO_RUN = 0,
478+
UBX_CFG_ODO_CYCLE,
479+
UBX_CFG_ODO_SWIM,
480+
UBX_CFG_ODO_CAR,
481+
UBX_CFG_ODO_CUSTOM,
482+
};
483+
468484
// Configuration Sub-Section mask definitions for saveConfigSelective (UBX-CFG-CFG)
469485
const uint32_t VAL_CFG_SUBSEC_IOPORT = 0x00000001; // ioPort - communications port settings (causes IO system reset!)
470486
const uint32_t VAL_CFG_SUBSEC_MSGCONF = 0x00000002; // msgConf - message configuration
@@ -909,8 +925,11 @@ class SFE_UBLOX_GNSS
909925
bool setDynamicModel(dynModel newDynamicModel = DYN_MODEL_PORTABLE, uint16_t maxWait = defaultMaxWait);
910926
uint8_t getDynamicModel(uint16_t maxWait = defaultMaxWait); // Get the dynamic model - returns 255 if the sendCommand fails
911927

912-
// Reset the odometer
928+
// Reset / enable / configure the odometer
913929
bool resetOdometer(uint16_t maxWait = defaultMaxWait); // Reset the odometer
930+
bool enableOdometer(bool enable = true, uint16_t maxWait = defaultMaxWait); // Enable / disable the odometer
931+
bool getOdometerConfig(uint8_t *flags, uint8_t *odoCfg, uint8_t *cogMaxSpeed, uint8_t *cogMaxPosAcc, uint8_t *velLpGain, uint8_t *cogLpGain, uint16_t maxWait = defaultMaxWait); // Read the odometer configuration
932+
bool setOdometerConfig(uint8_t flags, uint8_t odoCfg, uint8_t cogMaxSpeed, uint8_t cogMaxPosAcc, uint8_t velLpGain, uint8_t cogLpGain, uint16_t maxWait = defaultMaxWait); // Configure the odometer
914933

915934
// Enable/Disable individual GNSS systems using UBX-CFG-GNSS
916935
// Note: you must leave at least one major GNSS enabled! If in doubt, enable GPS before disabling the others

0 commit comments

Comments
 (0)
Please sign in to comment.