专栏/Ubuntu20.04+MAVROS+PX4+Gazebo保姆级安装教程

Ubuntu20.04+MAVROS+PX4+Gazebo保姆级安装教程

2023年04月10日 05:19--浏览 · --点赞 · --评论
粉丝:2044文章:4

Ubuntu20.04+MAVROS+PX4+Gazebo

  • 1、安装PX4步骤

  • 2、安装MAVROS

  • 3、安装QGC

  • 4、PX4仿真

1、安装PX4步骤

从github上clone源码

git clone https://github.com/PX4/PX4-Autopilot.git --recursive

进入PX4-Autopilot文件夹,继续下载未下载完的组件

cd PX4-Autopilot/
git submodule update --init --recursive

继续执行ubuntu.sh脚本

bash ./PX4-Autopilot/Tools/setup/ubuntu.sh

中间出错的话执行指令

python3 -m pip install --upgrade pip
python3 -m pip install --upgrade Pillow

如果过程中有安装失败的地方,可以再用以下命令更新一下,:

bash ./PX4-Autopilot/Tools/setup/ubuntu.sh --fix-missing

完成后重启系统

测试:
进入你下载的PX4-Autopilot文件夹内,执行以下命令

make px4_sitl_default gazebo

终端输入 commander takeoff ,可以看到无人机起飞
终端输入 commander land , 可以看到无人机降落

无人机起飞降落测试

添加环境变量(针对Ubuntu20.04)

source ~/PX4-Autopilot/Tools/simulation/gazebo-classic/setup_gazebo.bash ~/PX4-Autopilot ~/PX4-Autopilot/build/px4_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/PX4-Autopilot
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic


2、安装MAVROS

sudo apt-get install ros-noetic-mavros ros-noetic-mavros-extras

运行以下命令测试mavros是否安装成功

roslaunch mavros px4.launch

如果出现以下报错

运行mavros报错

则运行

sudo /opt/ros/kinetic/lib/mavros/install_geographiclib_datasets.sh

3、安装QGC

参考网站:https://docs.qgroundcontrol.com/master/en/getting_started/download_and_install.html

4、PX4仿真

添加完环境变量后,可以通过以下命令进行PX4仿真

roslaunch px4 mavros_posix_sitl.launch

该launch文件会启动gazebo、mavros、px4.launch等

gazebo-px4仿真

查看mavros话题

rostopic list
mavros话题


投诉或建议