This repository contains the official implementation of the Neural-Extended State Observer (Neural-ESO) for robust quadrotor flight control. By bridging traditional ESO with a learning-based dual-pathway architecture, this framework dynamically predicts and compensates for unmodeled dynamics and external disturbances in real-time.
The codebase includes offline PyTorch training scripts with spectral normalization (Lipschitz constraints) and online ROS/MAVSDK deployment scripts for hardware flight testing using PX4 and OptiTrack.
-
Data-Driven Disturbance Prediction: Utilizes a lightweight Multi-Layer Perceptron (MLP) to predict Z-axis disturbances (
$z_3$ ) based on 5 system states (altitude, velocity, thrust, roll, pitch). -
Provable Stability: Incorporates Spectral Normalization during training (Lipschitz constant
$K=1$ ) to bound the neural network's output and guarantee closed-loop stability. - Linear ESO Core: Robust baseline control using Linear ESO, modified to accept neural feedforward commands alongside the standard Extended State Observer.
-
Hardware-Ready Deployment: Fully asynchronous Python deployment script utilizing MAVSDK for PX4 offboard control and
vrpn_client_nodefor high-fidelity OptiTrack motion capture.
TrainingBoxLandingDNNchangable.py- PyTorch training script for the Neural-ESO.Test_BoxLandingLearningWithNN.py- ROS/MAVSDK online deployment and flight script.requirements.txt- Python package dependencies.README.md- This documentation file.
The system requires Python 3.8+, ROS Noetic, and a PX4 Autopilot environment (either SITL or physical hardware).
- Download and extract the code:
Download the provided
.zipfile and extract it to your local workspace.cd path/to/extracted/Neural-ESO-3051 - Install the required Python dependencies:
(Note: Ensure your ROS Noetic environment is sourced properly so
pip install -r requirements.txt
rospyandgeometry_msgsare available).
The neural network learns the disturbance mapping from baseline flight logs.
- Place your baseline ESO flight log (
.csv) in the directory. - Update the
FILENAME_TO_LOADvariable inTrainingBoxLandingDNNchangable.py. - Run the training script:
python TrainingBoxLandingDNNchangable.py
- Outputs: The script will generate three files required for deployment:
disturbance_model_BoxLanding.pth(Model Weights)scaler_X_BoxLanding.pkl(Input Scaler)scaler_y_BoxLanding.pkl(Output Scaler)
Ensure your OptiTrack system is publishing pose data to /vrpn_client_node/Drone1/pose and your PX4 autopilot is listening for MAVSDK UDP connections on udp://:14550.
- Launch the flight script:
python Test_BoxLandingLearningWithNN.py
-
Flight Sequence: The quadrotor will automatically arm, take off to a hover state to lock its initial position, and then execute the pre-programmed trajectory while running the Neural-ESO feedforward loop at a target rate of 50Hz (
$dt = 0.02s$ ). -
Logging & Visualization: Upon landing, the script will automatically save a new
.csvflight log and generate matplotlib figures comparing the actual trajectory, ESO residual estimations, and NN predictions.
This project is licensed under the MIT License