为了完成使用realsenseD435i相机在真实环境下的目标检测任务,下载了realsense-ros和yolo8-ros功能包(都在工作空间src下)。分两种情况,1、使用真实硬件(如realsenseD435i)。2、在纯仿真环境下进行目标识别(如Gazebo),这两种情况是不同的,需要修改yolo_v8.launch中的参数,具体修改如下:
此时的yolo_v8.launch文件为:
<?xml version="1.0" encoding="utf-8"?>
<launch>
<!-- Load Parameter -->
<param name="use_cpu" value="true" />
<!-- Start yolov5 and ros wrapper -->
<node pkg="yolov8_ros" type="yolo_v8.py" name="yolov8_ros" output="screen" >
<param name="weight_path" value="$(find yolov8_ros)/weights/yolov8s.pt"/>
<!-- run yolov8 use real camera -->
<param name="image_topic" value="/camera/color/image_raw" />
<param name="pub_topic" value="/yolov8/BoundingBoxes" />
<param name="camera_frame" value="camera_color_frame"/>
<param name="visualize" value="true"/>
<param name="conf" value="0.3" />
</node>
</launch>
需要注意的地方是,硬件条件下,订阅的图像话题为:/camera/color/image_raw
此时的yolo_v8.launch文件为:
<?xml version="1.0" encoding="utf-8"?>
<launch>
<!-- Load Parameter -->
<param name="use_cpu" value="true" />
<!-- Start yolov5 and ros wrapper -->
<node pkg="yolov8_ros" type="yolo_v8.py" name="yolov8_ros" output="screen" >
<param name="weight_path" value="$(find yolov8_ros)/weights/best.pt"/>
<!-- run yolov8 in gazebo simulation -->
<param name="image_topic" value="/camera/rgb/image_raw" />
<param name="pub_topic" value="/yolov8/BoundingBoxes" />
<param name="camera_frame" value="camera_color_frame"/>
<param name="visualize" value="true"/>
<param name="conf" value="0.3" />
</node>
</launch>
需要注意的地方是,仿真条件下,订阅的图像话题为:/camera/rgb/image_raw
之前我一直认为yolov8自带的权重文件就已经好用,但是经过测试并不行。针对特定的物体,会出现识别不到的情况,不能发布Boundingoxes 话题。