ros2-px4联合仿真环境配置

ROS2 安装以及相关环境配置

推荐使用鱼香ROS一键安装

1
wget http://fishros.com/install -O fishros && . fishros

按照文字提示操作

1
2
3
4
sudo apt install python3-pip
sudo apt install git

pip3 install empy==3.3.4 # 固定empy版本为3.3.4

PX4环境配置

下载PX4代码及其子模块

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

再次确认是否下载完全

1
2
3
cd PX4-Autopilot

git submodule update --init –recursive

安装完成后可以查看飞控代码版本

1
2
cd PX4-Autopilot/
git describe --tags

我选择切换到了1.16稳定版来开发,这个可选可不选

1
2
3
git fetch --tags
git checkout v1.16.0
git submodule update --init --recursive

使用PX4脚本自动部署

1
bash ./Tools/setup/ubuntu.sh

运行仿真

1
make px4_sitl gz_x500

PX4-gazebo
PX4-GAZEBO

控制台报错是因为没有连上地面站

1
WARN  [health_and_arming_checks] Preflight Fail: No connection to the ground control station

QGC地面站安装

QGC下载地址:https://github.com/mavlink/qgroundcontrol/releases

ubuntu下载 AppImage

1
2
chmod +x ./QGroundControl-x86_64.AppImage
./QGroundControl-x86_64.AppImage

安装 XRCE_DDS

1
git clone https://github.com/eProsima/Micro-XRCE-DDS-Agent.git
1
2
cd Micro-XRCE-DDS-Agent/
git describe --tags

注意根据PX4飞控版本来安装对应版本的XRCE_DDS,这里PX4版本是1.16,安装3.01

编译

1
2
3
4
5
6
mkdir build
cd build
cmake ..
make
sudo make install
sudo ldconfig /usr/local/lib/

仿真初步配置已完成,后续更新进一步的操作