Sei sulla pagina 1di 3

25/11/2019 LSM9DS0 + Teensy + Madgwick Filter Redux: Inverted Mag Z and slow response?

User Name Password Log in Help Register


Remember Me?

What's New? Forum

New Posts FAQ Calendar Community Forum Actions Quick Links Advanced Search

Forum Main Category Technical Support & Questions


LSM9DS0 + Teensy + Madgwick Filter Redux: Inverted Mag Z and slow response?

Forum Rule: Always post complete source code & details to reproduce any
issue!

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages, select the forum that
you want to visit from the selection below.

Results 1 to 1 of 1

Thread: LSM9DS0 + Teensy + Madgwick Filter Redux: Inverted Mag Z and slow
response?

Thread Tools Search Thread Display

08-18-2016, 08:53 PM #1

Fletcher
LSM9DS0 + Teensy + Madgwick Filter Redux:
Junior Member Inverted Mag Z and slow response?
Join Date: May 2016
Posts: 4 I am working on interfacing a pair of LSM9DS0 IMUs with
some Teensy code to reconstruct the orientation of two
connected rigid bodies (a user's forearm and palm, in this
case). The previous thread here, "Quaternian[sic] is
changing very slowly" was invaluable in getting my setup
running.

My problem: the quaternions update very slowly, no


matter how high I set the beta parameter in Madgwick's
algorihm. Also, I get acceptable results only if I invert the
magnetometer's Z value before passing it into Madgwick.
I've never seen this mentioned anywhere else online in the
context of LSM9DS0 + Madgwick, so I'm very confused
and wondering what I may have done wrong!

My setup: two LSM9DS0s on Adafruit breakout boards


daisy-chained via SPI. My code uses the Sparkfun
LSM9DS0 driver in SPI mode along with a slightly modified
version of Nicholas Robinson's LSM9DS0 AHRS. My
modified version incorporates onehorse's uint32_t fix, and
allows the developer to pass in a SFE_LSM9DS0 object to
the constructor, since I need to run two instances at once
(one per IMU). I am polling at a regular interval (~10ms)
rather than using interrupt-driven processing, to reduce
the number of wires between the devices. This may be a
mistake and I'm willing to reconsider if it ends up being
part of my problem.

I started out using onehorse's Madgwick-for-teensy


implementation, but realized that my environment had a
high level of soft iron distortion (metallic objects all
around) so ended up shifting my Madgwick to the PC so
that I could do all the soft iron correction ellipsoid fitting

https://forum.pjrc.com/threads/36177-LSM9DS0-Teensy-Madgwick-Filter-Redux-Inverted-Mag-Z-and-slow-response?highlight=yaw+problem 1/3
25/11/2019 LSM9DS0 + Teensy + Madgwick Filter Redux: Inverted Mag Z and slow response?

work there, before integrating with Madgwick. I'm using x-


io's C# Madgwick implementation. Again, if there's a
compelling reason to eg: do the Madgwick on the Teensy
and send the center offset and calibration matrix to the
Teensy at startup, I'm open to that, but I don't think it's
my problem? Regardless, I'm using usb serial to ship all
values (accelerometer, gyro and mag xyz) to the PC using
a binary protocol, sending everything as 32-bit floats.

Even ignoring mag calibration artifacts (and testing in the


middle of a large room with ferrous objects pushed to the
walls), I was seeing some really weird things!

Whenever I pitched or rolled the IMUs across the vertical


(ie: from positive to negative pitch, or vice-versa), the
reported yaw of the quaternion generated by Madgwick
would flip by 180! I looked at the LSM9DS0 datasheet (pg
11 / Sec. 1.2) and realized that the magnetometer Z is
flipped relative to the accelerometer output. I tried
inverting the Z axis before passing it into Madgwick and
this weird flip-flopping behavior was corrected! Okay,
awesome, but why has nobody else in the history of the
Internet had this problem? And what other weirdness is it
hiding?

I'm sampling at ~100Hz (teensy is reporting ~0.0102 sec


between samples right now), and I have tried adjusting
my Madgwick gyro measurement error everywhere from
180 deg/s to 0.1 deg/s (beta = sqrt(4f/3f) * PI * (error /
180f); ) -- low beta results in VERY slow quaternion
update; high beta somewhat faster but eventually noisy.

Any idea what I should be looking for here? And how might
my inverted Z be related to everything else?

I can post video of my system, and selected source code;


will just take a minute to capture/process/upload..

Last edited by Fletcher; 08-18-2016 at 10:33 PM. Reason: Added references to


SFE LSM9DS0 and Nicholas Robinson's AHRS code.
Reply With Quote

Quick Navigation Technical Support & Questions Top

« Previous Thread | Next Thread »

Posting Permissions
You may not post new BB code is On
threads Smilies are On
You may not post replies [IMG] code is On
You may not post [VIDEO] code is
attachments On
You may not edit your HTML code is Off
posts
Forum Rules

https://forum.pjrc.com/threads/36177-LSM9DS0-Teensy-Madgwick-Filter-Redux-Inverted-Mag-Z-and-slow-response?highlight=yaw+problem 2/3
25/11/2019 LSM9DS0 + Teensy + Madgwick Filter Redux: Inverted Mag Z and slow response?

-- Default Style PJRC Electronic Projects Archive Top

All times are GMT. The time now is 06:26 AM.

Powered by vBulletin® Version 4.2.2


Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.

https://forum.pjrc.com/threads/36177-LSM9DS0-Teensy-Madgwick-Filter-Redux-Inverted-Mag-Z-and-slow-response?highlight=yaw+problem 3/3

Potrebbero piacerti anche