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

Commit 9f11129

Browse files
committed
Adds vehicle dynamics exampel
1 parent 156233d commit 9f11129

File tree

2 files changed

+82
-1
lines changed

2 files changed

+82
-1
lines changed

examples/Dead Reckoning/Example1_calibrateSensor/Example1_calibrateSensor.ino

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
Reckoning. You may also check either the ZED-F9R or NEO-M8U Hookup Guide for
2525
more information. After the board is secure, you'll need to put the module
2626
through certain conditions for proper calibration: acceleration, turning,
27-
stopping, all under a clear sky with good GNSS signal. This example simply looks at the
27+
stopping for a few minutes, getting to a speed over 30km/h all under a clear sky
28+
with good GNSS signal. This example simply looks at the
2829
"fusionMode" status which indicates whether the SparkFun Dead Reckoning is
2930
not-calibrated - 0, or calibrated - 1.
3031
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
By: Elias Santistevan
3+
SparkFun Electronics
4+
Date: May, 2020
5+
License: MIT. See license file for more information but you can
6+
basically do whatever you want with this code.
7+
8+
Feel like supporting open source hardware?
9+
Buy a board from SparkFun!
10+
NEO-M8U: https://www.sparkfun.com/products/16329
11+
ZED-F9R: https://www.sparkfun.com/products/16344
12+
13+
Hardware Connections:
14+
Plug a Qwiic cable into the GPS and a Redboard Qwiic
15+
If you don't have a platform with a Qwiic connection use the
16+
SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
17+
Open the serial monitor at 115200 baud to see the output
18+
19+
After calibrating the module and securing it to your vehicle such that it's
20+
stable within 2 degrees, and the board is oriented correctly with regards to
21+
the vehicle's frame, you can now read the vehicle's "attitude". The attitude
22+
includes the vehicle's heading, pitch, and roll. You can also check the
23+
accuracy of those readings.
24+
25+
*/
26+
27+
#include <Wire.h> //Needed for I2C to GPS
28+
29+
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_Ublox_GPS
30+
SFE_UBLOX_GPS myGPS;
31+
32+
void setup()
33+
{
34+
Serial.begin(115200);
35+
while (!Serial); //Wait for user to open terminal
36+
Serial.println("SparkFun Ublox Example");
37+
38+
Wire.begin();
39+
40+
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
41+
{
42+
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
43+
while (1);
44+
}
45+
46+
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
47+
48+
if (myGPS.getEsfInfo()){
49+
50+
Serial.print("Fusion Mode: ");
51+
Serial.println(myGPS.imuMeas.fusionMode);
52+
53+
if (myGPS.imuMeas.fusionMode == 1){
54+
Serial.println("Fusion Mode is Initialized!");
55+
}
56+
else {
57+
Serial.println("Fusion Mode is either disabled or not initialized - Freezing!");
58+
Serial.println("Please see Example 1 description at top for more information.");
59+
}
60+
}
61+
}
62+
63+
void loop()
64+
{
65+
myGPS.getVehAtt(); // Give the sensor you want to check on.
66+
Serial.print("Roll: ");
67+
Serial.println(myGPS.vehAtt.roll);
68+
Serial.print("Pitch: ");
69+
Serial.println(myGPS.vehAtt.pitch);
70+
Serial.print("Heading: ");
71+
Serial.println(myGPS.vehAtt.heading);
72+
Serial.print("Roll Accuracy: ");
73+
Serial.println(myGPS.vehAtt.accRoll);
74+
Serial.print("Pitch Accuracy: ");
75+
Serial.println(myGPS.vehAtt.accPitch);
76+
Serial.print("Heading Accuracy: ");
77+
Serial.println(myGPS.vehAtt.accHeading);
78+
}
79+
80+

0 commit comments

Comments
 (0)