|
1 | 1 | /* |
2 | 2 | Using the BNO08x IMU |
3 | 3 |
|
4 | | - This example shows how to calibrate the sensor. See document 1000-4044. |
5 | | - You move the sensor into a sequence of positions, then send it an "S" to save. |
| 4 | + This example shows how to adjust settings of the dynamic calibration of the |
| 5 | + BNO08x. |
| 6 | + |
| 7 | + The BNO08x allows you to turn on/off dynamic calibration for each sensor in |
| 8 | + the IMU (accel, gyro, or mag). |
| 9 | +
|
| 10 | + Please refer to the BNO08X data sheet Section 3 (page 37) |
| 11 | + https://docs.sparkfun.com/SparkFun_VR_IMU_Breakout_BNO086_QWIIC/assets/component_documentation/BNO080_085-Datasheet_v1.16.pdf |
6 | 12 |
|
7 | | - While Calibration is in progress, it will output the x/y/z/accuracy of the mag |
8 | | - and the i/j/k/real parts of the game rotation vector. |
| 13 | + Note, by default, dynamic calibration is enabled for accel and mag. |
| 14 | + Some special use cases may require turning on all or any special combo of sensor |
| 15 | + dynamic calibration. |
| 16 | + |
| 17 | + After the calibration settings are set, this example will output the |
| 18 | + x/y/z/accuracy of the mag and the i/j/k/real parts of the game rotation vector. |
9 | 19 | https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation |
10 | 20 |
|
| 21 | + Note, the "simple calibration" feature, sh2_startCal(), is not available on |
| 22 | + the BNO08x. See this issue for more info: |
| 23 | + https://github.com/ceva-dsp/sh2/issues/11 |
| 24 | +
|
11 | 25 | By: Nathan Seidle |
12 | 26 | SparkFun Electronics |
13 | 27 | Date: December 21st, 2017 |
@@ -102,8 +116,11 @@ void setup() { |
102 | 116 |
|
103 | 117 | // Wire.setClock(400000); //Increase I2C data rate to 400kHz |
104 | 118 |
|
105 | | - //Enable dynamic calibration for accel, gyro, and mag |
106 | | - if (myIMU.calibrateAll() == true) { |
| 119 | + // Enable dynamic calibration for desired sensors (accel, gyro, and mag) |
| 120 | + // uncomment/comment out as needed to try various options |
| 121 | + if (myIMU.setCalibrationConfig(SH2_CAL_ACCEL || SH2_CAL_GYRO || SH2_CAL_MAG) == true) { // all three sensors |
| 122 | + //if (myIMU.setCalibrationConfig(SH2_CAL_ACCEL || SH2_CAL_MAG) == true) { // Default settings |
| 123 | + //if (myIMU.setCalibrationConfig(SH2_CAL_ACCEL) == true) { // only accel |
107 | 124 | Serial.println(F("Calibration Command Sent Successfully")); |
108 | 125 | } else { |
109 | 126 | Serial.println("Could not send Calibration Command. Freezing..."); |
@@ -204,51 +221,15 @@ void loop() { |
204 | 221 |
|
205 | 222 | if(incoming == 's') |
206 | 223 | { |
207 | | - //Saves the current dynamic calibration data (DCD) to memory |
| 224 | + // Saves the current dynamic calibration data (DCD) to memory |
| 225 | + // Note, The BNO08X stores updated Dynamic Calibration Data (DCD) to RAM |
| 226 | + // frequently (every 5 seconds), so this command may not be necessary |
| 227 | + // depending on your application. |
208 | 228 | if (myIMU.saveCalibration() == true) { |
209 | 229 | Serial.println(F("Calibration data was saved successfully")); |
210 | 230 | } else { |
211 | 231 | Serial.println("Save Calibration Failure"); |
212 | 232 | } |
213 | | - |
214 | | - //////////////////////////////////// |
215 | | - // CODE FROM PREVIOUS BNO080 LIBRARY vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv |
216 | | - // BEGIN /////////////////////////// |
217 | | - |
218 | | - // myIMU.requestCalibrationStatus(); //Sends command to get the latest calibration status |
219 | | - |
220 | | - // //Wait for calibration response, timeout if no response |
221 | | - // int counter = 100; |
222 | | - // while(1) |
223 | | - // { |
224 | | - // if(--counter == 0) break; |
225 | | - // if(myIMU.dataAvailable() == true) |
226 | | - // { |
227 | | - // //The IMU can report many different things. We must wait |
228 | | - // //for the ME Calibration Response Status byte to go to zero |
229 | | - // if(myIMU.calibrationComplete() == true) |
230 | | - // { |
231 | | - // Serial.println("Calibration data successfully stored"); |
232 | | - // delay(1000); |
233 | | - // break; |
234 | | - // } |
235 | | - // } |
236 | | - |
237 | | - // delay(1); |
238 | | - // } |
239 | | - // if(counter == 0) |
240 | | - // { |
241 | | - // Serial.println("Calibration data failed to store. Please try again."); |
242 | | - // } |
243 | | - |
244 | | - //myIMU.endCalibration(); //Turns off all calibration |
245 | | - //In general, calibration should be left on at all times. The BNO080 |
246 | | - //auto-calibrates and auto-records cal data roughly every 5 minutes |
247 | | - |
248 | | - //////////////////////////////////// |
249 | | - // CODE FROM PREVIOUS BNO080 LIBRARY ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
250 | | - // END ///////////////////////////// |
251 | | - |
252 | 233 | } |
253 | 234 | } |
254 | 235 | } |
|
0 commit comments