NOTE: This package is tested on Jetson Xavier AGX with Jetpack 5.1.3, ROS2 Foxy and Python3.8 using YOLOv8 object detection model only.
- Python >= 3.8
- ROS2 Foxy/Humble
- Ubuntu 20/22
- First install PyTorch on the machine (for Python and C++ LibTorch). For NVIDIA Jetson, follow the instruction at https://forums.developer.nvidia.com/t/installing-pytorch-for-cuda-10-2-on-jetson-xavier-nx-for-yolov5/183868/2 for installation.
- Obtain a pretrained model in torchscript format (.torchscript/.torchscript.pt). Follow instructions in YOLOv8 export.
- Clone this project to your ROS2 workspace
cd ~/ros2_ws/src
git clone https://github.com/joewong00/yolov8-ros2-wrapper.git yolov8_wrapper
- Ensure both
torchscript
model and a class lists file (coco.names
) is present, modify the path to both of the files in the launch file. - Install ROS dependencies
cd ../
sudo rosdep init
rosdep update
rosdep install --from-paths src -y --ignore-src
- Build the package
colcon build --symlink-install
- Run the detector
ros2 launch yolov8_wrapper detect.launch.py
https://github.com/ultralytics/ultralytics/tree/main/examples/YOLOv8-LibTorch-CPP-Inference