LOST 0.0.1
LOST: Open-source Star Tracker
Loading...
Searching...
No Matches
lost Namespace Reference

LOST starting point. More...

Classes

class  AttitudeEstimationAlgorithm
 An attitude estimation algorithm estimates the orientation of the camera based on identified stars. More...
class  DavenportQAlgorithm
 A slow but reliable attitude estimation algorithm. More...
class  TriadAlgorithm
 A fast attitude estimator which only takes into account information from two stars. More...
class  QuestAlgorithm
 A faster and just as accurate attitude estimator as the Davenport Q algorithm. More...
struct  Vec2
 A two dimensional vector with decimaling point components. More...
class  Vec3
 Three dimensional vector with decimaling point components. More...
class  Mat3
 3x3 vector with decimaling point components More...
class  EulerAngles
 A "human-readable" way to represent a 3d rotation or orientation. More...
class  Quaternion
 A quaternion is a common way to represent a 3d rotation. More...
class  Attitude
 The attitude (orientation) of a spacecraft. More...
class  Camera
 A full description of a camera. Enough information to reconstruct the camera matrix and then some. More...
struct  CentroidParams
struct  IWCoGParams
class  CentroidAlgorithm
 An algorithm that detects the (x,y) coordinates of bright points in an image, called "centroids". More...
class  DummyCentroidAlgorithm
 A centroid algorithm for debugging that returns random centroids. More...
class  CenterOfGravityAlgorithm
 A simple, fast, and pretty decent centroid algorithm. More...
class  IterativeWeightedCenterOfGravityAlgorithm
 A more complicated centroid algorithm which doesn't perform much better than CenterOfGravityAlgorithm. More...
struct  KVectorPair
class  KVectorIndex
 A data structure enabling constant-time range queries into fixed numerical data. More...
class  PairDistanceKVectorDatabase
 A database storing distances between pairs of stars. More...
class  TetraDatabase
 A database storing Tetra star patterns. More...
class  MultiDatabase
class  MultiDatabaseEntry
class  GeneratedStar
 A star used in simulated image generation. Contains extra data about how to simulate the star. More...
class  CentroidComparison
 The result of comparing actual and expected centroids Used for debugging and benchmarking. More...
class  UserSpecifiedOutputStream
 An output stream which might be a file or stdout. More...
class  Image
 An 8-bit grayscale 2d image. More...
class  PipelineOptions
 The command line options passed when running a pipeline. More...
class  PipelineInput
 Represents the input and expected outputs of a pipeline run. More...
class  GeneratedPipelineInput
 A pipeline input which is generated (fake image). More...
class  PngPipelineInput
 A pipeline input created by reading a PNG from a file on disk. More...
struct  PipelineOutput
 The result of running a pipeline. More...
struct  StarIdComparison
 The result of comparing an actual star identification with the true star idenification, used for testing and benchmarking. More...
class  Pipeline
 A set of algorithms that describes all or part of the star-tracking "pipeline". More...
class  DatabaseOptions
 Command line options when using the database command. More...
class  SerializeContext
class  DeserializeContext
class  IRUnidentifiedCentroid
 unidentified centroid used in IdentifyRemainingStarsPairDistance The "angles" through here are "triangular angles". More...
class  PairDistanceInvolvingIterator
 Given a list of star pairs, finds all those pairs which involve a certain star. More...
struct  FlatPairMap
 Given the result of a pair-distance kvector query, build a table of stars to other stars that appeared with it in the query. More...
class  StarIdAlgorithm
 A star idenification algorithm. More...
class  TetraStarIdAlgorithm
 Tetra star identification algorithm based on the one originally proposed by Brown & Stubis Creates patterns/mini-constellations of 4 stars and hashes them for quick lookup. More...
class  DummyStarIdAlgorithm
 A star-id algorithm that returns random results. For debugging. More...
class  GeometricVotingStarIdAlgorithm
 A star-id algorithm based on assigning votes for each centroid-catalog pair then choosing the highest voted catalog stars. More...
class  PyramidStarIdAlgorithm
 The "de facto" star-id algorithm used in many real-world missions. More...
class  CatalogStar
 A star from the Bright Star Catalog. More...
class  Star
 A "centroid" detected in an image. More...
class  StarIdentifier
 Records that a certain Star (detected in the image) corresponds to a certain CatalogStar. More...
class  CombinationIterator
struct  TetraConstants

Typedefs

using TetraPattern = std::array<uint16_t, TetraConstants::numPatternStars>
using MultiDatabaseDescriptor = std::vector<MultiDatabaseEntry>
typedef void(* PipelineComparator) (std::ostream &os, const PipelineInputList &, const std::vector< PipelineOutput > &, const PipelineOptions &)
typedef std::vector< std::unique_ptr< PipelineInput > > PipelineInputList
using HashCode = std::array<int, kNumEdgeRatios>
typedef std::vector< CatalogStar > Catalog
typedef std::vector< Star > Stars
typedef std::vector< StarIdentifier > StarIdentifiers

Functions

decimal QuestCharPoly (decimal x, decimal a, decimal b, decimal c, decimal d, decimal s)
 Characteristic polynomial of the quest K-matrix.
decimal QuestCharPolyPrime (decimal x, decimal a, decimal b, decimal c)
 Derivitive of the characteristic polynomial of the quest K-matrix.
bool QuestEigenvalueEstimator (decimal guess, decimal a, decimal b, decimal c, decimal d, decimal s, decimal *eig)
 Approximates roots of a real function using the Newton-Raphson algorithm.
Quaternion SphericalToQuaternion (decimal ra, decimal dec, decimal roll)
 Return a quaternion that will reorient the coordinate axes so that the x-axis points at the given right ascension and declination, then roll the coordinate axes counterclockwise (i.e., the stars will appear to rotate clockwise).
