## Reference Frame of Acceleration Data

acxz
Beginner
Posts: 1
Joined: Wed Feb 19, 2020 5:01 am

### Reference Frame of Acceleration Data

Hello!

I am having trouble understanding the acceleration observations on the Crazyflie Nano platform, specifically regarding the accelerations. (`stateEstimate.ax/ay/az`)
When keeping the drone on the ground and reading `stateEstimate.ax/ay/az`, all of the values are near zero. `stateEstimate.az` is around 0.04. However, my understanding of accelerometer data is that it should be -9.8 when sitting flat on the ground. Is the `stateEstimate.ax/ay/az` in the world frame instead of the body frame? What is the logic/math behind the `stateEstimate.ax/ay/az` values?

I tried to search the forums for previous topics on this, but the best I could find was the following comment by @nicuvlad94, which was not answered due to being off topic. viewtopic.php?f=2&t=4125&p=18896#p18896

If someone can explain this, it would be much appreciated.
Thank you
kimberly
Bitcraze
Posts: 686
Joined: Fri Jul 06, 2018 11:13 am

### Re: Reference Frame of Acceleration Data

Hi,

So we usually advice to look into the firmware to understand where this values are coming from. So let me give you some pointers right here:

The accelerometer values is estimated with a stateEstimator, which is either the Complementary or the Kalman filter. `stateEstimate.ax/ay/az` is in world coordinates, but originaly it comes out of the state estimator in body coordinates due to that accelerometers give out those values directly. Before the state estimator (for example: estimator_kalman.c) sends it values to the stablizer (.c), it transforms the body coordinates into world coordinates (https://github.com/bitcraze/crazyflie-f ... man.c#L404). So if you look into the kalmanCoreExternalizeState() function, you can also see comments of why the gravity vector was taken out of the acceleration. But if you make a logging variable of the estimated acceleration in the kalman filter file, this will be in body coordinates with gravity if I understood correctly.