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

Commit 1d363ee

Browse files
committed
Updating the Dead Reckoning examples for v2.0
1 parent dfdd187 commit 1d363ee

File tree

8 files changed

+141
-103
lines changed

8 files changed

+141
-103
lines changed

examples/Callbacks/CallbackExample4_HNR/CallbackExample4_HNR.ino

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ void printHNRATTdata(UBX_HNR_ATT_data_t ubxDataStruct)
3737
{
3838
Serial.println();
3939
Serial.print(F("Roll: ")); // Print selected data
40-
Serial.print(ubxDataStruct.roll);
40+
Serial.print((float)ubxDataStruct.roll / 100000.0, 2); // Convert roll to degrees
4141
Serial.print(F(" Pitch: "));
42-
Serial.print(ubxDataStruct.pitch);
42+
Serial.print((float)ubxDataStruct.pitch / 100000.0, 2); // Convert pitch to degrees
4343
Serial.print(F(" Heading: "));
44-
Serial.println(ubxDataStruct.heading);
44+
Serial.println((float)ubxDataStruct.heading / 100000.0, 2); // Convert heading to degrees
4545
}
4646

4747
// Callback: printHNRINSdata will be called when new HNR INS data arrives
@@ -92,11 +92,11 @@ void setup()
9292
else
9393
Serial.println(F("setHNRNavigationRate was NOT successful"));
9494

95-
if (myGPS.setAutoHNRAttcallback(&printHNRATTdata) == true) // Enable automatic HNR ATT messages with callback to printHNRATTdata
96-
Serial.println(F("setAutoHNRAttcallback successful"));
95+
if (myGPS.setAutoHNRATTcallback(&printHNRATTdata) == true) // Enable automatic HNR ATT messages with callback to printHNRATTdata
96+
Serial.println(F("setAutoHNRATTcallback successful"));
9797

98-
if (myGPS.setAutoHNRDyncallback(&printHNRINSdata) == true) // Enable automatic HNR INS messages with callback to printHNRINSdata
99-
Serial.println(F("setAutoHNRDyncallback successful"));
98+
if (myGPS.setAutoHNRINScallback(&printHNRINSdata) == true) // Enable automatic HNR INS messages with callback to printHNRINSdata
99+
Serial.println(F("setAutoHNRINScallback successful"));
100100

101101
if (myGPS.setAutoHNRPVTcallback(&printHNRPVTdata) == true) // Enable automatic HNR PVT messages with callback to printHNRPVTdata
102102
Serial.println(F("setAutoHNRPVTcallback successful"));

examples/Callbacks/CallbackExample5_ESF/CallbackExample5_ESF.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ void printESFALGdata(UBX_ESF_ALG_data_t ubxDataStruct)
4040
Serial.print(F(" (ms)"));
4141

4242
Serial.print(F(" Roll: ")); // Print selected data
43-
Serial.print(ubxDataStruct.roll);
43+
Serial.print((float)ubxDataStruct.roll / 100.0, 2); // Convert roll to degrees
4444

4545
Serial.print(F(" Pitch: "));
46-
Serial.print(ubxDataStruct.pitch);
46+
Serial.print((float)ubxDataStruct.pitch / 100.0, 2); // Convert pitch to degrees
4747

4848
Serial.print(F(" Yaw: "));
49-
Serial.print(ubxDataStruct.yaw);
49+
Serial.print((float)ubxDataStruct.yaw / 100.0, 2); // Convert yaw to degrees
5050

51-
Serial.println(F(" (Degrees*0.01)"));
51+
Serial.println(F(" (Degrees)"));
5252
}
5353

5454
// Callback: printESFINSdata will be called when new ESF INS data arrives

examples/Dead_Reckoning/Example1_calibrateSensor/Example1_calibrateSensor.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ void setup()
5050
}
5151

5252
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
53+
54+
//myGPS.resetIMUalignment(); // Uncomment this line to reset the IMU alignment
5355
}
5456

5557
void loop()