Vec3 SphericalToSpatial (decimal ra, decimal de)
 Convert from right ascension & declination to a 3d point on the unit sphere.
void SpatialToSpherical (const Vec3 &vec, decimal *ra, decimal *de)
 Convert from a 3d point on the unit sphere to right ascension & declination.
decimal RadToDeg (decimal rad)
decimal DegToRad (decimal deg)
decimal RadToArcSec (decimal rad)
decimal ArcSecToRad (decimal arcSec)
decimal DecimalModulo (decimal x, decimal mod)
 Given a decimal, find it "modulo" another decimal, in the true mathematical sense (not remainder).
std::ostream & operator<< (std::ostream &output, const Vec2 &vec)
std::ostream & operator<< (std::ostream &output, const Vec3 &vec)
Mat3 QuaternionToDCM (const Quaternion &quat)
 Convert a quaternion to a rotation matrix (Direction Cosine Matrix).
Quaternion DCMToQuaternion (const Mat3 &dcm)
 Convert a rotation matrix (Direction Cosine Matrix) to a quaternion representing the same rotation.
void SerializeVec3 (SerializeContext *ser, const Vec3 &vec)
 Serialize a Vec3 to buffer. Takes up space according to SerializeLengthVec3.
Vec3 DeserializeVec3 (DeserializeContext *des)
decimal Angle (const Vec3 &vec1, const Vec3 &vec2)
 Calculate the inner angle, in radians, between two vectors.
decimal AngleUnit (const Vec3 &vec1, const Vec3 &vec2)
 Calculate the inner angle, in radians, between two /unit/ vectors.
decimal Distance (const Vec2 &, const Vec2 &)
decimal Distance (const Vec3 &, const Vec3 &)
decimal FovToFocalLength (decimal xFov, decimal xResolution)
decimal FocalLengthToFov (decimal focalLength, decimal xResolution, decimal pixelSize)
int BadThreshold (unsigned char *image, int imageWidth, int imageHeight)
int OtsusThreshold (unsigned char *image, int imageWidth, int imageHeight)
int BasicThreshold (unsigned char *image, int imageWidth, int imageHeight, std::vector< unsigned char > *rowMax=nullptr)
int BasicThresholdOnePass (unsigned char *image, int imageWidth, int imageHeight)
void IWCoGHelper (IWCoGParams *p, long i, unsigned char *image, int imageWidth, int imageHeight, std::vector< int > *starIndices)
bool isFlagSet (uint32_t dbFlags, uint32_t flag)
bool CompareKVectorPairs (const KVectorPair &p1, const KVectorPair &p2)
void SerializeKVectorIndex (SerializeContext *ser, const std::vector< decimal > &values, decimal min, decimal max, long numBins)
 K-vector index layout.
std::vector< KVectorPair > CatalogToPairDistances (const Catalog &catalog, decimal minDistance, decimal maxDistance)
 pair K-vector database layout.
void SerializePairDistanceKVector (SerializeContext *ser, const Catalog &catalog, decimal minDistance, decimal maxDistance, long numBins)
 Serialize a pair-distance KVector into buffer.
std::vector< uint16_t > TetraPreprocessCatalog (const Catalog &catalog, const decimal maxFovDeg, int numPatternStarsPerFov)
decimal Clamp (decimal num, decimal low, decimal high)
 Return the value in the range [low,high] which is closest to num.
void SerializeTetraDatabase (SerializeContext *ser, const Catalog &catalog, decimal maxFovDeg, const std::vector< uint16_t > &catalogPatternStarInds, int numEdgeRatioBins)
void SerializeMultiDatabase (SerializeContext *ser, const MultiDatabaseDescriptor &dbs, uint32_t flags)
std::vector< CatalogStar > BscParse (std::string tsvPath)
 Parse the bright star catalog from the TSV file on disk.
const Catalog & CatalogRead ()
 Read and parse the full catalog from disk. If called multiple times, will re-use the first result.
unsigned char * SurfaceToGrayscaleImage (cairo_surface_t *cairoSurface)
 Convert a colored Cairo image surface into a row-major array of grayscale pixels.
cairo_surface_t * GrayscaleImageToSurface (const unsigned char *image, const int width, const int height)
void SurfacePlot (std::string description, cairo_surface_t *cairoSurface, const Stars &stars, const StarIdentifiers *starIds, const Catalog *catalog, const Attitude *attitude, double red, double green, double blue, double alpha, bool rawStarIndexes=false)
 Plot information about an image onto the image using Cairo.
SerializeContext serFromDbValues (const DatabaseOptions &values)
MultiDatabaseDescriptor GenerateDatabases (const Catalog &, const DatabaseOptions &values)
 Appropriately create descriptors for all requested databases according to command-line options.
std::ostream & operator<< (std::ostream &os, const Camera &camera)
 Print information about the camera in machine and human-readable form.
decimal FocalLengthFromOptions (const PipelineOptions &values, int xResolution)
 Calculate the focal length, in pixels, based on the given command line options.
PipelineInputList GetPngPipelineInput (const PipelineOptions &values)
PipelineInputList GetGeneratedPipelineInput (const PipelineOptions &values)
 Create a GeneratedPipelineInput based on the command line options in values.
PipelineInputList GetPipelineInput (const PipelineOptions &values)
 Come up with a list of pipeline inputs based on command line options.
Pipeline SetPipeline (const PipelineOptions &values)
 Create a pipeline from command line options.
CentroidComparison CentroidsCompare (decimal threshold, const Stars &expected, const Stars &actual)
 Compare expected and actual centroids.
CentroidComparison CentroidComparisonsCombine (std::vector< CentroidComparison > comparisons)
StarIdComparison StarIdsCompare (const StarIdentifiers &expected, const StarIdentifiers &actual, const Catalog &expectedCatalog, const Catalog &actualCatalog, decimal centroidThreshold, const Stars &expectedStars, const Stars &inputStars)
 Compare expected and actual star identifications.
