ROS下基于YOLO的px4无人机目标检测+对应的各种问题解决办法(亲测有效,避免入坑)

2023-05-16

ROS下基于YOLO的px4无人机目标检测

  • 一、搭建无人机仿真环境
    • 1.安装依赖
    • 2、ROS安装(已安装就忽略)
    • 3.Gazebo安装(已安装就忽略)
    • 4.MAVROS安装
    • 5.PX4配置
      • 编译make posix_sitl_default gazebo可能会遇到的问题:(由于小编忘记了截图)于是便拿我参考的问题解决方法分享(错误大概一致都可以按照以下解决)
        • 问题1:
        • 问题2:
        • 问题3:
        • 出现的问题:

一、搭建无人机仿真环境

1.安装依赖

sudo apt install -y \
ninja-build \
exiftool \
python-argparse \
python-empy \
python-toml \
python-numpy \
python-yaml \
python-dev \
python-pip \
ninja-build \
protobuf-compiler \
libeigen3-dev \
genromfs \
xmlstarlet
pip install \
pandas \
jinja2 \
pyserial \
cerberus \
pyulog \
numpy \
toml \
pyquaternion

2、ROS安装(已安装就忽略)

参考链接

3.Gazebo安装(已安装就忽略)

参考链接

4.MAVROS安装

这是一个飞机固件与ros通信的包:

sudo apt install ros-kinetic-mavros ros-kinetic-mavros-extras
wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh
sudo chmod a+x ./install_geographiclib_datasets.sh
sudo ./install_geographiclib_datasets.sh ##此时执行速度很慢,耐心等待完成

5.PX4配置

下载固件

git clone https://github.com/PX4/Firmware
mv Firmware PX4_Firmware
cd PX4_Firmware
git checkout -b xtdrone/dev v1.11.0-beta1
git submodule update --init --recursive

一般来说,第一次安装飞控固件,编译时会报错,因为缺少了必要的python依赖,因此在下载玩Firmware后,在编译之前,首先:

cd PX4_Firmware
 bash
 bash ./Tools/setup/ubuntu.sh --no-nuttx --no-sim-tools ##此处跳过了仿真器的安装,因为已经在ros已经配置好了

这之后,再执行下面指令,一般就不会出错,如果继续报错,一般为个人电脑环境配置的问题,请根据终端中的错误提示自行安装依赖。

make posix_sitl_default gazebo

**

编译make posix_sitl_default gazebo可能会遇到的问题:(由于小编忘记了截图)于是便拿我参考的问题解决方法分享(错误大概一致都可以按照以下解决)

问题1:

[ros] ccache: failed to create /home/ 问题解决
解决办法:删除/home/xxx/.ccache文件
(xxx)是你虚拟机用户名的名称

sudo rm -rf /home/xxx/.ccache/ 

问题2:

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
GSTREAMER_LIBRARIES (ADVANCED)

    linked by target "LiftDragPlugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "gazebo_gst_camera_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "gazebo_barometer_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "gazebo_geotagged_images_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "gazebo_magnetometer_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "sensor_msgs" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "gazebo_irlock_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "gazebo_video_stream_widget" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "gazebo_controller_interface" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "gazebo_wind_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "std_msgs" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "gazebo_gps_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "gazebo_sonar_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "mav_msgs" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "nav_msgs" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "gazebo_lidar_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "gazebo_opticalflow_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "gazebo_mavlink_interface" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "gazebo_uuv_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "gazebo_vision_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "gazebo_multirotor_base_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "gazebo_imu_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "gazebo_gimbal_controller_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "physics_msgs" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
    linked by target "gazebo_motor_model" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo

-- Configuring incomplete, errors occurred!

解决办法:

sudo apt-get install libgstreamer-plugins-base1.0-dev

问题3:

