MyRoboPath
computer vision16 min readUpdated 2026-03-11Intermediate

Real-Time Object Detection with YOLOv8 & ROS 2 Integration

Train custom YOLOv8 models, export optimized ONNX/TensorRT engines, and publish 2D/3D bounding boxes and class probabilities over ROS 2 topics.

Dr. Elena Rostova
Dr. Elena Rostova
Principal Computer Vision Scientist

Key Engineering Takeaways

  • YOLOv8 uses an anchor-free split head with task-aligned assigner, achieving higher mean Average Precision (mAP) and faster inference.
  • Convert ROS 2 `sensor_msgs/msg/Image` to OpenCV NumPy matrices using `cv_bridge`.
  • Publish standard `vision_msgs/msg/Detection2DArray` messages containing bounding boxes and classification scores.
Prerequisites
  • Python 3
  • ROS 2 basics
  • PyTorch basics

YOLOv8 Architecture & Anchor-Free Detection

YOLOv8 by Ultralytics eliminates predefined anchor boxes, directly predicting the center coordinates and bounding box dimensions. This improves generalization across diverse robotics targets (tools, packages, pedestrians, obstacles).
Tags:#YOLOv8#Object Detection#ROS 2#Deep Learning#PyTorch#Vision