2012-08-04 15:12:36 -07:00
|
|
|
#!nsh
|
|
|
|
|
#
|
|
|
|
|
# PX4FMU startup script.
|
2014-12-13 15:57:38 +01:00
|
|
|
#
|
2016-12-23 09:06:49 +01:00
|
|
|
# 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.
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
# NOTE: COMMENT LINES ARE REMOVED BEFORE STORED IN ROMFS.
|
2014-12-13 15:57:38 +01:00
|
|
|
#
|
2016-12-18 01:46:59 +01:00
|
|
|
# UART mapping on FMUv1/2/3/4:
|
|
|
|
|
#
|
|
|
|
|
# UART1 /dev/ttyS0 IO debug
|
|
|
|
|
# USART2 /dev/ttyS1 TELEM1 (flow control)
|
|
|
|
|
# USART3 /dev/ttyS2 TELEM2 (flow control)
|
|
|
|
|
# UART4
|
2016-12-18 22:29:14 +01:00
|
|
|
# UART7 CONSOLE
|
|
|
|
|
# UART8 SERIAL4
|
2016-12-18 01:46:59 +01:00
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
# UART mapping on FMUv5:
|
|
|
|
|
#
|
|
|
|
|
# UART1 /dev/ttyS0 GPS
|
|
|
|
|
# USART2 /dev/ttyS1 TELEM1 (flow control)
|
|
|
|
|
# USART3 /dev/ttyS2 TELEM2 (flow control)
|
|
|
|
|
# UART4 /dev/ttyS3 ?
|
|
|
|
|
# USART6 /dev/ttyS4 TELEM3 (flow control)
|
|
|
|
|
# UART7 /dev/ttyS5 ?
|
|
|
|
|
# UART8 /dev/ttyS6 CONSOLE
|
2012-08-04 15:12:36 -07:00
|
|
|
|
2016-12-12 12:53:12 -10:00
|
|
|
#
|
|
|
|
|
# Mount the procfs.
|
|
|
|
|
#
|
|
|
|
|
mount -t procfs /proc
|
|
|
|
|
|
2015-01-26 08:59:19 +01:00
|
|
|
#
|
|
|
|
|
# Start CDC/ACM serial driver
|
|
|
|
|
#
|
|
|
|
|
sercon
|
|
|
|
|
|
2012-08-04 15:12:36 -07:00
|
|
|
#
|
2014-02-01 15:46:04 +01:00
|
|
|
# Default to auto-start mode.
|
2012-08-04 15:12:36 -07:00
|
|
|
#
|
2015-01-17 04:04:48 +03:00
|
|
|
set MODE autostart
|
2012-08-04 15:12:36 -07:00
|
|
|
|
2014-11-17 14:58:29 +01:00
|
|
|
set TUNE_ERR ML<<CP4CP4CP4CP4CP4
|
2015-04-11 01:02:21 +02:00
|
|
|
set LOG_FILE /fs/microsd/bootlog.txt
|
2013-12-14 15:08:56 +01:00
|
|
|
|
2012-08-04 15:12:36 -07:00
|
|
|
#
|
|
|
|
|
# Try to mount the microSD card.
|
|
|
|
|
#
|
2015-02-14 20:33:20 +01:00
|
|
|
# REBOOTWORK this needs to start after the flight control loop
|
2012-08-04 15:12:36 -07:00
|
|
|
if mount -t vfat /dev/mmcsd0 /fs/microsd
|
|
|
|
|
then
|
2016-12-12 12:53:12 -10:00
|
|
|
echo "[i] microSD mounted: /fs/microsd"
|
|
|
|
|
if hardfault_log check
|
|
|
|
|
then
|
|
|
|
|
tone_alarm error
|
|
|
|
|
if hardfault_log commit
|
|
|
|
|
then
|
|
|
|
|
hardfault_log reset
|
|
|
|
|
tone_alarm stop
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
# Start playing the startup tune
|
|
|
|
|
tone_alarm start
|
|
|
|
|
fi
|
2012-08-04 15:12:36 -07:00
|
|
|
else
|
2015-04-11 01:02:21 +02:00
|
|
|
tone_alarm MBAGP
|
|
|
|
|
if mkfatfs /dev/mmcsd0
|
|
|
|
|
then
|
|
|
|
|
if mount -t vfat /dev/mmcsd0 /fs/microsd
|
|
|
|
|
then
|
2016-06-02 17:25:02 +01:00
|
|
|
echo "INFO [init] MicroSD card formatted"
|
2015-04-11 01:02:21 +02:00
|
|
|
else
|
2016-06-02 17:25:02 +01:00
|
|
|
echo "ERROR [init] Format failed"
|
2015-04-11 01:02:21 +02:00
|
|
|
tone_alarm MNBG
|
|
|
|
|
set LOG_FILE /dev/null
|
|
|
|
|
fi
|
2015-04-13 18:45:18 +02:00
|
|
|
else
|
|
|
|
|
set LOG_FILE /dev/null
|
2015-04-11 01:02:21 +02:00
|
|
|
fi
|
2012-08-04 15:12:36 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Look for an init script on the microSD card.
|
2014-01-10 23:14:29 +01:00
|
|
|
# Disable autostart if the script found.
|
2012-08-04 15:12:36 -07:00
|
|
|
#
|
2016-03-28 14:48:14 +02:00
|
|
|
set FRC /fs/microsd/etc/rc.txt
|
2014-11-17 14:58:29 +01:00
|
|
|
if [ -f $FRC ]
|
2012-12-27 13:17:43 +01:00
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
echo "INFO [init] Executing script: ${FRC}"
|
2014-11-17 14:58:29 +01:00
|
|
|
sh $FRC
|
2014-01-10 23:14:29 +01:00
|
|
|
set MODE custom
|
2012-08-04 15:12:36 -07:00
|
|
|
fi
|
2015-01-08 15:42:25 +01:00
|
|
|
unset FRC
|
2012-08-04 15:12:36 -07:00
|
|
|
|
2013-07-18 10:01:03 +02:00
|
|
|
if [ $MODE == autostart ]
|
|
|
|
|
then
|
2014-08-26 10:13:52 +02:00
|
|
|
|
2013-08-25 19:27:11 +02:00
|
|
|
#
|
|
|
|
|
# Start the ORB (first app to start)
|
|
|
|
|
#
|
|
|
|
|
uorb start
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2013-08-25 19:27:11 +02:00
|
|
|
#
|
2014-01-14 15:52:46 +01:00
|
|
|
# Load parameters
|
2013-08-25 19:27:11 +02:00
|
|
|
#
|
2014-01-15 00:02:57 +01:00
|
|
|
set PARAM_FILE /fs/microsd/params
|
2014-01-12 16:33:23 +01:00
|
|
|
if mtd start
|
|
|
|
|
then
|
2014-01-17 23:14:24 +01:00
|
|
|
set PARAM_FILE /fs/mtd_params
|
2014-01-15 00:02:57 +01:00
|
|
|
fi
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2014-01-15 00:02:57 +01:00
|
|
|
param select $PARAM_FILE
|
|
|
|
|
if param load
|
|
|
|
|
then
|
2014-01-12 16:33:23 +01:00
|
|
|
else
|
2014-08-11 14:56:13 +02:00
|
|
|
if param reset
|
|
|
|
|
then
|
|
|
|
|
fi
|
2014-01-12 17:43:33 +01:00
|
|
|
fi
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2013-08-25 19:27:11 +02:00
|
|
|
#
|
|
|
|
|
# Start system state indicator
|
|
|
|
|
#
|
|
|
|
|
if rgbled start
|
2013-08-17 15:48:13 +02:00
|
|
|
then
|
2013-08-25 19:27:11 +02:00
|
|
|
else
|
|
|
|
|
if blinkm start
|
|
|
|
|
then
|
|
|
|
|
blinkm systemstate
|
|
|
|
|
fi
|
2013-08-17 15:48:13 +02:00
|
|
|
fi
|
2014-05-29 13:52:29 +02:00
|
|
|
|
2015-06-12 09:31:10 +02:00
|
|
|
# Currently unused, but might be useful down the road
|
|
|
|
|
#if pca8574 start
|
|
|
|
|
#then
|
|
|
|
|
#fi
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2016-03-28 14:48:14 +02:00
|
|
|
#
|
|
|
|
|
# Set AUTOCNF flag to use it in AUTOSTART scripts
|
|
|
|
|
#
|
|
|
|
|
if param compare SYS_AUTOCONFIG 1
|
|
|
|
|
then
|
|
|
|
|
# Wipe out params except RC*
|
|
|
|
|
param reset_nostart RC*
|
|
|
|
|
set AUTOCNF yes
|
|
|
|
|
else
|
|
|
|
|
set AUTOCNF no
|
2016-07-02 12:08:57 +02:00
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Release 1.4.0 transitional support:
|
|
|
|
|
# set to old default if unconfigured.
|
|
|
|
|
# this preserves the previous behaviour
|
|
|
|
|
#
|
|
|
|
|
if param compare BAT_N_CELLS 0
|
|
|
|
|
then
|
|
|
|
|
param set BAT_N_CELLS 3
|
|
|
|
|
fi
|
2016-03-28 14:48:14 +02:00
|
|
|
fi
|
|
|
|
|
|
2013-11-05 19:56:33 +01:00
|
|
|
#
|
2014-01-10 23:14:29 +01:00
|
|
|
# Set default values
|
2013-11-05 19:56:33 +01:00
|
|
|
#
|
2014-01-10 23:14:29 +01:00
|
|
|
set HIL no
|
|
|
|
|
set VEHICLE_TYPE none
|
2014-01-15 00:02:57 +01:00
|
|
|
set MIXER none
|
2015-01-07 00:25:06 +02:00
|
|
|
set MIXER_AUX none
|
2014-01-11 17:52:29 +01:00
|
|
|
set OUTPUT_MODE none
|
2014-11-17 14:58:29 +01:00
|
|
|
set PWM_OUT none
|
2016-12-07 09:14:17 +01:00
|
|
|
set PWM_RATE p:PWM_RATE
|
|
|
|
|
set PWM_DISARMED p:PWM_DISARMED
|
|
|
|
|
set PWM_MIN p:PWM_MIN
|
|
|
|
|
set PWM_MAX p:PWM_MAX
|
2015-03-03 23:53:48 -08:00
|
|
|
set PWM_AUX_OUT none
|
|
|
|
|
set PWM_AUX_RATE none
|
2016-02-14 19:51:43 +01:00
|
|
|
set PWM_ACHDIS none
|
2016-12-07 09:14:17 +01:00
|
|
|
set PWM_AUX_DISARMED p:PWM_AUX_DISARMED
|
|
|
|
|
set PWM_AUX_MIN p:PWM_AUX_MIN
|
|
|
|
|
set PWM_AUX_MAX p:PWM_AUX_MAX
|
2015-04-26 23:27:23 +02:00
|
|
|
set FAILSAFE_AUX none
|
2014-11-17 14:58:29 +01:00
|
|
|
set MK_MODE none
|
2014-01-11 17:52:29 +01:00
|
|
|
set FMU_MODE pwm
|
2015-08-13 09:45:33 +02:00
|
|
|
set AUX_MODE pwm
|
2014-11-17 14:58:29 +01:00
|
|
|
set MAVLINK_F default
|
2016-11-10 21:35:17 -02:00
|
|
|
set MAVLINK_COMPANION_DEVICE /dev/ttyS2
|
2014-03-01 18:30:30 +04:00
|
|
|
set EXIT_ON_END no
|
2014-01-15 00:02:57 +01:00
|
|
|
set MAV_TYPE none
|
2014-08-26 10:13:52 +02:00
|
|
|
set FAILSAFE none
|
2016-03-12 12:50:14 +08:00
|
|
|
set USE_IO yes
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Set USE_IO flag
|
|
|
|
|
#
|
|
|
|
|
if param compare SYS_USE_IO 1
|
|
|
|
|
then
|
|
|
|
|
if ver hwcmp PX4FMU_V4
|
|
|
|
|
then
|
|
|
|
|
set USE_IO no
|
|
|
|
|
fi
|
|
|
|
|
|
2016-12-13 15:24:04 -10:00
|
|
|
if ver hwcmp PX4FMU_V5
|
|
|
|
|
then
|
|
|
|
|
set USE_IO no
|
|
|
|
|
set MAVLINK_COMPANION_DEVICE /dev/ttyS3
|
|
|
|
|
fi
|
|
|
|
|
|
2016-03-12 12:50:14 +08:00
|
|
|
if ver hwcmp MINDPX_V2
|
|
|
|
|
then
|
|
|
|
|
set USE_IO no
|
|
|
|
|
fi
|
2016-08-20 21:04:42 -04:00
|
|
|
|
|
|
|
|
if ver hwcmp CRAZYFLIE
|
|
|
|
|
then
|
|
|
|
|
set USE_IO no
|
2016-08-28 09:39:30 -04:00
|
|
|
|
|
|
|
|
if param compare SYS_AUTOSTART 0
|
|
|
|
|
then
|
|
|
|
|
param set SYS_AUTOSTART 4900
|
|
|
|
|
set AUTOCNF yes
|
|
|
|
|
fi
|
2016-08-20 21:04:42 -04:00
|
|
|
fi
|
2016-09-21 14:21:01 -03:00
|
|
|
|
|
|
|
|
if ver hwcmp AEROFC_V1
|
|
|
|
|
then
|
|
|
|
|
set USE_IO no
|
|
|
|
|
fi
|
2016-03-12 12:50:14 +08:00
|
|
|
else
|
|
|
|
|
set USE_IO no
|
|
|
|
|
fi
|
|
|
|
|
|
2016-12-05 09:18:00 -08:00
|
|
|
if ver hwcmp AEROFC_V1
|
|
|
|
|
then
|
|
|
|
|
if param compare SYS_AUTOSTART 0
|
|
|
|
|
then
|
|
|
|
|
set AUTOCNF yes
|
|
|
|
|
fi
|
2016-12-05 09:23:55 -08:00
|
|
|
|
|
|
|
|
# We don't allow changing AUTOSTART as it doesn't work in
|
|
|
|
|
# other configurations
|
2016-12-05 09:18:00 -08:00
|
|
|
param set SYS_AUTOSTART 4070
|
|
|
|
|
fi
|
|
|
|
|
|
2013-08-25 19:27:11 +02:00
|
|
|
#
|
2014-01-08 20:55:12 +01:00
|
|
|
# Set parameters and env variables for selected AUTOSTART
|
2013-08-25 19:27:11 +02:00
|
|
|
#
|
2014-01-10 23:41:03 +01:00
|
|
|
if param compare SYS_AUTOSTART 0
|
2013-10-15 17:54:57 +02:00
|
|
|
then
|
2014-01-10 23:41:03 +01:00
|
|
|
else
|
|
|
|
|
sh /etc/init.d/rc.autostart
|
2013-10-15 17:54:57 +02:00
|
|
|
fi
|
2015-01-09 07:56:20 +01:00
|
|
|
unset MODE
|
2013-10-15 17:54:57 +02:00
|
|
|
|
2015-12-07 11:38:28 +01:00
|
|
|
#
|
|
|
|
|
# Wipe incompatible settings for boards not having two outputs
|
|
|
|
|
if ver hwcmp PX4FMU_V4
|
|
|
|
|
then
|
|
|
|
|
set MIXER_AUX none
|
|
|
|
|
fi
|
|
|
|
|
|
2016-12-13 15:24:04 -10:00
|
|
|
if ver hwcmp PX4FMU_V5
|
|
|
|
|
then
|
|
|
|
|
set MIXER_AUX none
|
|
|
|
|
fi
|
|
|
|
|
|
2016-09-21 14:20:31 -03:00
|
|
|
if ver hwcmp AEROFC_V1
|
|
|
|
|
then
|
|
|
|
|
set MIXER_AUX none
|
|
|
|
|
fi
|
|
|
|
|
|
2013-08-25 19:27:11 +02:00
|
|
|
#
|
2014-01-10 23:14:29 +01:00
|
|
|
# Override parameters from user configuration file
|
2013-08-25 19:27:11 +02:00
|
|
|
#
|
2016-03-28 14:48:14 +02:00
|
|
|
set FCONFIG /fs/microsd/etc/config.txt
|
2014-11-17 14:58:29 +01:00
|
|
|
if [ -f $FCONFIG ]
|
2013-12-14 15:08:56 +01:00
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
echo "Custom: ${FCONFIG}"
|
2014-11-17 14:58:29 +01:00
|
|
|
sh $FCONFIG
|
2013-12-14 15:08:56 +01:00
|
|
|
fi
|
2014-11-17 14:58:29 +01:00
|
|
|
unset FCONFIG
|
2013-12-14 15:08:56 +01:00
|
|
|
|
2014-01-10 23:14:29 +01:00
|
|
|
#
|
|
|
|
|
# If autoconfig parameter was set, reset it and save parameters
|
|
|
|
|
#
|
2014-11-17 14:58:29 +01:00
|
|
|
if [ $AUTOCNF == yes ]
|
2013-08-02 15:47:04 +02:00
|
|
|
then
|
2016-12-26 19:30:14 +01:00
|
|
|
# Disable safety switch by default on Pixracer
|
|
|
|
|
if ver hwcmp PX4FMU_V4
|
|
|
|
|
then
|
|
|
|
|
param set CBRK_IO_SAFETY 22027
|
|
|
|
|
fi
|
2014-01-10 23:14:29 +01:00
|
|
|
param set SYS_AUTOCONFIG 0
|
2013-12-14 15:08:56 +01:00
|
|
|
fi
|
2015-01-09 07:56:20 +01:00
|
|
|
unset AUTOCNF
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2014-01-11 17:52:29 +01:00
|
|
|
set IO_PRESENT no
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2014-01-11 17:52:29 +01:00
|
|
|
if [ $USE_IO == yes ]
|
2013-12-14 15:08:56 +01:00
|
|
|
then
|
2014-01-11 17:52:29 +01:00
|
|
|
#
|
|
|
|
|
# Check if PX4IO present and update firmware if needed
|
|
|
|
|
#
|
2015-10-20 13:36:25 -04:00
|
|
|
if [ -f /etc/extras/px4io-v2.bin ]
|
2013-08-02 15:47:04 +02:00
|
|
|
then
|
2015-10-20 13:36:25 -04:00
|
|
|
set IO_FILE /etc/extras/px4io-v2.bin
|
2014-01-11 17:52:29 +01:00
|
|
|
else
|
2015-10-20 13:36:25 -04:00
|
|
|
set IO_FILE /etc/extras/px4io-v1.bin
|
2014-01-11 17:52:29 +01:00
|
|
|
fi
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2015-02-14 20:33:20 +01:00
|
|
|
if px4io checkcrc ${IO_FILE}
|
2014-01-11 17:52:29 +01:00
|
|
|
then
|
2016-09-04 20:55:03 +02:00
|
|
|
echo "[init] PX4IO CRC OK" >> $LOG_FILE
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2014-01-11 17:52:29 +01:00
|
|
|
set IO_PRESENT yes
|
|
|
|
|
else
|
2014-01-11 18:45:56 +01:00
|
|
|
tone_alarm MLL32CP8MB
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2015-02-28 11:15:13 +01:00
|
|
|
if px4io start
|
|
|
|
|
then
|
2015-03-04 09:04:01 +01:00
|
|
|
# try to safe px4 io so motor outputs dont go crazy
|
2015-02-28 11:15:13 +01:00
|
|
|
if px4io safety_on
|
|
|
|
|
then
|
2015-03-04 09:04:01 +01:00
|
|
|
# success! no-op
|
|
|
|
|
else
|
|
|
|
|
# px4io did not respond to the safety command
|
|
|
|
|
px4io stop
|
2015-02-28 11:15:13 +01:00
|
|
|
fi
|
|
|
|
|
fi
|
2015-02-14 20:33:20 +01:00
|
|
|
|
|
|
|
|
if px4io forceupdate 14662 ${IO_FILE}
|
2013-08-31 11:56:39 +02:00
|
|
|
then
|
2016-12-12 12:53:12 -10:00
|
|
|
usleep 10000
|
2016-12-23 09:06:49 +01:00
|
|
|
if px4io checkcrc ${IO_FILE}
|
2014-01-11 17:52:29 +01:00
|
|
|
then
|
2016-09-04 20:55:03 +02:00
|
|
|
echo "PX4IO CRC OK after updating" >> $LOG_FILE
|
2014-01-11 18:45:56 +01:00
|
|
|
tone_alarm MLL8CDE
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2014-01-11 17:52:29 +01:00
|
|
|
set IO_PRESENT yes
|
|
|
|
|
else
|
2016-09-04 20:55:03 +02:00
|
|
|
echo "PX4IO update failed" >> $LOG_FILE
|
2016-12-23 09:06:49 +01:00
|
|
|
tone_alarm ${TUNE_ERR}
|
2014-01-11 17:52:29 +01:00
|
|
|
fi
|
2013-12-14 15:08:56 +01:00
|
|
|
else
|
2016-09-04 20:55:03 +02:00
|
|
|
echo "PX4IO update failed" >> $LOG_FILE
|
2016-12-23 09:06:49 +01:00
|
|
|
tone_alarm ${TUNE_ERR}
|
2013-08-31 11:56:39 +02:00
|
|
|
fi
|
2014-01-11 17:52:29 +01:00
|
|
|
fi
|
2015-01-09 09:08:51 +01:00
|
|
|
unset IO_FILE
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2014-01-11 17:52:29 +01:00
|
|
|
if [ $IO_PRESENT == no ]
|
|
|
|
|
then
|
2016-09-04 20:55:03 +02:00
|
|
|
echo "PX4IO not found" >> $LOG_FILE
|
2016-12-23 09:06:49 +01:00
|
|
|
tone_alarm ${TUNE_ERR}
|
2013-08-31 11:56:39 +02:00
|
|
|
fi
|
2013-08-02 15:47:04 +02:00
|
|
|
fi
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2013-08-25 19:27:11 +02:00
|
|
|
#
|
2014-01-11 17:52:29 +01:00
|
|
|
# Set default output if not set
|
|
|
|
|
#
|
|
|
|
|
if [ $OUTPUT_MODE == none ]
|
2013-12-28 22:52:23 +01:00
|
|
|
then
|
2014-01-15 00:02:57 +01:00
|
|
|
if [ $USE_IO == yes ]
|
2014-01-11 17:52:29 +01:00
|
|
|
then
|
|
|
|
|
set OUTPUT_MODE io
|
|
|
|
|
else
|
|
|
|
|
set OUTPUT_MODE fmu
|
|
|
|
|
fi
|
2013-12-28 22:52:23 +01:00
|
|
|
fi
|
|
|
|
|
|
2014-01-15 00:02:57 +01:00
|
|
|
if [ $OUTPUT_MODE == io -a $IO_PRESENT != yes ]
|
2013-12-28 22:52:23 +01:00
|
|
|
then
|
2014-01-15 00:02:57 +01:00
|
|
|
# Need IO for output but it not present, disable output
|
|
|
|
|
set OUTPUT_MODE none
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2014-01-15 00:02:57 +01:00
|
|
|
# Avoid using ttyS0 for MAVLink on FMUv1
|
2014-04-27 17:42:45 +02:00
|
|
|
if ver hwcmp PX4FMU_V1
|
2014-01-15 00:02:57 +01:00
|
|
|
then
|
|
|
|
|
set FMU_MODE serial
|
|
|
|
|
fi
|
2013-10-19 11:11:15 +02:00
|
|
|
fi
|
2014-01-06 09:25:39 +01:00
|
|
|
|
2014-03-06 12:45:10 +01:00
|
|
|
if [ $OUTPUT_MODE == ardrone ]
|
|
|
|
|
then
|
|
|
|
|
set FMU_MODE gpio_serial
|
|
|
|
|
fi
|
|
|
|
|
|
2016-11-16 15:45:33 -02:00
|
|
|
if [ $OUTPUT_MODE == tap_esc ]
|
|
|
|
|
then
|
|
|
|
|
set FMU_MODE rcin
|
|
|
|
|
fi
|
|
|
|
|
|
2014-01-11 17:52:29 +01:00
|
|
|
if [ $HIL == yes ]
|
2014-01-06 09:25:39 +01:00
|
|
|
then
|
2014-01-11 17:52:29 +01:00
|
|
|
set OUTPUT_MODE hil
|
2014-04-27 17:42:45 +02:00
|
|
|
if ver hwcmp PX4FMU_V1
|
2014-01-18 16:47:23 +01:00
|
|
|
then
|
|
|
|
|
set FMU_MODE serial
|
|
|
|
|
fi
|
2016-03-28 14:48:14 +02:00
|
|
|
unset HIL
|
|
|
|
|
else
|
|
|
|
|
unset HIL
|
|
|
|
|
gps start
|
2014-01-06 09:25:39 +01:00
|
|
|
fi
|
2014-04-22 01:23:55 +02:00
|
|
|
|
2014-11-15 16:19:51 +01:00
|
|
|
# waypoint storage
|
2015-02-14 20:33:20 +01:00
|
|
|
# REBOOTWORK this needs to start in parallel
|
2014-08-11 14:54:18 +02:00
|
|
|
if dataman start
|
|
|
|
|
then
|
|
|
|
|
fi
|
2014-06-30 12:42:26 +02:00
|
|
|
|
2015-03-08 14:55:51 +01:00
|
|
|
#
|
|
|
|
|
# Sensors System (start before Commander so Preflight checks are properly run)
|
|
|
|
|
#
|
|
|
|
|
sh /etc/init.d/rc.sensors
|
2016-03-21 11:28:04 +01:00
|
|
|
|
2014-11-15 16:19:51 +01:00
|
|
|
# Needs to be this early for in-air-restarts
|
2016-04-15 15:39:43 +09:00
|
|
|
if [ $OUTPUT_MODE == hil ]
|
|
|
|
|
then
|
|
|
|
|
commander start -hil
|
|
|
|
|
else
|
|
|
|
|
commander start
|
|
|
|
|
fi
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2017-01-20 00:26:01 +01:00
|
|
|
if send_event start_listening
|
|
|
|
|
then
|
|
|
|
|
fi
|
|
|
|
|
|
2016-04-29 14:27:16 +02:00
|
|
|
#
|
|
|
|
|
# Start CPU load monitor
|
|
|
|
|
#
|
|
|
|
|
load_mon start
|
|
|
|
|
|
2014-01-10 23:14:29 +01:00
|
|
|
#
|
|
|
|
|
# Start primary output
|
|
|
|
|
#
|
2014-01-11 17:52:29 +01:00
|
|
|
set TTYS1_BUSY no
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2015-10-28 22:55:37 +01:00
|
|
|
#
|
|
|
|
|
# Check if UAVCAN is enabled, default to it for ESCs
|
|
|
|
|
#
|
|
|
|
|
if param greater UAVCAN_ENABLE 2
|
|
|
|
|
then
|
|
|
|
|
set OUTPUT_MODE uavcan_esc
|
|
|
|
|
fi
|
|
|
|
|
|
2016-10-28 17:19:42 +02:00
|
|
|
# Sensors on the PWM interface bank
|
|
|
|
|
# clear pins 5 and 6
|
|
|
|
|
if param compare SENS_EN_LL40LS 1
|
|
|
|
|
then
|
|
|
|
|
set FMU_MODE pwm4
|
|
|
|
|
set AUX_MODE pwm4
|
|
|
|
|
fi
|
|
|
|
|
if param greater TRIG_MODE 0
|
|
|
|
|
then
|
|
|
|
|
set FMU_MODE pwm4
|
|
|
|
|
set AUX_MODE pwm4
|
|
|
|
|
camera_trigger start
|
|
|
|
|
fi
|
|
|
|
|
|
2014-01-18 16:47:23 +01:00
|
|
|
# If OUTPUT_MODE == none then something is wrong with setup and we shouldn't try to enable output
|
|
|
|
|
if [ $OUTPUT_MODE != none ]
|
2013-08-28 15:50:06 +02:00
|
|
|
then
|
2014-07-07 02:31:05 +04:00
|
|
|
if [ $OUTPUT_MODE == uavcan_esc ]
|
2014-05-08 14:23:33 +02:00
|
|
|
then
|
2014-08-23 17:23:59 +04:00
|
|
|
if param compare UAVCAN_ENABLE 0
|
2014-05-08 14:23:33 +02:00
|
|
|
then
|
2016-11-15 16:36:36 +01:00
|
|
|
echo "OVERRIDING UAVCAN_ENABLE = 3" >> $LOG_FILE
|
|
|
|
|
param set UAVCAN_ENABLE 3
|
2014-05-08 14:23:33 +02:00
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2014-07-07 02:31:05 +04:00
|
|
|
if [ $OUTPUT_MODE == io -o $OUTPUT_MODE == uavcan_esc ]
|
2014-01-10 13:18:34 +01:00
|
|
|
then
|
2014-01-11 17:52:29 +01:00
|
|
|
if px4io start
|
|
|
|
|
then
|
|
|
|
|
sh /etc/init.d/rc.io
|
|
|
|
|
else
|
2016-09-04 20:55:03 +02:00
|
|
|
echo "PX4IO start failed" >> $LOG_FILE
|
2014-11-17 14:58:29 +01:00
|
|
|
tone_alarm $TUNE_ERR
|
2014-01-11 17:52:29 +01:00
|
|
|
fi
|
|
|
|
|
fi
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2014-03-06 23:00:00 +01:00
|
|
|
if [ $OUTPUT_MODE == fmu -o $OUTPUT_MODE == ardrone ]
|
2014-01-11 17:52:29 +01:00
|
|
|
then
|
|
|
|
|
if fmu mode_$FMU_MODE
|
|
|
|
|
then
|
|
|
|
|
else
|
2016-09-04 20:55:03 +02:00
|
|
|
echo "FMU start failed" >> $LOG_FILE
|
2014-11-17 14:58:29 +01:00
|
|
|
tone_alarm $TUNE_ERR
|
2014-01-11 17:52:29 +01:00
|
|
|
fi
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2014-04-27 17:42:45 +02:00
|
|
|
if ver hwcmp PX4FMU_V1
|
2014-01-11 17:52:29 +01:00
|
|
|
then
|
2014-01-15 00:02:57 +01:00
|
|
|
if [ $FMU_MODE == pwm -o $FMU_MODE == gpio ]
|
|
|
|
|
then
|
|
|
|
|
set TTYS1_BUSY yes
|
|
|
|
|
fi
|
2014-03-06 17:44:10 +04:00
|
|
|
if [ $FMU_MODE == pwm_gpio -o $OUTPUT_MODE == ardrone ]
|
2014-01-11 17:52:29 +01:00
|
|
|
then
|
|
|
|
|
set TTYS1_BUSY yes
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2014-01-08 20:55:12 +01:00
|
|
|
fi
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2014-01-18 16:47:23 +01:00
|
|
|
if [ $OUTPUT_MODE == mkblctrl ]
|
|
|
|
|
then
|
|
|
|
|
set MKBLCTRL_ARG ""
|
2015-02-16 22:06:17 +01:00
|
|
|
if [ $MKBLCTRL_MODE == x ]
|
2014-01-18 16:47:23 +01:00
|
|
|
then
|
|
|
|
|
set MKBLCTRL_ARG "-mkmode x"
|
|
|
|
|
fi
|
2015-02-16 22:06:17 +01:00
|
|
|
if [ $MKBLCTRL_MODE == + ]
|
2014-01-18 16:47:23 +01:00
|
|
|
then
|
|
|
|
|
set MKBLCTRL_ARG "-mkmode +"
|
|
|
|
|
fi
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2014-01-18 16:47:23 +01:00
|
|
|
if mkblctrl $MKBLCTRL_ARG
|
|
|
|
|
then
|
|
|
|
|
else
|
2016-09-04 20:55:03 +02:00
|
|
|
echo "MK start failed" >> $LOG_FILE
|
2014-11-17 14:58:29 +01:00
|
|
|
tone_alarm $TUNE_ERR
|
2014-01-18 16:47:23 +01:00
|
|
|
fi
|
2015-01-08 15:42:25 +01:00
|
|
|
unset MKBLCTRL_ARG
|
2014-03-31 10:10:50 +04:00
|
|
|
fi
|
2015-01-08 15:42:25 +01:00
|
|
|
unset MK_MODE
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2014-01-18 16:47:23 +01:00
|
|
|
if [ $OUTPUT_MODE == hil ]
|
|
|
|
|
then
|
2016-09-07 12:09:22 +02:00
|
|
|
if pwm_out_sim mode_pwm16
|
2014-01-18 16:47:23 +01:00
|
|
|
then
|
|
|
|
|
else
|
2014-11-17 14:58:29 +01:00
|
|
|
tone_alarm $TUNE_ERR
|
2014-01-18 16:47:23 +01:00
|
|
|
fi
|
|
|
|
|
fi
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2014-01-18 16:47:23 +01:00
|
|
|
#
|
|
|
|
|
# Start IO or FMU for RC PPM input if needed
|
|
|
|
|
#
|
|
|
|
|
if [ $IO_PRESENT == yes ]
|
|
|
|
|
then
|
|
|
|
|
if [ $OUTPUT_MODE != io ]
|
|
|
|
|
then
|
|
|
|
|
if px4io start
|
|
|
|
|
then
|
|
|
|
|
sh /etc/init.d/rc.io
|
|
|
|
|
else
|
2016-09-04 20:55:03 +02:00
|
|
|
echo "PX4IO start failed" >> $LOG_FILE
|
2014-11-17 14:58:29 +01:00
|
|
|
tone_alarm $TUNE_ERR
|
2014-01-18 16:47:23 +01:00
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
else
|
2014-03-06 12:45:10 +01:00
|
|
|
if [ $OUTPUT_MODE != fmu -a $OUTPUT_MODE != ardrone ]
|
2014-01-18 16:47:23 +01:00
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
if fmu mode_${FMU_MODE}
|
2014-01-18 16:47:23 +01:00
|
|
|
then
|
|
|
|
|
else
|
2016-12-23 09:06:49 +01:00
|
|
|
echo "FMU mode_${FMU_MODE} start failed" >> $LOG_FILE
|
2014-11-17 14:58:29 +01:00
|
|
|
tone_alarm $TUNE_ERR
|
2014-01-18 16:47:23 +01:00
|
|
|
fi
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2014-04-27 17:42:45 +02:00
|
|
|
if ver hwcmp PX4FMU_V1
|
2014-01-18 16:47:23 +01:00
|
|
|
then
|
|
|
|
|
if [ $FMU_MODE == pwm -o $FMU_MODE == gpio ]
|
|
|
|
|
then
|
|
|
|
|
set TTYS1_BUSY yes
|
|
|
|
|
fi
|
2014-03-06 17:44:10 +04:00
|
|
|
if [ $FMU_MODE == pwm_gpio -o $OUTPUT_MODE == ardrone ]
|
2014-01-18 16:47:23 +01:00
|
|
|
then
|
|
|
|
|
set TTYS1_BUSY yes
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2013-09-25 02:17:06 +09:00
|
|
|
fi
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2014-11-17 14:58:29 +01:00
|
|
|
if [ $MAVLINK_F == default ]
|
2013-08-25 19:27:11 +02:00
|
|
|
then
|
2014-04-22 01:23:55 +02:00
|
|
|
# Normal mode, use baudrate 57600 (default) and data rate 1000 bytes/s
|
|
|
|
|
if [ $TTYS1_BUSY == yes ]
|
2014-01-10 13:18:34 +01:00
|
|
|
then
|
2014-04-22 01:23:55 +02:00
|
|
|
# Start MAVLink on ttyS0, because FMU ttyS1 pins configured as something else
|
2015-07-31 20:05:59 +02:00
|
|
|
set MAVLINK_F "-r 1200 -d /dev/ttyS0"
|
2014-04-22 01:23:55 +02:00
|
|
|
|
|
|
|
|
# Exit from nsh to free port for mavlink
|
|
|
|
|
set EXIT_ON_END yes
|
2014-01-10 23:14:29 +01:00
|
|
|
else
|
2015-07-31 20:05:59 +02:00
|
|
|
set MAVLINK_F "-r 1200"
|
2015-11-27 15:14:24 +01:00
|
|
|
# Avoid using ttyS1 for MAVLink on FMUv4
|
|
|
|
|
if ver hwcmp PX4FMU_V4
|
|
|
|
|
then
|
2016-01-23 18:25:07 +01:00
|
|
|
set MAVLINK_F "-r 1200 -d /dev/ttyS1"
|
2015-12-17 22:07:27 +00:00
|
|
|
# Start MAVLink on Wifi (ESP8266 port)
|
2016-04-11 12:51:07 -07:00
|
|
|
mavlink start -r 20000 -m config -b 921600 -d /dev/ttyS0
|
2015-11-27 15:14:24 +01:00
|
|
|
fi
|
2016-11-10 21:38:41 -02:00
|
|
|
|
|
|
|
|
if ver hwcmp AEROFC_V1
|
|
|
|
|
then
|
|
|
|
|
set MAVLINK_F "-r 1200 -d /dev/ttyS4"
|
|
|
|
|
fi
|
2014-01-10 13:18:34 +01:00
|
|
|
fi
|
2016-09-11 21:41:51 -04:00
|
|
|
|
|
|
|
|
if ver hwcmp CRAZYFLIE
|
|
|
|
|
then
|
|
|
|
|
# Avoid using either of the two available serials
|
|
|
|
|
set MAVLINK_F none
|
|
|
|
|
fi
|
2013-08-25 19:27:11 +02:00
|
|
|
fi
|
2014-03-01 16:43:04 +04:00
|
|
|
|
2016-10-19 14:21:14 +02:00
|
|
|
if [ "x$MAVLINK_F" == xnone ]
|
2016-09-11 21:41:51 -04:00
|
|
|
then
|
|
|
|
|
else
|
2016-12-23 09:06:49 +01:00
|
|
|
mavlink start ${MAVLINK_F}
|
2016-09-11 21:41:51 -04:00
|
|
|
fi
|
2014-11-17 14:58:29 +01:00
|
|
|
unset MAVLINK_F
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2014-08-13 18:47:07 +02:00
|
|
|
#
|
|
|
|
|
# MAVLink onboard / TELEM2
|
|
|
|
|
#
|
2016-02-19 21:37:36 +01:00
|
|
|
if ver hwcmp PX4FMU_V1
|
2014-08-21 14:30:17 +02:00
|
|
|
then
|
2016-02-19 21:37:36 +01:00
|
|
|
else
|
2015-04-23 13:33:54 +02:00
|
|
|
# XXX We need a better way for runtime eval of shell variables,
|
|
|
|
|
# but this works for now
|
2016-04-30 12:00:56 +02:00
|
|
|
if param compare SYS_COMPANION 10
|
|
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
frsky_telemetry start -d ${MAVLINK_COMPANION_DEVICE}
|
2016-04-30 12:00:56 +02:00
|
|
|
fi
|
2016-08-28 09:36:06 -04:00
|
|
|
if param compare SYS_COMPANION 20
|
|
|
|
|
then
|
|
|
|
|
syslink start
|
2016-09-11 05:23:15 -04:00
|
|
|
mavlink start -d /dev/bridge0 -b 57600 -m osd -r 40000
|
2016-08-28 09:36:06 -04:00
|
|
|
fi
|
2014-12-26 18:01:52 +01:00
|
|
|
if param compare SYS_COMPANION 921600
|
|
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
mavlink start -d ${MAVLINK_COMPANION_DEVICE} -b 921600 -m onboard -r 80000 -x
|
2014-12-26 18:01:52 +01:00
|
|
|
fi
|
2015-04-23 13:33:54 +02:00
|
|
|
if param compare SYS_COMPANION 57600
|
|
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
mavlink start -d ${MAVLINK_COMPANION_DEVICE} -b 57600 -m onboard -r 5000 -x
|
2015-04-23 13:33:54 +02:00
|
|
|
fi
|
2015-06-06 22:07:23 +02:00
|
|
|
if param compare SYS_COMPANION 157600
|
2016-03-12 12:50:14 +08:00
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
mavlink start -d ${MAVLINK_COMPANION_DEVICE} -b 57600 -m osd -r 1000
|
2016-03-12 12:50:14 +08:00
|
|
|
fi
|
|
|
|
|
if param compare SYS_COMPANION 257600
|
|
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
mavlink start -d ${MAVLINK_COMPANION_DEVICE} -b 57600 -m magic -r 5000 -x
|
2016-03-12 12:50:14 +08:00
|
|
|
fi
|
2016-10-10 14:28:26 +00:00
|
|
|
if param compare SYS_COMPANION 319200
|
|
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
mavlink start -d ${MAVLINK_COMPANION_DEVICE} -b 19200 -r 1000
|
2016-10-10 14:28:26 +00:00
|
|
|
fi
|
|
|
|
|
if param compare SYS_COMPANION 338400
|
|
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
mavlink start -d ${MAVLINK_COMPANION_DEVICE} -b 38400 -r 1000
|
2016-10-10 14:28:26 +00:00
|
|
|
fi
|
2016-03-12 12:50:14 +08:00
|
|
|
if param compare SYS_COMPANION 357600
|
|
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
mavlink start -d ${MAVLINK_COMPANION_DEVICE} -b 57600 -r 1000
|
2016-03-12 12:50:14 +08:00
|
|
|
fi
|
2016-11-18 14:59:07 -05:00
|
|
|
if param compare SYS_COMPANION 419200
|
|
|
|
|
then
|
|
|
|
|
iridiumsbd start -d /dev/ttyS2
|
|
|
|
|
mavlink start -d /dev/iridium -b 19200 -m iridium -r 10
|
|
|
|
|
fi
|
2016-04-29 14:59:11 +02:00
|
|
|
if param compare SYS_COMPANION 1921600
|
|
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
mavlink start -d ${MAVLINK_COMPANION_DEVICE} -b 921600 -r 20000
|
2016-04-29 14:59:11 +02:00
|
|
|
fi
|
2016-11-10 21:39:21 -02:00
|
|
|
if param compare SYS_COMPANION 1500000
|
|
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
mavlink start -d ${MAVLINK_COMPANION_DEVICE} -b 1500000 -m onboard -r 10000 -x
|
2016-11-10 21:39:21 -02:00
|
|
|
fi
|
2016-03-12 12:50:14 +08:00
|
|
|
fi
|
|
|
|
|
|
2016-11-10 21:35:17 -02:00
|
|
|
unset MAVLINK_COMPANION_DEVICE
|
2016-10-28 17:19:42 +02:00
|
|
|
|
2015-10-03 13:50:07 +03:00
|
|
|
#
|
2016-03-28 14:48:14 +02:00
|
|
|
# Starting stuff according to UAVCAN_ENABLE value
|
2015-10-03 13:50:07 +03:00
|
|
|
#
|
2016-03-28 14:48:14 +02:00
|
|
|
if param greater UAVCAN_ENABLE 0
|
|
|
|
|
then
|
2016-12-18 11:24:11 +01:00
|
|
|
if uavcan start
|
2016-03-28 14:48:14 +02:00
|
|
|
then
|
2016-12-18 11:24:11 +01:00
|
|
|
uavcan start fw
|
2016-03-28 14:48:14 +02:00
|
|
|
else
|
2016-12-23 09:06:49 +01:00
|
|
|
tone_alarm ${TUNE_ERR}
|
2016-03-28 14:48:14 +02:00
|
|
|
fi
|
|
|
|
|
fi
|
2015-10-03 13:50:07 +03:00
|
|
|
|
2016-04-14 18:14:22 -04:00
|
|
|
#
|
|
|
|
|
# Optional drivers
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
# Sensors on the PWM interface bank
|
|
|
|
|
if param compare SENS_EN_LL40LS 1
|
|
|
|
|
then
|
|
|
|
|
if pwm_input start
|
|
|
|
|
then
|
|
|
|
|
if ll40ls start pwm
|
|
|
|
|
then
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2016-12-06 12:19:13 -05:00
|
|
|
# lightware serial lidar sensor
|
|
|
|
|
if param compare SENS_EN_SF0X 0
|
2016-04-14 18:14:22 -04:00
|
|
|
then
|
2016-12-06 12:19:13 -05:00
|
|
|
else
|
2017-01-04 10:44:08 +01:00
|
|
|
if sf0x start
|
|
|
|
|
then
|
|
|
|
|
fi
|
2016-04-14 18:14:22 -04:00
|
|
|
fi
|
|
|
|
|
|
2016-12-06 12:19:13 -05:00
|
|
|
# lightware i2c lidar sensor
|
|
|
|
|
if param compare SENS_EN_SF1XX 0
|
|
|
|
|
then
|
|
|
|
|
else
|
2017-01-04 10:44:08 +01:00
|
|
|
if sf1xx start
|
|
|
|
|
then
|
|
|
|
|
fi
|
2016-12-06 12:19:13 -05:00
|
|
|
fi
|
|
|
|
|
|
2016-07-29 16:18:27 -04:00
|
|
|
# mb12xx sonar sensor
|
|
|
|
|
if param compare SENS_EN_MB12XX 1
|
|
|
|
|
then
|
2017-01-04 10:44:08 +01:00
|
|
|
if mb12xx start
|
|
|
|
|
then
|
|
|
|
|
fi
|
2016-07-29 16:18:27 -04:00
|
|
|
fi
|
|
|
|
|
|
2016-08-26 12:03:18 +02:00
|
|
|
# teraranger one tof sensor
|
|
|
|
|
if param compare SENS_EN_TRONE 1
|
|
|
|
|
then
|
2017-01-04 10:44:08 +01:00
|
|
|
if trone start
|
|
|
|
|
then
|
|
|
|
|
fi
|
2016-08-26 12:03:18 +02:00
|
|
|
fi
|
|
|
|
|
|
2016-04-14 18:14:22 -04:00
|
|
|
if ver hwcmp PX4FMU_V4
|
|
|
|
|
then
|
|
|
|
|
frsky_telemetry start -d /dev/ttyS6
|
|
|
|
|
fi
|
|
|
|
|
|
2016-08-17 14:43:51 +08:00
|
|
|
if ver hwcmp MINDPX_V2
|
|
|
|
|
then
|
|
|
|
|
frsky_telemetry start -d /dev/ttyS6
|
|
|
|
|
fi
|
|
|
|
|
|
2016-04-14 18:14:22 -04:00
|
|
|
if ver hwcmp PX4FMU_V2
|
|
|
|
|
then
|
|
|
|
|
# Check for flow sensor - as it is a background task, launch it last
|
|
|
|
|
px4flow start &
|
|
|
|
|
fi
|
|
|
|
|
|
2016-10-25 20:31:46 +11:00
|
|
|
if ver hwcmp PX4FMU_V4
|
|
|
|
|
then
|
|
|
|
|
# Check for flow sensor - as it is a background task, launch it last
|
|
|
|
|
px4flow start &
|
|
|
|
|
fi
|
|
|
|
|
|
2016-04-14 18:14:22 -04:00
|
|
|
if ver hwcmp MINDPX_V2
|
|
|
|
|
then
|
|
|
|
|
px4flow start &
|
|
|
|
|
fi
|
|
|
|
|
|
2016-10-08 16:53:31 +02:00
|
|
|
# Start MAVLink
|
|
|
|
|
mavlink start -r 800000 -d /dev/ttyACM0 -m config -x
|
2016-04-14 18:14:22 -04:00
|
|
|
|
2016-05-15 14:28:19 +02:00
|
|
|
#
|
|
|
|
|
# Logging
|
|
|
|
|
#
|
|
|
|
|
if ver hwcmp PX4FMU_V1
|
|
|
|
|
then
|
|
|
|
|
if sdlog2 start -r 30 -a -b 2 -t
|
|
|
|
|
then
|
|
|
|
|
fi
|
|
|
|
|
else
|
2016-11-15 15:41:31 +01:00
|
|
|
if param compare SYS_LOGGER 0
|
2016-05-15 14:28:19 +02:00
|
|
|
then
|
2016-11-15 15:41:31 +01:00
|
|
|
# check if we should increase logging rate for ekf2 replay message logging
|
|
|
|
|
if param greater EKF2_REC_RPL 0
|
2016-05-15 14:28:19 +02:00
|
|
|
then
|
2016-05-22 15:17:44 +02:00
|
|
|
if sdlog2 start -r 500 -e -b 18 -t
|
2016-05-15 14:28:19 +02:00
|
|
|
then
|
|
|
|
|
fi
|
|
|
|
|
else
|
2016-11-15 15:41:31 +01:00
|
|
|
if sdlog2 start -r 100 -a -b 9 -t
|
2016-05-15 14:28:19 +02:00
|
|
|
then
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
else
|
2016-11-15 15:41:31 +01:00
|
|
|
set LOGGER_ARGS ""
|
|
|
|
|
if param compare SDLOG_MODE 1
|
|
|
|
|
then
|
|
|
|
|
set LOGGER_ARGS "-e"
|
|
|
|
|
fi
|
|
|
|
|
if param compare SDLOG_MODE 2
|
|
|
|
|
then
|
|
|
|
|
set LOGGER_ARGS "-f"
|
|
|
|
|
fi
|
2017-01-20 08:35:11 +11:00
|
|
|
if param compare SDLOG_MODE 3
|
|
|
|
|
then
|
|
|
|
|
set LOGGER_ARGS "-f"
|
|
|
|
|
fi
|
2017-01-25 14:03:57 -08:00
|
|
|
if ver hwcmp AEROFC_V1
|
|
|
|
|
then
|
|
|
|
|
set LOGGER_ARGS "-m mavlink"
|
|
|
|
|
fi
|
2016-12-23 09:06:49 +01:00
|
|
|
if logger start -b 12 -t ${LOGGER_ARGS}
|
2016-05-15 14:28:19 +02:00
|
|
|
then
|
|
|
|
|
fi
|
2016-11-15 15:41:31 +01:00
|
|
|
unset LOGGER_ARGS
|
2016-05-15 14:28:19 +02:00
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2014-03-05 10:50:16 +01:00
|
|
|
#
|
|
|
|
|
# Start up ARDrone Motor interface
|
|
|
|
|
#
|
2014-03-06 12:45:10 +01:00
|
|
|
if [ $OUTPUT_MODE == ardrone ]
|
2014-03-05 10:50:16 +01:00
|
|
|
then
|
|
|
|
|
ardrone_interface start -d /dev/ttyS1
|
|
|
|
|
fi
|
|
|
|
|
|
2014-01-10 23:14:29 +01:00
|
|
|
#
|
|
|
|
|
# Fixed wing setup
|
|
|
|
|
#
|
|
|
|
|
if [ $VEHICLE_TYPE == fw ]
|
2013-09-29 19:00:12 +02:00
|
|
|
then
|
2014-01-15 00:02:57 +01:00
|
|
|
if [ $MIXER == none ]
|
2014-01-08 20:55:12 +01:00
|
|
|
then
|
2014-01-15 00:02:57 +01:00
|
|
|
# Set default mixer for fixed wing if not defined
|
2015-01-07 00:25:06 +02:00
|
|
|
set MIXER AERT
|
2014-01-08 20:55:12 +01:00
|
|
|
fi
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2014-01-15 00:02:57 +01:00
|
|
|
if [ $MAV_TYPE == none ]
|
|
|
|
|
then
|
|
|
|
|
# Use MAV_TYPE = 1 (fixed wing) if not defined
|
|
|
|
|
set MAV_TYPE 1
|
|
|
|
|
fi
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2016-12-23 09:06:49 +01:00
|
|
|
param set MAV_TYPE ${MAV_TYPE}
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2014-01-10 23:14:29 +01:00
|
|
|
# Load mixer and configure outputs
|
2014-01-15 00:02:57 +01:00
|
|
|
sh /etc/init.d/rc.interface
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2014-01-10 23:14:29 +01:00
|
|
|
# Start standard fixedwing apps
|
2016-03-28 14:48:14 +02:00
|
|
|
sh /etc/init.d/rc.fw_apps
|
2013-09-29 19:00:12 +02:00
|
|
|
fi
|
2013-09-07 12:17:27 +02:00
|
|
|
|
2014-01-10 23:14:29 +01:00
|
|
|
#
|
|
|
|
|
# Multicopters setup
|
|
|
|
|
#
|
|
|
|
|
if [ $VEHICLE_TYPE == mc ]
|
2013-12-28 08:56:58 +01:00
|
|
|
then
|
2014-01-15 00:02:57 +01:00
|
|
|
if [ $MIXER == none ]
|
2014-01-10 13:18:34 +01:00
|
|
|
then
|
2016-09-04 20:55:03 +02:00
|
|
|
echo "Mixer undefined"
|
2014-01-15 00:02:57 +01:00
|
|
|
fi
|
2013-12-28 14:45:29 +01:00
|
|
|
|
2014-01-15 00:02:57 +01:00
|
|
|
if [ $MAV_TYPE == none ]
|
|
|
|
|
then
|
|
|
|
|
# Use mixer to detect vehicle type
|
2015-01-07 00:25:06 +02:00
|
|
|
if [ $MIXER == quad_x -o $MIXER == quad_+ ]
|
2014-02-10 15:12:32 +01:00
|
|
|
then
|
|
|
|
|
set MAV_TYPE 2
|
|
|
|
|
fi
|
2016-12-18 01:46:59 +01:00
|
|
|
if [ $MIXER == quad_w -o $MIXER == quad_dc ]
|
2014-02-10 15:12:32 +01:00
|
|
|
then
|
|
|
|
|
set MAV_TYPE 2
|
|
|
|
|
fi
|
2016-02-15 15:58:01 +01:00
|
|
|
if [ $MIXER == quad_h ]
|
|
|
|
|
then
|
|
|
|
|
set MAV_TYPE 2
|
|
|
|
|
fi
|
2015-02-05 23:23:41 -08:00
|
|
|
if [ $MIXER == tri_y_yaw- -o $MIXER == tri_y_yaw+ ]
|
|
|
|
|
then
|
2015-08-01 09:49:53 +02:00
|
|
|
set MAV_TYPE 15
|
2015-02-05 23:23:41 -08:00
|
|
|
fi
|
2015-01-07 00:25:06 +02:00
|
|
|
if [ $MIXER == hexa_x -o $MIXER == hexa_+ ]
|
2014-02-11 15:35:26 +01:00
|
|
|
then
|
2014-02-11 08:09:51 +01:00
|
|
|
set MAV_TYPE 13
|
|
|
|
|
fi
|
2015-01-07 00:25:06 +02:00
|
|
|
if [ $MIXER == hexa_cox ]
|
2014-01-15 00:02:57 +01:00
|
|
|
then
|
2014-01-19 10:45:38 +01:00
|
|
|
set MAV_TYPE 13
|
2014-01-15 00:02:57 +01:00
|
|
|
fi
|
2015-01-07 00:25:06 +02:00
|
|
|
if [ $MIXER == octo_x -o $MIXER == octo_+ ]
|
2014-01-15 00:02:57 +01:00
|
|
|
then
|
2014-01-19 10:45:38 +01:00
|
|
|
set MAV_TYPE 14
|
2014-01-15 00:02:57 +01:00
|
|
|
fi
|
2016-01-03 22:05:56 +01:00
|
|
|
if [ $MIXER == octo_cox -o $MIXER == octo_cox_w ]
|
2014-01-15 00:02:57 +01:00
|
|
|
then
|
2014-01-19 10:45:38 +01:00
|
|
|
set MAV_TYPE 14
|
2014-01-15 00:02:57 +01:00
|
|
|
fi
|
2016-05-20 10:06:04 +02:00
|
|
|
if [ $MIXER == coax ]
|
|
|
|
|
then
|
|
|
|
|
set MAV_TYPE 3
|
|
|
|
|
fi
|
2014-01-10 13:18:34 +01:00
|
|
|
fi
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2014-02-10 15:12:32 +01:00
|
|
|
# Still no MAV_TYPE found
|
|
|
|
|
if [ $MAV_TYPE == none ]
|
|
|
|
|
then
|
2016-09-04 20:55:03 +02:00
|
|
|
echo "Unknown MAV_TYPE"
|
2015-08-01 09:49:53 +02:00
|
|
|
param set MAV_TYPE 2
|
2014-02-10 15:12:32 +01:00
|
|
|
else
|
2016-12-23 09:06:49 +01:00
|
|
|
param set MAV_TYPE ${MAV_TYPE}
|
2014-02-10 15:12:32 +01:00
|
|
|
fi
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2014-01-10 23:14:29 +01:00
|
|
|
# Load mixer and configure outputs
|
2014-01-15 00:02:57 +01:00
|
|
|
sh /etc/init.d/rc.interface
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2014-01-10 23:14:29 +01:00
|
|
|
# Start standard multicopter apps
|
2016-03-28 14:48:14 +02:00
|
|
|
sh /etc/init.d/rc.mc_apps
|
2013-09-07 12:17:27 +02:00
|
|
|
fi
|
2013-12-01 07:57:22 +11:00
|
|
|
|
2014-12-02 10:30:26 +01:00
|
|
|
#
|
|
|
|
|
# VTOL setup
|
|
|
|
|
#
|
|
|
|
|
if [ $VEHICLE_TYPE == vtol ]
|
|
|
|
|
then
|
|
|
|
|
if [ $MIXER == none ]
|
|
|
|
|
then
|
2016-09-04 20:55:03 +02:00
|
|
|
echo "VTOL mixer undefined"
|
2014-12-02 10:30:26 +01:00
|
|
|
fi
|
2013-12-01 07:57:22 +11:00
|
|
|
|
2014-12-02 10:30:26 +01:00
|
|
|
if [ $MAV_TYPE == none ]
|
|
|
|
|
then
|
|
|
|
|
# Use mixer to detect vehicle type
|
2015-01-07 00:25:06 +02:00
|
|
|
if [ $MIXER == caipirinha_vtol ]
|
2014-12-02 10:30:26 +01:00
|
|
|
then
|
2014-12-02 11:02:23 +01:00
|
|
|
set MAV_TYPE 19
|
2014-12-02 10:30:26 +01:00
|
|
|
fi
|
2015-04-20 17:09:09 +02:00
|
|
|
if [ $MIXER == firefly6 ]
|
2015-01-05 20:52:18 +01:00
|
|
|
then
|
|
|
|
|
set MAV_TYPE 21
|
|
|
|
|
fi
|
2015-08-05 18:03:44 +02:00
|
|
|
if [ $MIXER == quad_x_pusher_vtol ]
|
|
|
|
|
then
|
|
|
|
|
set MAV_TYPE 22
|
|
|
|
|
fi
|
2014-12-02 10:30:26 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Still no MAV_TYPE found
|
|
|
|
|
if [ $MAV_TYPE == none ]
|
|
|
|
|
then
|
2016-09-04 20:55:03 +02:00
|
|
|
echo "Unknown MAV_TYPE"
|
2015-08-01 09:49:53 +02:00
|
|
|
param set MAV_TYPE 19
|
2014-12-02 10:30:26 +01:00
|
|
|
else
|
2016-12-23 09:06:49 +01:00
|
|
|
param set MAV_TYPE ${MAV_TYPE}
|
2014-12-02 10:30:26 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Load mixer and configure outputs
|
|
|
|
|
sh /etc/init.d/rc.interface
|
|
|
|
|
|
|
|
|
|
# Start standard vtol apps
|
2016-03-28 14:48:14 +02:00
|
|
|
sh /etc/init.d/rc.vtol_apps
|
2014-12-02 10:30:26 +01:00
|
|
|
fi
|
2015-02-19 21:50:54 +01:00
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Rover setup
|
|
|
|
|
#
|
|
|
|
|
if [ $VEHICLE_TYPE == rover ]
|
2015-02-20 14:43:28 +01:00
|
|
|
then
|
2015-02-19 21:50:54 +01:00
|
|
|
# 10 is MAV_TYPE_GROUND_ROVER
|
|
|
|
|
set MAV_TYPE 10
|
|
|
|
|
|
|
|
|
|
# Load mixer and configure outputs
|
|
|
|
|
sh /etc/init.d/rc.interface
|
|
|
|
|
|
|
|
|
|
# Start standard rover apps
|
2016-03-28 14:48:14 +02:00
|
|
|
sh /etc/init.d/rc.axialracing_ax10_apps
|
2015-08-01 09:49:53 +02:00
|
|
|
|
|
|
|
|
param set MAV_TYPE 10
|
2015-02-19 21:50:54 +01:00
|
|
|
fi
|
|
|
|
|
|
2016-03-24 22:31:47 +01:00
|
|
|
#
|
|
|
|
|
# For snapdragon, we need a passthrough mode
|
|
|
|
|
# Do not run any mavlink instances since we need the serial port for
|
|
|
|
|
# communication with Snapdragon.
|
|
|
|
|
#
|
|
|
|
|
if [ $VEHICLE_TYPE == passthrough ]
|
|
|
|
|
then
|
|
|
|
|
mavlink stop-all
|
2016-04-21 18:07:08 +02:00
|
|
|
commander stop
|
2016-03-24 22:31:47 +01:00
|
|
|
|
|
|
|
|
# Stop multicopter attitude controller if it is running, the controls come
|
|
|
|
|
# from Snapdragon.
|
|
|
|
|
if mc_att_control stop
|
|
|
|
|
then
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Start snapdragon interface on serial port.
|
|
|
|
|
if ver hwcmp PX4FMU_V2
|
|
|
|
|
then
|
|
|
|
|
# On Pixfalcon use the standard telemetry port (Telem 1).
|
|
|
|
|
snapdragon_rc_pwm start -d /dev/ttyS1
|
|
|
|
|
px4io start
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if ver hwcmp PX4FMU_V4
|
|
|
|
|
then
|
|
|
|
|
# On Pixracer use Telem 2 port (TL2).
|
|
|
|
|
snapdragon_rc_pwm start -d /dev/ttyS2
|
|
|
|
|
fmu mode_pwm4
|
|
|
|
|
fi
|
|
|
|
|
|
2016-04-21 12:52:51 +02:00
|
|
|
pwm failsafe -c 1234 -p 900
|
2016-04-25 13:49:08 +02:00
|
|
|
pwm disarmed -c 1234 -p 900
|
2016-04-21 12:52:51 +02:00
|
|
|
|
2016-03-24 22:31:47 +01:00
|
|
|
# Arm straightaway.
|
|
|
|
|
pwm arm
|
2016-03-27 10:40:49 +02:00
|
|
|
# Use 400 Hz PWM on all channels.
|
|
|
|
|
pwm rate -a -r 400
|
2016-03-24 22:31:47 +01:00
|
|
|
fi
|
|
|
|
|
|
2015-01-08 15:42:25 +01:00
|
|
|
unset MIXER
|
|
|
|
|
unset MAV_TYPE
|
|
|
|
|
unset OUTPUT_MODE
|
2014-12-15 22:47:10 +01:00
|
|
|
|
2014-05-13 08:03:01 +02:00
|
|
|
#
|
|
|
|
|
# Start the navigator
|
|
|
|
|
#
|
|
|
|
|
navigator start
|
|
|
|
|
|
2014-01-10 23:14:29 +01:00
|
|
|
#
|
|
|
|
|
# Generic setup (autostart ID not found)
|
|
|
|
|
#
|
|
|
|
|
if [ $VEHICLE_TYPE == none ]
|
2013-08-25 19:33:36 +02:00
|
|
|
then
|
2016-09-04 20:55:03 +02:00
|
|
|
echo "No autostart ID found"
|
2013-08-25 19:33:36 +02:00
|
|
|
fi
|
2014-01-10 23:14:29 +01:00
|
|
|
|
|
|
|
|
# Start any custom addons
|
2015-01-08 15:42:25 +01:00
|
|
|
set FEXTRAS /fs/microsd/etc/extras.txt
|
2014-11-17 14:58:29 +01:00
|
|
|
if [ -f $FEXTRAS ]
|
2013-08-25 19:27:11 +02:00
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
echo "Addons script: ${FEXTRAS}"
|
2014-11-17 14:58:29 +01:00
|
|
|
sh $FEXTRAS
|
2013-08-22 09:25:13 +02:00
|
|
|
fi
|
2014-11-17 14:58:29 +01:00
|
|
|
unset FEXTRAS
|
2013-09-03 08:17:22 +02:00
|
|
|
|
2016-09-11 22:06:10 -04:00
|
|
|
if ver hwcmp CRAZYFLIE
|
2014-12-15 15:34:19 +01:00
|
|
|
then
|
2016-09-11 22:06:10 -04:00
|
|
|
# CF2 shouldn't have an sd card
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
# Run no SD alarm
|
|
|
|
|
if [ $LOG_FILE == /dev/null ]
|
|
|
|
|
then
|
|
|
|
|
# Play SOS
|
|
|
|
|
tone_alarm error
|
|
|
|
|
fi
|
|
|
|
|
|
2016-09-17 12:10:14 -04:00
|
|
|
fi
|
2013-12-28 22:18:07 +01:00
|
|
|
|
2017-02-02 20:34:15 +11:00
|
|
|
#
|
|
|
|
|
# Check if we should start a thermal calibration
|
|
|
|
|
# TODO move further up and don't start unnecessary services if we are calibrating
|
|
|
|
|
#
|
|
|
|
|
if param compare SYS_CAL_GYRO 1
|
|
|
|
|
then
|
|
|
|
|
send_event start_temp_gyro_cal
|
|
|
|
|
param set SYS_CAL_GYRO 0
|
|
|
|
|
fi
|
|
|
|
|
if param compare SYS_CAL_ACCEL 1
|
|
|
|
|
then
|
|
|
|
|
send_event start_temp_accel_cal
|
|
|
|
|
param set SYS_CAL_ACCEL 0
|
|
|
|
|
fi
|
|
|
|
|
if param compare SYS_CAL_BARO 1
|
|
|
|
|
then
|
|
|
|
|
send_event start_temp_baro_cal
|
|
|
|
|
param set SYS_CAL_BARO 0
|
|
|
|
|
fi
|
|
|
|
|
|
2015-08-08 00:10:01 +02:00
|
|
|
# End of autostart
|
|
|
|
|
fi
|
2015-07-22 10:04:13 +02:00
|
|
|
|
2015-08-10 22:26:09 +02:00
|
|
|
# There is no further script processing, so we can free some RAM
|
|
|
|
|
# XXX potentially unset all script variables.
|
|
|
|
|
unset TUNE_ERR
|
|
|
|
|
|
2015-08-08 00:10:01 +02:00
|
|
|
# Boot is complete, inform MAVLink app(s) that the system is now fully up and running
|
|
|
|
|
mavlink boot_complete
|
2015-08-06 00:12:14 +02:00
|
|
|
|
2015-08-08 00:10:01 +02:00
|
|
|
if [ $EXIT_ON_END == yes ]
|
|
|
|
|
then
|
2016-09-04 20:55:03 +02:00
|
|
|
echo "NSH exit"
|
2015-08-08 00:10:01 +02:00
|
|
|
exit
|
2013-08-02 15:47:04 +02:00
|
|
|
fi
|
2015-08-08 00:10:01 +02:00
|
|
|
unset EXIT_ON_END
|