From 05930f8728b1a93e165a7e18ea66e4582aac3978 Mon Sep 17 00:00:00 2001 From: Elias Santistevan Date: Fri, 27 Mar 2020 13:21:32 -0600 Subject: [PATCH 01/13] Initial commit Some things may be missing because I was in the middle of development when stay at home orders were issued. Will be hammered out as I work through it. --- .gitignore | 5 + .../Example1_getIMU/Example1_getIMU.ino | 74 ++++++++++++ src/SparkFun_Ublox_Arduino_Library.cpp | 109 ++++++++++++++++++ src/SparkFun_Ublox_Arduino_Library.h | 31 +++++ 4 files changed, 219 insertions(+) create mode 100644 examples/NEO-M8U/Example1_getIMU/Example1_getIMU.ino diff --git a/.gitignore b/.gitignore index e4eedb2..484d3c2 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,8 @@ $RECYCLE.BIN/ Network Trash Folder Temporary Items .apdisk + +# VIM backup files +*~ +[._]*.un~ +*.swp diff --git a/examples/NEO-M8U/Example1_getIMU/Example1_getIMU.ino b/examples/NEO-M8U/Example1_getIMU/Example1_getIMU.ino new file mode 100644 index 0000000..7d46873 --- /dev/null +++ b/examples/NEO-M8U/Example1_getIMU/Example1_getIMU.ino @@ -0,0 +1,74 @@ + +/* + Some Description + By: Elias Santistevan + SparkFun Electronics + Date: February + License: MIT. See license file for more information but you can + basically do whatever you want with this code. + + + Feel like supporting open source hardware? + Buy a board from SparkFun! + NEO-M8U: https://www.sparkfun.com/products/15136 + ZED-F9R: https://www.sparkfun.com/products/15136 + + Hardware Connections: + Plug a Qwiic cable into the GPS and a BlackBoard + If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) + Open the serial monitor at 115200 baud to see the output +*/ + +#include //Needed for I2C to GPS + +#include //http://librarymanager/All#SparkFun_Ublox_GPS +SFE_UBLOX_GPS myGPS; + +void setup() +{ + Serial.begin(115200); + while (!Serial); //Wait for user to open terminal + Serial.println("SparkFun Ublox Example"); + + Wire.begin(); + + if (myGPS.begin() == false) //Connect to the Ublox module using Wire port + { + Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing.")); + while (1); + } + + myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) + + if (myGPS.getUdrStatus()) + { + Serial.print("Mode: "); + Serial.println(myGPS.imuMetric.fusionMode); + Serial.print("Number of Sensors: "); + Serial.println(myGPS.imuMetric.numSens); + } +} + +void loop() +{ + if (myGPS.getUdrStatus()) + Serial.println(myGPS.imuMetric.fusionMode); + + if (myGPS.getInsInfo()) + { + Serial.print("X validity: "); + Serial.println(myGPS.imuMetric.xAngRateVald); + Serial.print("X: "); + Serial.println(myGPS.imuMetric.xAngRate); + Serial.print("Y validity: "); + Serial.println(myGPS.imuMetric.yAngRateVald); + Serial.print("Y: "); + Serial.println(myGPS.imuMetric.yAngRate); + Serial.print("Z validity: "); + Serial.println(myGPS.imuMetric.zAngRateVald); + Serial.print("Z: "); + Serial.println(myGPS.imuMetric.zAngRate); + } + delay(250); +} + diff --git a/src/SparkFun_Ublox_Arduino_Library.cpp b/src/SparkFun_Ublox_Arduino_Library.cpp index 03f2400..52c233a 100644 --- a/src/SparkFun_Ublox_Arduino_Library.cpp +++ b/src/SparkFun_Ublox_Arduino_Library.cpp @@ -2709,3 +2709,112 @@ boolean SFE_UBLOX_GPS::getRELPOSNED(uint16_t maxWait) return (true); } +boolean SFE_UBLOX_GPS::getUdrStatus(uint16_t maxWait) +{ + // Requesting Data from the receiver + packetCfg.cls = UBX_CLASS_ESF; + packetCfg.id = UBX_ESF_STATUS; + packetCfg.len = 0; + packetCfg.startingSpot = 0; + + if (sendCommand(packetCfg, maxWait) == false) + return (false); //If command send fails then bail + + checkUblox(); + + // payload should be loaded. + imuMetric.version = extractByte(4); + imuMetric.fusionMode = extractByte(12); + imuMetric.numSens = extractByte(15); + + // Individual Status Sensor in different function + return(true); +} + +// +boolean SFE_UBLOX_GPS::getInsInfo(uint16_t maxWait) +{ + packetCfg.cls = UBX_CLASS_ESF; + packetCfg.id = UBX_ESF_INS; + packetCfg.len = 0; + packetCfg.startingSpot = 0; + + if (sendCommand(packetCfg, maxWait) == false) + return (false); //If command send fails then bail + + checkUblox(); + + // Validity of each sensor value below + uint32_t validity = extractLong(0); + + imuMetric.xAngRateVald = (validity && 0x0080) >> 8; + imuMetric.yAngRateVald = (validity && 0x0100) >> 9; + imuMetric.zAngRateVald = (validity && 0x0200) >> 10; + imuMetric.xAccelVald = (validity && 0x0400) >> 11; + imuMetric.yAccelVald = (validity && 0x0800) >> 12; + imuMetric.zAccelVald = (validity && 0x1000) >> 13; + + imuMetric.xAngRate = extractLong(12); // deg/s + imuMetric.yAngRate = extractLong(16); // deg/s + imuMetric.zAngRate = extractLong(20); // deg/s + + imuMetric.xAccel = extractLong(24); // m/s + imuMetric.yAccel = extractLong(28); // m/s + imuMetric.zAccel = extractLong(32); // m/s + + return(true); +} + +// +boolean SFE_UBLOX_GPS::getExternSensMeas(uint16_t maxWait) +{ + + packetCfg.cls = UBX_CLASS_ESF; + packetCfg.id = UBX_ESF_MEAS; + packetCfg.len = 0; + packetCfg.startingSpot = 0; + + if (sendCommand(packetCfg, maxWait) == false) + return (false); //If command send fails then bail + + checkUblox(); + + uint32_t timeStamp = extractLong(0); + uint32_t flags = extractInt(4); + + uint8_t timeSent = (flags && 0x01) >> 1; + uint8_t timeEdge = (flags && 0x02) >> 2; + uint8_t tagValid = (flags && 0x04) >> 3; + uint8_t numMeas = (flags && 0x1000) >> 15; + +} + +boolean SFE_UBLOX_GPS::getEsfRaw(uint16_t maxWait) +{ + + // Need the number of sensors to know what to sample. + getUdrStatus(); + + // Rate selected in UBX-CFG-MSG is not respected + packetCfg.cls = UBX_CLASS_ESF; + packetCfg.id = UBX_ESF_RAW; + packetCfg.len = 0; + packetCfg.startingSpot = 0; + + if (sendCommand(packetCfg, maxWait) == false) + return (false); //If command send fails then bail + + checkUblox(); + + uint8_t byteOffset = 8; + + for(uint8_t i=0; i> 23; // Repeating Blocks on the back burner... + imuMetric.data[i] = (bitField && 0xFFFFFF) + imuMetric.timeStamp[i] = extractLong(8 + byteOffset * i); + + } +} + diff --git a/src/SparkFun_Ublox_Arduino_Library.h b/src/SparkFun_Ublox_Arduino_Library.h index d5ac3ce..47288af 100644 --- a/src/SparkFun_Ublox_Arduino_Library.h +++ b/src/SparkFun_Ublox_Arduino_Library.h @@ -582,6 +582,10 @@ class SFE_UBLOX_GPS //Change the dynamic platform model using UBX-CFG-NAV5 boolean setDynamicModel(dynModel newDynamicModel = DYN_MODEL_PORTABLE, uint16_t maxWait = 1100); + boolean getUdrStatus(uint16_t maxWait = 1100); + boolean getInsInfo(uint16_t maxWait = 1100); + boolean getExternSensMeas(uint16_t maxWait = 1100); + //Survey-in specific controls struct svinStructure { @@ -655,6 +659,33 @@ class SFE_UBLOX_GPS uint16_t rtcmFrameCounter = 0; //Tracks the type of incoming byte inside RTCM frame + struct udrData + { + uint8_t version; + uint8_t fusionMode; + uint8_t numSens; + + uint8_t xAngRateVald; + uint8_t yAngRateVald; + uint8_t zAngRateVald; + uint8_t xAccelVald; + uint8_t yAccelVald; + uint8_t zAccelVald; + + int32_t xAngRate; + int32_t yAngRate; + int32_t zAngRate; + + int32_t xAccel; + int32_t yAccel; + int32_t zAccel; + + // The array size is based on testing directly on M8U and F9R + uint32_t data[7]; + uint32_t dataType[7]; + uint32_t timeStamp[7]; + } imuMetric; + private: //Depending on the sentence type the processor will load characters into different arrays enum SentenceTypes From 7c3caab519bc69024321db4e7dfbc27649870a6a Mon Sep 17 00:00:00 2001 From: Elias Santistevan Date: Fri, 3 Apr 2020 09:34:31 -0600 Subject: [PATCH 02/13] Adds ubx message values, fixes typos --- examples/NEO-M8U/Example1_getIMU/Example1_getIMU.ino | 1 - src/SparkFun_Ublox_Arduino_Library.cpp | 2 +- src/SparkFun_Ublox_Arduino_Library.h | 9 +++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/NEO-M8U/Example1_getIMU/Example1_getIMU.ino b/examples/NEO-M8U/Example1_getIMU/Example1_getIMU.ino index 7d46873..6a3b2f3 100644 --- a/examples/NEO-M8U/Example1_getIMU/Example1_getIMU.ino +++ b/examples/NEO-M8U/Example1_getIMU/Example1_getIMU.ino @@ -1,4 +1,3 @@ - /* Some Description By: Elias Santistevan diff --git a/src/SparkFun_Ublox_Arduino_Library.cpp b/src/SparkFun_Ublox_Arduino_Library.cpp index 52c233a..1cd9767 100644 --- a/src/SparkFun_Ublox_Arduino_Library.cpp +++ b/src/SparkFun_Ublox_Arduino_Library.cpp @@ -2812,7 +2812,7 @@ boolean SFE_UBLOX_GPS::getEsfRaw(uint16_t maxWait) uint32_t bitField = extractLong(4 + byteOffset * i); imuMetric.dataType[i] = (bitField && 0xFF000000) >> 23; // Repeating Blocks on the back burner... - imuMetric.data[i] = (bitField && 0xFFFFFF) + imuMetric.data[i] = (bitField && 0xFFFFFF); imuMetric.timeStamp[i] = extractLong(8 + byteOffset * i); } diff --git a/src/SparkFun_Ublox_Arduino_Library.h b/src/SparkFun_Ublox_Arduino_Library.h index 47288af..9528f84 100644 --- a/src/SparkFun_Ublox_Arduino_Library.h +++ b/src/SparkFun_Ublox_Arduino_Library.h @@ -315,6 +315,14 @@ const uint8_t UBX_ACK_NACK = 0x00; const uint8_t UBX_ACK_ACK = 0x01; const uint8_t UBX_ACK_NONE = 0x02; //Not a real value +// The following constants are used to get External Sensor Measurements and Status +// Information. +const uint8_t UBX_ESF_MEAS = 0x02; +const uint8_t UBX_ESF_RAW = 0x03; +const uint8_t UBX_ESF_STATUS = 0x10; +const uint8_t UBX_ESF_INS = 0x15; //36 bytes + + const uint8_t SVIN_MODE_DISABLE = 0x00; const uint8_t SVIN_MODE_ENABLE = 0x01; @@ -585,6 +593,7 @@ class SFE_UBLOX_GPS boolean getUdrStatus(uint16_t maxWait = 1100); boolean getInsInfo(uint16_t maxWait = 1100); boolean getExternSensMeas(uint16_t maxWait = 1100); + boolean getEsfRaw(uint16_t maxWait = 1100); //Survey-in specific controls struct svinStructure From 9d5988080ff198243075ac284c052fcda3eb2961 Mon Sep 17 00:00:00 2001 From: Elias Santistevan Date: Thu, 16 Apr 2020 09:47:51 -0600 Subject: [PATCH 03/13] Adds sensor status function, changes name of imuMetric struct to imuData * Adds more fields to the imuData struct for Raw Data * Adds new struct for all sensor status information --- src/SparkFun_Ublox_Arduino_Library.cpp | 101 +++++++++++++++++++------ src/SparkFun_Ublox_Arduino_Library.h | 37 ++++++--- 2 files changed, 104 insertions(+), 34 deletions(-) diff --git a/src/SparkFun_Ublox_Arduino_Library.cpp b/src/SparkFun_Ublox_Arduino_Library.cpp index 1cd9767..5a457ba 100644 --- a/src/SparkFun_Ublox_Arduino_Library.cpp +++ b/src/SparkFun_Ublox_Arduino_Library.cpp @@ -2709,7 +2709,7 @@ boolean SFE_UBLOX_GPS::getRELPOSNED(uint16_t maxWait) return (true); } -boolean SFE_UBLOX_GPS::getUdrStatus(uint16_t maxWait) +boolean SFE_UBLOX_GPS::getEsfStatus(uint16_t maxWait) { // Requesting Data from the receiver packetCfg.cls = UBX_CLASS_ESF; @@ -2723,16 +2723,16 @@ boolean SFE_UBLOX_GPS::getUdrStatus(uint16_t maxWait) checkUblox(); // payload should be loaded. - imuMetric.version = extractByte(4); - imuMetric.fusionMode = extractByte(12); - imuMetric.numSens = extractByte(15); + imuData.version = extractByte(4); + imuData.fusionMode = extractByte(12); + imuData.numSens = extractByte(15); // Individual Status Sensor in different function return(true); } // -boolean SFE_UBLOX_GPS::getInsInfo(uint16_t maxWait) +boolean SFE_UBLOX_GPS::getEsfInfo(uint16_t maxWait) { packetCfg.cls = UBX_CLASS_ESF; packetCfg.id = UBX_ESF_INS; @@ -2747,26 +2747,26 @@ boolean SFE_UBLOX_GPS::getInsInfo(uint16_t maxWait) // Validity of each sensor value below uint32_t validity = extractLong(0); - imuMetric.xAngRateVald = (validity && 0x0080) >> 8; - imuMetric.yAngRateVald = (validity && 0x0100) >> 9; - imuMetric.zAngRateVald = (validity && 0x0200) >> 10; - imuMetric.xAccelVald = (validity && 0x0400) >> 11; - imuMetric.yAccelVald = (validity && 0x0800) >> 12; - imuMetric.zAccelVald = (validity && 0x1000) >> 13; + imuData.xAngRateVald = (validity && 0x0080) >> 8; + imuData.yAngRateVald = (validity && 0x0100) >> 9; + imuData.zAngRateVald = (validity && 0x0200) >> 10; + imuData.xAccelVald = (validity && 0x0400) >> 11; + imuData.yAccelVald = (validity && 0x0800) >> 12; + imuData.zAccelVald = (validity && 0x1000) >> 13; - imuMetric.xAngRate = extractLong(12); // deg/s - imuMetric.yAngRate = extractLong(16); // deg/s - imuMetric.zAngRate = extractLong(20); // deg/s + imuData.xAngRate = extractLong(12); // deg/s + imuData.yAngRate = extractLong(16); // deg/s + imuData.zAngRate = extractLong(20); // deg/s - imuMetric.xAccel = extractLong(24); // m/s - imuMetric.yAccel = extractLong(28); // m/s - imuMetric.zAccel = extractLong(32); // m/s + imuData.xAccel = extractLong(24); // m/s + imuData.yAccel = extractLong(28); // m/s + imuData.zAccel = extractLong(32); // m/s return(true); } // -boolean SFE_UBLOX_GPS::getExternSensMeas(uint16_t maxWait) +boolean SFE_UBLOX_GPS::getEsfMeas(uint16_t maxWait) { packetCfg.cls = UBX_CLASS_ESF; @@ -2787,14 +2787,23 @@ boolean SFE_UBLOX_GPS::getExternSensMeas(uint16_t maxWait) uint8_t tagValid = (flags && 0x04) >> 3; uint8_t numMeas = (flags && 0x1000) >> 15; + uint8_t byteOffset = 4; + + for(uint8_t i=0; i> 23; + imuData.data[i] = (bitField && 0xFFFFFF); + imuData.dataTStamp[i] = extractLong(8 + byteOffset * i); + + } + } boolean SFE_UBLOX_GPS::getEsfRaw(uint16_t maxWait) { - // Need the number of sensors to know what to sample. - getUdrStatus(); - + // Need to know the number of sensor to get the correct data // Rate selected in UBX-CFG-MSG is not respected packetCfg.cls = UBX_CLASS_ESF; packetCfg.id = UBX_ESF_RAW; @@ -2808,13 +2817,55 @@ boolean SFE_UBLOX_GPS::getEsfRaw(uint16_t maxWait) uint8_t byteOffset = 8; - for(uint8_t i=0; i> 23; // Repeating Blocks on the back burner... - imuMetric.data[i] = (bitField && 0xFFFFFF); - imuMetric.timeStamp[i] = extractLong(8 + byteOffset * i); + imuData.rawDataType[i] = (bitField && 0xFF000000) >> 23; + imuData.rawData[i] = (bitField && 0xFFFFFF); + imuData.rawTStamp[i] = extractLong(8 + byteOffset * i); } } +boolean SFE_UBLOX_GPS::getSensorStatus(uint8_t sensor) +{ + + packetCfg.cls = UBX_CLASS_ESF; + packetCfg.id = UBX_ESF_STATUS; + packetCfg.len = 0; + packetCfg.startingSpot = 0; + + if (sendCommand(packetCfg, maxWait) == false) + return (false); //If command send fails then bail + + uint8_t numberSens = extactByte(15) + if (sensor > numberSens) + return SFE_UBLOX_STATUS_OUT_OF_RANGE; + + checkUblox(); + + uint8_t offset = 4; + + // Only the last sensor value checked will remain. + for(uint8_t i=0; i> 5; + ubloxSen.isUsed = (sensorFieldOne && 0x20) >> 6; + ubloxSen.isReady = (sensorFieldOne && 0x30) >> 7; + + ubloxSen.calibStatus = sensorFieldTwo && 0x03; + ubloxSen.timeStatus = (sensorFieldTwo && 0xC) >> 2; + + ubloxSen.badMeas = (sensorFieldThr && 0x01); + ubloxSen.badTag = (sensorFieldThr && 0x02) >> 1; + ubloxSen.missMeas = (sensorFieldThr && 0x04) >> 2; + ubloxSen.noisyMeas = (sensorFieldThr && 0x08) >> 3; + } + +} + diff --git a/src/SparkFun_Ublox_Arduino_Library.h b/src/SparkFun_Ublox_Arduino_Library.h index 9528f84..8b17c8e 100644 --- a/src/SparkFun_Ublox_Arduino_Library.h +++ b/src/SparkFun_Ublox_Arduino_Library.h @@ -590,9 +590,9 @@ class SFE_UBLOX_GPS //Change the dynamic platform model using UBX-CFG-NAV5 boolean setDynamicModel(dynModel newDynamicModel = DYN_MODEL_PORTABLE, uint16_t maxWait = 1100); - boolean getUdrStatus(uint16_t maxWait = 1100); - boolean getInsInfo(uint16_t maxWait = 1100); - boolean getExternSensMeas(uint16_t maxWait = 1100); + boolean getEsfStatus(uint16_t maxWait = 1100); + boolean getEsfInfo(uint16_t maxWait = 1100); + boolean getEsfMeas(uint16_t maxWait = 1100); boolean getEsfRaw(uint16_t maxWait = 1100); //Survey-in specific controls @@ -668,11 +668,12 @@ class SFE_UBLOX_GPS uint16_t rtcmFrameCounter = 0; //Tracks the type of incoming byte inside RTCM frame - struct udrData +#define DEF_NUM_SENS 7 + struct deadReckData { uint8_t version; uint8_t fusionMode; - uint8_t numSens; + uint8_t numSens = DEF_NUM_SENS; uint8_t xAngRateVald; uint8_t yAngRateVald; @@ -690,10 +691,28 @@ class SFE_UBLOX_GPS int32_t zAccel; // The array size is based on testing directly on M8U and F9R - uint32_t data[7]; - uint32_t dataType[7]; - uint32_t timeStamp[7]; - } imuMetric; + uint32_t rawData[numSens]; + uint32_t rawDataType[numSens]; + uint32_t rawTstamp[numSens]; + + uint32_t data[numSens]; + uint32_t dataType[numSens]; + uint32_t dataTstamp[numSens]; + } imuData; + + struct indivImuData + { + uint8_t senType; + bool isUsed; + bool isReady; + uint8_t calibStatus; + uint8_t timeStatus; + uint8_t freq; // Hz + uint8_t badMeas; + uint8_t badTag; + uint8_t missMeas; + uint8_t noisyMeas; + } ubloxSen; private: //Depending on the sentence type the processor will load characters into different arrays From 0cbbfb269c774817a7c5ea8a256a280ff8b18652 Mon Sep 17 00:00:00 2001 From: Elias Santistevan Date: Thu, 16 Apr 2020 14:48:39 -0600 Subject: [PATCH 04/13] Renames functions so that they make sense with what they do * correctly checks for ublox return code when using sendCommand() * Irons out a few typos --- .../Example1_getIMU/Example1_getIMU.ino | 26 +++---- src/SparkFun_Ublox_Arduino_Library.cpp | 78 ++++++++++--------- src/SparkFun_Ublox_Arduino_Library.h | 33 ++++---- 3 files changed, 69 insertions(+), 68 deletions(-) diff --git a/examples/NEO-M8U/Example1_getIMU/Example1_getIMU.ino b/examples/NEO-M8U/Example1_getIMU/Example1_getIMU.ino index 6a3b2f3..d2a85cc 100644 --- a/examples/NEO-M8U/Example1_getIMU/Example1_getIMU.ino +++ b/examples/NEO-M8U/Example1_getIMU/Example1_getIMU.ino @@ -38,35 +38,27 @@ void setup() } myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) - - if (myGPS.getUdrStatus()) - { - Serial.print("Mode: "); - Serial.println(myGPS.imuMetric.fusionMode); - Serial.print("Number of Sensors: "); - Serial.println(myGPS.imuMetric.numSens); - } } void loop() { - if (myGPS.getUdrStatus()) - Serial.println(myGPS.imuMetric.fusionMode); + if (myGPS.getEsfInfo()) + Serial.println(myGPS.imuMeas.fusionMode); - if (myGPS.getInsInfo()) + if (myGPS.getEsfMeas()) { Serial.print("X validity: "); - Serial.println(myGPS.imuMetric.xAngRateVald); + Serial.println(myGPS.imuMeas.xAngRateVald); Serial.print("X: "); - Serial.println(myGPS.imuMetric.xAngRate); + Serial.println(myGPS.imuMeas.xAngRate); Serial.print("Y validity: "); - Serial.println(myGPS.imuMetric.yAngRateVald); + Serial.println(myGPS.imuMeas.yAngRateVald); Serial.print("Y: "); - Serial.println(myGPS.imuMetric.yAngRate); + Serial.println(myGPS.imuMeas.yAngRate); Serial.print("Z validity: "); - Serial.println(myGPS.imuMetric.zAngRateVald); + Serial.println(myGPS.imuMeas.zAngRateVald); Serial.print("Z: "); - Serial.println(myGPS.imuMetric.zAngRate); + Serial.println(myGPS.imuMeas.zAngRate); } delay(250); } diff --git a/src/SparkFun_Ublox_Arduino_Library.cpp b/src/SparkFun_Ublox_Arduino_Library.cpp index 5a457ba..be3204b 100644 --- a/src/SparkFun_Ublox_Arduino_Library.cpp +++ b/src/SparkFun_Ublox_Arduino_Library.cpp @@ -2709,7 +2709,7 @@ boolean SFE_UBLOX_GPS::getRELPOSNED(uint16_t maxWait) return (true); } -boolean SFE_UBLOX_GPS::getEsfStatus(uint16_t maxWait) +boolean SFE_UBLOX_GPS::getEsfInfo(uint16_t maxWait) { // Requesting Data from the receiver packetCfg.cls = UBX_CLASS_ESF; @@ -2717,29 +2717,28 @@ boolean SFE_UBLOX_GPS::getEsfStatus(uint16_t maxWait) packetCfg.len = 0; packetCfg.startingSpot = 0; - if (sendCommand(packetCfg, maxWait) == false) + if (sendCommand(packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) return (false); //If command send fails then bail checkUblox(); // payload should be loaded. - imuData.version = extractByte(4); - imuData.fusionMode = extractByte(12); - imuData.numSens = extractByte(15); + imuMeas.version = extractByte(4); + imuMeas.fusionMode = extractByte(12); // Individual Status Sensor in different function return(true); } // -boolean SFE_UBLOX_GPS::getEsfInfo(uint16_t maxWait) +boolean SFE_UBLOX_GPS::getEsfMeas(uint16_t maxWait) { packetCfg.cls = UBX_CLASS_ESF; packetCfg.id = UBX_ESF_INS; packetCfg.len = 0; packetCfg.startingSpot = 0; - if (sendCommand(packetCfg, maxWait) == false) + if (sendCommand(packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) return (false); //If command send fails then bail checkUblox(); @@ -2747,26 +2746,26 @@ boolean SFE_UBLOX_GPS::getEsfInfo(uint16_t maxWait) // Validity of each sensor value below uint32_t validity = extractLong(0); - imuData.xAngRateVald = (validity && 0x0080) >> 8; - imuData.yAngRateVald = (validity && 0x0100) >> 9; - imuData.zAngRateVald = (validity && 0x0200) >> 10; - imuData.xAccelVald = (validity && 0x0400) >> 11; - imuData.yAccelVald = (validity && 0x0800) >> 12; - imuData.zAccelVald = (validity && 0x1000) >> 13; + imuMeas.xAngRateVald = (validity && 0x0080) >> 8; + imuMeas.yAngRateVald = (validity && 0x0100) >> 9; + imuMeas.zAngRateVald = (validity && 0x0200) >> 10; + imuMeas.xAccelVald = (validity && 0x0400) >> 11; + imuMeas.yAccelVald = (validity && 0x0800) >> 12; + imuMeas.zAccelVald = (validity && 0x1000) >> 13; - imuData.xAngRate = extractLong(12); // deg/s - imuData.yAngRate = extractLong(16); // deg/s - imuData.zAngRate = extractLong(20); // deg/s + imuMeas.xAngRate = extractLong(12); // deg/s + imuMeas.yAngRate = extractLong(16); // deg/s + imuMeas.zAngRate = extractLong(20); // deg/s - imuData.xAccel = extractLong(24); // m/s - imuData.yAccel = extractLong(28); // m/s - imuData.zAccel = extractLong(32); // m/s + imuMeas.xAccel = extractLong(24); // m/s + imuMeas.yAccel = extractLong(28); // m/s + imuMeas.zAccel = extractLong(32); // m/s return(true); } // -boolean SFE_UBLOX_GPS::getEsfMeas(uint16_t maxWait) +boolean SFE_UBLOX_GPS::getEsfDataInfo(uint16_t maxWait) { packetCfg.cls = UBX_CLASS_ESF; @@ -2774,7 +2773,7 @@ boolean SFE_UBLOX_GPS::getEsfMeas(uint16_t maxWait) packetCfg.len = 0; packetCfg.startingSpot = 0; - if (sendCommand(packetCfg, maxWait) == false) + if (sendCommand(packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) return (false); //If command send fails then bail checkUblox(); @@ -2788,19 +2787,20 @@ boolean SFE_UBLOX_GPS::getEsfMeas(uint16_t maxWait) uint8_t numMeas = (flags && 0x1000) >> 15; uint8_t byteOffset = 4; + uint8_t numSens = extractByte(15); - for(uint8_t i=0; i> 23; - imuData.data[i] = (bitField && 0xFFFFFF); - imuData.dataTStamp[i] = extractLong(8 + byteOffset * i); + imuMeas.dataType[i] = (bitField && 0xFF000000) >> 23; + imuMeas.data[i] = (bitField && 0xFFFFFF); + imuMeas.dataTStamp[i] = extractLong(8 + byteOffset * i); } } -boolean SFE_UBLOX_GPS::getEsfRaw(uint16_t maxWait) +boolean SFE_UBLOX_GPS::getEsfRawDataInfo(uint16_t maxWait) { // Need to know the number of sensor to get the correct data @@ -2810,24 +2810,25 @@ boolean SFE_UBLOX_GPS::getEsfRaw(uint16_t maxWait) packetCfg.len = 0; packetCfg.startingSpot = 0; - if (sendCommand(packetCfg, maxWait) == false) + if (sendCommand(packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) return (false); //If command send fails then bail checkUblox(); uint8_t byteOffset = 8; + uint8_t numSens = extractByte(15); - for(uint8_t i=0; i> 23; - imuData.rawData[i] = (bitField && 0xFFFFFF); - imuData.rawTStamp[i] = extractLong(8 + byteOffset * i); + imuMeas.rawDataType[i] = (bitField && 0xFF000000) >> 23; + imuMeas.rawData[i] = (bitField && 0xFFFFFF); + imuMeas.rawTStamp[i] = extractLong(8 + byteOffset * i); } } -boolean SFE_UBLOX_GPS::getSensorStatus(uint8_t sensor) +sfe_ublox_status_e SFE_UBLOX_GPS::getSensState(uint8_t sensor, uint16_t maxWait) { packetCfg.cls = UBX_CLASS_ESF; @@ -2835,11 +2836,12 @@ boolean SFE_UBLOX_GPS::getSensorStatus(uint8_t sensor) packetCfg.len = 0; packetCfg.startingSpot = 0; - if (sendCommand(packetCfg, maxWait) == false) - return (false); //If command send fails then bail + if (sendCommand(packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) + return (SFE_UBLOX_STATUS_FAIL); //If command send fails then bail + + ubloxSen.numSens = extractByte(15); - uint8_t numberSens = extactByte(15) - if (sensor > numberSens) + if (sensor > ubloxSen.numSens) return SFE_UBLOX_STATUS_OUT_OF_RANGE; checkUblox(); @@ -2851,7 +2853,7 @@ boolean SFE_UBLOX_GPS::getSensorStatus(uint8_t sensor) uint8_t sensorFieldOne = extractByte(16 + offset * i); uint8_t sensorFieldTwo = extractByte(17 + offset * i); - ublox.freq = extractByte(18 + offset * i); + ubloxSen.freq = extractByte(18 + offset * i); uint8_t sensorFieldThr = extractByte(19 + offset * i); ubloxSen.senType = (sensorFieldOne && 0x10) >> 5; @@ -2866,6 +2868,8 @@ boolean SFE_UBLOX_GPS::getSensorStatus(uint8_t sensor) ubloxSen.missMeas = (sensorFieldThr && 0x04) >> 2; ubloxSen.noisyMeas = (sensorFieldThr && 0x08) >> 3; } + + return SFE_UBLOX_STATUS_SUCCESS; } diff --git a/src/SparkFun_Ublox_Arduino_Library.h b/src/SparkFun_Ublox_Arduino_Library.h index 8b17c8e..b9f96fa 100644 --- a/src/SparkFun_Ublox_Arduino_Library.h +++ b/src/SparkFun_Ublox_Arduino_Library.h @@ -590,10 +590,11 @@ class SFE_UBLOX_GPS //Change the dynamic platform model using UBX-CFG-NAV5 boolean setDynamicModel(dynModel newDynamicModel = DYN_MODEL_PORTABLE, uint16_t maxWait = 1100); - boolean getEsfStatus(uint16_t maxWait = 1100); boolean getEsfInfo(uint16_t maxWait = 1100); boolean getEsfMeas(uint16_t maxWait = 1100); - boolean getEsfRaw(uint16_t maxWait = 1100); + boolean getEsfDataInfo(uint16_t maxWait = 1100); + boolean getEsfRawDataInfo(uint16_t maxWait = 1100); + sfe_ublox_status_e getSensState(uint8_t sensor, uint16_t maxWait = 1100); //Survey-in specific controls struct svinStructure @@ -673,7 +674,6 @@ class SFE_UBLOX_GPS { uint8_t version; uint8_t fusionMode; - uint8_t numSens = DEF_NUM_SENS; uint8_t xAngRateVald; uint8_t yAngRateVald; @@ -691,27 +691,32 @@ class SFE_UBLOX_GPS int32_t zAccel; // The array size is based on testing directly on M8U and F9R - uint32_t rawData[numSens]; - uint32_t rawDataType[numSens]; - uint32_t rawTstamp[numSens]; + uint32_t rawData[DEF_NUM_SENS]; + uint32_t rawDataType[DEF_NUM_SENS]; + uint32_t rawTStamp[DEF_NUM_SENS]; - uint32_t data[numSens]; - uint32_t dataType[numSens]; - uint32_t dataTstamp[numSens]; - } imuData; + uint32_t data[DEF_NUM_SENS]; + uint32_t dataType[DEF_NUM_SENS]; + uint32_t dataTStamp[DEF_NUM_SENS]; + } imuMeas; struct indivImuData { + + uint8_t numSens; + uint8_t senType; bool isUsed; bool isReady; uint8_t calibStatus; uint8_t timeStatus; + uint8_t freq; // Hz - uint8_t badMeas; - uint8_t badTag; - uint8_t missMeas; - uint8_t noisyMeas; + + bool badMeas; + bool badTag; + bool missMeas; + bool noisyMeas; } ubloxSen; private: From 3c4eafba65c40bc58525a704d190f1d0e7b7c905 Mon Sep 17 00:00:00 2001 From: Elias Santistevan Date: Thu, 16 Apr 2020 14:50:43 -0600 Subject: [PATCH 05/13] Renames example code - no additions to example code yet --- .../Example1_getIMU.ino | 0 .../Example1_getIMUData.ino | 65 +++++++++++++++++++ 2 files changed, 65 insertions(+) rename examples/{NEO-M8U/Example1_getIMU => Dead Reckoning/Example1_calibrateSensor}/Example1_getIMU.ino (100%) create mode 100644 examples/Dead Reckoning/Example2_getImuData/Example1_getIMUData.ino diff --git a/examples/NEO-M8U/Example1_getIMU/Example1_getIMU.ino b/examples/Dead Reckoning/Example1_calibrateSensor/Example1_getIMU.ino similarity index 100% rename from examples/NEO-M8U/Example1_getIMU/Example1_getIMU.ino rename to examples/Dead Reckoning/Example1_calibrateSensor/Example1_getIMU.ino diff --git a/examples/Dead Reckoning/Example2_getImuData/Example1_getIMUData.ino b/examples/Dead Reckoning/Example2_getImuData/Example1_getIMUData.ino new file mode 100644 index 0000000..d2a85cc --- /dev/null +++ b/examples/Dead Reckoning/Example2_getImuData/Example1_getIMUData.ino @@ -0,0 +1,65 @@ +/* + Some Description + By: Elias Santistevan + SparkFun Electronics + Date: February + License: MIT. See license file for more information but you can + basically do whatever you want with this code. + + + Feel like supporting open source hardware? + Buy a board from SparkFun! + NEO-M8U: https://www.sparkfun.com/products/15136 + ZED-F9R: https://www.sparkfun.com/products/15136 + + Hardware Connections: + Plug a Qwiic cable into the GPS and a BlackBoard + If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) + Open the serial monitor at 115200 baud to see the output +*/ + +#include //Needed for I2C to GPS + +#include //http://librarymanager/All#SparkFun_Ublox_GPS +SFE_UBLOX_GPS myGPS; + +void setup() +{ + Serial.begin(115200); + while (!Serial); //Wait for user to open terminal + Serial.println("SparkFun Ublox Example"); + + Wire.begin(); + + if (myGPS.begin() == false) //Connect to the Ublox module using Wire port + { + Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing.")); + while (1); + } + + myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) +} + +void loop() +{ + if (myGPS.getEsfInfo()) + Serial.println(myGPS.imuMeas.fusionMode); + + if (myGPS.getEsfMeas()) + { + Serial.print("X validity: "); + Serial.println(myGPS.imuMeas.xAngRateVald); + Serial.print("X: "); + Serial.println(myGPS.imuMeas.xAngRate); + Serial.print("Y validity: "); + Serial.println(myGPS.imuMeas.yAngRateVald); + Serial.print("Y: "); + Serial.println(myGPS.imuMeas.yAngRate); + Serial.print("Z validity: "); + Serial.println(myGPS.imuMeas.zAngRateVald); + Serial.print("Z: "); + Serial.println(myGPS.imuMeas.zAngRate); + } + delay(250); +} + From a8fc05f427887ad36d567db67a2beb00cc15b4a6 Mon Sep 17 00:00:00 2001 From: Elias Santistevan Date: Thu, 16 Apr 2020 15:58:35 -0600 Subject: [PATCH 06/13] Adds one more place holder example sketch (not implemented) --- .../Example1_getIMU.ino | 17 ----- .../Example1_getSensorStatus.ino | 65 +++++++++++++++++++ 2 files changed, 65 insertions(+), 17 deletions(-) create mode 100644 examples/Dead Reckoning/Example3_getSensorStatus/Example1_getSensorStatus.ino diff --git a/examples/Dead Reckoning/Example1_calibrateSensor/Example1_getIMU.ino b/examples/Dead Reckoning/Example1_calibrateSensor/Example1_getIMU.ino index d2a85cc..06366c3 100644 --- a/examples/Dead Reckoning/Example1_calibrateSensor/Example1_getIMU.ino +++ b/examples/Dead Reckoning/Example1_calibrateSensor/Example1_getIMU.ino @@ -45,21 +45,4 @@ void loop() if (myGPS.getEsfInfo()) Serial.println(myGPS.imuMeas.fusionMode); - if (myGPS.getEsfMeas()) - { - Serial.print("X validity: "); - Serial.println(myGPS.imuMeas.xAngRateVald); - Serial.print("X: "); - Serial.println(myGPS.imuMeas.xAngRate); - Serial.print("Y validity: "); - Serial.println(myGPS.imuMeas.yAngRateVald); - Serial.print("Y: "); - Serial.println(myGPS.imuMeas.yAngRate); - Serial.print("Z validity: "); - Serial.println(myGPS.imuMeas.zAngRateVald); - Serial.print("Z: "); - Serial.println(myGPS.imuMeas.zAngRate); - } - delay(250); -} diff --git a/examples/Dead Reckoning/Example3_getSensorStatus/Example1_getSensorStatus.ino b/examples/Dead Reckoning/Example3_getSensorStatus/Example1_getSensorStatus.ino new file mode 100644 index 0000000..d2a85cc --- /dev/null +++ b/examples/Dead Reckoning/Example3_getSensorStatus/Example1_getSensorStatus.ino @@ -0,0 +1,65 @@ +/* + Some Description + By: Elias Santistevan + SparkFun Electronics + Date: February + License: MIT. See license file for more information but you can + basically do whatever you want with this code. + + + Feel like supporting open source hardware? + Buy a board from SparkFun! + NEO-M8U: https://www.sparkfun.com/products/15136 + ZED-F9R: https://www.sparkfun.com/products/15136 + + Hardware Connections: + Plug a Qwiic cable into the GPS and a BlackBoard + If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) + Open the serial monitor at 115200 baud to see the output +*/ + +#include //Needed for I2C to GPS + +#include //http://librarymanager/All#SparkFun_Ublox_GPS +SFE_UBLOX_GPS myGPS; + +void setup() +{ + Serial.begin(115200); + while (!Serial); //Wait for user to open terminal + Serial.println("SparkFun Ublox Example"); + + Wire.begin(); + + if (myGPS.begin() == false) //Connect to the Ublox module using Wire port + { + Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing.")); + while (1); + } + + myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) +} + +void loop() +{ + if (myGPS.getEsfInfo()) + Serial.println(myGPS.imuMeas.fusionMode); + + if (myGPS.getEsfMeas()) + { + Serial.print("X validity: "); + Serial.println(myGPS.imuMeas.xAngRateVald); + Serial.print("X: "); + Serial.println(myGPS.imuMeas.xAngRate); + Serial.print("Y validity: "); + Serial.println(myGPS.imuMeas.yAngRateVald); + Serial.print("Y: "); + Serial.println(myGPS.imuMeas.yAngRate); + Serial.print("Z validity: "); + Serial.println(myGPS.imuMeas.zAngRateVald); + Serial.print("Z: "); + Serial.println(myGPS.imuMeas.zAngRate); + } + delay(250); +} + From 29449fce5ea2fcff468857436b4dfd9774c5230e Mon Sep 17 00:00:00 2001 From: Elias Santistevan Date: Fri, 17 Apr 2020 10:53:22 -0600 Subject: [PATCH 07/13] Removes array from raw data, updates example 1 --- ...etIMU.ino => Example1_calibrateSensor.ino} | 27 +++++++++++++++---- src/SparkFun_Ublox_Arduino_Library.cpp | 24 +++++++---------- src/SparkFun_Ublox_Arduino_Library.h | 8 +++--- 3 files changed, 35 insertions(+), 24 deletions(-) rename examples/Dead Reckoning/Example1_calibrateSensor/{Example1_getIMU.ino => Example1_calibrateSensor.ino} (50%) diff --git a/examples/Dead Reckoning/Example1_calibrateSensor/Example1_getIMU.ino b/examples/Dead Reckoning/Example1_calibrateSensor/Example1_calibrateSensor.ino similarity index 50% rename from examples/Dead Reckoning/Example1_calibrateSensor/Example1_getIMU.ino rename to examples/Dead Reckoning/Example1_calibrateSensor/Example1_calibrateSensor.ino index 06366c3..9a66707 100644 --- a/examples/Dead Reckoning/Example1_calibrateSensor/Example1_getIMU.ino +++ b/examples/Dead Reckoning/Example1_calibrateSensor/Example1_calibrateSensor.ino @@ -9,13 +9,25 @@ Feel like supporting open source hardware? Buy a board from SparkFun! - NEO-M8U: https://www.sparkfun.com/products/15136 - ZED-F9R: https://www.sparkfun.com/products/15136 + NEO-M8U: https://www.sparkfun.com/products/16329 + ZED-F9R: https://www.sparkfun.com/products/16344 Hardware Connections: - Plug a Qwiic cable into the GPS and a BlackBoard + Plug a Qwiic cable into the GPS and a Redboard Qwiic If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) Open the serial monitor at 115200 baud to see the output + + To take advantage of the internal IMU of either the Dead Reckoning GPS + boards (ZED-F9R, NEO-M8U), you must first calibrate them. This includes securing the GPS module + to your vehicle so that it is stable within 2 degrees and that the frame of + reference of the board is consistent with the picture outlined in the + Receiver-Description-Prot-Spec Datasheet under Automotive/Untethered Dead + Reckoning. You may also check either the ZED-F9R or NEO-M8U Hookup Guide for + more information. After the board is secure, you'll need to put the module + through certain conditions for proper calibration: acceleration, turning, + stopping, all under a clear sky with good GNSS signal. This example simply looks at the + "fusionMode" status which indicates whether the SparkFun Dead Reckoning is + not-calibrated - 0, or calibrated - 1. */ #include //Needed for I2C to GPS @@ -42,7 +54,12 @@ void setup() void loop() { - if (myGPS.getEsfInfo()) - Serial.println(myGPS.imuMeas.fusionMode); + if (myGPS.getEsfInfo()){ + Serial.println(myGPS.imuMeas.fusionMode); + if (myGPS.imuMeas.fusionMode) == 1 + Serial.println("Sensor is calibrated!"); + } + delay(250) +} diff --git a/src/SparkFun_Ublox_Arduino_Library.cpp b/src/SparkFun_Ublox_Arduino_Library.cpp index be3204b..965556c 100644 --- a/src/SparkFun_Ublox_Arduino_Library.cpp +++ b/src/SparkFun_Ublox_Arduino_Library.cpp @@ -2731,7 +2731,7 @@ boolean SFE_UBLOX_GPS::getEsfInfo(uint16_t maxWait) } // -boolean SFE_UBLOX_GPS::getEsfMeas(uint16_t maxWait) +boolean SFE_UBLOX_GPS::getEsfIns(uint16_t maxWait) { packetCfg.cls = UBX_CLASS_ESF; packetCfg.id = UBX_ESF_INS; @@ -2760,8 +2760,6 @@ boolean SFE_UBLOX_GPS::getEsfMeas(uint16_t maxWait) imuMeas.xAccel = extractLong(24); // m/s imuMeas.yAccel = extractLong(28); // m/s imuMeas.zAccel = extractLong(32); // m/s - - return(true); } // @@ -2786,10 +2784,12 @@ boolean SFE_UBLOX_GPS::getEsfDataInfo(uint16_t maxWait) uint8_t tagValid = (flags && 0x04) >> 3; uint8_t numMeas = (flags && 0x1000) >> 15; + if (numMeas > DEF_NUM_SENS) + numMeas = DEF_NUM_SENS; + uint8_t byteOffset = 4; - uint8_t numSens = extractByte(15); - for(uint8_t i=0; i> 23; @@ -2815,17 +2815,11 @@ boolean SFE_UBLOX_GPS::getEsfRawDataInfo(uint16_t maxWait) checkUblox(); - uint8_t byteOffset = 8; - uint8_t numSens = extractByte(15); - - for(uint8_t i=0; i> 23; + imuMeas.rawData = (bitField && 0xFFFFFF); + imuMeas.rawTStamp = extractLong(8); - uint32_t bitField = extractLong(4 + byteOffset * i); - imuMeas.rawDataType[i] = (bitField && 0xFF000000) >> 23; - imuMeas.rawData[i] = (bitField && 0xFFFFFF); - imuMeas.rawTStamp[i] = extractLong(8 + byteOffset * i); - - } } sfe_ublox_status_e SFE_UBLOX_GPS::getSensState(uint8_t sensor, uint16_t maxWait) diff --git a/src/SparkFun_Ublox_Arduino_Library.h b/src/SparkFun_Ublox_Arduino_Library.h index b9f96fa..c78931a 100644 --- a/src/SparkFun_Ublox_Arduino_Library.h +++ b/src/SparkFun_Ublox_Arduino_Library.h @@ -591,7 +591,7 @@ class SFE_UBLOX_GPS boolean setDynamicModel(dynModel newDynamicModel = DYN_MODEL_PORTABLE, uint16_t maxWait = 1100); boolean getEsfInfo(uint16_t maxWait = 1100); - boolean getEsfMeas(uint16_t maxWait = 1100); + boolean getEsfIns(uint16_t maxWait = 1100); boolean getEsfDataInfo(uint16_t maxWait = 1100); boolean getEsfRawDataInfo(uint16_t maxWait = 1100); sfe_ublox_status_e getSensState(uint8_t sensor, uint16_t maxWait = 1100); @@ -691,9 +691,9 @@ class SFE_UBLOX_GPS int32_t zAccel; // The array size is based on testing directly on M8U and F9R - uint32_t rawData[DEF_NUM_SENS]; - uint32_t rawDataType[DEF_NUM_SENS]; - uint32_t rawTStamp[DEF_NUM_SENS]; + uint32_t rawData; + uint32_t rawDataType; + uint32_t rawTStamp; uint32_t data[DEF_NUM_SENS]; uint32_t dataType[DEF_NUM_SENS]; From 33e8fe218ec1cc155d97f0ecbc253032e1dd7928 Mon Sep 17 00:00:00 2001 From: Elias Santistevan Date: Fri, 17 Apr 2020 11:06:35 -0600 Subject: [PATCH 08/13] Adds vehicle attitude function and struct to handle data, fixes example 1 --- .../Example1_calibrateSensor.ino | 4 +-- src/SparkFun_Ublox_Arduino_Library.cpp | 18 +++++++++++++ src/SparkFun_Ublox_Arduino_Library.h | 25 ++++++++++++++----- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/examples/Dead Reckoning/Example1_calibrateSensor/Example1_calibrateSensor.ino b/examples/Dead Reckoning/Example1_calibrateSensor/Example1_calibrateSensor.ino index 9a66707..893e38f 100644 --- a/examples/Dead Reckoning/Example1_calibrateSensor/Example1_calibrateSensor.ino +++ b/examples/Dead Reckoning/Example1_calibrateSensor/Example1_calibrateSensor.ino @@ -57,9 +57,9 @@ void loop() if (myGPS.getEsfInfo()){ Serial.println(myGPS.imuMeas.fusionMode); - if (myGPS.imuMeas.fusionMode) == 1 + if (myGPS.imuMeas.fusionMode == 1) Serial.println("Sensor is calibrated!"); } - delay(250) + delay(250); } diff --git a/src/SparkFun_Ublox_Arduino_Library.cpp b/src/SparkFun_Ublox_Arduino_Library.cpp index 965556c..1439015 100644 --- a/src/SparkFun_Ublox_Arduino_Library.cpp +++ b/src/SparkFun_Ublox_Arduino_Library.cpp @@ -2867,3 +2867,21 @@ sfe_ublox_status_e SFE_UBLOX_GPS::getSensState(uint8_t sensor, uint16_t maxWait) } +bool SFE_UBLOX_GPS::getVehAtt(uint16_t maxWait){ + + packetCfg.cls = UBX_CLASS_NAV; + packetCfg.id = UBX_NAV_ATT; + packetCfg.len = 0; + packetCfg.startingSpot = 0; + + checkUblox(); + + vehAtt.roll = extractLong(8); + vehAtt.pitch = extractLong(12); + vehAtt.heading = extractLong(16); + + vehAtt.accRoll = extractLong(20); + vehAtt.accPitch = extractLong(24); + vehAtt.accHeading = extractLong(28); + +} diff --git a/src/SparkFun_Ublox_Arduino_Library.h b/src/SparkFun_Ublox_Arduino_Library.h index c78931a..cdfc4e3 100644 --- a/src/SparkFun_Ublox_Arduino_Library.h +++ b/src/SparkFun_Ublox_Arduino_Library.h @@ -255,6 +255,7 @@ const uint8_t UBX_MON_TXBUF = 0x08; //Transmitter Buffer Status. Used for query const uint8_t UBX_MON_VER = 0x04; //Receiver/Software Version. Used for obtaining Protocol Version. //The following are used to configure the NAV UBX messages (navigation results messages). Descriptions from UBX messages overview (ZED_F9P Interface Description Document page 35-36) +const uint8_t UBX_NAV_ATT = 0x05; //Vehicle "Attitude" Solution const uint8_t UBX_NAV_CLOCK = 0x22; //Clock Solution const uint8_t UBX_NAV_DOP = 0x04; //Dilution of precision const uint8_t UBX_NAV_EOE = 0x61; //End of Epoch @@ -595,6 +596,7 @@ class SFE_UBLOX_GPS boolean getEsfDataInfo(uint16_t maxWait = 1100); boolean getEsfRawDataInfo(uint16_t maxWait = 1100); sfe_ublox_status_e getSensState(uint8_t sensor, uint16_t maxWait = 1100); + boolean getVehAtt(uint16_t maxWait = 1100); //Survey-in specific controls struct svinStructure @@ -706,19 +708,30 @@ class SFE_UBLOX_GPS uint8_t numSens; uint8_t senType; - bool isUsed; - bool isReady; + boolean isUsed; + boolean isReady; uint8_t calibStatus; uint8_t timeStatus; uint8_t freq; // Hz - bool badMeas; - bool badTag; - bool missMeas; - bool noisyMeas; + boolean badMeas; + boolean badTag; + boolean missMeas; + boolean noisyMeas; } ubloxSen; + struct vehicleAttitude + { + // All values in degrees + int32_t roll; + int32_t pitch; + int32_t heading; + uint32_t accRoll; + uint32_t accPitch; + uint32_t accHeading; + } vehAtt; + private: //Depending on the sentence type the processor will load characters into different arrays enum SentenceTypes From 156233ddf26dfb8ac49fff48dd00963140e1b559 Mon Sep 17 00:00:00 2001 From: Elias Santistevan Date: Fri, 17 Apr 2020 16:00:08 -0600 Subject: [PATCH 09/13] Fixes naming of example code, fleashes out example 2-3 --- .../Example1_calibrateSensor.ino | 8 +- .../Example2_getIMUData.ino | 84 ++++++++++++++++ .../Example1_getIMUData.ino | 65 ------------- .../Example1_getSensorStatus.ino | 65 ------------- .../Example3_getSensorStatus.ino | 97 +++++++++++++++++++ src/SparkFun_Ublox_Arduino_Library.cpp | 5 +- 6 files changed, 189 insertions(+), 135 deletions(-) create mode 100644 examples/Dead Reckoning/Example2_getIMUData/Example2_getIMUData.ino delete mode 100644 examples/Dead Reckoning/Example2_getImuData/Example1_getIMUData.ino delete mode 100644 examples/Dead Reckoning/Example3_getSensorStatus/Example1_getSensorStatus.ino create mode 100644 examples/Dead Reckoning/Example3_getSensorStatus/Example3_getSensorStatus.ino diff --git a/examples/Dead Reckoning/Example1_calibrateSensor/Example1_calibrateSensor.ino b/examples/Dead Reckoning/Example1_calibrateSensor/Example1_calibrateSensor.ino index 893e38f..8809e1e 100644 --- a/examples/Dead Reckoning/Example1_calibrateSensor/Example1_calibrateSensor.ino +++ b/examples/Dead Reckoning/Example1_calibrateSensor/Example1_calibrateSensor.ino @@ -1,12 +1,10 @@ /* - Some Description By: Elias Santistevan SparkFun Electronics - Date: February + Date: May, 2020 License: MIT. See license file for more information but you can basically do whatever you want with this code. - Feel like supporting open source hardware? Buy a board from SparkFun! NEO-M8U: https://www.sparkfun.com/products/16329 @@ -14,7 +12,8 @@ Hardware Connections: Plug a Qwiic cable into the GPS and a Redboard Qwiic - If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) + If you don't have a platform with a Qwiic connection use the + SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) Open the serial monitor at 115200 baud to see the output To take advantage of the internal IMU of either the Dead Reckoning GPS @@ -56,6 +55,7 @@ void loop() { if (myGPS.getEsfInfo()){ + Serial.print("Fusion Mode: "); Serial.println(myGPS.imuMeas.fusionMode); if (myGPS.imuMeas.fusionMode == 1) Serial.println("Sensor is calibrated!"); diff --git a/examples/Dead Reckoning/Example2_getIMUData/Example2_getIMUData.ino b/examples/Dead Reckoning/Example2_getIMUData/Example2_getIMUData.ino new file mode 100644 index 0000000..399b8dd --- /dev/null +++ b/examples/Dead Reckoning/Example2_getIMUData/Example2_getIMUData.ino @@ -0,0 +1,84 @@ +/* + By: Elias Santistevan + SparkFun Electronics + Date: May, 2020 + License: MIT. See license file for more information but you can + basically do whatever you want with this code. + + Feel like supporting open source hardware? + Buy a board from SparkFun! + NEO-M8U: https://www.sparkfun.com/products/16329 + ZED-F9R: https://www.sparkfun.com/products/16344 + + Hardware Connections: + Plug a Qwiic cable into the GPS and a Redboard Qwiic + If you don't have a platform with a Qwiic connection use the + SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) + Open the serial monitor at 115200 baud to see the output + + After calibrating the module, also known as "Fusion Mode", you can get + data directly from the IMU. This data is integrated directly into the GNSS + output, but is provided by the module as well. + +*/ + +#include //Needed for I2C to GPS + +#include //http://librarymanager/All#SparkFun_Ublox_GPS +SFE_UBLOX_GPS myGPS; + +void setup() +{ + Serial.begin(115200); + while (!Serial); //Wait for user to open terminal + Serial.println("SparkFun Ublox Example"); + + Wire.begin(); + + if (myGPS.begin() == false) //Connect to the Ublox module using Wire port + { + Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing.")); + while (1); + } + + myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) + + if (myGPS.getEsfInfo()){ + + Serial.print("Fusion Mode: "); + Serial.println(myGPS.imuMeas.fusionMode); + + if (myGPS.imuMeas.fusionMode == 1){ + Serial.println("Fusion Mode is Initialized!"); + } + else { + Serial.println("Fusion Mode is either disabled or not initialized - Freezing!"); + Serial.println("Please see Example 1 description at top for more information."); + } + } +} + +void loop() +{ + + if (myGPS.getEsfIns()) + { + Serial.print("X: "); + Serial.println(myGPS.imuMeas.xAngRate); + Serial.print("Y: "); + Serial.println(myGPS.imuMeas.yAngRate); + Serial.print("Z: "); + Serial.println(myGPS.imuMeas.zAngRate); + Serial.print("X Acceleration: "); + Serial.println(myGPS.imuMeas.xAccel); + Serial.print("Y Acceleration: "); + Serial.println(myGPS.imuMeas.yAccel); + Serial.print("Z Acceleration: "); + Serial.println(myGPS.imuMeas.zAccel); + // These values also have "validity checks" that can be provided by the + // ublox library, add "Vald" to values: e.g. xAngRateVald or xAccelVald. + } + + delay(250); +} + diff --git a/examples/Dead Reckoning/Example2_getImuData/Example1_getIMUData.ino b/examples/Dead Reckoning/Example2_getImuData/Example1_getIMUData.ino deleted file mode 100644 index d2a85cc..0000000 --- a/examples/Dead Reckoning/Example2_getImuData/Example1_getIMUData.ino +++ /dev/null @@ -1,65 +0,0 @@ -/* - Some Description - By: Elias Santistevan - SparkFun Electronics - Date: February - License: MIT. See license file for more information but you can - basically do whatever you want with this code. - - - Feel like supporting open source hardware? - Buy a board from SparkFun! - NEO-M8U: https://www.sparkfun.com/products/15136 - ZED-F9R: https://www.sparkfun.com/products/15136 - - Hardware Connections: - Plug a Qwiic cable into the GPS and a BlackBoard - If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) - Open the serial monitor at 115200 baud to see the output -*/ - -#include //Needed for I2C to GPS - -#include //http://librarymanager/All#SparkFun_Ublox_GPS -SFE_UBLOX_GPS myGPS; - -void setup() -{ - Serial.begin(115200); - while (!Serial); //Wait for user to open terminal - Serial.println("SparkFun Ublox Example"); - - Wire.begin(); - - if (myGPS.begin() == false) //Connect to the Ublox module using Wire port - { - Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing.")); - while (1); - } - - myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) -} - -void loop() -{ - if (myGPS.getEsfInfo()) - Serial.println(myGPS.imuMeas.fusionMode); - - if (myGPS.getEsfMeas()) - { - Serial.print("X validity: "); - Serial.println(myGPS.imuMeas.xAngRateVald); - Serial.print("X: "); - Serial.println(myGPS.imuMeas.xAngRate); - Serial.print("Y validity: "); - Serial.println(myGPS.imuMeas.yAngRateVald); - Serial.print("Y: "); - Serial.println(myGPS.imuMeas.yAngRate); - Serial.print("Z validity: "); - Serial.println(myGPS.imuMeas.zAngRateVald); - Serial.print("Z: "); - Serial.println(myGPS.imuMeas.zAngRate); - } - delay(250); -} - diff --git a/examples/Dead Reckoning/Example3_getSensorStatus/Example1_getSensorStatus.ino b/examples/Dead Reckoning/Example3_getSensorStatus/Example1_getSensorStatus.ino deleted file mode 100644 index d2a85cc..0000000 --- a/examples/Dead Reckoning/Example3_getSensorStatus/Example1_getSensorStatus.ino +++ /dev/null @@ -1,65 +0,0 @@ -/* - Some Description - By: Elias Santistevan - SparkFun Electronics - Date: February - License: MIT. See license file for more information but you can - basically do whatever you want with this code. - - - Feel like supporting open source hardware? - Buy a board from SparkFun! - NEO-M8U: https://www.sparkfun.com/products/15136 - ZED-F9R: https://www.sparkfun.com/products/15136 - - Hardware Connections: - Plug a Qwiic cable into the GPS and a BlackBoard - If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) - Open the serial monitor at 115200 baud to see the output -*/ - -#include //Needed for I2C to GPS - -#include //http://librarymanager/All#SparkFun_Ublox_GPS -SFE_UBLOX_GPS myGPS; - -void setup() -{ - Serial.begin(115200); - while (!Serial); //Wait for user to open terminal - Serial.println("SparkFun Ublox Example"); - - Wire.begin(); - - if (myGPS.begin() == false) //Connect to the Ublox module using Wire port - { - Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing.")); - while (1); - } - - myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) -} - -void loop() -{ - if (myGPS.getEsfInfo()) - Serial.println(myGPS.imuMeas.fusionMode); - - if (myGPS.getEsfMeas()) - { - Serial.print("X validity: "); - Serial.println(myGPS.imuMeas.xAngRateVald); - Serial.print("X: "); - Serial.println(myGPS.imuMeas.xAngRate); - Serial.print("Y validity: "); - Serial.println(myGPS.imuMeas.yAngRateVald); - Serial.print("Y: "); - Serial.println(myGPS.imuMeas.yAngRate); - Serial.print("Z validity: "); - Serial.println(myGPS.imuMeas.zAngRateVald); - Serial.print("Z: "); - Serial.println(myGPS.imuMeas.zAngRate); - } - delay(250); -} - diff --git a/examples/Dead Reckoning/Example3_getSensorStatus/Example3_getSensorStatus.ino b/examples/Dead Reckoning/Example3_getSensorStatus/Example3_getSensorStatus.ino new file mode 100644 index 0000000..8c7cbdf --- /dev/null +++ b/examples/Dead Reckoning/Example3_getSensorStatus/Example3_getSensorStatus.ino @@ -0,0 +1,97 @@ +/* + By: Elias Santistevan + SparkFun Electronics + Date: May, 2020 + License: MIT. See license file for more information but you can + basically do whatever you want with this code. + + Feel like supporting open source hardware? + Buy a board from SparkFun! + NEO-M8U: https://www.sparkfun.com/products/16329 + ZED-F9R: https://www.sparkfun.com/products/16344 + + Hardware Connections: + Plug a Qwiic cable into the GPS and a Redboard Qwiic + If you don't have a platform with a Qwiic connection use the + SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) + Open the serial monitor at 115200 baud to see the output + + After calibrating the module, also known as "Fusion Mode", you can get + data directly from the IMU. This example code walks you through trouble + shooting or identifying the different states of any individual + "external" (which include internal) sensors you've hooked up (vehicle speed + sensor) or the internal IMU used by the modules. You can see if the sensor is + being used, if it's calibrated, ready, what data type it returns, the state + of the measurement etc. + +*/ + +#include //Needed for I2C to GPS + +#include //http://librarymanager/All#SparkFun_Ublox_GPS +SFE_UBLOX_GPS myGPS; + +void setup() +{ + Serial.begin(115200); + while (!Serial); //Wait for user to open terminal + Serial.println("SparkFun Ublox Example"); + + Wire.begin(); + + if (myGPS.begin() == false) //Connect to the Ublox module using Wire port + { + Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing.")); + while (1); + } + + myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) + + // GetEsfInfo also gets the number of sensors used by the ublox module, this + // includes (in the case of the ZED-F9R) wheel tick input from the vehicle + // speed sensor attached to the module. + if (myGPS.getEsfInfo()){ + + Serial.print("Fusion Mode: "); + Serial.println(myGPS.imuMeas.fusionMode); + + if (myGPS.imuMeas.fusionMode == 1){ + Serial.println("Fusion Mode is Initialized!"); + } + else { + Serial.println("Fusion Mode is either disabled or not initialized - Freezing!"); + Serial.println("Please see Example 1 description at top for more information."); + } + } +} + +void loop() +{ + + for(int i=1; i<=myGPS.ubloxSen.numSens; i++){ + myGPS.getSensState(i); // Give the sensor you want to check on. + Serial.print("Sensor Data Type: "); //See ublox receiver description + //or our hookup guide for information on the + //return value. + Serial.println(myGPS.ubloxSen.senType); + Serial.print("Being Used: "); + Serial.println(myGPS.ubloxSen.isUsed); + Serial.print("Is Ready: "); + Serial.println(myGPS.ubloxSen.isReady); + Serial.print("Calibration Status: "); + Serial.println(myGPS.ubloxSen.calibStatus); + Serial.print("Time Status: "); + Serial.println(myGPS.ubloxSen.timeStatus); + Serial.print("Bad Measure: "); + Serial.println(myGPS.ubloxSen.timeStatus); + Serial.print("Bad Time Tag: "); + Serial.println(myGPS.ubloxSen.badTag); + Serial.print("Missed Measure : "); + Serial.println(myGPS.ubloxSen.missMeas); + Serial.print("Noisy Measure: "); + Serial.println(myGPS.ubloxSen.noisyMeas); + } + +} + + diff --git a/src/SparkFun_Ublox_Arduino_Library.cpp b/src/SparkFun_Ublox_Arduino_Library.cpp index 1439015..49f1eec 100644 --- a/src/SparkFun_Ublox_Arduino_Library.cpp +++ b/src/SparkFun_Ublox_Arduino_Library.cpp @@ -2725,6 +2725,7 @@ boolean SFE_UBLOX_GPS::getEsfInfo(uint16_t maxWait) // payload should be loaded. imuMeas.version = extractByte(4); imuMeas.fusionMode = extractByte(12); + ubloxSen.numSens = extractByte(15); // Individual Status Sensor in different function return(true); @@ -2867,7 +2868,7 @@ sfe_ublox_status_e SFE_UBLOX_GPS::getSensState(uint8_t sensor, uint16_t maxWait) } -bool SFE_UBLOX_GPS::getVehAtt(uint16_t maxWait){ +boolean SFE_UBLOX_GPS::getVehAtt(uint16_t maxWait){ packetCfg.cls = UBX_CLASS_NAV; packetCfg.id = UBX_NAV_ATT; @@ -2883,5 +2884,7 @@ bool SFE_UBLOX_GPS::getVehAtt(uint16_t maxWait){ vehAtt.accRoll = extractLong(20); vehAtt.accPitch = extractLong(24); vehAtt.accHeading = extractLong(28); + + return true; } From 9f111296a326756ab869e347a800878987371771 Mon Sep 17 00:00:00 2001 From: Elias Santistevan Date: Mon, 20 Apr 2020 11:04:31 -0600 Subject: [PATCH 10/13] Adds vehicle dynamics exampel --- .../Example1_calibrateSensor.ino | 3 +- .../Example4_vehicleDynamics.ino | 80 +++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 examples/Dead Reckoning/Example4_vehicleDynamics/Example4_vehicleDynamics.ino diff --git a/examples/Dead Reckoning/Example1_calibrateSensor/Example1_calibrateSensor.ino b/examples/Dead Reckoning/Example1_calibrateSensor/Example1_calibrateSensor.ino index 8809e1e..e5cfb4b 100644 --- a/examples/Dead Reckoning/Example1_calibrateSensor/Example1_calibrateSensor.ino +++ b/examples/Dead Reckoning/Example1_calibrateSensor/Example1_calibrateSensor.ino @@ -24,7 +24,8 @@ Reckoning. You may also check either the ZED-F9R or NEO-M8U Hookup Guide for more information. After the board is secure, you'll need to put the module through certain conditions for proper calibration: acceleration, turning, - stopping, all under a clear sky with good GNSS signal. This example simply looks at the + stopping for a few minutes, getting to a speed over 30km/h all under a clear sky + with good GNSS signal. This example simply looks at the "fusionMode" status which indicates whether the SparkFun Dead Reckoning is not-calibrated - 0, or calibrated - 1. */ diff --git a/examples/Dead Reckoning/Example4_vehicleDynamics/Example4_vehicleDynamics.ino b/examples/Dead Reckoning/Example4_vehicleDynamics/Example4_vehicleDynamics.ino new file mode 100644 index 0000000..1403ce0 --- /dev/null +++ b/examples/Dead Reckoning/Example4_vehicleDynamics/Example4_vehicleDynamics.ino @@ -0,0 +1,80 @@ +/* + By: Elias Santistevan + SparkFun Electronics + Date: May, 2020 + License: MIT. See license file for more information but you can + basically do whatever you want with this code. + + Feel like supporting open source hardware? + Buy a board from SparkFun! + NEO-M8U: https://www.sparkfun.com/products/16329 + ZED-F9R: https://www.sparkfun.com/products/16344 + + Hardware Connections: + Plug a Qwiic cable into the GPS and a Redboard Qwiic + If you don't have a platform with a Qwiic connection use the + SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) + Open the serial monitor at 115200 baud to see the output + + After calibrating the module and securing it to your vehicle such that it's + stable within 2 degrees, and the board is oriented correctly with regards to + the vehicle's frame, you can now read the vehicle's "attitude". The attitude + includes the vehicle's heading, pitch, and roll. You can also check the + accuracy of those readings. + +*/ + +#include //Needed for I2C to GPS + +#include //http://librarymanager/All#SparkFun_Ublox_GPS +SFE_UBLOX_GPS myGPS; + +void setup() +{ + Serial.begin(115200); + while (!Serial); //Wait for user to open terminal + Serial.println("SparkFun Ublox Example"); + + Wire.begin(); + + if (myGPS.begin() == false) //Connect to the Ublox module using Wire port + { + Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing.")); + while (1); + } + + myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) + + if (myGPS.getEsfInfo()){ + + Serial.print("Fusion Mode: "); + Serial.println(myGPS.imuMeas.fusionMode); + + if (myGPS.imuMeas.fusionMode == 1){ + Serial.println("Fusion Mode is Initialized!"); + } + else { + Serial.println("Fusion Mode is either disabled or not initialized - Freezing!"); + Serial.println("Please see Example 1 description at top for more information."); + } + } +} + +void loop() +{ + myGPS.getVehAtt(); // Give the sensor you want to check on. + Serial.print("Roll: "); + Serial.println(myGPS.vehAtt.roll); + Serial.print("Pitch: "); + Serial.println(myGPS.vehAtt.pitch); + Serial.print("Heading: "); + Serial.println(myGPS.vehAtt.heading); + Serial.print("Roll Accuracy: "); + Serial.println(myGPS.vehAtt.accRoll); + Serial.print("Pitch Accuracy: "); + Serial.println(myGPS.vehAtt.accPitch); + Serial.print("Heading Accuracy: "); + Serial.println(myGPS.vehAtt.accHeading); +} + + From 5b206758d98c5b1e878584e5fe947327508e0959 Mon Sep 17 00:00:00 2001 From: Elias Santistevan Date: Mon, 27 Apr 2020 08:27:40 -0600 Subject: [PATCH 11/13] Dereferences packetCfg (now that it's a pointer) instead of referencing global --- src/SparkFun_Ublox_Arduino_Library.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/SparkFun_Ublox_Arduino_Library.cpp b/src/SparkFun_Ublox_Arduino_Library.cpp index 49f1eec..f23894a 100644 --- a/src/SparkFun_Ublox_Arduino_Library.cpp +++ b/src/SparkFun_Ublox_Arduino_Library.cpp @@ -2717,7 +2717,7 @@ boolean SFE_UBLOX_GPS::getEsfInfo(uint16_t maxWait) packetCfg.len = 0; packetCfg.startingSpot = 0; - if (sendCommand(packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) + if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) return (false); //If command send fails then bail checkUblox(); @@ -2739,7 +2739,7 @@ boolean SFE_UBLOX_GPS::getEsfIns(uint16_t maxWait) packetCfg.len = 0; packetCfg.startingSpot = 0; - if (sendCommand(packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) + if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) return (false); //If command send fails then bail checkUblox(); @@ -2772,7 +2772,7 @@ boolean SFE_UBLOX_GPS::getEsfDataInfo(uint16_t maxWait) packetCfg.len = 0; packetCfg.startingSpot = 0; - if (sendCommand(packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) + if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) return (false); //If command send fails then bail checkUblox(); @@ -2811,7 +2811,7 @@ boolean SFE_UBLOX_GPS::getEsfRawDataInfo(uint16_t maxWait) packetCfg.len = 0; packetCfg.startingSpot = 0; - if (sendCommand(packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) + if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) return (false); //If command send fails then bail checkUblox(); @@ -2831,7 +2831,7 @@ sfe_ublox_status_e SFE_UBLOX_GPS::getSensState(uint8_t sensor, uint16_t maxWait) packetCfg.len = 0; packetCfg.startingSpot = 0; - if (sendCommand(packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) + if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) return (SFE_UBLOX_STATUS_FAIL); //If command send fails then bail ubloxSen.numSens = extractByte(15); @@ -2875,6 +2875,9 @@ boolean SFE_UBLOX_GPS::getVehAtt(uint16_t maxWait){ packetCfg.len = 0; packetCfg.startingSpot = 0; + if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) + return (SFE_UBLOX_STATUS_FAIL); //If command send fails then bail + checkUblox(); vehAtt.roll = extractLong(8); From a86fdc5b7a1144129d0be727f8010a56a21aac3e Mon Sep 17 00:00:00 2001 From: Elias Santistevan Date: Fri, 1 May 2020 10:31:41 -0600 Subject: [PATCH 12/13] Fixes print statments, adds returns to functions missing returns --- .../Example1_calibrateSensor.ino | 8 +++--- .../Example2_getIMUData.ino | 22 +++++++-------- .../Example3_getSensorStatus.ino | 28 +++++++++---------- .../Example4_vehicleDynamics.ino | 24 ++++++++-------- src/SparkFun_Ublox_Arduino_Library.cpp | 11 ++++++-- 5 files changed, 50 insertions(+), 43 deletions(-) diff --git a/examples/Dead Reckoning/Example1_calibrateSensor/Example1_calibrateSensor.ino b/examples/Dead Reckoning/Example1_calibrateSensor/Example1_calibrateSensor.ino index e5cfb4b..cb19a97 100644 --- a/examples/Dead Reckoning/Example1_calibrateSensor/Example1_calibrateSensor.ino +++ b/examples/Dead Reckoning/Example1_calibrateSensor/Example1_calibrateSensor.ino @@ -17,7 +17,7 @@ Open the serial monitor at 115200 baud to see the output To take advantage of the internal IMU of either the Dead Reckoning GPS - boards (ZED-F9R, NEO-M8U), you must first calibrate them. This includes securing the GPS module + boards (ZED-F9R, NEO-M8U), you must first calibrate it. This includes securing the GPS module to your vehicle so that it is stable within 2 degrees and that the frame of reference of the board is consistent with the picture outlined in the Receiver-Description-Prot-Spec Datasheet under Automotive/Untethered Dead @@ -39,7 +39,7 @@ void setup() { Serial.begin(115200); while (!Serial); //Wait for user to open terminal - Serial.println("SparkFun Ublox Example"); + Serial.println(F("SparkFun Ublox Example")); Wire.begin(); @@ -56,10 +56,10 @@ void loop() { if (myGPS.getEsfInfo()){ - Serial.print("Fusion Mode: "); + Serial.print(F("Fusion Mode: ")); Serial.println(myGPS.imuMeas.fusionMode); if (myGPS.imuMeas.fusionMode == 1) - Serial.println("Sensor is calibrated!"); + Serial.println(F("Sensor is calibrated!")); } delay(250); diff --git a/examples/Dead Reckoning/Example2_getIMUData/Example2_getIMUData.ino b/examples/Dead Reckoning/Example2_getIMUData/Example2_getIMUData.ino index 399b8dd..f7c62a0 100644 --- a/examples/Dead Reckoning/Example2_getIMUData/Example2_getIMUData.ino +++ b/examples/Dead Reckoning/Example2_getIMUData/Example2_getIMUData.ino @@ -31,7 +31,7 @@ void setup() { Serial.begin(115200); while (!Serial); //Wait for user to open terminal - Serial.println("SparkFun Ublox Example"); + Serial.println(F("SparkFun Ublox Example")); Wire.begin(); @@ -45,15 +45,15 @@ void setup() if (myGPS.getEsfInfo()){ - Serial.print("Fusion Mode: "); + Serial.print(F("Fusion Mode: ")); Serial.println(myGPS.imuMeas.fusionMode); if (myGPS.imuMeas.fusionMode == 1){ - Serial.println("Fusion Mode is Initialized!"); + Serial.println(F("Fusion Mode is Initialized!")); } else { - Serial.println("Fusion Mode is either disabled or not initialized - Freezing!"); - Serial.println("Please see Example 1 description at top for more information."); + Serial.println(F("Fusion Mode is either disabled or not initialized - Freezing!")); + Serial.println(F("Please see Example 1 description at top for more information.")); } } } @@ -63,17 +63,17 @@ void loop() if (myGPS.getEsfIns()) { - Serial.print("X: "); + Serial.print(F("X: ")); Serial.println(myGPS.imuMeas.xAngRate); - Serial.print("Y: "); + Serial.print(F("Y: ")); Serial.println(myGPS.imuMeas.yAngRate); - Serial.print("Z: "); + Serial.print(F("Z: ")); Serial.println(myGPS.imuMeas.zAngRate); - Serial.print("X Acceleration: "); + Serial.print(F("X Acceleration: ")); Serial.println(myGPS.imuMeas.xAccel); - Serial.print("Y Acceleration: "); + Serial.print(F("Y Acceleration: ")); Serial.println(myGPS.imuMeas.yAccel); - Serial.print("Z Acceleration: "); + Serial.print(F("Z Acceleration: ")); Serial.println(myGPS.imuMeas.zAccel); // These values also have "validity checks" that can be provided by the // ublox library, add "Vald" to values: e.g. xAngRateVald or xAccelVald. diff --git a/examples/Dead Reckoning/Example3_getSensorStatus/Example3_getSensorStatus.ino b/examples/Dead Reckoning/Example3_getSensorStatus/Example3_getSensorStatus.ino index 8c7cbdf..ba89587 100644 --- a/examples/Dead Reckoning/Example3_getSensorStatus/Example3_getSensorStatus.ino +++ b/examples/Dead Reckoning/Example3_getSensorStatus/Example3_getSensorStatus.ino @@ -35,7 +35,7 @@ void setup() { Serial.begin(115200); while (!Serial); //Wait for user to open terminal - Serial.println("SparkFun Ublox Example"); + Serial.println(F("SparkFun Ublox Example")); Wire.begin(); @@ -52,15 +52,15 @@ void setup() // speed sensor attached to the module. if (myGPS.getEsfInfo()){ - Serial.print("Fusion Mode: "); + Serial.print(F("Fusion Mode: ")); Serial.println(myGPS.imuMeas.fusionMode); if (myGPS.imuMeas.fusionMode == 1){ - Serial.println("Fusion Mode is Initialized!"); + Serial.println(F("Fusion Mode is Initialized!")); } else { - Serial.println("Fusion Mode is either disabled or not initialized - Freezing!"); - Serial.println("Please see Example 1 description at top for more information."); + Serial.println(F("Fusion Mode is either disabled or not initialized - Freezing!")); + Serial.println(F("Please see Example 1 description at top for more information.")); } } } @@ -70,25 +70,25 @@ void loop() for(int i=1; i<=myGPS.ubloxSen.numSens; i++){ myGPS.getSensState(i); // Give the sensor you want to check on. - Serial.print("Sensor Data Type: "); //See ublox receiver description + Serial.print(F("Sensor Data Type: ")); //See ublox receiver description //or our hookup guide for information on the //return value. Serial.println(myGPS.ubloxSen.senType); - Serial.print("Being Used: "); + Serial.print(F("Being Used: ")); Serial.println(myGPS.ubloxSen.isUsed); - Serial.print("Is Ready: "); + Serial.print(F("Is Ready: ")); Serial.println(myGPS.ubloxSen.isReady); - Serial.print("Calibration Status: "); + Serial.print(F("Calibration Status: ")); Serial.println(myGPS.ubloxSen.calibStatus); - Serial.print("Time Status: "); + Serial.print(F("Time Status: ")); Serial.println(myGPS.ubloxSen.timeStatus); - Serial.print("Bad Measure: "); + Serial.print(F("Bad Measure: ")); Serial.println(myGPS.ubloxSen.timeStatus); - Serial.print("Bad Time Tag: "); + Serial.print(F("Bad Time Tag: ")); Serial.println(myGPS.ubloxSen.badTag); - Serial.print("Missed Measure : "); + Serial.print(F("Missed Measure : ")); Serial.println(myGPS.ubloxSen.missMeas); - Serial.print("Noisy Measure: "); + Serial.print(F("Noisy Measure: ")); Serial.println(myGPS.ubloxSen.noisyMeas); } diff --git a/examples/Dead Reckoning/Example4_vehicleDynamics/Example4_vehicleDynamics.ino b/examples/Dead Reckoning/Example4_vehicleDynamics/Example4_vehicleDynamics.ino index 1403ce0..562632c 100644 --- a/examples/Dead Reckoning/Example4_vehicleDynamics/Example4_vehicleDynamics.ino +++ b/examples/Dead Reckoning/Example4_vehicleDynamics/Example4_vehicleDynamics.ino @@ -33,7 +33,7 @@ void setup() { Serial.begin(115200); while (!Serial); //Wait for user to open terminal - Serial.println("SparkFun Ublox Example"); + Serial.println(F("SparkFun Ublox Example")); Wire.begin(); @@ -47,15 +47,15 @@ void setup() if (myGPS.getEsfInfo()){ - Serial.print("Fusion Mode: "); + Serial.print(F("Fusion Mode: ")); Serial.println(myGPS.imuMeas.fusionMode); if (myGPS.imuMeas.fusionMode == 1){ - Serial.println("Fusion Mode is Initialized!"); + Serial.println(F("Fusion Mode is Initialized!")); } else { - Serial.println("Fusion Mode is either disabled or not initialized - Freezing!"); - Serial.println("Please see Example 1 description at top for more information."); + Serial.println(F("Fusion Mode is either disabled or not initialized - Freezing!")); + Serial.println(F("Please see Example 1 description at top for more information.")); } } } @@ -63,18 +63,20 @@ void setup() void loop() { myGPS.getVehAtt(); // Give the sensor you want to check on. - Serial.print("Roll: "); + Serial.print(F("Roll: ")); Serial.println(myGPS.vehAtt.roll); - Serial.print("Pitch: "); + Serial.print(F("Pitch: ")); Serial.println(myGPS.vehAtt.pitch); - Serial.print("Heading: "); + Serial.print(F("Heading: ")); Serial.println(myGPS.vehAtt.heading); - Serial.print("Roll Accuracy: "); + Serial.print(F("Roll Accuracy: ")); Serial.println(myGPS.vehAtt.accRoll); - Serial.print("Pitch Accuracy: "); + Serial.print(F("Pitch Accuracy: ")); Serial.println(myGPS.vehAtt.accPitch); - Serial.print("Heading Accuracy: "); + Serial.print(F("Heading Accuracy: ")); Serial.println(myGPS.vehAtt.accHeading); + + delay(250); } diff --git a/src/SparkFun_Ublox_Arduino_Library.cpp b/src/SparkFun_Ublox_Arduino_Library.cpp index fe6997a..56b64ae 100644 --- a/src/SparkFun_Ublox_Arduino_Library.cpp +++ b/src/SparkFun_Ublox_Arduino_Library.cpp @@ -3219,6 +3219,8 @@ boolean SFE_UBLOX_GPS::getEsfIns(uint16_t maxWait) imuMeas.xAccel = extractLong(24); // m/s imuMeas.yAccel = extractLong(28); // m/s imuMeas.zAccel = extractLong(32); // m/s + + return(true); } // @@ -3257,6 +3259,8 @@ boolean SFE_UBLOX_GPS::getEsfDataInfo(uint16_t maxWait) } + return(true); + } boolean SFE_UBLOX_GPS::getEsfRawDataInfo(uint16_t maxWait) @@ -3279,6 +3283,7 @@ boolean SFE_UBLOX_GPS::getEsfRawDataInfo(uint16_t maxWait) imuMeas.rawData = (bitField && 0xFFFFFF); imuMeas.rawTStamp = extractLong(8); + return(true); } sfe_ublox_status_e SFE_UBLOX_GPS::getSensState(uint8_t sensor, uint16_t maxWait) @@ -3295,7 +3300,7 @@ sfe_ublox_status_e SFE_UBLOX_GPS::getSensState(uint8_t sensor, uint16_t maxWait) ubloxSen.numSens = extractByte(15); if (sensor > ubloxSen.numSens) - return SFE_UBLOX_STATUS_OUT_OF_RANGE; + return (SFE_UBLOX_STATUS_OUT_OF_RANGE); checkUblox(); @@ -3322,7 +3327,7 @@ sfe_ublox_status_e SFE_UBLOX_GPS::getSensState(uint8_t sensor, uint16_t maxWait) ubloxSen.noisyMeas = (sensorFieldThr && 0x08) >> 3; } - return SFE_UBLOX_STATUS_SUCCESS; + return (SFE_UBLOX_STATUS_SUCCESS); } @@ -3346,6 +3351,6 @@ boolean SFE_UBLOX_GPS::getVehAtt(uint16_t maxWait){ vehAtt.accPitch = extractLong(24); vehAtt.accHeading = extractLong(28); - return true; + return (true); } From 685b0939b81c3783f1e6b6be43872bbd8e5114d6 Mon Sep 17 00:00:00 2001 From: Elias Santistevan Date: Fri, 1 May 2020 10:37:18 -0600 Subject: [PATCH 13/13] Adds new function and literals to keywords --- keywords.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/keywords.txt b/keywords.txt index 7562d61..c2745cc 100644 --- a/keywords.txt +++ b/keywords.txt @@ -144,6 +144,13 @@ disableMessage KEYWORD2 enableNMEAMessage KEYWORD2 disableNMEAMessage KEYWORD2 +getEsfInfo KEYWORD2 +getEsfIns KEYWORD2 +getEsfDataInfo KEYWORD2 +getEsfRawDataInfo KEYWORD2 + +getSensState KEYWORD2 +getVehAtt KEYWORD2 ####################################### # Constants (LITERAL1) ####################################### @@ -211,3 +218,8 @@ DYN_MODEL_AIRBORNE2g LITERAL1 DYN_MODEL_AIRBORNE4g LITERAL1 DYN_MODEL_WRIST LITERAL1 DYN_MODEL_BIKE LITERAL1 + +UBX_ESF_STATUS LITERAL1 +UBX_ESF_RAW LITERAL1 +UBX_ESF_MEAS LITERAL1 +UBX_ESF_INS LITERAL1