PX4默认使用的EKF配置为融合GPS的水平位置与气压计高度。如果我们想使用视觉定位,就需要把修改配置文件。让EKF融合来自mavros/vision_pose/pose的数据
gedit ~/PX4_Firmware/ROMFS/px4fmu_common/init.d-posix/rcS
?通过注释来修改不同的参数
# 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
重启仿真前,需要删除上一次记录在虚拟eeprom中的参数文件,否则仿真程序会读取该参数文件,导致本次rcS的修改不能生效
rm ~/.ros/eeprom/parameters*
rm -rf ~/.ros/sitl*
安装依赖:
sudo apt-get install liblapack-dev libsuitesparse-dev libcxsparse3 libgflags-dev libgoogle-glog-dev libgtest-dev
下载编译ceres1.14.0
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
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
roslaunch px4 indoor1.launch
cd ~/catkin_ws
bash scripts/xtdrone_run_vio.sh
由于VINS-Fusion发布的是Odometry类型的话题,我们要将其对应转为PX4所需的话题
cd ~/XTDrone/sensing/slam/vio
python vins_transfer.py iris 0
然后建立通信,键盘控制起飞即可
cd ~/XTDrone/communication
python multirotor_communication.py iris 0
cd ~/XTDrone/control/keyboard
python multirotor_keyboard_control.py iris 1 vel
效果: