Skip to content

Add carla_tsr_ros: ROS wrapper for YOLOv8 traffic sign recognition with roslaunch support - #7653

Closed
HaiLang47 wants to merge 1 commit into
OpenHUTB:mainfrom
HaiLang47:feature/carla_tsr_ros
Closed

HaiLang47 wants to merge 1 commit into
OpenHUTB:mainfrom
HaiLang47:feature/carla_tsr_ros

Conversation

@HaiLang47

Copy link
Copy Markdown
Contributor
  • package.xml + CMakeLists.txt: catkin package definition
  • ros_nodes/image_publisher.py: loop-publish local images to /camera/image_raw
  • ros_nodes/perception_node.py: subscribe image, run YOLOv8 inference, publish detections
  • ros_nodes/control_node.py: subscribe detections, publish brake command
  • main.launch: roslaunch entry to start all three nodes
  • main.py + main.sh: unified entry points
  • config/params.yaml: runtime parameters
  • data/sample_stop.jpg: synthetic stop sign for demo
  • demo.gif: ROS pipeline demonstration
  • README.md: environment, build steps, NN principle, algorithm flow, weight download
  • Bypass cv_bridge by manually building sensor_msgs/Image (cv_bridge incompatible with OpenCV 5.0.0 in conda env)

修改概述:

修改内容

新增 src/carla_tsr_ros 模块,将 YOLOv8 交通标志识别封装为 ROS Noetic catkin 包,实现从图像输入到控制指令输出的完整话题链路。

新增文件

  • package.xml + CMakeLists.txt:catkin 包定义
  • ros_nodes/image_publisher.py:从本地图片目录循环发布图像到 /camera/image_raw
  • ros_nodes/perception_node.py:订阅图像,用 YOLOv8n 推理,发布 /perception/traffic_signs(JSON)和 /perception/annotated_image
  • ros_nodes/control_node.py:订阅检测结果,检测到 stop sign 时发布 /vehicle/control_cmd(刹车)
  • main.launch:roslaunch 入口,一键启动三个节点
  • main.py + main.sh:统一入口脚本
  • config/params.yaml:运行时参数
  • data/sample_stop.jpg:合成 stop sign 测试图
  • demo.gif:ROS 流水线演示
  • README.md:运行环境、编译步骤、神经网络原理、算法流程、权重下载说明

技术要点

  • 神经网络:YOLOv8n(ultralytics 8.0.196)单阶段目标检测,检测 COCO 类别 11(stop sign)
  • ROS 话题链路:/camera/image_raw → perception_node → /perception/traffic_signs → control_node → /vehicle/control_cmd
  • 绕过 cv_bridge:conda 环境里的 OpenCV 5.0.0 与 ROS Noetic 的 cv_bridge 不兼容(CvType 编码 KeyError: 16),本模块手动构造/解析 sensor_msgs/Image 消息
  • 统一入口:roslaunch carla_tsr_ros main.launch 或 bash main.sh

运行环境

  • Ubuntu 20.04 + ROS Noetic
  • conda 环境 carla38(Python 3.8.20)
  • PyTorch 2.0.1+cpu、Torchvision 0.15.2+cpu
  • Ultralytics 8.0.196、OpenCV 5.0.0、NumPy 1.24.3

运行效果

demo

截图显示 /perception/annotated_image 话题的标注图像(YOLO 检测框 + stop sign 0.93),以及 roslaunch 终端持续输出 Detected: ['stop sign']。

运行步骤

详见 README.md。

备注

  • 权重文件 yolov8n.pt(6.3MB)被仓库根 .gitignore 的 *.pt 规则屏蔽,README 中提供了下载地址
  • 相关模块:carla_traffic_sign_recognition(Windows 端 Carla 实时感知,无 ROS)

- package.xml + CMakeLists.txt: catkin package definition
- ros_nodes/image_publisher.py: loop-publish local images to /camera/image_raw
- ros_nodes/perception_node.py: subscribe image, run YOLOv8 inference, publish detections
- ros_nodes/control_node.py: subscribe detections, publish brake command
- main.launch: roslaunch entry to start all three nodes
- main.py + main.sh: unified entry points
- config/params.yaml: runtime parameters
- data/sample_stop.jpg: synthetic stop sign for demo
- demo.gif: ROS pipeline demonstration
- README.md: environment, build steps, NN principle, algorithm flow, weight download
- Bypass cv_bridge by manually building sensor_msgs/Image (cv_bridge incompatible with OpenCV 5.0.0 in conda env)
@HaiLang47

Copy link
Copy Markdown
Contributor Author

根据维护者反馈,ROS 相关功能应提交到 OpenHUTB/ros2 仓库。本 PR 主动关闭,内容将迁移到 ros2 仓库重新提交。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant