juliangaal / mpu6050

MPU6050 embedded-hal driver written in Rust
https://crates.io/crates/mpu6050
MIT License
52 stars 31 forks source link

Raw gyro readings to rad/s conversion issue. #45

Closed HeikoRibberink closed 2 years ago

HeikoRibberink commented 2 years ago

As seen in line 367 in lib.rs in function get_gyro(): gyro *= PI_180 * self.gyro_sensitivity; the raw values are multiplied by the gyro sensitivity, while they should be divided by it, like in the corrected version: gyro *= PI_180 / self.gyro_sensitivity;

I found this issue because I was reading -761 rad/s while the mpu6050 was laying still, which would be roughly 121 revolutions per second. That seemed a bit much for a measurement error to me.

TL;DR Please change line 367 in lib.rs to gyro *= PI_180 / self.gyro_sensitivity;.

HeikoRibberink commented 2 years ago

I'm sorry, I just saw that you already had a pull request for this.

HeikoRibberink commented 2 years ago

It would be nice, however, if you were to push the change to master and to crates.io, since they haven't yet been updated.