赞
踩
前言:小白向,由于双系统下的ubantu一直报错,所以就转到虚拟机上来进行环境搭建,等双系统实现之后再做更新。
搭建过程主要参考了下面这位博主的文章和xdrone的使用文档,配置的时候有几处小问题先写一下
https://blog.csdn.net/qq_45067735/article/details/108014941?ops_request_misc=&request_id=&biz_id=102&utm_term=darknetros&utm_medium=distribute.pc_search_result.none-task-blog-2allsobaiduweb~default-3-108014941.142v86insert_down1,239v2insert_chatgpt&spm=1018.2226.3001.4187
https://www.yuque.com/xtdrone/manual_cn/target_detection_tracking
(1)No package ‘libv4l2’ found
我的是18.04版本使用下面指令,根据你的uabntu版本来选
sudo apt-get install v4l2-ctl
我安装时会报无法定位安装包,使用下面代码安装完成之后正常
sudo apt-get install ros-melodic-usb-cam
安装完成后未报错
(2)运行usbcam报错
roslaunch usb_cam usb_cam-test.launch
虚拟机中会出现下面的问题,错误如下
[ERROR] [1682215855.236322602]: Cannot identify ‘/dev/video0’: 2, No such file or directory
[usb_cam-2] process has died [pid 64303, exit code 1, cmd /opt/ros/melodic/lib/usb_cam/usb_cam_node __name:=usb_cam __log:=/home/jyf/.ros/log/13b60d18-e17c-11ed-baca-000c29266693/usb_cam-2.log].
log file: /home/jyf/.ros/log/13b60d18-e17c-11ed-baca-000c29266693/usb_cam-2*.log
注意看下摄像头启用没
还是不行的话就看看系统设置,我是笔记本默认的usb2.0要改成3.0
改完之后启动正常,能显示笔记本摄像头画面
darknet_ros.launchRLException: [darknet_ros.launch] is neither a launch file in package [darknet_ros] nor is [darknet_ros] a launch file name
The traceback for the exception was written to the log file
一般情况都是没有source导致报错,到你的工作区下面source一下。
source devel/setup.bash
然后启动
roslaunch darknet_ros darknet_ros.launch
要注意的是有时候在启动yolo和usbcam的时候打开两个终端需要两次source
有种简单的办法在主目录下面ctrl+h显示隐藏文件在最后面加上
source ~/你的工作区/devel/setup.bash
例:source ~/catkin_ws/devel/setup.bash
修改完后保存主目录终端
source .bashrc
之后启动就无须再反复source setup.bash了
RLException: [target_track.launch] is neither a launch file in package [darknet_ros] nor is [darknet_ros] a launch file name
The traceback for the exception was written to the log file
查了一下官网,启动语句是下面这句,启动lolov3
roslaunch darknet_ros task1.launch
yolov4的是用这句
roslaunch darknet_ros multi_target_search.launch
xtdrone复制过来的启动文件如下,可能是xtdrone后面更新了launch文件
还有个需要注意的点是,复制xtdrone的文件之前注意看看里面是不是有文件。我第一次复制过去里面没文件直接编译出错,找了半天原因发现文件夹是空的,复制过去重新编译就好了。
3.在启动室外仿真场景roslaunch px4 outdoor1.launch时报错
RLException: [outdoor1.launch] is neither a launch file in package [px4] nor is [px4] a launch file name
The traceback for the exception was written to the log file
原因是PX4_Firmware出现问题,在.bashrc文件最后加入
source ~/catkin_ws/devel/setup.bash
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
要注意source顺序,我就是工作区与PX4_Firmware反了报错
source ~/.bashrc
然后测试一下
cd ~/PX4_Firmware
roslaunch px4 mavros_posix_sitl.launch
正常后在测试一下通信
rostopic echo /mavros/state
没问题的话显示如下
有问题的话检查一下.bashrc里的路径。
然后继续执行
cd ~/PX4_Firmware
roslaunch px4 outdoor1.launch
工作区下打开darknet_ros
roslaunch darknet_ros task1.launch
就可以运行仿真了
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。