examples/Dead_Reckoning/Example2_getIMUData/Example2_getIMUData.ino

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
ZED-F9R: https://www.sparkfun.com/products/16344
1212
1313
Hardware Connections:
14-
Plug a Qwiic cable into the GPS and a Redboard Qwiic
14+
Plug a Qwiic cable into the GNSS and a Redboard Qwiic
1515
If you don't have a platform with a Qwiic connection use the
1616
SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
1717
Open the serial monitor at 115200 baud to see the output
@@ -22,7 +22,7 @@
2222
2323
*/
2424

25-
#include <Wire.h> //Needed for I2C to GPS
25+
#include <Wire.h> //Needed for I2C to GNSS
2626

2727
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
2828
SFE_UBLOX_GPS myGPS;
@@ -37,48 +37,55 @@ void setup()
3737

3838
if (myGPS.begin() == false) //Connect to the u-blox module using Wire port
3939
{
40-
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
40+
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
4141
while (1);
4242
}
4343

4444
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
4545

4646
if (myGPS.getEsfInfo()){
4747

48-
Serial.print(F("Fusion Mode: "));
49-
Serial.println(myGPS.imuMeas.fusionMode);
48+
Serial.print(F("Fusion Mode: "));
49+
Serial.println(myGPS.packetUBXESFSTATUS->data.fusionMode);
5050

51-
if (myGPS.imuMeas.fusionMode == 1){
51+
if (myGPS.packetUBXESFSTATUS->data.fusionMode == 1){
5252
Serial.println(F("Fusion Mode is Initialized!"));
5353
}
5454
else {
55-
Serial.println(F("Fusion Mode is either disabled or not initialized - Freezing!"));
56-
Serial.println(F("Please see Example 1 description at top for more information."));
55+
Serial.println(F("Fusion Mode is either disabled or not initialized!"));
56+
Serial.println(F("Please see the previous example for more information."));
5757
}
5858
}
5959
}
6060

6161
void loop()
6262
{
63-
64-
if (myGPS.getEsfIns())
63+
// ESF data is produced at the navigation rate, so by default we'll get fresh data once per second
64+
if (myGPS.getEsfIns()) // Poll new ESF INS data
6565
{
66-
Serial.print(F("X: "));
67-
Serial.println(myGPS.imuMeas.xAngRate);
68-
Serial.print(F("Y: "));
69-
Serial.println(myGPS.imuMeas.yAngRate);
70-
Serial.print(F("Z: "));
71-
Serial.println(myGPS.imuMeas.zAngRate);
72-
Serial.print(F("X Acceleration: "));
73-
Serial.println(myGPS.imuMeas.xAccel);
74-
Serial.print(F("Y Acceleration: "));
75-
Serial.println(myGPS.imuMeas.yAccel);
76-
Serial.print(F("Z Acceleration: "));
77-
Serial.println(myGPS.imuMeas.zAccel);
66+
Serial.print(F("X Ang Rate: "));
67+
Serial.print(myGPS.packetUBXESFINS->data.xAngRate);
68+
Serial.print(F(" Y Ang Rate: "));
69+
Serial.print(myGPS.packetUBXESFINS->data.yAngRate);
70+
Serial.print(F(" Z Ang Rate: "));
71+
Serial.print(myGPS.packetUBXESFINS->data.zAngRate);
72+
Serial.print(F(" X Accel: "));
73+
Serial.print(myGPS.packetUBXESFINS->data.xAccel);
74+
Serial.print(F(" Y Accel: "));
75+
Serial.print(myGPS.packetUBXESFINS->data.yAccel);
76+
Serial.print(F(" Z Accel: "));
77+
Serial.print(myGPS.packetUBXESFINS->data.zAccel);
78+
7879
// These values also have "validity checks" that can be provided by the
79-
// ublox library, add "Vald" to values: e.g. xAngRateVald or xAccelVald.
80+
// ublox library by reading bitfield0
81+
Serial.print(F(" Validity: "));
82+
Serial.print(myGPS.packetUBXESFINS->data.bitfield0.bits.xAngRateValid);
83+
Serial.print(myGPS.packetUBXESFINS->data.bitfield0.bits.yAngRateValid);
84+
Serial.print(myGPS.packetUBXESFINS->data.bitfield0.bits.zAngRateValid);
85+
Serial.print(myGPS.packetUBXESFINS->data.bitfield0.bits.xAccelValid);
86+
Serial.print(myGPS.packetUBXESFINS->data.bitfield0.bits.yAccelValid);
87+
Serial.println(myGPS.packetUBXESFINS->data.bitfield0.bits.zAccelValid);
8088
}
8189

8290
delay(250);
8391
}
84-

