I'm trying to implement the "BNO055 9 Axes Motion Shield". There is an existing Arduino sketch GitHub that reads out the Euler data, I changed it a bit to print out quaternion data.
#include "NAxisMotion.h" //Contains the bridge code between the API and the Arduino Environment
#include <Wire.h>
NAxisMotion mySensor; //Object that for the sensor
unsigned long lastStreamTime = 0; //To store the last streamed time stamp
const int streamPeriod = 20; //To stream at 50Hz without using additional timers (time period(ms) =1000/frequency(Hz))
void setup() //This code is executed once
{
//Peripheral Initialization
Serial.begin(115200); //Initialize the Serial Port to view information on the Serial Monitor
I2C.begin(); //Initialize I2C communication to the let the library communicate with the sensor.
//Sensor Initialization
mySensor.initSensor(); //The I2C Address can be changed here inside this function in the library
mySensor.setOperationMode(OPERATION_MODE_NDOF); //Can be configured to other operation modes as desired
mySensor.setUpdateMode(MANUAL); //The default is AUTO. Changing to MANUAL requires calling the relevant update functions prior to calling the read functions
//Setting to MANUAL requires fewer reads to the sensor
}
void loop() //This code is looped forever
{
if ((millis() - lastStreamTime) >= streamPeriod)
{
lastStreamTime = millis();
mySensor.updateQuat(); //Update the Quat data into the structure of the object
mySensor.updateCalibStatus(); //Update the Calibration Status
Serial.print("Time: ");
Serial.print(lastStreamTime);
Serial.print("ms ");
Serial.print(" W: ");
Serial.print(mySensor.readQuatW());
Serial.print(" X: ");
Serial.print(mySensor.readQuatX());
Serial.print(" Y: ");
Serial.print(mySensor.readQuatY());
Serial.print(" Z: ");
Serial.print(mySensor.readQuatZ());
Serial.println();
}
}
Here is a snippet of the "NAxisMotion.h" header file:
/*******************************************************************************************
*Description: This function is used to return the w-axis of the quaternion data
*Input Parameters: None
*Return Parameter:
* int16_t: W-axis quaternion data multiplied by 1000 (for 3 decimal places accuracy)
*******************************************************************************************/
int16_t readQuatW(void);
/*******************************************************************************************
*Description: This function is used to return the x-axis of the quaternion data
*Input Parameters: None
*Return Parameter:
* int16_t: X-axis quaternion data multiplied by 1000 (for 3 decimal places accuracy)
*******************************************************************************************/
int16_t readQuatX(void);
/*******************************************************************************************
*Description: This function is used to return the y-axis of the quaternion data
*Input Parameters: None
*Return Parameter:
* int16_t: Y-axis quaternion data multiplied by 1000 (for 3 decimal places accuracy)
*******************************************************************************************/
int16_t readQuatY(void);
/*******************************************************************************************
*Description: This function is used to return the z-axis of the quaternion data
*Input Parameters: None
*Return Parameter:
* int16_t: Z-axis quaternion data multiplied by 1000 (for 3 decimal places accuracy)
*******************************************************************************************/
int16_t readQuatZ(void);
I understand that the output data type is signed integer, but what syntax do I need to use to store them in an array? Because it seems the only way to access them is through "mySensor.readQuatX()"
#include <xxx>
before#include "xxx"
. This also means if you get a duplicate definitionint foo = 7
the error will be reported against the code you are more likely to have written rather than suggesting some system library is wrong. Others will argue I'm wrong, but it would be boring if we all thought the same.