v1.8.2
@[TOC]PX4的启动控制逻辑:
(1)启动程序分析
启动脚本的位置在Firmware\ROMFS\px4fmu_common\init.d\rcS文件中。打开文件,找到对应的机架模型即可
如果是VTOL模式,则找到对应的这个机架即可
#
# VTOL setup
#
if [ $VEHICLE_TYPE == vtol ]
then
if [ $MIXER == none ]
then
echo "VTOL mixer undefined"
fi
if [ $MAV_TYPE == none ]
then
# Use mixer to detect vehicle type
if [ $MIXER == caipirinha_vtol ]
then
set MAV_TYPE 19
fi
if [ $MIXER == firefly6 ]
then
set MAV_TYPE 21
fi
if [ $MIXER == quad_x_pusher_vtol ]
then
set MAV_TYPE 22
fi
fi
# Still no MAV_TYPE found
if [ $MAV_TYPE == none ]
then
echo "Unknown MAV_TYPE"
param set MAV_TYPE 19
else
param set MAV_TYPE ${MAV_TYPE}
fi
# Load mixer and configure outputs
sh /etc/init.d/rc.interface
# Start standard vtol apps
sh /etc/init.d/rc.vtol_apps
fi
MIXER为对应的混控器,在\Firmware\ROMFS\px4fmu_common\mixers文件夹中,rc.interface为加载混控器和PWM输出,rc.vtol_app为VTOL模式下运行的程序。在Firmware\ROMFS\px4fmu_common\init.d中找到该文件,看看需要启动哪些程序
#!nsh
#
# Standard apps for vtol:
# att & pos estimator, att & pos control.
#
#
#---------------------------------------
# Estimator group selction
#
# INAV (deprecated)
if param compare SYS_MC_EST_GROUP 0
then
echo "ERROR [init] Estimator INAV deprecated. Using EKF2"
param set SYS_MC_EST_GROUP 2
param save
fi
# LPE
if param compare SYS_MC_EST_GROUP 1
then
# Try to start LPE. If it fails, start EKF2 as a default
# Unfortunately we do not build it on px4fmu-v2 due to a limited flash.
if attitude_estimator_q start
then
local_position_estimator start
else
echo "ERROR [init] Estimator LPE not available. Using EKF2"
param set SYS_MC_EST_GROUP 2
param save
fi
fi
# EKF
if param compare SYS_MC_EST_GROUP 2
then
ekf2 start
fi
#---------------------------------------
vtol_att_control start
mc_att_control start
mc_pos_control start
fw_att_control start
fw_pos_control_l1 start
#
# Start Land Detector
# Multicopter for now until we have something for VTOL
#
land_detector start vtol
#
# Start Wind and Airspeed Scale Estimator
#
#wind_estimator start
其中主要的控制程序文件路径在**\Firmware\src\modules**中,包含以下程序:
vtol_att_control start
mc_att_control start
mc_pos_control start
fw_att_control start
fw_pos_control_l1 start
-------未完待续
参考: PX4启动脚本分析.