kriswiner / ESP32

Arduino sketches for the ESP32
167 stars 47 forks source link

angle offset to 0 #18

Open tomgraph79 opened 5 years ago

tomgraph79 commented 5 years ago

Dear Kris,

thank you for sharing your fantastic libraries and documentation! : )

I 'm using a ESP32 DevKit Combo Board with a InvenSense MPU9250. I could upload your script and it seems that everything is running fine.

But i suppose the Calibration is not working properly. I would like to have the value 0 for all angles (roll, pitch, yaw) after the calibration. Do you have any idea, how i could handle that?

Thank you and sorry for my bad English ; ) Thomas

Scanning... I2C device found at address 0x0C ! I2C device found at address 0x68 ! done

MPU9250 9-axis motion sensor... MPU9250 I AM 73 I should be 71 MPU9250 is online... x-axis self test: acceleration trim within : 0.3% of factory value y-axis self test: acceleration trim within : -3.4% of factory value z-axis self test: acceleration trim within : -0.1% of factory value x-axis self test: gyration trim within : -4.0% of factory value y-axis self test: gyration trim within : -1.1% of factory value z-axis self test: gyration trim within : 0.5% of factory value Calibrate gyro and accel accel biases (mg) 976.38 -273.19 -974.18 gyro biases (dps) -1.16 1.56 1.89 MPU9250 initialized for active data mode.... AK8963 I AM 48 I should be 48 AK8963 initialized for active data mode.... Mag Calibration: Wave device in a figure eight until done! Mag Calibration done! AK8963 mag biases (mG) 101.82 -300.11 -158.42 AK8963 mag scale (mG) 1.10 0.90 1.02 X-Axis sensitivity adjustment value 1.19 Y-Axis sensitivity adjustment value 1.19 Z-Axis sensitivity adjustment value 1.15 MS5637 pressure sensor reset... PROM dta read: C0 = 14080 C1 = 14080 C2 = 14080 C3 = 14080 C4 = 14080 C5 = 14080 C6 = 14080 Checksum = 13 , should be 3

Yaw: 5.50 Pitch: 0.00 Roll: 0.00

Yaw: 39.92 Pitch: 62.81 Roll: -63.46

Yaw: 38.67 Pitch: 63.06 Roll: -64.81

Yaw: 37.43 Pitch: 63.28 Roll: -66.12

tomgraph79 commented 5 years ago

Ups! What happend to the font size?

kriswiner commented 5 years ago

Well, are you saying you don;t know how to calibrate the sensors?

Roll and pitch should be less than 1 degree when the sensors are properly calibrated and the sensor is lying flast and motionless, like on a table.

The yaw will only be zero when the axis you have chosen for North is pointed along the magnetic north direction.

On Mon, Nov 19, 2018 at 1:28 PM tomgraph79 notifications@github.com wrote:

Dear Kris,

thank you for sharing your fantastic libraries and documentation! : )

I 'm using a ESP32 DevKit Combo Board with a InvenSense MPU9250. I could upload your script and it seems that everything is running fine.

But i suppose the Calibration is not working properly. I would like to have the value 0 for all angles (roll, pitch, yaw) after the calibration. Do you have any idea, how i could handle that?

Thank you and sorry for my bad English ; ) Thomas

Scanning... I2C device found at address 0x0C ! I2C device found at address 0x68 ! done MPU9250 9-axis motion sensor... MPU9250 I AM 73 I should be 71 MPU9250 is online... x-axis self test: acceleration trim within : 0.3% of factory value y-axis self test: acceleration trim within : -3.4% of factory value z-axis self test: acceleration trim within : -0.1% of factory value x-axis self test: gyration trim within : -4.0% of factory value y-axis self test: gyration trim within : -1.1% of factory value z-axis self test: gyration trim within : 0.5% of factory value Calibrate gyro and accel accel biases (mg) 976.38 -273.19 -974.18 gyro biases (dps) -1.16 1.56 1.89 MPU9250 initialized for active data mode.... AK8963 I AM 48 I should be 48 AK8963 initialized for active data mode.... Mag Calibration: Wave device in a figure eight until done! Mag Calibration done! AK8963 mag biases (mG) 101.82 -300.11 -158.42 AK8963 mag scale (mG) 1.10 0.90 1.02 X-Axis sensitivity adjustment value 1.19 Y-Axis sensitivity adjustment value 1.19 Z-Axis sensitivity adjustment value 1.15 MS5637 pressure sensor reset... PROM dta read: C0 = 14080 C1 = 14080 C2 = 14080 C3 = 14080 C4 = 14080 C5 = 14080 C6 = 14080 Checksum = 13 , should be 3 Yaw: 5.50 Pitch: 0.00 Roll: 0.00 Yaw: 39.92 Pitch: 62.81 Roll: -63.46 Yaw: 38.67 Pitch: 63.06 Roll: -64.81 Yaw: 37.43 Pitch: 63.28 Roll: -66.12

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kriswiner/ESP32/issues/18, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qpQdLEJiD52OiYfdpa0Tj6Zrq25Kks5uwyKHgaJpZM4Yp7UO .

