# EKF2 module gyro sensor units

**URL:** <https://discuss.px4.io/t/ekf2-module-gyro-sensor-units/18819>\
**Category:** Uncategorized\
**Created:** [September 30, 2020, 6:27am UTC](https://discuss.px4.io/t/ekf2-module-gyro-sensor-units/18819 "2020-09-30T06:27:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Safranek42](https://discuss.px4.io/user_avatar/discuss.px4.io/safranek42/32/6181_2.png) [@Safranek42](https://discuss.px4.io/u/Safranek42)\
**Post date:** [September 30, 2020, 6:27am UTC](https://discuss.px4.io/t/ekf2-module-gyro-sensor-units/18819/1 "2020-09-30T06:27:26Z")

</div>

Hi,

I am trying to understand how the ekf module works in PX4, and I ran into a confusing part.  
In src/modules/ekf2/EKF2.cpp I tried to follow how the angular rate is published, and the unit of the variables seem to be controversial.

First [here](https://github.com/PX4/Firmware/blob/master/src/modules/ekf2/EKF2.cpp#L287) we define `imu_sample_new.delta_ang` as `[rad/s]`, but if the if statement goes [here](https://github.com/PX4/Firmware/blob/master/src/modules/ekf2/EKF2.cpp#L308) it is integrating the gyro output over time and it will be set as `[rad]`.

Furthermore, [here](https://github.com/PX4/Firmware/blob/master/src/modules/ekf2/EKF2.cpp#L1254) we should get `[rad/s]` for rollspeed, therefore the `imu.delta_ang` variable’s unit should be `[rad/s/s]`.

(I have taken all unit definitions from corresponding `.msg` files.)

I’m sure I am missing something trivial but can someone point out where I made the mistake?

Thanks in advance for any help.

---

<div class="post-metadata">

**Author:** ![CarlOlsson](https://discuss.px4.io/user_avatar/discuss.px4.io/carlolsson/32/4175_2.png) [@CarlOlsson](https://discuss.px4.io/u/CarlOlsson)\
**Post date:** [September 30, 2020, 8:49am UTC](https://discuss.px4.io/t/ekf2-module-gyro-sensor-units/18819/2 "2020-09-30T08:49:33Z")

</div>

Hi,

I think your confusion stems from

> <https://github.com/PX4/Firmware/blob/master/msg/vehicle_imu.msg#L9>

  
I agree it is a bit confusing in the comment but the unit is [rad] not [rad/s]

---

<div class="post-metadata">

**Author:** ![Safranek42](https://discuss.px4.io/user_avatar/discuss.px4.io/safranek42/32/6181_2.png) [@Safranek42](https://discuss.px4.io/u/Safranek42)\
**Post date:** [September 30, 2020, 9:33am UTC](https://discuss.px4.io/t/ekf2-module-gyro-sensor-units/18819/3 "2020-09-30T09:33:44Z")

</div>

Thanks for clarifying that, yes it is quite confusing as the comment explicitly says [rad/s].

On the other hand, this does not explain [this](https://github.com/PX4/Firmware/blob/master/src/modules/ekf2/EKF2.cpp#L1254) part, as it seems to produce [rad\*s] for rates that should be [rad/s]. Here `imu` is an [imuSample](https://github.com/PX4/ecl/blob/4c2355a63821836bf8801e996d4651dcabe0287f/EKF/common.h#L92) type variable, and the used fields are in [rad] and [s] respectively, according to the description.

---

<div class="post-metadata">

**Author:** ![CarlOlsson](https://discuss.px4.io/user_avatar/discuss.px4.io/carlolsson/32/4175_2.png) [@CarlOlsson](https://discuss.px4.io/u/CarlOlsson)\
**Post date:** [September 30, 2020, 1:06pm UTC](https://discuss.px4.io/t/ekf2-module-gyro-sensor-units/18819/4 "2020-09-30T13:06:24Z")

</div>

hm that looks like a bug to me

> <https://github.com/PX4/Firmware/pull/15856>

---

<div class="post-metadata">

**Author:** ![Safranek42](https://discuss.px4.io/user_avatar/discuss.px4.io/safranek42/32/6181_2.png) [@Safranek42](https://discuss.px4.io/u/Safranek42)\
**Post date:** [October 1, 2020, 9:43am UTC](https://discuss.px4.io/t/ekf2-module-gyro-sensor-units/18819/5 "2020-10-01T09:43:56Z")

</div>

Nice to see it is fixed already, thanks for reporting it.
