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

Commit f9b46dc

Browse files
committed
Adding support for RELPOS. See issue 11.
1 parent 3a8ed65 commit f9b46dc

File tree

3 files changed

+168
-2
lines changed

3 files changed

+168
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/*
2+
Send UBX binary commands to enable RTCM sentences on Ublox ZED-F9P module
3+
By: Nathan Seidle
4+
SparkFun Electronics
5+
Date: January 9th, 2019
6+
License: MIT. See license file for more information but you can
7+
basically do whatever you want with this code.
8+
9+
This example shows how to query the module for RELPOS information in the NED frame.
10+
It assumes you already have RTCM correction data being fed to the receiver.
11+
12+
Feel like supporting open source hardware?
13+
Buy a board from SparkFun!
14+
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
15+
NEO-M8P RTK: https://www.sparkfun.com/products/15005
16+
SAM-M8Q: https://www.sparkfun.com/products/15106
17+
18+
Hardware Connections:
19+
Plug a Qwiic cable into the GPS and a RedBoard Qwiic or BlackBoard
20+
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
21+
Open the serial monitor at 115200 baud to see the output
22+
*/
23+
24+
#include <Wire.h> //Needed for I2C to GPS
25+
26+
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_Ublox_GPS
27+
SFE_UBLOX_GPS myGPS;
28+
29+
void setup()
30+
{
31+
Serial.begin(115200);
32+
while (!Serial); //Wait for user to open terminal
33+
Serial.println("Ublox Base station example");
34+
35+
Wire.begin();
36+
Wire.setClock(400000); //Increase I2C clock speed to 400kHz
37+
38+
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
39+
{
40+
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
41+
while (1);
42+
}
43+
}
44+
45+
void loop()
46+
{
47+
if (myGPS.getRELPOSNED() == true)
48+
{
49+
Serial.print("relPosN: ");
50+
Serial.println(myGPS.relPosInfo.relPosN, 4);
51+
Serial.print("relPosE: ");
52+
Serial.println(myGPS.relPosInfo.relPosE, 4);
53+
Serial.print("relPosD: ");
54+
Serial.println(myGPS.relPosInfo.relPosD, 4);
55+
56+
Serial.print("accN: ");
57+
Serial.println(myGPS.relPosInfo.accN, 4);
58+
Serial.print("accE: ");
59+
Serial.println(myGPS.relPosInfo.accE, 4);
60+
Serial.print("accD: ");
61+
Serial.println(myGPS.relPosInfo.accD, 4);
62+
63+
Serial.print("gnssFixOk: ");
64+
if (myGPS.relPosInfo.gnssFixOk == true)
65+
Serial.println("x");
66+
else
67+
Serial.println("");
68+
69+
Serial.print("diffSolution: ");
70+
if (myGPS.relPosInfo.diffSoln == true)
71+
Serial.println("x");
72+
else
73+
Serial.println("");
74+
75+
Serial.print("relPosValid: ");
76+
if (myGPS.relPosInfo.relPosValid == true)
77+
Serial.println("x");
78+
else
79+
Serial.println("");
80+
81+
Serial.print("carrier Solution Type: ");
82+
if (myGPS.relPosInfo.carrSoln == 0)
83+
Serial.println("None");
84+
else if (myGPS.relPosInfo.carrSoln == 1)
85+
Serial.println("Float");
86+
else if (myGPS.relPosInfo.carrSoln == 2)
87+
Serial.println("Fixed");
88+
89+
Serial.print("isMoving: ");
90+
if (myGPS.relPosInfo.isMoving == true)
91+
Serial.println("x");
92+
else
93+
Serial.println("");
94+
95+
Serial.print("refPosMiss: ");
96+
if (myGPS.relPosInfo.refPosMiss == true)
97+
Serial.println("x");
98+
else
99+
Serial.println("");
100+
101+
Serial.print("refObsMiss: ");
102+
if (myGPS.relPosInfo.refObsMiss == true)
103+
Serial.println("x");
104+
else
105+
Serial.println("");
106+
}
107+
else
108+
Serial.println("RELPOS request failed");
109+
110+
delay(4000);
111+
}

src/SparkFun_Ublox_Arduino_Library.cpp

+36-2
Original file line numberDiff line numberDiff line change
@@ -1354,8 +1354,42 @@ boolean SFE_UBLOX_GPS::getRELPOSNED(uint16_t maxWait)
13541354
return (false); //If command send fails then bail
13551355

13561356
//We got a response, now parse the bits
1357-
Serial.print("RELPOSNED: 0x");
1358-
Serial.println(payloadCfg[38], HEX);
1357+
1358+
uint16_t refStationID = extractInt(2);
1359+
Serial.print("refStationID: ");
1360+
Serial.println(refStationID);
1361+
1362+
int32_t tempRelPos;
1363+
1364+
tempRelPos = extractLong(8);
1365+
relPosInfo.relPosN = tempRelPos / 100.0; //Convert cm to m
1366+
1367+
tempRelPos = extractLong(12);
1368+
relPosInfo.relPosE = tempRelPos / 100.0; //Convert cm to m
1369+
1370+
tempRelPos = extractLong(16);
1371+
relPosInfo.relPosD = tempRelPos / 100.0; //Convert cm to m
1372+
1373+
uint32_t tempAcc;
1374+
1375+
tempAcc = extractLong(24);
1376+
relPosInfo.accN = tempAcc / 10000.0; //Convert 0.1 mm to m
1377+
1378+
tempAcc = extractLong(28);
1379+
relPosInfo.accE = tempAcc / 10000.0; //Convert 0.1 mm to m
1380+
1381+
tempAcc = extractLong(32);
1382+
relPosInfo.accD = tempAcc / 10000.0; //Convert 0.1 mm to m
1383+
1384+
uint8_t flags = payloadCfg[36];
1385+
1386+
relPosInfo.gnssFixOk = flags & (1 << 0);
1387+
relPosInfo.diffSoln = flags & (1 << 1);
1388+
relPosInfo.relPosValid = flags & (1 << 2);
1389+
relPosInfo.carrSoln = (flags & (0b11 << 3)) >> 3;
1390+
relPosInfo.isMoving = flags & (1 << 5);
1391+
relPosInfo.refPosMiss = flags & (1 << 6);
1392+
relPosInfo.refObsMiss = flags & (1 << 7);
13591393

13601394
return (true);
13611395
}

src/SparkFun_Ublox_Arduino_Library.h

+21
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,27 @@ class SFE_UBLOX_GPS
279279
float meanAccuracy;
280280
} svin;
281281

282+
//Relative Positioning Info in NED frame specific controls
283+
struct frelPosInfoStructure
284+
{
285+
uint16_t refStationID;
286+
287+
float relPosN;
288+
float relPosE;
289+
float relPosD;
290+
float accN;
291+
float accE;
292+
float accD;
293+
294+
bool gnssFixOk;
295+
bool diffSoln;
296+
bool relPosValid;
297+
uint8_t carrSoln;
298+
bool isMoving;
299+
bool refPosMiss;
300+
bool refObsMiss;
301+
} relPosInfo;
302+
282303
//The major datums we want to globally store
283304
int32_t latitude; //Degrees * 10^-7 (more accurate than floats)
284305
int32_t longitude; //Degrees * 10^-7 (more accurate than floats)

0 commit comments

Comments
 (0)