tomgraph79 commented 5 years ago

Thank you for your reply. That was very quick! : ) When i point the X or Y axis exactly to north, i get +/- 180° for roll, +/- 0° for pitch and around 70° for yaw. If it's stabil i can work with it, because i can do the offset later in my 3d program. But why is the yaw not +/- 90 °?

tomgraph79 commented 5 years ago

another thing i just realized: When i want to make the pitch a 360° turn, after arround 90° it goes back 89°, 87°, 86°, ... 0° instead of 91°, 92°,93°, ... 360°.

tomgraph79 commented 5 years ago

ok, after some calibration test, now i got 0° for all angles. But i still have the Problem with the Pitch rotation. It allways goes back after a 90° turn. What could cause this problem?

kriswiner commented 5 years ago

Are you feeding the fusion filter the sensor data in the correct order, NED?

On Tue, Nov 20, 2018 at 7:55 AM tomgraph79 notifications@github.com wrote:

ok, after some calibration test, now i got 0° for all angles. But i still have the Problem with the Pitch rotation. It allways goes back after a 90° turn. What could cause this problem?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/ESP32/issues/18#issuecomment-440323921, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qs3Rv2ox1vhJ4GWFeb0tDC4zBr4gks5uxCXtgaJpZM4Yp7UO .

tomgraph79 commented 5 years ago

where can i make these settings or find out?

kriswiner commented 5 years ago

What are you using for your sensor fusion?

On Tue, Nov 20, 2018 at 11:05 AM tomgraph79 notifications@github.com wrote:

where can i make these settings or find out?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/ESP32/issues/18#issuecomment-440393668, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qjO7ud5BiGZHITCFgb_opfVWFGzUks5uxFKKgaJpZM4Yp7UO .

tomgraph79 commented 5 years ago

I'm using your code "MPU9250_MS5637_AHRS.ino" and up to now i didn't change very mutch. Actually just a couple of snippets to get a Midi Signal out.

kriswiner commented 5 years ago

Fine, doesn't mean its correct. Can you answer my original question please?

On Tue, Nov 20, 2018 at 4:05 PM tomgraph79 notifications@github.com wrote:

I'm using your code "MPU9250_MS5637_AHRS.ino" and up to now i didn't change very mutch. Actually just a couple of snippets to get a Midi Signal out.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/kriswiner/ESP32/issues/18#issuecomment-440475347, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qv6GcH9oGppkPQzUu0uF9fKPsh3Uks5uxJjRgaJpZM4Yp7UO .

tomgraph79 commented 5 years ago

