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
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)
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.
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.
The roll pitch and yaw value in your formula are roll pitch and yaw torques right ? These values are between -1 and 1 but what is the maximum torque corresponding to 1 ? I have the same question for collective_trhust variable. Then the output is thrust that is the thrust of one motor and that is also a value between 0 and 1. But how it his value then transformed into a motor command like a PWM ?
@Daniel_Blanquez Everything is normalized, so 1 = maximum positive torque , -1 = maximum negative torque. For a motor, 1 is full power (maximum pwm command, e.g.: 2ms) and 0 is minimum power/idle speed (minimum pwm command, e.g.: 1ms).
Hi, i’m still dont understand, how can we estimate value of PWM that has to generated to reach the normalized torque given the parameter of each copter can be different resulted to produce same value of thrust for different value of PWM.