[11/33] Building CXX object CMakeFiles...plugin.dir/src/gazebo_uuv_plugin.cpp.o
FAILED: /usr/bin/c++   -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -Dgazebo_uuv_plugin_EXPORTS -isystem /usr/include/qt4 -isystem /usr/include/qt4/QtGui -isystem /usr/include/qt4/QtCore -isystem /usr/include/gazebo-7 -isystem /usr/include/sdformat-4.4 -isystem /usr/include/ignition/math2 -isystem /usr/include/OGRE -I/home/weiweu/PX4_Firmware/Tools/sitl_gazebo/include -I. -I/usr/include/eigen3 -I/usr/include/eigen3/eigen3 -I/usr/include/gazebo-7/gazebo/msgs -I/home/weiweu/PX4_Firmware/mavlink/include -I/usr/include/OGRE/Paging -isystem /opt/ros/kinetic/include/opencv-3.3.1-dev -isystem /opt/ros/kinetic/include/opencv-3.3.1-dev/opencv -I/home/weiweu/PX4_Firmware/Tools/sitl_gazebo/external/OpticalFlow/include -I/usr/include/gstreamer-1.0 -I/usr/lib/x86_64-linux-gnu/gstreamer-1.0/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wno-deprecated-declarations -Wno-address-of-packed-member -fPIC   -std=gnu++14 -MMD -MT CMakeFiles/gazebo_uuv_plugin.dir/src/gazebo_uuv_plugin.cpp.o -MF CMakeFiles/gazebo_uuv_plugin.dir/src/gazebo_uuv_plugin.cpp.o.d -o CMakeFiles/gazebo_uuv_plugin.dir/src/gazebo_uuv_plugin.cpp.o -c /home/weiweu/PX4_Firmware/Tools/sitl_gazebo/src/gazebo_uuv_plugin.cpp
c++: internal compiler error: 已杀死 (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.
[11/33] Building CXX object CMakeFiles...dir/src/gazebo_mavlink_interface.cpp.o
ninja: build stopped: subcommand failed.
[2/5] Generating ../../logs
FAILED: cd /home/weiweu/PX4_Firmware/build/px4_sitl_default/build_gazebo && /usr/bin/cmake --build .
ninja: build stopped: subcommand failed.
Makefile:198: recipe for target 'px4_sitl_default' failed
make: *** [px4_sitl_default] Error 1

解决办法:
这个原因是内存不足, 在linux下增加临时swap空间

#注释:of=/home/swap,放置swap的空间; count的大小就是增加的swap空间的大小,64M就是块大小,这里是64MB,所以总共空间就是bs*count=1024MB.这里分配空间的时候需要一点时间,等待执行完毕。
sudo dd if=/dev/zero of=/home/swap bs=64M count=16  

#注释:把刚才空间格式化成swap各式
sudo mkswap /home/swap (可能会提示warning: don't erase bootbits sectorson whole disk. Use -f to force,不用理会)


#注释:使刚才创建的swap空间
sudo swapon /home/swap

然后执行你的需要的make,我的是

make px4_sitl_default gazebo

便可以成功运行:
在这里插入图片描述
在这里插入图片描述
px4无人机的基本环境就配置好了,应该可以看到gazebo界面中已经有了一个叫做iris的无人机。

修改 ~/.bashrc,加入以下代码,注意路径匹配。

source ~/PX4_Firmware/Tools/setup_gazebo.bash ~/PX4_Firmware/ ~/PX4_Firmware/build/px4_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/PX4_Firmware
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/PX4_Firmware/Tools/sitl_gazebo

在这里插入图片描述

然后运行如下命令,此时会启动Gazebo,如下图所示。

roslaunch px4 mavros_posix_sitl.launch

出现的问题:

[FATAL] [1592276532.778789363]: 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!
  NAV_DLL_ACT: curr: 0 -> new: 2
  RTL_DESCEND_ALT: curr: 30.0000 -> new: 5.0000
  RTL_LAND_DELAY: curr: -1.0000 -> new: 5.0000
  RTL_RETURN_ALT: curr: 60.0000 -> new: 30.0000
  SDLOG_MODE: curr: 0 -> new: 1
  SDLOG_PROFILE: curr: 3 -> new: 131
  SDLOG_DIRS_MAX: curr: 0 -> new: 7
  SENS_BOARD_X_OFF: curr: 0.0000 -> new: 0.0000
  SENS_DPRES_OFF: curr: 0.0000 -> new: 0.0010
  TRIG_INTERFACE: curr: 4 -> new: 3
* RTL_DESCEND_ALT: curr: 5.0000 -> new: 10.0000
* RTL_LAND_DELAY: curr: 5.0000 -> new: 0.0000
  PWM_MAX: curr: 2000 -> new: 1950
  PWM_MIN: curr: 1000 -> new: 1075
  GPS_UBX_DYNMODEL: curr: 7 -> new: 6
* SYS_AUTOCONFIG: curr: 1 -> new: 0
INFO  [dataman] Unknown restart, data manager file './dataman' size is 11798680 bytes
INFO  [simulator] Waiting for simulator to accept connection on TCP port 4560
[ INFO] [1592276533.100343456]: Finished loading Gazebo ROS API Plugin.
[ INFO] [1592276533.100970472]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised, waiting...
[ INFO] [1592276533.123831704]: Finished loading Gazebo ROS API Plugin.
[ INFO] [1592276533.124724290]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised, waiting...
================================================================================REQUIRED process [mavros-6] has died!
process has finished cleanly
log file: /home/weiweu/.ros/log/c620005a-af7d-11ea-ac47-000c299b4adc/mavros-6*.log
Initiating shutdown!
================================================================================
[mavros-6] killing on exit
[vehicle_spawn_weiweu_virtual_machine_5785_5709449976029652956-5] killing on exit
[gazebo_gui-4] killing on exit
[gazebo-3] killing on exit
[sitl-2] killing on exit
Traceback (most recent call last):
  File "/opt/ros/kinetic/lib/gazebo_ros/spawn_model", line 32, in <module>
    import tf.transformations as tft
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf/__init__.py", line 28, in <module>
    from tf2_ros import TransformException as Exception, ConnectivityException, LookupException, ExtrapolationException
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf2_ros/__init__.py", line 39, in <module>
    from .buffer_interface import *
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf2_ros/buffer_interface.py", line 32, in <module>
    import roslib; roslib.load_manifest('tf2_ros')
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslib/launcher.py", line 62, in load_manifest
    sys.path = _generate_python_path(package_name, _rospack) + sys.path
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslib/launcher.py", line 93, in _generate_python_path
    m = rospack.get_manifest(pkg)
  File "/usr/lib/python2.7/dist-packages/rospkg/rospack.py", line 171, in get_manifest
    return self._load_manifest(name)
  File "/usr/lib/python2.7/dist-packages/rospkg/rospack.py", line 215, in _load_manifest
    retval = self._manifests[name] = parse_manifest_file(self.get_path(name), self._manifest_name, rospack=self)
  File "/usr/lib/python2.7/dist-packages/rospkg/manifest.py", line 410, in parse_manifest_file
    from rosdep2.rospack import init_rospack_interface, is_ros_package, is_system_dependency, is_view_empty
  File "/usr/lib/python2.7/dist-packages/rosdep2/__init__.py", line 45, in <module>
ERROR [px4] Startup script returned with return value: 2
    from .lookup import RosdepDefinition, RosdepView, RosdepLookup, \
  File "/usr/lib/python2.7/dist-packages/rosdep2/lookup.py", line 44, in <module>
    from .sources_list import SourcesListLoader
  File "/usr/lib/python2.7/dist-packages/rosdep2/sources_list.py", line 48, in <module>
    from .gbpdistro_support import get_gbprepo_as_rosdep_data, download_gbpdistro_as_rosdep_data
  File "/usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py", line 18, in <module>
    from .platforms.debian import APT_INSTALLER
  File "/usr/lib/python2.7/dist-packages/rosdep2/platforms/__init__.py", line 1, in <module>
    
KeyboardInterrupt
[rosout-1] killing on exit
[master] killing on exit
shutting down processing monitor...
... shutting down processing monitor complete
done

解决办法:
还在解决中!!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

ROS下基于YOLO的px4无人机目标检测+对应的各种问题解决办法(亲测有效,避免入坑) 的相关文章

  • MySQL相关面试题总结

    1 解释一下单列索引和联合索引 单列索引是指在表的某一列上创建索引 联合索引是在多个列上联合创建索引 单列索引可以出现在where条件的任何位置 而联合索引需要按照一定的顺序来写 在多条件查询的时候 联合索引的效率更高 我们联合索引也最多创
  • 修改firefox浏览器滚动条的样式

    最近做了一个网站的项目 xff0c 使用原生的滚动条 ie和谷歌都显示的好好的 xff0c 火狐的滚动条样式没有生效 原因 xff1a 火狐浏览器没有提供原生滚动条的方法和属性 后来浏览器升级之后提供了部分可以修改样式的属性 属性较多 xf
  • jetson nx ssd镜像克隆

    1 打开disk查看要克隆的ssd名称 2卸载ssd 制作镜像 sudo umount dev sdb1 sudo s sudo dd if 61 dev sdb1 conv 61 sync noerror bs 61 64k gzip c
  • Android 关于IPV6 DNS的问题

    目前在测试IPV6 DNS解析的时候发现一个问题 xff0c 这里记录一下 问题是 xff1a 当dhcpv6服务器分配的IPV6 dns是fe80类型的dns时 xff0c 无法发送dns请求 xff0c 抓包看不到有目标地址为fe80
  • PX4开发环境搭建

    PX4开发环境搭建 编译工具链的安装vscode 编译工具链的安装 下载ubuntu sh requirements txt wget https raw githubusercontent com PX4 Firmware master
  • TFmini在nora+(px4)上的使用和验证

    目标 xff1a 使用tfmini完成定高实验 设置 xff1a 1 sens tfmini cfg 设置为telem2 xff08 可修改为其他 xff0c 保证硬件连线一致 xff0c 1一般是无线数传所以没改过去 其他的对应在官网里有
  • ROS | Realsense中的IMU解算orientation

    文章目录 概述 一 定义介绍 二 操作教程 一 下载并编译imu tools功能包 1 创建工作空间并初始化 2 下载imu tools并编译 二 修改配置 1 修改imu tools源码 2 修改launch文件 3 启动解算 概述 本文
  • prometheus服务监控之mysql监控

    文章目录 上传解压安装mysqld exporter安装mariadb在数据库里创建mysql账号用户收集数据在mysql exporter中设置mysql配置信息启动mysql exporter配置prometheus拉取mysql节点信
  • HTTP请求头Authorization

    今天部署了一个Authorization项目 xff0c 由于改了auth服务器客户端id和密码 xff0c 而前端请求header没有修改 xff0c 登录时一直弹框要求输入用户名和密码 xff0c 输入后却无效 xff0c 只好改前端代
  • c语言编程规范第三部分

    3 头文件应向稳定的方向包含 头文件的包含关系是一种依赖 xff0c 一般来说 xff0c 应当让不稳定的模块依赖稳定的模块 xff0c 从而当不稳定的模块发生变化时 xff0c 不会影响 xff08 编译 xff09 稳定的模块 就我们的
  • 看完《C++ primer》后,我都收获了什么?

    文章目录 1 语言只是一个工具2 光学会一门语言还不够3 结语 迫于读研和未来就业的压力 xff0c 我研一上自学了C 43 43 的这门语言 xff0c 自我感觉比较认真的看完了 C 43 43 primer 这本书的大部分章节 xff0
  • Ubuntu18.04 ROS Melodic版本安装gazebo_ros_pkgs包

    疫情期间宅在家没法做实验 xff0c 只能上手gazebo做仿真 xff0c 导入实验室机器人的相关文件后 xff0c 打算看看效果 xff0c 运行代码 roslaunch probot gazebo probot anno gazebo
  • vim如何批量注释

    1 ctrl 43 v 进入 2 按箭头 选中要注释的首行 3 按下大写 i 进入插入模式 4输入 按esc 就可以看到如下内容
  • 还弄不明白【委托和事件】么?看这一篇就足够了!!!

    这两个概念长时间不用了 xff0c 今天看到CAD二次开发中用到了自定义事件 xff0c 有点迷糊了 xff0c 索性再整理一下加深印象 xff01 一说到委托和事件 xff0c 他们总是绑定在一起的不可分割 xff01 可能你会说啊 xf
  • 三种简单排序(冒泡、插入、选择)的比较和图解

    冒泡排序 这种排序方式是最容易理解的 xff0c 主体思想就是 xff1a 指针重复地走访过要排序的数列 xff0c 一次比较两个元素 xff0c 如果他们的顺序错误就把他们交换过来 走访数列的工作是重复地进行直到没有再需要交换 xff0c
  • ModuleNotFoundError: No module named 'XXX'的解决办法

    类似问题一 ModuleNotFoundError No module named 39 captcha 39 pycharm打开的项目 xff0c 在虚拟环境里通过终端命令python manage py runserver运行pytho
  • 微信小程序实现搜索功能以及效果(超详细)

    我们先来看一下实现哪些功能 1 搜索历史记录以及清空历史记录 2 热门搜索推荐以及更新推荐内容 3 根据输入框输入的内容来自动搜索相关查询 后台逻辑是模糊查询 后台就先不扯了 这里我用的是自己定义的虚拟数据 暂时没用后台接口 可能有点问题
  • 微信小程序实现收货地址城市选择效果(添加收货地址)

    先来张效果图 这里主要是城市选择效果 请忽视其他 不要吐槽 谢谢 接下来看一下代码吧 wxml lt pages my my add address index wxml gt lt view class 61 34 redact addr
  • uni-app实现商城多商家购物车功能(超详细, 附带源码)

    我们先来看一下效果 有什么不懂可以直接下方留言 先来看代码 lt template gt lt view class 61 34 cart 34 gt lt 购物车为空 S gt lt view v if 61 34 cartList le
  • 微信小程序web-view的使用教程

    最近公司有需求 xff0c 需要点击小程序首页banner xff0c 跳转到别人的h5页面 首先是域名的问题 xff1a 步骤 xff1a 先登录小程序开发平台 xff0c 将页面需要跳转的域名写上去 xff0c 注意了 xff0c 域名

随机推荐