examples/Dead_Reckoning/Example3_getSensorStatus/Example3_getSensorStatus.ino

Lines changed: 61 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
ZED-F9R: https://www.sparkfun.com/products/16344
1212
1313
Hardware Connections:
14-
Plug a Qwiic cable into the GPS and a Redboard Qwiic
14+
Plug a Qwiic cable into the GNSS and a Redboard Qwiic
1515
If you don't have a platform with a Qwiic connection use the
1616
SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
1717
Open the serial monitor at 115200 baud to see the output
@@ -26,7 +26,7 @@
2626
2727
*/
2828

29-
#include <Wire.h> //Needed for I2C to GPS
29+
#include <Wire.h> //Needed for I2C to GNSS
3030

3131
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
3232
SFE_UBLOX_GPS myGPS;
@@ -41,7 +41,7 @@ void setup()
4141

4242
if (myGPS.begin() == false) //Connect to the u-blox module using Wire port
4343
{
44-
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
44+
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
4545
while (1);
4646
}
4747

@@ -53,45 +53,73 @@ void setup()
5353
if (myGPS.getEsfInfo()){
5454

5555
Serial.print(F("Fusion Mode: "));
56-
Serial.println(myGPS.imuMeas.fusionMode);
56+
Serial.println(myGPS.packetUBXESFSTATUS->data.fusionMode);
5757

58-
if (myGPS.imuMeas.fusionMode == 1){
58+
if (myGPS.packetUBXESFSTATUS->data.fusionMode == 1){
5959
Serial.println(F("Fusion Mode is Initialized!"));
6060
}
6161
else {
62-
Serial.println(F("Fusion Mode is either disabled or not initialized - Freezing!"));
63-
Serial.println(F("Please see Example 1 description at top for more information."));
62+
Serial.println(F("Fusion Mode is either disabled or not initialized!"));
63+
Serial.println(F("Please see the previous example for more information."));
6464
}
6565
}
6666
}
6767

