FOUND Coverage Report


src/
File: command-line/execution/executors.cpp
Date: 2026-03-24 21:41:51
Lines:
70/70
100.0%
Functions:
10/10
100.0%
Branches:
81/81
100.0%

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