-
Notifications
You must be signed in to change notification settings - Fork 469
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
Magnetometer and Madgwick or Mahony does not work in case of tilting #180
Comments
"float heading = atan2(my, mx);", funny!
Why aren't you using the sensor fusion to get heading?
And did you calibrate your sensors to remove offset bias?
…On Tue, Aug 29, 2017 at 10:01 PM, mindchanger82 ***@***.***> wrote:
Dear Chris.
First of all thanks a lot for your great work for all in this esp and 9250
things. Great Job.
I'm facing a probem right now. I successfully get the imu to run with your
example codes but it seems, that the filter functions have no influence to
the mag data when i turn the device over some axes.
EG I mountet the imu to a robotic lawn mower. Everytime the mower moves
over a small hill it moves to somewhere but not to the should direction.
I tested it on a breakout board inside with another imu and esp32 device
with the same result.
Here is my function to print out the heading degrees.
I placed it in the loop, directly under the serial prints of mx,my,mz
`
float heading = atan2(my, mx);
float headingDegrees=0;
float declinationAngle = 30.45/1000;
heading += declinationAngle;
if(heading < 0)
heading += 2*PI;
if(heading > 2*PI)
heading -= 2*PI;
// Convert radians to degrees for readability.
//float headingDegrees = 360-(heading * 180/M_PI);
headingDegrees = heading * 180/M_PI;
headingDegrees = 360.00 - headingDegrees;
Serial.print("Heading = "); Serial.print( (int)headingDegrees ); Serial.println(" Degrees!");`
So everytime i softly move the device (yaw or pitch) the mag data changes
a lot to unsensful values.
Have you got any idea? Is my code wrong for this case?
PS: I used your latest "MPU9250_MS5637_AHRS_t3.ino" and removed all the
display stuff.
Thanks in advance and with best regards
Marius
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#180>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGY1qsTdzx9ugFPTv7JusWDFKHDWRUjZks5sdOyNgaJpZM4PG3oJ>
.
|
Hi Chris. Thanks for your reply. That is exactly my problem. Either I don't know how to use the sensor fusion, that's my goal to achive, nor I don't exactly know how to calibrate the sensors. I just used your mag calibration with figure 8 waving. |
@mindchanger82 the idea is to feed accelerometer, magnetometer and gyroscope measurements into the madgwickQuaternionUpdate, which, when run, fills out the q[0]...q[3] array (quaternion), which you then can convert into 3 angles - heading (yaw), tilt around 1 axis (pitch), tilt around another axis (roll) using simple formulas https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles |
Dear TediumRemedy. but from where do I know which arry pos (q[0] or q[xyz] stands for q.w or q.z ? |
@mindchanger82 you can use pieces of code from: https://github.com/kriswiner/MPU9250/blob/master/MPU9250_MS5637_AHRS_t3.ino
and you get yaw/pitch/roll in degrees (can be negative). The original code uses another conversion, apparently to save Arduino time on mathematical operations:
|
woaaaaah. Thank you so much. I used, as you said, the following lines: |
That's a good question. |
The other formulation is to calculate members of the rotation matrix from
which gravity and linear acceleration are easily estimated.
…On Wed, Aug 30, 2017 at 9:08 AM, mindchanger82 ***@***.***> wrote:
woaaaaah. Thank you so much.
I used, as you said, the following lines:
yaw = atan2f(2.0f * (q[1] * q[2] + q[0] * q[3]), q[0] * q[0] + q[1] * q[1]
- q[2] * q[2] - q[3] * q[3]); yaw *= 180.0f / PI; yaw += 1.44f; //
Declination at Düsseldorf Germany if(yaw < 0) yaw += 360.0f; // Ensure yaw
stays between 0 and 360
The data is now very stable, but false :-) haha, real south is 279 degrees
with the code... mhhhhhh where is the error.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#180 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGY1qp8cIZQWR3UblP6lHi2xVg7qk2tSks5sdYkRgaJpZM4PG3oJ>
.
|
The Madgwick filter is NED, so choose which accel axis you want for North,
and then, make sure you feed in sensor data into the Madwick filter
accordingly. I usually choose accel x as North and also negate the accel
data, this gives me a true North reading along the accel x-axis modulo the
declination.
My colleague says Madgwick is ENU, so maybe this is why negating the accel
data works better.
But the point is, it needs to be consistent.
…On Wed, Aug 30, 2017 at 9:21 AM, Kris Winer ***@***.***> wrote:
The other formulation is to calculate members of the rotation matrix from
which gravity and linear acceleration are easily estimated.
On Wed, Aug 30, 2017 at 9:08 AM, mindchanger82 ***@***.***>
wrote:
> woaaaaah. Thank you so much.
>
> I used, as you said, the following lines:
> yaw = atan2f(2.0f * (q[1] * q[2] + q[0] * q[3]), q[0] * q[0] + q[1] *
> q[1] - q[2] * q[2] - q[3] * q[3]); yaw *= 180.0f / PI; yaw += 1.44f; //
> Declination at Düsseldorf Germany if(yaw < 0) yaw += 360.0f; // Ensure yaw
> stays between 0 and 360
> The data is now very stable, but false :-) haha, real south is 279
> degrees with the code... mhhhhhh where is the error.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#180 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AGY1qp8cIZQWR3UblP6lHi2xVg7qk2tSks5sdYkRgaJpZM4PG3oJ>
> .
>
|
Thanks Kris |
Thanks Kris and TediumRemedy. |
@mindchanger82 glad you got your setup working! I am also faced with "yaw" problems. Could you please have a look at [https://github.com//issues/182](my issue) and confirm you don't have this problem in your setup. In brief, the problem is that the yaw angle "misses" a couple of degrees when rotating the setup, e.g., I rotate the MPU by 90° and the yaw changes by 80°... Thanks alot! |
Dear henzim. |
Thanks! |
Hi Henzim. Sorry for my late replay. Best regards |
Hey, no problem, thanks a lot for testing!It really seems to depend a lot on the CPU performance.Although I am still not quite convinced... I did try sending the values to the PC and doing the integration there but the results were still far from perfect.Now I'll try my luck with this powerful beauty: https://www.tindie.com/products/onehorse/nrf52832-development-board/
…-------- Ursprüngliche Nachricht --------
Von: mindchanger82 <notifications@github.com>
Datum: 17.10.17 06:26 (GMT+01:00)
An: kriswiner/MPU9250 <MPU9250@noreply.github.com>
Cc: henzim <henrik@zimcs.de>, Comment <comment@noreply.github.com>
Betreff: Re: [kriswiner/MPU9250] Magnetometer and Madgwick or Mahony does not
work in case of tilting (#180)
Hi Henzim. Sorry for my late replay.
I tested it the last weekend and and I don't get these kind of errors. But keep in mind that I use a esp32 and it seems to be a "bit faster" than the arduino mini pro.
Best regards
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/kriswiner/MPU9250","title":"kriswiner/MPU9250","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/kriswiner/MPU9250"}},"updates":{"snippets":[{"icon":"PERSON","message":"@mindchanger82 in #180: Hi Henzim. Sorry for my late replay.\r\nI tested it the last weekend and and I don't get these kind of errors. But keep in mind that I use a esp32 and it seems to be a \"bit faster\" than the arduino mini pro.\r\n\r\nBest regards"}],"action":{"name":"View Issue","url":"#180 (comment)"}}}
|
What MCU are you using?
…On Tue, Nov 1, 2022 at 6:30 AM Kaijudo2 ***@***.***> wrote:
I am having issue with 'TwoWire i2c'. Program says "no matching function
for call to 'TwoWire::TwoWire()'". Would really appreciate if anyone could
help me!
—
Reply to this email directly, view it on GitHub
<#180 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABTDLKVJDGECTRPOMO7YHH3WGELP7ANCNFSM4DY3PIEQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I am using adafruit esp32 feather
|
… On Tue, Nov 1, 2022 at 9:37 AM Kaijudo2 ***@***.***> wrote:
I am using adafruit esp32 feather
What MCU are you using?
… <#m_-2263717153512973863_>
On Tue, Nov 1, 2022 at 6:30 AM Kaijudo2 *@*.*> wrote: I am having issue
with 'TwoWire i2c'. Program says "no matching function for call to
'TwoWire::TwoWire()'". Would really appreciate if anyone could help me! —
Reply to this email directly, view it on GitHub <#180 (comment)
<#180 (comment)>>,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ABTDLKVJDGECTRPOMO7YHH3WGELP7ANCNFSM4DY3PIEQ
<https://github.com/notifications/unsubscribe-auth/ABTDLKVJDGECTRPOMO7YHH3WGELP7ANCNFSM4DY3PIEQ>
. You are receiving this because you were mentioned.Message ID: @.*>
—
Reply to this email directly, view it on GitHub
<#180 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABTDLKTUKIB7AN7UYPTDGA3WGFBOHANCNFSM4DY3PIEQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Dear Chris.
First of all thanks a lot for your great work for all in this esp and 9250 things. Great Job.
I'm facing a probem right now. I successfully get the imu to run with your example codes but it seems, that the filter functions have no influence to the mag data when i turn the device over some axes.
EG I mountet the imu to a robotic lawn mower. Everytime the mower moves over a small hill it moves to somewhere but not to the should direction.
I tested it on a breakout board inside with another imu and esp32 device with the same result.
Here is my function to print out the heading degrees.
I placed it in the loop, directly under the serial prints of mx,my,mz
`
float heading = atan2(my, mx);
float headingDegrees=0;
float declinationAngle = 30.45/1000;
heading += declinationAngle;
So everytime i softly move the device (yaw or pitch) the mag data changes a lot to unsensful values.
Have you got any idea? Is my code wrong for this case?
PS: I used your latest "MPU9250_MS5637_AHRS_t3.ino" and removed all the display stuff.
Thanks in advance and with best regards
Marius
The text was updated successfully, but these errors were encountered: