kriswiner / ICM42688

Collection of Arduino sketches for TDK's combo accel/gyro motion sensor
MIT License
32 stars 4 forks source link

Data fusion lag #9

Open shurik179 opened 9 months ago

shurik179 commented 9 months ago

This is not so much a bug report as a question. I am using (slightly modified) version of this repository for my robot (https://github.com/shurik179/yozh) and I have a strange issue: the there seems to be a lag in updating yaw.

I.e. I have code "rotate right until yaw of (current +90 deg) is reached". The robot rotates, stops, and if I read the yaw immediately, it is about 90 deg. If I read the yaw one second later, it is 94 deg - even though during this second the robot was not moving. And real-life value is indeed about 94 deg - so the robot overshot the turn.

Strangest of all, this only applies for rotating right (clockwise); when rotating CCW, this issue doesn't arise.

Do you have any ideas what could be causing that? The data fusion code I use is the same 6 DoF Madgwick as in your repo, except that I do not run multiple iterations with each reading (I am running it on SAMD21G18 chip, with cpu frequency of 48 mhz, so it can only run data fusion at about 200 hz frequency - while I set the output data rate for both accel and gyro at 500 hz). Just in case, the code is here: https://github.com/shurik179/yozh/blob/main/firmware/yozh-firmware/IMU.cpp

BTW, the yaw drift when the robot stands still is very low, I am quite happy with that.

kriswiner commented 9 months ago

I have no idea. Generally, the fusion filter runs at the rate of the gyro. You might try dropping the accel/gyro rates to 200 Hz. But I would also say that a 4 degree heading error with just 6 DoF is pretty good; unlikely to do better.

On Fri, Nov 17, 2023 at 7:00 AM shurik179 @.***> wrote:

This is not so much a bug report as a question. I am using (slightly modified) version of this repository for my robot ( https://github.com/shurik179/yozh) and I have a strange issue: the there seems to be a lag in updating yaw.

I.e. I have code "rotate right until yaw of (current +90 deg) is reached". The robot rotates, stops, and if I read the yaw immediately, it is about 90 deg. If I read the yaw one second later, it is 94 deg - even though during this second the robot was not moving. And real-life value is indeed about 94 deg - so the robot overshot the turn.

Strangest of all, this only applies for rotating right (clockwise); when rotating CCW, this issue doesn't arise.

Do you have any ideas what could be causing that? The data fusion code I use is the same 6 DoF Madgwick as in your repo, except that I do not run multiple iterations with each reading (I am running it on SAMD21G18 chip, with cpu frequency of 48 mhz, so it can only run data fusion at about 200 hz frequency - while I set the output data rate for both accel and gyro at 500 hz). Just in case, the code is here: https://github.com/shurik179/yozh/blob/main/firmware/yozh-firmware/IMU.cpp

BTW, the yaw drift when the robot stands still is very low, I am quite happy with that.

— Reply to this email directly, view it on GitHub https://github.com/kriswiner/ICM42688/issues/9, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKQGGN5CTHAOK25NCJDYE53YDAVCNFSM6AAAAAA7P5OYKCVHI2DSMVQWIX3LMV43ASLTON2WKOZRHE4TSMZSGEZTOMY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

shurik179 commented 9 months ago

Thanks, will try lowering the ODR. What really puzzled me was the asymmetry: why it only shows for CW rotation...

BTW, thanks a lot for your work! it was certainly very helpful.

kriswiner commented 9 months ago

Probably because the gyro drift is asymmetric, and the yaw "error" depends on this....

On Fri, Nov 17, 2023 at 9:19 AM shurik179 @.***> wrote:

Thanks, will try lowering the ODR. What really puzzled me was the asymmetry: why it only shows for CW rotation...

BTW, thanks a lot for your work! it was certainly very helpful.

— Reply to this email directly, view it on GitHub https://github.com/kriswiner/ICM42688/issues/9#issuecomment-1816804874, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKXWXF3JZJ6GSJWCCNLYE6MC7AVCNFSM6AAAAAA7P5OYKCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJWHAYDIOBXGQ . You are receiving this because you commented.Message ID: @.***>