How johnwtt/kalmannetforsensorfusion works
1. What this repository is
- This is a PyTorch-based research implementation of KalmanNet for integrated navigation/data fusion on the NCLT dataset.
- The codebase is organized around a standard ML pipeline: raw sensor/ground-truth data → preprocessing → dataset objects → model training → checkpoint/export → inference/visualization.
2. Primary runtime and framework
- The core training and model code lives under Net/, and is centered on Python + PyTorch.
- Training is launched from train.py and configured through files in configs/, which strongly suggests a config-driven experiment workflow rather than hardcoded scripts.
3. Data ingestion boundary
- Raw NCLT data is handled in data/NCLT/.
- down.py downloads sensor and ground-truth archives; preprocess.py converts them into the repository’s processed format.
- The processed artifacts in data/NCLT/processed/ are the main data interface for the rest of the system: train.pt, val.pt, test.pt and RTK variants (*_rtk.pt).
4. Dataset layer
- Net/dataset/nclt_dataset.py and Net/dataset/track_dataset.py define dataset abstractions for loading the processed navigation sequences.
- This layer is the bridge between the preprocessed .pt files and the model/trainer stack, likely packaging time-series inputs, targets, and possibly auxiliary measurements for fusion.
5. Model subsystem
- Net/models/kalman_net/kalman_net.py is the core KalmanNet implementation.
- Net/models/kalman_net/skalman_net.py provides a “split” variant, likely separating parts of the estimation/fusion pipeline.
- Net/models/fusion_net/fusion_kalman_net.py appears to combine multiple sensing sources into the KalmanNet framework, which is the main architectural specialization in this repo.
6. Training subsystem
- Net/trainer/base_trainer.py provides shared training/evaluation behavior.
- Net/trainer/fusion_trainer.py specializes that flow for the fusion models.
- This split indicates the repo has a general training loop plus task-specific logic for the navigation fusion use case.
7. Experiment configuration and parameterization
- configs/nclt/fusion/wheel_gpsfusion_origin.py and wheel_gpsfusion_split.py define the two main experiment variants documented in the README.
- Net/params/make_params.py likely builds a structured parameter object from the config, which helps keep dataset/model/trainer wiring consistent across experiments.
8. Shared utilities
- Net/utils/metrics.py likely defines loss/error metrics such as MSE and navigation-specific evaluation.
- Net/utils/registry.py suggests a registration mechanism for dynamically selecting datasets, models, or trainers from config.
- Net/utils/misc.py contains supporting helpers used across the training and evaluation pipeline.
9. Main data flow
- The flow is: NCLT raw data and ground truth are downloaded and preprocessed into .pt tensors.
- Those tensors feed the dataset classes, which feed the KalmanNet/fusion models through the trainer.
- Training produces checkpoints under weights/, and one trained artifact is already included in weights/kalman560/.
10. Artifact outputs and deployment
- The repository includes model.onnx and model.onnx.data, indicating at least one exported inference representation outside pure PyTorch checkpoints.
- This suggests the trained model can be consumed in a deployment or offline inference setting, not just during training.
11. Inference and analysis workflow
- nclt_predict.ipynb is the primary inference/postprocessing entry point.
- The notebook likely loads a trained checkpoint, runs prediction on test sequences, and produces geospatial outputs for visualization.
12. Visualization boundary
- The QGIS/ directory contains a prepared QGIS project and example outputs (.kml, .json) for plotting trajectories on a map.
- The visualization layer is intentionally outside the ML pipeline: the model outputs coordinates, and QGIS is used to inspect trajectory quality and alignment against map context.
13. Repository-specific experiment scope
- The current tracked configuration and artifacts focus on a single NCLT day (2012-11-16) and compare KalmanNet vs. split KalmanNet/fusion variants.
- That makes this repo less of a generic framework and more of a focused experimental implementation for integrated navigation on one dataset/domain.
14. Architectural summary
- The cleanest diagram would show four major boundaries:
Data preparation (data/NCLT) → Learning pipeline (Net/dataset, Net/models, Net/trainer, Net/utils, configs, train.py) → Saved artifacts (weights, model.onnx) → Evaluation/visualization (nclt_predict.ipynb, QGIS/).
Main entry points: registry.py Registry · base_trainer.py Base trainer · fusion_trainer.py Fusion trainer · processed Processed sets
Components 20
Data prep
Raw NCLT ingestion and preprocessing into trainable sequence tensors.
- NCLT raw · Source sensor and ground-truth archives for the NCLT navigation dataset.
data/NCLT - Downloader · Downloads the NCLT sensor and ground-truth archives.
data/NCLT/down.py - Preprocess · Converts raw NCLT data into the repository's processed tensor format.
data/NCLT/preprocess.py - Processed sets · Train/val/test sequence tensors, including RTK variants, consumed by datasets.
data/NCLT/processed
Learning stack
Config-driven PyTorch training, datasets, models, trainers, and utilities.
- Train entry · Main training entry point that launches the experiment pipeline.
train.py - Fusion cfgs · NCLT fusion experiment variants for origin and split KalmanNet runs.
configs/nclt/fusion - Params builder · Builds structured parameters from config for dataset, model, and trainer setup.
Net/params/make_params.py - Registry · Central selection mechanism for pluggable components such as datasets, models, or trainers.
Net/utils/registry.py - NCLT dataset · Loads processed NCLT sequences and packages inputs and targets.
Net/dataset/nclt_dataset.py - Track dataset · Alternative sequence dataset abstraction for trajectory-style navigation data.
Net/dataset/track_dataset.py - KalmanNet · Core KalmanNet implementation for learned state estimation.
Net/models/kalman_net/kalman_net.py - Split KalmanNet · Split variant of KalmanNet with separated estimation components.
Net/models/kalman_net/skalman_net.py - Fusion Kalman · Fusion-oriented KalmanNet variant combining multiple sensing sources.
Net/models/fusion_net/fusion_kalman_net.py - Base trainer · Shared training and evaluation loop logic.
Net/trainer/base_trainer.py - Fusion trainer · Task-specific trainer for fusion navigation experiments.
Net/trainer/fusion_trainer.py - Metrics · Loss and navigation error metrics used during training and validation.
Net/utils/metrics.py
Artifacts
Saved checkpoints and exported inference models.
- Checkpoint · Saved PyTorch checkpoint for a trained KalmanNet run.
weights/kalman560/epoch=44-val_loss=75.70-val_MSE_dB=18.79.ckpt - ONNX export · Exported inference representation for deployment or offline use.
model.onnx
Eval and viz
Prediction notebook and QGIS-based trajectory inspection.
- Predict notebook · Loads a trained model and runs prediction/postprocessing on NCLT sequences.
nclt_predict.ipynb - QGIS project · Map-based trajectory inspection project and output artifacts.
QGIS/20121116.qgz
Connections 24
- NCLT raw → Downloader: source · Raw NCLT archives are fetched by the downloader.
- Downloader → Preprocess: input · Downloaded archives are consumed by preprocessing.
- Preprocess → Processed sets: writes · Preprocessing generates train/val/test tensor files.
- Processed sets → NCLT dataset: loads · The NCLT dataset reads processed tensor splits.
- Processed sets → Track dataset: loads · Track-style dataset abstractions also consume processed sequences.
- Fusion cfgs → Params builder: configures · Experiment configs are transformed into runtime parameters.
- Params builder → Registry: resolves · Parameters are used to resolve component implementations.
- Registry → NCLT dataset: selects · Dataset implementation is selected through the registry path.
- Registry → KalmanNet: selects · Core model implementation can be selected dynamically.
- Registry → Fusion Kalman: selects · Fusion model variant can be selected dynamically.
- Registry → Fusion trainer: selects · Trainer implementation can be selected dynamically.
- Train entry → Fusion cfgs: loads · Training starts from a config-defined experiment.
- Train entry → Params builder: builds · The entry point builds structured parameters for the run.
- NCLT dataset → Base trainer: feeds · Dataset batches are consumed by the training loop.
- Track dataset → Base trainer: feeds · Trajectory dataset batches can also feed the trainer stack.
- KalmanNet → Base trainer: trained by · Base trainer optimizes the core KalmanNet model.
- Split KalmanNet → Fusion trainer: trained by · Fusion trainer can specialize around the split variant.
- Fusion Kalman → Fusion trainer: trained by · Fusion trainer drives the fusion model experiments.
- Base trainer → Metrics: evaluates · Training and validation use shared metrics.
- Fusion trainer → Metrics: evaluates · Fusion-specific evaluation also uses shared metrics.
- Base trainer → Checkpoint: saves · Trained weights are persisted as checkpoints.
- Checkpoint → Predict notebook: loads · The notebook loads saved checkpoints for inference.
- ONNX export → Predict notebook: loads · Exported ONNX artifacts support downstream inference.
- Predict notebook → QGIS project: exports · Prediction outputs are prepared for QGIS visualization.