Skip to content

RoshaRazmarafar02/MathworksMiniDroneCompetition-BigO1-2024

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Equilibrium Algorithmic Framework for Autonomous Navigation of MiniDrone

Team Big O One · MathWorks Minidrone Challenge
1st place · 2024 (National, Turkey) — 4th place · 2023

Rosha Razmarafar  ·  Şafak ATAN
Maltepe University · Faculty of Engineering and Natural Sciences
Recognized by MathWorks Italy and MathWorks Turkey — Maltepe University announcement


Project

The MathWorks Minidrone Challenge tasks student teams with designing a fully autonomous flight controller for a Parrot Mambo Minidrone that follows a marked track, executes turns, and lands precisely on a designated circle — using only the drone's onboard sensors and camera. No external positioning or motion-capture systems are allowed.

This repository contains the full MATLAB/Simulink implementation and hardware-flight-tested codebase submitted by team Big O One for the 2024 competition, along with the accompanying research paper: "Equilibrium Algorithmic Framework for Autonomous Navigation of MiniDrone" (included as PDF).

The framework integrates three tightly coupled components — image processing, control algorithms, and path planning — into a single model-based design that was compiled via Embedded Coder and deployed directly to hardware.


Algorithmic Framework

The final controller is the result of three iterative algorithm generations, each resolving the failure modes of the previous one.

Algorithm 1 — Midpoint Navigation

The first approach extracted midpoints along the camera-visible path, scaled their coordinates by a constant factor (0.00001), and forwarded them to the path planner for navigation. A bottom-half camera mask was applied to prevent the drone from retracing its path. The approach worked for straight segments but failed on sharp turns and higher velocities, where the drone would lose track of the path.

Algorithm 2 — Manual Yaw for 90° Turns

The second algorithm introduced a manually calculated yawOut to enable 90-degree turns, combined with the midpoint image processing from Algorithm 1. This allowed more versatile movement but introduced a new failure mode: at perpendicular angles, the bottom-half mask simultaneously obscured both the continuation of the path and the drone's rear, preventing the turn from completing correctly.

Algorithm 3 — Equilibrium Framework (Final)

The winning solution decoupled path detection from turn detection using a structured set of submatrices and eliminated the earlier mask ambiguity through a 60-degree forward field-of-view constraint.

Image Processing — Line Following

The 160×120 camera frame is processed through morphological erosion to remove noise and thin isolated pixels, leaving a clean path. Seven symmetric submatrices, each dedicated to a specific detection role, operate in parallel on the cleaned frame:

Submatrix Role
str_l / str_r Left / right stabilizers — keep drone centred on straight path
str_l_t / str_r_t Turn stabilizers — re-centre after completing a yaw manoeuvre
left_t / right_t Detect left / right turn condition
po Path-is-over — triggers landing evaluation

The screen is segmented at 30°, 60°, and 90° angles to provide angular reference for yaw decisions. A 60-degree forward-only mask prevents the drone from seeing its own path history and avoids conflicts with perpendicular segments.

Image Processing — Circle Detection

When po activates, the circle detection pipeline engages. A 10-pixel erosion removes the straight path from the binary image, leaving only circular structures. A Blob Analysis block computes centroids and bounding boxes. To avoid false positives at acute-angle vertices (which can resemble circles after erosion), a second independent blob analysis runs on the raw vision frame. The landing phase triggers only when both blob analyses confirm the circle.

Path Planning — Stateflow

The drone transitions between four primary movement states:

Hover (3 s stabilise)
  ↓
Movement  ←→  yaw_left_stabilizer
  ↓       ←→  yaw_right_stabilizer
yaw_left / yaw_right
  ↓
Land

State transitions are driven by the boolean flags output by the image processing subsystem (str_l, str_r, left_t, right_t, po, circle, mainX, mainY). During movement, position is incremented as:

xout = xout + 0.0008 · cos(yaw_estim)
yout = yout + 0.0008 · sin(yaw_estim)

Yaw states increment yawout by ±0.001 per step. The stabiliser states run simultaneously with yaw, correcting lateral drift before transitioning to forward motion, which significantly reduces the time needed to re-centre on the line. Landing descends at zout += 0.004 per step until touchdown.


Performance Results

Four parameter configurations were evaluated across six waypoints each. Completion time, flight speed, yaw stabiliser parameters, and landing speed were varied systematically.

