Hi Holger,
We had a bit of a discussion on the dev call yesterday about strategies
for PX4 mixing in the copter code, and in particular the need for mixing
to support UAVCAN ESCs.
I know you've been working on this for a while, so I've just had a look
through your px4mix branch:
https://github.com/hsteinhaus/ardupilot/commits/px4mix
and I thought it would be worth discussing the approach taken, and
comparing it to the approach I've just done for plane support for
creating mixers.
For the benefit of other people on the list, I thought I should first
describe the approach taken in your px4mix branch.
In your branch you create a new copter frame type 'px4mix', and a new
AP_Motors class to go along with it:
https://github.com/hsteinhaus/ardupilot/blob/f1d6a83630cd409253646d6710aa5e83b431b6e3/libraries/AP_Motors/AP_MotorsPX4.cpp
The code then loads a mixer file based on a frame type, using mixer
files from the PX4/ROMFS/mixers directory (such as FMU_quad_x.mix). The
AP_MotorsPX4 class also does the ORB publication of the output values
which provides the input to the mixer.
I can see how this approach works, but it had the disadvantage that it
bypasses the current stability/limits code used by ArduPilot for
existing users. That means we won't get exactly the same flight
behaviour when using UAVCAN ESCs as we would get when using PWM based
ESCs. I think it would be nice to be able to keep as much of the
stability code inside ArduPilot as possible (Randy, Jon and
Leonard may be able to provide some useful input as well).
Have you considered instead taking this approach:
- generate a mixer file in the AP_MotorsMatrix class, using the simple
scaler based mixing elements. This file could be in
/fs/microsd/APM/MIXER.MIX, same as plane now uses. See this code for
the way plane generates a mixer:
https://github.com/diydrones/ardupilot/blob/master/ArduPlane/px4_mixer.pde#L26
I think the motors matrix mixer creation would be a lot simpler than
that
- always publish actuator values in AP_HAL_Linux/RCOutput.cpp even if
not using UAVCAN. These will be ignored on copters that don't use
UAVCAN, as the px4io code will use the raw PWM values. The UAVCAN
code will use the actuator values.
- the actuator values would be based on the RC3_MIN/RC3_MAX range
(adjusted for RCMAP), plus the PWM values already passed into
hal.rcout->write()
I think the advantages are:
- this approach should work for planes and rovers using UAVCAN ESCs as
well, as it isn't copter specific
- it keeps using the current stability code in AP_Motors, so it should
fly extremely similarly to the current ArduCopter code
What do you think?
Cheers, Tridge