Propshield Orientation Rotation Backwards

Status
Not open for further replies.
Hello to all,

I started using the Teensy 3.5 and the prop shield about two weeks ago. The hardware looks to be a good fit to what I need. When I run the Orientation module that was part of the package, the getYaw() function for the Serial.print(heading), rotates the compass in the opposite direction to the actual rotation. The code is below.

The problem looks to me to be in NXPMotionSense imu or NXPSensorFusion filter (maybe?) . I've reloaded Arduino, and the TeensyDuino several times on a Win10 platform and with the teensy 3.5. and re-downloaded the github link for the NXP code as described in the installation guide. I've searched the web for info, and only found one entry about this problem, but can't find the fix at github. After two weeks of pounding the keyboard and searching for an answer I'm finally saying Uncle and asking your forum for help.

The goal is to have the Teensy report all the parameters from the propshield IMU to another computer/program. I can read the data on the Win10 or Arduino IDE very easily, but the mag data appears to rotate wrong.

The NXPMotionSense and NXPSensorFusion packages are very large and cumbersome to include in this posting.

If anyone has run into this can you suggest how to correct my problem.

Thanx Rick


// Full orientation sensing using NXP's advanced sensor fusion algorithm.
//
// You *must* perform a magnetic calibration before this code will work.
//
// To view this data, use the Arduino Serial Monitor to watch the
// scrolling angles, or run the OrientationVisualiser example in Processing.

#include <NXPMotionSense.h>
#include <Wire.h>
#include <EEPROM.h>

NXPMotionSense imu;
NXPSensorFusion filter;

void setup() {
Serial.begin(9600);
imu.begin();
filter.begin(100);
}

void loop() {
float ax, ay, az;
float gx, gy, gz;
float mx, my, mz;
float roll, pitch, heading;

if (imu.available()) {
// Read the motion sensors
imu.readMotionSensor(ax, ay, az, gx, gy, gz, mx, my, mz);

// Update the SensorFusion filter
filter.update(gx, gy, gz, ax, ay, az, mx, my, mz);

// print the heading, pitch and roll
roll = filter.getRoll();
pitch = filter.getPitch();
heading = filter.getYaw();
Serial.print("Orientation: ");
Serial.print(heading);
Serial.print(" ");
Serial.print(pitch);
Serial.print(" ");
Serial.println(roll);
}
}
 
I noticed the same. You can print 360-heading to get the actual compass direction. I didn't ever decide if there was an error or if that is just how things work out when the instrument readings are convoluted in the filter algorithms.

I also tried Mahony and Madgwick filters. I found the Mahony filter to be 10 degrees off in pitch.
 
Just by way of warning. Make sure you do a good calibration per the propshield web page: https://www.pjrc.com/store/prop_shield.html. Its a little it down the page and available for windows, Linux and mac.

EDIT: Its been awhile since I used the propshield and can't remember if there it does accel and gyro calibration. If you want to test out Madgwick and Mahoney filters you can check out Kris Winer's implementation: https://github.com/kriswiner/Teensy_Prop_Shield
 
Last edited:
mjs513, I'll check kris winders after I finish this entry.

I've recalibrated the IMU multiple times, after the rebuilds. I had a almost a fully filled floating ball the last couple of times.

The non-fusion method of finding heading works in the Orientation.ino if I disable the filter.update and then (rem) or // the lines pertaining to printing the getXxx() data. However the Heading jitters back and for several degrees, which isn't really accurate.

The "mx & my"s have been swapped back & forth and the delays have been tested from delay(0) to delay(10000)


Code:
// Full orientation sensing using NXP's advanced sensor fusion algorithm.
//
// You *must* perform a magnetic calibration before this code will work.
//
// To view this data, use the Arduino Serial Monitor to watch the
// scrolling angles, or run the OrientationVisualiser example in Processing.

#include <NXPMotionSense.h>
#include <Wire.h>
#include <EEPROM.h>

NXPMotionSense imu;
NXPSensorFusion filter;

void setup() {
  Serial.begin(9600);
  imu.begin();
  filter.begin(100);
}

