一、PX4飞控EKF配置
PX4默认使用的EKF配置为融合GPS的水平位置与气压计高度。如果我们想使用视觉定位,就需要把修改配置文件。让EKF融合来自mavros/vision_pose/pose的数据
1.1修改rcS配置文件
bash
gedit ~/PX4_Firmware/ROMFS/px4fmu_common/init.d-posix/rcS
通过注释来修改不同的参数
cpp
# GPS used
#param set EKF2_AID_MASK 1
# Vision used and GPS denied
param set EKF2_AID_MASK 24
# Barometer used for hight measurement
#param set EKF2_HGT_MODE 0
# Barometer denied and vision used for hight measurement
param set EKF2_HGT_MODE 3
1.2删除参数文件
重启仿真前,需要删除上一次记录在虚拟eeprom中的参数文件,否则仿真程序会读取该参数文件,导致本次rcS的修改不能生效
bash
rm ~/.ros/eeprom/parameters*
rm -rf ~/.ros/sitl*
二、编译VINS-Fusion
2.1安装ceres
安装依赖:
bash
sudo apt-get install liblapack-dev libsuitesparse-dev libcxsparse3 libgflags-dev libgoogle-glog-dev libgtest-dev
下载编译ceres1.14.0
bash
wget ceres-solver.org/ceres-solver-1.14.0.tar.gz
tar -zxvf ceres-solver-1.14.0.tar.gz
cd ceres-solver-1.14.0/
mkdir build
cd build/
cmake ..
make
sudo make install
2.2编译vins-fusion
bash
cp -r ~/XTDrone/sensing/slam/vio/VINS-Fusion ~/catkin_ws/src/
mkdir ~/catkin_ws/scripts/
cp ~/XTDrone/sensing/slam/vio/xtdrone_run_vio.sh ~/catkin_ws/scripts/
cd ~/catkin_ws
catkin build
三、启动仿真
3.1 打开仿真环境
bash
roslaunch px4 indoor1.launch
3.2运行vins-fusion
bash
cd ~/catkin_ws
bash scripts/xtdrone_run_vio.sh
3.3修改话题
由于VINS-Fusion发布的是Odometry类型的话题,我们要将其对应转为PX4所需的话题
bash
cd ~/XTDrone/sensing/slam/vio
python vins_transfer.py iris 0
3.4建立通信
然后建立通信,键盘控制起飞即可
bash
cd ~/XTDrone/communication
python multirotor_communication.py iris 0
bash
cd ~/XTDrone/control/keyboard
python multirotor_keyboard_control.py iris 1 vel
效果: