Robotics / Simulation

ROS2 & SITL Integration

Advanced simulation environment integrating ROS2 with SITL for autonomous drone testing.

README.md

Color-Based Emergency Landing Zone Detection System#

License: MIT Python 3.10+ PX4 v1.17.0+ ROS 2 Jazzy Gazebo Harmonic Status: Active Development

Overview#

The Color-Based Emergency Landing Zone Detection System is an autonomous robotics solution that enables unmanned aerial vehicles (UAVs) to intelligently identify, evaluate, and select optimal emergency landing zones using real-time computer vision. Built on the modern ROS 2 Jazzy stack with Gazebo Harmonic simulation, the system autonomously processes downward-facing camera feeds to detect colored landing pads, applies a multi-criteria decision algorithm to rank candidates, and selects the safest landing target.

This project demonstrates practical integration of computer vision, autonomous vehicle control, and intelligent decision-making systems in safety-critical UAV operations using cutting-edge robotics middleware.

System Requirements#

Hardware Requirements

  • CPU: Intel i5/i7 equivalent or better
  • RAM: 16GB minimum (8GB with swap)

Software Environment

Operating System

  • Primary: Ubuntu 24.04 LTS (Jazzy)
  • Alternative: Ubuntu 22.04 LTS (Humble - limited support)

Core Dependencies

ComponentVersionPurposeStatus
ROS 2Jazzy (24.04)Robotics middleware✅ Primary
GazeboHarmonicPhysics simulation✅ Primary
PX4v1.17.0-alpha1+Autopilot firmware✅ Latest
Python3.10+ (3.12.3)Development language✅ Supported
OpenCV4.8.0+Computer vision✅ Integrated

ROS 2 Gazebo Integration Stack (Installed)

✅ ros_gz - Core ROS 2 ↔ Gazebo bridge
✅ ros_gz_bridge - Message/service bridging
✅ ros_gz_image - Image transport bridging
✅ ros_gz_interfaces - Custom message types
✅ ros_gz_sim - Gazebo simulation node
✅ gz_ros2_control - Control system integration
✅ gz_sensors_vendor - Sensor simulation packages

Verified Installation:

robot_builder@LAPTOP-UNKNOWN:~/PX4-Autopilot$ ros2 pkg list | grep gz
# All 21 gazebo-ros2 packages installed and verified ✅

Project Status#

PhaseComponentStatus
1Mission Setup & Failure SimulationComplete
2Color Detection & ClassificationComplete
3Landing Zone Selection AlgorithmComplete
4Autonomous Navigation & Precision LandingIn Development

Key Features#

Real-Time Color Detection

  • HSV-based color segmentation for robust detection under varying lighting conditions
  • Five-color detection system: Red, White, Blue, Green, Yellow
  • Real-time processing at 30 FPS with sub-35ms latency
  • Morphological noise filtering with >95% false positive elimination
  • Confidence-based detection validation
  • Compatible with Gazebo Harmonic camera sensor models

Intelligent Decision-Making

  • Multi-criteria decision analysis (MCDA) scoring algorithm
  • Three-factor evaluation: color priority, distance penalty, visibility confidence
  • Deterministic ranking with complete decision audit trail
  • Top-3 candidate selection with score transparency
  • Configurable priority weights for mission-specific optimization

Modern ROS 2 Integration

  • Native ROS 2 Jazzy topic-based communication
  • Gazebo Harmonic through ros_gz bridge infrastructure
  • Unified namespace for sensor data and control commands
  • Type-safe message passing with ROS 2 interfaces
  • Real-time synchronization between simulator and control system

Mission Simulation

  • PX4 SITL v1.17.0-alpha1 integration with realistic autopilot behavior
  • Gazebo Harmonic physics-based simulation environment
  • Pre-planned delivery missions with 5-7 waypoints
  • Programmable battery failure triggers
  • Comprehensive telemetry logging and data persistence

System Robustness

  • Real-time performance at 30 FPS frame rate across all layers
  • Color detection accuracy: 92% (target ≥85%)
  • Scoring algorithm consistency: 100% reproducibility
  • Modular ROS 2 node architecture for component-level testing
  • Complete audit trail for mission analysis and debugging

Completed Components#

Phase 1: Mission Setup and Failure Simulation

Accomplishments:

  • MAVSDK Python framework integration with PX4 SITL v1.17.0
  • ROS 2 Jazzy node creation for mission control
  • Delivery mission design with 5-7 waypoints (25-40m altitude)
  • Battery failure trigger mechanism at waypoint 3-4
  • Real-time telemetry collection via ros_gz topics:
    • GPS coordinates (latitude, longitude) from
      /model/iris/pose
    • Altitude and vertical position data
    • Battery percentage monitoring via autopilot MAVLink
    • Event timestamps and drone velocity vectors
    • Orientation and attitude data via IMU sensors

ROS 2 Integration:

  • Mission controller as ROS 2 node
  • Telemetry subscribers to gazebo topics
  • Service-based failure trigger mechanism
  • Publishing mission state to diagnostic aggregator

Deliverables:

  • ROS 2 mission controller node with MAVSDK integration
  • Telemetry subscriber node for data collection
  • Mission configuration with waypoint definitions
  • Launch file for coordinated startup (
    emergency_landing_mission.launch.py
    )
  • Autopilot communication interface via ros_gz bridge

Phase 2: Color Detection and Classification

Accomplishments:

  • HSV color space processing pipeline with five color channels
  • ROS 2 image subscriber node for camera feed processing
  • Color segmentation for Red, White, Blue, Green, Yellow
  • Morphological image processing (erosion/dilation)
  • Contour detection and validation system
  • GPS coordinate transformation from pixel detections
  • Real-time camera frame processing (30 FPS at <35ms latency) via Gazebo Harmonic camera plugin

