Skip to content

Commit

Permalink
Add questionable catalog indexing for LOST attitude step to work
Browse files Browse the repository at this point in the history
  • Loading branch information
zeddie888 committed Aug 17, 2022
1 parent b9f4528 commit a728d5c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/star-id.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ StarIdentifiers TetraStarIdAlgorithm::Go(const unsigned char *database,
// for(const Star &star : stars){
// std::cout << star.position.x << ", " << star.position.y << std::endl;
// }
// std::cout << catalog.size() << std::endl; // 5000 stars


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


// TODO: implement the generator function
// Right now I'm just do a simplified way, taking the first 4 centroids

copyStars = std::vector<Star>(copyStars.begin(), copyStars.begin() + numPattStars);

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

for(int i = 0; i < numPattStars; i++){
std::cout << "centroid: " << centroidIndices[i]
<< ", starID: " << catSortedStarIDs[i];
std::cout << std::endl;
result.push_back(
StarIdentifier(centroidIndices[i], catSortedStarIDs[i]));
// std::cout << "centroid: " << sortedCentroidIndices[i]
// << ", starID: " << catSortedStarIDs[i];
// std::cout << std::endl;

int centroidIndex = sortedCentroidIndices[i];
int resultStarID = catSortedStarIDs[i];

int catalogIndex = FindCatalogStarIndex(catalog, resultStarID);

// const CatalogStar *catStar = FindNamedStar(catalog, resultStarID);
std::cout << "catstar: " << catalogIndex << std::endl;

result.push_back(StarIdentifier(centroidIndex, catalogIndex));
// Ah, catalog is different than what Tetra expects
}

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

std::cout << "SUCCESS: stars successfully matched" << std::endl;
return result; // TODO: work on this more
return result;
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/star-utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ const CatalogStar *FindNamedStar(const Catalog &catalog, int name) {
return NULL;
}

// TODO: ok? Seems kinda stupid, anyways here's a function to get index of a CatalogStar in catalog given name
int FindCatalogStarIndex(const Catalog &catalog, int name){

This comment has been minimized.

Copy link
@markasoftware

markasoftware Aug 17, 2022

Member

It's a bit sketch but since FindNamedStar returns a pointer into an array, you could implement this as FindNamedStar(...) - catalog

for(int i = 0; i < (int)catalog.size(); i++){
if(catalog[i].name == name){
return i;
}
}
return -1; // no star found
}

/// @sa SerializeCatalogStar
long SerializeLengthCatalogStar(bool inclMagnitude, bool inclName) {
long starSize = SerializeLengthVec3();
Expand Down
2 changes: 2 additions & 0 deletions src/star-utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ void SerializeCatalog(const Catalog &, bool inclMagnitude, bool inclName, unsign
Catalog DeserializeCatalog(const unsigned char *buffer, bool *inclMagnitudeReturn, bool *inclNameReturn);
const CatalogStar *FindNamedStar(const Catalog &, int name);

int FindCatalogStarIndex(const Catalog &, int name);

// TODO: make maxStars work right, need to sort by magnitude before filter! maxMagnitude is 10^-2
// (so 523 = 5.23)
Catalog NarrowCatalog(const Catalog &, int maxMagnitude, int maxStars);
Expand Down

0 comments on commit a728d5c

Please sign in to comment.