YOLO object detection on a robot: a practical setup

Run YOLO on a robot: frame-rate budget, model size, dataset, export formats, turning boxes into 3D positions and the failures seen in real cells.

Reference
RE-958
Published
Read
7 min

About the author · Sources, testing and AI policy

Industrial camera above a tote of metal parts with a robot gripper reaching in

YOLO on a robot is a solved problem in the lab and a hard one in a cell. The detector is rarely the bottleneck; lighting, latency and the link from pixel to robot coordinate are.

This guide covers the hardware that can run a detector at a usable frame rate, how to prepare a small dataset, how to export and run the model, how to convert a detection into a 3D position, and the failure modes that make demos fall apart in production.

Start with the frame-rate budget

Decide how often your robot needs a decision. A mobile robot moving at 0.5 m/s needs a detection at least every 200 ms to react within 10 cm. An arm picking from a static bin can work at 2 frames per second. That number determines the hardware.

PlatformRealistic inferenceNotes
Laptop CPUA few fps at 640 pxFine for development and offline tests
Raspberry Pi 5Low single digits at 640 pxUse a small model, expect thermal throttling
Jetson Orin NanoTens of fps at 640 pxTensorRT export, active cooling required
Jetson Orin NXHigher, or larger modelsMore power and cost
Desktop GPUHighestNot practical on a small robot

These are ranges, not promises. Measure on your own robot with your own camera, because resolution, model size and cooling change the answer by a large factor.

Pick a model size that fits

Current YOLO families ship in several sizes, from a nano variant to a large one. The nano model is roughly an order of magnitude faster than the large model and less accurate on small or overlapping objects. For a robot detecting cups, boxes or people at close range, nano or small is usually enough.

  • Nano: embedded boards, high frame rate, easy classes.
  • Small: a good default on Jetson or a laptop.
  • Medium and large: offline inspection, or a desktop GPU in the cell.
  • Segmentation models: when you need the outline, for grasping or area.
  • Pose models: when you need keypoints, such as a human hand.

Do not start with the largest model and plan to shrink later. Start with the smallest model that clears your accuracy requirement, because deployment constraints are harder to fix than accuracy.

Build a dataset from your own camera

Public datasets rarely match your lens, lighting and background. Record a few hundred frames from the actual robot in the actual cell, at the heights and angles it will use. Then label them.

  • Capture at the deployment resolution, not a higher one you will never use.
  • Include the lighting you will actually have, including the bad hour of the day.
  • Include partial occlusion, clutter and empty scenes.
  • Label consistently; define the box for a partly visible object.
  • Hold out a validation set from a different session, not the same video.

A few hundred well-labelled images can outperform a few thousand sloppy ones. The usual failure is a dataset that only contains perfect views, so the model fails the moment a part is rotated or half-hidden.

Train, export and run

Training on a desktop GPU is faster and does not tie up the robot. Export the trained weights to a runtime your robot supports: ONNX for portability, TensorRT for Jetson, NCNN or TFLite for small ARM boards.

yolo detect train data=dataset.yaml model=yolo11n.pt epochs=100 imgsz=640
yolo export model=runs/detect/train/weights/best.pt format=onnx imgsz=640
yolo export model=runs/detect/train/weights/best.pt format=engine imgsz=640

TensorRT engines are specific to the GPU, TensorRT version and often the exact batch size and resolution. Build the engine on the target device, not on your laptop, or you will spend an evening debugging a deserialisation error.

At runtime, keep the pipeline simple: capture frame, resize, infer, filter by class and confidence, publish results. Every extra copy and colour conversion costs milliseconds on an embedded board.

From bounding box to robot coordinate

A box in the image says where the object is on screen. The robot needs a position in its own frame. There are three common ways to get there.

MethodHowBest for
Fixed plane assumptionBack-project the box centre onto a known table heightPick and place on a flat surface
Depth cameraSample depth at the box centre or median of the maskUnknown heights, bins
Calibrated stereo or lidarTriangulate or project onto a point cloudOutdoor or long range