void PipelineComparatorPlotCentroidIndices (std::ostream &os, const PipelineInputList &expected, const std::vector< PipelineOutput > &actual, const PipelineOptions &)
 Plot an annotated image where centroids are annotated with their centroid index.
void PipelineComparison (const PipelineInputList &expected, const std::vector< PipelineOutput > &actual, const PipelineOptions &values)
 Print or otherwise analyze the results of (perhaps multiple) runs of a star tracking pipeline.
void InspectCatalog ()
template<typename T>
void SwapEndianness (unsigned char *buffer)
 Unconditionally swap the endianness of a value (uses sizeof T).
template<typename T>
void SwapEndiannessIfNecessary (unsigned char *buffer, SerializeContext *ser)
 Swap the endianness of a value if necessary.
template<>
void SwapEndiannessIfNecessary< decimal > (unsigned char *buffer, SerializeContext *ser)
template<typename T>
void DeserializePadding (DeserializeContext *des)
 Move the cursor forward past any padding that would appear before a value of type T.
template<typename T>
T DeserializePrimitive (DeserializeContext *des)
template<typename T>
const T * DeserializeArray (DeserializeContext *des, long arrLength)
 return an array of items as a pointer. Will point into the buffer (mmap style).
template<typename T>
void SerializePadding (SerializeContext *ser)
template<typename T>
void SerializePrimitive (SerializeContext *ser, const T &val)
std::vector< int16_t > IdentifyThirdStar (const PairDistanceKVectorDatabase &db, const Catalog &catalog, int16_t catalogIndex1, int16_t catalogIndex2, decimal distance1, decimal distance2, decimal tolerance)
 Given two already-identified centroids, and the distance from each to an as-yet unidentified third centroid, return a list of candidate catalog stars that could be the third centroid.
int IdentifyRemainingStarsPairDistance (StarIdentifiers *identifiers, const Stars &stars, const PairDistanceKVectorDatabase &db, const Catalog &catalog, const Camera &camera, decimal tolerance)
 Given some identified stars, attempt to identify the rest.
std::vector< int16_t > ConsumeInvolvingIterator (PairDistanceInvolvingIterator it)
std::vector< std::vector< IRUnidentifiedCentroid * >::iterator > FindUnidentifiedCentroidsInRange (std::vector< IRUnidentifiedCentroid * > *centroids, const Star &star, const Camera &camera, decimal minDistance, decimal maxDistance)
 Return all the unidentified centroids within the requested distance bounds from star.
void AddToAllUnidentifiedCentroids (const StarIdentifier &starId, const Stars &stars, std::vector< IRUnidentifiedCentroid * > *aboveThresholdCentroids, std::vector< IRUnidentifiedCentroid * > *belowThresholdCentroids, decimal minDistance, decimal maxDistance, decimal angleFrom90Threshold, const Camera &camera)
 Given a list of unidentified centroids not yet at the soft threshold, and a list of unidentified centroids already below the soft threshold, appropriately add the given centroid to all the unidentified centroids still above the threshold, and perhaps move them to the below threshold list.
IRUnidentifiedCentroid * SelectNextUnidentifiedCentroid (std::vector< IRUnidentifiedCentroid * > *aboveThresholdCentroids, std::vector< IRUnidentifiedCentroid * > *belowThresholdCentroids)
bool CatalogStarMagnitudeCompare (const CatalogStar &a, const CatalogStar &b)
Catalog NarrowCatalog (const Catalog &, int maxMagnitude, int maxStars, decimal minSeparation)
 Remove unwanted stars from an unfiltered catalog.
size_t TetraFindPatternIndex (const int *patternEdgeRatios, size_t numRatios, int numEdgeRatioBins, size_t tableSize)
Catalog::const_iterator FindNamedStar (const Catalog &catalog, int name)
 Return a pointer to the star with the given name, or NULL if not found.
void SerializeCatalogStar (SerializeContext *ser, const CatalogStar &catalogStar, bool inclMagnitude, bool inclName)
 Serialize a CatalogStar into a byte buffer.
CatalogStar DeserializeCatalogStar (DeserializeContext *des, bool inclMagnitude, bool inclName)
 Deserialize a catalog star.
void SerializeCatalog (SerializeContext *ser, const Catalog &catalog, bool inclMagnitude, bool inclName)
 Serialize the catalog to buffer.
Catalog DeserializeCatalog (DeserializeContext *des, bool *inclMagnitudeReturn, bool *inclNameReturn)
 Deserialize a catalog.
decimal MagToBrightness (int magnitude)
 returns some relative brightness measure, which is proportional to the total number of photons received from a star.
template<typename SpatialAccessor>
bool AllPairsWithinFov (int numStars, SpatialAccessor spatial, decimal cosMaxFov)
template<typename SpatialAccessor>
std::vector< decimal > TetraEdgeRatios (int numStars, SpatialAccessor spatial)

Variables

const Mat3 kIdentityMat3
 3x3 identity matrix
decimal iWCoGMinChange = DECIMAL(0.0002)
const int32_t kCatalogMagicValue = 0xF9A283BC
const int kMaxBrightness = 255
const decimal kAngleFrom90SoftThreshold = DECIMAL_M_PI_4

Detailed Description

LOST starting point.

Helpers to serialize and deserialize arbitrary data types to disk.

Reads in CLI arguments/flags and starts the appropriate pipelines

The serialization and deserialization helpers here assume that (a) integers and decimal point numbers are stored in the same format on the source and target systems except for endianness, and (b) the target system requires no greater than n-byte alignment for n-byte values (eg, an int32_t only needs 4-byte alignment, not 8-byte), and (c) the database itself will be aligned at a multiple of the largest size of any value stored within (because we only align values relative to the start of the database, so everything breaks if the database itself is misaligned).

