This folder contains the supervised-learning pipeline for the quadrotor controller experiments. It is organized so the same saved configuration can be reused across:
- training
- checkpoint reconstruction
- offline testing
- automated feature ablations
- closed-loop simulation from datasets
- random-start robustness simulation
- race-track style gate simulation
-
train.py Main training entrypoint. Reads
train_config.yaml, builds the requested model, trains it, and writes:- a checkpoint into
checkpoints/ - a resolved copy of the config into
configs/
- a checkpoint into
-
test.py Evaluation entrypoint. Rebuilds the model from the saved YAML, runs the test set, and optionally performs automated feature ablations.
-
Simulator_start_dataset.py Initializes the simulator from states taken directly from the dataset and compares simulated closed-loop rollouts against reference commands/energy.
-
Simulator_random_start.py Samples random physically plausible initial states and measures convergence, energy, and time-to-target.
-
Simulator_race_drone.py Re-centers the drone around successive gates and evaluates repeated gate-passing behavior.
-
utils/model_builder.py Centralized architecture factory used by all scripts. This is the main place where model type, width scaling, preprocessing blocks, and CfC/LTC options are interpreted.
-
utils/quadrotor_sim.py Shared simulation code:
- state transforms
- continuous-time dynamics
- numerical integration
- observation window management
- checkpoint-backed controller rollout
-
utils/ablation.py Feature-group masking for automated testing ablations.
-
utils/feedforward.py Plain MLP baseline, wrapped to match the same sequence interface as the recurrent models.
-
utils/data.py Dataset loading, normalization-vector construction, feature expansion, and sliding-window generation.
-
utils/lightning.py Shared Lightning wrapper used by training and test-time checkpoint execution.
Edit train_config.yaml, then run:
python3 LNN_SL_quadrotor_training/train.pyOutputs:
LNN_SL_quadrotor_training/checkpoints/<checkpoint>.ckptLNN_SL_quadrotor_training/configs/<checkpoint>.yaml
The saved YAML is important because test/simulators rebuild the exact same architecture from it.
Set model_path in test_config.yaml to the checkpoint stem, then run:
python3 LNN_SL_quadrotor_training/test.pyOptional plot:
python3 LNN_SL_quadrotor_training/test.py --plotSet model_path in simulator_config.yaml, then choose one:
python3 LNN_SL_quadrotor_training/Simulator_start_dataset.py
python3 LNN_SL_quadrotor_training/Simulator_random_start.py
python3 LNN_SL_quadrotor_training/Simulator_race_drone.pyThe primary architecture switch lives in train_config.yaml -> model.type.
Supported values:
cfcltcncpctrnnsimplernngrulstmmlp
When model.type: cfc, the following are used:
-
model.cfc_modeValues:default,pure,no_gate -
model.backbone_units -
model.backbone_layers -
model.backbone_dropout
When model.type: ncp, the following are used:
model.ncp.inter_neuronsmodel.ncp.command_neuronsmodel.ncp.sensory_fanoutmodel.ncp.inter_fanoutmodel.ncp.recurrent_command_synapsesmodel.ncp.motor_fanin
The refactored pipeline builds NCP controllers as CfC models with an
ncps.wirings.NCP(...) wiring.
Use:
model.scale_factor
This scales:
- recurrent hidden width
- CfC backbone width
- MLP preprocessing widths
- feedforward hidden widths
- convolution output width
Use:
model.no_neurons_layer
This controls the hidden width for recurrent backbones.
To use a plain non-recurrent controller:
model:
type: mlp
hidden_layers: [128, 128]
activation: reluThis follows the same train/test/simulator path as the recurrent models.
Use:
conv_block:
value: true
output_dim: 256This requires sequencing:
sequencing:
value: true
seq_len: 1Use:
mlp_block:
value: true
no_layers: [64, 128, 256]This inserts an MLP feature extractor before the recurrent core.
Ablation is configured in test_config.yaml:
ablation:
enabled: true
fill_value: 0.0
feature_sets:
position: [dx, dy, dz]
velocity: [vx, vy, vz]
attitude: [phi, theta, psi]For each named group:
- the matching feature indices are resolved from the configured input label order
- the input tensor is copied
- those channels are replaced with
fill_value - the test evaluation is rerun
Controls:
- dataset labels and paths
- dataloader settings
- sequencing
- optional preprocessing blocks
- model family and hyperparameters
- scaling
- logging
Controls:
- which saved model to load
- which test dataset to evaluate
- whether to run ablations
- plotting toggle
Controls:
- which saved model to load
- which simulation horizon and timestep to use
- which integration method to use
- convergence thresholds
- random-start simulation count
This refactor focuses on the main supervised-learning path. Older side scripts such as:
*_NN.pySimulator_start_dataset_model_comparison.pytest_NN.py
were left as legacy utilities and were not migrated onto the new shared helper stack.
- Train with
train.py. - Copy the resulting checkpoint stem.
- Put that stem into
test_config.yamland/orsimulator_config.yaml. - Run
test.pyfor baseline and ablation metrics. - Run one or more simulator scripts for closed-loop behavior checks.