Px4+gazebo+ros2+QGC实现轨迹跟踪仿真

本次教程是我走了很多弯路摸索出来的,如果和我一样使用的是Ubuntu22.04版本的话应该不会有什么问题,其他版本的ubuntu可能会有版本不兼容的问题,仅供参考

下图是本次环境配置的构架图,以PX4为中心来实现Ubuntu中的无人机轨迹跟踪仿真

Px4+gazebo+ros2+QGC实现轨迹跟踪仿真_第1张图片

一、gazebo仿真环境搭建与px4的编译


这里我使用的Ubuntu版本是22.04,安装的是较新的gazebo garden,不是传统的gazebo classic,gazebo classic容易出现无人机显示不出来的问题。接下来是安装步骤:
1、添加软件源:

sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null

2、添加密钥

wget https://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -

3、更新软件包并安装gazebo garden

sudo apt update
sudo apt install gz-garden


4、克隆px4源码,并进入文件夹(网络问题欢迎私信咨询)

git clone --branch v1.14.0 https://github.com/PX4/PX4-Autopilot.git --recursive
cd PX4-Autopilot

5、用gazebo garden编译

make px4_sitl gz_x500


二、安装QGoundControl地面站

1、安装相关的依赖项(可能需要重启来启用用户权限的更改)

sudo usermod -a -G dialout $USER
sudo apt-get remove modemmanager -y
sudo apt install gstreamer1.0-plugins-bad gstreamer1.0-libav gstreamer1.0-gl -y
sudo apt install libfuse2 -y
sudo apt install libxcb-xinerama0 libxkbcommon-x11-0 libxcb-cursor-dev -y

2、下载QGroundControl.AppImage

点击链接下载:QGroundControl.AppImage

3、授权并运行(QGC会自动与PX4连接)

chmod +x ./QGroundControl.AppImage
./QGroundControl.AppImage

三、安装ROS2

1、设置区域设置

locale  # check for UTF-8

sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8

locale  # verify settings

2、设置源

首先确保Ubuntu Universe已启用

你可能感兴趣的:(ubuntu,无人机,目标跟踪)