Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 1d2c89b
Author: Tri Nguyen <[email protected]>
Date:   Sat Oct 5 17:19:22 2024 -0700

    Example Test bugs

commit adece2b
Author: Tri Nguyen <[email protected]>
Date:   Sat Oct 5 17:11:03 2024 -0700

    Stage extension for all stages
  • Loading branch information
heeu0 committed Oct 6, 2024
1 parent f2be7c1 commit b410ee9
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 75 deletions.
19 changes: 4 additions & 15 deletions src/distance/distance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,20 @@
#define DISTANCE_H

#include "style/style.hpp"
#include "pipeline/pipeline.hpp"

namespace found {

/**
* The DistanceDeterminationAlgorithm class houses the Distance Determination Algorithm. This
* algorithm calculates the distance from Earth based on the pixels of Earth's Edge found in the image.
*/
class DistanceDeterminationAlgorithm {
class DistanceDeterminationAlgorithm : public Stage<Points, distFromEarth> {
public:
// Constructs this
DistanceDeterminationAlgorithm() = default;
// Destroys this
virtual ~DistanceDeterminationAlgorithm();

/**
* Computes the distance of the satellite from Earth based on an image of Earth
*
* @param image The image of Earth, represented as a character array with values from 0-255
* that represents the black/white color of each pixel
* @param p The Points that we find on Earth's horizon with respect to the image coordinate
* system
*
* @return The distance of the satellite from Earth
*/
virtual distFromEarth Run(char* image, Points &p /*More go here*/) = 0;
};

/**
Expand All @@ -48,7 +37,7 @@ class SphericalDistanceDeterminationAlgorithm : public DistanceDeterminationAlgo
/**
* Place documentation here. Press enter to automatically make a new line
* */
distFromEarth Run(char* image, Points &p/*More go here*/) override;
distFromEarth Run(const Points &p) override;
private:
// Fields specific to this algorithm, and helper methods
};
Expand All @@ -72,7 +61,7 @@ class EllipticDistanceDeterminationAlgorithm : public DistanceDeterminationAlgor
/**
* Place documentation here. Press enter to automatically make a new line
* */
distFromEarth Run(char* image, Points &p/*More go here*/) override;
distFromEarth Run(const Points &p) override;
private:
// Fields specific to this algorithm, and helper methods
};
Expand Down
18 changes: 4 additions & 14 deletions src/distance/edge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,15 @@
#define EDGE_H

#include "style/style.hpp"
#include "pipeline/pipeline.hpp"

namespace found {

/**
* The EdgeDetection Algorithm class houses the Edge Detection Algorithm. This algorithm uses
* a picture of Earth and finds all points on the horizon within the picture.
*/
class EdgeDetectionAlgorithm {
public:
/**
* Finds all points on Earth's horizon as seen in an image
*
* @param image The image of Earth, represented as a character array with values from 0-255
* that represents the black/white color of each pixel
*
* @return A Points object that holds all points found in the image
*/
virtual Points Run(unsigned char* image/*parameters all algorithms will need (Override this plz)*/) = 0;
};
class EdgeDetectionAlgorithm : public Stage<Image, Points> {};

/**
* The SimpleEdgeDetection Algorithm class houses the Edge Detection Algorithm. This algorithm uses
Expand All @@ -42,7 +32,7 @@ class SimpleEdgeDetectionAlgorithm : public EdgeDetectionAlgorithm {
/**
* Place documentation here. Press enter to automatically make a new line
* */
Points Run(unsigned char* image/*parameters all algorithms will need (Override this plz)*/) override;
Points Run(const Image &image/*parameters all algorithms will need (Override this plz)*/) override;
private:
// useful fields specific to this algorithm and helper methods
};
Expand All @@ -67,7 +57,7 @@ class LoCEdgeDetectionAlgorithm : public EdgeDetectionAlgorithm {
/**
* Place documentation here. Press enter to automatically make a new line
* */
Points Run(unsigned char* image/*parameters all algorithms will need (Override this plz)*/) override;
Points Run(const Image &image/*parameters all algorithms will need (Override this plz)*/) override;
private:
// useful fields specific to this algorithm and helper methods
};
Expand Down
19 changes: 6 additions & 13 deletions src/distance/vectorize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "spatial/attitude-utils.hpp"
#include "style/style.hpp"
#include "pipeline/pipeline.hpp"