void loop() {
  float ax, ay, az;
  float gx, gy, gz;
  float mx, my, mz;
/  float roll, pitch, heading;
  float Pi = 3.14159;
  float mheading;

  if (imu.available()) {
    // Read the motion sensors
    imu.readMotionSensor(ax, ay, az, gx, gy, gz, mx, my, mz);

    // Update the SensorFusion filter
    //filter.update(gx, gy, gz, ax, ay, az, mx, my, mz);

 
  //Calculate the angle of the vector y,x
  float mheading = (atan2(my,mx) * 180)/Pi;
  
  //Normalize to 0-360
  if (mheading < 0){
    mheading = 360 + mheading;
  }

 /*
    // print the heading, pitch and roll
    roll = filter.getRoll();
    pitch = filter.getPitch();
    heading = filter.getYaw();
    Serial.print(": ");
    Serial.print("  Manualy Compensated Mhdng = ");
    Serial.print(int(mheading));
        Serial.print(" hdng = ");
        Serial.print(int(heading));
    Serial.print(" Pitch = ");
    Serial.print(int(pitch));
    Serial.print(" Roll = ");
    Serial.println(int(roll));
*/

    Serial.print(" heading = ");
    Serial.println(int(mheading));

delay(100);    
  }
}
 
Last edited by a moderator:
Ok. Pulled out my prop shield and loaded up the example and did the calibration. Yes - the rotations aren't aligning with what the normal aircraft conventions are. Its been quite awhile since I went through this so let me see if I can go back and remember :)

UPDATE:
Change the filter update line to:
Code:
    // Update the SensorFusion filter
    filter.update(gx, -gy, -gz, -ax, ay, az, mx, -my, -mz);
and it should give you what you need. This is based on kwiner's code for axis alignment.
 
Last edited:
I don't believe the examples do any calibration of the gyro and accelerometers. I printed out gx,gy and gz when the unit was at rest. In my application, I subtracted those numbers from the gyro readings before using them in the Madgwick filter. Before I did this, my heading would rotate through 360 degrees in about a minute. I did not try any calibration of the accelerometers. ( note: the Madgwick filter does not use the magnetic readings and heading is just a relative value ).
 
This change did the trick.

filter.update(gx, -gy, -gz, -ax, ay, az, mx, -my, -mz);

My thanks to all of you and especially mjs513. You are all an incredible source.

I hope that I've used the correct format for this request.

Again,
Thanx
Rick Mason
 
@rcarr
note: the Madgwick filter does not use the magnetic readings and heading is just a relative value
Actually both the Mahony and Madwick filters can be run with and without a magnetomer. If you look in the Madgwick .h file you will see two filter updates:
Code:
    void update(float gx, float gy, float gz, float ax, float ay, float az, float mx, float my, float mz);
    void updateIMU(float gx, float gy, float gz, float ax, float ay, float az);
The first allows you to run the filter with a magnetometer while the second will allow you to run the filter without. Just substitute one call for the other. As for accel/gyro calibration, take a look at the standalone implementation and you can probably port that over to your application.

@rickmason1
thanks for the compliment Rick but learned from a lot of other people on the forum as well.

Mike
 
The NxpMotionSense works fairly well with filter.update(gx, -gy, -gz, -ax, ay, az, mx, -my, -mz); from above, however the drift isn't acceptable, and I can't seem to get it to realign to magnetic heading. If the registers haven't been written then it thinks it's heading 359 degrees, or it uses the last registers that were written.

I wrote a small addition to the Orientation sketch before it starts the main void loop() to find the average of 100 samplings of the atan2() function of the my, mx, my, but I can't figure out how to interface the mag compass reading to the nxpmotionsense to initialize the gyro, and then inserted to same atan2() function into the void loop(). The code for this is attached below. It's not elegant but it works.

Is it possible to stop the drift, and also to send the initial mag info to nxpmotionsense to get it to understand the start up compass heading.

I down_loaded the Teensy_Prop_Shield by Kris Winer, but It's a little intimidating to my 70year old mind, and it wants to recalibrate the Prop_Shield each time it runs. I would prefer to keep the MotionCal.exe settings, and for simplicity run the nxpmotionsense.h if I can.

As before, I searched the web and this forum quite a bit before I came back to you for help.

Any ideas?

Thanx
Rick Mason




// Full orientation sensing using NXP's advanced sensor fusion algorithm.
//
// You *must* perform a magnetic calibration before this code will work.
//
// To view this data, use the Arduino Serial Monitor to watch the
// scrolling angles, or run the OrientationVisualiser example in Processing.