6868
void loop()
6969
{
70+
// ESF data is produced at the navigation rate, so by default we'll get fresh data once per second
71+
if (myGPS.getEsfInfo()) // Poll new ESF STATUS data
72+
{
73+
UBX_ESF_STATUS_sensorStatus_t sensorStatus; // Create storage for the individual sensor status
74+
75+
//See ublox receiver description or our hookup guide for information on the return values
76+
77+
Serial.println(F(" "));
78+
Serial.println(F(" C "));
79+
Serial.println(F(" a "));
80+
Serial.println(F(" l "));
81+
Serial.println(F(" i "));
82+
Serial.println(F(" b M "));
83+
Serial.println(F(" r i N"));
84+
Serial.println(F(" a B s o"));
85+
Serial.println(F(" S t T B a s i"));
86+
Serial.println(F("S e B i i a d e s"));
87+
Serial.println(F("e n e o m d d y"));
88+
Serial.println(F("n s i I n e T "));
89+
Serial.println(F("s o n s M i M M"));
90+
Serial.println(F("o r g S S e m e e"));
91+
Serial.println(F("r R t t a e a a"));
92+
Serial.println(F(" T U e a a s s s"));
93+
Serial.println(F("N y s a t t u T u u"));
94+
Serial.println(F("o p e d u u r a r r"));
95+
Serial.println(F(". e d y s s e g e e"));
96+
Serial.println(F(" "));
97+
98+
for(uint8_t i = 0; i < myGPS.packetUBXESFSTATUS->data.numSens; i++)
99+
{
100+
myGPS.getSensorFusionStatus(&sensorStatus, i); // Extract the individual sensor data for this sensor
101+
102+
Serial.print(i); Serial.print(F(" ")); // Print the sensor number
103+
104+
// Print the sensor type
105+
Serial.print(sensorStatus.sensStatus1.bits.type);
106+
if (sensorStatus.sensStatus1.bits.type < 10) Serial.print(F(" "));
107+
Serial.print(F(" "));
108+
109+
Serial.print(sensorStatus.sensStatus1.bits.used); Serial.print(F(" ")); // Print the used flag
110+
Serial.print(sensorStatus.sensStatus1.bits.ready); Serial.print(F(" ")); // Print the ready flag
111+
112+
Serial.print(sensorStatus.sensStatus2.bits.calibStatus); Serial.print(F(" ")); // Print the calibration status
113+
Serial.print(sensorStatus.sensStatus2.bits.timeStatus); Serial.print(F(" ")); // Print the time status
114+
115+
Serial.print(sensorStatus.faults.bits.badMeas); Serial.print(F(" ")); // Print the bad measurement flag
116+
Serial.print(sensorStatus.faults.bits.badTTag); Serial.print(F(" ")); // Print the time tag flag
117+
Serial.print(sensorStatus.faults.bits.missingMeas); Serial.print(F(" ")); // Print the missing measurement flag
118+
Serial.print(sensorStatus.faults.bits.noisyMeas); // Print the noisy measure flag
119+
120+
Serial.println();
121+
}
122+
}
70123

71-
for(int i=1; i<=myGPS.ubloxSen.numSens; i++){
72-
myGPS.getSensState(i); // Give the sensor you want to check on.
73-
Serial.print(F("Sensor Data Type: ")); //See ublox receiver description
74-
//or our hookup guide for information on the
75-
//return value.
76-
Serial.println(myGPS.ubloxSen.senType);
77-
Serial.print(F("Being Used: "));
78-
Serial.println(myGPS.ubloxSen.isUsed);
79-
Serial.print(F("Is Ready: "));
80-
Serial.println(myGPS.ubloxSen.isReady);
81-
Serial.print(F("Calibration Status: "));
82-
Serial.println(myGPS.ubloxSen.calibStatus);
83-
Serial.print(F("Time Status: "));
84-
Serial.println(myGPS.ubloxSen.timeStatus);
85-
Serial.print(F("Bad Measure: "));
86-
Serial.println(myGPS.ubloxSen.timeStatus);
87-
Serial.print(F("Bad Time Tag: "));
88-
Serial.println(myGPS.ubloxSen.badTag);
89-
Serial.print(F("Missed Measure : "));
90-
Serial.println(myGPS.ubloxSen.missMeas);
91-
Serial.print(F("Noisy Measure: "));
92-
Serial.println(myGPS.ubloxSen.noisyMeas);
93-
}
94-
124+
delay(250);
95125
}
96-
97-

examples/Dead_Reckoning/Example4_vehicleDynamics/Example4_vehicleDynamics.ino

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
ZED-F9R: https://www.sparkfun.com/products/16344
1212
1313
Hardware Connections:
14-
Plug a Qwiic cable into the GPS and a Redboard Qwiic
14+
Plug a Qwiic cable into the GNSS and a Redboard Qwiic
1515
If you don't have a platform with a Qwiic connection use the
1616
SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
1717
Open the serial monitor at 115200 baud to see the output
@@ -24,7 +24,7 @@
2424
2525
*/
2626

27-
#include <Wire.h> //Needed for I2C to GPS
27+
#include <Wire.h> //Needed for I2C to GNSS
2828

2929
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
3030
SFE_UBLOX_GPS myGPS;
@@ -39,7 +39,7 @@ void setup()
3939

4040
if (myGPS.begin() == false) //Connect to the u-blox module using Wire port
4141
{
42-
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
42+
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
4343
while (1);
4444
}
4545

@@ -48,35 +48,36 @@ void setup()
4848
if (myGPS.getEsfInfo()){
4949

5050
Serial.print(F("Fusion Mode: "));
51-
Serial.println(myGPS.imuMeas.fusionMode);
51+
Serial.println(myGPS.packetUBXESFSTATUS->data.fusionMode);
5252

53-
if (myGPS.imuMeas.fusionMode == 1){
53+
if (myGPS.packetUBXESFSTATUS->data.fusionMode == 1){
5454
Serial.println(F("Fusion Mode is Initialized!"));
5555
}
5656
else {
57-
Serial.println(F("Fusion Mode is either disabled or not initialized - Freezing!"));
58-
Serial.println(F("Please see Example 1 description at top for more information."));
57+
Serial.println(F("Fusion Mode is either disabled or not initialized!"));
58+
Serial.println(F("Please see the previous example for more information."));
5959
}
6060
}
6161
}
6262