ROS 2 Camera Integration:

  • Subscribes to
    /camera/image_raw
    topic from Gazebo
  • Publishes detected pads to
    /detected_landing_pads
    custom topic
  • Uses sensor_msgs/Image type for camera feed
  • Confidence metrics published via
    /pad_detection_diagnostics

HSV Detection Parameters:

ColorHue RangeSaturationValuePriority
Red0-10, 350-360≥100≥100Primary
White0-1800-30≥200Secondary
Blue100-130≥50≥50Tertiary
Green50-90≥50≥50Quaternary
Yellow20-40≥100≥100Last Resort

Deliverables:

  • ROS 2 color detection node with OpenCV integration
  • Camera subscription node for Gazebo Harmonic
  • Morphological image processing pipeline
  • Camera calibration framework with ROS 2 camera_info topics
  • Contour detection and validation algorithms
  • HSV parameter configuration via ROS 2 parameters
  • Custom ROS 2 message types for detected pads

Phase 3: Landing Zone Selection Algorithm

Accomplishments:

  • Multi-criteria scoring formula implementation:
    Final Score = Color Priority - (Distance × 2) + Size Bonus
    
  • Color priority ranking system (Red: 100pts → Yellow: 20pts)
  • Distance-based penalty calculation (2 points per meter)
  • Size-based confidence bonus (10 points if area > 100px)
  • Automatic candidate ranking and selection
  • Structured decision report generation with full transparency
  • ROS 2 service for on-demand landing zone evaluation

ROS 2 Decision Integration:

  • Subscribes to
    /detected_landing_pads
    topic
  • Implements
    /select_landing_zone
    service
  • Publishes ranked candidates to
    /landing_zone_candidates
  • Decision outcome published to
    /selected_landing_zone
  • Logging via ROS 2 logging system with DEBUG/INFO levels

Scoring System:

RankColorPointsClassification
1Red100Primary Emergency Zone
2White80Secondary Safe Zone
3Blue60Tertiary Acceptable Zone
4Green40Quaternary Marginal Zone
5Yellow20Last Resort Zone

Deliverables:

  • ROS 2 landing zone selection node
  • Scoring engine with configurable weights via ROS 2 parameters
  • Ranking and sorting system
  • Decision service implementation
  • Custom ROS 2 message types for scoring results
  • Performance metrics collection node

System Architecture#

ROS 2 Node Architecture

ROS-Nodes Block Diagram

ROS 2 Topic/Service Interface

Topics Published:
  /detected_landing_pads
    - Type: custom_interfaces/DetectedLandingPads
    - Frequency: 30 Hz (30 FPS camera processing)
    - Content: Array of detected pads with color, location, area, confidence

  /landing_zone_candidates
    - Type: custom_interfaces/LandingZoneCandidates
    - Frequency: 1-3 Hz (algorithm execution)
    - Content: Top 3 ranked candidates with scores

  /selected_landing_zone
    - Type: custom_interfaces/SelectedLandingZone
    - Frequency: 1 Hz
    - Content: Chosen target with GPS coords, confidence, decision rationale

Topics Subscribed:
  /camera/image_raw
    - Type: sensor_msgs/Image
    - Source: Gazebo Harmonic camera plugin

  /model/iris/pose
    - Type: geometry_msgs/Pose
    - Source: Gazebo entity pose updates

  /vehicle/battery_status
    - Type: sensor_msgs/BatteryState
    - Source: PX4 MAVLink telemetry

Services:
  /select_landing_zone
    - Type: custom_interfaces/SelectLandingZone
    - Server: landing_zone_selector_node
    - Request: List of detected pads
    - Response: Selected target + scoring breakdown

Parameters:
  /color_detector/hsv_ranges
  /landing_zone_selector/color_priorities
  /landing_zone_selector/distance_penalty
  /landing_zone_selector/size_bonus

Data Flow Pipeline

ROS-Pipeline Block Diagram


ROS 2 Launch Configuration#

Main Launch File:
emergency_landing_mission.launch.py

from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource

def generate_launch_description():
    # Gazebo Harmonic simulator
    gazebo_launch = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            'ros_gz_sim/launch/gz_sim.launch.py'),
        launch_arguments={'gz_args': '-r custom_landing_zones.world'}.items()
    )
    
    # PX4 SITL bridge node
    px4_bridge_node = Node(
        package='ros_gz_bridge',
        executable='parameter_bridge',
        arguments=[
            '/clock@rosgraph_msgs/Clock[gz.msgs.Clock',
            '/camera@sensor_msgs/Image[gz.msgs.Image',
            '/model/iris/pose@geometry_msgs/PoseStamped[gz.msgs.Pose',
            '/vehicle/battery_status@sensor_msgs/BatteryState'
        ]
    )
    
    # Color detection node
    color_detector = Node(
        package='color_detection',
        executable='color_detector_node',
        name='color_detector',
        parameters=['config/hsv_color_ranges.yaml']
    )
    
    # Landing zone selector node
    zone_selector = Node(
        package='color_detection',
        executable='landing_zone_selector_node',
        name='landing_zone_selector',
        parameters=['config/mission_params.yaml']
    )
    
    # Telemetry logger
    logger_node = Node(
        package='color_detection',
        executable='telemetry_logger_node',
        name='telemetry_logger'
    )
    
    return LaunchDescription([
        gazebo_launch,
        px4_bridge_node,
        color_detector,
        zone_selector,
        logger_node
    ])

References#


License#

This project is licensed under the MIT License - see the LICENSE file for details.


Last Updated: December 2025
Project Status: Active Development - Phase 3 Complete, Phase 4 In Progress
ROS 2 Version: Jazzy (24.04)
Gazebo Version: Harmonic
PX4 Version: v1.17.0-alpha1+