Skip to content

Commit 60a2953

Browse files
authored
Merge pull request #2 from UWCubeSat/noise-filter
Noise filter + reorganize placeholders
2 parents cb78014 + 6280b81 commit 60a2953

21 files changed

Lines changed: 461 additions & 206 deletions

.clang-format

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ TabWidth: 4
44
AccessModifierOffset: -3
55
UseTab: Never
66
SortIncludes: Never
7+
ColumnLimit: 120
8+
AllowShortFunctionsOnASingleLine: Empty
9+
PointerAlignment: Right
10+
BreakConstructorInitializers: AfterColon

src/scope/algorithms-placeholder/algorithms-placeholder.cpp

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/scope/algorithms-placeholder/algorithms-placeholder.hpp

Lines changed: 0 additions & 79 deletions
This file was deleted.
Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,42 @@
11
#include "scope/command-line/execution/executors.hpp"
2-
#include "scope/common/style.hpp"
3-
#include "common/logging.hpp"
4-
#include "common/time/time.hpp"
52

3+
#include <cstring>
4+
5+
#include <iostream>
66
#include <memory>
77
#include <utility>
8-
#include <cstring>
8+
#include <vector>
99

10-
namespace scope {
10+
#include "scope/common/style.hpp"
11+
#include "common/logging.hpp"
12+
#include "common/time/time.hpp"
1113

12-
using Image = found::Image;
14+
namespace scope {
1315

14-
PrimaryScopePipelineExecutor::PrimaryScopePipelineExecutor(RecalibrationOptions &&options,
15-
std::unique_ptr<NoiseFilterAlgorithm> noiseFilterAlgorithm,
16-
std::unique_ptr<StarCentroidAlgorithm> starCentroidAlgorithm,
17-
std::unique_ptr<OptimizationAlgorithm> optimizationAlgorithm)
18-
: options_(std::move(options)) {
16+
PrimaryScopePipelineExecutor::PrimaryScopePipelineExecutor(
17+
RecalibrationOptions &&options, std::unique_ptr<NoiseFilterAlgorithm> noiseFilterAlgorithm,
18+
std::unique_ptr<StarCentroidAlgorithm> starCentroidAlgorithm,
19+
std::unique_ptr<OptimizationAlgorithm> optimizationAlgorithm) :
20+
options_(std::move(options)) {
1921
// TODO: change inputs + outputs of stages to actual values we will use
2022
std::unique_ptr<found::FunctionStage<Images, Image>> noiseFilterStage(std::move(noiseFilterAlgorithm));
21-
std::unique_ptr<found::FunctionStage<Image, std::vector<float>>> starCentroidStage(std::move(starCentroidAlgorithm));
22-
std::unique_ptr<found::FunctionStage<std::vector<float>, std::vector<float>>> optimizationStage(std::move(optimizationAlgorithm));
23+
std::unique_ptr<found::FunctionStage<Image, std::vector<float>>> starCentroidStage(
24+
std::move(starCentroidAlgorithm));
25+
std::unique_ptr<found::FunctionStage<std::vector<float>, std::vector<float>>> optimizationStage(
26+
std::move(optimizationAlgorithm));
2327
this->pipeline_.AddStage(std::move(noiseFilterStage))
24-
.AddStage(std::move(starCentroidStage))
25-
.Complete(std::move(optimizationStage));
28+
.AddStage(std::move(starCentroidStage))
29+
.Complete(std::move(optimizationStage));
2630
}
2731

2832
void PrimaryScopePipelineExecutor::ExecutePipeline() {
29-
// Results are stored within the pipeline, can also be accessed
30-
// via this function call
3133
this->pipeline_.Run(this->options_.images);
3234
}
3335

34-
// Will output the values found by this recalibration
3536
void PrimaryScopePipelineExecutor::OutputResults() {
36-
//std::vector<float> *&output = this->pipeline_.GetProduct();
37+
// std::vector<float> *&output = this->pipeline_.GetProduct();
3738
// TODO: something with output
3839
std::cout << "Nothing is implemented :(" << std::endl;
3940
}
4041

41-
} // namespace scope
42+
} // namespace scope
Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,54 @@
1+
/**
2+
* @file executors.hpp
3+
* @brief Pipeline executor for the primary SCOPE calibration chain.
4+
*/
5+
16
#ifndef SRC_SCOPE_COMMAND_LINE_EXECUTION_EXECUTORS_HPP_
27
#define SRC_SCOPE_COMMAND_LINE_EXECUTION_EXECUTORS_HPP_
38

49
#include <memory>
510

611
#include "scope/command-line/parsing/options.hpp"
712
#include "scope/common/style.hpp"
8-
#include "scope/algorithms-placeholder/algorithms-placeholder.hpp"
13+
#include "scope/noise-filter/noise-filter.hpp"
14+
#include "scope/optimization/optimization.hpp"
15+
#include "scope/star-centroid/star-centroid.hpp"
916

1017
#include "command-line/execution/executors.hpp"
1118

1219
namespace scope {
1320

21+
/**
22+
* Owns and runs the primary SCOPE calibration pipeline
23+
* (noise filter -> star centroid -> optimization).
24+
*/
1425
class PrimaryScopePipelineExecutor : public found::PipelineExecutor {
15-
public:
16-
explicit PrimaryScopePipelineExecutor(
17-
RecalibrationOptions &&options,
18-
std::unique_ptr<NoiseFilterAlgorithm> noiseFilterAlgorithm,
19-
std::unique_ptr<StarCentroidAlgorithm> starCentroidAlgorithm,
20-
std::unique_ptr<OptimizationAlgorithm> optimizationAlgorithm);
21-
26+
public:
27+
/**
28+
* Constructs a PrimaryScopePipelineExecutor and assembles its pipeline.
29+
*
30+
* @param options Parsed recalibration options consumed by the run.
31+
* @param noiseFilterAlgorithm Stage that reduces raw frames to one image.
32+
* @param starCentroidAlgorithm Stage that extracts star centroids.
33+
* @param optimizationAlgorithm Stage that fits camera parameters.
34+
*/
35+
explicit PrimaryScopePipelineExecutor(RecalibrationOptions &&options,
36+
std::unique_ptr<NoiseFilterAlgorithm> noiseFilterAlgorithm,
37+
std::unique_ptr<StarCentroidAlgorithm> starCentroidAlgorithm,
38+
std::unique_ptr<OptimizationAlgorithm> optimizationAlgorithm);
39+
40+
/// Runs the assembled pipeline end-to-end.
2241
void ExecutePipeline() override;
42+
/// Prints the calibrated parameters produced by the pipeline.
2343
void OutputResults() override;
2444

25-
private:
26-
// The options being used by the pipeline
45+
private:
46+
/// The options driving this pipeline run.
2747
const RecalibrationOptions options_;
28-
// The primary pipeline for SCOPE operation
48+
/// The pipeline assembled for SCOPE operation.
2949
PrimaryScopePipeline pipeline_;
3050
};
3151

32-
} // namespace scope
52+
} // namespace scope
3353

