| Line |
Branch |
Exec |
Source |
| 1 |
|
|
#include "command-line/execution/executors.hpp" |
| 2 |
|
|
|
| 3 |
|
|
#include <memory> |
| 4 |
|
|
#include <utility> |
| 5 |
|
|
#include <cstring> |
| 6 |
|
|
|
| 7 |
|
|
#include "common/logging.hpp" |
| 8 |
|
|
#include "common/time/time.hpp" |
| 9 |
|
|
|
| 10 |
|
|
namespace found { |
| 11 |
|
|
|
| 12 |
|
8 |
CalibrationPipelineExecutor::CalibrationPipelineExecutor(CalibrationOptions &&options, |
| 13 |
|
8 |
std::unique_ptr<CalibrationAlgorithm> calibrationAlgorithm) |
| 14 |
1/1
✓ Branch 4 taken 8 times.
|
8 |
: options_(std::move(options)) { |
| 15 |
1/1
✓ Branch 4 taken 8 times.
|
8 |
this->pipeline_.Complete(std::move(calibrationAlgorithm)); |
| 16 |
|
8 |
} |
| 17 |
|
|
|
| 18 |
|
8 |
void CalibrationPipelineExecutor::ExecutePipeline() { |
| 19 |
|
|
// Results are stored within the pipeline, can also be accessed |
| 20 |
|
|
// via this function call |
| 21 |
1/1
✓ Branch 3 taken 8 times.
|
16 |
this->pipeline_.Run({this->options_.lclOrientation, |
| 22 |
|
8 |
this->options_.refOrientation}); |
| 23 |
|
8 |
} |
| 24 |
|
|
|
| 25 |
|
8 |
void CalibrationPipelineExecutor::OutputResults() { |
| 26 |
|
|
// Output the results of the calibration |
| 27 |
|
8 |
Quaternion *&calibrationQuaternion = this->pipeline_.GetProduct(); |
| 28 |
16/16
✓ Branch 3 taken 8 times.
✓ Branch 10 taken 8 times.
✓ Branch 13 taken 8 times.
✓ Branch 16 taken 8 times.
✓ Branch 20 taken 8 times.
✓ Branch 23 taken 8 times.
✓ Branch 26 taken 8 times.
✓ Branch 29 taken 8 times.
✓ Branch 32 taken 8 times.
✓ Branch 35 taken 8 times.
✓ Branch 38 taken 8 times.
✓ Branch 41 taken 8 times.
✓ Branch 44 taken 8 times.
✓ Branch 47 taken 8 times.
✓ Branch 50 taken 8 times.
✓ Branch 53 taken 8 times.
|
24 |
LOG_INFO("Calibration Quaternion: (" << calibrationQuaternion->real << ", " |
| 29 |
|
|
<< calibrationQuaternion->i << ", " |
| 30 |
|
|
<< calibrationQuaternion->j << ", " |
| 31 |
|
|
<< calibrationQuaternion->k << ")"); |
| 32 |
|
8 |
DataFile outputDF{}; |
| 33 |
|
8 |
outputDF.relative_attitude = *calibrationQuaternion; |
| 34 |
1/1
✓ Branch 2 taken 8 times.
|
8 |
std::ofstream outputFile(this->options_.outputFile); |
| 35 |
1/1
✓ Branch 1 taken 8 times.
|
8 |
serializeDataFile(outputDF, outputFile); |
| 36 |
|
16 |
} |
| 37 |
|
|
|
| 38 |
|
64 |
DistancePipelineExecutor::~DistancePipelineExecutor() { |
| 39 |
|
24 |
stbi_image_free(this->options_.image.image); |
| 40 |
|
40 |
} |
| 41 |
|
|
|
| 42 |
|
7 |
DistancePipelineExecutor::DistancePipelineExecutor(DistanceOptions &&options, |
| 43 |
|
|
std::unique_ptr<EdgeDetectionAlgorithm> edgeDetectionAlgorithm, |
| 44 |
|
|
std::unique_ptr<DistanceDeterminationAlgorithm> distanceAlgorithm, |
| 45 |
|
7 |
std::unique_ptr<VectorGenerationAlgorithm> vectorizationAlgorithm) |
| 46 |
|
7 |
: options_(std::move(options)) { |
| 47 |
1/1
✓ Branch 3 taken 7 times.
|
14 |
this->pipeline_.AddStage(std::move(edgeDetectionAlgorithm)) |
| 48 |
1/1
✓ Branch 3 taken 7 times.
|
14 |
.AddStage(std::move(distanceAlgorithm)) |
| 49 |
1/1
✓ Branch 6 taken 7 times.
|
21 |
.Complete(std::move(vectorizationAlgorithm)); |
| 50 |
|
7 |
} |
| 51 |
|
|
|
| 52 |
|
|
|
| 53 |
|
5 |
DistancePipelineExecutor::DistancePipelineExecutor(DistanceOptions &&options, |
| 54 |
|
|
std::unique_ptr<EdgeDetectionAlgorithm> edgeDetectionAlgorithm, |
| 55 |
|
|
std::unique_ptr<EdgeFilteringAlgorithms> filters, |
| 56 |
|
|
std::unique_ptr<DistanceDeterminationAlgorithm> distanceAlgorithm, |
| 57 |
|
5 |
std::unique_ptr<VectorGenerationAlgorithm> vectorizationAlgorithm) |
| 58 |
|
5 |
: options_(std::move(options)) { |
| 59 |
1/1
✓ Branch 3 taken 5 times.
|
10 |
this->pipeline_.AddStage(std::move(edgeDetectionAlgorithm)) |
| 60 |
1/1
✓ Branch 3 taken 5 times.
|
10 |
.AddStage(std::move(filters)) |
| 61 |
1/1
✓ Branch 3 taken 5 times.
|
10 |
.AddStage(std::move(distanceAlgorithm)) |
| 62 |
1/1
✓ Branch 7 taken 5 times.
|
20 |
.Complete(std::move(vectorizationAlgorithm)); |
| 63 |
|
5 |
} |
| 64 |
|
|
|
| 65 |
|
12 |
void DistancePipelineExecutor::ExecutePipeline() { |
| 66 |
|
|
// Results are stored within the pipeline, can also be accessed |
| 67 |
|
|
// via this function call |
| 68 |
1/1
✓ Branch 2 taken 12 times.
|
12 |
this->pipeline_.Run(this->options_.image); |
| 69 |
|
12 |
} |
| 70 |
|
|
|
| 71 |
|
12 |
void DistancePipelineExecutor::OutputResults() { |
| 72 |
|
12 |
PositionVector *&positionVector = this->pipeline_.GetProduct(); |
| 73 |
14/14
✓ Branch 3 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
✓ Branch 16 taken 12 times.
✓ Branch 20 taken 12 times.
✓ Branch 23 taken 12 times.
✓ Branch 26 taken 12 times.
✓ Branch 29 taken 12 times.
✓ Branch 32 taken 12 times.
✓ Branch 35 taken 12 times.
✓ Branch 38 taken 12 times.
✓ Branch 41 taken 12 times.
✓ Branch 44 taken 12 times.
✓ Branch 47 taken 12 times.
|
36 |
LOG_INFO("Calculated Position: (" << positionVector->x << ", " |
| 74 |
|
|
<< positionVector->y << ", " |
| 75 |
|
|
<< positionVector->z << ") m"); |
| 76 |
11/11
✓ Branch 3 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
✓ Branch 16 taken 12 times.
✓ Branch 20 taken 12 times.
✓ Branch 23 taken 12 times.
✓ Branch 26 taken 12 times.
✓ Branch 29 taken 12 times.
✓ Branch 32 taken 12 times.
✓ Branch 35 taken 12 times.
✓ Branch 38 taken 12 times.
|
36 |
LOG_INFO("Distance from Earth: " << positionVector->Magnitude() << " m"); |
| 77 |
|
|
// TODO: Figure out a much more optimized way of doing this please, especially |
| 78 |
|
|
// since we're saving it into the exact same file, there should be an easy way |
| 79 |
|
|
// to simply modify the file directly instead of this mess. |
| 80 |
|
12 |
DataFile outputDF{}; |
| 81 |
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
|
12 |
if (this->options_.calibrationData.header.version != emptyDFVer) { |
| 82 |
|
6 |
outputDF.header = this->options_.calibrationData.header; |
| 83 |
|
6 |
outputDF.relative_attitude = this->options_.calibrationData.relative_attitude; |
| 84 |
1/1
✓ Branch 2 taken 6 times.
|
6 |
outputDF.positions = std::make_unique<LocationRecord[]>(outputDF.header.num_positions + 1); |
| 85 |
|
6 |
std::memcpy(outputDF.positions.get(), |
| 86 |
|
6 |
this->options_.calibrationData.positions.get(), |
| 87 |
|
6 |
outputDF.header.num_positions); |
| 88 |
|
|
} else { |
| 89 |
1/1
✓ Branch 1 taken 6 times.
|
6 |
outputDF.relative_attitude = SphericalToQuaternion(this->options_.relOrientation); |
| 90 |
1/1
✓ Branch 2 taken 6 times.
|
6 |
outputDF.positions = std::make_unique<LocationRecord[]>(1); |
| 91 |
|
|
} |
| 92 |
1/1
✓ Branch 3 taken 12 times.
|
12 |
outputDF.positions[outputDF.header.num_positions++] = {static_cast<uint64_t>(getUT1Time().epochs), *positionVector}; |
| 93 |
3/3
✓ Branch 1 taken 12 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 3 times.
|
12 |
if (this->options_.outputFile != "") { |
| 94 |
1/1
✓ Branch 2 taken 9 times.
|
9 |
std::ofstream outputFile(this->options_.outputFile); |
| 95 |
1/1
✓ Branch 1 taken 9 times.
|
9 |
serializeDataFile(outputDF, outputFile); |
| 96 |
|
9 |
} else { |
| 97 |
1/1
✓ Branch 2 taken 3 times.
|
3 |
std::ofstream outputFile(this->options_.calibrationData.path); |
| 98 |
1/1
✓ Branch 1 taken 3 times.
|
3 |
serializeDataFile(outputDF, outputFile); |
| 99 |
|
3 |
} |
| 100 |
|
24 |
} |
| 101 |
|
|
|
| 102 |
|
4 |
OrbitPipelineExecutor::OrbitPipelineExecutor(OrbitOptions &&options, |
| 103 |
|
4 |
std::unique_ptr<OrbitPropagationAlgorithm> orbitPropagationAlgorithm) |
| 104 |
|
4 |
: options_(std::move(options)) { |
| 105 |
1/1
✓ Branch 4 taken 4 times.
|
4 |
this->pipeline_.Complete(std::move(orbitPropagationAlgorithm)); |
| 106 |
|
4 |
} |
| 107 |
|
|
|
| 108 |
|
4 |
void OrbitPipelineExecutor::ExecutePipeline() { |
| 109 |
|
|
// Results are stored within the pipeline, can also be accessed |
| 110 |
|
|
// via this function call |
| 111 |
1/1
✓ Branch 2 taken 4 times.
|
4 |
this->pipeline_.Run(this->options_.positionData); |
| 112 |
|
4 |
} |
| 113 |
|
|
|
| 114 |
|
4 |
void OrbitPipelineExecutor::OutputResults() { |
| 115 |
|
|
// TODO: Output this somewhere |
| 116 |
|
4 |
[[maybe_unused]] LocationRecord &futurePosition = this->pipeline_.GetProduct()->back(); |
| 117 |
17/17
✓ Branch 3 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
✓ Branch 16 taken 4 times.
✓ Branch 20 taken 4 times.
✓ Branch 23 taken 4 times.
✓ Branch 26 taken 4 times.
✓ Branch 29 taken 4 times.
✓ Branch 32 taken 4 times.
✓ Branch 35 taken 4 times.
✓ Branch 38 taken 4 times.
✓ Branch 41 taken 4 times.
✓ Branch 44 taken 4 times.
✓ Branch 47 taken 4 times.
✓ Branch 50 taken 4 times.
✓ Branch 53 taken 4 times.
✓ Branch 56 taken 4 times.
|
12 |
LOG_INFO("Calculated Future Position: (" << futurePosition.position.x << ", " |
| 118 |
|
|
<< futurePosition.position.y << ", " |
| 119 |
|
|
<< futurePosition.position.z << ") m" |
| 120 |
|
|
<< " at time " |
| 121 |
|
|
<< futurePosition.timestamp << " s"); |
| 122 |
|
4 |
} |
| 123 |
|
|
|
| 124 |
|
|
} // namespace found |
| 125 |
|
|
|