6363
void loop()
6464
{
65-
myGPS.getVehAtt(); // Give the sensor you want to check on.
66-
Serial.print(F("Roll: "));
67-
Serial.println(myGPS.vehAtt.roll);
68-
Serial.print(F("Pitch: "));
69-
Serial.println(myGPS.vehAtt.pitch);
70-
Serial.print(F("Heading: "));
71-
Serial.println(myGPS.vehAtt.heading);
72-
Serial.print(F("Roll Accuracy: "));
73-
Serial.println(myGPS.vehAtt.accRoll);
74-
Serial.print(F("Pitch Accuracy: "));
75-
Serial.println(myGPS.vehAtt.accPitch);
76-
Serial.print(F("Heading Accuracy: "));
77-
Serial.println(myGPS.vehAtt.accHeading);
65+
// ESF data is produced at the navigation rate, so by default we'll get fresh data once per second
66+
if (myGPS.getEsfAlignment()) // Poll new ESF ALG data
67+
{
68+
Serial.print(F("Status: "));
69+
Serial.print(myGPS.packetUBXESFALG->data.flags.bits.status);
70+
Serial.print(F(" Roll: "));
71+
Serial.print(myGPS.getESFroll(), 2); // Use the helper function to get the roll in degrees
72+
Serial.print(F(" Pitch: "));
73+
Serial.print(myGPS.getESFpitch(), 2); // Use the helper function to get the pitch in degrees
74+
Serial.print(F(" Heading: "));
75+
Serial.print(myGPS.getESFyaw(), 2); // Use the helper function to get the yaw in degrees
76+
Serial.print(F(" Errors: "));
77+
Serial.print(myGPS.packetUBXESFALG->data.error.bits.tiltAlgError);
78+
Serial.print(myGPS.packetUBXESFALG->data.error.bits.yawAlgError);
79+
Serial.println(myGPS.packetUBXESFALG->data.error.bits.angleError);
80+
}
7881

79-
delay(250);
82+
delay(250);
8083
}
81-
82-

examples/Dead_Reckoning/Example5_getHNRData/Example5_getHNRData.ino

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ void setup()
5656
else
5757
Serial.println(F("setHNRNavigationRate was NOT successful"));
5858

59-
myGPS.setAutoHNRAtt(false); //Make sure auto HNR attitude messages are disabled
60-
myGPS.setAutoHNRDyn(false); //Make sure auto HNR vehicle dynamics messages are disabled
59+
myGPS.setAutoHNRATT(false); //Make sure auto HNR attitude messages are disabled
60+
myGPS.setAutoHNRINS(false); //Make sure auto HNR vehicle dynamics messages are disabled
6161
myGPS.setAutoHNRPVT(false); //Make sure auto HNR PVT messages are disabled
6262
}
6363

@@ -67,11 +67,11 @@ void loop()
6767
if (myGPS.getHNRAtt(125) == true) // Request HNR Att data using a 125ms timeout
6868
{
6969
Serial.print(F("Roll: "));
70-
Serial.print(myGPS.packetUBXHNRATT->data.roll);
70+
Serial.print(myGPS.getHNRroll(), 2); // Use the helper function to get the roll in degrees
7171
Serial.print(F(" Pitch: "));
72-
Serial.print(myGPS.packetUBXHNRATT->data.pitch);
72+
Serial.print(myGPS.getHNRpitch(), 2); // Use the helper function to get the pitch in degrees
7373
Serial.print(F(" Heading: "));
74-
Serial.println(myGPS.packetUBXHNRATT->data.heading);
74+
Serial.println(myGPS.getHNRheading(), 2); // Use the helper function to get the heading in degrees
7575
}
7676
if (myGPS.getHNRDyn(125) == true) // Request HNR Dyn data using a 125ms timeout
7777
{

0 commit comments

Comments
 (0)