Skip to content

jonaw2005/UARV

Repository files navigation

๐Ÿ›ฉ๏ธ UARV โ€” Unmanned Aerial Reconnaissance Vehicle

A full-stack MAVLink ground control system for ArduPilot/PX4-based drones

Python Flask Socket.IO Leaflet MAVLink Raspberry Pi NGINX


โœจ Features โ€ข ๐Ÿ—๏ธ Architecture โ€ข ๐Ÿš€ Getting Started โ€ข ๐Ÿ“ก API Reference โ€ข ๐Ÿ–ฅ๏ธ Web Interface โ€ข ๐Ÿ› ๏ธ Configuration โ€ข ๐Ÿ“ Project Structure


โœจ Features

๐ŸŽฎ Full Drone Control

  • Arm / Disarm with safety confirmation
  • Flight mode switching (MANUAL, FBWA, AUTO, GUIDED, RTL, LOITER, STABILIZE, LAND)
  • Takeoff with automatic GUIDED mode transition
  • Velocity control (local NED frame)
  • GPS waypoint navigation (goto command)
  • Mission upload & download with full MAVLink protocol support
  • Emergency abort (disarm + switch to MANUAL)

๐Ÿ“Š Real-Time Telemetry

  • GPS position (latitude, longitude, altitude)
  • Attitude (roll, pitch, yaw)
  • Velocity (ground speed, airspeed, climb rate)
  • Battery status (voltage, current, remaining %)
  • GPS quality (fix type, satellite count)
  • System health (connected status, heartbeat)
  • Live video stream via Socket.IO at ~30 FPS

๐Ÿ—บ๏ธ Interactive Map

  • Leaflet-based with OpenStreetMap tiles
  • Real-time aircraft position with heading indicator
  • Rotating triangle marker showing drone orientation
  • Auto-centering on GPS coordinates
  • Telemetry data in a draggable floating window

๐Ÿ“‹ Mission Planner

  • Visual waypoint placement by clicking on the map
  • Action insertion (takeoff, loiter, RTL, land, delay, speed, yaw)
  • Drag-and-drop reordering of mission items
  • Mission upload to Pixhawk via MAVLink
  • Mission download from Pixhawk
  • Coordinate input for precise waypoint placement

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Raspberry Pi (onboard)                   โ”‚
โ”‚                                                             โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚  controll_api.py โ”‚โ—„โ”€โ”€โ–บโ”‚        mav_bridge.py         โ”‚   โ”‚
โ”‚  โ”‚  (Flask + Socket)โ”‚    โ”‚   (pymavlink MAVLink bridge) โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚         โ”‚                           โ”‚                       โ”‚
โ”‚         โ”‚ HTTP/WS                   โ”‚ UART (921600 baud)    โ”‚
โ”‚         โ–ผ                           โ–ผ                       โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                 โ”‚
โ”‚  โ”‚  Web Browser โ”‚          โ”‚   Pixhawk    โ”‚                 โ”‚
โ”‚  โ”‚  (Admin UI)  โ”‚          โ”‚  (ArduPilot) โ”‚                 โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Component Breakdown

Component Technology Purpose
controll_api.py Flask + Flask-SocketIO REST API server & WebSocket video streaming
mav_bridge.py pymavlink MAVLink protocol bridge to Pixhawk over UART
admin_panel/ HTML/CSS/JS + Leaflet Web-based ground control interface
config.js JavaScript Dynamic API URL resolution via window.location.origin

๐Ÿš€ Getting Started

Prerequisites

  • Hardware: Raspberry Pi (any model with UART), Pixhawk (or any ArduPilot/PX4 autopilot)
  • Connection: Pixhawk connected to Raspberry Pi UART (/dev/ttyAMA0)
  • Software: Python 3.10+, pip

Installation

# 1. Clone the repository
git clone https://github.com/jonaw2005/UARV.git
cd UARV

# 2. Install Python dependencies
pip install -r requirements.txt

# 3. (Optional) Create a virtual environment
python -m venv venv
source venv/bin/activate  # Linux/Mac
# or: venv\Scripts\activate  # Windows

Running

# Start the API server (default: port 8000)
python controll_api.py

The web interface will be available at: http://<raspberry-pi-ip>:8000

Note: The web interface automatically detects the server's IP address using window.location.origin โ€” no hardcoded IPs needed!


๐Ÿ“ก API Reference

Status & Health

Endpoint Method Description
/api/status GET API health check
/api/get_health GET System health status
/api/get_telemetry GET Full telemetry data
/api/get_location GET GPS location only

Vehicle Control

Endpoint Method Description
/api/arm GET Arm the vehicle
/api/disarm GET Disarm the vehicle
/api/arm_disarm GET Toggle arm/disarm
/api/is_armed GET Check armed status
/api/takeoff GET Takeoff (switches to GUIDED)
/api/change_flightmode POST Change flight mode
/api/get_flightmode GET Get current flight mode
/api/set_velocity POST Set velocity (vx, vy, vz)
/api/goto POST Go to GPS coordinate

Mission Management

Endpoint Method Description
/api/mission_upload POST Upload mission to Pixhawk
/api/mission_download GET Download mission from Pixhawk
/api/mission_start GET Start mission (switch to AUTO)
/api/abort_mission GET Abort mission (disarm + MANUAL)

Parameters & GPS

