Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Big modifications, but most importantly added NED and ENU frame supports. #40

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codespellrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See: https://github.com/codespell-project/codespell#using-a-config-file
[codespell]
# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here:
ignore-words-list = ,
ignore-words-list = ned, enu
check-filenames =
check-hidden =
skip = ./.git
35 changes: 28 additions & 7 deletions examples/Visualize101/Visualize101.ino
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <CurieIMU.h>
// for better performance, compile this code using at least C++ 17.
#include <MadgwickAHRS.h>

Madgwick filter;
Expand All @@ -8,11 +9,15 @@ float accelScale, gyroScale;
void setup() {
Serial.begin(9600);

// start the IMU and filter
// start the IMU
CurieIMU.begin();
CurieIMU.setGyroRate(25);
CurieIMU.setAccelerometerRate(25);
filter.begin(25);

// set the Madgwick's filter parameter (beta)
filter.setBeta(0.1);
// set the IMU update frequency in Hz
filter.setFrequency(25);

// Set the accelerometer range to 2 g
CurieIMU.setAccelerometerRange(2);
Expand All @@ -30,6 +35,7 @@ void loop() {
float ax, ay, az;
float gx, gy, gz;
float roll, pitch, heading;
float q[4];
unsigned long microsNow;

// check if it's time to read data and update the filter
Expand All @@ -48,19 +54,34 @@ void loop() {
gz = convertRawGyro(giz);

// update the filter, which computes orientation
filter.updateIMU(gx, gy, gz, ax, ay, az);
// the first template parameter is the local reference frame
// NWU = 0, NED = 1, ENU = 2
// the second template parameter is the measurement unit of the gyroscope reading
// 'D' = degree per second, 'R' = radians per second
filter.updateIMU<0,'D'>(gx, gy, gz, ax, ay, az);

// print the heading, pitch and roll
roll = filter.getRoll();
pitch = filter.getPitch();
heading = filter.getYaw();
// print the heading, pitch and roll (Tait-Bryan angle in ZYX convention)
roll = filter.getRollDegree();
pitch = filter.getPitchDegree();
heading = filter.getYawDegree();
Serial.print("Orientation: ");
Serial.print(heading);
Serial.print(" ");
Serial.print(pitch);
Serial.print(" ");
Serial.println(roll);

// get and print the quaternion
filter.getQuaternion(q);
Serial.print("Quaternion: ");
Serial.print(q[0]);
Serial.print(" ");
Serial.print(q[1]);
Serial.print(" ");
Serial.print(q[2]);
Serial.print(" ");
Serial.println(q[3]);

// increment previous time, so we keep proper pace
microsPrevious = microsPrevious + microsPerReading;
}
Expand Down
12 changes: 9 additions & 3 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ Madgwick KEYWORD1
# Methods and Functions (KEYWORD2)
#######################################

setBeta KEYWORD2
setFrequency KEYWORD2
getQuaternion KEYWORD2
update KEYWORD2
updateIMU KEYWORD2
getPitch KEYWORD2
getYaw KEYWORD2
getRoll KEYWORD2
getPitchDegree KEYWORD2
getYawDegree KEYWORD2
getRollDegree KEYWORD2
getPitchRadians KEYWORD2
getYawRadians KEYWORD2
getRollRadians KEYWORD2


#######################################
Expand Down
Loading