Generally, the "bulk" of any database will not be explicitly deserialized into a data structure in memory, but instead will just effectively memory-mapped, by just storing a pointer to a certain offset into the database. The serialization functions in this file can still be used to create such a "bulk" section, but deserialization must be handled manually.

Typedef Documentation

◆ Catalog

typedef std::vector<CatalogStar> lost::Catalog

Definition at line 101 of file star-utils.hpp.

◆ HashCode

using lost::HashCode = std::array<int, kNumEdgeRatios>

Definition at line 28 of file star-id.cpp.

◆ MultiDatabaseDescriptor

Definition at line 187 of file databases.hpp.

◆ PipelineComparator

typedef void(* lost::PipelineComparator) (std::ostream &os, const PipelineInputList &, const std::vector< PipelineOutput > &, const PipelineOptions &)

Definition at line 1284 of file io.cpp.

◆ PipelineInputList

typedef std::vector<std::unique_ptr<PipelineInput> > lost::PipelineInputList

Definition at line 222 of file io.hpp.

◆ StarIdentifiers

typedef std::vector<StarIdentifier> lost::StarIdentifiers

Definition at line 103 of file star-utils.hpp.

◆ Stars

typedef std::vector<Star> lost::Stars

Definition at line 102 of file star-utils.hpp.

◆ TetraPattern

using lost::TetraPattern = std::array<uint16_t, TetraConstants::numPatternStars>

Definition at line 93 of file databases.hpp.

Function Documentation

◆ AddToAllUnidentifiedCentroids()

void lost::AddToAllUnidentifiedCentroids ( const StarIdentifier & starId,
const Stars & stars,
std::vector< IRUnidentifiedCentroid * > * aboveThresholdCentroids,
std::vector< IRUnidentifiedCentroid * > * belowThresholdCentroids,
decimal minDistance,
decimal maxDistance,
decimal angleFrom90Threshold,
const Camera & camera )

Given a list of unidentified centroids not yet at the soft threshold, and a list of unidentified centroids already below the soft threshold, appropriately add the given centroid to all the unidentified centroids still above the threshold, and perhaps move them to the below threshold list.

Parameters
angleFrom90ThresholdOnce an IRUnidentifiedCentroid's best angle from 90 goes below this threshold

Definition at line 636 of file star-id.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AllPairsWithinFov()

template<typename SpatialAccessor>
bool lost::AllPairsWithinFov ( int numStars,
SpatialAccessor spatial,
decimal cosMaxFov )

Definition at line 185 of file star-utils.hpp.

Here is the caller graph for this function:

◆ Angle()

decimal lost::Angle ( const Vec3 & vec1,
const Vec3 & vec2 )

Calculate the inner angle, in radians, between two vectors.

angle between two vectors, using dot product and magnitude division

Definition at line 484 of file attitude-utils.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AngleUnit()

decimal lost::AngleUnit ( const Vec3 & vec1,
const Vec3 & vec2 )

Calculate the inner angle, in radians, between two /unit/ vectors.

angle between two vectors, /assuming/ that they are already unit length

Slightly faster than Angle() @warn If the vectors are not already unit vectors, will return the wrong result!

Definition at line 493 of file attitude-utils.cpp.

Here is the caller graph for this function:

◆ ArcSecToRad()

decimal lost::ArcSecToRad ( decimal arcSec)

Definition at line 164 of file attitude-utils.cpp.

Here is the call graph for this function:

◆ BadThreshold()

int lost::BadThreshold ( unsigned char * image,
int imageWidth,
int imageHeight )

Definition at line 30 of file centroiders.cpp.

◆ BasicThreshold()

int lost::BasicThreshold ( unsigned char * image,
int imageWidth,
int imageHeight,
std::vector< unsigned char > * rowMax = nullptr )

Definition at line 80 of file centroiders.cpp.

Here is the caller graph for this function:

◆ BasicThresholdOnePass()

int lost::BasicThresholdOnePass ( unsigned char * image,
int imageWidth,
int imageHeight )

Definition at line 104 of file centroiders.cpp.

◆ BscParse()

std::vector< CatalogStar > lost::BscParse ( std::string tsvPath)

Parse the bright star catalog from the TSV file on disk.

Definition at line 60 of file io.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CatalogRead()

const Catalog & lost::CatalogRead ( )

Read and parse the full catalog from disk. If called multiple times, will re-use the first result.

Definition at line 101 of file io.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CatalogStarMagnitudeCompare()

bool lost::CatalogStarMagnitudeCompare ( const CatalogStar & a,
const CatalogStar & b )

Definition at line 17 of file star-utils.cpp.

Here is the caller graph for this function:

◆ CatalogToPairDistances()

std::vector< KVectorPair > lost::CatalogToPairDistances ( const Catalog & catalog,
decimal minDistance,
decimal maxDistance )

pair K-vector database layout.

The kvector appears before the bulk pair data because it contains the number of pairs, which is necessary to read the bulk pair data.

| size (bytes)             | name         | description                                                 |
|--------------------------+--------------+-------------------------------------------------------------|
| sizeof kvectorIndex      | kVectorIndex | Serialized KVector index                                    |
| 2*sizeof(int16)*numPairs | pairs        | Bulk pair data                                              |

Definition at line 176 of file databases.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CentroidComparisonsCombine()

CentroidComparison lost::CentroidComparisonsCombine ( std::vector< CentroidComparison > comparisons)

Definition at line 1184 of file io.cpp.

◆ CentroidsCompare()

CentroidComparison lost::CentroidsCompare ( decimal threshold,
const Stars & expected,
const Stars & actual )

Compare expected and actual centroids.

Useful for debugging and benchmarking.

