diff options
| author | Dawsyn Schraiber <[email protected]> | 2024-06-13 14:30:58 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-06-13 14:30:58 -0400 |
| commit | 58b4bc754bbb9f5197119cd0c124e49c05acff46 (patch) | |
| tree | 8a65e23756374626e2c9cb997af9d8ed6f892390 /test | |
| parent | 8fbd08fe29bbc2246a78b481b219c241f62ff420 (diff) | |
| download | active-drag-system-58b4bc754bbb9f5197119cd0c124e49c05acff46.tar.gz active-drag-system-58b4bc754bbb9f5197119cd0c124e49c05acff46.tar.bz2 active-drag-system-58b4bc754bbb9f5197119cd0c124e49c05acff46.zip | |
Where to begin…. (#13)
+/- Reworked collection of altimeter related functions into altimeter class
+/- Reworked bno055 class to be imu class with minimal functionality
\- Removed external Kalman filter implementations in favor of own in house version
\- Removed any/unused files
\+ Added buffer logger for when sitting on pad for extended period of time in effort to prevent filling of flash chip
\+ Added heartbeat LED for alive status
Diffstat (limited to 'test')
| -rw-r--r-- | test/CMakeLists.txt | 70 | ||||
| -rw-r--r-- | test/actuationPlanTest.cpp | 54 | ||||
| -rw-r--r-- | test/kalmanFilterTest.cpp | 101 | ||||
| -rw-r--r-- | test/loggerTest.cpp | 57 | ||||
| -rw-r--r-- | test/motorTest.cpp | 50 | ||||
| -rw-r--r-- | test/sensorAltimeterTest.cpp | 50 | ||||
| -rw-r--r-- | test/sensorIMUTest.cpp | 50 | ||||
| -rw-r--r-- | test/sensor_test.cpp | 10 | ||||
| -rw-r--r-- | test/surfaceFitModelTest.cpp | 43 |
9 files changed, 0 insertions, 485 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index 13d4dc6..0000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,70 +0,0 @@ -cmake_minimum_required(VERSION 3.16.3) - -project(ADSTests) - -# Set Variables -set(TARGET_A TESTkalmanFilter) -set(SOURCES_A kalmanFilterTest.cpp ../src/kalmanfilter.cpp) - -set(TARGET_B TESTsurfaceFitModel) -set(SOURCES_B surfaceFitModelTest.cpp ../src/surfaceFitModel.cpp) - -set(TARGET_C TESTactuationPlan) -set(SOURCES_C actuationPlanTest.cpp ../src/actuationPlan.cpp ../src/surfaceFitModel.cpp ../src/rocketUtils.cpp ../src/sensorIMU.cpp ../src/sensorAltimeter.cpp) - -# set(TARGET_D TESTads) -# set(SOURCES_D adsTest.cpp ../src/ads.cpp ../src/actuationPlan.cpp ../src/surfaceFitModel.cpp ../src/rocketUtils.cpp ../src/sensorIMU.cpp ../src/sensorAltimeter.cpp ../src/motor.cpp ../src/logger.cpp ../src/kalmanfilter.cpp) - -set(TARGET_E TESTmotorPlan) -set(SOURCES_E motorTest.cpp ../src/motor.cpp ../src/rocketUtils.cpp) - -set(TARGET_F TESTsensorAltimeterPlan) -set(SOURCES_F sensorAltimeterTest.cpp ../src/sensorAltimeter.cpp ../src/rocketUtils.cpp) - -set(TARGET_G TESTsensorIMUPlan) -set(SOURCES_G sensorIMUTest.cpp ../src/sensorIMU.cpp ../src/rocketUtils.cpp) - - -#Set-up Google Test -set(CMAKE_CXX_STANDARD 14) -include(FetchContent) -FetchContent_Declare( - googletest - URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip -) -# For Windows: Prevent overriding the parent project's compiler/linker settings -set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) -FetchContent_MakeAvailable(googletest) - - - - -# Create Executables & Link Dependencies -add_executable(${TARGET_A} ${SOURCES_A}) -target_link_libraries(${TARGET_A} PUBLIC gtest_main) # Link GoogleTest's main() to Executable -# Tell CMake the Target is a Unit Test -add_test(NAME ${TARGET_A} COMMAND ${TARGET_A}) - -add_executable(${TARGET_B} ${SOURCES_B}) -target_link_libraries(${TARGET_B} PUBLIC gtest_main) -add_test(NAME ${TARGET_B} COMMAND ${TARGET_B}) - -add_executable(${TARGET_C} ${SOURCES_C}) -target_link_libraries(${TARGET_C} PUBLIC gtest_main) -add_test(NAME ${TARGET_C} COMMAND ${TARGET_C}) - -# add_executable(${TARGET_D} ${SOURCES_D}) -# target_link_libraries(${TARGET_D} PUBLIC gtest_main) -# add_test(NAME ${TARGET_D} COMMAND ${TARGET_D}) - -add_executable(${TARGET_E} ${SOURCES_E}) -target_link_libraries(${TARGET_E} PUBLIC gtest_main) -add_test(NAME ${TARGET_E} COMMAND ${TARGET_E}) - -add_executable(${TARGET_F} ${SOURCES_F}) -target_link_libraries(${TARGET_F} PUBLIC gtest_main) -add_test(NAME ${TARGET_F} COMMAND ${TARGET_F}) - -add_executable(${TARGET_G} ${SOURCES_G}) -target_link_libraries(${TARGET_G} PUBLIC gtest_main) -add_test(NAME ${TARGET_G} COMMAND ${TARGET_G})
\ No newline at end of file diff --git a/test/actuationPlanTest.cpp b/test/actuationPlanTest.cpp deleted file mode 100644 index 72410b0..0000000 --- a/test/actuationPlanTest.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include <iostream> -#include <gtest/gtest.h> -#include "../include/surfaceFitModel.hpp" -#include "../include/actuationPlan.hpp" -#include "../include/rocketUtils.hpp" - - -class ActuationPlanTest : public ::testing::Test { - - protected: - - ActuationPlanTest() { - - SurfaceFitModel sfm = SurfaceFitModel(); - plan = new ActuationPlan(sfm); - } - - //~ActuationPlanTest() {} - - ActuationPlan *plan; -}; - - -/** - * @brief Tests running the Actuation Plan - * - * **/ -TEST_F(ActuationPlanTest, runPlan) { - - Vehicle rocket; - - rocket.imuInitFail = false; - rocket.imuReadFail = false; - rocket.altiInitFail = false; - rocket.altiReadFail = false; - - // Test when Vehicle Status: Glide - rocket.fail_time = (time_t)(-1); - rocket.deploy_time = time(nullptr); - rocket.status = GLIDE; - rocket.filtered_altitude = 1; - rocket.filtered_velocity = 2; - plan->runPlan(rocket); - EXPECT_NEAR(rocket.deployment_angle, 120.0, 0.01); - EXPECT_NE(rocket.fail_time, (time_t)(-1)); - - // Test when Vehicle Status: Apogee - rocket.deploy_time = time(nullptr); - rocket.status = APOGEE; - rocket.filtered_altitude = 1; - rocket.filtered_velocity = 2; - plan->runPlan(rocket); - EXPECT_NEAR(rocket.deployment_angle, 110.0, 0.01); -}
\ No newline at end of file diff --git a/test/kalmanFilterTest.cpp b/test/kalmanFilterTest.cpp deleted file mode 100644 index bb0acda..0000000 --- a/test/kalmanFilterTest.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include <iostream> -#include <gtest/gtest.h> -#include <Eigen/Dense> -#include "../include/kalmanfilter.hpp" - -using namespace Eigen; - -class KalmanFilterTest : public ::testing::Test { - - protected: - - KalmanFilterTest() { - - kf = new KalmanFilter(2, 1, 1, 1); - } - - //~KalmanFilterTest() {} - - KalmanFilter *kf; -}; - - -/** - * @brief Test Setting the initial state x & P - * - * **/ -TEST_F(KalmanFilterTest, setInitialState) { - - VectorXf state_vec(2); - MatrixXf state_cov(2, 2); - state_vec << 1, 2; - state_cov << 1, 3, 4, 9; - - // Success Case - EXPECT_TRUE(kf->setInitialState(state_vec, state_cov)); - - // Failure Case - VectorXf state_vec2(4); - state_vec2 << 1, 2, 3, 4; - EXPECT_FALSE(kf->setInitialState(state_vec2, state_cov)); -} - -/** - * @brief Test a single iteration of the Kalman Filter - * - * **/ -TEST_F(KalmanFilterTest, run) { - - VectorXf control(1); - VectorXf measurement(1); - control << 1; - measurement << 1; - VectorXf res(1); - - res = kf->run(control, measurement, 1); - - EXPECT_NEAR(0.5454, res(0), 0.0001); - EXPECT_NEAR(1, res(1), 0.0001); -} - - -/** - * @brief Test run() when the time step value is changed between function calls. - * - */ -TEST_F(KalmanFilterTest, runChange) { - - VectorXf control(1); - VectorXf measurement(1); - control << 1; - measurement << 1; - VectorXf res(1); - - res = kf->run(control, measurement, 0.1); - EXPECT_NEAR(0.09545, res(0), 0.00001); - EXPECT_NEAR(0.1, res(1), 0.1); - - res = kf->run(control, measurement, 0.15); - EXPECT_NEAR(0.2761, res(0), 0.0001); - EXPECT_NEAR(0.3585, res(1), 0.0001); -} - - - - - - - - - - - - - - - - - - - - diff --git a/test/loggerTest.cpp b/test/loggerTest.cpp deleted file mode 100644 index fab2f25..0000000 --- a/test/loggerTest.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "../include/logger.hpp" - -class Two { - - public: - Two() { - - } - - void WritetoLog() { - Logger::Get().log("THIS IS A NEEEEEWWWW TEST!!!!!"); - Logger::Get().logErr("ERRORRRRRRRR"); - Logger::Get().printLog(); - } - - void TryPrint() { - Logger::Get().printLog(); - } -}; - -class One { - - public: - Two two; - One() { - two = Two(); - } - - void OpenLog() { - Logger::Get().openLog("output.txt"); - two.WritetoLog(); - Logger::Get().closeLog(); - two.TryPrint(); - } -}; - - - - -int main(int argc, char* argv[]) { - - // Logger::Get().openLog("output.txt"); - // Logger::Get().log("Testing Info aksdjflkas lksajfdlasjfaowe aslkdjf alskjf asodfj03945430 0349534 5039485 345"); - // Logger::Get().log("Testing Info Just some stuff"); - // Logger::Get().log("Testing something words words words"); - // Logger::Get().logErr("Testing Error lksdj fa 3459374"); - // Logger::Get().log("Testing blah blah blah blah blah lbal lab lbas labal abala"); - // Logger::Get().log("Testing Info aksdjflkas l11111111111111111111111111111111111111111485 345"); - // Logger::Get().logErr("Testing Error Some other type of error"); - // Logger::Get().logErr("Testing Error Another one"); - // Logger::Get().closeLog(); - // //log.printLog(); - - One one = One(); - one.OpenLog(); - -}
\ No newline at end of file diff --git a/test/motorTest.cpp b/test/motorTest.cpp deleted file mode 100644 index c570826..0000000 --- a/test/motorTest.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include <iostream> -#include <vector> -#include <gtest/gtest.h> -#include "../include/motor.hpp" -#include "../include/rocketUtils.hpp" - -class MotorTest : public ::testing::Test { - - protected: - - MotorTest() { - - m1 = new Motor(); - } - - //~IMUSensorTest() {} - - Motor *m1; -}; - - -/** - * @brief Test a - * - * **/ -TEST_F(MotorTest, init) { - - Vehicle rocket; - - m1->init((void*)&rocket); - - // ASSERT Statements..... -} - - -/** - * @brief Test a - * - * **/ -TEST_F(MotorTest, writeData) { - - Vehicle rocket; - - m1->writeData((void*)&rocket); - - // ASSERT Statements..... -} - - -// TODO: FIGURE OUT WHY MAKING 'rocket' a POINTER CAUSES A SEGFAULT diff --git a/test/sensorAltimeterTest.cpp b/test/sensorAltimeterTest.cpp deleted file mode 100644 index 7ba9521..0000000 --- a/test/sensorAltimeterTest.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include <iostream> -#include <vector> -#include <gtest/gtest.h> -#include "../include/sensorAltimeter.hpp" -#include "../include/rocketUtils.hpp" - -class AltimeterSensorTest : public ::testing::Test { - - protected: - - AltimeterSensorTest() { - - alti = new AltimeterSensor(); - } - - //~IMUSensorTest() {} - - AltimeterSensor *alti; -}; - - -/** - * @brief Test a - * - * **/ -TEST_F(AltimeterSensorTest, init) { - - Vehicle rocket; - - alti->init((void*)&rocket); - - // ASSERT Statements..... -} - - -/** - * @brief Test a - * - * **/ -TEST_F(AltimeterSensorTest, getData) { - - Vehicle rocket; - - alti->getData((void*)&rocket.current_altitude); - - // ASSERT Statements..... -} - - -// TODO: FIGURE OUT WHY MAKING 'rocket' a POINTER CAUSES A SEGFAULT diff --git a/test/sensorIMUTest.cpp b/test/sensorIMUTest.cpp deleted file mode 100644 index d16930e..0000000 --- a/test/sensorIMUTest.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include <iostream> -#include <vector> -#include <gtest/gtest.h> -#include "../include/sensorIMU.hpp" -#include "../include/rocketUtils.hpp" - -class IMUSensorTest : public ::testing::Test { - - protected: - - IMUSensorTest() { - - imu = new IMUSensor(); - } - - //~IMUSensorTest() {} - - IMUSensor *imu; -}; - - -/** - * @brief Test a - * - * **/ -TEST_F(IMUSensorTest, init) { - - Vehicle rocket; - - imu->init((void*)&rocket); - - // ASSERT Statements..... -} - - -/** - * @brief Test a - * - * **/ -TEST_F(IMUSensorTest, getData) { - - Vehicle rocket; - - imu->getData((void*)&rocket); - - // ASSERT Statements..... -} - - -// TODO: FIGURE OUT WHY MAKING 'rocket' a POINTER CAUSES A SEGFAULT diff --git a/test/sensor_test.cpp b/test/sensor_test.cpp deleted file mode 100644 index e4ab5ca..0000000 --- a/test/sensor_test.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include <iostream> -#include "sensorI2C.hpp" - -int main (int argc, char** argv) { - AltimeterSensor altimeter = new AltimeterSensor("/dev/i2c-2"); - altimeter.init(); - for (int i = 0; i < 1000; i++) { - std::cout << "Altitude: " << altimeter.getAltitude() << std::endl; - } -} diff --git a/test/surfaceFitModelTest.cpp b/test/surfaceFitModelTest.cpp deleted file mode 100644 index f0521b5..0000000 --- a/test/surfaceFitModelTest.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include <iostream> -#include <gtest/gtest.h> -#include "eigen3/Eigen/Dense" -#include "../include/surfaceFitModel.hpp" - -using namespace Eigen; - -class SurfaceFitModelTest : public ::testing::Test { - - protected: - - SurfaceFitModelTest() { - - surfFM = new SurfaceFitModel(); - } - - //~SurfaceFitModelTest() {} - - SurfaceFitModel *surfFM; -}; - - -/** - * @brief Test a - * - * **/ -TEST_F(SurfaceFitModelTest, getFit1) { - - double res = surfFM->getFit(1, 2); - - EXPECT_NEAR(res, -771671.3793209707, 0.01); -} - -/** - * @brief Test a - * - * **/ -TEST_F(SurfaceFitModelTest, getFit2) { - - double res = surfFM->getFit(33.3, 49); - - EXPECT_NEAR(res, -507325.4658735892, 0.01); -}
\ No newline at end of file |
