MATLAB Answers

why the yaw angle from the IMU+AHRS block have cnstant error with the true yaw angle?

5 views (last 30 days)
Hao Chen
Hao Chen on 27 Dec 2020
Edited: Brian Fanous on 5 Jan 2021
Hello Matlab Community,
I am just wondering if anyone has had any experience of using IMU+AHRS block from sensor fusion and tracking toolbox?Right now I have a quadcopter model and I'm trying to integrate this IMU+AHRS block to get the orientation and angular velocity which will be used in my estimator.
I think I got this IMU+AHRS block work, and the roll and pitch angles from this block match the true roll and pitch angles although there are some reasonable errors.However, the yaw angle from AHRS block always have constant error(around 0.1 rad which is 5.7 degree) with true yaw angle. All the parameters for IMU and AHRS block are default. I posted the simulation result of my simulink model and In this picture, you can see a clear mismatch in yaw angle. Is this a reasonable error or not? Thank you
Hao Chen
Hao Chen on 28 Dec 2020
Thank you for your reply but I didn't get what you mean. Actually the orientation estimation from the AHRS is quaternion.Then I use the command quat2eul to convert it to euler angle(roll,pitch,yaw) and then plot it.
For the quaternion, the estimated values from AHRS, q0,q1,q2, is similar to true q1,q2,q3. However, the estimated q3 from AHRS always have some error with true q3.
This is q0, the blue one is true q0,and the yellow one is AHRS estimated q0.
This is q1, the blue one is true q1,and the yellow one is AHRS estimated q1.
This is q2, the blue one is true q2,and the yellow one is AHRS estimated q2.
This is q3, the blue one is true q3,and the yellow one is AHRS estimated q3.As we can see, the q3 are mismatched. is this a reasobable error because of the mechanism of magninometer?

Sign in to comment.

Accepted Answer

Brian Fanous
Brian Fanous on 4 Jan 2021
Edited: Brian Fanous on 5 Jan 2021
It's tough to say what is going on without more information. Is this recorded or synthetic data and where/how was this recording made?
What might be happening is that you are seeing the difference between True North and Magnetic North. The difference between these two locations will show up as a constant offset in the yaw and is known as the magnetic declination. The AHRS Filter navigates to Magnetic North (because it assumes no GPS and no declination lookup table; it is intentionally somewhat simple). If your ground truth orientation is directed to True North you will see the difference in the declination.
  1 Comment
Hao Chen
Hao Chen on 4 Jan 2021
Hello. Thank you for your reply.
I have build a quadcopter simulink model which can generate the true states of quadcopter.Meanwhile,the trues states and true derivates of states will be as inputs to the block which contains IMU+ AHRS. Therefore, I can say this is a synthetic data which is generated from my quadcopter model.
I think you are right since this constant offset of yaw angle is around 0.08~0.1rad(4.5~5.7deg).In my quadcopter model, the origion of the inertial frame is set [0,0,0], so I believe my ground truth orientation is directed to True North.
Do you have any recommendation to cancael this offset? is it just simplily to let my estimated yaw angle minus the difference to let it close to true yaw angle?

Sign in to comment.

More Answers (1)

Brian Fanous
Brian Fanous on 4 Jan 2021
There are tools in Aerospace Toolbox and Aerospace Blockset to calculate the magnetic declination at any location. You can use these tools to compensate for the declination difference in the AHRS. Typically we suggest doing any rotational math on the quaternion or rotation matrix representation, not the Euler angles (yaw).

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!