bolderflight / invensense-imu

Arduino and CMake library for communicating with the InvenSense MPU-6500, MPU-9250 and MPU-9255 nine-axis IMUs.
MIT License
497 stars 210 forks source link

Why inverted axis for gyro and accelerometer #111

Closed tcerqueira closed 2 years ago

tcerqueira commented 2 years ago

Months using this library with some problems along the way and I just realized for each gyro axis the accelerometer axis is inverted. I have been assuming the same frame of reference for both and it explains a lot of my problems. Is this intended behaviour or am I missing something?

flybrianfly commented 2 years ago

The accel, gyro, and mag all use the coordinate frame depicted. If I accelerate the gyro in the positive X direction, I get a positive acceleration. Positive gyro is likewise a right-hand rotation around the axis. I'm not seeing why you think the accel and gyro are inverted.

tcerqueira commented 2 years ago

For example, with my breakout board laying flat the acceleration along the z-axis is -9 meaning the z-axis is pointing up. I'd expect a negative rotation if I rotate clockwise, which is not the case. The same happens for other axis. So only the gyro frame matches the documentation.

Im using this board if it matters. https://electropeak.com/learn/interfacing-gy-91-9-axis-mpu9250-bmp280-module-with-arduino/

flybrianfly commented 2 years ago

I think there's a misunderstanding; an accelerometer at rest will measure 9.80665 m/s/s of upwards acceleration. There is a Wikipedia article that gives a decent explanation. You can try accelerating the IMU by hand in different directions (i.e. accelerating forward along the X axis) and I think you can see that the accelerometer and gyro axis are in agreement and match the documentation.

tcerqueira commented 2 years ago

Oh I thought the accelerometer data was an acceleration vector so I was expecting a positive value for gravity since the z-axis is down. Wrong assumption I guess, thanks for clarifying.

flybrianfly commented 2 years ago

It is an acceleration vector, except for gravity.