2013-04-26 20:14:32 -03:00
|
|
|
#!nsh
|
2013-07-15 08:58:43 -03:00
|
|
|
#
|
|
|
|
# Flight startup script for PX4FMU+PX4IO
|
|
|
|
#
|
2013-04-26 20:14:32 -03:00
|
|
|
|
2013-07-15 08:58:43 -03:00
|
|
|
# disable USB and autostart
|
2013-04-26 20:14:32 -03:00
|
|
|
set USB no
|
2013-07-15 08:58:43 -03:00
|
|
|
set MODE custom
|
2013-04-26 20:14:32 -03:00
|
|
|
|
|
|
|
#
|
2013-04-18 10:53:25 -03:00
|
|
|
# Start the ORB (first app to start)
|
2013-04-26 20:14:32 -03:00
|
|
|
#
|
|
|
|
uorb start
|
|
|
|
|
|
|
|
#
|
|
|
|
# Load microSD params
|
|
|
|
#
|
|
|
|
echo "[init] loading microSD params"
|
2013-05-13 05:26:42 -03:00
|
|
|
param select /fs/microsd/params
|
|
|
|
if [ -f /fs/microsd/params ]
|
2013-04-26 20:14:32 -03:00
|
|
|
then
|
2013-05-13 05:26:42 -03:00
|
|
|
param load /fs/microsd/params
|
2013-04-26 20:14:32 -03:00
|
|
|
fi
|
2013-07-15 08:58:43 -03:00
|
|
|
|
|
|
|
#
|
|
|
|
# Load default params for this platform
|
|
|
|
#
|
|
|
|
if param compare SYS_AUTOCONFIG 1
|
|
|
|
then
|
|
|
|
# Set all params here, then disable autoconfig
|
|
|
|
param set SYS_AUTOCONFIG 0
|
2013-07-15 09:03:39 -03:00
|
|
|
param save /fs/microsd/params
|
2013-07-15 08:58:43 -03:00
|
|
|
fi
|
2013-04-26 20:14:32 -03:00
|
|
|
|
|
|
|
#
|
|
|
|
# Force some key parameters to sane values
|
|
|
|
# MAV_TYPE 1 = fixed wing, 2 = quadrotor, 13 = hexarotor
|
|
|
|
# see https://pixhawk.ethz.ch/mavlink/
|
|
|
|
#
|
|
|
|
param set MAV_TYPE 1
|
|
|
|
|
|
|
|
#
|
2013-04-18 10:53:25 -03:00
|
|
|
# Check if PX4IO Firmware should be upgraded (from Andrew Tridgell)
|
2013-04-26 20:14:32 -03:00
|
|
|
#
|
2013-04-18 10:53:25 -03:00
|
|
|
if [ -f /fs/microsd/px4io.bin ]
|
|
|
|
then
|
|
|
|
echo "PX4IO Firmware found. Checking Upgrade.."
|
|
|
|
if cmp /fs/microsd/px4io.bin /fs/microsd/px4io.bin.current
|
|
|
|
then
|
|
|
|
echo "No newer version, skipping upgrade."
|
|
|
|
else
|
|
|
|
echo "Loading /fs/microsd/px4io.bin"
|
|
|
|
if px4io update /fs/microsd/px4io.bin > /fs/microsd/px4io_update.log
|
|
|
|
then
|
|
|
|
cp /fs/microsd/px4io.bin /fs/microsd/px4io.bin.current
|
|
|
|
echo "Flashed /fs/microsd/px4io.bin OK" >> /fs/microsd/px4io_update.log
|
|
|
|
else
|
|
|
|
echo "Failed flashing /fs/microsd/px4io.bin" >> /fs/microsd/px4io_update.log
|
|
|
|
echo "Failed to upgrade PX4IO firmware - check if PX4IO is in bootloader mode"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
2013-04-26 20:14:32 -03:00
|
|
|
|
|
|
|
#
|
2013-04-18 10:53:25 -03:00
|
|
|
# Start MAVLink (depends on orb)
|
2013-04-26 20:14:32 -03:00
|
|
|
#
|
|
|
|
mavlink start -d /dev/ttyS1 -b 57600
|
|
|
|
usleep 5000
|
|
|
|
|
|
|
|
#
|
2013-04-18 10:53:25 -03:00
|
|
|
# Start the commander (depends on orb, mavlink)
|
2013-04-26 20:14:32 -03:00
|
|
|
#
|
|
|
|
commander start
|
|
|
|
|
|
|
|
#
|
2013-04-18 10:53:25 -03:00
|
|
|
# Start PX4IO interface (depends on orb, commander)
|
2013-04-26 20:14:32 -03:00
|
|
|
#
|
2013-04-18 10:53:25 -03:00
|
|
|
px4io start
|
2013-02-17 13:11:33 -04:00
|
|
|
|
2012-08-04 19:12:36 -03:00
|
|
|
#
|
2013-04-18 10:53:25 -03:00
|
|
|
# Allow PX4IO to recover from midair restarts.
|
|
|
|
# this is very unlikely, but quite safe and robust.
|
|
|
|
px4io recovery
|
2013-07-15 08:58:43 -03:00
|
|
|
|
|
|
|
#
|
|
|
|
# Set actuator limit to 100 Hz update (50 Hz PWM)
|
|
|
|
px4io limit 100
|
2013-04-26 20:14:32 -03:00
|
|
|
|
|
|
|
#
|
2013-04-18 10:53:25 -03:00
|
|
|
# Start the sensors (depends on orb, px4io)
|
2013-04-26 20:14:32 -03:00
|
|
|
#
|
2013-04-18 10:53:25 -03:00
|
|
|
sh /etc/init.d/rc.sensors
|
2013-04-26 20:14:32 -03:00
|
|
|
|
|
|
|
#
|
2013-04-18 10:53:25 -03:00
|
|
|
# Start GPS interface (depends on orb)
|
2013-04-26 20:14:32 -03:00
|
|
|
#
|
2013-04-18 10:53:25 -03:00
|
|
|
gps start
|
|
|
|
|
|
|
|
#
|
|
|
|
# Start the attitude estimator (depends on orb)
|
|
|
|
#
|
|
|
|
kalman_demo start
|
2013-04-26 20:14:32 -03:00
|
|
|
|
|
|
|
#
|
2013-04-18 10:53:25 -03:00
|
|
|
# Load mixer and start controllers (depends on px4io)
|
2013-04-26 20:14:32 -03:00
|
|
|
#
|
|
|
|
mixer load /dev/pwm_output /etc/mixers/FMU_Q.mix
|
|
|
|
control_demo start
|
|
|
|
|
|
|
|
#
|
|
|
|
# Start logging
|
|
|
|
#
|
2013-07-15 08:58:43 -03:00
|
|
|
sdlog2 start -r 50 -a -b 14
|
2013-04-18 10:53:25 -03:00
|
|
|
|
2013-04-26 20:14:32 -03:00
|
|
|
#
|
|
|
|
# Start system state
|
|
|
|
#
|
|
|
|
if blinkm start
|
|
|
|
then
|
|
|
|
blinkm systemstate
|
|
|
|
fi
|