Skip to content

Commit a728d5c

Browse files
committed
Add questionable catalog indexing for LOST attitude step to work
1 parent b9f4528 commit a728d5c

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

src/star-id.cpp

+19-6
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ StarIdentifiers TetraStarIdAlgorithm::Go(const unsigned char *database,
5252
// for(const Star &star : stars){
5353
// std::cout << star.position.x << ", " << star.position.y << std::endl;
5454
// }
55+
// std::cout << catalog.size() << std::endl; // 5000 stars
56+
5557

5658
TetraDatabase db;
5759
db.fillStarTable();
@@ -70,8 +72,10 @@ StarIdentifiers TetraStarIdAlgorithm::Go(const unsigned char *database,
7072
copyStars.begin(), copyStars.end(),
7173
[](const Star &a, const Star &b) { return a.magnitude > b.magnitude; });
7274

75+
7376
// TODO: implement the generator function
7477
// Right now I'm just do a simplified way, taking the first 4 centroids
78+
7579
copyStars = std::vector<Star>(copyStars.begin(), copyStars.begin() + numPattStars);
7680

7781
std::vector<int> centroidIndices;
@@ -263,17 +267,26 @@ StarIdentifiers TetraStarIdAlgorithm::Go(const unsigned char *database,
263267
ArgsortVector<Vec3>(catStarVecs, catRadii);
264268

265269
for(int i = 0; i < numPattStars; i++){
266-
std::cout << "centroid: " << centroidIndices[i]
267-
<< ", starID: " << catSortedStarIDs[i];
268-
std::cout << std::endl;
269-
result.push_back(
270-
StarIdentifier(centroidIndices[i], catSortedStarIDs[i]));
270+
// std::cout << "centroid: " << sortedCentroidIndices[i]
271+
// << ", starID: " << catSortedStarIDs[i];
272+
// std::cout << std::endl;
273+
274+
int centroidIndex = sortedCentroidIndices[i];
275+
int resultStarID = catSortedStarIDs[i];
276+
277+
int catalogIndex = FindCatalogStarIndex(catalog, resultStarID);
278+
279+
// const CatalogStar *catStar = FindNamedStar(catalog, resultStarID);
280+
std::cout << "catstar: " << catalogIndex << std::endl;
281+
282+
result.push_back(StarIdentifier(centroidIndex, catalogIndex));
283+
// Ah, catalog is different than what Tetra expects
271284
}
272285

273286
// TODO: StarIdentifier wants the catalog INDEX, not the real star ID
274287

275288
std::cout << "SUCCESS: stars successfully matched" << std::endl;
276-
return result; // TODO: work on this more
289+
return result;
277290
}
278291
}
279292

src/star-utils.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ const CatalogStar *FindNamedStar(const Catalog &catalog, int name) {
4343
return NULL;
4444
}
4545

46+
// TODO: ok? Seems kinda stupid, anyways here's a function to get index of a CatalogStar in catalog given name
47+
int FindCatalogStarIndex(const Catalog &catalog, int name){
48+
for(int i = 0; i < (int)catalog.size(); i++){
49+
if(catalog[i].name == name){
50+
return i;
51+
}
52+
}
53+
return -1; // no star found
54+
}
55+
4656
/// @sa SerializeCatalogStar
4757
long SerializeLengthCatalogStar(bool inclMagnitude, bool inclName) {
4858
long starSize = SerializeLengthVec3();

src/star-utils.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ void SerializeCatalog(const Catalog &, bool inclMagnitude, bool inclName, unsign
100100
Catalog DeserializeCatalog(const unsigned char *buffer, bool *inclMagnitudeReturn, bool *inclNameReturn);
101101
const CatalogStar *FindNamedStar(const Catalog &, int name);
102102

103+
int FindCatalogStarIndex(const Catalog &, int name);
104+
103105
// TODO: make maxStars work right, need to sort by magnitude before filter! maxMagnitude is 10^-2
104106
// (so 523 = 5.23)
105107
Catalog NarrowCatalog(const Catalog &, int maxMagnitude, int maxStars);

0 commit comments

Comments
 (0)