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

Commit 33e8fe2

Browse files
committed
Adds vehicle attitude function and struct to handle data, fixes example 1
1 parent 29449fc commit 33e8fe2

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

examples/Dead Reckoning/Example1_calibrateSensor/Example1_calibrateSensor.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ void loop()
5757

5858
if (myGPS.getEsfInfo()){
5959
Serial.println(myGPS.imuMeas.fusionMode);
60-
if (myGPS.imuMeas.fusionMode) == 1
60+
if (myGPS.imuMeas.fusionMode == 1)
6161
Serial.println("Sensor is calibrated!");
6262
}
6363

64-
delay(250)
64+
delay(250);
6565
}

src/SparkFun_Ublox_Arduino_Library.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2867,3 +2867,21 @@ sfe_ublox_status_e SFE_UBLOX_GPS::getSensState(uint8_t sensor, uint16_t maxWait)
28672867

28682868
}
28692869

2870+
bool SFE_UBLOX_GPS::getVehAtt(uint16_t maxWait){
2871+
2872+
packetCfg.cls = UBX_CLASS_NAV;
2873+
packetCfg.id = UBX_NAV_ATT;
2874+
packetCfg.len = 0;
2875+
packetCfg.startingSpot = 0;
2876+
2877+
checkUblox();
2878+
2879+
vehAtt.roll = extractLong(8);
2880+
vehAtt.pitch = extractLong(12);
2881+
vehAtt.heading = extractLong(16);
2882+
2883+
vehAtt.accRoll = extractLong(20);
2884+
vehAtt.accPitch = extractLong(24);
2885+
vehAtt.accHeading = extractLong(28);
2886+
2887+
}

src/SparkFun_Ublox_Arduino_Library.h

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ const uint8_t UBX_MON_TXBUF = 0x08; //Transmitter Buffer Status. Used for query
255255
const uint8_t UBX_MON_VER = 0x04; //Receiver/Software Version. Used for obtaining Protocol Version.
256256

257257
//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)
258+
const uint8_t UBX_NAV_ATT = 0x05; //Vehicle "Attitude" Solution
258259
const uint8_t UBX_NAV_CLOCK = 0x22; //Clock Solution
259260
const uint8_t UBX_NAV_DOP = 0x04; //Dilution of precision
260261
const uint8_t UBX_NAV_EOE = 0x61; //End of Epoch
@@ -595,6 +596,7 @@ class SFE_UBLOX_GPS
595596
boolean getEsfDataInfo(uint16_t maxWait = 1100);
596597
boolean getEsfRawDataInfo(uint16_t maxWait = 1100);
597598
sfe_ublox_status_e getSensState(uint8_t sensor, uint16_t maxWait = 1100);
599+
boolean getVehAtt(uint16_t maxWait = 1100);
598600

599601
//Survey-in specific controls
600602
struct svinStructure
@@ -706,19 +708,30 @@ class SFE_UBLOX_GPS
706708
uint8_t numSens;
707709

708710
uint8_t senType;
709-
bool isUsed;
710-
bool isReady;
711+
boolean isUsed;
712+
boolean isReady;
711713
uint8_t calibStatus;
712714
uint8_t timeStatus;
713715

714716
uint8_t freq; // Hz
715717

716-
bool badMeas;
717-
bool badTag;
718-
bool missMeas;
719-
bool noisyMeas;
718+
boolean badMeas;
719+
boolean badTag;
720+
boolean missMeas;
721+
boolean noisyMeas;
720722
} ubloxSen;
721723

724+
struct vehicleAttitude
725+
{
726+
// All values in degrees
727+
int32_t roll;
728+
int32_t pitch;
729+
int32_t heading;
730+
uint32_t accRoll;
731+
uint32_t accPitch;
732+
uint32_t accHeading;
733+
} vehAtt;
734+
722735
private:
723736
//Depending on the sentence type the processor will load characters into different arrays
724737
enum SentenceTypes

0 commit comments

Comments
 (0)