diff --git a/CMakeLists.txt b/CMakeLists.txt index a013cb2a0cbccb8904b40f631bcd2d00ead24c70..859b26d6f03a33685ddb376ac00fb9c68709b112 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ sbs_target(auxiliary-entry stm32f429zi_skyward_pyxis_auxiliary) add_executable(main-entry-euroc src/entrypoints/Main/main-entry.cpp ${MAIN_COMPUTER}) target_include_directories(main-entry-euroc PRIVATE ${OBSW_INCLUDE_DIRS}) -target_compile_definitions(main-entry-euroc PRIVATE EUROC BUZZER_LOW INTERP) +target_compile_definitions(main-entry-euroc PRIVATE EUROC BUZZER_LOW INTERP USE_SERIAL_TRANSCEIVER) sbs_target(main-entry-euroc stm32f429zi_skyward_death_stack_v3) add_executable(main-entry-roccaraso src/entrypoints/Main/main-entry.cpp ${MAIN_COMPUTER}) @@ -54,7 +54,7 @@ sbs_target(main-entry-milano stm32f429zi_skyward_death_stack_v3) add_executable(main-entry-hil-euroc src/entrypoints/Main/main-entry.cpp ${MAIN_COMPUTER} ${HIL}) target_include_directories(main-entry-hil-euroc PRIVATE ${OBSW_INCLUDE_DIRS}) -target_compile_definitions(main-entry-hil-euroc PRIVATE HILSimulation EUROC BUZZER_LOW INTERP) +target_compile_definitions(main-entry-hil-euroc PRIVATE HILSimulation EUROC BUZZER_LOW INTERP USE_SERIAL_TRANSCEIVER) sbs_target(main-entry-hil-euroc stm32f429zi_skyward_death_stack_v3) add_executable(main-entry-hil-roccaraso src/entrypoints/Main/main-entry.cpp ${MAIN_COMPUTER} ${HIL}) diff --git a/skyward-boardcore b/skyward-boardcore index cb195bf7c6263d81228e9647892806cdeddd5cb3..e60ca34f7557877779f3da84d33a76ca0e1d84d5 160000 --- a/skyward-boardcore +++ b/skyward-boardcore @@ -1 +1 @@ -Subproject commit cb195bf7c6263d81228e9647892806cdeddd5cb3 +Subproject commit e60ca34f7557877779f3da84d33a76ca0e1d84d5 diff --git a/src/boards/Main/Configs/AirBrakesControllerConfigInterp.h b/src/boards/Main/Configs/AirBrakesControllerConfigInterp.h index 22e27612fc65b4e444260267e0434327bdd4c332..4bbc8d30774a39c0f420598286ba6e59e4e6fde5 100644 --- a/src/boards/Main/Configs/AirBrakesControllerConfigInterp.h +++ b/src/boards/Main/Configs/AirBrakesControllerConfigInterp.h @@ -31,7 +31,7 @@ namespace Main namespace AirBrakesControllerConfig { -static const Boardcore::AirBrakesInterpConfig ABK_CONFIG_INTERP{ +static const Boardcore::AirBrakesInterpConfig ABK_CONFIG_ALG{ .INITIAL_FILTER_COEFF = 0.3, .INITIAL_T_FILTER = 12, .DELTA_T_FILTER = 2.5, diff --git a/src/boards/Main/Configs/AirBrakesControllerConfigPI.h b/src/boards/Main/Configs/AirBrakesControllerConfigPI.h index e2696756f531b63b310d053a598bee81640d6540..f0d67a9f0aeed319b250fdc80c07deef1f828efb 100644 --- a/src/boards/Main/Configs/AirBrakesControllerConfigPI.h +++ b/src/boards/Main/Configs/AirBrakesControllerConfigPI.h @@ -31,7 +31,7 @@ namespace Main namespace AirBrakesControllerConfig { -static const Boardcore::AirBrakesPIConfig ABK_CONFIG_PI{ +static const Boardcore::AirBrakesPIConfig ABK_CONFIG_ALG{ .KP = 20, .KI = 5, .TS = UPDATE_PERIOD / 1000.0}; } // namespace AirBrakesControllerConfig diff --git a/src/boards/Main/Radio/Radio.cpp b/src/boards/Main/Radio/Radio.cpp index a8b4a27d238fa2332fbdd5c65318c8cca313c04d..7bdc19aade5612aa6f59f46fc71838aab0ccf7e3 100644 --- a/src/boards/Main/Radio/Radio.cpp +++ b/src/boards/Main/Radio/Radio.cpp @@ -96,7 +96,7 @@ Radio::Radio() { #if defined(USE_SERIAL_TRANSCEIVER) Boardcore::SerialTransceiver* transceiver; - transceiver = new SerialTransceiver(Buses::getInstance().usart2); + transceiver = new SerialTransceiver(Buses::getInstance().usart1); #elif defined(USE_XBEE_TRANSCEIVER) SPIBusConfig config; config.clockDivider = SPI::ClockDivider::DIV_16; diff --git a/src/boards/Main/StateMachines/AirBrakesController/AirBrakesController.cpp b/src/boards/Main/StateMachines/AirBrakesController/AirBrakesController.cpp index 8996ae207a1e9b2a3f0a8f1aeb94d6cf6e78bfea..f4fad290417aeb5d2175dfb68468ff1066894f0d 100644 --- a/src/boards/Main/StateMachines/AirBrakesController/AirBrakesController.cpp +++ b/src/boards/Main/StateMachines/AirBrakesController/AirBrakesController.cpp @@ -197,7 +197,6 @@ void AirBrakesController::state_end(const Event& event) AirBrakesController::AirBrakesController() : FSM(&AirBrakesController::state_init), abk( -#ifndef INTERP #ifndef HILMockNAS []() { return TimedTrajectoryPoint{ @@ -207,28 +206,16 @@ AirBrakesController::AirBrakesController() []() { return Sensors::getInstance().state.kalman->getLastSample(); }, #endif // HILMockNAS TRAJECTORY_SET, AirBrakesControllerConfig::ABK_CONFIG, - AirBrakesControllerConfig::ABK_CONFIG_PI, + AirBrakesControllerConfig::ABK_CONFIG_ALG, [](float position) { Actuators::getInstance().setServo(ServosList::AIR_BRAKES_SERVO, position); - }) -#else // INTERP -#ifndef HILMockNAS - []() { - return TimedTrajectoryPoint{ - NASController::getInstance().getNasState()}; - }, -#else // HILMockNAS - []() { return Sensors::getInstance().state.kalman->getLastSample(); }, -#endif // HILMockNAS - TRAJECTORY_SET, AirBrakesControllerConfig::ABK_CONFIG, - AirBrakesControllerConfig::ABK_CONFIG_INTERP, - [](float position) { - Actuators::getInstance().setServo(ServosList::AIR_BRAKES_SERVO, - position); - }, - Main::dz) + } +#ifdef INTERP + , + Main::dz #endif // INTERP + ) { EventBroker::getInstance().subscribe(this, TOPIC_ABK); EventBroker::getInstance().subscribe(this, TOPIC_FLIGHT); diff --git a/src/hardware_in_the_loop/HIL_sensors/HILAccelerometer.h b/src/hardware_in_the_loop/HIL_sensors/HILAccelerometer.h index 1d630feacbf34241d1ecc21ddf9e9460352afd74..806b7e04f667452be67d319c753ae059ac2c7440 100644 --- a/src/hardware_in_the_loop/HIL_sensors/HILAccelerometer.h +++ b/src/hardware_in_the_loop/HIL_sensors/HILAccelerometer.h @@ -22,6 +22,8 @@ #pragma once +#include <logger/Logger.h> + #include "HILSensor.h" /** @@ -51,6 +53,8 @@ protected: tempData.accelerationZ = matlabData.getZ(); tempData.accelerationTimestamp = updateTimestamp(); + Boardcore::Logger::getInstance().log(tempData); + return tempData; } -}; \ No newline at end of file +}; diff --git a/src/hardware_in_the_loop/HIL_sensors/HILBarometer.h b/src/hardware_in_the_loop/HIL_sensors/HILBarometer.h index 425a92aa0dea33b990ccedf525b7b9b1c6c0b4a8..99f1ccfe6584dced172ddb120ff41f489fd592d0 100644 --- a/src/hardware_in_the_loop/HIL_sensors/HILBarometer.h +++ b/src/hardware_in_the_loop/HIL_sensors/HILBarometer.h @@ -22,6 +22,8 @@ #pragma once +#include <logger/Logger.h> + #include "HILSensor.h" /** @@ -44,6 +46,8 @@ protected: tempData.pressure = sensorData->barometer.measures[sampleCounter]; tempData.pressureTimestamp = updateTimestamp(); + Boardcore::Logger::getInstance().log(tempData); + return tempData; } -}; \ No newline at end of file +}; diff --git a/src/hardware_in_the_loop/HIL_sensors/HILGps.h b/src/hardware_in_the_loop/HIL_sensors/HILGps.h index cc3c775590f11467b735973be2de69c3aa762b17..8601d869901df10563d806bc484d64263dbd2010 100644 --- a/src/hardware_in_the_loop/HIL_sensors/HILGps.h +++ b/src/hardware_in_the_loop/HIL_sensors/HILGps.h @@ -22,6 +22,8 @@ #pragma once +#include <logger/Logger.h> + #include <cmath> #include "HILSensor.h" @@ -64,6 +66,8 @@ protected: tempData.gpsTimestamp = updateTimestamp(); + Boardcore::Logger::getInstance().log(tempData); + return tempData; } }; diff --git a/src/hardware_in_the_loop/HIL_sensors/HILGyroscope.h b/src/hardware_in_the_loop/HIL_sensors/HILGyroscope.h index 1a2dc3f5ddcec50d273b1ee907d0eab1042c136f..840ace99aba1bfe89fa0f87243098355b59d1596 100644 --- a/src/hardware_in_the_loop/HIL_sensors/HILGyroscope.h +++ b/src/hardware_in_the_loop/HIL_sensors/HILGyroscope.h @@ -22,6 +22,8 @@ #pragma once +#include <logger/Logger.h> + #include "HILSensor.h" /** @@ -50,6 +52,8 @@ protected: tempData.angularVelocityZ = matlabData.getZ(); tempData.angularVelocityTimestamp = updateTimestamp(); + Boardcore::Logger::getInstance().log(tempData); + return tempData; } -}; \ No newline at end of file +}; diff --git a/src/hardware_in_the_loop/HIL_sensors/HILImu.h b/src/hardware_in_the_loop/HIL_sensors/HILImu.h index 6c2ee30ac6744c197d02d5c8aac368c29de2e3ea..22daa1a93762495965af7ea4ac843a761a516ce7 100644 --- a/src/hardware_in_the_loop/HIL_sensors/HILImu.h +++ b/src/hardware_in_the_loop/HIL_sensors/HILImu.h @@ -22,6 +22,8 @@ #pragma once +#include <logger/Logger.h> + #include "HILAccelerometer.h" #include "HILGyroscope.h" #include "HILMagnetometer.h" @@ -69,6 +71,8 @@ protected: tempData.angularVelocityTimestamp = tempData.accelerationTimestamp; tempData.magneticFieldTimestamp = tempData.accelerationTimestamp; + Boardcore::Logger::getInstance().log(tempData); + return tempData; } }; diff --git a/src/hardware_in_the_loop/HIL_sensors/HILMagnetometer.h b/src/hardware_in_the_loop/HIL_sensors/HILMagnetometer.h index 9df731985243a66b02d54e888b164d1489a96813..269b449a23ed0db7d45234329093ac31c593ea84 100644 --- a/src/hardware_in_the_loop/HIL_sensors/HILMagnetometer.h +++ b/src/hardware_in_the_loop/HIL_sensors/HILMagnetometer.h @@ -22,6 +22,8 @@ #pragma once +#include <logger/Logger.h> + #include "HILSensor.h" /** @@ -52,6 +54,8 @@ protected: matlabData.getZ() / 1000.0f; // from nanotesla to microtesla tempData.magneticFieldTimestamp = updateTimestamp(); + Boardcore::Logger::getInstance().log(tempData); + return tempData; } }; diff --git a/src/hardware_in_the_loop/HIL_sensors/HILPitot.h b/src/hardware_in_the_loop/HIL_sensors/HILPitot.h index cf87bec71ba3d6cc7c8a0a9097e3dfc06eab5547..9fabdc85be944bd998cbdba7497577b8746d20d6 100644 --- a/src/hardware_in_the_loop/HIL_sensors/HILPitot.h +++ b/src/hardware_in_the_loop/HIL_sensors/HILPitot.h @@ -22,6 +22,7 @@ #pragma once +#include <logger/Logger.h> #include <utils/AeroUtils/AeroUtils.h> #include "HILSensor.h" @@ -50,6 +51,8 @@ protected: Boardcore::Aeroutils::relDensity(sensorData->barometer.measures[0]); tempData.airspeed = sqrtf(2 * fabs(tempData.deltaP) / airDensity); + Boardcore::Logger::getInstance().log(tempData); + return tempData; } -}; \ No newline at end of file +}; diff --git a/src/hardware_in_the_loop/HIL_sensors/HILSensorsData.h b/src/hardware_in_the_loop/HIL_sensors/HILSensorsData.h index 62f276016a30710f034397199d6a2ace20c5ddf0..34b9ea3e58f3bcdf30767dff551fabc3f5dedc6e 100644 --- a/src/hardware_in_the_loop/HIL_sensors/HILSensorsData.h +++ b/src/hardware_in_the_loop/HIL_sensors/HILSensorsData.h @@ -21,6 +21,7 @@ */ #include <sensors/SensorData.h> +#include <sensors/analog/Pitot/PitotData.h> struct HILAccelData : public Boardcore::AccelerometerData { diff --git a/src/hardware_in_the_loop/HIL_sensors/HILTemperature.h b/src/hardware_in_the_loop/HIL_sensors/HILTemperature.h index 5940f3a545ad6cc213a461983ccb6525972ddb0b..3d9ee61a322f90acce761aa7c25c1e638f1d0e71 100644 --- a/src/hardware_in_the_loop/HIL_sensors/HILTemperature.h +++ b/src/hardware_in_the_loop/HIL_sensors/HILTemperature.h @@ -22,6 +22,8 @@ #pragma once +#include <logger/Logger.h> + #include "HILSensor.h" /** @@ -44,6 +46,8 @@ protected: tempData.temperature = sensorData->temperature.measure; tempData.temperatureTimestamp = updateTimestamp(); + Boardcore::Logger::getInstance().log(tempData); + return tempData; } -}; \ No newline at end of file +}; diff --git a/src/scripts/logdecoder/Main/Makefile b/src/scripts/logdecoder/Main/Makefile index 6bbaf34fc2008754ca1425004f33514659c56baf..991e56ed0f6ffa2e83987d40c353e07be908762b 100644 --- a/src/scripts/logdecoder/Main/Makefile +++ b/src/scripts/logdecoder/Main/Makefile @@ -1,5 +1,5 @@ BOARDCORE := ../../../../skyward-boardcore/ -OBSW := ../../../../src/boards/ +OBSW := ../../../../src/ all: g++ -std=c++17 -O2 -o logdecoder logdecoder.cpp \ @@ -11,6 +11,7 @@ all: -I$(BOARDCORE)libs/eigen \ -I$(BOARDCORE)libs/tscpp \ -I$(BOARDCORE)src/shared \ - -I$(OBSW) + -I$(OBSW)hardware_in_the_loop \ + -I$(OBSW)boards clean: rm logdecoder diff --git a/src/scripts/logdecoder/Main/logdecoder.cpp b/src/scripts/logdecoder/Main/logdecoder.cpp index 6e8176338eb8c1d0441efb59c1b0d3c91e334642..05a1d64cec8e5f6e24027e02f15d9bc144661d9b 100644 --- a/src/scripts/logdecoder/Main/logdecoder.cpp +++ b/src/scripts/logdecoder/Main/logdecoder.cpp @@ -20,6 +20,7 @@ * THE SOFTWARE. */ +#include <HIL_sensors/HILSensorsData.h> #include <Main/StateMachines/ADAController/ADAControllerData.h> #include <Main/StateMachines/AirBrakesController/AirBrakesControllerData.h> #include <Main/StateMachines/Deployment/DeploymentData.h> @@ -127,6 +128,16 @@ void registerTypes(Deserializer& ds) ds.registerType<DeploymentStatus>(); ds.registerType<FlightModeManagerStatus>(); ds.registerType<NASControllerStatus>(); + + // HIL + ds.registerType<HILAccelData>(); + ds.registerType<HILGyroscopeData>(); + ds.registerType<HILMagnetometerData>(); + ds.registerType<HILImuData>(); + ds.registerType<HILGpsData>(); + ds.registerType<HILBaroData>(); + ds.registerType<HILPitotData>(); + ds.registerType<HILTempData>(); } void showUsage(const string& cmdName)