ROS(5)PX4仿真安装及运行

1、配置,提升下载速度

启动

  • $ cd clash-for-linux
  • $ sudo bash start.sh
  • $ source /etc/profile.d/clash.sh
  • $ proxy_on

关闭

  • $ cd clash-for-linux
  • $ sudo bash shutdown.sh
  • $ proxy_off

2、安装PX4开源无人机

bash 复制代码
git clone https://github.com/PX4/PX4-Autopilot.git --recursive

在PX4根目录执行

安装时如果下载较慢,则需要加快下载速度

bash 复制代码
bash ./PX4-Autopilot/Tools/setup/ubuntu.sh --no-sim-tools --no-nuttx
bash 复制代码
sudo apt-get install protobuf-compiler libeigen3-dev libopencv-dev -y

如果有安装失败的情况,执行

复制代码
python3 -m pip install --upgrade pip

python3 -m pip install --upgrade Pillow
bash 复制代码
bash ./PX4-Autopilot/Tools/setup/ubuntu.sh --fix-missing

更新并重启系统

**注意:下方命令为继续下载未下载完的组件,如在github执行clone时出错可执行命令

复制代码
git submodule update --init --recursive

打开gazebo

重启后

make distclean

打开gazebo

make px4_sitl_default gazebo

加载px4 v3部件

加载px4 v3部件

make px4_fmu-v3_default

**报错:arm-none-eabi-gcc

sudo apt-get install gcc-arm-none-eabi

3、利用ros查看无人机飞行

  • cd PX4-Autopilot
  • make px4_sitl_default gazebo
  • 终端输入 commander takeoff ,可以看到无人机起飞
  • 终端输入 commander land , 可以看到无人机降落

添加环境变量

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

安装mavros

cpp 复制代码
sudo apt-get install ros-noetic-mavros ros-noetic-mavros-extras
bash 复制代码
sudo /opt/ros/noetic/lib/mavros/install_geographiclib_datasets.sh

**注意:如果未执行上方安装命令,则会报错 UAS:GeographicLib exception: File not readable

执行命令

bash 复制代码
roslaunch mavros px4.launch

如果出现FCU: DeviceError:serial:open: No such file or directory报错,是由于没有链接硬件所致。

也可以参考树莓派串口通信设置 - 知乎,解决serial0和ttyAMA0映射关系问题

4、安装QGC

Download and Install · QGroundControl User Guidehttps://docs.qgroundcontrol.com/master/en/getting_started/download_and_install.html

  1. On the command prompt enter:

    复制代码
    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 libqt5gui5 -y
    sudo apt install libfuse2 -y
  2. Logout and login again to enable the change to user permissions.

  1. Download QGroundControl.AppImage.(下载后的文件放到指定文件夹中)

  2. Install (and run) using the terminal commands:

    复制代码
    chmod +x ./QGroundControl.AppImage
    ./QGroundControl.AppImage  (or double click)

5、px4仿真

启动gazebo、mavros、px4.launch等

roslaunch px4 mavros_posix_sitl.launch

如果启动成功,可以使用commander takeoff / commander land执行起飞和降落

查看话题列表

rostopic list

相关推荐
倒头就睡的小比特4 天前
算法竞赛C++常用的STL
c++·算法
weilx12344 天前
C++笔记-文件IO-<fcntl.h>
c++
未济4 天前
linux 配置环境变量
linux
傲世仙尊4 天前
目录即文件-Ext文件系统收尾篇
linux·c语言
风合星语4 天前
2026 具身智能技术实战(一):VLA 到底怎么控制机器人?——用 LeRobot 跑通 SmolVLA 推理
pytorch·机器人·具身智能·vla·lerobot·smolvla
鲁邦通物联网4 天前
图书馆机器人跨楼层运行,机器人梯控低噪设计与架构分析
机器人·巡检机器人·机器人梯控·agv梯控·非侵入式采集·机器人乘梯·机器人自主乘梯
Smileyqp沛沛4 天前
前端?C++ ?较大差异基础罗列
c++·基础·前端转c++
C语言小火车4 天前
C/C++ 为什么需要编译器?
开发语言·c++
_艾伦 耶格尔.4 天前
进程间通信
linux
旖旎夜光4 天前
力控面试题 01.01: 判定字符是否唯一(位运算) —— 题解
c++·学习·算法·leetcode·力控