How mixer work

Ok guys,

Sorry in advance, but I really have struggle to understand how the mixing is handled by the pixhawk midleware.

I’ve read the dev guide on mixing, but I still don’t understand what is written there. I don’t see how a simple file like this where there is only definition can convert attitude value like roll pitch and yaw into pwm value to motors… Maybe I am just dumb :sweat:

There is mutliple cpp file that are related to mixing “fmu.cpp” “mixer.cpp” etc… and I don’t see the link between mixing file quad_x.main and high level cpp file.

Can someone explain me simply the work-flow from publishing value into actuator_control topic like roll, pitch yaw and throttle and at the end sending to ioctl() function the pwm value to motors.

Is there any matematical expression like:
output_pwm_actuator1=function_of(pitch,roll,yaw,throttle)
output_pwm_actuator2=function_of(pitch,roll,yaw,throttle)
output_pwm_actuator3=function_of(pitch,roll,yaw,throttle)
output_pwm_actuator4=function_of(pitch,roll,yaw,throttle)

it should be trigonometric relation right ?

Thank in advance,

How I understand it .

     Throttle       Pitch       Roll        Yaw    
M1     100%          100%        100%        100%
M2     100%          100%      - 100%      - 100%
M3     100%        - 100%      - 100%        100%
M4     100%        - 100%        100%      - 100%

So with that we make the mixing file:
R: 4x 10000 10000 10000 0
M: 1
O: 10000 10000 0 -10000 10000
S: 3 5 10000 10000 0 -10000 10000
M: 1
O: 10000 10000 0 -10000 10000
S: 3 6 10000 10000 0 -10000 10000

Right ?
But after ? How is it handle by the middleware

You’re missing the autopilot. For quadcopters, it is handled by this and
[this] (https://github.com/PX4/Firmware/tree/master/src/modules/mc_pos_control) depending on which flight mode you use.

In the most basic case of manual RC control, the stick input is processed in mc_att_control and output to _actuators_0_pub topic. This is then used by the mixer to output PWM value.

I’m using pixhawk for fixed wing application, and not too familiar with MC, but I believe the main idea should be right. For the details, please look inside the linked files.

[This] (http://uav-lab.org/2016/08/15/px4-research-log-7-a-closer-look-at-mc_att_control/) might also be useful

Hi @Darkus3,
The control allocation matrices (“mixer tables”) are generated by the python script px_generate_mixers.py given the geometries of the vehicles.
After this, the matrix is used here 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 where the algorithm as been prototyped in Python. This Python script is also used here to verify the C++ implementation.

EDIT: updated comment for v1.9 release

5 Likes

hi
thx for your description
would you please update your explanation links they are dead

Hi @ghasem20 ,

I updated the links and the description since the multicopter mixer had a complete rewrite between v1.8 and v1.9.

Description of the new algorithm here.

1 Like

hi again
thx for your description
I still have some questions about the topic that i will ask when i take the background