34-
#endif // SRC_SCOPE_COMMAND_LINE_EXECUTION_EXECUTORS_HPP_
54+
#endif // SRC_SCOPE_COMMAND_LINE_EXECUTION_EXECUTORS_HPP_

src/scope/command-line/parsing/options.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ SCOPE_CLI_OPTION("input-images", scope::Images, images, {}, scope::strtoimages(o
3434

3535
// NOLINTEND
3636

37-
/**
38-
* Options object, contains all data requested from user to run all algorithms
39-
*/
37+
/** Parsed CLI options driving a recalibration run. */
4038
class RecalibrationOptions {
4139
public:
4240
#define SCOPE_CLI_OPTION(name, type, prop, defaultVal, converter, defaultArg, \

src/scope/command-line/parsing/parser.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ int optind = 2;
2424

2525
namespace scope {
2626

27-
/// For macro processing
27+
/// Sentinel for options with no default value.
2828
const char kNoDefaultArgument = 0;
2929

3030
RecalibrationOptions ParseRecalibrationOptions(int argc, char **argv) {
31-
// Define an enum for each valid flag (command-line entry), which maps it
32-
// from the name to an integer
31+
// Each block below re-expands RECALIBRATE to derive a piece of getopt
32+
// wiring from the option table in options.hpp.
3333
enum class ClientOption {
3434
#define SCOPE_CLI_OPTION(name, type, prop, defaultVal, converter, defaultArg, \
3535
ASSIGN, doc) \
@@ -38,8 +38,6 @@ RecalibrationOptions ParseRecalibrationOptions(int argc, char **argv) {
3838
#undef SCOPE_CLI_OPTION
3939
};
4040

41-
// Define an array of options, which defines the traits pertaining to each
42-
// expected command-line entry
4341
static option long_options[] = {
4442
#define SCOPE_CLI_OPTION(name, type, prop, defaultVal, converter, defaultArg, \
4543
ASSIGN, doc) \
@@ -50,15 +48,10 @@ RecalibrationOptions ParseRecalibrationOptions(int argc, char **argv) {
5048
#undef SCOPE_CLI_OPTION
5149
{0}};
5250

53-
// Define our result, and iterator helpers
5451
RecalibrationOptions options;
5552
int index;
5653
int option;
5754

58-
// Iterates through the list of command-line tokens and figures out
59-
// what data to assign to which field in options. Note that the
60-
// SCOPE_CLI_OPTION defines the conversion already between any
61-
// particular parameter (as a string) to its actual type
6255
while ((option = getopt_long(argc, argv, "", long_options, &index)) != -1) {
6356
switch (option) {
6457
#define SCOPE_CLI_OPTION(name, type, prop, defaultVal, converter, defaultArg, \
@@ -78,4 +71,4 @@ RecalibrationOptions ParseRecalibrationOptions(int argc, char **argv) {
7871
return options;
7972
}
8073

81-
} // namespace scope
74+
} // namespace scope

src/scope/command-line/parsing/parser.hpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ namespace scope {
88
#define HELP_MSG "Use ./scope --help or ./scope -h for help"
99

1010
/**
11-
* Parses the recalibration options from the command line to
12-
* run the recalibration algorithm
13-
*
14-
* @param argc The number of command-line arguments
15-
* @param argv The command line arguments
16-
*
17-
* @return CalibrationOptions The options for the calibration
18-
* algorithm as extracted on the command line
11+
* Parses recalibration flags from the command line.
12+
*
13+
* @param argc The number of command-line arguments.
14+
* @param argv The command-line arguments.
15+
*
16+
* @return The recalibration options extracted from the command line.
1917
*/
2018
RecalibrationOptions ParseRecalibrationOptions(int argc, char **argv);
2119

src/scope/command-line/scope-main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <cstdlib>
22

33
#include <iostream>
4+
#include <memory>
45
#include <string>
56

67
#include "scope/command-line/scope-main.hpp"

src/scope/command-line/scope-main.hpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@
44
namespace scope {
55

66
/**
7-
* This is where the program starts.
7+
* Program entry point. Parses command-line options and runs the
8+
* recalibration pipeline.
89
*
9-
* @param argc The number of arguments passed into the command line
10-
* @param argv The arguments passed into the command line
10+
* @param argc The number of command-line arguments.
11+
* @param argv The command-line arguments.
1112
*
12-
* @return An integer indicating success (0) iff the program executes
13-
* successfully
14-
*
15-
* @note The method itself uses command line arguments to generate
16-
* an Options object that represents all the algorithms we want to run
17-
* and their parameters
13+
* @return 0 on success, non-zero on failure.
1814
*/
1915
int main(int argc, char** argv);
2016

0 commit comments

Comments
 (0)