Parameters
thresholdThe maximum number of pixels apart two centroids can be to be considered the same.

Definition at line 1158 of file io.cpp.

◆ Clamp()

decimal lost::Clamp ( decimal num,
decimal low,
decimal high )

Return the value in the range [low,high] which is closest to num.

Definition at line 305 of file databases.cpp.

◆ CompareKVectorPairs()

bool lost::CompareKVectorPairs ( const KVectorPair & p1,
const KVectorPair & p2 )

Definition at line 30 of file databases.cpp.

Here is the caller graph for this function:

◆ ConsumeInvolvingIterator()

std::vector< int16_t > lost::ConsumeInvolvingIterator ( PairDistanceInvolvingIterator it)

Definition at line 509 of file star-id.cpp.

Here is the call graph for this function:

◆ DCMToQuaternion()

Quaternion lost::DCMToQuaternion ( const Mat3 & dcm)

Convert a rotation matrix (Direction Cosine Matrix) to a quaternion representing the same rotation.

Definition at line 381 of file attitude-utils.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DecimalModulo()

decimal lost::DecimalModulo ( decimal x,
decimal mod )

Given a decimal, find it "modulo" another decimal, in the true mathematical sense (not remainder).

Always returns something in [0,mod) Eg -0.8 mod 0.6 = 0.4

Definition at line 168 of file attitude-utils.cpp.

◆ DegToRad()

decimal lost::DegToRad ( decimal deg)

Definition at line 156 of file attitude-utils.cpp.

Here is the caller graph for this function:

◆ DeserializeArray()

template<typename T>
const T * lost::DeserializeArray ( DeserializeContext * des,
long arrLength )

return an array of items as a pointer. Will point into the buffer (mmap style).

Definition at line 105 of file serialize-helpers.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DeserializeCatalog()

Catalog lost::DeserializeCatalog ( DeserializeContext * des,
bool * inclMagnitudeReturn,
bool * inclNameReturn )

Deserialize a catalog.

Parameters
[out]inclMagnitudeReturn,inclNameReturnWill store whether inclMagnitude and inclNameReturn were set in the corresponding SerializeCatalog() call.

Definition at line 144 of file star-utils.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DeserializeCatalogStar()

CatalogStar lost::DeserializeCatalogStar ( DeserializeContext * des,
bool inclMagnitude,
bool inclName )

Deserialize a catalog star.

@warn The inclMagnitude and inclName parameters must be the same as passed to SerializeCatalogStar()

See also
SerializeCatalogStar

Definition at line 107 of file star-utils.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DeserializePadding()

template<typename T>
void lost::DeserializePadding ( DeserializeContext * des)

Move the cursor forward past any padding that would appear before a value of type T.

Definition at line 91 of file serialize-helpers.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DeserializePrimitive()

template<typename T>
T lost::DeserializePrimitive ( DeserializeContext * des)

Definition at line 96 of file serialize-helpers.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DeserializeVec3()

Vec3 lost::DeserializeVec3 ( DeserializeContext * des)

Definition at line 474 of file attitude-utils.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Distance() [1/2]

decimal lost::Distance ( const Vec2 & ,
const Vec2 &  )

◆ Distance() [2/2]

decimal lost::Distance ( const Vec3 & ,
const Vec3 &  )

◆ FindNamedStar()

Catalog::const_iterator lost::FindNamedStar ( const Catalog & catalog,
int name )

Return a pointer to the star with the given name, or NULL if not found.

Definition at line 75 of file star-utils.cpp.

◆ FindUnidentifiedCentroidsInRange()

std::vector< std::vector< IRUnidentifiedCentroid * >::iterator > lost::FindUnidentifiedCentroidsInRange ( std::vector< IRUnidentifiedCentroid * > * centroids,
const Star & star,
const Camera & camera,
decimal minDistance,
decimal maxDistance )

Return all the unidentified centroids within the requested distance bounds from star.

The returned vector has pointers into the vector passed as an argument. Thus, it's important not to modify the centroids argument after calling.

Definition at line 585 of file star-id.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FocalLengthFromOptions()

decimal lost::FocalLengthFromOptions ( const PipelineOptions & values,
int xResolution )

Calculate the focal length, in pixels, based on the given command line options.

This function exists because there are two ways to specify how "zoomed-in" the camera is. One way is using just FOV, which is useful when generating false images. Another is a combination of pixel size and focal length, which is useful for physical cameras.

Definition at line 329 of file io.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FocalLengthToFov()

decimal lost::FocalLengthToFov ( decimal focalLength,
decimal xResolution,
decimal pixelSize )

Definition at line 62 of file camera.cpp.

Here is the caller graph for this function:

◆ FovToFocalLength()

decimal lost::FovToFocalLength ( decimal xFov,
decimal xResolution )

Definition at line 58 of file camera.cpp.

Here is the caller graph for this function:

◆ GenerateDatabases()

MultiDatabaseDescriptor lost::GenerateDatabases ( const Catalog & ,
const DatabaseOptions & values )

Appropriately create descriptors for all requested databases according to command-line options.

See also
SerializeMultiDatabase

Definition at line 275 of file io.cpp.

Here is the call graph for this function:

◆ GetGeneratedPipelineInput()

PipelineInputList lost::GetGeneratedPipelineInput ( const PipelineOptions & values)

Create a GeneratedPipelineInput based on the command line options in values.

Definition at line 790 of file io.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPipelineInput()

PipelineInputList lost::GetPipelineInput ( const PipelineOptions & values)

Come up with a list of pipeline inputs based on command line options.

Definition at line 862 of file io.cpp.

Here is the call graph for this function:

◆ GetPngPipelineInput()

PipelineInputList lost::GetPngPipelineInput ( const PipelineOptions & values)

Definition at line 407 of file io.cpp.