#include <NXPMotionSense.h>
#include <Wire.h>
#include <EEPROM.h>

NXPMotionSense imu;
NXPSensorFusion filter;

void setup() {
Serial.begin(9600);
imu.begin();
filter.begin(100); //(1000) nope RM
ini();
}

float Pi = 3.14159;
int loop_cntr=1;
float ax, ay, az;
float gx, gy, gz;
float mx, my, mz;
float roll, pitch, heading;
float mheading;
float xmheading=0;
int mag_calib_cntr=10; //numbers of times to test compass


//~~~~~~~~~~~~Begin Compass Calibration ~~~~
void ini(){ //THIS SECTION GETS A MAG HEADING TO SET THE GYRO COMPASS

while (loop_cntr<=mag_calib_cntr){
if (imu.available()) {
// Read the motion sensors
imu.readMotionSensor(ax, ay, az, gx, gy, gz, mx, my, mz);
Serial.println("CALIBRATING COMPASS AND GYRO ");
Serial.print(" loop_cntr=");
Serial.print(loop_cntr);

//Calculate the angle of the vector y,x
// Read the motion sensors
imu.readMotionSensor(ax, ay, az, gx, gy, gz, mx, my, mz);
float mheading = ((atan2(my,mx) * 180)/Pi);

//Normalize to 0-360
if (mheading < 0){
mheading = 360 + mheading;
}
Serial.print(" xmheading=");
Serial.print(int(xmheading));
Serial.print(" mheading=");
Serial.print(int(mheading));

xmheading=xmheading+mheading;

delay(100); //50); //100);
loop_cntr+=1;}
}

delay(100);
loop_cntr-=1;

xmheading = int(xmheading)/loop_cntr;
Serial.println();
Serial.print(" CALIBRATED COMPASS Heading");
Serial.println(" after + xmheading/loop=");
Serial.print("loop_cntr=");
Serial.print(loop_cntr);
Serial.print(" xmheading=");
Serial.print(int(xmheading));
Serial.print(" mheading=");
Serial.println(int(mheading));

delay(100);
//while (1){}

//~~~~~~~~~~~~End of Compass Calibration ~~~~

}


void loop(){
if (imu.available()) {
// Read the motion sensors
imu.readMotionSensor(ax, ay, az, gx, gy, gz, mx, my, mz);

float mheading = ((atan2(my,mx) * 180)/Pi);

//Normalize to 0-360
if (mheading < 0){
mheading = 360 + mheading;
}

// Update the SensorFusion filter
//filter.update(gx, gy, gz, ax, ay, az, mx, my, mz);
filter.update(gx, -gy, -gz, -ax, ay, az, mx, -my, -mz);


// print the heading, pitch and roll
roll = filter.getRoll();
pitch = filter.getPitch();
heading = filter.getYaw();

// heading = filter.getMag(); //NOPE RM
Serial.print("Calibrated xmheading=") ;
Serial.print(int(xmheading)) ;
Serial.print(" Mag heading:=");
Serial.print(int(mheading));

Serial.print(" Gyro heading:=");
Serial.print(int(heading));
Serial.print(" pitch:=");
Serial.print(int(pitch));
Serial.print(" roll:=");
Serial.println(int(roll));
delay(5); //10);
//loop_cntr+=1;
delay(10);

} //if imu
} //void loop
 
Is it possible to stop the drift, and also to send the initial mag info to nxpmotionsense to get it to understand the start up compass heading.
Don't know if there is a way to initialize the gyro in the motion sense library. To be honest I have really looked before.

As for Gyro and Accelerometer calibration. Gyro Calibration you should always do at startup. Accel you could do once using Kwiners sketch, saving the values and then use them in the Motion sense library. You have to make sure of a few things: 1) the Kris's sketch is using the same scales for gyro and accel (think its set for 2000dps and 4g). (2) make sure when you apply the corrections they are the same units :) You could do the gyro also but it may be off from run to run.

I put together a library that was kind of a cross between Kris's and the MotionSense that did incorporate a slightly different way to save the calibration and load it at run time (actually it gave you a choice) but I haven't used it for a long time so not sure if 100%. Here's the GitHub link: https://github.com/mjs513/PRJC-PropShield-Practice-Sketches/tree/master/MotionSense .
 
