diff --git a/.gitignore b/.gitignore index 151c17d1a310de0d56ed25b1ea8a3c124752631f..a626a4d8754f6849d29125f85b62ac76f0f6ca83 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ obj/* bin/* -build/* *.o *.a @@ -12,19 +11,27 @@ build/* .*.sw? .*.pyc -.project -.cproject +.project +.cproject .settings +compile_flags.txt +STM32F429zi_Discovery.xml + ._* .DS_Store build +cmake-build-* *.sublime-workspace *.sublime-project store.json -scripts/event_header_generator/generated/ -scripts/event_header_generator/venv/ +**/generated/ +core + +__pycache__ +/scripts/generators/generated +/scripts/generators/scxmls **/generated **/scxmls diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index dbed30c8726e788cd946af37c9aa16333cd58ccc..eccea156a6e4cf52a47b20238d1ed5d4e4c14944 100755 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -8,16 +8,16 @@ "defines": [ "DEBUG", "_ARCH_CORTEXM4_STM32F4", - "_BOARD_stm32f429zi_skyward_death_stack", - "_MIOSIX_BOARDNAME=stm32f429zi_skyward_death_stack", + "_BOARD_stm32f429zi_skyward_death_stack_x", + "_MIOSIX_BOARDNAME=stm32f429zi_skyward_death_stack_x", "HSE_VALUE=8000000", "SYSCLK_FREQ_168MHz=168000000", "_MIOSIX", "__cplusplus=201103L" ], "includePath": [ - "${workspaceFolder}/skyward-boardcore/libs/miosix-kernel/miosix/config/arch/cortexM4_stm32f4/stm32f429zi_skyward_death_stack", - "${workspaceFolder}/skyward-boardcore/libs/miosix-kernel/miosix/arch/cortexM4_stm32f4/stm32f429zi_skyward_death_stack", + "${workspaceFolder}/skyward-boardcore/libs/miosix-kernel/miosix/config/arch/cortexM4_stm32f4/stm32f429zi_skyward_death_stack_x", + "${workspaceFolder}/skyward-boardcore/libs/miosix-kernel/miosix/arch/cortexM4_stm32f4/stm32f429zi_skyward_death_stack_x", "${workspaceFolder}/skyward-boardcore/libs/miosix-kernel/miosix/arch/cortexM4_stm32f4/common", "${workspaceFolder}/skyward-boardcore/libs/miosix-kernel/miosix/arch/common", "${workspaceFolder}/skyward-boardcore/libs/miosix-kernel/miosix", @@ -27,9 +27,8 @@ "${workspaceFolder}/skyward-boardcore/libs", "${workspaceFolder}/skyward-boardcore/src/shared", "${workspaceFolder}/skyward-boardcore/src/tests", - "${workspaceFolder}/src/boards/DeathStack", "${workspaceFolder}/src/boards", - "${workspaceFolder}/src/common", + "${workspaceFolder}/src/tests", "${workspaceFolder}/src" ], "browse": { @@ -52,10 +51,8 @@ "${workspaceFolder}/skyward-boardcore/libs/fmt", "${workspaceFolder}/skyward-boardcore/src/shared", "${workspaceFolder}/skyward-boardcore/src/tests", - "${workspaceFolder}/src/boards/DeathStack", "${workspaceFolder}/src/boards", "${workspaceFolder}/src/tests", - "${workspaceFolder}/src/common", "${workspaceFolder}/src" ], "limitSymbolsToIncludedHeaders": true @@ -64,4 +61,4 @@ } ], "version": 4 -} \ No newline at end of file +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 9855cc51f52f63950acaf85427db223822deea29..ebb9bf0dc00c887d21952f6119b51ae52235b0e9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -92,5 +92,10 @@ "specialfunctions": "cpp", "splines": "cpp", "matrixfunctions": "cpp" - } + }, + "cSpell.words": [ + "Gpio", + "leds", + "miosix" + ] } diff --git a/CMakeLists Lynx.txt b/CMakeLists Lynx.txt new file mode 100644 index 0000000000000000000000000000000000000000..91ae326141eb20c54f12f86b4abf085d1477f4b6 --- /dev/null +++ b/CMakeLists Lynx.txt @@ -0,0 +1,414 @@ +# Copyright (c) 2021 Skyward Experimental Rocketry +# Author: Damiano Amatruda +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +cmake_minimum_required(VERSION 3.16) +include(skyward-boardcore/cmake/sbs.cmake) + +#-----------------------------------------------------------------------------# +# Project # +#-----------------------------------------------------------------------------# + +project(SkywardOnBoardSoftware) + +#-----------------------------------------------------------------------------# +# Entrypoints # +#-----------------------------------------------------------------------------# + +add_executable(death-stack-x-entry + src/entrypoints/death-stack-x-entry.cpp + ${DEATHSTACK_NEW_SOURCES} + ${MOCK_SENSORS_DATA_SOURCES} +) +target_include_directories(death-stack-x-entry PRIVATE ${OBSW_INCLUDE_DIRS}) +target_compile_definitions(death-stack-x-entry PRIVATE FLIGHT EUROC) +sbs_target(death-stack-x-entry stm32f429zi_skyward_death_stack_x) + +add_executable(death-stack-x-testsuite + src/entrypoints/death-stack-x-testsuite.cpp + ${DEATHSTACK_NEW_SOURCES} +) +target_include_directories(death-stack-x-testsuite PRIVATE ${OBSW_INCLUDE_DIRS}) +sbs_target(death-stack-x-testsuite stm32f429zi_skyward_death_stack_x) + +add_executable(payload-entry + src/entrypoints/payload-entry.cpp + ${PAYLOAD_SOURCES} +) +target_include_directories(payload-entry PRIVATE ${OBSW_INCLUDE_DIRS}) +sbs_target(payload-entry stm32f429zi_skyward_death_stack_x) + +#add_executable(death-stack-entry src/entrypoints/death-stack-entry.cpp ${DEATHSTACK_SOURCES}) +#target_include_directories(death-stack-entry PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(death-stack-entry PRIVATE DEATH_STACK_1) +#sbs_target(death-stack-entry stm32f429zi_skyward_death_stack_x) + +#add_executable(death-stack-testsuite src/entrypoints/death-stack-testsuite.cpp ${DEATHSTACK_SOURCES}) +#target_include_directories(death-stack-testsuite PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(death-stack-testsuite PRIVATE DEATH_STACK_1) +#sbs_target(death-stack-testsuite stm32f429zi_skyward_death_stack_x) + +#add_executable(windtunnel-entry src/entrypoints/windtunnel-entry.cpp ${DEATHSTACK_NEW_SOURCES}) +#target_include_directories(windtunnel-entry PRIVATE ${OBSW_INCLUDE_DIRS}) +#sbs_target(windtunnel-entry stm32f429zi_skyward_death_stack_x) + +#add_executable(hil-entry +# src/entrypoints/hardware_in_the_loop/hil-entry.cpp +# ${FMM_SOURCES} +# ${PINHANDLER_SOURCES} +# ${ADA_SOURCES} +# ${NAVIGATION_SYSTEM_SOURCES} +# ${LOGSERVICE_SOURCES} +# ${DEPLOYMENT_SOURCES} +#) +#target_include_directories(hil-entry PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(hil-entry PRIVATE HARDWARE_IN_THE_LOOP) +#sbs_target(hil-entry stm32f429zi_skyward_death_stack_x) + +#-----------------------------------------------------------------------------# +# Tests - Catch # +#-----------------------------------------------------------------------------# + +#add_executable(catch-tests-entry +# src/tests/catch/catch-tests-entry.cpp +# ${DEATHSTACK_SOURCES} +# ${HERMES_TESTS_SOURCES} +# ${ADA_TEST_SOURCES} +# ${MOCK_SENSORS_DATA_SOURCES} +#) +#target_include_directories(catch-tests-entry PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(catch-tests-entry PRIVATE DEATH_STACK_1) +#sbs_target(catch-tests-entry stm32f429zi_skyward_death_stack_x) + +add_executable(tests-catch + src/tests/catch/catch-tests-entry.cpp + ${DEATHSTACK_NEW_SOURCES} + ${TESTS_OBSW_SOURCES} + ${ADA_TEST_SOURCES} + ${MOCK_SENSORS_DATA_SOURCES} +) +target_include_directories(tests-catch PRIVATE ${OBSW_INCLUDE_DIRS}) +sbs_target(tests-catch stm32f429zi_skyward_death_stack_x) + +#-----------------------------------------------------------------------------# +# Tests - Drivers # +#-----------------------------------------------------------------------------# + +#add_executable(test-imus src/tests/drivers/test-imus.cpp) +#target_include_directories(test-imus PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(test-imus PRIVATE DEATH_STACK_1) +#sbs_target(test-imus stm32f429zi_skyward_death_stack_x) + +#add_executable(test-cutter src/tests/drivers/test-cutter.cpp) +#target_include_directories(test-cutter PRIVATE ${OBSW_INCLUDE_DIRS}) +#sbs_target(test-cutter stm32f429zi_skyward_death_stack_x) + +#add_executable(test-mavlink src/tests/drivers/test-mavlink.cpp ${TMTC_SOURCES} ${LOGSERVICE_SOURCES}) +#target_include_directories(test-mavlink PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(test-mavlink PRIVATE TRACE_EVENTS DEATH_STACK_1) +#sbs_target(test-mavlink stm32f429zi_skyward_death_stack_x) + +#add_executable(ledwave src/tests/ledwave.cpp) +#target_include_directories(ledwave PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(ledwave PRIVATE <compile>) +#sbs_target(ledwave stm32f429zi_skyward_death_stack_x) + +add_executable(ramtest src/tests/ram_test/ramtest.cpp ${RAM_TEST_SOURCES}) +target_include_directories(ramtest PRIVATE ${OBSW_INCLUDE_DIRS}) +target_compile_definitions(ramtest PRIVATE __ENABLE_XRAM) +sbs_target(ramtest stm32f429zi_skyward_death_stack_x) + +#add_executable(test-motor src/tests/drivers/test-motor.cpp ${DEPLOYMENT_SOURCES}) +#target_include_directories(test-motor PRIVATE ${OBSW_INCLUDE_DIRS}) +#sbs_target(test-motor stm32f429zi_skyward_death_stack_x) + +#add_executable(test-servo src/tests/drivers/test-servo.cpp ${LOGSERVICE_SOURCES} ${AIRBRAKES_SOURCES}) +#target_include_directories(test-servo PRIVATE ${OBSW_INCLUDE_DIRS}) +#sbs_target(test-servo stm32f429zi_skyward_death_stack_x) + +#add_executable(test-hse src/tests/test-hse.cpp) +#target_include_directories(test-hse PRIVATE ${OBSW_INCLUDE_DIRS}) +#sbs_target(test-hse stm32f429zi_skyward_death_stack_x) + +#add_executable(test-all-sensors src/tests/drivers/test-all-sensors.cpp) +#target_include_directories(test-all-sensors PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(test-all-sensors PRIVATE DEATH_STACK_1) +#sbs_target(test-all-sensors stm32f429zi_skyward_death_stack_x) + +#add_executable(test-preassure-calib src/tests/drivers/test-pressure-calib.cpp) +#target_include_directories(test-preassure-calib PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(test-preassure-calib PRIVATE DEATH_STACK_1) +#sbs_target(test-preassure-calib stm32f429zi_skyward_death_stack_x) + +#-----------------------------------------------------------------------------# +# Tests - Components # +#-----------------------------------------------------------------------------# + +#add_executable(test-canproxy src/tests/test-canproxy.cpp) +#target_include_directories(test-canproxy PRIVATE ${OBSW_INCLUDE_DIRS}) +#sbs_target(test-canproxy stm32f429zi_skyward_death_stack_x) + +add_executable(test-pinhandler src/tests/test-pinhandler.cpp ${PINHANDLER_SOURCES} ${LOGSERVICE_SOURCES}) +target_include_directories(test-pinhandler PRIVATE ${OBSW_INCLUDE_DIRS}) +sbs_target(test-pinhandler stm32f429zi_skyward_death_stack_x) + +#add_executable(test-logproxy src/tests/test-logproxy.cpp ${LOGSERVICE_SOURCES}) +#target_include_directories(test-logproxy PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(test-logproxy PRIVATE DEATH_STACK_1) +#sbs_target(test-logproxy stm32f429zi_skyward_death_stack_x) + +#add_executable(test-sensormanager src/tests/test-sensormanager.cpp ${LOGSERVICE_SOURCES} ${ADA_TEST_SOURCES}) +#target_include_directories(test-sensormanager PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(test-sensormanager PRIVATE USE_MOCK_SENSORS DEATH_STACK_1) +#sbs_target(test-sensormanager stm32f429zi_skyward_death_stack_x) + +# Cannot use this as it is since the DeathStack singleton is required for handling messages in the TCHandler class +#add_executable( +# test-sm+tmtc src/tests/test-sm+tmtc.cpp +# ${LOGSERVICE_SOURCES} +# ${ADA_SOURCES} +# ${TMTC_SOURCES} +# ${EVT_FUNCTIONS_SOURCES} +# ${ADA_TEST_SOURCES} +#) +#target_include_directories(test-sm+tmtc PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(test-sm+tmtc PRIVATE DEATH_STACK_1) +#sbs_target(test-sm+tmtc stm32f429zi_skyward_death_stack) + +#add_executable(test-fmm src/tests/catch/fsm/test-fmm.cpp ${DEATHSTACK_NEW_SOURCES}) +#target_include_directories(test-fmm PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(test-fmm PRIVATE STANDALONE_CATCH1_TEST) +#sbs_target(test-fmm stm32f429zi_skyward_death_stack_x) + +#add_executable(test-fmm-interactive src/tests/test-fmm-interactive.cpp ${DEATHSTACK_NEW_SOURCES}) +#target_include_directories(test-fmm-interactive PRIVATE ${OBSW_INCLUDE_DIRS}) +#sbs_target(test-fmm-interactive stm32f429zi_skyward_death_stack_x) + +#-----------------------------------------------------------------------------# +# Tests - FSM # +#-----------------------------------------------------------------------------# + +#add_executable(test-ada +# src/tests/catch/fsm/test-ada.cpp +# ${ADA_SOURCES} +# ${TEST_UTILS_SOURCES} +# ${ADA_TEST_SOURCES} +# ${MOCK_SENSORS_DATA_SOURCES} +# ${LOGSERVICE_SOURCES} +#) +#target_include_directories(test-ada PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(test-ada PRIVATE STANDALONE_CATCH1_TEST) +#sbs_target(test-ada stm32f429zi_skyward_death_stack_x) + +#add_executable(test-ada-simulation +# src/tests/catch/ada/ada_kalman_p/test-ada-simulation.cpp +# ${ADA_TEST_SOURCES} +# ${DEATHSTACK_NEW_SOURCES} +#) +#target_include_directories(test-ada-simulation PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(test-ada-simulation PRIVATE STANDALONE_CATCH1_TEST) +#sbs_target(test-ada-simulation stm32f429zi_skyward_death_stack_x) + +add_executable(test-ada-dpl-simulation + src/tests/test-ada-dpl-simulation.cpp + ${ADA_TEST_SOURCES} + ${DEATHSTACK_NEW_SOURCES} +) +target_include_directories(test-ada-dpl-simulation PRIVATE ${OBSW_INCLUDE_DIRS}) +sbs_target(test-ada-dpl-simulation stm32f429zi_skyward_death_stack_x) + +add_executable(test-nas + src/tests/catch/fsm/test-nas.cpp + ${NAVIGATION_SYSTEM_SOURCES} + ${TEST_UTILS_SOURCES} + ${MOCK_SENSORS_DATA_SOURCES} + ${LOGSERVICE_SOURCES} +) +target_include_directories(test-nas PRIVATE ${OBSW_INCLUDE_DIRS}) +target_compile_definitions(test-nas PRIVATE STANDALONE_CATCH1_TEST) +sbs_target(test-nas stm32f429zi_skyward_death_stack_x) + +add_executable(test-nas-simulation + src/tests/catch/nas/test-nas-simulation.cpp + ${NAVIGATION_SYSTEM_SOURCES} + ${MOCK_SENSORS_DATA_SOURCES} + ${LOGSERVICE_SOURCES} +) +target_include_directories(test-nas-simulation PRIVATE ${OBSW_INCLUDE_DIRS}) +target_compile_definitions(test-nas-simulation PRIVATE STANDALONE_CATCH1_TEST) +sbs_target(test-nas-simulation stm32f429zi_skyward_death_stack_x) + +#add_executable(test-tmtc src/tests/test-tmtc.cpp ${TEST_UTILS_SOURCES} ${DEATHSTACK_NEW_SOURCES}) +#target_include_directories(test-tmtc PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(test-tmtc PRIVATE STANDALONE_CATCH1_TEST) +#sbs_target(test-tmtc stm32f429zi_skyward_death_stack_x) + +#add_executable(test-flightstatsrecorder +# src/tests/catch/fsm/test-flightstatsrecorder.cpp +# ${TEST_UTILS_SOURCES} +# ${LOGSERVICE_SOURCES} +#) +#target_include_directories(test-flightstatsrecorder PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(test-flightstatsrecorder PRIVATE STANDALONE_CATCH1_TEST) +#sbs_target(test-flightstatsrecorder stm32f429zi_skyward_death_stack_x) + +#add_executable(test-ignition src/tests/catch/fsm/test-ignition.cpp ${TEST_UTILS_SOURCES}) +#target_include_directories(test-ignition PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(test-ignition PRIVATE STANDALONE_CATCH1_TEST) +#sbs_target(test-ignition stm32f429zi_skyward_death_stack_x) + +#-----------------------------------------------------------------------------# +# Tests - HIL # +#-----------------------------------------------------------------------------# + +#add_executable(test-SerialInterface src/tests/hardware_in_the_loop/test-SerialInterface/test-SerialInterface.cpp) +#target_include_directories(test-SerialInterface PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(test-SerialInterface PRIVATE HIL_SERIALINTERFACE) +#sbs_target(test-SerialInterface stm32f407vg_stm32f4discovery) + +#add_executable(test-HIL src/tests/hardware_in_the_loop/test-HIL/test-HIL.cpp) +#target_include_directories(test-HIL PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(test-HIL PRIVATE HIL) +#sbs_target(test-HIL stm32f407vg_stm32f4discovery) + +#add_executable(test-HIL+Aerobrake src/tests/hardware_in_the_loop/test-HIL+Aerobrake/test-HIL+Aerobrake.cpp) +#target_include_directories(test-HIL+Aerobrake PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(test-HIL+Aerobrake PRIVATE HIL_AEROBRAKE) +#sbs_target(test-HIL+Aerobrake stm32f407vg_stm32f4discovery) + +#add_executable(test-HIL+AerobrakeController src/tests/hardware_in_the_loop/test-HIL+AerobrakeController/test-HIL+AerobrakeController.cpp) +#target_include_directories(test-HIL+AerobrakeController PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(test-HIL+AerobrakeController PRIVATE HIL_AEROBRAKE) +#sbs_target(test-HIL+AerobrakeController stm32f407vg_stm32f4discovery) + +#add_executable(test-HIL+ADA +# src/tests/hardware_in_the_loop/test-HIL+ApogeeDetectionAlgorithm/test-HIL+ADA.cpp +# ${ADA_SOURCES} +# ${ADA_TEST_SOURCES} +# ${LOGSERVICE_SOURCES} +#) +#target_include_directories(test-HIL+ADA PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(test-HIL+ADA PRIVATE HIL_ADA) +#sbs_target(test-HIL+ADA stm32f429zi_skyward_death_stack_x) + +#add_executable(test-HIL+ADA+Aerobrake +# src/tests/hardware_in_the_loop/test-HIL+ADA+Aerobrake/test-HIL+ADA+Aerobrake.cpp +# ${ADA_SOURCES} +# ${ADA_TEST_SOURCES} +# ${LOGSERVICE_SOURCES} +#) +#target_include_directories(test-HIL+ADA+Aerobrake PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(test-HIL+ADA+Aerobrake PRIVATE HIL_ADA_AEROBRAKE) +#sbs_target(test-HIL+ADA+Aerobrake stm32f407vg_stm32f4discovery) + +#add_executable(test-HIL+ADA+AerobrakeController+nas +# src/tests/hardware_in_the_loop/test-HIL+ADA+AerobrakeController+nas/test-HIL+ADA+AerobrakeController+nas.cpp +# ${ADA_SOURCES} +# ${ADA_TEST_SOURCES} +# ${LOGSERVICE_SOURCES} +# ${NAVIGATION_SYSTEM_SOURCES} +#) +#target_include_directories(test-HIL+ADA+AerobrakeController+nas PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(test-HIL+ADA+AerobrakeController+nas PRIVATE HIL_ADA_AEROBRAKECONTROLLER_NAS) +#sbs_target(test-HIL+ADA+AerobrakeController+nas stm32f429zi_stm32f4discovery) + +#add_executable(eigen-test src/tests/eigen-test.cpp) +#target_include_directories(eigen-test PRIVATE ${OBSW_INCLUDE_DIRS}) +#sbs_target(eigen-test stm32f429zi_stm32f4discovery) + +#add_executable(test-mock-sensors src/tests/mock_sensors/test-mock-sensors.cpp ${MOCK_SENSORS_DATA}) +#target_include_directories(test-mock-sensors PRIVATE ${OBSW_INCLUDE_DIRS}) +#sbs_target(test-mock-sensors stm32f429zi_stm32f4discovery) + +#add_executable(test-deployment +# src/tests/catch/fsm/test-deployment.cpp +# ${TEST_UTILS_SOURCES} +# ${DEPLOYMENT_SOURCES} +# ${LOGSERVICE_SOURCES} +#) +#target_include_directories(test-deployment PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(test-deployment PRIVATE STANDALONE_CATCH1_TEST) +#sbs_target(test-deployment stm32f429zi_skyward_death_stack_x) + +#add_executable(test-deployment-interactive +# src/tests/deployment/test-deployment-interactive.cpp +# ${TEST_UTILS_SOURCES} +# ${DEPLOYMENT_SOURCES} +# ${LOGSERVICE_SOURCES} +#) +#target_include_directories(test-deployment-interactive PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(test-deployment-interactive PRIVATE STANDALONE_CATCH1_TEST) +#sbs_target(test-deployment-interactive stm32f429zi_skyward_death_stack_x) + +#add_executable(test-airbrakes +# src/tests/catch/fsm/test-airbrakes.cpp +# ${TEST_UTILS_SOURCES} +# ${LOGSERVICE_SOURCES} +# ${AIRBRAKES_SOURCES} +#) +#target_include_directories(test-airbrakes PRIVATE ${OBSW_INCLUDE_DIRS}) +#target_compile_definitions(test-airbrakes PRIVATE STANDALONE_CATCH1_TEST) +#sbs_target(test-airbrakes stm32f429zi_skyward_death_stack_x) + +add_executable(test-airbrakes-interactive + src/tests/airbrakes/test-airbrakes-interactive.cpp + ${TEST_UTILS_SOURCES} + ${LOGSERVICE_SOURCES} + ${AIRBRAKES_SOURCES} +) +target_include_directories(test-airbrakes-interactive PRIVATE ${OBSW_INCLUDE_DIRS}) +sbs_target(test-airbrakes-interactive stm32f429zi_skyward_death_stack_x) + +#add_executable(test-airbrakes-algorithm +# src/tests/airbrakes/test-airbrakes-algorithm.cpp +# ${LOGSERVICE_SOURCES} +# ${AIRBRAKES_SOURCES} +#) +#target_include_directories(test-airbrakes-algorithm PRIVATE ${OBSW_INCLUDE_DIRS}) +#sbs_target(test-airbrakes-algorithm stm32f429zi_skyward_death_stack_x) + +#-----------------------------------------------------------------------------# +# Tests - Comprehensive (included in death-stack-x-testsuite) # +#-----------------------------------------------------------------------------# + +#add_executable(test-power-board +# src/tests/deathstack-boards/test-power-board.cpp +# ${TEST_UTILS_SOURCES} +# ${LOGSERVICE_SOURCES} +# ${AIRBRAKES_SOURCES} +#) +#target_include_directories(test-power-board PRIVATE ${OBSW_INCLUDE_DIRS}) +#sbs_target(test-power-board stm32f429zi_skyward_death_stack_x) + +#add_executable(test-stm-board src/tests/deathstack-boards/test-stm-board.cpp) +#target_include_directories(test-stm-board PRIVATE ${OBSW_INCLUDE_DIRS}) +#sbs_target(test-stm-board stm32f429zi_skyward_death_stack_x) + +#add_executable(test-rf-board src/tests/deathstack-boards/test-rf-board.cpp) +#target_include_directories(test-rf-board PRIVATE ${OBSW_INCLUDE_DIRS}) +#sbs_target(test-rf-board stm32f429zi_skyward_death_stack_x) + +#add_executable(test-analog-board +# src/tests/deathstack-boards/test-analog-board.cpp +# ${PINHANDLER_SOURCES} +# ${LOGSERVICE_SOURCES} +#) +#target_include_directories(test-analog-board PRIVATE ${OBSW_INCLUDE_DIRS}) +#sbs_target(test-analog-board stm32f429zi_skyward_death_stack_x) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52974fd93c01399196f0ad1d0846df300c601f0c..2c14beeea49abadc2b0f0cbe0775e8211deb642e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,386 +29,15 @@ include(skyward-boardcore/cmake/sbs.cmake) project(SkywardOnBoardSoftware) #-----------------------------------------------------------------------------# -# Entrypoints # +# Main Computer # #-----------------------------------------------------------------------------# -add_executable(death-stack-x-entry - src/entrypoints/death-stack-x-entry.cpp - ${DEATHSTACK_NEW_SOURCES} - ${MOCK_SENSORS_DATA_SOURCES} +add_executable(catch-tests-main + src/tests/Main/catch/catch-tests-entry.cpp + src/tests/Main/catch/test-deployment.cpp + ${MAIN_COMPUTER} ) -target_include_directories(death-stack-x-entry PRIVATE ${OBSW_INCLUDE_DIRS}) -target_compile_definitions(death-stack-x-entry PRIVATE FLIGHT EUROC) -sbs_target(death-stack-x-entry stm32f429zi_skyward_death_stack_x) - -add_executable(death-stack-x-testsuite - src/entrypoints/death-stack-x-testsuite.cpp - ${DEATHSTACK_NEW_SOURCES} -) -target_include_directories(death-stack-x-testsuite PRIVATE ${OBSW_INCLUDE_DIRS}) -sbs_target(death-stack-x-testsuite stm32f429zi_skyward_death_stack_x) - -add_executable(payload-entry - src/entrypoints/payload-entry.cpp - ${PAYLOAD_SOURCES} -) -target_include_directories(payload-entry PRIVATE ${OBSW_INCLUDE_DIRS}) -sbs_target(payload-entry stm32f429zi_skyward_death_stack_x) - -#add_executable(death-stack-entry src/entrypoints/death-stack-entry.cpp ${DEATHSTACK_SOURCES}) -#target_include_directories(death-stack-entry PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(death-stack-entry PRIVATE DEATH_STACK_1) -#sbs_target(death-stack-entry stm32f429zi_skyward_death_stack_x) - -#add_executable(death-stack-testsuite src/entrypoints/death-stack-testsuite.cpp ${DEATHSTACK_SOURCES}) -#target_include_directories(death-stack-testsuite PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(death-stack-testsuite PRIVATE DEATH_STACK_1) -#sbs_target(death-stack-testsuite stm32f429zi_skyward_death_stack_x) - -#add_executable(windtunnel-entry src/entrypoints/windtunnel-entry.cpp ${DEATHSTACK_NEW_SOURCES}) -#target_include_directories(windtunnel-entry PRIVATE ${OBSW_INCLUDE_DIRS}) -#sbs_target(windtunnel-entry stm32f429zi_skyward_death_stack_x) - -#add_executable(hil-entry -# src/entrypoints/hardware_in_the_loop/hil-entry.cpp -# ${FMM_SOURCES} -# ${PINHANDLER_SOURCES} -# ${ADA_SOURCES} -# ${NAVIGATION_SYSTEM_SOURCES} -# ${LOGSERVICE_SOURCES} -# ${DEPLOYMENT_SOURCES} -#) -#target_include_directories(hil-entry PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(hil-entry PRIVATE HARDWARE_IN_THE_LOOP) -#sbs_target(hil-entry stm32f429zi_skyward_death_stack_x) - -#-----------------------------------------------------------------------------# -# Tests - Catch # -#-----------------------------------------------------------------------------# - -#add_executable(catch-tests-entry -# src/tests/catch/catch-tests-entry.cpp -# ${DEATHSTACK_SOURCES} -# ${HERMES_TESTS_SOURCES} -# ${ADA_TEST_SOURCES} -# ${MOCK_SENSORS_DATA_SOURCES} -#) -#target_include_directories(catch-tests-entry PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(catch-tests-entry PRIVATE DEATH_STACK_1) -#sbs_target(catch-tests-entry stm32f429zi_skyward_death_stack_x) - -add_executable(tests-catch - src/tests/catch/catch-tests-entry.cpp - ${DEATHSTACK_NEW_SOURCES} - ${TESTS_OBSW_SOURCES} - ${ADA_TEST_SOURCES} - ${MOCK_SENSORS_DATA_SOURCES} -) -target_include_directories(tests-catch PRIVATE ${OBSW_INCLUDE_DIRS}) -sbs_target(tests-catch stm32f429zi_skyward_death_stack_x) - -#-----------------------------------------------------------------------------# -# Tests - Drivers # -#-----------------------------------------------------------------------------# - -#add_executable(test-imus src/tests/drivers/test-imus.cpp) -#target_include_directories(test-imus PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(test-imus PRIVATE DEATH_STACK_1) -#sbs_target(test-imus stm32f429zi_skyward_death_stack_x) - -#add_executable(test-cutter src/tests/drivers/test-cutter.cpp) -#target_include_directories(test-cutter PRIVATE ${OBSW_INCLUDE_DIRS}) -#sbs_target(test-cutter stm32f429zi_skyward_death_stack_x) - -#add_executable(test-mavlink src/tests/drivers/test-mavlink.cpp ${TMTC_SOURCES} ${LOGSERVICE_SOURCES}) -#target_include_directories(test-mavlink PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(test-mavlink PRIVATE TRACE_EVENTS DEATH_STACK_1) -#sbs_target(test-mavlink stm32f429zi_skyward_death_stack_x) - -#add_executable(ledwave src/tests/ledwave.cpp) -#target_include_directories(ledwave PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(ledwave PRIVATE <compile>) -#sbs_target(ledwave stm32f429zi_skyward_death_stack_x) - -add_executable(ramtest src/tests/ram_test/ramtest.cpp ${RAM_TEST_SOURCES}) -target_include_directories(ramtest PRIVATE ${OBSW_INCLUDE_DIRS}) -target_compile_definitions(ramtest PRIVATE __ENABLE_XRAM) -sbs_target(ramtest stm32f429zi_skyward_death_stack_x) - -#add_executable(test-motor src/tests/drivers/test-motor.cpp ${DEPLOYMENT_SOURCES}) -#target_include_directories(test-motor PRIVATE ${OBSW_INCLUDE_DIRS}) -#sbs_target(test-motor stm32f429zi_skyward_death_stack_x) - -#add_executable(test-servo src/tests/drivers/test-servo.cpp ${LOGSERVICE_SOURCES} ${AIRBRAKES_SOURCES}) -#target_include_directories(test-servo PRIVATE ${OBSW_INCLUDE_DIRS}) -#sbs_target(test-servo stm32f429zi_skyward_death_stack_x) - -#add_executable(test-hse src/tests/test-hse.cpp) -#target_include_directories(test-hse PRIVATE ${OBSW_INCLUDE_DIRS}) -#sbs_target(test-hse stm32f429zi_skyward_death_stack_x) - -#add_executable(test-all-sensors src/tests/drivers/test-all-sensors.cpp) -#target_include_directories(test-all-sensors PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(test-all-sensors PRIVATE DEATH_STACK_1) -#sbs_target(test-all-sensors stm32f429zi_skyward_death_stack_x) - -#add_executable(test-preassure-calib src/tests/drivers/test-pressure-calib.cpp) -#target_include_directories(test-preassure-calib PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(test-preassure-calib PRIVATE DEATH_STACK_1) -#sbs_target(test-preassure-calib stm32f429zi_skyward_death_stack_x) - -#-----------------------------------------------------------------------------# -# Tests - Components # -#-----------------------------------------------------------------------------# - -#add_executable(test-canproxy src/tests/test-canproxy.cpp) -#target_include_directories(test-canproxy PRIVATE ${OBSW_INCLUDE_DIRS}) -#sbs_target(test-canproxy stm32f429zi_skyward_death_stack_x) - -add_executable(test-pinhandler src/tests/test-pinhandler.cpp ${PINHANDLER_SOURCES} ${LOGSERVICE_SOURCES}) -target_include_directories(test-pinhandler PRIVATE ${OBSW_INCLUDE_DIRS}) -sbs_target(test-pinhandler stm32f429zi_skyward_death_stack_x) - -#add_executable(test-logproxy src/tests/test-logproxy.cpp ${LOGSERVICE_SOURCES}) -#target_include_directories(test-logproxy PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(test-logproxy PRIVATE DEATH_STACK_1) -#sbs_target(test-logproxy stm32f429zi_skyward_death_stack_x) - -#add_executable(test-sensormanager src/tests/test-sensormanager.cpp ${LOGSERVICE_SOURCES} ${ADA_TEST_SOURCES}) -#target_include_directories(test-sensormanager PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(test-sensormanager PRIVATE USE_MOCK_SENSORS DEATH_STACK_1) -#sbs_target(test-sensormanager stm32f429zi_skyward_death_stack_x) - -# Cannot use this as it is since the DeathStack singleton is required for handling messages in the TCHandler class -#add_executable( -# test-sm+tmtc src/tests/test-sm+tmtc.cpp -# ${LOGSERVICE_SOURCES} -# ${ADA_SOURCES} -# ${TMTC_SOURCES} -# ${EVT_FUNCTIONS_SOURCES} -# ${ADA_TEST_SOURCES} -#) -#target_include_directories(test-sm+tmtc PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(test-sm+tmtc PRIVATE DEATH_STACK_1) -#sbs_target(test-sm+tmtc stm32f429zi_skyward_death_stack) - -#add_executable(test-fmm src/tests/catch/fsm/test-fmm.cpp ${DEATHSTACK_NEW_SOURCES}) -#target_include_directories(test-fmm PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(test-fmm PRIVATE STANDALONE_CATCH1_TEST) -#sbs_target(test-fmm stm32f429zi_skyward_death_stack_x) - -#add_executable(test-fmm-interactive src/tests/test-fmm-interactive.cpp ${DEATHSTACK_NEW_SOURCES}) -#target_include_directories(test-fmm-interactive PRIVATE ${OBSW_INCLUDE_DIRS}) -#sbs_target(test-fmm-interactive stm32f429zi_skyward_death_stack_x) - -#-----------------------------------------------------------------------------# -# Tests - FSM # -#-----------------------------------------------------------------------------# - -#add_executable(test-ada -# src/tests/catch/fsm/test-ada.cpp -# ${ADA_SOURCES} -# ${TEST_UTILS_SOURCES} -# ${ADA_TEST_SOURCES} -# ${MOCK_SENSORS_DATA_SOURCES} -# ${LOGSERVICE_SOURCES} -#) -#target_include_directories(test-ada PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(test-ada PRIVATE STANDALONE_CATCH1_TEST) -#sbs_target(test-ada stm32f429zi_skyward_death_stack_x) - -#add_executable(test-ada-simulation -# src/tests/catch/ada/ada_kalman_p/test-ada-simulation.cpp -# ${ADA_TEST_SOURCES} -# ${DEATHSTACK_NEW_SOURCES} -#) -#target_include_directories(test-ada-simulation PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(test-ada-simulation PRIVATE STANDALONE_CATCH1_TEST) -#sbs_target(test-ada-simulation stm32f429zi_skyward_death_stack_x) - -add_executable(test-ada-dpl-simulation - src/tests/test-ada-dpl-simulation.cpp - ${ADA_TEST_SOURCES} - ${DEATHSTACK_NEW_SOURCES} -) -target_include_directories(test-ada-dpl-simulation PRIVATE ${OBSW_INCLUDE_DIRS}) -sbs_target(test-ada-dpl-simulation stm32f429zi_skyward_death_stack_x) - -add_executable(test-nas - src/tests/catch/fsm/test-nas.cpp - ${NAVIGATION_SYSTEM_SOURCES} - ${TEST_UTILS_SOURCES} - ${MOCK_SENSORS_DATA_SOURCES} - ${LOGSERVICE_SOURCES} -) -target_include_directories(test-nas PRIVATE ${OBSW_INCLUDE_DIRS}) -target_compile_definitions(test-nas PRIVATE STANDALONE_CATCH1_TEST) -sbs_target(test-nas stm32f429zi_skyward_death_stack_x) - -add_executable(test-nas-simulation - src/tests/catch/nas/test-nas-simulation.cpp - ${NAVIGATION_SYSTEM_SOURCES} - ${MOCK_SENSORS_DATA_SOURCES} - ${LOGSERVICE_SOURCES} -) -target_include_directories(test-nas-simulation PRIVATE ${OBSW_INCLUDE_DIRS}) -target_compile_definitions(test-nas-simulation PRIVATE STANDALONE_CATCH1_TEST) -sbs_target(test-nas-simulation stm32f429zi_skyward_death_stack_x) - -#add_executable(test-tmtc src/tests/test-tmtc.cpp ${TEST_UTILS_SOURCES} ${DEATHSTACK_NEW_SOURCES}) -#target_include_directories(test-tmtc PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(test-tmtc PRIVATE STANDALONE_CATCH1_TEST) -#sbs_target(test-tmtc stm32f429zi_skyward_death_stack_x) - -#add_executable(test-flightstatsrecorder -# src/tests/catch/fsm/test-flightstatsrecorder.cpp -# ${TEST_UTILS_SOURCES} -# ${LOGSERVICE_SOURCES} -#) -#target_include_directories(test-flightstatsrecorder PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(test-flightstatsrecorder PRIVATE STANDALONE_CATCH1_TEST) -#sbs_target(test-flightstatsrecorder stm32f429zi_skyward_death_stack_x) - -#add_executable(test-ignition src/tests/catch/fsm/test-ignition.cpp ${TEST_UTILS_SOURCES}) -#target_include_directories(test-ignition PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(test-ignition PRIVATE STANDALONE_CATCH1_TEST) -#sbs_target(test-ignition stm32f429zi_skyward_death_stack_x) - -#-----------------------------------------------------------------------------# -# Tests - HIL # -#-----------------------------------------------------------------------------# - -#add_executable(test-SerialInterface src/tests/hardware_in_the_loop/test-SerialInterface/test-SerialInterface.cpp) -#target_include_directories(test-SerialInterface PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(test-SerialInterface PRIVATE HIL_SERIALINTERFACE) -#sbs_target(test-SerialInterface stm32f407vg_stm32f4discovery) - -#add_executable(test-HIL src/tests/hardware_in_the_loop/test-HIL/test-HIL.cpp) -#target_include_directories(test-HIL PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(test-HIL PRIVATE HIL) -#sbs_target(test-HIL stm32f407vg_stm32f4discovery) - -#add_executable(test-HIL+Aerobrake src/tests/hardware_in_the_loop/test-HIL+Aerobrake/test-HIL+Aerobrake.cpp) -#target_include_directories(test-HIL+Aerobrake PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(test-HIL+Aerobrake PRIVATE HIL_AEROBRAKE) -#sbs_target(test-HIL+Aerobrake stm32f407vg_stm32f4discovery) - -#add_executable(test-HIL+AerobrakeController src/tests/hardware_in_the_loop/test-HIL+AerobrakeController/test-HIL+AerobrakeController.cpp) -#target_include_directories(test-HIL+AerobrakeController PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(test-HIL+AerobrakeController PRIVATE HIL_AEROBRAKE) -#sbs_target(test-HIL+AerobrakeController stm32f407vg_stm32f4discovery) - -#add_executable(test-HIL+ADA -# src/tests/hardware_in_the_loop/test-HIL+ApogeeDetectionAlgorithm/test-HIL+ADA.cpp -# ${ADA_SOURCES} -# ${ADA_TEST_SOURCES} -# ${LOGSERVICE_SOURCES} -#) -#target_include_directories(test-HIL+ADA PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(test-HIL+ADA PRIVATE HIL_ADA) -#sbs_target(test-HIL+ADA stm32f429zi_skyward_death_stack_x) - -#add_executable(test-HIL+ADA+Aerobrake -# src/tests/hardware_in_the_loop/test-HIL+ADA+Aerobrake/test-HIL+ADA+Aerobrake.cpp -# ${ADA_SOURCES} -# ${ADA_TEST_SOURCES} -# ${LOGSERVICE_SOURCES} -#) -#target_include_directories(test-HIL+ADA+Aerobrake PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(test-HIL+ADA+Aerobrake PRIVATE HIL_ADA_AEROBRAKE) -#sbs_target(test-HIL+ADA+Aerobrake stm32f407vg_stm32f4discovery) - -#add_executable(test-HIL+ADA+AerobrakeController+nas -# src/tests/hardware_in_the_loop/test-HIL+ADA+AerobrakeController+nas/test-HIL+ADA+AerobrakeController+nas.cpp -# ${ADA_SOURCES} -# ${ADA_TEST_SOURCES} -# ${LOGSERVICE_SOURCES} -# ${NAVIGATION_SYSTEM_SOURCES} -#) -#target_include_directories(test-HIL+ADA+AerobrakeController+nas PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(test-HIL+ADA+AerobrakeController+nas PRIVATE HIL_ADA_AEROBRAKECONTROLLER_NAS) -#sbs_target(test-HIL+ADA+AerobrakeController+nas stm32f429zi_stm32f4discovery) - -#add_executable(eigen-test src/tests/eigen-test.cpp) -#target_include_directories(eigen-test PRIVATE ${OBSW_INCLUDE_DIRS}) -#sbs_target(eigen-test stm32f429zi_stm32f4discovery) - -#add_executable(test-mock-sensors src/tests/mock_sensors/test-mock-sensors.cpp ${MOCK_SENSORS_DATA}) -#target_include_directories(test-mock-sensors PRIVATE ${OBSW_INCLUDE_DIRS}) -#sbs_target(test-mock-sensors stm32f429zi_stm32f4discovery) - -#add_executable(test-deployment -# src/tests/catch/fsm/test-deployment.cpp -# ${TEST_UTILS_SOURCES} -# ${DEPLOYMENT_SOURCES} -# ${LOGSERVICE_SOURCES} -#) -#target_include_directories(test-deployment PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(test-deployment PRIVATE STANDALONE_CATCH1_TEST) -#sbs_target(test-deployment stm32f429zi_skyward_death_stack_x) - -#add_executable(test-deployment-interactive -# src/tests/deployment/test-deployment-interactive.cpp -# ${TEST_UTILS_SOURCES} -# ${DEPLOYMENT_SOURCES} -# ${LOGSERVICE_SOURCES} -#) -#target_include_directories(test-deployment-interactive PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(test-deployment-interactive PRIVATE STANDALONE_CATCH1_TEST) -#sbs_target(test-deployment-interactive stm32f429zi_skyward_death_stack_x) - -#add_executable(test-airbrakes -# src/tests/catch/fsm/test-airbrakes.cpp -# ${TEST_UTILS_SOURCES} -# ${LOGSERVICE_SOURCES} -# ${AIRBRAKES_SOURCES} -#) -#target_include_directories(test-airbrakes PRIVATE ${OBSW_INCLUDE_DIRS}) -#target_compile_definitions(test-airbrakes PRIVATE STANDALONE_CATCH1_TEST) -#sbs_target(test-airbrakes stm32f429zi_skyward_death_stack_x) - -add_executable(test-airbrakes-interactive - src/tests/airbrakes/test-airbrakes-interactive.cpp - ${TEST_UTILS_SOURCES} - ${LOGSERVICE_SOURCES} - ${AIRBRAKES_SOURCES} -) -target_include_directories(test-airbrakes-interactive PRIVATE ${OBSW_INCLUDE_DIRS}) -sbs_target(test-airbrakes-interactive stm32f429zi_skyward_death_stack_x) - -#add_executable(test-airbrakes-algorithm -# src/tests/airbrakes/test-airbrakes-algorithm.cpp -# ${LOGSERVICE_SOURCES} -# ${AIRBRAKES_SOURCES} -#) -#target_include_directories(test-airbrakes-algorithm PRIVATE ${OBSW_INCLUDE_DIRS}) -#sbs_target(test-airbrakes-algorithm stm32f429zi_skyward_death_stack_x) - -#-----------------------------------------------------------------------------# -# Tests - Comprehensive (included in death-stack-x-testsuite) # -#-----------------------------------------------------------------------------# - -#add_executable(test-power-board -# src/tests/deathstack-boards/test-power-board.cpp -# ${TEST_UTILS_SOURCES} -# ${LOGSERVICE_SOURCES} -# ${AIRBRAKES_SOURCES} -#) -#target_include_directories(test-power-board PRIVATE ${OBSW_INCLUDE_DIRS}) -#sbs_target(test-power-board stm32f429zi_skyward_death_stack_x) - -#add_executable(test-stm-board src/tests/deathstack-boards/test-stm-board.cpp) -#target_include_directories(test-stm-board PRIVATE ${OBSW_INCLUDE_DIRS}) -#sbs_target(test-stm-board stm32f429zi_skyward_death_stack_x) - -#add_executable(test-rf-board src/tests/deathstack-boards/test-rf-board.cpp) -#target_include_directories(test-rf-board PRIVATE ${OBSW_INCLUDE_DIRS}) -#sbs_target(test-rf-board stm32f429zi_skyward_death_stack_x) - -#add_executable(test-analog-board -# src/tests/deathstack-boards/test-analog-board.cpp -# ${PINHANDLER_SOURCES} -# ${LOGSERVICE_SOURCES} -#) -#target_include_directories(test-analog-board PRIVATE ${OBSW_INCLUDE_DIRS}) -#sbs_target(test-analog-board stm32f429zi_skyward_death_stack_x) +target_include_directories(catch-tests-main PRIVATE ${OBSW_INCLUDE_DIRS}) +target_compile_definitions(catch-tests-main PRIVATE USE_MOCK_PERIPHERALS) +sbs_target(catch-tests-main stm32f429zi_skyward_death_stack_x) +sbs_catch_test(catch-tests-main) diff --git a/cmake/dependencies Lynx.cmake b/cmake/dependencies Lynx.cmake new file mode 100644 index 0000000000000000000000000000000000000000..d067614da27b84f9362c2191904dd59d235f94fc --- /dev/null +++ b/cmake/dependencies Lynx.cmake @@ -0,0 +1,136 @@ +# Copyright (c) 2021 Skyward Experimental Rocketry +# Author: Damiano Amatruda +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +set(OBSW_INCLUDE_DIRS + src + src/common + src/boards + src/boards/DeathStack +) + +set(DEATHSTACK_NEW_SOURCES + src/common/events/EventStrings.cpp + src/boards/DeathStack/PinHandler/PinHandler.cpp + src/boards/DeathStack/TelemetriesTelecommands/TMTCController.cpp + src/boards/DeathStack/TelemetriesTelecommands/TCHandler.cpp + src/boards/DeathStack/TelemetriesTelecommands/TmRepository.cpp + src/boards/DeathStack/Main/Radio.cpp + src/boards/DeathStack/Main/Sensors.cpp + src/boards/DeathStack/Main/StateMachines.cpp + src/boards/DeathStack/Deployment/DeploymentController.cpp + src/boards/DeathStack/FlightModeManager/FMMController.cpp + src/boards/DeathStack/ApogeeDetectionAlgorithm/ADACalibrator.cpp + src/boards/DeathStack/ApogeeDetectionAlgorithm/ADAAlgorithm.cpp + src/boards/DeathStack/NavigationAttitudeSystem/NASCalibrator.cpp + src/boards/DeathStack/NavigationAttitudeSystem/ExtendedKalmanEigen.cpp + src/boards/DeathStack/FlightStatsRecorder/FSRController.cpp + src/boards/DeathStack/AirBrakes/AirBrakesServo.cpp +) +#set(DEATHSTACK_SOURCES +# src/boards/DeathStack/LoggerService/LoggerService.cpp +# src/boards/DeathStack/events/EventStrings.cpp +# src/boards/DeathStack/FlightModeManager/FMMController.cpp +# src/boards/DeathStack/SensorManager/SensorManager.cpp +# src/boards/DeathStack/Deployment/DeploymentController.cpp +# src/boards/DeathStack/PinHandler/PinHandler.cpp +# src/boards/DeathStack/TMTCManager/TMTCManager.cpp +# src/boards/DeathStack/LoggerService/TmRepository.cpp +# src/boards/DeathStack/ApogeeDetectionAlgorithm/ADAAlgorithm.cpp +# src/boards/DeathStack/ApogeeDetectionAlgorithm/ADACalibrator.cpp +# src/boards/DeathStack/LoggerService/FSRController.cpp +# src/boards/DeathStack/TMTCManager/XbeeInterrupt.cpp +# src/boards/DeathStack/AirBrakes/AirBrakesServo.cpp +#) +set(PAYLOAD_SOURCES + src/common/events/EventStrings.cpp + src/boards/Payload/WingControl/WingServo.cpp + src/boards/Payload/Main/Sensors.cpp + src/boards/Payload/Main/Radio.cpp + src/boards/Payload/PinHandler/PinHandler.cpp +) +set(ADA_SOURCES + src/boards/DeathStack/ApogeeDetectionAlgorithm/ADAAlgorithm.cpp + src/boards/DeathStack/ApogeeDetectionAlgorithm/ADACalibrator.cpp +) +set(DEPLOYMENT_SOURCES + src/boards/DeathStack/Deployment/DeploymentController.cpp +) +set(AIRBRAKES_SOURCES + src/boards/DeathStack/AirBrakes/AirBrakesServo.cpp +) +set(PINHANDLER_SOURCES + src/boards/DeathStack/PinHandler/PinHandler.cpp +) +set(FMM_SOURCES + src/boards/DeathStack/FlightModeManager/FMMController.cpp +) +#set(SENSORS_SOURCES +# src/boards/DeathStack/Sensors/BMX160Calibrator.cpp +# skyward-boardcore/src/shared/sensors/calibration/SensorDataExtra.cpp +#) +#set(TMTC_SOURCES +# src/boards/DeathStack/TelemetriesTelecommands/TCHandler.cpp +# src/boards/DeathStack/TelemetriesTelecommands/TMTCManager.cpp +#) +set(ALDEERAN_SOURCES + src/boards/Ignition/IgnitionManager.cpp +) +set(LOGSERVICE_SOURCES + src/boards/DeathStack/TelemetriesTelecommands/TmRepository.cpp + src/boards/DeathStack/FlightStatsRecorder/FSRController.cpp +) +set(ADA_TEST_SOURCES + src/tests/catch/ada/ada_kalman_p/test-ada-data.cpp +) +set(KALMAN_TEST_SOURCES + src/tests/catch/ada/kalman_acc/test-kalman-acc-data.cpp +) +set(MOCK_SENSORS_DATA_SOURCES + src/mocksensors/lynx_flight_data/lynx_imu_data.cpp + src/mocksensors/lynx_flight_data/lynx_press_data.cpp + src/mocksensors/lynx_flight_data/lynx_pressure_static_data.cpp + src/mocksensors/lynx_flight_data/lynx_gps_data.cpp + src/mocksensors/lynx_flight_data/lynx_airspeed_data.cpp +) +set(HERMES_TESTS_SOURCES + src/tests/catch/fsm/test-ada.cpp +) +set(RAM_TEST_SOURCES + src/tests/ram_test/sha1.cpp +) +set(EVT_FUNCTIONS_SOURCES + src/boards/DeathStack/events/EventStrings.cpp +) +set(NAVIGATION_SYSTEM_SOURCES + src/boards/DeathStack/NavigationAttitudeSystem/NASCalibrator.cpp + src/boards/DeathStack/NavigationAttitudeSystem/ExtendedKalmanEigen.cpp +) +set(TESTS_OBSW_SOURCES + src/tests/catch/fsm/test-fmm.cpp + src/tests/catch/fsm/test-tmtc.cpp + src/tests/catch/fsm/test-ada.cpp + src/tests/catch/ada/ada_kalman_p/test-ada-simulation.cpp + src/tests/catch/fsm/test-deployment.cpp + src/tests/catch/fsm/test-flightstatsrecorder.cpp + src/tests/catch/fsm/test-airbrakes.cpp + #src/tests/catch/fsm/test-nas.cpp + #src/tests/catch/nas/test-nas-simulation.cpp +) diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index d067614da27b84f9362c2191904dd59d235f94fc..ee5705d965d19aa3eac56cc1d8eaef029fdff9ca 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -20,117 +20,11 @@ # THE SOFTWARE. set(OBSW_INCLUDE_DIRS - src - src/common src/boards - src/boards/DeathStack ) -set(DEATHSTACK_NEW_SOURCES - src/common/events/EventStrings.cpp - src/boards/DeathStack/PinHandler/PinHandler.cpp - src/boards/DeathStack/TelemetriesTelecommands/TMTCController.cpp - src/boards/DeathStack/TelemetriesTelecommands/TCHandler.cpp - src/boards/DeathStack/TelemetriesTelecommands/TmRepository.cpp - src/boards/DeathStack/Main/Radio.cpp - src/boards/DeathStack/Main/Sensors.cpp - src/boards/DeathStack/Main/StateMachines.cpp - src/boards/DeathStack/Deployment/DeploymentController.cpp - src/boards/DeathStack/FlightModeManager/FMMController.cpp - src/boards/DeathStack/ApogeeDetectionAlgorithm/ADACalibrator.cpp - src/boards/DeathStack/ApogeeDetectionAlgorithm/ADAAlgorithm.cpp - src/boards/DeathStack/NavigationAttitudeSystem/NASCalibrator.cpp - src/boards/DeathStack/NavigationAttitudeSystem/ExtendedKalmanEigen.cpp - src/boards/DeathStack/FlightStatsRecorder/FSRController.cpp - src/boards/DeathStack/AirBrakes/AirBrakesServo.cpp -) -#set(DEATHSTACK_SOURCES -# src/boards/DeathStack/LoggerService/LoggerService.cpp -# src/boards/DeathStack/events/EventStrings.cpp -# src/boards/DeathStack/FlightModeManager/FMMController.cpp -# src/boards/DeathStack/SensorManager/SensorManager.cpp -# src/boards/DeathStack/Deployment/DeploymentController.cpp -# src/boards/DeathStack/PinHandler/PinHandler.cpp -# src/boards/DeathStack/TMTCManager/TMTCManager.cpp -# src/boards/DeathStack/LoggerService/TmRepository.cpp -# src/boards/DeathStack/ApogeeDetectionAlgorithm/ADAAlgorithm.cpp -# src/boards/DeathStack/ApogeeDetectionAlgorithm/ADACalibrator.cpp -# src/boards/DeathStack/LoggerService/FSRController.cpp -# src/boards/DeathStack/TMTCManager/XbeeInterrupt.cpp -# src/boards/DeathStack/AirBrakes/AirBrakesServo.cpp -#) -set(PAYLOAD_SOURCES - src/common/events/EventStrings.cpp - src/boards/Payload/WingControl/WingServo.cpp - src/boards/Payload/Main/Sensors.cpp - src/boards/Payload/Main/Radio.cpp - src/boards/Payload/PinHandler/PinHandler.cpp -) -set(ADA_SOURCES - src/boards/DeathStack/ApogeeDetectionAlgorithm/ADAAlgorithm.cpp - src/boards/DeathStack/ApogeeDetectionAlgorithm/ADACalibrator.cpp -) -set(DEPLOYMENT_SOURCES - src/boards/DeathStack/Deployment/DeploymentController.cpp -) -set(AIRBRAKES_SOURCES - src/boards/DeathStack/AirBrakes/AirBrakesServo.cpp -) -set(PINHANDLER_SOURCES - src/boards/DeathStack/PinHandler/PinHandler.cpp -) -set(FMM_SOURCES - src/boards/DeathStack/FlightModeManager/FMMController.cpp -) -#set(SENSORS_SOURCES -# src/boards/DeathStack/Sensors/BMX160Calibrator.cpp -# skyward-boardcore/src/shared/sensors/calibration/SensorDataExtra.cpp -#) -#set(TMTC_SOURCES -# src/boards/DeathStack/TelemetriesTelecommands/TCHandler.cpp -# src/boards/DeathStack/TelemetriesTelecommands/TMTCManager.cpp -#) -set(ALDEERAN_SOURCES - src/boards/Ignition/IgnitionManager.cpp -) -set(LOGSERVICE_SOURCES - src/boards/DeathStack/TelemetriesTelecommands/TmRepository.cpp - src/boards/DeathStack/FlightStatsRecorder/FSRController.cpp -) -set(ADA_TEST_SOURCES - src/tests/catch/ada/ada_kalman_p/test-ada-data.cpp -) -set(KALMAN_TEST_SOURCES - src/tests/catch/ada/kalman_acc/test-kalman-acc-data.cpp -) -set(MOCK_SENSORS_DATA_SOURCES - src/mocksensors/lynx_flight_data/lynx_imu_data.cpp - src/mocksensors/lynx_flight_data/lynx_press_data.cpp - src/mocksensors/lynx_flight_data/lynx_pressure_static_data.cpp - src/mocksensors/lynx_flight_data/lynx_gps_data.cpp - src/mocksensors/lynx_flight_data/lynx_airspeed_data.cpp -) -set(HERMES_TESTS_SOURCES - src/tests/catch/fsm/test-ada.cpp -) -set(RAM_TEST_SOURCES - src/tests/ram_test/sha1.cpp -) -set(EVT_FUNCTIONS_SOURCES - src/boards/DeathStack/events/EventStrings.cpp -) -set(NAVIGATION_SYSTEM_SOURCES - src/boards/DeathStack/NavigationAttitudeSystem/NASCalibrator.cpp - src/boards/DeathStack/NavigationAttitudeSystem/ExtendedKalmanEigen.cpp -) -set(TESTS_OBSW_SOURCES - src/tests/catch/fsm/test-fmm.cpp - src/tests/catch/fsm/test-tmtc.cpp - src/tests/catch/fsm/test-ada.cpp - src/tests/catch/ada/ada_kalman_p/test-ada-simulation.cpp - src/tests/catch/fsm/test-deployment.cpp - src/tests/catch/fsm/test-flightstatsrecorder.cpp - src/tests/catch/fsm/test-airbrakes.cpp - #src/tests/catch/fsm/test-nas.cpp - #src/tests/catch/nas/test-nas-simulation.cpp +set(MAIN_COMPUTER + src/boards/Main/events/EventStrings.cpp + src/boards/Main/Actuators/Actuators.cpp + src/boards/Main/Deployment/DeploymentController.cpp ) diff --git a/skyward-boardcore b/skyward-boardcore index 715cf492bb0239f53444ca6475dccbb9f4ac8ec7..c6824c3b2e8e51fc17c3ed5ce5cc1bbbfcd8d860 160000 --- a/skyward-boardcore +++ b/skyward-boardcore @@ -1 +1 @@ -Subproject commit 715cf492bb0239f53444ca6475dccbb9f4ac8ec7 +Subproject commit c6824c3b2e8e51fc17c3ed5ce5cc1bbbfcd8d860 diff --git a/src/boards/Main/Actuators/Actuators.cpp b/src/boards/Main/Actuators/Actuators.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7cc13c76518078761a8496e2ea385f45dd646d05 --- /dev/null +++ b/src/boards/Main/Actuators/Actuators.cpp @@ -0,0 +1,45 @@ +/* Copyright (c) 2021 Skyward Experimental Rocketry + * Author: Alberto Nidasio + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "Actuators.h" + +#include <Main/AirBrakes/AirBrakesConfig.h> +#include <Main/Deployment/DeploymentConfig.h> +#include <interfaces-impl/hwmapping.h> + +using namespace miosix; +using namespace MainComputer::DeploymentConfig; +using namespace MainComputer::AirBrakesConfigs; + +namespace MainComputer +{ + +Actuators::Actuators() + : servoExpulsion(DPL_SERVO_TIMER, DPL_SERVO_PWM_CH), + servoAirbrakes(ABK_SERVO_TIMER, ABK_SERVO_PWM_CH), + led1(leds::led_red1::getPin()), led2(leds::led_red2::getPin()), + led3(leds::led_blue1::getPin()), + cutter(actuators::nosecone::thCut1::ena::getPin()) +{ +} + +} // namespace MainComputer diff --git a/src/boards/Main/Actuators/Actuators.h b/src/boards/Main/Actuators/Actuators.h new file mode 100644 index 0000000000000000000000000000000000000000..d6931f408ff5831694511c69e7522bf3082601ff --- /dev/null +++ b/src/boards/Main/Actuators/Actuators.h @@ -0,0 +1,50 @@ +/* Copyright (c) 2021 Skyward Experimental Rocketry + * Author: Alberto Nidasio + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include <Singleton.h> +#include <drivers/servo/Servo.h> +#include <interfaces/gpio.h> + +namespace MainComputer +{ + +struct Actuators : public Boardcore::Singleton<Actuators> +{ + friend class Boardcore::Singleton<Actuators>; + + Boardcore::Servo servoExpulsion; + Boardcore::Servo servoAirbrakes; + + miosix::GpioPin led1; + miosix::GpioPin led2; + miosix::GpioPin led3; + // miosix::GpioPin led4; + + miosix::GpioPin cutter; + +private: + Actuators(); +}; + +} // namespace MainComputer diff --git a/src/boards/Main/AirBrakes/AirBrakesConfig.h b/src/boards/Main/AirBrakes/AirBrakesConfig.h new file mode 100644 index 0000000000000000000000000000000000000000..038711aad964260fb0bc3cacb6697d836a452962 --- /dev/null +++ b/src/boards/Main/AirBrakes/AirBrakesConfig.h @@ -0,0 +1,46 @@ +/* Copyright (c) 2021 Skyward Experimental Rocketry + * Author: Vincenzo Santomarco + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include <drivers/timer/PWM.h> +#include <utils/Constants.h> + +namespace MainComputer +{ + +namespace AirBrakesConfigs +{ + +TIM_TypeDef* const ABK_SERVO_TIMER = TIM8; +constexpr Boardcore::TimerUtils::Channel ABK_SERVO_PWM_CH = + Boardcore::TimerUtils::Channel::CHANNEL_2; + +static constexpr int SHADOW_MODE_TIMEOUT = 3.5 * 1000; + +static constexpr float ABK_SERVO_MAX_POS = 50.0; // [deg] +static constexpr float ABK_SERVO_MIN_POS = 0.0; // [deg] +static constexpr float ABK_SERVO_WIGGLE_AMPLITUDE = 10.0; // [deg] + +} // namespace AirBrakesConfigs + +} // namespace MainComputer diff --git a/src/boards/Main/Deployment/Deployment.scxml b/src/boards/Main/Deployment/Deployment.scxml new file mode 100644 index 0000000000000000000000000000000000000000..734c51fd6499805666888ccb1a2e98cf87309dbb --- /dev/null +++ b/src/boards/Main/Deployment/Deployment.scxml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="init" version="1.0"> + <state id="init"> + <onentry>servo.enable()</onentry> + <onentry>servo.reset()</onentry> + <onentry>transitionTo(idle)</onentry> + </state> + <state id="idle"> + <transition event="DPL.WIGGLE" target="idle">servo.wiggle()</transition> + <transition event="DPL.OPEN" target="idle">servo.open()</transition> + <transition event="DPL.RESET" target="idle">servo.reset()</transition> + <transition event="DPL.OPEN_NC" target="nosecone_ejection"></transition> + <transition event="DPL.CUT_DROGUE" target="cutting"></transition> + </state> + <state id="nosecone_ejection"> + <onentry>servo.open()</onentry> + <onentry>postD(DPL.OPEN_NC_TIMEOUT)</onentry> + <transition event="DPL.OPEN_NC_TIMEOUT" target="idle"></transition> + <transition event="FLIGHT.NC_DETACHED" target="idle">removeD(DPL.OPEN_NC_TIMEOUT)</transition> + </state> + <state id="cutting"> + <onentry>startCutting()</onentry> + <onentry>postD(DPL.CUT_TIMEOUT)</onentry> + <transition event="DPL.CUT_TIMEOUT" target="idle">stopCutting()</transition> + </state> +</scxml> diff --git a/src/boards/Main/Deployment/DeploymentConfig.h b/src/boards/Main/Deployment/DeploymentConfig.h new file mode 100644 index 0000000000000000000000000000000000000000..f9a64688d094de5fba29b98dfb90db0f8016912d --- /dev/null +++ b/src/boards/Main/Deployment/DeploymentConfig.h @@ -0,0 +1,47 @@ +/* Copyright (c) 2022 Skyward Experimental Rocketry + * Author: Alberto Nidasio + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include <drivers/timer/PWM.h> +#include <drivers/timer/TimerUtils.h> + +namespace MainComputer +{ + +namespace DeploymentConfig +{ + +static TIM_TypeDef* const DPL_SERVO_TIMER = TIM4; +static constexpr Boardcore::TimerUtils::Channel DPL_SERVO_PWM_CH = + Boardcore::TimerUtils::Channel::CHANNEL_1; + +static constexpr int OPEN_NC_TIMEOUT = 5 * 1000; // [ms] +static constexpr int CUT_DURATION = 50; // [ms] + +static constexpr float DPL_SERVO_MIN_POS = 155; // [deg] +static constexpr float DPL_SERVO_MAX_POS = 178; // [deg] +static constexpr float DPL_SERVO_RESET_POS = 178; // [deg] +static constexpr float DPL_SERVO_EJECT_POS = 157; // [deg] +static constexpr float DPL_SERVO_WIGGLE_AMPLITUDE = 2; // [deg] + +} // namespace DeploymentConfig + +} // namespace MainComputer diff --git a/src/boards/Main/Deployment/DeploymentController.cpp b/src/boards/Main/Deployment/DeploymentController.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f7b35c56e5a72388ae445dfe5038d6f6ffb925a7 --- /dev/null +++ b/src/boards/Main/Deployment/DeploymentController.cpp @@ -0,0 +1,237 @@ +/* Copyright (c) 2022 Skyward Experimental Rocketry + * Author: Alberto Nidasio + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "DeploymentController.h" + +#include <Main/Actuators/Actuators.h> +#include <Main/events/Events.h> +#include <drivers/timer/TimestampTimer.h> +#include <events/EventBroker.h> +#include <logger/Logger.h> +#include <miosix.h> + +#include "DeploymentConfig.h" + +using namespace Boardcore; +using namespace MainComputer::DeploymentConfig; + +namespace MainComputer +{ + +DeploymentController::DeploymentController() + : FSM(&DeploymentController::state_init) +{ + memset(&status, 0, sizeof(DeploymentControllerStatus)); + sEventBroker.subscribe(this, TOPIC_DPL); + sEventBroker.subscribe(this, TOPIC_FLIGHT); +} + +DeploymentController::~DeploymentController() +{ + sEventBroker.unsubscribe(this); +} + +void DeploymentController::state_init(const Event& ev) +{ + switch (ev.code) + { + case EV_ENTRY: + { + Actuators::getInstance().servoExpulsion.setPosition180Deg( + DPL_SERVO_RESET_POS); + Actuators::getInstance().servoExpulsion.enable(); + + transition(&DeploymentController::state_idle); + + logStatus(INIT); + LOG_DEBUG(logger, "[Deployment] entering state init\n"); + break; + } + case EV_EXIT: + { + LOG_DEBUG(logger, "[Deployment] exiting state init\n"); + break; + } + default: + { + break; + } + } +} + +void DeploymentController::state_idle(const Event& ev) +{ + switch (ev.code) + { + case EV_ENTRY: + { + logStatus(IDLE); + LOG_DEBUG(logger, "[Deployment] entering state idle\n"); + break; + } + case EV_EXIT: + { + LOG_DEBUG(logger, "[Deployment] exiting state idle\n"); + break; + } + case DPL_WIGGLE: + { + wiggle_servo(); + break; + } + case DPL_OPEN: + { + Actuators::getInstance().servoExpulsion.setPosition180Deg( + DPL_SERVO_EJECT_POS); + break; + } + case DPL_RESET: + { + + Actuators::getInstance().servoExpulsion.setPosition180Deg( + DPL_SERVO_RESET_POS); + break; + } + case DPL_OPEN_NC: + { + transition(&DeploymentController::state_nosecone_ejection); + break; + } + case DPL_CUT_DROGUE: + { + transition(&DeploymentController::state_cutting); + break; + } + default: + { + break; + } + } +} + +void DeploymentController::state_nosecone_ejection(const Event& ev) +{ + switch (ev.code) + { + case EV_ENTRY: + { + Actuators::getInstance().servoExpulsion.setPosition180Deg( + DPL_SERVO_EJECT_POS); + + ev_open_nc_timeout_id = sEventBroker.postDelayed<OPEN_NC_TIMEOUT>( + Boardcore::Event{DPL_OPEN_NC_TIMEOUT}, TOPIC_DPL); + + logStatus(NOSECONE_EJECTION); + LOG_DEBUG(logger, + "[Deployment] entering state nosecone_ejection\n"); + break; + } + case EV_EXIT: + { + LOG_DEBUG(logger, "[Deployment] exiting state nosecone_ejection\n"); + break; + } + case DPL_OPEN_NC_TIMEOUT: + { + transition(&DeploymentController::state_idle); + break; + } + case FLIGHT_NC_DETACHED: + { + sEventBroker.removeDelayed(ev_open_nc_timeout_id); + transition(&DeploymentController::state_idle); + break; + } + default: + { + break; + } + } +} + +void DeploymentController::state_cutting(const Event& ev) +{ + switch (ev.code) + { + case EV_ENTRY: + { + start_cutting(); + + ev_nc_cutting_timeout_id = sEventBroker.postDelayed<CUT_DURATION>( + Boardcore::Event{DPL_CUT_TIMEOUT}, TOPIC_DPL); + + logStatus(CUTTING); + LOG_DEBUG(logger, "[Deployment] entering state cutting\n"); + break; + } + case EV_EXIT: + { + LOG_DEBUG(logger, "[Deployment] exiting state cutting\n"); + break; + } + case DPL_CUT_TIMEOUT: + { + stop_cutting(); + transition(&DeploymentController::state_idle); + break; + } + default: + { + break; + } + } +} + +void DeploymentController::wiggle_servo() +{ + for (int i = 0; i < 2; i++) + { + Actuators::getInstance().servoExpulsion.setPosition180Deg( + DPL_SERVO_RESET_POS - DPL_SERVO_WIGGLE_AMPLITUDE); + miosix::Thread::sleep(500); + Actuators::getInstance().servoExpulsion.setPosition180Deg( + DPL_SERVO_RESET_POS); + miosix::Thread::sleep(500); + } +} + +void DeploymentController::start_cutting() +{ + // TODO: Change with actual cutter + Actuators::getInstance().led1.high(); +} + +void DeploymentController::stop_cutting() +{ + // TODO: Change with actual cutter + Actuators::getInstance().led1.low(); +} + +void DeploymentController::logStatus(DeploymentControllerState state) +{ + status.timestamp = TimestampTimer::getInstance().getTimestamp(); + status.state = state; + + Logger::getInstance().log(status); +} + +} // namespace MainComputer diff --git a/src/boards/Main/Deployment/DeploymentController.h b/src/boards/Main/Deployment/DeploymentController.h new file mode 100644 index 0000000000000000000000000000000000000000..17502a6ef5c2cef975f82e1a20a3c684b1075e78 --- /dev/null +++ b/src/boards/Main/Deployment/DeploymentController.h @@ -0,0 +1,59 @@ +/* Copyright (c) 2022 Skyward Experimental Rocketry + * Author: Alberto Nidasio + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include <diagnostic/PrintLogger.h> +#include <events/FSM.h> + +#include "DeploymentData.h" + +namespace MainComputer +{ + +class DeploymentController : public Boardcore::FSM<DeploymentController> +{ +public: + DeploymentController(); + ~DeploymentController(); + + void state_init(const Boardcore::Event& ev); + void state_idle(const Boardcore::Event& ev); + void state_nosecone_ejection(const Boardcore::Event& ev); + void state_cutting(const Boardcore::Event& ev); + +private: + DeploymentControllerStatus status; + + void wiggle_servo(); + void start_cutting(); + void stop_cutting(); + + void logStatus(DeploymentControllerState state); + + uint16_t ev_open_nc_timeout_id = 0; + uint16_t ev_nc_cutting_timeout_id = 0; + + Boardcore::PrintLogger logger = Boardcore::Logging::getLogger("main.dpl"); +}; + +} // namespace MainComputer diff --git a/src/boards/Main/Deployment/DeploymentData.h b/src/boards/Main/Deployment/DeploymentData.h new file mode 100644 index 0000000000000000000000000000000000000000..61e399e65819c12ee38f816d26bebc936df27d0f --- /dev/null +++ b/src/boards/Main/Deployment/DeploymentData.h @@ -0,0 +1,60 @@ +/* Copyright (c) 2022 Skyward Experimental Rocketry + * Author: Alberto Nidasio + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include <stdint.h> + +#include <iostream> +#include <string> + +namespace MainComputer +{ + +/** + * Enum defining the possible FSM states. + */ +enum DeploymentControllerState : uint8_t +{ + INIT = 0, + IDLE, + NOSECONE_EJECTION, + CUTTING, +}; + +/** + * Structure defining the overall controller status. + */ +struct DeploymentControllerStatus +{ + long long timestamp; + DeploymentControllerState state; + + static std::string header() { return "timestamp,state\n"; } + + void print(std::ostream& os) const + { + os << timestamp << "," << (int)state << "\n"; + } +}; + +} // namespace MainComputer diff --git a/src/boards/Main/events/EventStrings.cpp b/src/boards/Main/events/EventStrings.cpp new file mode 100644 index 0000000000000000000000000000000000000000..65008ebed06378f83cb3d2f0db6efebc461eb9e3 --- /dev/null +++ b/src/boards/Main/events/EventStrings.cpp @@ -0,0 +1,61 @@ +/* Copyright (c) 2018-2020 Skyward Experimental Rocketry + * Authors: Luca Erbetta, Alvise de' Faveri Tron + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/* + ****************************************************************************** + * THIS FILE IS AUTOGENERATED. DO NOT EDIT. * + ****************************************************************************** + */ + +// Autogen date: 2022-02-06 19:56:00.244476 + +#include <map> +using std::map; + +#include "Events.h" +#include "Topics.h" + +string getEventString(uint8_t event) +{ + static const map<uint8_t, string> event_string_map{ + {DPL_CUT_DROGUE, "DPL_CUT_DROGUE"}, + {DPL_CUT_TIMEOUT, "DPL_CUT_TIMEOUT"}, + {DPL_OPEN, "DPL_OPEN"}, + {DPL_OPEN_NC, "DPL_OPEN_NC"}, + {DPL_OPEN_NC_TIMEOUT, "DPL_OPEN_NC_TIMEOUT"}, + {DPL_RESET, "DPL_RESET"}, + {DPL_WIGGLE, "DPL_WIGGLE"}, + {FLIGHT_NC_DETACHED, "FLIGHT_NC_DETACHED"}, + }; + auto it = event_string_map.find(event); + return it == event_string_map.end() ? "EV_UNKNOWN" : it->second; +} + +string getTopicString(uint8_t topic) +{ + static const map<uint8_t, string> topic_string_map{ + {TOPIC_DPL, "TOPIC_DPL"}, + {TOPIC_FLIGHT, "TOPIC_FLIGHT"}, + }; + auto it = topic_string_map.find(topic); + return it == topic_string_map.end() ? "TOPIC_UNKNOWN" : it->second; +} diff --git a/src/boards/Main/events/Events.h b/src/boards/Main/events/Events.h new file mode 100644 index 0000000000000000000000000000000000000000..6b0d79bbe2b49a7ebe621db09fa2b00045cfff4d --- /dev/null +++ b/src/boards/Main/events/Events.h @@ -0,0 +1,71 @@ +/* Copyright (c) 2018-2022 Skyward Experimental Rocketry + * Authors: Luca Erbetta, Alvise de' Faveri Tron + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/* + ****************************************************************************** + * THIS FILE IS AUTOGENERATED. DO NOT EDIT. * + ****************************************************************************** + */ + +// Autogen date: 2022-02-06 19:56:00.244476 + +#pragma once + +#include <events/Event.h> +#include <events/EventBroker.h> + +#include <cstdint> +#include <string> +#include <vector> + +#include "Topics.h" + +using std::string; + +/** + * Definition of all events in the Board software. + * Refer to the Software Design Document. + */ +enum Events : uint8_t +{ + DPL_CUT_DROGUE = Boardcore::EV_FIRST_SIGNAL, + DPL_CUT_TIMEOUT, + DPL_OPEN, + DPL_OPEN_NC, + DPL_OPEN_NC_TIMEOUT, + DPL_RESET, + DPL_WIGGLE, + FLIGHT_NC_DETACHED, +}; + +const std::vector<uint8_t> EVENT_LIST{ + DPL_CUT_DROGUE, DPL_CUT_TIMEOUT, DPL_OPEN, DPL_OPEN_NC, + DPL_OPEN_NC_TIMEOUT, DPL_RESET, DPL_WIGGLE, FLIGHT_NC_DETACHED, +}; + +/** + * @brief Returns the name of the provided event + * + * @param event + * @return string + */ +string getEventString(uint8_t event); diff --git a/src/boards/Main/events/Topics.h b/src/boards/Main/events/Topics.h new file mode 100644 index 0000000000000000000000000000000000000000..3bad1b982a95326448d4f9e7b4227fa3d05b8829 --- /dev/null +++ b/src/boards/Main/events/Topics.h @@ -0,0 +1,59 @@ +/* Copyright (c) 2018-2022 Skyward Experimental Rocketry + * Authors: Luca Erbetta, Alvise de' Faveri Tron + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/* + ****************************************************************************** + * THIS FILE IS AUTOGENERATED. DO NOT EDIT. * + ****************************************************************************** + */ + +// Autogen date: 2022-02-06 19:56:00.244476 + +#pragma once + +#include <cstdint> +#include <string> +#include <vector> + +using std::string; + +/** + * Definition of various event topics to use in the EventBroker + */ +enum Topics : uint8_t +{ + TOPIC_DPL, + TOPIC_FLIGHT, +}; + +const std::vector<uint8_t> TOPIC_LIST{ + TOPIC_DPL, + TOPIC_FLIGHT, +}; + +/** + * @brief Returns the name of the provided event + * + * @param event + * @return string + */ +string getTopicString(uint8_t topic); diff --git a/src/tests/Main/catch/catch-tests-entry.cpp b/src/tests/Main/catch/catch-tests-entry.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1b970e126204eba4f2976fe22ece8fa787d161f3 --- /dev/null +++ b/src/tests/Main/catch/catch-tests-entry.cpp @@ -0,0 +1,155 @@ +/* Copyright (c) 2019 Skyward Experimental Rocketry + * Author: Luca Erbetta + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/* + * Entrypoint for all Catch1-based tests. You should not need to modify this + * file. + * + * To add a test, just create a new source file and include <catch.hpp>, then + * add test cases as you wish. Do not add a main() function in your test + * sources. + * Once the test is written, compile the test source file(s) + this entrypoint + * in sbs.conf. Run it and all your test will be automatically executed. + * + * You can also include this file in your test source if you want to run it as a + * standalone test, and not togheter with all the others. See the + * skyward-boardcore wiki at: <link here> for more information. + * + * You can specify command line options such as "-s" to display messages for + * succesfull tests (and not only messages for the ones that fail), plus others. + * You can also add tags in order to specify which tests you want to be + * executed. For a list of the command line arguments, take a look at: + * https://github.com/catchorg/Catch2/blob/Catch1.x/docs/command-line.md + * + * To specify the command line options, add, in the definition of the entrypoint + * in sbs.conf, add the CATCH1_CL_OPTIONS define. + * Example: -DCATCH1_CL_OPTIONS="\"[tag1][tag2] -s\"" + * Remember to correctly escape the quotation marks, as shown + * above. + * + * Further information at: + * https://git.skywarder.eu/r2a/skyward-boardcore/wikis/Testing + */ + +#define CATCH_CONFIG_RUNNER +#define CATCH_CONFIG_NO_POSIX_SIGNALS + +#include <miosix.h> + +#include <catch2/catch.hpp> +#include <cstring> +#include <string> +#include <vector> + +using miosix::Thread; +using std::string; +using std::vector; + +// No tags or command line options as default. +#ifndef CATCH1_CL_OPTIONS +#define CATCH1_CL_OPTIONS "" +#endif + +/** + * @brief Splits a string around spaces + * Eg: "This is a string" -> {"This", "is", "a", "string"} + * + * @param str String to split + * @return vector<string> + */ +vector<string> splitSpaces(string str) +{ + unsigned int p = 0; + bool end = false; + vector<string> out; + + do + { + unsigned int p2 = str.find(" ", p); + + if (p2 == string::npos) // No match + { + p2 = str.length(); + end = true; + } + + size_t len = p2 - p; // Length of the substring + + if (len > 0) + { + out.push_back(str.substr(p, len)); + } + p = p2 + 1; + } while (!end); + + return out; +} + +/** + * @brief Entrypoint for the tests. Parses the options and tags + * provided in sbs.conf and runs a Catch1 session. + */ +int main() +{ + // Parse command line arguments from #defines in sbs.conf + + string skw{"Skyward-tests"}; + + // CATCH1_CL_OPTIONS defined in sbs.conf + string options_str{CATCH1_CL_OPTIONS}; + + vector<string> options = splitSpaces(options_str); + vector<string> args{skw}; + + if (options.size() > 0) + args.insert(args.end(), options.begin(), options.end()); + + // Convert vector of strings to array of c-strings + size_t argc = args.size(); + + char** argv = + new char*[argc]; // Array of c strings, aka array of char pointers + for (size_t i = 0; i < argc; i++) + { + string s = args.at(i); + char* c_arg = new char[s.length() + 1]; + strcpy(c_arg, s.c_str()); + argv[i] = c_arg; + } + + // Run tests with the provided arguments + Catch::Session().run(argc, argv); + + // Clear memory + for (size_t i = 0; i < argc; i++) + { + delete[] argv[i]; + } + delete[] argv; + + printf("End.\n"); + // Infinite loop to avoid board reset each time we return + for (;;) + { + Thread::sleep(10000); + } +} diff --git a/src/tests/Main/catch/test-deployment.cpp b/src/tests/Main/catch/test-deployment.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4ff05896b77e5b895c9dc4ad112c7488dcf11131 --- /dev/null +++ b/src/tests/Main/catch/test-deployment.cpp @@ -0,0 +1,133 @@ +/* Copyright (c) 2022 Skyward Experimental Rocketry + * Author: Alberto Nidasio + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// We need access to the handleEvent(...) function in state machines in order to +// test them synchronously +#define protected public + +#include <Main/Deployment/DeploymentController.h> +#include <Main/events/Events.h> +#include <miosix.h> +#include <utils/testutils/TestHelper.h> + +#include <catch2/catch.hpp> + +using namespace miosix; +using namespace Boardcore; +using namespace MainComputer; + +class DeploymentControllerFixture +{ +public: + // This is called at the beginning of each test / section + DeploymentControllerFixture() + { + // cppcheck-suppress noCopyConstructor + // cppcheck-suppress noOperatorEq + controller = new DeploymentController(); + sEventBroker.start(); + controller->start(); + } + + // This is called at the end of each test / section + ~DeploymentControllerFixture() + { + controller->stop(); + sEventBroker.unsubscribe(controller); + sEventBroker.clearDelayedEvents(); + delete controller; + } + +protected: + DeploymentController* controller; +}; + +TEST_CASE_METHOD(DeploymentControllerFixture, "Testing transitions from init") +{ + controller->transition(&DeploymentController::state_init); +} + +TEST_CASE_METHOD(DeploymentControllerFixture, "Testing transitions from idle") +{ + controller->transition(&DeploymentController::state_idle); + + SECTION("WIGGLE -> IDLE") + { + REQUIRE(testFSMTransition(*controller, Event{DPL_WIGGLE}, + &DeploymentController::state_idle)); + } + + SECTION("OPEN -> IDLE") + { + REQUIRE(testFSMTransition(*controller, Event{DPL_OPEN}, + &DeploymentController::state_idle)); + } + + SECTION("RESET -> IDLE") + { + REQUIRE(testFSMTransition(*controller, Event{DPL_RESET}, + &DeploymentController::state_idle)); + } + + SECTION("OPEN_NC -> NOSECONE_EJECTION") + { + REQUIRE( + testFSMTransition(*controller, Event{DPL_OPEN_NC}, + &DeploymentController::state_nosecone_ejection)); + } + + SECTION("CUT_DROGUE -> CUTTING") + { + REQUIRE(testFSMTransition(*controller, Event{DPL_CUT_DROGUE}, + &DeploymentController::state_cutting)); + } +} + +TEST_CASE_METHOD(DeploymentControllerFixture, + "Testing transitions from nosecone_ejection") +{ + controller->transition(&DeploymentController::state_nosecone_ejection); + + SECTION("OPEN_NC_TIMEOUT -> IDLE") + { + REQUIRE(testFSMTransition(*controller, Event{DPL_OPEN_NC_TIMEOUT}, + &DeploymentController::state_idle)); + } + + SECTION("NC_DETACHED -> IDLE") + { + REQUIRE(testFSMTransition(*controller, Event{FLIGHT_NC_DETACHED}, + &DeploymentController::state_idle)); + } +} + +TEST_CASE_METHOD(DeploymentControllerFixture, + "Testing transitions from cutting") +{ + controller->transition(&DeploymentController::state_cutting); + + SECTION("CUT_TIMEOUT -> IDLE") + { + REQUIRE(testFSMTransition(*controller, Event{DPL_CUT_TIMEOUT}, + &DeploymentController::state_idle)); + } +}