i tried both: the MahonyQuaternion and MadgwickQuaternion and both together. In all cases the same result! : (

kriswiner commented 5 years ago

" both together" what??!!

The sensor data need to be put into these functions (one or the other) in NED or ENU convention order.

So An, Ae, Ad, Gn, Ge, Gd, Mn, Me, Md order.

Is this what you are doing?

On Tue, Nov 20, 2018 at 4:42 PM tomgraph79 notifications@github.com wrote:

i tried both: the MahonyQuaternion and MadgwickQuaternion and both together. In all cases the same result! : (

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/ESP32/issues/18#issuecomment-440483546, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qu6yXGNvHR4Xod9aJirLECwrR37Nks5uxKGGgaJpZM4Yp7UO .

tomgraph79 commented 5 years ago

actually this are just 2 options, right. NED and ENU. I tried both versions of calibration. so one should have been right.

Or do i have to change the code anyway?

kriswiner commented 5 years ago

This has nothing to do with calibration...

On Tue, Nov 20, 2018 at 5:47 PM tomgraph79 notifications@github.com wrote:

actually this are just 2 options, right. NED and ENU. I tried both versions of calibration. so one should have been right.

Or do i have to change the code anyway?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/ESP32/issues/18#issuecomment-440497980, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qk4SMpXDKYuQuk_T34EyJWqcBZPXks5uxLCjgaJpZM4Yp7UO .

tomgraph79 commented 5 years ago

well, in the code is the order x, y, z. If i point x to north, than has the sensor be down, right.

kriswiner commented 5 years ago

Are you choosing Ax as North?

On Tue, Nov 20, 2018 at 6:20 PM tomgraph79 notifications@github.com wrote:

well, in the code is the order x, y, z. If i point x to north, than has the sensor be down, right.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/ESP32/issues/18#issuecomment-440504297, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qsU-RZFzRU9ReQEn1d6CGgh6cgsGks5uxLhdgaJpZM4Yp7UO .

tomgraph79 commented 5 years ago

MahonyQuaternionUpdate(ax, ay, az, gxPI/180.0f, gyPI/180.0f, gz*PI/180.0f, mx, my, mz);

kriswiner commented 5 years ago

Good, now is this in NED or ENU order? Needs to be in one of them...

On Tue, Nov 20, 2018 at 6:52 PM tomgraph79 notifications@github.com wrote:

MahonyQuaternionUpdate(ax, ay, az, gxPI/180.0f, gyPI/180.0f, gz*PI/180.0f, mx, my, mz);

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/ESP32/issues/18#issuecomment-440509871, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qlzTEaXFGeEer74FPx9BGFxp8axkks5uxL_zgaJpZM4Yp7UO .

tomgraph79 commented 5 years ago

isn't it?

tomgraph79 commented 5 years ago

you mean during the calibration?

kriswiner commented 5 years ago

I am waiting for your answer...

On Tue, Nov 20, 2018 at 6:56 PM tomgraph79 notifications@github.com wrote:

isn't it?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/ESP32/issues/18#issuecomment-440510587, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qscCmIJHcWbTEgW8TXaodjvEDo7uks5uxMDrgaJpZM4Yp7UO .

kriswiner commented 5 years ago

Nope...

On Tue, Nov 20, 2018 at 6:57 PM tomgraph79 notifications@github.com wrote:

you mean during the calibration?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/ESP32/issues/18#issuecomment-440510770, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qi0zwgGewlRqWsTiT_4zMXq9awVWks5uxMEwgaJpZM4Yp7UO .

tomgraph79 commented 5 years ago

but in the code isn't defined which axis needs to pint to north

tomgraph79 commented 5 years ago

point

kriswiner commented 5 years ago

Right, you select.

On Tue, Nov 20, 2018 at 7:01 PM tomgraph79 notifications@github.com wrote:

point

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/ESP32/issues/18#issuecomment-440511460, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qnlBuBv1UvaBo5xN1-ehj1U3-Sqmks5uxMITgaJpZM4Yp7UO .

tomgraph79 commented 5 years ago

during calibration, right

tomgraph79 commented 5 years ago

you mean the order in this line is wrong? MahonyQuaternionUpdate(ax, ay, az, gxPI/180.0f, gyPI/180.0f, gz*PI/180.0f, mx, my, mz);

kriswiner commented 5 years ago

This function isn't used during calibration.

Sounds like you have no idea what you are doing...

On Tue, Nov 20, 2018 at 7:03 PM tomgraph79 notifications@github.com wrote:

during calibration, right

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/ESP32/issues/18#issuecomment-440511711, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qlhndXu4Ba43wHgL5Rf3pWc5SrGmks5uxMJ4gaJpZM4Yp7UO .

tomgraph79 commented 5 years ago

i just try to understand the code!

kriswiner commented 5 years ago

The sensor data need to be fed into this function:

MahonyQuaternionUpdate(ax, ay, az, gxPI/180.0f, gyPI/180.0f, gz*PI/180.0f, mx, my, mz);

in the correct order. That order is either NED or ENU. You select which axis points North. Then everything else is determined by the geometry of your sensor.

Is this what you are doing?

Until you can verify that the answer is yes, you are wasting your time and my time.

On Tue, Nov 20, 2018 at 7:04 PM Tlera Corporation tleracorp@gmail.com wrote:

This function isn't used during calibration.

Sounds like you have no idea what you are doing...

On Tue, Nov 20, 2018 at 7:03 PM tomgraph79 notifications@github.com wrote:

during calibration, right

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/ESP32/issues/18#issuecomment-440511711, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qlhndXu4Ba43wHgL5Rf3pWc5SrGmks5uxMJ4gaJpZM4Yp7UO .

tomgraph79 commented 5 years ago

when i understand you right, then means NED:

MahonyQuaternionUpdate(ax, ay, az, gxPI/180.0f, gyPI/180.0f, gz*PI/180.0f, mx, my, mz);

when x axis is pointing north with z axis is down.

and ENO:

MahonyQuaternionUpdate(ay, ax, az, gyPI/180.0f, gxPI/180.0f, gz*PI/180.0f, my, mx, mz);

when y axis is pointing north with z axis is up.

tomgraph79 commented 5 years ago

of course i don't want to waste your time! i will find the solution! Thanks for everything : )

kriswiner commented 5 years ago

Check Fig 1 in the data sheet for help here.

On Tue, Nov 20, 2018 at 7:26 PM tomgraph79 notifications@github.com wrote:

of course i don't want to waste your time! i will find the solution! Thanks for everything : )

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/ESP32/issues/18#issuecomment-440515560, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qiAIXrT0pLtrG78dOuZPhUQaRMLEks5uxMfUgaJpZM4Yp7UO .

tomgraph79 commented 5 years ago

you mean the data sheet for mpu9250?

kriswiner commented 5 years ago

I thought you were using the LSM9DS1, but look in the MPU9250 data sheet for the orienation of sensor axes. The sensor order you are using cannot be correct.

On Tue, Nov 20, 2018 at 7:32 PM tomgraph79 notifications@github.com wrote:

you mean the data sheet for mpu9250?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/ESP32/issues/18#issuecomment-440517813, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qkN24DVRqv0pe3lnUTHnkRDVqui0ks5uxMlqgaJpZM4Yp7UO .

tomgraph79 commented 5 years ago

no, i'm using MPU9250. Thanks! : ) i will check the data sheet tomorrow. no i need to go to sleep ; ) it's 4:37