An ACADOS-based nonlinear MPC for a quadrotor tracking a circular trajectory while keeping its yaw pointed at a static ground target, with a Python-to-C++ pipeline and deliberate model-mismatch robustness testing.

Stars

38

7-day growth

No data

Forks

4

Open issues

0

License

No data

Last updated

2026-07-27

AI repository intelligence
FR-AI / ANALYSIS

Why it is worth attention

It provides a complete, reproducible pipeline from symbolic model definition in Python (CasADi) to compiled C solver execution, explicitly tests robustness through model mismatch between the MPC predictor and plant simulator, and uses a unit-vector yaw encoding to avoid angle wrapping issues.

Who it is for

  • quadrotor control researchers
  • robotics engineers implementing MPC on embedded systems
  • students learning nonlinear model predictive control
  • developers integrating ACADOS into real-time applications

Use cases

  • circular trajectory tracking with fixed camera orientation toward a center target
  • benchmarking MPC performance under plant-model mismatch
  • education on end-to-end NMPC code generation and deployment
  • rapid prototyping of perception-aware control strategies

Strengths

  • clear separation of physics (ode) and control (cost/constraints) in separate scripts
  • robustness validation: plant uses second-order dynamics while MPC uses first-order approximation
  • yaw formulated as unit vector in cost to handle angle wrapping naturally
  • single-command pipeline (run.sh) that generates C code, builds, simulates, and visualizes

Considerations

  • first-order inner-loop lag is an approximation, not the exact second-order dynamics of PX4
  • Euler-angle singularity at θ=±90° restricts pitch to ±60°
  • requires manual ACADOS installation with fixed path dependency (~/acados)

README quick start

Argus — Quadrotor Target-Tracking MPC

Model Predictive Control for a quadrotor tracking a circular trajectory with yaw locked toward an object at the centre. The controller is formulated as a Nonlinear MPC using ACADOS, which generates a C solver that is called from C++.

Drone (blue trail) holding a 2 m-radius circle at 1.5 m altitude while the camera frustum (amber, dashed-green ideal) stays locked on the static ground target. Generated with python3 scripts/animate_xy.py --save-gif ... — see How to run.


Model

State and inputs

The quadrotor is modelled with 12 states and 4 inputs, using ZYX Euler angles.

State x ∈ ℝ¹²:

SymbolIndicesUnitDescription
x, y, z0–2mposition in world frame
vx, vy, vz3–5m/svelocity in world frame
φ, θ, ψ6–8radroll, pitch, yaw (ZYX Euler)
p, q, r9–11rad/sbody-frame angular rates

Input u ∈ ℝ⁴:

SymbolIndexUnitDescription
T0Ncollective thrust (sum of all rotor forces)
p_cmd1rad/scommanded roll rate
q_cmd2rad/scommanded pitch rate
r_cmd3rad/scommanded yaw rate

The inputs are thrust and commanded body rates — matching the interface of a real flight controller such as PX4, which exposes a body-rate setpoint API. The dynamics of the inner rate controller are captured by a first-order lag on each body rate (time constants in config/quadrotor.yaml under inner_loop).

Continuous-time ODE

Position kinematics — velocity integrates into position:

ẋ  = vx
ẏ  = vy
ż  = vz

Translational dynamics — thrust T acts along the body z-axis; rotating it to the world frame via R(φ,θ,ψ) gives the acceleration:

v̇x = T/m · (cos(ψ)·sin(θ)·cos(φ) + sin(ψ)·sin(φ))
v̇y = T/m · (sin(ψ)·sin(θ)·cos(φ) − cos(ψ)·sin(φ))
v̇z = T/m · cos(θ)·cos(φ) − g

The rotation is the ZYX convention: R = Rz(ψ) · Ry(θ) · Rx(φ). When the drone is level (φ = θ = 0) this reduces to v̇z = T/m − g, so T = mg at hover.

Euler angle kinematics — relates body rates (p, q, r) to Euler rates:

φ̇ = p + sin(φ)·tan(θ)·q + cos(φ)·tan(θ)·r
θ̇ =     cos(φ)·q         − sin(φ)·r
ψ̇ =    (sin(φ)·q         + cos(φ)·r) / cos(θ)

This transformation has a kinematic singularity at θ = ±90°. The pitch constraint (

Related repositories

Similar projects matched by category, topics, and programming language.

lopopolo
Featured
lopopolo GitHub avatar

harness-engineering

Harness Engineering is a methodology for improving coding agent outputs by carefully crafting the environment around them—providing curated context, tools, and executable constraints that encode an organization’s nonfunctional requirements and cumulative lessons.

AI & Machine LearningAI Agents
2,390
slvDev
Featured
slvDev GitHub avatar

esp32-ai

A 28.9 million parameter language model runs on an $8 ESP32-S3 microcontroller entirely on-device, generating simple stories at about 9.5 tokens per second.

AI & Machine LearningLarge Language Models
1,960
littledivy
Featured
littledivy GitHub avatar

mimic

mimic captures traffic from any iOS or web app and automatically generates a Python client library that lets you call the app's API like a regular library.

AI & Machine Learning
1,482