forked from Archive/PX4-Autopilot
253 lines
5.5 KiB
Plaintext
253 lines
5.5 KiB
Plaintext
#!nsh
|
|
#
|
|
# Script to configure control interface
|
|
#
|
|
#
|
|
# NOTE: environment variable references:
|
|
# If the dollar sign ('$') is followed by a left bracket ('{') then the
|
|
# variable name is terminated with the right bracket character ('}').
|
|
# Otherwise, the variable name goes to the end of the argument.
|
|
#
|
|
|
|
set SDCARD_MIXERS_PATH /fs/microsd/etc/mixers
|
|
|
|
if [ $MIXER != none -a $MIXER != skip ]
|
|
then
|
|
#
|
|
# Load main mixer
|
|
#
|
|
|
|
if [ $MIXER_AUX == none -a $USE_IO == yes ]
|
|
then
|
|
set MIXER_AUX ${MIXER}
|
|
fi
|
|
|
|
# Use the mixer file from the SD-card if it exists
|
|
if [ -f ${SDCARD_MIXERS_PATH}/${MIXER}.main.mix ]
|
|
then
|
|
set MIXER_FILE ${SDCARD_MIXERS_PATH}/${MIXER}.main.mix
|
|
# Try out the old convention, for backward compatibility
|
|
else
|
|
|
|
if [ -f ${SDCARD_MIXERS_PATH}/${MIXER}.mix ]
|
|
then
|
|
set MIXER_FILE ${SDCARD_MIXERS_PATH}/${MIXER}.mix
|
|
else
|
|
set MIXER_FILE /etc/mixers/${MIXER}.main.mix
|
|
fi
|
|
fi
|
|
|
|
if [ $OUTPUT_MODE == mkblctrl ]
|
|
then
|
|
set OUTPUT_DEV /dev/mkblctrl0
|
|
else
|
|
set OUTPUT_DEV /dev/pwm_output0
|
|
fi
|
|
|
|
if [ $OUTPUT_MODE == uavcan_esc ]
|
|
then
|
|
set OUTPUT_DEV /dev/uavcan/esc
|
|
fi
|
|
|
|
if [ $OUTPUT_MODE == tap_esc ]
|
|
then
|
|
set OUTPUT_DEV /dev/tap_esc
|
|
fi
|
|
|
|
if mixer load ${OUTPUT_DEV} ${MIXER_FILE}
|
|
then
|
|
echo "INFO [init] Mixer: ${MIXER_FILE} on ${OUTPUT_DEV}"
|
|
else
|
|
echo "ERROR [init] Failed loading mixer: ${MIXER_FILE}"
|
|
echo "ERROR [init] Failed loading mixer: ${MIXER_FILE}" >> $LOG_FILE
|
|
tone_alarm ${TUNE_ERR}
|
|
fi
|
|
|
|
unset MIXER_FILE
|
|
else
|
|
if [ $MIXER != skip ]
|
|
then
|
|
echo "ERROR [init] Mixer undefined"
|
|
echo "ERROR [init] Mixer undefined" >> $LOG_FILE
|
|
tone_alarm ${TUNE_ERR}
|
|
fi
|
|
fi
|
|
|
|
if [ $OUTPUT_MODE == fmu -o $OUTPUT_MODE == io ]
|
|
then
|
|
if [ $PWM_OUT != none ]
|
|
then
|
|
#
|
|
# Set PWM output frequency
|
|
#
|
|
if [ $PWM_RATE != none ]
|
|
then
|
|
pwm rate -c ${PWM_OUT} -r ${PWM_RATE}
|
|
fi
|
|
|
|
#
|
|
# Set disarmed, min and max PWM values
|
|
#
|
|
if [ $PWM_DISARMED != none ]
|
|
then
|
|
pwm disarmed -c ${PWM_OUT} -p ${PWM_DISARMED}
|
|
fi
|
|
if [ $PWM_MIN != none ]
|
|
then
|
|
pwm min -c ${PWM_OUT} -p ${PWM_MIN}
|
|
fi
|
|
if [ $PWM_MAX != none ]
|
|
then
|
|
pwm max -c ${PWM_OUT} -p ${PWM_MAX}
|
|
fi
|
|
fi
|
|
|
|
#
|
|
# Per channel disarmed settings
|
|
#
|
|
pwm disarmed -c 1 -p p:PWM_MAIN_DIS1
|
|
pwm disarmed -c 2 -p p:PWM_MAIN_DIS2
|
|
pwm disarmed -c 3 -p p:PWM_MAIN_DIS3
|
|
pwm disarmed -c 4 -p p:PWM_MAIN_DIS4
|
|
pwm disarmed -c 5 -p p:PWM_MAIN_DIS5
|
|
pwm disarmed -c 6 -p p:PWM_MAIN_DIS6
|
|
pwm disarmed -c 7 -p p:PWM_MAIN_DIS7
|
|
pwm disarmed -c 8 -p p:PWM_MAIN_DIS8
|
|
|
|
if [ $FAILSAFE != none ]
|
|
then
|
|
pwm failsafe -d ${OUTPUT_DEV} ${FAILSAFE}
|
|
fi
|
|
fi
|
|
|
|
if ver hwcmp MINDPX_V2 CRAZYFLIE AEROFC_V1 PX4FMU_V4 NXPHLITE_V3
|
|
then
|
|
set MIXER_AUX none
|
|
fi
|
|
|
|
if [ $MIXER_AUX != none -a $AUX_MODE != none ]
|
|
then
|
|
#
|
|
# Load aux mixer
|
|
#
|
|
|
|
set MIXER_AUX_FILE none
|
|
set OUTPUT_AUX_DEV /dev/pwm_output1
|
|
|
|
if [ -f ${SDCARD_MIXERS_PATH}/${MIXER_AUX}.aux.mix ]
|
|
then
|
|
set MIXER_AUX_FILE ${SDCARD_MIXERS_PATH}/${MIXER_AUX}.aux.mix
|
|
else
|
|
|
|
if [ -f /etc/mixers/${MIXER_AUX}.aux.mix ]
|
|
then
|
|
set MIXER_AUX_FILE /etc/mixers/${MIXER_AUX}.aux.mix
|
|
fi
|
|
fi
|
|
|
|
if [ $MIXER_AUX_FILE != none ]
|
|
then
|
|
if fmu mode_${AUX_MODE} $FMU_ARGS
|
|
then
|
|
# Append aux mixer to main device
|
|
if param compare SYS_HITL 1
|
|
then
|
|
if mixer append ${OUTPUT_DEV} ${MIXER_AUX_FILE}
|
|
then
|
|
echo "INFO [init] Mixer: ${MIXER_AUX_FILE} appended to ${OUTPUT_DEV}"
|
|
else
|
|
echo "ERROR [init] Failed appending mixer: ${MIXER_AUX_FILE}"
|
|
echo "ERROR [init] Failed appending mixer: ${MIXER_AUX_FILE}" >> $LOG_FILE
|
|
fi
|
|
fi
|
|
if [ -e $OUTPUT_AUX_DEV -a $OUTPUT_MODE != hil ]
|
|
then
|
|
if mixer load ${OUTPUT_AUX_DEV} ${MIXER_AUX_FILE}
|
|
then
|
|
echo "INFO [init] Mixer: ${MIXER_AUX_FILE} on ${OUTPUT_AUX_DEV}"
|
|
else
|
|
echo "ERROR [init] Failed loading mixer: ${MIXER_AUX_FILE}"
|
|
echo "ERROR [init] Failed loading mixer: ${MIXER_AUX_FILE}" >> $LOG_FILE
|
|
fi
|
|
else
|
|
set PWM_AUX_OUT none
|
|
set FAILSAFE_AUX none
|
|
fi
|
|
else
|
|
echo "ERROR: Could not start: fmu mode_pwm" >> $LOG_FILE
|
|
tone_alarm ${TUNE_ERR}
|
|
set PWM_AUX_OUT none
|
|
set FAILSAFE_AUX none
|
|
fi
|
|
|
|
# Set min / max for aux out and rates
|
|
if [ $PWM_AUX_OUT != none ]
|
|
then
|
|
#
|
|
# Set PWM_AUX output frequency
|
|
#
|
|
if [ $PWM_AUX_RATE != none ]
|
|
then
|
|
pwm rate -c ${PWM_AUX_OUT} -r ${PWM_AUX_RATE} -d ${OUTPUT_AUX_DEV}
|
|
fi
|
|
|
|
if [ $PWM_AUX_MIN != none ]
|
|
then
|
|
pwm min -c ${PWM_AUX_OUT} -p ${PWM_AUX_MIN} -d ${OUTPUT_AUX_DEV}
|
|
fi
|
|
if [ $PWM_AUX_MAX != none ]
|
|
then
|
|
pwm max -c ${PWM_AUX_OUT} -p ${PWM_AUX_MAX} -d ${OUTPUT_AUX_DEV}
|
|
fi
|
|
fi
|
|
|
|
# Set disarmed values for aux out
|
|
|
|
# Transitional support until all configs
|
|
# are updated
|
|
if [ $PWM_ACHDIS == none ]
|
|
then
|
|
set PWM_ACHDIS ${PWM_AUX_OUT}
|
|
fi
|
|
|
|
#
|
|
# Set disarmed, min and max PWM_AUX values
|
|
#
|
|
if [ $PWM_AUX_DISARMED != none -a $PWM_ACHDIS != none ]
|
|
then
|
|
pwm disarmed -c ${PWM_ACHDIS} -p ${PWM_AUX_DISARMED} -d ${OUTPUT_AUX_DEV}
|
|
fi
|
|
|
|
#
|
|
# Per channel disarmed settings
|
|
#
|
|
pwm disarmed -c 1 -p p:PWM_AUX_DIS1 -d ${OUTPUT_AUX_DEV}
|
|
pwm disarmed -c 2 -p p:PWM_AUX_DIS2 -d ${OUTPUT_AUX_DEV}
|
|
pwm disarmed -c 3 -p p:PWM_AUX_DIS3 -d ${OUTPUT_AUX_DEV}
|
|
pwm disarmed -c 4 -p p:PWM_AUX_DIS4 -d ${OUTPUT_AUX_DEV}
|
|
pwm disarmed -c 5 -p p:PWM_AUX_DIS5 -d ${OUTPUT_AUX_DEV}
|
|
pwm disarmed -c 6 -p p:PWM_AUX_DIS6 -d ${OUTPUT_AUX_DEV}
|
|
|
|
if [ $FAILSAFE_AUX != none ]
|
|
then
|
|
pwm failsafe -d ${OUTPUT_AUX_DEV} ${FAILSAFE}
|
|
fi
|
|
|
|
fi
|
|
fi
|
|
|
|
unset PWM_OUT
|
|
unset PWM_RATE
|
|
unset PWM_ACHDIS
|
|
unset PWM_MIN
|
|
unset PWM_MAX
|
|
unset PWM_AUX_OUT
|
|
unset PWM_AUX_RATE
|
|
unset PWM_AUX_DISARMED
|
|
unset PWM_AUX_MIN
|
|
unset PWM_AUX_MAX
|
|
unset FAILSAFE_AUX
|
|
unset FAILSAFE
|
|
unset OUTPUT_DEV
|
|
unset OUTPUT_AUX_DEV
|