You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have mounted a Nicla Sense ME on a simple platform, with USB on the underside of the board. I have setup a simple 15 sec logging program for the rotation (SENSOR_ID_RV). I have performed simple pitch, roll and heading directional movements in accordance with the X-Y-Z graphic on the top of the board, to try and orientate myself to the Nicla coordinate system. After logging the data at 100 Hz for 15 sec and porting the data to Excel using Putty, I normalized and converted the data to Euler angles in degrees using
When I've reviewed the data in Excel, I find the following conclusions:
the X and Y axis as printed on the board are backwards. Pitch (normally rot_x) is rot_y, Roll (normally rot_y) is rot_x.
Pitch* (corrected) is 0° when USB is pointed downward, and +90° when laying flat on the table with USB on the underside
Roll* (corrected) is 0° when the board is laying flat on the table and the USB is on the underside
when USB is pointed north, heading is 90° (instead of 0°); when USB is pointed south, heading is -90° (instead of 180°); clockwise rotation moves the direction positively (+°)
Can you see any problems with what I am concluding? I'll admit I'm new at this. My sketch is below
#include<Arduino_BHY2.h>// BHY2 sensor library
#include<Nicla_System.h>//Nicla system library
#include<LibPrintf.h>// Printf function library// ///////////////////////////////////////////////////////////////////////////
#defineFREQUENCY_HZ (100) // 10 Hz
#defineINTERVAL_MS (1000 / FREQUENCY_HZ)
#defineSAMPLE_NO (1500)
#defineACCEL_RANGE (4) // up to 4g
#defineGYRO_RANGE (2000) // up to 2000 dps// ///////////////////////////////////////////////////////////////////////////// Local variables// SensorXYZ accel(SENSOR_ID_ACC); //returns xyz data// SensorXYZ gyro(SENSOR_ID_GYRO); //returns xyz data// SensorXYZ mag(SENSOR_ID_MAG); //returns xyz data
SensorQuaternion rot(SENSOR_ID_RV); //returns xyz data
SensorQuaternion orient(SENSOR_ID_ORI); //returns xyz datastaticunsignedlong printTime;
staticunsignedint sampleCount = 0; // number of samples takenbool dataCol = false; // New variable to track data collection status// ///////////////////////////////////////////////////////////////////////////voidsetup()
{
// Initialize Serial Port for debug info
Serial.begin(115200);
while(!Serial); //waits until serial com established before proceeding// Initialize Sensor Modules
Serial.print("Initializing the sensors...");
nicla::begin();
nicla::leds.begin();
BHY2.begin(NICLA_I2C);
// accel.begin();// gyro.begin();// mag.begin();
rot.begin();
orient.begin();
Serial.println("done");
printTime = millis();
// Print CSV header printf("timestamp, rot_X, rot_Y, rot_Z, rot_W, orient_x, orient_y, orient_z, orient_w, sampleCount\n");
// Turn on LED to blinking yellow for 5 sec delayfor (int i = 0; i < 10; i++) {
nicla::leds.setColor(red);
delay(500); // Yellow on for 0.5 seconds
nicla::leds.setColor(off);
delay(500); // Yellow off for 0.5 seconds
}
// Change LED color to green and indicate data collection has started
nicla::leds.setColor(green);
dataCol = true;
}
// ///////////////////////////////////////////////////////////////////////////voidloop()
{
auto currentTime = millis();
// Update function should be continuously polled
BHY2.update();
// Set Interval Time and Check sensor valuesif (sampleCount < SAMPLE_NO && currentTime - printTime >= INTERVAL_MS) {
printTime = currentTime;
sampleCount++;
printf("%lu,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%d\n",
printTime,
rot.x(), rot.y(), rot.z(), rot.w(),
orient.x(), orient.y, orient.z, orient.w(),
sampleCount
);
}
if (sampleCount >= SAMPLE_NO) {
nicla::leds.setColor(off);
dataCol = false;
}
}
The text was updated successfully, but these errors were encountered:
I have mounted a Nicla Sense ME on a simple platform, with USB on the underside of the board. I have setup a simple 15 sec logging program for the rotation (SENSOR_ID_RV). I have performed simple pitch, roll and heading directional movements in accordance with the X-Y-Z graphic on the top of the board, to try and orientate myself to the Nicla coordinate system. After logging the data at 100 Hz for 15 sec and porting the data to Excel using Putty, I normalized and converted the data to Euler angles in degrees using
When I've reviewed the data in Excel, I find the following conclusions:
Can you see any problems with what I am concluding? I'll admit I'm new at this. My sketch is below
The text was updated successfully, but these errors were encountered: