原文链接:https://pixhawk.org/dev/mixing
This page discusses the general-purpose control mixing architecture in PX4. If you are looking for specific mixer setup instructions, you should go to the Platforms page.
The mixing architecture is capable to deal with relatively complex airframes, as shown in this video:
The following image explains the mixing for a wing only elevon configuration (roll and pitch inputs mixed together for 2 elevon servo actuators) The “output channels” (Pixhawk pins) are assigned to the mixer description file based upon the order they appear in the mix's file:
If you wanted to change only the second output, channel-1 (Pixhawk pin 2), you still need an entry for first output, channel-0 (Pixhawk pin 1)
EXAMPLE: Roll has no mix here, but is needed to have the pitch description be second in the file.
When using the multirotor mixer (R:), it takes the place of the first three output pins mixes. The first mix after an “R:” is pin4.
The output rates can be configured with this command line app: pwm (Application) or via IOCTLs (please refer to the source code of the app for examples on how to use the IOCTL interface).
The default output rate in the RC industry is 50 Hz, which normal analog servos sustain well. Digital servos can accept higher rates. The recommended output rate for multicopter ESCs is 400 Hz, in order to minimise latency (NOT because the outputs would require 400 Hz, as multicopter rotors spin only at 80-120 Hz and can't change speed multiple times during a single revolution, but to actually overcome the input filtering most motor controllers have and to minimize worst-case latency if the attitude control loop is not synchronized to the PWM generation).
The hardware generating the PWM signal is grouped into different timers, and each timer outputs on one or multiple pins. These pins can change their output rate only together. The three groups for IO (MAIN output on Pixhawk) are:
A module that combines a set of inputs according to pre-defined rules and parameters to produce a set of outputs.
An arithmetic module that adjusts a single input according to parameters to generate a single output.
Inputs are expected to be in the range -1.0 (-10000) to 1.0 (10000) for roll, pitch and yaw, and 0 - 1.0 (10000) for thrust and made available to the mixer by the module or component that owns the mixer. This may be a vehicle control such as 'roll', or any other number.
The result of applying the mixer rules to zero or more inputs.
A module invokes a mixer (or mixer group, see below) when it wants to generate a fresh set of outputs; for example, when it is notified that the inputs it has been watching have changed.
The mixer will obtain the inputs it requires, scale and mix them according to the mixer definition, and generate the output set. The module is then free to use the outputs as required; for example to update servo outputs, or to publish the results for other modules to use.
Mixer inputs are often scaled in order to adjust the relative significance of each input during the mixing phase. Several different scaling approaches are used, depending on circumstance.
The simplest form of scaling simply multiplies the input value by a constant scaling factor. This approach is used when the base value for an input is well-known, or the value is not otherwise required to be adjusted.
This scaling technique allows for asymmetrical scaling either side of input zero, as well as biasing the result and clamping the output.
Inputs to this scaler are:
The scaling workflow looks like this:
if (input < 0) output = (input * NEGATIVE_SCALE) + OFFSET else output = (input * POSITIVE_SCALE) + OFFSET if (output < LOWER_LIMIT) output = LOWER_LIMIT if (output > UPPER_LIMIT) output = UPPER_LIMIT
The rules that are applied vary from mixer to mixer, with the following mixers being defined:
As its name suggests, the simple mixer reads one or more inputs, scales them, sums the scaled values, scales the result and returns a single output.
input input input | | | v v v scale scale scale | | | | v | +-------> mix <------+ | scale | v output
Parameters to the simple mixer are:
Both the input and output scaling is performed using linear scalers.
This mixer is designed for mixing flight controls (roll, pitch, yaw, thrust) to produce motor speed control outputs suitable for multirotor air vehicles.
Parameters to the multirotor mixer (R:) are:
R: <geometry> <roll scale> <pitch scale> <yaw scale> <deadband>
A variety of vehicle geometries are known to the mixer, including common quad (4X,4+), hex (6X,6+) and octo (8X,8+) and tri (3y)configurations. The mixer can be extended to any configuration that can be expressed using separate roll, pitch and yaw compensation factors for each rotor. In all cases, simple scaling is applied to the inputs.
The output from the multirotor mixer is clamped such that at most one rotor output is saturated, in order to avoid issues rolling heavy vehicles, and the output value is never permitted to fall into the deadband in order to avoid issues with motor re-start whilst in flight.
In addition to that, any clamping respects the ratio of the input, to prevent multi rotors from flipping over. If a motor gets into positive or negative saturation, the overall thrust will be reduced so that the ratio between the individual motors can be satisfied without saturation.
Input (quadrotor, four motors), Limit is 100:
150 75 75 75
Resulting clamped output:
100 50 50 50
Note that motor 1 has still double the speed of motors 2-4, so the resulting attitude will be correct. The vehicle will however not increase altitude (or decrease altitude) compared to the non-clamped motor inputs. If the clamping would just limit motor 1, the vehicle may flip over or become unstable, because the ratio between the motors that defines the collective thrust plane is violated.
Control groups are grouped actuator control positions. These functional groups are centered around core flight control (group 0), auxiliary flight control (group 1), payload (group 2) and manual passthrough (group 3, e.g. for gimbal control).
Control groups 1, 2, and 3 are not sent to the actuators unless there is a change in control group 0. If, for example, aux0 was being used to control the pitch setting of a gimbal motor, the pitch would only change when the flight control motors associated with control group 0 were armed.
These groups are NOT mixer inputs, but serve as meta-channels to feed fixed wing and multicopter controller outputs into the VTOL governor module.