mjs513,

I think your name is "Paul". I wish I could keep up with how fast you respond with all of this coding. I'm NOT complaining. I'll work on what you've sent me. Many thanx to you and all the forum that are/is/have been helping me.

Rick Mason
 
Hi Rick
I re-organized the GitHub Repository to make it a little clearer. AP_Filter and PSIMU directories should be put into the libraries folder. The calibration GUI directory has two folders. 1 is the exe and the second is the python sources.

Mike
 
mjs513,

I worked on your last PSImu information and code for 4 or 5 hours and worked out many of the bugs, mostly missing libraries, (I've learned a lot about libraries and how to install them), but I hit one road block that has me stymied in the psIMU...cpp. I've gone through it but the code is just too much for me. If you get a chance could you give me an idea of how to correct this. The error is below.

Thanx
Rick

C:\Users\rick\Documents\Arduino\libraries\PSImu-master\psIMU..cpp:813:8: error: 'motion_detect_ma' was not declared in this scope

if(motion_detect_ma.process(motionDetect) > 0.5) {

^

Error compiling for board Teensy 3.5.
 
mjs13 Mike,
I got a little ahead of you and didn't see your last post. I'll go thru it first, so ignore my previous post about the error.

Thanx
Rick
 
mjs513 Mike,

I re-downloaded the PSImu from github and reloaded it in my user directory for the libraries "C:\Users\rick\Documents\Arduino\libraries" (win10) a screen shot of that folder is hopefully enclosed.

Then I tried to run "verify" on the psIMU_serial again. Below are the errors that it's throwing out. Any ideas on what I've done wrong?

Thanx
Rick













psIMU_serial: In function 'float invSqrt(float)':
psIMU_serial:371: warning: dereferencing type-punned pointer will break strict-aliasing rules
uint32_t i = 0x5F1F1412 - (*(uint32_t*)&x >> 1);

^

psIMU_serial:372: warning: dereferencing type-punned pointer will break strict-aliasing rules
float tmp = *(float*)&i;

^

MadgwickQuantFileter: In function 'void MadgwickQuaternionUpdate(float, float, float, float, float, float, float, float, float)':
MadgwickQuantFileter:15: warning: variable '_2q0q2' set but not used
float _2q0mx, _2q0my, _2q0mz, _2q1mx, _2bx, _2bz, _4bx, _4bz, _2q0, _2q1, _2q2, _2q3, _2q0q2, _2q2q3, q0q0, q0q1, q0q2, q0q3, q1q1, q1q2, q1q3, q2q2, q2q3, q3q3;

^

MadgwickQuantFileter:15: warning: variable '_2q2q3' set but not used
float _2q0mx, _2q0my, _2q0mz, _2q1mx, _2bx, _2bz, _4bx, _4bz, _2q0, _2q1, _2q2, _2q3, _2q0q2, _2q2q3, q0q0, q0q1, q0q2, q0q3, q1q1, q1q2, q1q3, q2q2, q2q3, q3q3;

^

MahoneyQuantFilter: In function 'void MahonyQuaternionUpdate(float, float, float, float, float, float, float, float, float)':
MahoneyQuantFilter:48: warning: 'halfex' may be used uninitialized in this function
halfex += (my * halfwz - mz * halfwy);

^

MahoneyQuantFilter:49: warning: 'halfey' may be used uninitialized in this function
halfey += (mz * halfwx - mx * halfwz);

^

MahoneyQuantFilter:50: warning: 'halfez' may be used uninitialized in this function
halfez += (mx * halfwy - my * halfwx);

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:8:1: error: 'MovingAvarageFilter' does not name a type

MovingAvarageFilter accnorm_avg(5);

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:9:1: error: 'MovingAvarageFilter' does not name a type

MovingAvarageFilter accnorm_test_avg(7);

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:10:1: error: 'MovingAvarageFilter' does not name a type

MovingAvarageFilter accnorm_var(7);

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:11:1: error: 'MovingAvarageFilter' does not name a type

MovingAvarageFilter motion_detect_ma(7);

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:17:1: error: 'butter10hz0_3' does not name a type

butter10hz0_3 mfilter_accx;

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:18:1: error: 'butter10hz0_3' does not name a type

butter10hz0_3 mfilter_accy;

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:19:1: error: 'butter10hz0_3' does not name a type

butter10hz0_3 mfilter_accz;

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:25:1: error: 'butter100hz2_0' does not name a type

butter100hz2_0 mfilter_mx;

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:26:1: error: 'butter100hz2_0' does not name a type

butter100hz2_0 mfilter_my;

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:27:1: error: 'butter100hz2_0' does not name a type

butter100hz2_0 mfilter_mz;

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp: In member function 'void psIMU::getValues(float*)':

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:170:15: error: 'mfilter_accx' was not declared in this scope

int axcnt = mfilter_accx.filter((float) accelCount[0]);

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:171:15: error: 'mfilter_accy' was not declared in this scope

int aycnt = mfilter_accy.filter((float) accelCount[1]);

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:172:15: error: 'mfilter_accz' was not declared in this scope

int azcnt = mfilter_accz.filter((float) accelCount[2]);

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:193:15: error: 'mfilter_mx' was not declared in this scope

int mxcnt = mfilter_mx.filter((float) magCount[0]);

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:194:15: error: 'mfilter_my' was not declared in this scope

int mycnt = mfilter_my.filter((float) magCount[1]);

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:195:15: error: 'mfilter_mz' was not declared in this scope

int mzcnt = mfilter_mz.filter((float) magCount[2]);

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp: In member function 'void psIMU::MotionDetect(float*)':

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:754:24: error: 'accnorm_avg' was not declared in this scope

float accnormavg = accnorm_avg.process(accnorm);

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:755:28: error: 'accnorm_test_avg' was not declared in this scope

float accnormtestavg = accnorm_test_avg.process(accnorm_test);

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:764:8: error: 'accnorm_var' was not declared in this scope

if(accnorm_var.process(sq(accnorm-accnormavg)) < 0.0005) {

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:813:8: error: 'motion_detect_ma' was not declared in this scope

if(motion_detect_ma.process(motionDetect) > 0.5) {

^

Error compiling for board Teensy 3.5.
 
Hi Rick
Looks like you forgot to move the AP_Filter folder into the library folder. Just as a FYI I am running on a Windows 10 machine as well.

Mike

BTW> COMMENT OUT THE LINE FOR SETFILACAL() to run the built-in cal to start with. To use the cal file you will need to run calgui.exe program and save the calibration.h file into library folder for the PSIMU
 
mjs513 Mike,

The missing library errors and are fixed. Thank you.

I'm still throwing many errors during "upload" to the Teensy & prop shield (below in red). I've run the psIMU_serial.ino with "myIMU.setFileCal()", both commented out and without commented. I've also set it to both 0 & 1 as in the comment before it " //Set calibration source, 0 = builtin, 1 = file" for testing.

The sketch calibration is too inaccurate and doesn't produce the heading data that I need.

I've run the sketch by letting it calibrate itself, and using the "calibration.h" file in the libraries directory in my users folder. Shown below in green.

When I run the "cal_gui.exe" and produce/save the "calibration.h" to the libraries with "myIMU.setFileCal()" set to read the calibration.h file, the Teensy produces,
"Orientation: nan nan nan"

I think I've still missed something in setting the libraries and the psIMU sketch up.

Just and FYI this a small but very important part of the system that I'm programming for the aircraft that I've been building and is very close to flying after many years of work building it. I have a full panel display built for Attitude Indicator, Pressure Airspeed, Compass, (Engine/brakes/cooling temp/ and pressures), and I've simulated the attitude and compass input to it, now I just need the mag compass, and if it's gyro stabilized that's icing on the cake. Since the aircraft being experimental is allowed to have this type of display. This is the 4th aircraft of this type that I've helped build, and/or test flown. I could buy all of this panel, but I really want the satisfaction of building the Aircraft, engine, display and computers myself.

I'm concerned that my questions are too numerous or just a PIA. I hope not, but after all, you've got a life too.

Thanx
Rick Mason
ATP/Commercial ASMELG/CFII-ASMEL/Retired
MCSE/Retired



/**
* psIMU calibration header. Automatically generated by psIMU_GUI.
* Do not edit manually unless you know what you are doing.
*/


#define CALIBRATION_H

accel_bias[0] = 196;
accel_bias[1] = 454;
accel_bias[2] = -615;
accel_scale[0] = 2701.917289;
accel_scale[1] = 5730.801741;
accel_scale[2] = 6351.651277;

mag_bias[0] = -157;
mag_bias[1] = 28;
mag_bias[2] = 279;
mag_scale[0] = 459.710415;
mag_scale[0] = 527.586282;
mag_scale[0] = 501.421584;




H:\Aircraft_Panel\PSImu-master\examples\psIMU_serial\psIMU_serial.ino\psIMU_serial.ino.ino: In function 'float invSqrt(float)':

H:\Aircraft_Panel\PSImu-master\examples\psIMU_serial\psIMU_serial.ino\psIMU_serial.ino.ino:374:49: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

uint32_t i = 0x5F1F1412 - (*(uint32_t*)&x >> 1);

^

H:\Aircraft_Panel\PSImu-master\examples\psIMU_serial\psIMU_serial.ino\psIMU_serial.ino.ino:375:31: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

float tmp = *(float*)&i;

^

MadgwickQuantFileter: In function 'void MadgwickQuaternionUpdate(float, float, float, float, float, float, float, float, float)':
MadgwickQuantFileter:15: warning: variable '_2q0q2' set but not used
float _2q0mx, _2q0my, _2q0mz, _2q1mx, _2bx, _2bz, _4bx, _4bz, _2q0, _2q1, _2q2, _2q3, _2q0q2, _2q2q3, q0q0, q0q1, q0q2, q0q3, q1q1, q1q2, q1q3, q2q2, q2q3, q3q3;

^

MadgwickQuantFileter:15: warning: variable '_2q2q3' set but not used
float _2q0mx, _2q0my, _2q0mz, _2q1mx, _2bx, _2bz, _4bx, _4bz, _2q0, _2q1, _2q2, _2q3, _2q0q2, _2q2q3, q0q0, q0q1, q0q2, q0q3, q1q1, q1q2, q1q3, q2q2, q2q3, q3q3;

^

MahoneyQuantFilter: In function 'void MahonyQuaternionUpdate(float, float, float, float, float, float, float, float, float)':
MahoneyQuantFilter:48: warning: 'halfex' may be used uninitialized in this function
halfex += (my * halfwz - mz * halfwy);

^

MahoneyQuantFilter:49: warning: 'halfey' may be used uninitialized in this function
halfey += (mz * halfwx - mx * halfwz);

^

MahoneyQuantFilter:50: warning: 'halfez' may be used uninitialized in this function
halfez += (mx * halfwy - my * halfwx);

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp: In member function 'void psIMU::FXOS8700CQMagOffset()':

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:365:9: warning: variable 'dest1' set but not used [-Wunused-but-set-variable]

float dest1[3] = {0, 0, 0}, dest2[3] = {0, 0, 0};

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:365:31: warning: variable 'dest2' set but not used [-Wunused-but-set-variable]

float dest1[3] = {0, 0, 0}, dest2[3] = {0, 0, 0};

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp: In member function 'void psIMU::initFIFOMPL3115A2()':

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:963:11: warning: variable 'temp' set but not used [-Wunused-but-set-variable]

uint8_t temp;

^

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp: In member function 'void psIMU::initRealTimeMPL3115A2()':

C:\Users\rick\Documents\Arduino\libraries\PSIMU\psIMU..cpp:1000:11: warning: variable 'temp' set but not used [-Wunused-but-set-variable]

uint8_t temp;

^

C:\Users\rick\Documents\Arduino\libraries\iCompass\iCompass.cpp:5:0: warning: "M_PI" redefined

#define M_PI 3.14159265359

^

In file included from C:\Program Files\Arduino\hardware\teensy\avr\cores\teensy3/WProgram.h:36:0,

from C:\Users\rick\AppData\Local\Temp\arduino_build_557263/pch/Arduino.h:6,

from C:\Users\rick\Documents\Arduino\libraries\iCompass/iCompass.h:4,

from C:\Users\rick\Documents\Arduino\libraries\iCompass\iCompass.cpp:1:

c:\program files\arduino\hardware\tools\arm\arm-none-eabi\include\math.h:640:0: note: this is the location of the previous definition

#define M_PI 3.14159265358979323846

^

C:\Users\rick\Documents\Arduino\libraries\iCompass\iCompass.cpp: In constructor 'iCompass::iCompass()':

C:\Users\rick\Documents\Arduino\libraries\iCompass\iCompass.cpp:10:84: warning: unused variable 'test' [-Wunused-variable]

iCompass::iCompass(void) : myRA(1) { declinationAngle = 0; maxSamples = 500; float test = 1.0f; samples = 0; myRA.clear(); }

^

C:\Users\rick\Documents\Arduino\libraries\iCompass\iCompass.cpp: In constructor 'iCompass::iCompass(float)':

C:\Users\rick\Documents\Arduino\libraries\iCompass\iCompass.cpp:11:97: warning: unused variable 'test' [-Wunused-variable]

iCompass::iCompass(float dAngle) : myRA(1) { declinationAngle = dAngle; maxSamples = 500; float test = 1.0f; samples = 0; myRA.clear(); }

^

C:\Users\rick\Documents\Arduino\libraries\iCompass\iCompass.cpp: In constructor 'iCompass::iCompass(float, unsigned int)':

C:\Users\rick\Documents\Arduino\libraries\iCompass\iCompass.cpp:12:127: warning: unused variable 'test' [-Wunused-variable]

iCompass::iCompass(float dAngle, unsigned int windSize) : myRA(windSize) { declinationAngle = dAngle; maxSamples = 500; float test = 1.0f; samples = 0; myRA.clear(); }

^

C:\Users\rick\Documents\Arduino\libraries\iCompass\iCompass.cpp: In constructor 'iCompass::iCompass(float, unsigned int, unsigned int)':

C:\Users\rick\Documents\Arduino\libraries\iCompass\iCompass.cpp:13:147: warning: unused variable 'test' [-Wunused-variable]

iCompass::iCompass(float dAngle, unsigned int windSize, unsigned int maxS) : myRA(windSize) { declinationAngle = dAngle; maxSamples = maxS; float test = 1.0f; samples = 0; myRA.clear(); }

^

Archiving built core (caching) in: C:\Users\rick\AppData\Local\Temp\arduino_cache_296841\core\core_teensy_avr_teensy35_usb_serial,speed_120,opt_o2std,keys_en-us_71a00981eaa0bad0868b6b2ed88d327b.a
Sketch uses 61084 bytes (11%) of program storage space. Maximum is 524288 bytes.
Global variables use 8288 bytes (3%) of dynamic memory, leaving 253848 bytes for local variables. Maximum is 262136 bytes.
 
I'm concerned that my questions are too numerous or just a PIA
First. Don't worry about questions and they are definitely not a PIA. I am glad to help.

I'm still throwing many errors during "upload" to the Teensy & prop shield (below in red). I've run the psIMU_serial.ino with "myIMU.setFileCal()", both commented out and without commented. I've also set it to both 0 & 1 as in the comment before it " //Set calibration source, 0 = builtin, 1 = file" for testing
We will get to the errors in a couple of minutes. To be honest I forgot to change the comment "//Set calibration source, 0 = builtin, 1 = file". It really should read:
Code:
//Comment out the setFileCal() to use the built-in calibration.  Uncomment to use the calibration file.
Also, there is a line in the "myIMU.setAccelSensitivity(4096);" this is the sensitivity for when you set the accel at 2g. I really should add the following to the sketch as a comment:
Code:
Possible Accel Scales
2g -- 4096 (8192/2)
4g -- 2048
8g -- 1024
When I run the "cal_gui.exe" and produce/save the "calibration.h"....
When I look at the data from you calibration file the accel readings look strange. What accel scale are you using? Either way the ax scale is way out compared to ay and az. Mag does look ok. Here is a references on using the GUI: https://github.com/mjs513/FreeIMU-Updates/wiki/04.-FreeIMU-Calibration. Oh, and if you put the cursor in one of the calibration views you can zoom in or out with the mouse scroll wheel and shift the view around by holding the left mouse button down and moving the mouse.
set to read the calibration.h file, the Teensy produces,
"Orientation: nan nan nan"
That's usually occurs when the cal is not good. Make sure you are using the psIMU_serial_kalman.ino sketch. Guess you found that you can hit the z key to print out the orientation data.

Ok. Just noticed you are using the psIMU_serial.ino sketch. Use the other one and most of those errors will disappear.
 
Status
Not open for further replies.
Back
Top