๐ฉ Object Detection Node
The Object Detection Node is the vision brain of your robot โ it processes images from the onboard camera, detects objects using YOLOv8, estimates their positions, and publishes them to ROS2 so other nodes (like navigation and manipulation) can act.
๐ What It Does & How It Worksโ
Hereโs a high-level summary of the main logic in object_detector.py:
- Initializes ROS2 node and loads YOLOv8 model weights.
- Subscribes to RGB and depth image topics.
- For each incoming frame:
- Runs YOLOv8 inference to detect objects.
- For each detection, extracts bounding box, class, and confidence.
- Uses depth data to estimate the 3D position of each detected object.
- Publishes:
- Target pose (
geometry_msgs/PoseStamped) for navigation/manipulation. - Detection list (bounding boxes, classes, confidences).
- Annotated image with detection overlays.
- Target pose (
- Handles configuration via parameters (e.g., depth limits, YOLO weights).
- Includes error handling for missing images, sync issues, and model loading.
See the source code for implementation details.
- Subscribes to RGB and depth image topics from the Orbbec DaBai depth camera.
- Runs YOLOv8 inference on each frame to detect objects in real time.
- Estimates 3D positions of detected objects using depth data.
- Publishes detections:
/target_poseโgeometry_msgs/PoseStamped(used by Mission Manager & Navigation)/detectionsโ list of bounding boxes, class names, confidence scores/image_bboxโ image with overlayed detection boxes and labels
โ๏ธ Setup & Configurationโ
1. Requirementsโ
- Python โฅ 3.8
- ROS2 Foxy workspace
- Ultralytics YOLOv8 installed
- Depth camera drivers running
2. Installationโ
Clone the object detector package into your workspace:
cd ~/limo_ws/src
git clone https://github.com/krish-rRay23/LIMO_COBOT_PROJECT/blob/main/src/object_detector/
cd ~/limo_ws
colcon build
source install/setup.bash
3. Configuration Parametersโ
Inside object_detector.py:
MIN_DEPTH_METERS = 0.15 # Ignore objects closer than 15cm
MAX_DEPTH_METERS = 4.0 # Ignore objects further than 4m
APPROACH_DIST = 0.30 # Distance to stop before object
YOLO_WEIGHTS = "runs/detect/train/weights/best.pt"
You can adjust these values in the launch file or node parameters.
โถ๏ธ Usage Instructionsโ
Start the camera drivers:
ros2 launch orbbec_camera dabai.launch.py
Run the Object Detection Node:
ros2 run object_detector yolo_detector
Verify outputs:
- View annotated detections in RViz or
rqt_image_view - Monitor detection topic:
ros2 topic echo /detections
For full autonomous mode, launch with full_system.launch.py โ it will auto-start the detector and integrate with navigation/manipulation.
๐ฏ Training Your Own YOLO Modelโ
To detect new objects:
1. Collect Imagesโ
- Use the robot camera or a smartphone
- Capture from multiple angles, lighting conditions, and distances
2. Label Dataโ
- Use LabelImg or Roboflow
3. Train YOLOv8โ
yolo task=detect mode=train model=yolov8n.pt data=your_data.yaml epochs=50 imgsz=640
4. Deploy Weightsโ
- Copy
best.ptto the robot - Update
YOLO_WEIGHTSpath inobject_detector.pyor launch file
๐ Troubleshooting Tipsโ
| Problem | Possible Cause | Solution |
|---|---|---|
| No detections | Wrong weights or incorrect camera topic | Check YOLO_WEIGHTS path & camera topics |
| Poor accuracy | Dataset too small / poorly labeled | Collect more varied training data |
| Depth pose is wrong | Depth/RGB not synced | Use message filters for synchronized topics |
| Slow FPS | Model too large for hardware | Use smaller YOLO model (e.g., yolov8n.pt) |
| Node crashes on startup | Missing dependencies | Reinstall ultralytics & required packages |
Always verify your depth alignment and TF transforms โ incorrect transforms will cause wrong navigation goals.