Here is the caller graph for this function:

◆ GrayscaleImageToSurface()

cairo_surface_t * lost::GrayscaleImageToSurface ( const unsigned char * image,
const int width,
const int height )

Definition at line 158 of file io.cpp.

Here is the caller graph for this function:

◆ IdentifyRemainingStarsPairDistance()

int lost::IdentifyRemainingStarsPairDistance ( StarIdentifiers * identifiers,
const Stars & stars,
const PairDistanceKVectorDatabase & db,
const Catalog & catalog,
const Camera & camera,
decimal tolerance )

Given some identified stars, attempt to identify the rest.

Requires a pair distance database to be present. Iterates through the unidentified centroids in an intelligent order, identifying them one by one.

Definition at line 747 of file star-id.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IdentifyThirdStar()

std::vector< int16_t > lost::IdentifyThirdStar ( const PairDistanceKVectorDatabase & db,
const Catalog & catalog,
int16_t catalogIndex1,
int16_t catalogIndex2,
decimal distance1,
decimal distance2,
decimal tolerance )

Given two already-identified centroids, and the distance from each to an as-yet unidentified third centroid, return a list of candidate catalog stars that could be the third centroid.

The order in which the two centroids are passed in /does/ matter wrt spectral-ness. If the first supplied catalog star is a, second is b, and the unidentified is c, then (a crossproduct b) dot c will be positive for all returned c. Intuitively, if the triangle is fairly small on the surface of the sphere, then viewed from the origin, the vertices a, b, and c should be clockwise (then, the cross product of a and b will point mostly towards c, and a little outwards, so that dot product with c captures that positive outward part).

Definition at line 670 of file star-id.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InspectCatalog()

void lost::InspectCatalog ( )

◆ isFlagSet()

bool lost::isFlagSet ( uint32_t dbFlags,
uint32_t flag )
inline

Definition at line 20 of file databases.cpp.

Here is the caller graph for this function:

◆ IWCoGHelper()

void lost::IWCoGHelper ( IWCoGParams * p,
long i,
unsigned char * image,
int imageWidth,
int imageHeight,
std::vector< int > * starIndices )

Definition at line 211 of file centroiders.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MagToBrightness()

decimal lost::MagToBrightness ( int magnitude)

returns some relative brightness measure, which is proportional to the total number of photons received from a star.

As always, the magnitude is actually 100* the usual magnitude

Definition at line 168 of file star-utils.cpp.

Here is the caller graph for this function:

◆ NarrowCatalog()

Catalog lost::NarrowCatalog ( const Catalog & ,
int maxMagnitude,
int maxStars,
decimal minSeparation )

Remove unwanted stars from an unfiltered catalog.

TODO: Don't necessarily remove both stars when they're within minSeparation. Instead, if the brightnesses are different enough, just keep the brightest one!

Parameters
maxMagnitudeShould be 100*(magnitude), just like CatalogStar::magnitude. The narrowed catalog will only contain stars at least as bright as that (i.e., lower magnitude). Pass something like 9999 to not filter based on magnitude.
maxStarsNo more than maxStars many stars will be in the narrowed catalog (prefers brightest). Pass something like 99999 to not filter maxStars.
minDistanceAny star which is within minDistance of another star is removed from the catalog. Pass something like -1 to not filter based on minDistance. TODO: In the future, some provision may be made so that instead of being removed, these stars get a special distinguishing mark, so that star-id algorithms can reason about them instead of thinking they are false stars, but no such provision is made yet.

Definition at line 21 of file star-utils.cpp.

Here is the call graph for this function:

◆ operator<<() [1/3]

std::ostream & lost::operator<< ( std::ostream & os,
const Camera & camera )

Print information about the camera in machine and human-readable form.

Definition at line 314 of file io.cpp.

Here is the call graph for this function:

◆ operator<<() [2/3]

std::ostream & lost::operator<< ( std::ostream & output,
const Vec2 & vec )

Definition at line 174 of file attitude-utils.cpp.

◆ operator<<() [3/3]

std::ostream & lost::operator<< ( std::ostream & output,
const Vec3 & vec )

Definition at line 179 of file attitude-utils.cpp.

◆ OtsusThreshold()

int lost::OtsusThreshold ( unsigned char * image,
int imageWidth,
int imageHeight )

Definition at line 40 of file centroiders.cpp.

◆ PipelineComparatorPlotCentroidIndices()

void lost::PipelineComparatorPlotCentroidIndices ( std::ostream & os,
const PipelineInputList & expected,
const std::vector< PipelineOutput > & actual,
const PipelineOptions &  )

Plot an annotated image where centroids are annotated with their centroid index.

For debugging. Use whatever stars were input into the star-id algo (so either actual centroids, or inputstars)

Definition at line 1481 of file io.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PipelineComparison()

void lost::PipelineComparison ( const PipelineInputList & expected,
const std::vector< PipelineOutput > & actual,
const PipelineOptions & values )

Print or otherwise analyze the results of (perhaps multiple) runs of a star tracking pipeline.

Uses the command line options in values to determine which analyses to run. Examples include plotting an annotated output image to a png file, comparing the actual and expected centroids, etc

Definition at line 1774 of file io.cpp.

Here is the call graph for this function:

◆ QuaternionToDCM()

Mat3 lost::QuaternionToDCM ( const Quaternion & quat)

Convert a quaternion to a rotation matrix (Direction Cosine Matrix).

Definition at line 369 of file attitude-utils.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ QuestCharPoly()

decimal lost::QuestCharPoly ( decimal x,
decimal a,
decimal b,
decimal c,
decimal d,
decimal s )

Characteristic polynomial of the quest K-matrix.

See also
equation 19b of https://arc.aiaa.org/doi/pdf/10.2514/1.62549

Definition at line 164 of file attitude-estimators.cpp.

