PX4学习笔记:1. ROS及PX4环境搭建


一、环境

Ubuntu18.04

二、安装教程参考

https://www.guyuehome.com/8983

三、安装过程中问题的解决

问题1

rosdep init 错误的终极解决方法
注意etc/下的ros和rostep文件夹要自己建

问题2

Ubuntu安装ROS报错 sudo: rosdep:找不到命令

问题3(更好地解决了问题1、2)【推荐】

解决GitHub的raw.githubusercontent.com无法连接问题

问题4:GeographicLib的安装

教程中安装GeographicLib datasets会出现问题
参考官网用cmake安装:https://geographiclib.sourceforge.io/html/install.html#cmake

其中,cmake的安装参考(可以跳过此链接,直接使用我的方法):https://blog.csdn.net/weixin_43274923/article/details/84866234

我在安装cmake时选择了当时的最新版本cmake3.19.0
方法如下:

$ wget https://cmake.org/files/v3.19/cmake-3.19.0-Linux-x86_64.tar.gz
$ tar zxvf cmake-3.19.0-Linux-x86_64.tar.gz
$ sudo apt install tree
$ tree -L 2 cmake-3.19.0-Linux-x86_64
$ mv cmake-3.19.0-Linux-x86_64 /opt/cmake-3.19.0
$ ln -sf /opt/cmake-3.19.0/bin/* /usr/bin/
$ cmake --version

官网安装需要先下载安装包:https://sourceforge.net/projects/geographiclib/files/distrib/GeographicLib-1.50.1.tar.gz/download
再根据cmake教程安装,我没有看太懂,又参考了这篇博客:https://blog.csdn.net/m_zhangJingDong/article/details/78164851

问题5:下载编译px4时git报错

  • 运行此句:
git submodule update --init --recursive
  • 弹出如下错误:
zth@SugoAsurada:~/catkin_ws/Firmware$ git submodule update --init --recursive
正克隆到 '/home/zth/catkin_ws/Firmware/boards/atlflight/cmake_hexagon'...
正克隆到 '/home/zth/catkin_ws/Firmware/mavlink/include/mavlink/v2.0'...
正克隆到 '/home/zth/catkin_ws/Firmware/platforms/nuttx/NuttX/apps'...
正克隆到 '/home/zth/catkin_ws/Firmware/platforms/nuttx/NuttX/nuttx'...
正克隆到 '/home/zth/catkin_ws/Firmware/platforms/qurt/dspal'...
正克隆到 '/home/zth/catkin_ws/Firmware/src/drivers/gps/devices'...
正克隆到 '/home/zth/catkin_ws/Firmware/src/drivers/uavcan/libuavcan'...
正克隆到 '/home/zth/catkin_ws/Firmware/src/examples/gyro_fft/CMSIS_5'...
正克隆到 '/home/zth/catkin_ws/Firmware/src/lib/ecl'...
fatal: unable to access 'https://github.com/PX4/PX4-ECL/': Failed to connect to github.com port 443: 连接超时
fatal: 无法克隆 'https://github.com/PX4/PX4-ECL' 到子模组路径 '/home/zth/catkin_ws/Firmware/src/lib/ecl'
克隆 'src/lib/ecl' 失败。按计划重试
正克隆到 '/home/zth/catkin_ws/Firmware/src/lib/matrix'...
正克隆到 '/home/zth/catkin_ws/Firmware/src/modules/micrortps_bridge/micro-CDR'...
正克隆到 '/home/zth/catkin_ws/Firmware/src/lib/ecl'...
子模组路径 'Tools/sitl_gazebo':检出 'cd8ba25c81f32d6fe088482e37f8a38892209ef4'
子模组 'external/OpticalFlow'(https://github.com/PX4/OpticalFlow.git)未对路径 'Tools/sitl_gazebo/external/OpticalFlow' 注册
正克隆到 '/home/zth/catkin_ws/Firmware/Tools/sitl_gazebo/external/OpticalFlow'...
子模组路径 'Tools/sitl_gazebo/external/OpticalFlow':检出 '28ef45c1fcb532b2bfd54c16b059c6a545143b2f'
子模组 'external/klt_feature_tracker'(https://github.com/ethz-ait/klt_feature_tracker.git)未对路径 'Tools/sitl_gazebo/external/OpticalFlow/external/klt_feature_tracker' 注册
正克隆到 '/home/zth/catkin_ws/Firmware/Tools/sitl_gazebo/external/OpticalFlow/external/klt_feature_tracker'...
子模组路径 'Tools/sitl_gazebo/external/OpticalFlow/external/klt_feature_tracker':检出 '9b5b567ae77f93d1ef4d36151529ba2506a46e7a'
子模组路径 'boards/atlflight/cmake_hexagon':检出 '08fd0a73045346448adf6969660196228b23e1fa'
子模组路径 'mavlink/include/mavlink/v2.0':检出 '1de17e039b27c541ccdb9ed214ea41aaaf180ae0'
子模组路径 'platforms/nuttx/NuttX/apps':检出 '909eff540d8004371d5838b9c0764cc753d665cf'
子模组路径 'platforms/nuttx/NuttX/nuttx':检出 '904a602c74dc08a100b5c2bd490807de19e73e10'
子模组路径 'platforms/qurt/dspal':检出 '0322a4e345e48ea28cb1cee14a33033cdaf0b16a'
子模组 'cmake_hexagon'(https://github.com/ATLFlight/cmake_hexagon)未对路径 'platforms/qurt/dspal/cmake_hexagon' 注册
正克隆到 '/home/zth/catkin_ws/Firmware/platforms/qurt/dspal/cmake_hexagon'...
子模组路径 'platforms/qurt/dspal/cmake_hexagon':检出 '07168bd5715818802b78f674816ec851307998a7'
子模组路径 'src/drivers/gps/devices':检出 '0bf63c9820f4af997d0a48743dcc1008d119e49c'
子模组路径 'src/drivers/uavcan/libuavcan':检出 '04377cc2704eb7e2fae36fffa5e67063cc40b4c0'
子模组 'dsdl'(https://github.com/UAVCAN/dsdl)未对路径 'src/drivers/uavcan/libuavcan/dsdl' 注册
子模组 'libuavcan/dsdl_compiler/pyuavcan'(https://github.com/UAVCAN/pyuavcan)未对路径 'src/drivers/uavcan/libuavcan/libuavcan/dsdl_compiler/pyuavcan' 注册
正克隆到 '/home/zth/catkin_ws/Firmware/src/drivers/uavcan/libuavcan/dsdl'...
正克隆到 '/home/zth/catkin_ws/Firmware/src/drivers/uavcan/libuavcan/libuavcan/dsdl_compiler/pyuavcan'...
子模组路径 'src/drivers/uavcan/libuavcan/dsdl':检出 '192295c4f9b67f4a20b0eabf74757b6597415f2b'
子模组路径 'src/drivers/uavcan/libuavcan/libuavcan/dsdl_compiler/pyuavcan':检出 'c58477a644d20ccf95a20c151f3a0402f271c3b8'
子模组 'dsdl'(https://github.com/UAVCAN/dsdl)未对路径 'src/drivers/uavcan/libuavcan/libuavcan/dsdl_compiler/pyuavcan/dsdl' 注册
正克隆到 '/home/zth/catkin_ws/Firmware/src/drivers/uavcan/libuavcan/libuavcan/dsdl_compiler/pyuavcan/dsdl'...
子模组路径 'src/drivers/uavcan/libuavcan/libuavcan/dsdl_compiler/pyuavcan/dsdl':检出 'fd12483ddd4e58242d61d74a163e7aeaa1e0f466'
子模组路径 'src/examples/gyro_fft/CMSIS_5':检出 '4ed5730787a0f98e8858c9998e406c608ab10b28'
子模组路径 'src/lib/ecl':检出 'da9f314b69585ba169d033fec293e9ea48b9d1fd'
子模组路径 'src/lib/matrix':检出 'a504b6e88152d88dba936bc74e449f2f281b84e2'
子模组路径 'src/modules/micrortps_bridge/micro-CDR':检出 '56b2696e4a9bb43d2aef9690fc5c6a2d6b1af8ee'
子模组路径 'src/lib/ecl':检出 'da9f314b69585ba169d033fec293e9ea48b9d1fd'

问题6:No module named ‘jinja2.asyncsupport’

  • 运行:
#开始编译
make px4_sitl_default gazebo
  • 错误如下:
ModuleNotFoundError: No module named 'jinja2.asyncsupport'

https://github.com/cocodataset/cocoapi/issues/90

问题7:symbol lookup error

  • 运行:
#开始编译
make px4_sitl_default gazebo
  • 错误如下:
gz: symbol lookup error: /usr/lib/x86_64-linux-gnu/libgazebo_common.so.9: undefined symbol: _ZN8ignition10fuel_tools12ClientConfig12SetUserAgentERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE

四、测试

4.1 编译运行

zth@SugoAsurada:~/catkin_ws/Firmware$ sudo make px4_sitl_default gazebo

4.2 解锁

按回车,然后输入:

commander arm

运行结果如下:
在这里插入图片描述

4.3 起飞

commander takeoff

运行结果如下:
在这里插入图片描述

4.4 降落

commander land

4.5 多机测试

roslaunch px4 multi_uav_mavros_sitl.launch

报错如下:

[FATAL] [1455208235.573568497]: UAS: GeographicLib exception: File not readable /usr/share/GeographicLib/geoids/egm96-5.pgm | Run install_geographiclib_dataset.sh script in order to install Geoid Model dataset!
================================================================================REQUIRED process [mavros-2] has died!
process has died [pid 2396, exit code -6, cmd /home/ubuntu/catkin_ws_wyz/devel/lib/mavros/mavros_node __name:=mavros __log:=/home/ubuntu/.ros/log/c5fc1ef8-d0dc-11e5-89a3-00044b65bbf5/mavros-2.log].
log file: /home/ubuntu/.ros/log/c5fc1ef8-d0dc-11e5-89a3-00044b65bbf5/mavros-2*.log
Initiating shutdown!
================================================================================
[mavros-2] killing on exit
[rosout-1] killing on exit
[master] killing on exit
shutting down processing monitor...
... shutting down processing monitor complete
done

解决方法

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


多次运行launch文件后会报错如下:

ERROR [px4] is_server_running: failed to create lock file: /tmp/px4_lock-0, reason=Permission denied

解决方法:重启电脑。
问题原因:涉及到操作系统中互斥锁的概念,上一次运行launch文件后上锁了,需要解锁释放资源后,其他任务才能执行。



成功运行效果如下(这里我修改了launch文件,故只有两架无人机,原文件会生成三架):
在这里插入图片描述]
https://img-blog.csdnimg.cn/2020121311505129.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ0MzI0MTgx,size_16,color_FFFFFF,t_70)

五、QGroundControl

5.1 安装下载

QGroundControl官方安装教程

5.2 px4视频流测试

进入Firmware文件夹,终端运行:

make px4_sitl gazebo_typhoon_h480

效果如下:
QGC测试
参考文档

下一篇真正开始入门px4开发

猜你喜欢

转载自blog.csdn.net/qq_44324181/article/details/109891069