# How mixer work

**URL:** <https://discuss.px4.io/t/how-mixer-work/3886>\
**Category:** PX4 Autopilot\
**Created:** [July 13, 2017, 2:21pm UTC](https://discuss.px4.io/t/how-mixer-work/3886 "2017-07-13T14:21:38Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![bresch](https://discuss.px4.io/user_avatar/discuss.px4.io/bresch/32/2343_2.png) [@bresch](https://discuss.px4.io/u/bresch)\
**Post date:** [July 14, 2017, 8:12pm UTC](https://discuss.px4.io/t/how-mixer-work/3886/5 "2017-07-14T20:12:35Z")

</div>

Hi @Darkus3,  
The control allocation matrices (“mixer tables”) are generated by the python script [px\_generate\_mixers.py](https://github.com/PX4/Firmware/blob/master/src/lib/mixer/geometries/tools/px_generate_mixers.py) given the [geometries](https://github.com/PX4/Firmware/tree/master/src/lib/mixer/geometries) of the vehicles.  
After this, the matrix is used [here](https://github.com/PX4/Firmware/blob/903deb7579ec655ffea526eb5701b78f9f5c9ce8/src/lib/mixer/mixer_multirotor.cpp#L278-L281) to create the thrust output of each motor with the following expression:  
`thrust = roll*roll_scale + pitch*pitch_scale + yaw*yaw_scale + collective_thrust*thrust_scale`  
Where the output scale is used when you have a different prop/motor (tricopter for example).  
Then, in the same file are implemented some strategies (called _Airmode_) to avoid loss of control when some actuators reach saturation.  
For more details, check this [control allocation repository](https://github.com/Auterion/Flight_Control_Prototyping_Scripts/tree/master/control_allocation) where the algorithm as been prototyped in Python. This Python script is also used [here](https://github.com/PX4/Firmware/blob/master/src/lib/mixer/mixer_multirotor.py) to verify the C++ implementation.

EDIT: updated comment for v1.9 release

---

_[View the full topic](https://discuss.px4.io/t/how-mixer-work/3886)._