Here is the caller graph for this function:

◆ QuestCharPolyPrime()

decimal lost::QuestCharPolyPrime ( decimal x,
decimal a,
decimal b,
decimal c )

Derivitive of the characteristic polynomial of the quest K-matrix.

Definition at line 169 of file attitude-estimators.cpp.

Here is the caller graph for this function:

◆ QuestEigenvalueEstimator()

bool lost::QuestEigenvalueEstimator ( decimal guess,
decimal a,
decimal b,
decimal c,
decimal d,
decimal s,
decimal * eig )

Approximates roots of a real function using the Newton-Raphson algorithm.

See also
https://www.geeksforgeeks.org/program-for-newton-raphson-method/
Returns
false if it doesn't converge within QUEST_MAX_ITERATIONS

Definition at line 176 of file attitude-estimators.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RadToArcSec()

decimal lost::RadToArcSec ( decimal rad)

Definition at line 160 of file attitude-utils.cpp.

Here is the call graph for this function:

◆ RadToDeg()

decimal lost::RadToDeg ( decimal rad)

Definition at line 152 of file attitude-utils.cpp.

Here is the caller graph for this function:

◆ SelectNextUnidentifiedCentroid()

IRUnidentifiedCentroid * lost::SelectNextUnidentifiedCentroid ( std::vector< IRUnidentifiedCentroid * > * aboveThresholdCentroids,
std::vector< IRUnidentifiedCentroid * > * belowThresholdCentroids )

Definition at line 715 of file star-id.cpp.

Here is the caller graph for this function:

◆ serFromDbValues()

SerializeContext lost::serFromDbValues ( const DatabaseOptions & values)

Definition at line 271 of file io.cpp.

Here is the caller graph for this function:

◆ SerializeCatalog()

void lost::SerializeCatalog ( SerializeContext * ser,
const Catalog & catalog,
bool inclMagnitude,
bool inclName )

Serialize the catalog to buffer.

Use SerializeLengthCatalog() to determine how many bytes to allocate in buffer

Parameters
inclMagnitude,inclNameSee SerializeCatalogStar()

Definition at line 128 of file star-utils.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SerializeCatalogStar()

void lost::SerializeCatalogStar ( SerializeContext * ser,
const CatalogStar & catalogStar,
bool inclMagnitude,
bool inclName )

Serialize a CatalogStar into a byte buffer.

Use SerializeLengthCatalogStar() to determine how many bytes to allocate in buffer

Parameters
inclMagnitudeWhether to include the magnitude of the star.
inclNameWhether to include the (numerical) name of the star.
buffer[out]Where the serialized star is stored.

Definition at line 91 of file star-utils.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SerializeKVectorIndex()

void lost::SerializeKVectorIndex ( SerializeContext * ser,
const std::vector< decimal > & values,
decimal min,
decimal max,
long numBins )

K-vector index layout.