All three need camera intrinsics and a transform from the camera frame to the robot base. In ROS 2, that is a TF lookup at the timestamp of the image, not “latest”. Using the latest transform with a stale image is a classic source of centimetre-level error while the arm moves.

# typical ROS 2 shape
# 1. subscribe to image and camera_info
# 2. run detector on the image
# 3. use the box centre pixel and depth to get a 3D point in camera frame
# 4. transform that point to base_link using the image timestamp
# 5. publish a pose or send a grasp goal

Calibration matters more than the model

If the camera intrinsics are wrong, the box will be in the right place on screen and the robot will reach the wrong place in the world. Calibrate with a checkerboard or Charuco board, and re-check after any bump to the camera mount.

  • Calibrate at the resolution you will run.
  • Use at least 20 varied views across the image.
  • Record the reprojection error and keep it with the calibration file.
  • Verify the hand-eye transform with a physical target, not by eye.
  • Re-calibrate after transport, impact or a lens change.

Failure modes you will actually see

SymptomLikely causeFix
Good in the lab, poor in the cellLighting or background changedRetrain with cell images
Detections lag the robotFull-resolution inference or no hardware accelerationSmaller model, lower resolution, TensorRT
Boxes drift when the arm movesTransform at the wrong timestampUse the image timestamp for TF
Misses small partsDownscaling or model too smallCrop, raise resolution, larger model
Confident false positivesBackgrounds in the dataset too cleanAdd negatives and clutter
Frame rate drops over timeThermal throttlingCooling, lower power mode, duty cycle

A sensible first deployment

Start with a fixed camera looking at a flat pick area, one object class, and a robot that moves to a detected position and stops. No grasping, no clutter. Prove the pixel-to-robot path end to end, then add a second class, then add grasping, then move the camera onto the arm.

That sequence isolates failures. Most teams that struggle jumped straight to a moving camera with a multi-class model, and then cannot tell whether the problem is detection, calibration, timing or the grasp.

Related: OpenCV on Raspberry Pi, robot vision camera guide, Raspberry Pi vs Jetson, TCP calibration, ROS 2 TF2 tutorial.

Can YOLO run on a Raspberry Pi?

Yes, with a small model and a lightweight runtime, but expect low single-digit frame rates at 640 pixels. A Jetson board is a better fit if you need more than about 10 frames per second.

How many images do I need to train a YOLO model for a robot?

A few hundred well-labelled images from your own camera often work for a small number of classes. More important than count is variety: lighting, angles, occlusion and empty scenes.

How do I convert a YOLO bounding box into a robot position?

Take the box centre pixel, use the camera intrinsics and a depth source or a known plane to get a 3D point in the camera frame, then transform it into the robot base frame using the image timestamp.

Why does my detector work in testing but fail in the cell?

Usually the training images do not match the cell lighting, background or camera angle. Retrain with images recorded in the real environment, including difficult conditions.

Which YOLO export format should I use on a Jetson?

TensorRT, built on the target device. ONNX is a good portable fallback, but TensorRT gives the best throughput when the engine matches the device and software versions.

A clean image starts with the machine vision lighting guide.

Detection gives a box; guidance needs a transform, covered in the vision-guided robotics guide.

A detector gives a bounding box, and an OpenCV calibration step gives that box a real world position.

A colour model gives boxes, not distance; add a depth camera if the robot must reach the object it detected.

To run a detector at frame rate, convert it with the TensorRT workflow described here.

Detection models are one option among several, and the defect detection guide explains when rules are the better choice.

Sources and further reading

Pass it onWhatsAppLinkedIn

Keep reading

Continue learning

The Build Note

One short email when something is worth your bench time.

A new build sheet, a part price that moved, or a mistake worth avoiding. No daily drip, no recycled news.

One short email when a build or a price is worth your time. Unsubscribe in one click.