*建议早上安装 *
1.下载以往版本
从github上clone源码
git clone https://github.com/PX4/PX4-Autopilot.git
进入PX4-Autopilot文件夹
cd PX4-Autopilot
查看当前分支,位于origin/main
git status
查看所有远程分支,带release的
git branch -r | grep "release"
切换到发行分支v1.12
git checkout origin/release/1.12
更新子模块
git submodule update --init --recursive
查看当前分支,位于release/1.12
git status
2.下载mian版本
git clone https://github.com/PX4/PX4-Autopilot.git --recursive
进入PX4-Autopilot文件夹,继续下载未下载完的组件
cd PX4-Autopilotgit submodule update --init --recursive
3.回到主目录,安装px4
bash ./PX4-Autopilot/Tools/setup/ubuntu.sh
出错执行指令
python3 -m pip install --upgrade pippython3 -m pip install --upgrade Pillow
再bash一下
bash ./PX4-Autopilot/Tools/setup/ubuntu.sh --fix-missing
4.添加环境变量
sudo gedit ~/.bashrc
加在文件末尾(注意要和自己的下载路径一致)
注:我在PX4_Firmware中下载的PX4,主目录下载不用加PX4_Firmware,删掉即可(有5处要修改!!!)
source ~/PX4_Firmware/PX4-Autopilot/Tools/setup_gazebo.bash ~/PX4_Firmware/PX4-Autopilot ~/PX4_Firmware/PX4-Autopilot/build/px4_sitl_defaultexport ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:~/PX4_Firmware/PX4-Autopilotexport ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/PX4_Firmware/PX4-Autopilot/Tools/sitl_gazebo
source一下
source ~/.bashrc
测试(要打开QGC)
5.测试(要打开QGC)
cd PX4-Autopilot
make px4_sitl_default gazebo
终端输入 commander takeoff ,可以看到无人机起飞
终端输入 commander land , 可以看到无人机降落
6.安装QGC
sudo usermod -a -G dialout $USERsudo apt-get remove modemmanager -ysudo apt install gstreamer1.0-plugins-bad gstreamer1.0-libav gstreamer1.0-gl -ysudo apt install libqt5gui5 -ysudo apt install libfuse2 -y
QGroundControl.AppImage
chmod +x ./QGroundControl.AppImage./QGroundControl.AppImage (or double click)
7.安装MAVROS
sudo apt-get install ros-noetic-mavros ros-noetic-mavros-extras ros-noetic-mavros-msgswget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.shsudo chmod a+x ./install_geographiclib_datasets.shsudo ./install_geographiclib_datasets.sh
若wget连接不上则执行以下操作
sudo gedit /etc/hosts
红框内为raw.githubusercontent.com最新地址
IP查询
测试MAVROS
roslaunch mavros px4.launch fcu_url:="udp://:14540@127.0.0.1:14557"
没有报错则说明安装成功