Relation between stabilizer and acc

Firmware/software/electronics/mechanics
Post Reply
Kiva
Beginner
Posts: 13
Joined: Wed Dec 28, 2016 6:26 pm

Relation between stabilizer and acc

Post by Kiva »

Hi guys,

I try to understand how works sensors and stabilizer data and I have some questions:

When I power on my crazyflie, I get a stabilizater log with something like this:
  • roll: 0.002
    pitch: 0.01
    yaw: 0.03
I thought have 0, 0, 0 but no. When I send position like this:

Code: Select all

self._cf.commander.send_setpoint(0, 0, 0, 33000)
I thought my crazyflie will be stabilize but not, it drifts always.

So my first questions are:

How is calculated the stabilizater log in startup ?
Why the position (0, 0, 0) doesn't stabililze the drone ?

I have a question about the acc sensor. I read the documentation about it and my question is:

Is it exists a relation between the acc sensor and the calculation of the stabilizater log ?

Thanks for your answer ;)
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Relation between stabilizer and acc

Post by arnaud »

Hi,
Kiva wrote: How is calculated the stabilizater log in startup ?
In Crazyflie we assume the sensor are mounted flat on the board. At startup there is a measurement of the gyroscope values to calibrate and correct the gyroscope drift. Then the roll/pitch estimates are initialized using the accelerometer and a complementary filter uses both accelerometer and gyroscope to keep track of roll/pich. Considering that we are not zeroing the orientation but assuming the sensor are flat, your measurements are very good!
Kiva wrote: Why the position (0, 0, 0) doesn't stabililze the drone ?
In theory keeping the platform flat should not generate any side-ways acceleration and keep the platform stable in x/y. In reality though nothing is perfect, if one motor is slightly misaligned or the airflow is a bit disturbed you will get motion. To stay stable in space the Crazyflie will need other sensors that indicates how the platform is moving in relation with the room (like the LPS, camera, motion sensors, ....).
Kiva wrote: Is it exists a relation between the acc sensor and the calculation of the stabilizater log ?
Yes, unless you are running the Kalman filter, gyroscope and accelerometer are fused to estimate roll/pitch. The rational is that the accelerometer will show the gravity if integrated for a long period of time, this is used to calibrate the gyroscope.

Yaw is only measured using the gyroscope, since it is collinear with gravity, and so is subject to drift over time.
Kiva
Beginner
Posts: 13
Joined: Wed Dec 28, 2016 6:26 pm

Re: Relation between stabilizer and acc

Post by Kiva »

Thanks for your complete answer :)
Kiva
Beginner
Posts: 13
Joined: Wed Dec 28, 2016 6:26 pm

Re: Relation between stabilizer and acc

Post by Kiva »

I reply on my own post.

Do you know the formula which transforms gyro and accelerometer to roll/pitch/yaw ?

What is the unit of these data (roll/pitch/yaw) ?
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Relation between stabilizer and acc

Post by arnaud »

This is happening in the estimators, there is two estimators: the complementary estimator and the kalman filter. Generaly the gyro readings are accumulated to keep track of the current attitude. You can look in the code to see where it is happening
- for the kalman filter: https://github.com/bitcraze/crazyflie-f ... man.c#L504
- for the complementary filter: https://github.com/bitcraze/crazyflie-f ... on6.c#L101

The unit exposed to the outside (ie. log and state controller) is degrees for roll/pitch/yaw. My understanding is that in the Kalman filter the orientation is kept as a rotation matrix and in the complementary filter as a quaternion.
Post Reply