namespace found {

Expand All @@ -11,20 +12,12 @@ namespace found {
* finds the position from Earth with respect to its center with a 3D Vector (Vec3).
*
*/
class VectorGenerationAlgorithm {
class VectorGenerationAlgorithm : public Stage<distFromEarth, PositionVector> {
public:
// Constructs this
VectorGenerationAlgorithm() = default;
// Destroys this
virtual ~VectorGenerationAlgorithm();

/**
* Finds the vector of the satellite with respect to Earth's center
*
* @param x_E The distance from Earth
*
* @return A PositionVector that represents the 3D Vector of the satellite relative to
* Earth's center
*/
virtual PositionVector Run(distFromEarth x_E /*Params common to this type*/) = 0;
};

/**
Expand Down Expand Up @@ -54,7 +47,7 @@ class LOSTVectorGenerationAlgorithm : public VectorGenerationAlgorithm {
* @return A PositionVector that represents the 3D Vector of the satellite relative to
* Earth's center
*/
PositionVector Run(distFromEarth x_E /*Params to override the base class one*/) override;
PositionVector Run(const distFromEarth &x_E /*Params to override the base class one*/) override;

private:
// Fields specific to this algorithm go here, and helper methods
Expand Down Expand Up @@ -83,7 +76,7 @@ class FeatureDetectionVectorGenerationAlgorithm : public VectorGenerationAlgorit
/**
* Place documentation here. Press enter to automatically make a new line
* */
PositionVector Run(distFromEarth x_E /*Params to override the base class one*/) override;
PositionVector Run(const distFromEarth &x_E /*Params to override the base class one*/) override;
private:
// Fields specific to this algorithm go here, and helper methods
};
Expand Down
17 changes: 4 additions & 13 deletions src/model/kinematic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "style/style.hpp"
#include "spatial/attitude-utils.hpp"
#include "pipeline/pipeline.hpp"

namespace found {

Expand All @@ -13,20 +14,10 @@ namespace found {
* position of the satellite at any time
*
*/
class KinematicProfilingAlgorithm {
class KinematicProfilingAlgorithm : public Stage<OrbitParams, KinematicPrediction> {
public:
// Destroys this
virtual ~KinematicProfilingAlgorithm();

/**
* Derives the kinematic profile of the satellite
*
* @param orbit The projected path of the satellite
*
* @return A KinematicPrediction that describes the kinematic profile of the satellite
*
*/
virtual KinematicPrediction Run(OrbitParams &orbit /*Params common to this type*/) = 0;
};

/**
Expand All @@ -52,7 +43,7 @@ class EulerianKinematicProfilingAlgorithm : public KinematicProfilingAlgorithm {
/**
* Place documentation here. Press enter to automatically make a new line
* */
KinematicPrediction Run(OrbitParams &orbit /*Params to override the base class one*/) override;
KinematicPrediction Run(const OrbitParams &orbit /*Params to override the base class one*/) override;
private:
// Fields specific to this algorithm go here, and helper methods
};
Expand Down Expand Up @@ -80,7 +71,7 @@ class KeplerKinematicProfilingAlgorithm : public KinematicProfilingAlgorithm {
/**
* Place documentation here. Press enter to automatically make a new line
* */
KinematicPrediction Run(OrbitParams &orbit /*Params to override the base class one*/) override;
KinematicPrediction Run(const OrbitParams &orbit /*Params to override the base class one*/) override;
private:
// Fields specific to this algorithm go here, and helper methods
};
Expand Down
18 changes: 4 additions & 14 deletions src/model/orbit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "spatial/attitude-utils.hpp"
#include "style/style.hpp"
#include "pipeline/pipeline.hpp"

namespace found {

Expand All @@ -13,21 +14,10 @@ namespace found {
* algorithm finds the orbit path of the satellite from known position vectors relative to Earth
*
*/
class OrbitDeterminationAlgorithm {
class OrbitDeterminationAlgorithm : public Stage<std::vector<Vec3>, OrbitParams> {
public:
// Destroys this
virtual ~OrbitDeterminationAlgorithm();

/**
* Finds orbit parameters based off of given positional vectors
*
* @param positions A list describing known points along satellite path
*
* @return An OrbitParams, which describes the characteristics of the orbital path
*
* @note See style.hpp for more detailed documentation of OrbitParams
*/
virtual OrbitParams Run(std::vector<Vec3> &positions /*Params common to this type*/) = 0;
};

/**
Expand All @@ -51,7 +41,7 @@ class EllipticalOrbitDerminationAlgorithm : public OrbitDeterminationAlgorithm {
/**
* Place documentation here. Press enter to automatically make a new line
* */
OrbitParams Run(std::vector<Vec3> &positions /*Params to override the base class one*/) override;
OrbitParams Run(const std::vector<Vec3> &positions /*Params to override the base class one*/) override;
private:
// Fields specific to this algorithm go here, and helper methods
};
Expand All @@ -77,7 +67,7 @@ class PrecessionOrbitDeterminationAlgorithm : public OrbitDeterminationAlgorithm
/**
* Place documentation here. Press enter to automatically make a new line
* */
OrbitParams Run(std::vector<Vec3> &positions /*Params to override the base class one*/) override;
OrbitParams Run(const std::vector<Vec3> &positions /*Params to override the base class one*/) override;
private:
// Fields specific to this algorithm go here, and helper methods
};
Expand Down
4 changes: 2 additions & 2 deletions src/pipeline/pipeline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Stage : public Action {
*
* @return The output of this stage
*/
virtual Output Run(Input input) = 0;
virtual Output Run(const Input &input) = 0;

/**
* Executes Run (with a stored input and storing the output)
Expand Down Expand Up @@ -174,7 +174,7 @@ class Pipeline : public Stage<Input, Output> {
* i.e. before this::Run is called, this::Complete must have
* been called successfully
*/
Output Run(Input input) override {
Output Run(const Input &input) override {
if (!this->ready) throw std::runtime_error("This is an illegal action: the pipeline is not ready yet");
this->resource = input;
*this->firstResource = input;
Expand Down
10 changes: 10 additions & 0 deletions src/style/style.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ typedef decimal distFromEarth;
/// coordinate system.
typedef Vec3 PositionVector;

/**
* Represents an image
*/
struct Image {
/// The image contents
unsigned char *image;
/// The image {width, height, channels}
int dimensions[3];
};

/**
* OrbitParams defines the orbital
* parameters of a given orbit
Expand Down
3 changes: 2 additions & 1 deletion test/common/constants/example-constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
namespace found {

// Array that holds one
unsigned char arr[1] = {1};
unsigned char imageContents[1] = {1};
Image image = {imageContents, {1, 0, 1}};

/**
* Expected Results from our Mock
Expand Down
3 changes: 2 additions & 1 deletion test/common/mocks/example-mocks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <gmock/gmock.h>

#include "src/distance/edge.hpp"
#include "src/style/style.hpp"

namespace found {

Expand All @@ -32,7 +33,7 @@ class MockEdgeDetectionAlgorithm : public EdgeDetectionAlgorithm {
// erase any existing behavior of this method so that we can tell
// this method what to do when its called. More information can
// be found here: https://google.github.io/googletest/gmock_for_dummies.html
MOCK_METHOD(Points, Run, (unsigned char* image), (override));
MOCK_METHOD(Points, Run, (const Image &), (override));
};

} // namespace found
2 changes: 1 addition & 1 deletion test/common/mocks/pipeline-mocks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace found {
template <typename Input, typename Output>
class MockStage : public Stage<Input, Output> {
public:
MOCK_METHOD(Output, Run, (Input), (override));
MOCK_METHOD(Output, Run, (const Input &), (override));
};

} // namespace found
2 changes: 1 addition & 1 deletion test/example/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ TEST_F(ExampleTest, MySecondTest) {

// Here, we run the function we want to test,
// which will execute our Mocked behavior
Points p = eda->Run(arr);
Points p = eda->Run(image);

// Now, we test if the result of our
// function matched our expectation
Expand Down

0 comments on commit b410ee9

Please sign in to comment.