No magic value because its never used on its own. | size | name | description | |------------—+---------—+----------------------------------------------------------—| | 4 | numEntries | | | sizeof decimal | min | minimum value contained in the database | | sizeof decimal | max | max value contained in index | | 4 | numBins | | | 4*(numBins+1) | bins | The `i'th bin (starting from zero) stores how many pairs of | | | | stars have a distance lesst han or equal to: | | | | min+i*(max-min)/numBins | */

apparently there's no easy way to accept an iterator argument. Hate java all you want, but at least it can do that! https://stackoverflow.com/questions/5054087/declare-a-function-accepting-generic-iterator or rather, the correct way is to use a template and just use the ++ and * operators willy-nilly, which will throw an error if the operators are not implemented.

/** Serialize a KVector index to disk. Use SerializeLengthKVectorIndex to determine how long the buffer should be.

Parameters
valuesThe actual entries the kvector should be referring to, sorted in ascending order.
Precondition
values must be sorted in ascending order!
Parameters
min,maxGuaranteed bounds on the entries of values
Todo
Consider replacing min and max parameters by just calculating the min and max of values?
Parameters
numBinsthe number of "bins" the KVector should use. A higher number makes query results "tighter" but takes up more disk space. Usually should be set somewhat smaller than (max-min) divided by the "width" of the typical query.
buffer[out]index is written here.

Definition at line 65 of file databases.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SerializeMultiDatabase()

void lost::SerializeMultiDatabase ( SerializeContext * ser,
const MultiDatabaseDescriptor & dbs,
uint32_t flags )

Definition at line 521 of file databases.cpp.

Here is the call graph for this function:

◆ SerializePadding()

template<typename T>
void lost::SerializePadding ( SerializeContext * ser)

Definition at line 114 of file serialize-helpers.hpp.

Here is the caller graph for this function:

◆ SerializePairDistanceKVector()

void lost::SerializePairDistanceKVector ( SerializeContext * ser,
const Catalog & catalog,
decimal minDistance,
decimal maxDistance,
long numBins )

Serialize a pair-distance KVector into buffer.

Use SerializeLengthPairDistanceKVector to determine how large the buffer needs to be. See command line documentation for other options.

Definition at line 199 of file databases.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SerializePrimitive()

template<typename T>
void lost::SerializePrimitive ( SerializeContext * ser,
const T & val )

Definition at line 121 of file serialize-helpers.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SerializeTetraDatabase()

void lost::SerializeTetraDatabase ( SerializeContext * ser,
const Catalog & catalog,
decimal maxFovDeg,
const std::vector< uint16_t > & catalogPatternStarInds,
int numEdgeRatioBins )

Definition at line 374 of file databases.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SerializeVec3()

void lost::SerializeVec3 ( SerializeContext * ser,
const Vec3 & vec )

Serialize a Vec3 to buffer. Takes up space according to SerializeLengthVec3.

Definition at line 468 of file attitude-utils.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetPipeline()

Pipeline lost::SetPipeline ( const PipelineOptions & values)

Create a pipeline from command line options.

Definition at line 898 of file io.cpp.

◆ SpatialToSpherical()

void lost::SpatialToSpherical ( const Vec3 & vec,
decimal * ra,
decimal * de )

Convert from a 3d point on the unit sphere to right ascension & declination.

Definition at line 145 of file attitude-utils.cpp.

◆ SphericalToQuaternion()

Quaternion lost::SphericalToQuaternion ( decimal ra,
decimal dec,
decimal roll )

Return a quaternion that will reorient the coordinate axes so that the x-axis points at the given right ascension and declination, then roll the coordinate axes counterclockwise (i.e., the stars will appear to rotate clockwise).

This is an "improper" z-y'-x' Euler rotation.

Definition at line 100 of file attitude-utils.cpp.

Here is the caller graph for this function:

◆ SphericalToSpatial()

Vec3 lost::SphericalToSpatial ( decimal ra,
decimal de )

Convert from right ascension & declination to a 3d point on the unit sphere.

returns unit vector

Definition at line 136 of file attitude-utils.cpp.

Here is the caller graph for this function:

◆ StarIdsCompare()

StarIdComparison lost::StarIdsCompare ( const StarIdentifiers & expected,
const StarIdentifiers & actual,
const Catalog & expectedCatalog,
const Catalog & actualCatalog,
decimal centroidThreshold,
const Stars & expectedStars,
const Stars & inputStars )

Compare expected and actual star identifications.

Useful for debugging and benchmarking.

The following description is compatible with, but more actionable than, the definitions in the documentation for StarIdComparison. A star-id is correct if the centroid is the closest centroid to some expected centroid, and the referenced catalog star is the same one as in the expected star-ids for that centroid. Also permissible is if the centroid is not the closest to any expected centroid, but it has the same star-id as another star closer to the closest expected centroid. All other star-ids are incorrect (because they are either identifying false stars, or are incorrect identifications on true stars)

The "total" in the result is just the number of input stars.

Definition at line 1203 of file io.cpp.

◆ SurfacePlot()

void lost::SurfacePlot ( std::string description,
cairo_surface_t * cairoSurface,
const Stars & stars,
const StarIdentifiers * starIds,
const Catalog * catalog,
const Attitude * attitude,
double red,
double green,
double blue,
double alpha,
bool rawStarIndexes = false )

Plot information about an image onto the image using Cairo.

Puts a box around each centroid, writes the attitude in the top left, etc.

Parameters
red,green,blueThe color to use when annotating the image. 0 represents none of that color, 1 represents that color in full.
alphaThe transparency of annotations. 0 is completely transparent, 1 is completely opaque.
rawStarIndexesIf true, print the catalog index. This is in contrast with the default behavior, which is to print the name of the catalog star.

Definition at line 180 of file io.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SurfaceToGrayscaleImage()

unsigned char * lost::SurfaceToGrayscaleImage ( cairo_surface_t * cairoSurface)

Convert a colored Cairo image surface into a row-major array of grayscale pixels.

Result is allocated with new[]

Definition at line 129 of file io.cpp.

Here is the caller graph for this function:

◆ SwapEndianness()

template<typename T>
void lost::SwapEndianness ( unsigned char * buffer)

Unconditionally swap the endianness of a value (uses sizeof T).

Definition at line 64 of file serialize-helpers.hpp.

Here is the caller graph for this function:

◆ SwapEndiannessIfNecessary()

template<typename T>
void lost::SwapEndiannessIfNecessary ( unsigned char * buffer,
SerializeContext * ser )

Swap the endianness of a value if necessary.

Uses LOST_DATABASE_{SOURCE,TARGET}_INTEGER_ENDIANNESS to determine to switch all values but decimal which uses LOST_DATABASE_{SOURCE,TARGET}_DECIMAL_ENDIANNESS.

Definition at line 74 of file serialize-helpers.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SwapEndiannessIfNecessary< decimal >()

template<>
void lost::SwapEndiannessIfNecessary< decimal > ( unsigned char * buffer,
SerializeContext * ser )
inline

Definition at line 83 of file serialize-helpers.hpp.

Here is the call graph for this function:

◆ TetraEdgeRatios()

template<typename SpatialAccessor>
std::vector< decimal > lost::TetraEdgeRatios ( int numStars,
SpatialAccessor spatial )

Definition at line 196 of file star-utils.hpp.

Here is the caller graph for this function:

◆ TetraFindPatternIndex()

size_t lost::TetraFindPatternIndex ( const int * patternEdgeRatios,
size_t numRatios,
int numEdgeRatioBins,
size_t tableSize )

Definition at line 59 of file star-utils.cpp.

Here is the caller graph for this function:

◆ TetraPreprocessCatalog()

std::vector< uint16_t > lost::TetraPreprocessCatalog ( const Catalog & catalog,
const decimal maxFovDeg,
int numPatternStarsPerFov )

Definition at line 221 of file databases.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ iWCoGMinChange

decimal lost::iWCoGMinChange = DECIMAL(0.0002)

Definition at line 197 of file centroiders.cpp.

◆ kAngleFrom90SoftThreshold

const decimal lost::kAngleFrom90SoftThreshold = DECIMAL_M_PI_4

Definition at line 739 of file star-id.cpp.

◆ kCatalogMagicValue

const int32_t lost::kCatalogMagicValue = 0xF9A283BC

Definition at line 15 of file databases.hpp.

◆ kIdentityMat3

const Mat3 lost::kIdentityMat3
Initial value:
= {1,0,0,
0,1,0,
0,0,1}

3x3 identity matrix

Definition at line 358 of file attitude-utils.cpp.

◆ kMaxBrightness

const int lost::kMaxBrightness = 255

Definition at line 532 of file io.cpp.