$ show UBNanosatLab/openstartracker
openstartracker is an application for autonomous spacecraft attitude determination from star images. It runs as a long-lived localhost TCP daemon (startracker.py) that accepts commands via socket or stdin, processes images with OpenCV, and returns matched star vectors. The core matching engine is a custom C++ header library (BEAST) wrapped with SWIG, using a Hipparcos-derived constellation database, Morton-coded spatial hashing, an in-place kd-tree, and Bayesian posterior scoring for lost-in-space identification. It also tracks non-star objects across frames and can extrapolate attitude between image times.
The LLM identified 3 files worth highlighting for reuse:
Self-contained header implementing Morton/Z-order interleaved hashes for 2D, 3D, and 4D coordinates. Provides hash(), bin_size(), and mask() functions so a fixed-width hash can be truncated to search a spatial range. Depends only on <stdint.h> and can be extracted into another project needing compact spatial bucketing or range-query acceleration.
Implements an unusually compact in-place kd-tree: the star array is recursively partitioned with std::nth_element (quickselect) and leaves are sorted by flux, requiring no per-node allocations or separate tree structures. star_query::kdsearch prunes subtrees and maintains brightness-ordered result lists. It is coupled to the project's global config constants, but the underlying range-search technique is non-obvious and applicable to other point-cloud lookup problems.
A reusable star-scene simulator with five camera projection models (rectilinear, equidistant, equisolid, stereographic, orthographic), photon-noise modeling, false-star injection, and scene randomization. It generates CSV scenes and ground-truth Hipparcos IDs for star-tracker validation. The Camera, StarCatalog, StarDetector, and Scene classes are largely independent of the BEAST library and can be adapted to test other star identification systems.