-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tracking mode #105
base: master
Are you sure you want to change the base?
Tracking mode #105
Changes from all commits
89d0883
e1977a1
74560ae
52e04c0
549f32c
04ebb59
8700009
e6aa00b
6f44b40
d062459
4ad6bdd
3f24f61
052300a
0cf4f54
e0abcee
4d11776
99e9c1d
80ea959
43bffc8
16f7108
0722366
8912d80
209c14b
55ee888
e320cc8
b14869e
6706376
fe4833e
c4c3892
0a537ed
c088f80
5b87217
0824c8e
bee762c
b71ab21
43b8e9f
d789857
632647c
e252f03
7c93c23
e564591
119bc2e
f956e3f
ba76233
77b4198
8b919c2
01ba8b9
bbe64d9
ce74e1d
40b8415
9e16953
905103b
3e5cbbf
eb95e44
5291c39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
*.o | ||
*.d | ||
*.png | ||
*.dat | ||
*.txt | ||
|
||
/documentation/man-*.h | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ pipeline \- builds a pipeline of the star identification process | |
.br | ||
\fBpipeline\fP --generate[=\fInum-images\fP] [--horizontal-res \fIres\fP] [--vertical-res \fIres\fP] [--horizontal-fov \fIdegrees\fP] [--ref-brightness \fImag\fP] [--spread-stddev \fIstddev\fP] [--noise-stddev \fIstddev\fP] [--boresight-right-asc \fIascension\fP] [--boresight-dec \fIdeclination\fP] [--boresight-roll \fIroll\fP] | ||
[--centroid-algo \fIalgorithm\fP [--centroid-dummy-stars \fInum-stars\fP]] [--centroid-mag-filter \fImin-mag\fP] | ||
[--database \fIfilename\fP] [--star-id-algo \fIalgo\fP (--gv-tolerance \fIdegrees\fP | --py-tolerance \fIdegrees\fP --false-stars \fInum\fP --max-mismatch-prob \fIprobability\fP)] [--attitude-algo \fIalgo\fP] [--plot \fIoutput-path\fB] | ||
[--database \fIfilename\fP] [--star-id-algo \fIalgo\fP (--gv-tolerance \fIdegrees\fP | --py-tolerance \fIdegrees\fP --false-stars \fInum\fP --max-mismatch-prob \fIprobability\fP | --prev-attitude \fIattitude\fP --uncertainty \fIradius\fP (--tracking-compare-threshold \fIthreshold\fP))] [--attitude-algo \fIalgo\fP] [--plot \fIoutput-path\fB] | ||
|
||
.SH DESCRIPTION | ||
|
||
|
@@ -55,7 +55,7 @@ Will not consider candidate as centroid if its magnitude is below \fImin-mag\fP. | |
|
||
.TP | ||
\fB--star-id-algo\fP \fIalgo\fP | ||
Runs the \fIalgo\fP star identification algorithm. Current options are "dummy", "gv", and "pyramid". Defaults to "dummy" if option is not selected. | ||
Runs the \fIalgo\fP star identification algorithm. Current options are "dummy", "gv", "pyramid", and "tracking". Defaults to "pyramid" if option is not selected. | ||
|
||
.TP | ||
\fB--angular-tolerance\fP [\fItolerance\fP] Sets the estimated angular centroiding error tolerance, | ||
|
@@ -69,6 +69,18 @@ used in some star id algorithms, to \fItolerance\fP degrees. Defaults to 0.04 de | |
\fB--max-mismatch-prob\fP \fIprobability\fP | ||
\fIprobability\fP is the maximum allowable probability of an incorrect star identification, for star id algorithms which support it. Defaults to 0.001. | ||
|
||
.TP | ||
\fB--prev-attitude\fP \fIattitude\fP | ||
\fIattitude\fP is the known previous attitude for tracking mode. Should give ra, dec, and roll as a comma-separated list: "ra,dec,roll." | ||
|
||
.TP | ||
\fB--uncertainty\fP \fIradius\fP | ||
For tracking mode. \fIradius\fP gives the boundary for how much the field of view could have rotated. Defaults to 0.001 if not selected. Must be nonnegative. | ||
|
||
.TP | ||
\fB--tracking-compare-threshold\fP \fIthreshold\fP | ||
\fIthreshold\fP is the threshold for comparing floats for tracking mode. Defaults to 0.001 if no value is given. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are the units? What exactly is being compared? |
||
|
||
.TP | ||
\fB--attitude-algo\fP \fIalgo\fP | ||
Runs the \fIalgo\fP algorithm for the attitude stage of the pipeline. Current options are "dqm" (Davenport Q) and "triad". Defaults to dqm. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,23 @@ class TripleInnerKVectorDatabase { | |
int16_t *triples; | ||
}; | ||
|
||
|
||
|
||
// tracking mode database (basically stars are sorted by vector spatial x coord) | ||
class TrackingSortedDatabase { | ||
public: | ||
TrackingSortedDatabase(const unsigned char *databaseBytes); | ||
const static int32_t kMagicValue = 0x2536f0A9; | ||
std::vector<int16_t> QueryNearestStars(const Catalog &, const Vec3 point, float radius); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should have short documentation comment in header file |
||
|
||
private: | ||
int16_t length; // length of catalog | ||
std::vector<int16_t> indices; // sorted list of catalog indices | ||
}; | ||
|
||
long SerializeLengthTrackingCatalog(const Catalog &catalog); | ||
void SerializeTrackingCatalog(const Catalog &catalog, unsigned char *buffer); | ||
|
||
// maximum number of databases in a MultiDatabase | ||
const int kMultiDatabaseMaxDatabases = 64; | ||
const long kMultiDatabaseTocLength = 8*kMultiDatabaseMaxDatabases; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -249,6 +249,15 @@ void BuildKVectorDatabase(MultiDatabaseBuilder &builder, const Catalog &catalog, | |
|
||
} | ||
|
||
void BuildTrackingDatabase(MultiDatabaseBuilder &builder, const Catalog &catalog) { | ||
long length = SerializeLengthTrackingCatalog(catalog); | ||
unsigned char *buffer = builder.AddSubDatabase(TrackingSortedDatabase::kMagicValue, length); | ||
if (buffer == NULL) { | ||
std::cerr << "No room for another database." << std::endl; | ||
} | ||
SerializeTrackingCatalog(catalog, buffer); | ||
} | ||
|
||
|
||
void GenerateDatabases(MultiDatabaseBuilder &builder, const Catalog &catalog, const DatabaseOptions &values) { | ||
|
||
|
@@ -257,6 +266,8 @@ void GenerateDatabases(MultiDatabaseBuilder &builder, const Catalog &catalog, co | |
float maxDistance = DegToRad(values.kvectorMaxDistance); | ||
long numBins = values.kvectorNumDistanceBins; | ||
BuildKVectorDatabase(builder, catalog, minDistance, maxDistance, numBins); | ||
} else if (values.tracking) { | ||
BuildTrackingDatabase(builder, catalog); | ||
} else { | ||
std::cerr << "No database builder selected -- no database generated." << std::endl; | ||
exit(1); | ||
|
@@ -473,8 +484,8 @@ GeneratedPipelineInput::GeneratedPipelineInput(const Catalog &catalog, | |
|
||
// don't add false stars to centroids or star ids | ||
if (isTrueStar) { | ||
starIds.push_back(StarIdentifier(stars.size() - 1, i)); | ||
stars.push_back(star); | ||
starIds.push_back(StarIdentifier(stars.size() - 1, i)); | ||
} | ||
} | ||
} | ||
|
@@ -684,6 +695,28 @@ Pipeline SetPipeline(const PipelineOptions &values) { | |
result.starIdAlgorithm = std::unique_ptr<StarIdAlgorithm>(new GeometricVotingStarIdAlgorithm(DegToRad(values.angularTolerance))); | ||
} else if (values.idAlgo == "py") { | ||
result.starIdAlgorithm = std::unique_ptr<StarIdAlgorithm>(new PyramidStarIdAlgorithm(DegToRad(values.angularTolerance), values.estimatedNumFalseStars, values.maxMismatchProb, 1000)); | ||
} else if (values.idAlgo == "tracking") { | ||
|
||
if (values.prevAttitudeString == "") { | ||
std::cout << "WARNING: information about the previous attitude has not been passed in while tracking mode is set." << std::endl; | ||
} | ||
|
||
// convert user inputted string ra,dec,roll to individual floats | ||
std::vector<float> attInputs; | ||
std::stringstream ss (values.prevAttitudeString); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Taking attitude input as a single comma-separated string is a good idea, but we need to apply it consistently across the codebase. If we're going to do it here, we also need to replace the |
||
std::string item; | ||
while (std::getline (ss, item, ',')) { | ||
attInputs.push_back(stof(item)); | ||
} | ||
|
||
// convert ra, dec, and roll to attitude | ||
Quaternion q = SphericalToQuaternion(DegToRad(attInputs[0]), DegToRad(attInputs[1]), DegToRad(attInputs[2])); | ||
Attitude a(q); | ||
|
||
// set prev attitude and id algo | ||
PrevAttitude prev(a, values.uncertainty, values.trackingCompareThreshold); | ||
result.starIdAlgorithm = std::unique_ptr<StarIdAlgorithm>(new TrackingModeStarIdAlgorithm(prev)); | ||
|
||
} else if (values.idAlgo != "") { | ||
std::cout << "Illegal id algorithm." << std::endl; | ||
exit(1); | ||
|
@@ -762,7 +795,6 @@ PipelineOutput Pipeline::Go(const PipelineInput &input) { | |
std::vector<PipelineOutput> Pipeline::Go(const PipelineInputList &inputs) { | ||
std::vector<PipelineOutput> result; | ||
|
||
|
||
for (const std::unique_ptr<PipelineInput> &input : inputs) { | ||
result.push_back(Go(*input)); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
#include <math.h> | ||
#include <assert.h> | ||
#include <vector> | ||
#include <algorithm> | ||
#include <map> | ||
|
||
#include "star-id.hpp" | ||
#include "databases.hpp" | ||
|
@@ -489,7 +491,6 @@ StarIdentifiers PyramidStarIdAlgorithm::Go( | |
|
||
PyramidIdentifyRemainingStars(&identified, stars, catalog, vectorDatabase, camera, tolerance); | ||
printf("Identified an additional %d stars\n", (int)identified.size() - 4); | ||
|
||
return identified; | ||
} | ||
|
||
|
@@ -503,4 +504,37 @@ StarIdentifiers PyramidStarIdAlgorithm::Go( | |
return identified; | ||
} | ||
|
||
// for ordering Quaternions in tracking mode votes map | ||
bool operator<(const Quaternion& l, const Quaternion& r) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not an appropriate general-purpose comparison for quaternions, just write it as a separate function and pass as a custom comparator to std::sort Also, |
||
if (l.real < r.real) return true; | ||
if (l.i < r.i) return true; | ||
if (l.j < r.j) return true; | ||
return (l.k < r.k); | ||
} | ||
|
||
StarIdentifiers TrackingModeStarIdAlgorithm::Go( | ||
const unsigned char *database, const Stars &stars, const Catalog &catalog, const Camera &camera) const { | ||
|
||
StarIdentifiers definite; | ||
MultiDatabase multiDatabase(database); | ||
const unsigned char *databaseBuffer = multiDatabase.SubDatabasePointer(TrackingSortedDatabase::kMagicValue); | ||
if (databaseBuffer == NULL) { | ||
return definite; | ||
} | ||
TrackingSortedDatabase vectorDatabase(databaseBuffer); | ||
|
||
// find all stars that only have 1 possible previous star, so we've definitely id'd them | ||
for (int i = 0; i < (int)stars.size(); i++) { | ||
Vec3 prevPos = camera.CameraToSpatial(stars[i].position).Normalize(); | ||
prevPos = prevAttitude.prev.GetQuaternion().Conjugate().Rotate(prevPos); | ||
|
||
std::vector<int16_t> possiblePrevStars = vectorDatabase.QueryNearestStars(catalog, prevPos, prevAttitude.uncertainty+prevAttitude.compareThreshold); | ||
if (possiblePrevStars.size() == 1) { | ||
definite.push_back(StarIdentifier(i,possiblePrevStars[0])); | ||
} | ||
} | ||
|
||
return definite; | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the units? Degrees, pixels?
Also, the name is too short, the cli option name should make it clear that it's talking about uncertainty in the previous attitude.