Config Speed Yaw stab. Landing speed Outcome
1 0.0008 0.0008 0.004 Final accepted solution — all 6 waypoints
2 0.0008 0.0008 0.002 All waypoints · smoother landing
3 0.0008 0.00085 0.004 All waypoints · faster but less accurate
4 0.0015 0.0008 0.004 Rejected — lost path at waypoint 4

Configuration 1 was selected for competition submission. In real-world flights, the controller operated with a 98% gain (rather than full gain) on motor torque distribution to prevent over-actuation under battery-power variance. The use of yaw, erosion, and submatrices delivered superior orientation control and improved path precision across all tested scenarios.

Hardware flight progression:

Session Track completion
Flight 1 16%
Flight 2 10%
Flight 3 98%
Flight 4 98%
Flight 5 98%
Flight 6 100%
Flight 7 100% ✓
Flight 8 100%
Flight 9 100%
Flight 10 100% — full sequence with turns, hover & landing

System Architecture

The project is a MATLAB Simulink Project (parrotMinidroneCompetition.prj) structured as follows:

.
├── controller/          # Flight Control System — deployed to hardware
│   └── flightControlSystem.slx
├── mainModels/          # Top-level simulation model and competition data
│   ├── parrotMinidroneCompetition.slx
│   ├── cmdData.mat / cmdData.xlsx
│   └── sensorCalibration.mat
├── linearAirframe/      # Linearised 6DOF model at hover trim point
├── nonlinearAirframe/   # Full nonlinear 6DOF airframe
├── libraries/           # Shared dynamics and environment block libraries
├── tasks/               # Workspace initialisation and parameter scripts
├── utilities/           # Code generation helpers (generateFlightCode.m)
├── tests/               # Simulink Test harness
├── waypoints.csv        # Competition track waypoints
└── droneFlight*.txt     # Raw hardware telemetry logs from each test session

Low-level control and estimation (inside flightControlSystem.slx):

Channel Method Sensors
Attitude Kalman Filter + FIR / Chebyshev pre-filters IMU (accel + gyro)
Altitude Butterworth KF Barometer + sonar
Velocity Dual Kalman Filter Optical flow + accelerometer
Yaw (competition) PD controller via AC cmd / orient_ref IMU gyroscope estimate

The controller runs at 200 Hz (Ts = 0.005 s). The Parrot Mambo vehicle model used: 63 g mass, 4-motor diamond configuration, 33 mm rotors, Ct = 0.0107, motor command range 10–500.


Getting Started

Requirements

  • MATLAB R2023a or later (R2022b-compatible .slx files included)
  • Simulink · Stateflow
  • Aerospace Blockset / UAV Toolbox
  • Simulink Coder + Embedded Coder (hardware deployment)
  • Simulink Control Design (linearisation, optional)
  • Parrot Minidrone Support Package

Simulation

openProject('parrotMinidroneCompetition.prj')  % loads all workspace variables
% then open and run mainModels/parrotMinidroneCompetition.slx

Deploy to Hardware

generateFlightCode()   % compiles flightControlSystem.slx → ERT C → Parrot binary

Run Tests

cd tests && runProjectTests

Team

Name Role
Rosha Razmarafar Algorithm design · Control · Implementation
Şafak ATAN Algorithm design · Image processing · Implementation

Institution: Maltepe University · Faculty of Engineering and Natural Sciences
Recognition: Following the 2024 win, the team was visited by Alex Tarchini (MATLAB Italy team leader) and Silvan Schwaller (MathWorks Turkey Academic Planning and Development Engineer) at Maltepe University. → University announcement


Paper

Equilibrium Algorithmic Framework for Autonomous Navigation of MiniDrone
Rosha Razmarafar, Şafak ATAN

The paper details the full algorithmic development across all three algorithm generations, the image processing pipeline, the Stateflow path planner, and the performance evaluation against the four parameter configurations.


Acknowledgements

Base Simulink framework provided by MathWorks as part of the Minidrone Competition starter project. Airframe dynamics model derived from Peter Corke's Robotics Toolbox for MATLAB. Controller estimator structure originally developed by Fabian Riether. See support/LICENSE.md for full attribution.

About

1st place · MathWorks Minidrone Challenge 2024 (National, Turkey). Autonomous line-following controller for Parrot Mambo — image processing, yaw-based control, and Stateflow path planning compiled via Embedded Coder and deployed to hardware.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages