Python port of the U.S. Naval Research Laboratory's Tracker Component Library for target tracking algorithms
Project description
Tracker Component Library (Python)
A Python port of the U.S. Naval Research Laboratory's Tracker Component Library, a comprehensive collection of algorithms for target tracking, estimation, coordinate systems, and related mathematical functions.
Overview
The Tracker Component Library provides building blocks for developing target tracking algorithms, including:
- Coordinate Systems: Conversions between Cartesian, spherical, geodetic, and other coordinate systems
- Dynamic Models: State transition matrices for constant velocity, coordinated turn, and other motion models
- Estimation Algorithms: Kalman filters (EKF, UKF, etc.), particle filters, and batch estimation
- Assignment Algorithms: Hungarian algorithm, auction algorithms, and multi-dimensional assignment
- Mathematical Functions: Special functions, statistics, numerical integration, and more
- Astronomical Code: Ephemeris calculations, time systems, celestial mechanics
- Navigation: Geodetic calculations, INS algorithms, GNSS utilities
- Geophysical Models: Gravity, magnetism, atmosphere, and terrain models
Installation
Basic Installation
pip install nrl-tracker
With Optional Dependencies
# For astronomy features (ephemerides, celestial mechanics)
pip install nrl-tracker[astronomy]
# For geodesy features (coordinate transforms, map projections)
pip install nrl-tracker[geodesy]
# For visualization
pip install nrl-tracker[visualization]
# For development
pip install nrl-tracker[dev]
# Install everything
pip install nrl-tracker[all]
From Source
git clone https://github.com/nedonatelli/TCL.git
cd TCL
pip install -e ".[dev]"
Quick Start
Coordinate Conversions
import numpy as np
from pytcl.coordinate_systems import cart2sphere, sphere2cart
# Convert Cartesian to spherical coordinates
cart_point = np.array([1.0, 1.0, 1.0])
r, az, el = cart2sphere(cart_point)
print(f"Range: {r:.3f}, Azimuth: {np.degrees(az):.1f}°, Elevation: {np.degrees(el):.1f}°")
# Convert back
cart_recovered = sphere2cart(r, az, el)
Kalman Filter
from pytcl.dynamic_estimation.kalman import KalmanFilter
from pytcl.dynamic_models import constant_velocity_model
# Create a constant velocity model
dt = 0.1
F, Q = constant_velocity_model(dt, dimension=2, process_noise_intensity=1.0)
# Initialize filter
kf = KalmanFilter(
F=F, # State transition matrix
H=np.array([[1, 0, 0, 0], [0, 0, 1, 0]]), # Measurement matrix
Q=Q, # Process noise
R=np.eye(2) * 10, # Measurement noise
)
# Run filter
x_est, P_est = kf.predict()
x_est, P_est = kf.update(measurement)
Assignment Problem
from pytcl.assignment_algorithms import hungarian
# Cost matrix (tracks x measurements)
cost_matrix = np.array([
[10, 5, 13],
[3, 15, 8],
[7, 9, 12],
])
# Solve assignment
assignment, total_cost = hungarian(cost_matrix)
print(f"Optimal assignment: {assignment}, Total cost: {total_cost}")
Module Structure
pytcl/
├── core/ # Foundation utilities and constants
├── mathematical_functions/ # Basic math, statistics, special functions
├── coordinate_systems/ # Coordinate conversions and transforms
├── dynamic_models/ # State transition and process noise models
├── dynamic_estimation/ # Kalman filters, particle filters
├── static_estimation/ # ML, least squares estimation
├── assignment_algorithms/ # 2D and multi-dimensional assignment
├── clustering/ # Mixture reduction, clustering
├── performance_evaluation/ # OSPA, track metrics
├── astronomical/ # Ephemerides, time systems
├── navigation/ # Geodetic, INS, GNSS
├── atmosphere/ # Atmosphere models, refraction
├── gravity/ # Gravity models
├── magnetism/ # Magnetic field models
├── terrain/ # Terrain elevation models
└── misc/ # Utilities, visualization
Documentation
Comparison with Original MATLAB Library
This library aims to provide equivalent functionality to the original MATLAB library with Pythonic APIs:
| MATLAB | Python |
|---|---|
Cart2Sphere(cartPoints) |
cart2sphere(cart_points) |
FPolyKal(T, xDim, order) |
poly_kalman_F(dt, dim, order) |
KalmanUpdate(...) |
KalmanFilter.update(...) |
Key differences:
- Function names use
snake_caseinstead ofPascalCase - Arrays are NumPy arrays (row-major) vs MATLAB matrices (column-major)
- 0-based indexing vs 1-based indexing
- Object-oriented APIs where appropriate
Testing
# Run all tests
pytest
# Run with coverage
pytest --cov=pytcl
# Run only fast tests
pytest -m "not slow"
# Run tests validated against MATLAB
pytest -m matlab_validated
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Development Setup
git clone https://github.com/nedonatelli/TCL.git
cd TCL
pip install -e ".[dev]"
pre-commit install
Running Quality Checks
# Format code
black .
# Lint
flake8 pytcl
# Type check
mypy pytcl
# Run all checks
pre-commit run --all-files
Citation
If you use this library in your research, please cite the original MATLAB library:
@article{crouse2017tracker,
title={The Tracker Component Library: Free Routines for Rapid Prototyping},
author={Crouse, David F.},
journal={IEEE Aerospace and Electronic Systems Magazine},
volume={32},
number={5},
pages={18--27},
year={2017},
publisher={IEEE}
}
License
This project is in the public domain, following the original MATLAB library's license. See LICENSE for details.
Acknowledgments
- Original MATLAB library by David F. Crouse at the U.S. Naval Research Laboratory
- This port follows the Federal Source Code Policy (OMB M-16-21)
Related Projects
- FilterPy - Kalman filtering library
- Stone Soup - Framework for tracking algorithms
- Astropy - Astronomy library for Python
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nrl_tracker-0.12.0.tar.gz.
File metadata
- Download URL: nrl_tracker-0.12.0.tar.gz
- Upload date:
- Size: 339.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06f492d9273378b24940a2dcad3528beee4a15f42e2e0f26ea62a6bbe3df1d57
|
|
| MD5 |
5c58e4364fa9c1442d87b563050e743c
|
|
| BLAKE2b-256 |
607bd82f8bca3b2fdb15f22b70dcc602881c9d1ff3b1c759ac9ae4b2b77260f9
|
Provenance
The following attestation bundles were made for nrl_tracker-0.12.0.tar.gz:
Publisher:
publish.yml on nedonatelli/TCL
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nrl_tracker-0.12.0.tar.gz -
Subject digest:
06f492d9273378b24940a2dcad3528beee4a15f42e2e0f26ea62a6bbe3df1d57 - Sigstore transparency entry: 785139313
- Sigstore integration time:
-
Permalink:
nedonatelli/TCL@779b0794efb05347bff170c2efefbe3b9c953d83 -
Branch / Tag:
refs/tags/v0.12.0 - Owner: https://github.com/nedonatelli
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@779b0794efb05347bff170c2efefbe3b9c953d83 -
Trigger Event:
release
-
Statement type:
File details
Details for the file nrl_tracker-0.12.0-py3-none-any.whl.
File metadata
- Download URL: nrl_tracker-0.12.0-py3-none-any.whl
- Upload date:
- Size: 319.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35d21f7991f40c093bc4c92f5697cea73fc3f3c3764f034b6ce3b0e44904cf82
|
|
| MD5 |
339722008bcc3412caa209ba3d03983b
|
|
| BLAKE2b-256 |
82b8479656166953c96dfb8e512ad9f00731e4905722abd5acac7cd63a5120dd
|
Provenance
The following attestation bundles were made for nrl_tracker-0.12.0-py3-none-any.whl:
Publisher:
publish.yml on nedonatelli/TCL
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nrl_tracker-0.12.0-py3-none-any.whl -
Subject digest:
35d21f7991f40c093bc4c92f5697cea73fc3f3c3764f034b6ce3b0e44904cf82 - Sigstore transparency entry: 785139330
- Sigstore integration time:
-
Permalink:
nedonatelli/TCL@779b0794efb05347bff170c2efefbe3b9c953d83 -
Branch / Tag:
refs/tags/v0.12.0 - Owner: https://github.com/nedonatelli
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@779b0794efb05347bff170c2efefbe3b9c953d83 -
Trigger Event:
release
-
Statement type: