Hello,
I am trying to implement an autopilot in the Crazyflie. I have been making some changes to the firmware to implement a new control law. For that I need to know the orientation in pitch, roll and yaw.
I already added gyro drift subtraction for pitch and roll, and the readings seems to be right. I tested it with the 2 Crazyflies I have.
For yaw, it has been a lot of fun, and by that I mean lot of troubles, . First, the gyro drift subtraction does not work on yaw. I am using the magnetometer based on the information on this post:
http://forum.bitcraze.se/viewtopic.php? ... ilit=10dof
I tried that and then changed to something similar using tilt compensation, but it is the same. The yaw position is always locked. I was wondering why this happens. I already surfed the web a million times, . The magnetometer datasheet says it can be used to have a 360 heading reading and there are numerous projects using it with tilt compensation to have the same effect. Does the magnetic field produced by the motors is so strong it locks the value?
Thanks.
--Luis
Yaw from magnetometer locked in one position.
Re: Yaw from magnetometer locked in one position.
Great project and a big challenge. It might be that the magnetometer has saturated and needs to be set in a different sensitivity. Have you tried logging the raw magnetometer values?
One difficult thing with the magnetometer is to calibrate it from all the soft and hard iron effects caused by the surrounding magnetic fields. Before doing that the magnetometer readings are way off.
One difficult thing with the magnetometer is to calibrate it from all the soft and hard iron effects caused by the surrounding magnetic fields. Before doing that the magnetometer readings are way off.
Re: Yaw from magnetometer locked in one position.
It is working! The yaw reading is spanning 360 degrees and it does not drift. I had to get lots of data to do the calibration and I removed data out of range.
X axis: Data point
Y axis: Angle
X axis: Data point
Y axis: Angle
Re: Yaw from magnetometer locked in one position.
Great achievement! Do you have your code on bitbucket?
Re: Yaw from magnetometer locked in one position.
Hello,
I do not have an account on bitbucket yet, : P. I was doing more testings and it seems the calibration does not work if the CF is tilted too much. More over, I think only the hard iron calibration is needed, the one that adjust the offset of the readings. Below is a graph of the raw data:
After hard iron calibration the norm is around 1, which means the sensor is OK. Now for both hard iron and soft iron:
The norm is also around 1. In both cases the output for the heading is almost the same, tested on the CF:
Now, the heading spans 360 degrees. To calculate the hard iron and soft iron matrices I used this information:
http://diydrones.com/forum/topics/compa ... n-magnetic
Now, back to the heading problem, has anyone been able to read the yaw angle effectively, whereas using the magnetometer or other methods?
I do not have an account on bitbucket yet, : P. I was doing more testings and it seems the calibration does not work if the CF is tilted too much. More over, I think only the hard iron calibration is needed, the one that adjust the offset of the readings. Below is a graph of the raw data:
After hard iron calibration the norm is around 1, which means the sensor is OK. Now for both hard iron and soft iron:
The norm is also around 1. In both cases the output for the heading is almost the same, tested on the CF:
Now, the heading spans 360 degrees. To calculate the hard iron and soft iron matrices I used this information:
http://diydrones.com/forum/topics/compa ... n-magnetic
Now, back to the heading problem, has anyone been able to read the yaw angle effectively, whereas using the magnetometer or other methods?
-
- Member
- Posts: 38
- Joined: Mon Sep 16, 2013 10:22 am
Re: Yaw from magnetometer locked in one position.
Oh really good job!!
But did you use the calibration method of ak1394 http://forum.bitcraze.se/viewtopic.php? ... ilit=10DOF or of Ozan Aktaş http://diydrones.com/forum/topics/compa ... n-magnetic.
I would understand what is the best and easiest method.
But did you use the calibration method of ak1394 http://forum.bitcraze.se/viewtopic.php? ... ilit=10DOF or of Ozan Aktaş http://diydrones.com/forum/topics/compa ... n-magnetic.
I would understand what is the best and easiest method.