Object Detection Applications
rcar_object_detection drives the YOLOv5, YOLOv8, and YOLOX detectors through
the rcar_model graph runtime and publishes detections and inference timing.
rcar_chess_pieces_detection builds on the same YOLOv8 path and adds board-state
reconstruction.
rcar_object_detection
The package provides four executables that share one model-configuration and launch convention:
Executable |
Topology |
Lanes |
Default |
|---|---|---|---|
|
Multi-lane YOLOv5 (TVM backbone plus ONNX Non-Maximum Suppression (NMS)) |
4 |
|
|
Single-stage YOLOv8 |
1 |
|
|
Single-stage YOLOX |
1 |
|
|
Single-stage YOLOX for soft objects |
1 |
|
Parameters
The following table lists the node parameters:
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
string |
per executable |
Key in |
|
double |
0.4 |
Detection score threshold. Overrides the value in the YAML file when set. |
|
double |
from the YAML file |
NMS Intersection over Union (IoU) threshold. Not used by |
|
int |
1 |
Drop-oldest depth on the per-lane frame source and on the image subscription QoS history. |
|
string[] |
one entry per lane |
Input topics. The length must match the number of inputs in the |
Topics
The following table lists the topics the node subscribes to and publishes:
Topic |
Direction |
Type |
|---|---|---|
|
sub |
|
|
pub |
|
|
pub |
|
|
pub |
|
For the multi-lane YOLOv5 node the lane index is taken from the trailing digits of the model or
input name in the JSON, so detect0, nms3, and in2 map to lanes 0, 3, and 2.
Provided Models
The following table lists the models shipped with the package:
|
Classes |
Confidence |
IoU |
Stages |
|---|---|---|---|---|
|
80 (COCO) |
0.4 |
0.45 |
|
|
3 (paper, rock, scissor) |
0.6 |
0.3 |
|
|
3 (paper, rock, scissor) |
0.6 |
0.3 |
|
|
5 (carrot, coke, egg, pp_cup, sponge) |
0.7 |
0.45 |
|
Class names, thresholds, and the graph wiring live in config/models/models_config.yaml and in
each model’s config/models/<name>/exec_config.json. The compiled models ship with the package
under config/models/<name>/models/; every TVM model is compiled with REACTION
task: tvm_cch.
Launch Files
Each launch file brings up its image sources, the detection node, a per-lane bounding-box
visualizer, a timing overlay, and a foxglove_bridge on port 8765.
# Four-lane YOLOv5 on the bundled COCO test images
ros2 launch rcar_object_detection static_yolov5_4lane.launch.py
# Single-lane YOLOv8 rock-paper-scissors on a bundled test image
ros2 launch rcar_object_detection static_yolov8_rps.launch.py
# Single-lane YOLOX rock-paper-scissors on a bundled test image
ros2 launch rcar_object_detection static_yolox_rps.launch.py
For the four-lane launch, the outputs are remapped per lane to
/object_detection/lane<lane>/bounding_box and
/object_detection/lane<lane>/inference_timing.
To run a node directly with custom settings:
# Custom confidence threshold
ros2 run rcar_object_detection yolov8_rps_detection --ros-args -p confidence_threshold:=0.6
# Point a single-lane detector at another image topic
ros2 run rcar_object_detection yolov8_rps_detection \
--ros-args -p image_topics:="['/camera/image_raw']"
# Give YOLOv5 its four input topics
ros2 run rcar_object_detection yolov5_object_detection \
--ros-args -p image_topics:="['/cam0','/cam1','/cam2','/cam3']"
Adding a Model
Place the model artifacts under
config/models/<name>/: anexec_config.jsonplus amodels/subdirectory holding the per-stage TVM and ONNX files it references. Thefilepaths in the JSON are relative to theexec_config.jsondirectory.Add an entry to
config/models/models_config.yaml:<name>: exec_config: "models/<name>/exec_config.json" # relative to config/ class_names: [ ... ] confidence_threshold: 0.4 iou_threshold: 0.45 input_order: rgb # optional, default 'rgb'; set 'bgr' for BGR-trained models
Stage names such as
detect0andnms1are read from themodelssection of the JSON at startup. Do not declare them in the YAML file. For atvm_cchmodel, also setinput_nameon itsmodelsentry, as described in The exec_config.json File.Rebuild, then run with
-p model_type:=<name>.
rcar_chess_pieces_detection
This package runs a 12-class YOLOv8 detector through the same runtime and converts the detections
into a board state expressed as a Forsyth-Edwards Notation (FEN) piece-placement string. The
model, yolov8_chess, is YOLOv8m at 640x640 compiled with REACTION task: tvm_cch.
The executable is yolov8_chess_pieces_detection.
Parameters
The following table lists the node parameters:
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
string |
|
Key in |
|
double |
0.5 |
Detection score threshold. |
|
double |
0.45 |
NMS IoU threshold. |
|
string[] |
|
One entry per lane. |
|
int |
1 |
Frames buffered per lane. |
|
bool |
false |
Publish |
|
double |
800.0 |
Canonical board size the homography rectifies to. |
|
string |
|
Square-center calibration the FEN homography is built from. |
|
bool |
false |
Run inference only on |
|
double |
5.0 |
How long a |
Topics and Services
The following table lists the topics and services of the node:
Name |
Kind |
Type |
|---|---|---|
|
sub |
|
|
pub |
|
|
pub |
|
|
pub |
|
|
pub |
|
|
srv |
|
|
srv |
|
Building
Build each package inside the cross-compilation container:
cross-colcon-build --packages-up-to rcar_object_detection
cross-colcon-build --packages-up-to rcar_chess_pieces_detection