Endpoint Method Description
/api/get_param POST Read a single parameter
/api/get_param_test GET Test: read STAT_RUNTIME
/api/get_all_params GET Read all parameters
/api/get_gps GET GPS position (GLOBAL_POSITION_INT)
/api/get_gps_raw GET GPS position (GPS_RAW_INT)
/api/gps_status GET GPS fix type & satellites
/api/battery_level GET Battery voltage, current, remaining

Video Streaming

Endpoint Method Description
/video GET MJPEG video stream
Socket.IO video_frame WS Base64-encoded JPEG frames

๐Ÿ–ฅ๏ธ Web Interface

Dashboard (index.html)

The main dashboard provides three panels:

Panel Features
๐Ÿ“ท Live Camera Real-time video stream from the onboard camera via Socket.IO. Displays connection status and stream URL.
๐Ÿ—บ๏ธ Interactive Map โ€ข Leaflet map with OpenStreetMap tiles
โ€ข Aircraft position with heading-indicating triangle marker
โ€ข GPS coordinate display (lat/lon)
โ€ข Telemetry floating window (attitude, velocity, battery, GPS)
โ€ข Mission Order floating window (downloaded mission display)
๐ŸŽฎ Controls โ€ข Arm/Disarm toggle with automatic status polling (every 3s)
โ€ข Flight mode dropdown (MANUAL, FBWA, AUTO, GUIDED, RTL, LOITER, STABILIZE, LAND)
โ€ข Takeoff button
โ€ข Abort button
โ€ข Mission Planner link
โ€ข Mission Order download button

Mission Planner (mission_planner.html)

A full-featured mission planning interface:

  • Click-to-place waypoints on the map
  • Action insertion with parameter configuration
  • Drag-and-drop reordering of mission items
  • Coordinate form for precise waypoint entry
  • Mission upload to Pixhawk (converts to MAVLink format)
  • Mission download from Pixhawk
  • Numbered markers and route polyline visualization

๐Ÿ› ๏ธ Configuration

Pixhawk Connection

The connection is configured in controll_api.py:

bridge = MAVBridge("/dev/ttyAMA0", baud=921600)
Parameter Default Description
connection_string /dev/ttyAMA0 UART device path
baud 921600 Baud rate (must match Pixhawk)
source_system 255 MAVLink system ID

Web Interface

All API URLs are dynamically resolved using window.location.origin (defined in admin_panel/config.js). No configuration needed โ€” just access the web interface from any device on the same network.


๐Ÿ“ Project Structure

UARV/
โ”œโ”€โ”€ controll_api.py          # Flask REST API + Socket.IO server
โ”œโ”€โ”€ mav_bridge.py            # MAVLink protocol bridge
โ”œโ”€โ”€ mav_bridge_backup.py     # Backup of original bridge
โ”œโ”€โ”€ mav_test.py              # MAVLink test script
โ”œโ”€โ”€ requirements.txt         # Python dependencies
โ”œโ”€โ”€ servo_test.py            # Servo test script
โ”œโ”€โ”€ test_mission_download.py # Mission download test
โ”œโ”€โ”€ test_mission_upload.py   # Mission upload test
โ”œโ”€โ”€ update_uarv.sh           # Update script
โ”œโ”€โ”€ README.md                # This file
โ”‚
โ””โ”€โ”€ admin_panel/             # Web frontend
    โ”œโ”€โ”€ config.js            # Shared configuration (API_BASE)
    โ”œโ”€โ”€ index.html           # Main dashboard
    โ”œโ”€โ”€ mission_planner.html # Mission planner interface
    โ”œโ”€โ”€ stylesheet.css       # Main stylesheet
    โ”œโ”€โ”€ mission_planner.css  # Mission planner styles
    โ”œโ”€โ”€ buttons.js           # Control buttons & arm status polling
    โ”œโ”€โ”€ camera.js            # Socket.IO video stream client
    โ”œโ”€โ”€ map.js               # Leaflet map, telemetry, mission display
    โ”œโ”€โ”€ mission_planner.js   # Mission planning logic
    โ”œโ”€โ”€ logo.png             # UARV logo
    โ””โ”€โ”€ ...

๐Ÿ”ง Dependencies

Package Version Purpose
flask โ‰ฅ2.0 Web framework
flask-socketio โ‰ฅ5.0 WebSocket support for video streaming
pymavlink โ‰ฅ2.4 MAVLink protocol implementation
opencv-python โ‰ฅ4.5 Camera capture & JPEG encoding
eventlet โ€” (Removed โ€” conflicts with pymavlink)

โš ๏ธ Troubleshooting

"Pixhawk not responding"

  • Check UART connection (/dev/ttyAMA0)
  • Verify baud rate matches Pixhawk configuration (921600)
  • Ensure Pixhawk is powered and running ArduPilot

"Arm command fails"

  • Check pre-arm status in telemetry
  • Ensure the vehicle is in GUIDED or STABILIZE mode
  • Verify GPS has a 3D fix

"Video stream not loading"

  • Check camera connection (/dev/video0)
  • Verify the API server is running on port 8000
  • Check browser console for Socket.IO connection errors

Built with โค๏ธ for the UARV project

GitHub

About

Complete UAV ground control software with MAVLink protocol bridge, web dashboard, live camera feed, GPS tracking, and mission upload/download.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors