diff --git a/WST-FC/configuration_preprocesor.py b/WST-FC/configuration_preprocesor.py new file mode 100644 index 0000000..b767aa3 --- /dev/null +++ b/WST-FC/configuration_preprocesor.py @@ -0,0 +1,8 @@ +Import("env") +use_bt = env.GetProjectOption("use_bluestack", "no") + +if use_bt == "yes": + env.Append(CPPDEFINES=["USE_BLUEPAD32"]) + env.Append(PIOPLATFORMPACKAGES=[ + "framework-arduinoespressif32@https://github.com/maxgerhardt/pio-framework-bluepad32/archive/refs/heads/main.zip" + ]) \ No newline at end of file diff --git a/WST-FC/include/CommunicationModule.h b/WST-FC/include/CommunicationModule.h index 94a5f33..e959b15 100644 --- a/WST-FC/include/CommunicationModule.h +++ b/WST-FC/include/CommunicationModule.h @@ -9,13 +9,15 @@ #include "communicationModules\CommunicationWiFiUDPModule.h" #include "communicationModules\CommunicationESPNowModule.h" #include "communicationModules\CommunicationSerialModule.h" -#include "communicationModules\CommunicationGamepadModule.h" +#if (COMMUNICATION_METHOD == 3) + #include "communicationModules\CommunicationGamepadModule.h" +#endif class CommunicationModule { private: DroneControlData *sharedData; - ICommunicationInterface *communicationInterface; + std::vector communicationInterfaces; wl_status_t connectionStatus{WL_IDLE_STATUS}; DroneStatus *droneStatus; diff --git a/WST-FC/include/Configuration.h b/WST-FC/include/Configuration.h index 34cbd71..e249e8f 100644 --- a/WST-FC/include/Configuration.h +++ b/WST-FC/include/Configuration.h @@ -1,16 +1,17 @@ #ifndef CONFIGURATION_H #define CONFIGURATION_H -#define VEHICLE_TYPE_AIRBOAT +#define VEHICLE_TYPE_TANK -#define WIFI_SSID "AutisticDrones" -#define WIFI_PASSWORD "Autyzm2137" -#define UDP_CONTROLL_PORT 4210 #define MAX_ROGUE_TIME 1000 #define MIN_RSSI -80 -#define COMMUNICATION_METHOD 3 #define TELEMETRY_TIME 1000 +#define USE_WIFI_UDP +//#define USE_ESP_NOW +#define USE_SERIAL +//#define USE_GAMEPAD + enum DroneStatus { WORKS, @@ -28,4 +29,10 @@ enum DroneStatus #define WG_PEER_PUBLIC_KEY "KLUCZ_PUBLICZNY_SERWERA=" #endif +#if defined(USE_WIFI_UDP) || defined(USE_ESP_NOW) + #define WIFI_SSID "HPLOVER" + #define WIFI_PASSWORD "Autyzm2137!" + #define UDP_CONTROLL_PORT 4210 +#endif + #endif \ No newline at end of file diff --git a/WST-FC/include/DroneFactory.h b/WST-FC/include/DroneFactory.h new file mode 100644 index 0000000..57937e8 --- /dev/null +++ b/WST-FC/include/DroneFactory.h @@ -0,0 +1,16 @@ +#ifndef DRONEFACTORY_H +#define DRONEFACTORY_H + +#include +#include +#include "SensorsModule.h" +#include "modules/IModule.h" +#include "IMixer.h" + +class DroneFactory +{ +public: + static IMixer* BuildVehicle(SensorsModule& sensorsModule, std::vector& modules); +}; + +#endif \ No newline at end of file diff --git a/WST-FC/include/SystemRegistry.h b/WST-FC/include/SystemRegistry.h new file mode 100644 index 0000000..4f4e271 --- /dev/null +++ b/WST-FC/include/SystemRegistry.h @@ -0,0 +1,92 @@ +#ifndef SYSTEM_REGISTRY_H +#define SYSTEM_REGISTRY_H + +#include +#include + +enum ParamType { + PARAM_INT, + PARAM_FLOAT, + PARAM_DOUBLE, + PARAM_BOOL +}; + +struct ConfigParam { + const char* name; + void* ptr; + ParamType type; +}; + +class SystemRegistry { +private: + std::vector params; + SystemRegistry() {} + +public: + static SystemRegistry& GetInstance() { + static SystemRegistry instance; + return instance; + } + + void Register(const char* name, void* ptr, ParamType type) + { + params.push_back({name, ptr, type}); + } + + bool SetValue(const char* name, const char* valueStr) + { + for(const auto& param : params) + { + if(strcmp(param.name, name) == 0) + { + switch (param.type) { + case PARAM_INT: + *(int*)param.ptr = atoi(valueStr); + break; + case PARAM_FLOAT: + *(float*)param.ptr = atof(valueStr); + break; + case PARAM_DOUBLE: + *(double*)param.ptr = atof(valueStr); + break; + case PARAM_BOOL: + *(bool*)param.ptr = (atoi(valueStr) > 0); + break; + } + Serial.println("Value SET"); + return true; + } + } + Serial.println("There is no such variable"); + return false; + } + + void ReturnAllRegistryNames() + { + for(const auto& param : params) + { + Serial.print(param.name); + Serial.print(": "); + + switch (param.type) { + case PARAM_INT: + Serial.println(*(int*)param.ptr); + break; + case PARAM_FLOAT: + Serial.println(*(float*)param.ptr); + break; + case PARAM_DOUBLE: + Serial.println(*(double*)param.ptr); + break; + case PARAM_BOOL: + Serial.println(*(bool*)param.ptr); + break; + default: + Serial.println("UNSUPPORTED_TYPE"); + break; + } + } + } +}; + +#endif \ No newline at end of file diff --git a/WST-FC/include/communicationModules/CommunicationESPNowModule.h b/WST-FC/include/communicationModules/CommunicationESPNowModule.h index db6f052..37b1d50 100644 --- a/WST-FC/include/communicationModules/CommunicationESPNowModule.h +++ b/WST-FC/include/communicationModules/CommunicationESPNowModule.h @@ -11,9 +11,6 @@ class CommunicationESPNowModule : public ICommunicationInterface{ private: static CommunicationESPNowModule* instance; - DroneControlData *sharedData; - unsigned long lastUpdate{0}; - DroneStatus *droneStatus; ulong lastDataTime = 0; uint8_t broadcastAddress[6] {0xEC,0x64,0xC9,0xC4,0xA2,0x1A}; public: diff --git a/WST-FC/include/communicationModules/CommunicationGamepadModule.h b/WST-FC/include/communicationModules/CommunicationGamepadModule.h index 46a028e..e3942d8 100644 --- a/WST-FC/include/communicationModules/CommunicationGamepadModule.h +++ b/WST-FC/include/communicationModules/CommunicationGamepadModule.h @@ -1,6 +1,6 @@ #ifndef COMMUNICATIONGAMEPADMODULE_H #define COMMUNICATIONGAMEPADMODULE_H - +#ifdef USE_BLUEPAD32 #include "DroneData.h" #include "ICommunicationInterface.h" #include "Configuration.h" @@ -9,8 +9,6 @@ class CommunicationGamepadModule : public ICommunicationInterface { private: - DroneControlData *sharedData; - DroneStatus *droneStatus; GamepadPtr myGamepad = nullptr; public: @@ -27,4 +25,5 @@ class CommunicationGamepadModule : public ICommunicationInterface { static void onConnectedGamepad(GamepadPtr gp); static void onDisconnectedGamepad(GamepadPtr gp); }; +#endif #endif \ No newline at end of file diff --git a/WST-FC/include/communicationModules/CommunicationSerialModule.h b/WST-FC/include/communicationModules/CommunicationSerialModule.h index cf76732..6c5a5d0 100644 --- a/WST-FC/include/communicationModules/CommunicationSerialModule.h +++ b/WST-FC/include/communicationModules/CommunicationSerialModule.h @@ -8,14 +8,9 @@ class CommunicationSerialModule : public ICommunicationInterface{ private: - DroneControlData *sharedData; - unsigned long lastUpdate{0}; - DroneStatus *droneStatus; long lastDataTime = 0; - uint8_t inputBuffer[sizeof(DroneControlData)]; + uint8_t inputBuffer[128]; - const uint8_t HEADER_BYTE_1 = 0x44; // 'D' - const uint8_t HEADER_BYTE_2 = 0x43; // 'C' public: CommunicationSerialModule(DroneControlData *dataPtr, DroneStatus *status); void Init() override; diff --git a/WST-FC/include/communicationModules/CommunicationWiFiUDPModule.h b/WST-FC/include/communicationModules/CommunicationWiFiUDPModule.h index a376da8..b492b61 100644 --- a/WST-FC/include/communicationModules/CommunicationWiFiUDPModule.h +++ b/WST-FC/include/communicationModules/CommunicationWiFiUDPModule.h @@ -11,15 +11,12 @@ #endif class CommunicationWiFiUDPModule : public ICommunicationInterface{ private: - DroneControlData *sharedData; WiFiUDP udp; unsigned int localPort{0}; char packetBuffer[255]; - unsigned long lastUpdate{0}; int8_t rssi{0}; wl_status_t connectionStatus{WL_IDLE_STATUS}; - DroneStatus *droneStatus; IPAddress remoteIP; unsigned int remotePort {0}; diff --git a/WST-FC/include/communicationModules/ICommunicationInterface.h b/WST-FC/include/communicationModules/ICommunicationInterface.h index 62a82ee..3d38e58 100644 --- a/WST-FC/include/communicationModules/ICommunicationInterface.h +++ b/WST-FC/include/communicationModules/ICommunicationInterface.h @@ -2,7 +2,46 @@ #define ICOMMUNICATIONINTERFACE #include "../SensorsData.h" +#include "SystemRegistry.h" +#include "Configuration.h" class ICommunicationInterface{ +protected: + DroneControlData *sharedData; + DroneStatus *droneStatus; + unsigned long lastUpdate{0}; + + void ParseIncomingBytes(uint8_t* buffer, size_t len) + { + if (sharedData == nullptr || len < 2) return; + + if (len == sizeof(DroneControlData)) + { + memcpy(sharedData, buffer, sizeof(DroneControlData)); + lastUpdate = millis(); + } + else if (buffer[0] == 'S' && buffer[1] == 'E' && buffer[2] == 'T') + { + if (len < 64) buffer[len] = '\0'; + else buffer[63] = '\0'; + + char* str = (char*)buffer; + char* cmd = strtok(str, " "); + char* paramName = strtok(NULL, " "); + char* valueStr = strtok(NULL, " "); + + if (paramName != nullptr && valueStr != nullptr) + { + SystemRegistry::GetInstance().SetValue(paramName, valueStr); + } + } + else if (buffer[0] == 'G' && buffer[1] == 'E' && buffer[2] == 'T') + { + if (len < 64) buffer[len] = '\0'; + else buffer[63] = '\0'; + SystemRegistry::GetInstance().ReturnAllRegistryNames(); + } + } + public: virtual ~ICommunicationInterface(){} virtual void Init(); diff --git a/WST-FC/include/modules/CameraModule.h b/WST-FC/include/modules/CameraModule.h index d1fa098..906f406 100644 --- a/WST-FC/include/modules/CameraModule.h +++ b/WST-FC/include/modules/CameraModule.h @@ -27,7 +27,7 @@ #define HREF_GPIO_NUM 23 #define PCLK_GPIO_NUM 22 #define XCLK_FREQ_HZ 20000000 - #define JPEG_QUALITY 25 + #define JPEG_QUALITY 45 #define FB_COUNT 2 #define PART_BOUNDARY "123456789000000000000987654321" diff --git a/WST-FC/platformio.ini b/WST-FC/platformio.ini index 29ea818..d5a6f26 100644 --- a/WST-FC/platformio.ini +++ b/WST-FC/platformio.ini @@ -1,40 +1,39 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html +[platformio] +description = Advanced, gloriously over-engineered, and fundamentally unreasonable take on making things move. It is an open-source framework built to prove that the sweet spot of engineering lies exactly where "genuinely useful" meets "utterly insane." [env] platform = espressif32 -platform_packages = - framework-arduinoespressif32@https://github.com/maxgerhardt/pio-framework-bluepad32/archive/refs/heads/main.zip framework = arduino monitor_speed = 115200 +extra_scripts = pre:configuration_preprocesor.py +use_bluestack = no +monitor_echo = yes +monitor_filters = send_on_enter +build_flags = -DCORE_DEBUG_LEVEL=5 lib_deps = - adafruit/Adafruit MPU6050@^2.2.6 - adafruit/DHT sensor library@^1.4.6 - madhephaestus/ESP32Servo@^3.0.9 - br3ttb/PID@^1.2.1 - adafruit/Adafruit ADXL345@^1.3.4 - adafruit/Adafruit Unified Sensor@^1.1.14 - ciniml/WireGuard-ESP32 @ ^0.1.5 + adafruit/Adafruit MPU6050@^2.2.6 + adafruit/DHT sensor library@^1.4.6 + madhephaestus/ESP32Servo@^3.0.9 + br3ttb/PID@^1.2.1 + adafruit/Adafruit ADXL345@^1.3.4 + adafruit/Adafruit Unified Sensor@^1.1.14 + ciniml/WireGuard-ESP32 @ ^0.1.5 [env:esp32doit-devkit-v1] board = esp32doit-devkit-v1 -build_flags = - -D CORE_DEBUG_LEVEL=3 board_build.partitions = huge_app.csv [env:esp32-c3-super-mini] board = esp32-c3-devkitm-1 build_flags = - -D ARDUINO_USB_MODE=1 - -D ARDUINO_USB_CDC_ON_BOOT=1 - -D CORE_DEBUG_LEVEL=0 + -D ARDUINO_USB_MODE=1 + -D ARDUINO_USB_CDC_ON_BOOT=1 [env:esp32cam] -board = esp32cam \ No newline at end of file +board = esp32cam +platform_packages = + framework-arduinoespressif32 +framework = arduino +build_flags = + -D BOARD_HAS_PSRAM + -mfix-esp32-psram-cache-issue diff --git a/WST-FC/src/CommunicationModule.cpp b/WST-FC/src/CommunicationModule.cpp index b2adbfc..2ee1666 100644 --- a/WST-FC/src/CommunicationModule.cpp +++ b/WST-FC/src/CommunicationModule.cpp @@ -9,34 +9,40 @@ CommunicationModule::CommunicationModule(DroneControlData *dataPtr, DroneStatus void CommunicationModule::Init() { - if(COMMUNICATION_METHOD == 0){ - communicationInterface = new CommunicationWiFiUDPModule(sharedData, UDP_CONTROLL_PORT, droneStatus); - } - if(COMMUNICATION_METHOD == 1){ - communicationInterface = new CommunicationESPNowModule(sharedData, droneStatus); - } - if(COMMUNICATION_METHOD == 2){ - communicationInterface = new CommunicationSerialModule(sharedData, droneStatus); - } - if(COMMUNICATION_METHOD == 3){ - communicationInterface = new CommunicationGamepadModule(sharedData, droneStatus); - } + #ifdef USE_WIFI_UDP + communicationInterfaces.push_back(new CommunicationWiFiUDPModule(sharedData, UDP_CONTROLL_PORT, droneStatus)); + #endif + + #ifdef USE_ESP_NOW + communicationInterfaces.push_back( new CommunicationESPNowModule(sharedData, droneStatus)); + #endif + + #ifdef USE_SERIAL + communicationInterfaces.push_back(new CommunicationSerialModule(sharedData, droneStatus)); + #endif - if(communicationInterface == nullptr) + #ifdef USE_GAMEPAD + communicationInterfaces.push_back(new CommunicationGamepadModule(sharedData, droneStatus)); + #endif + + for(auto interface : communicationInterfaces) { - //Critical error!!! - }else{ - communicationInterface->Init(); + interface->Init(); } + } void CommunicationModule::Loop() { - if(communicationInterface == nullptr) return; - communicationInterface -> Loop(); + for(auto interface : communicationInterfaces) + { + interface->Loop(); + }; } void CommunicationModule::SendData(SensorsData* data) { - if(communicationInterface == nullptr) return; - communicationInterface->SendData(data); + for(auto interface : communicationInterfaces) + { + interface->SendData(data); + }; } \ No newline at end of file diff --git a/WST-FC/src/DroneFactory.cpp b/WST-FC/src/DroneFactory.cpp new file mode 100644 index 0000000..3c0f38e --- /dev/null +++ b/WST-FC/src/DroneFactory.cpp @@ -0,0 +1,50 @@ +#include "DroneFactory.h" + +#ifdef VEHICLE_TYPE_BICOPTER + #include "BicopterMixer.h" + #include "sensors/MpuSensor.h" + MpuSensor mpuSensor; +#endif + +#ifdef VEHICLE_TYPE_AIRBOAT + #include "AirBoatMixer.h" + #include "sensors/AdxlSensor.h" + DCMotor motorL(16, 17, 4, 0); + DCMotor motorR(18, 19, 5, 1); + AdxlSensor adxlSensor; +#endif + +#ifdef VEHICLE_TYPE_TANK + #include "AirBoatMixer.h" + #include "modules/CameraModule.h" + #include "sensors/HCSR04Sensor.h" + DCMotor motorL(13, 14, 0); + DCMotor motorR(15, 2, 1); +#endif + +IMixer* DroneFactory::BuildVehicle(SensorsModule& sensorsModule, std::vector& modules) +{ + IMixer* droneMixer = nullptr; + + #ifdef VEHICLE_TYPE_BICOPTER + Serial.println("Configuring as BICOPTER"); + sensorsModule.AddSensor(&mpuSensor); + droneMixer = new BicopterMixer(); + #endif + + #ifdef VEHICLE_TYPE_AIRBOAT + Serial.println("Configuring as AIRBOAT"); + sensorsModule.AddSensor(&adxlSensor); + droneMixer = new BoatMixer(&motorL, &motorR); + #endif + + #ifdef VEHICLE_TYPE_TANK + Serial.println("Configuring as TANK"); + //Serial.end();//Not enough pins on esp cam + droneMixer = new BoatMixer(&motorL, &motorR); + //modules.push_back(new CameraModule()); + //sensorsModule.AddSensor(new HCSR04Sensor(12,16,0)); + #endif + + return droneMixer; +} \ No newline at end of file diff --git a/WST-FC/src/communicationModules/CommunicationESPNowModule.cpp b/WST-FC/src/communicationModules/CommunicationESPNowModule.cpp index 725a40f..c936aae 100644 --- a/WST-FC/src/communicationModules/CommunicationESPNowModule.cpp +++ b/WST-FC/src/communicationModules/CommunicationESPNowModule.cpp @@ -3,7 +3,8 @@ #include "communicationModules\CommunicationESPNowModule.h" - +//TO-DO +//Connect to ParseIncomingBytes CommunicationESPNowModule::CommunicationESPNowModule(DroneControlData *dataPtr, DroneStatus *status){ sharedData = dataPtr; diff --git a/WST-FC/src/communicationModules/CommunicationGamepadModule.cpp b/WST-FC/src/communicationModules/CommunicationGamepadModule.cpp index a5a9f35..e686bac 100644 --- a/WST-FC/src/communicationModules/CommunicationGamepadModule.cpp +++ b/WST-FC/src/communicationModules/CommunicationGamepadModule.cpp @@ -1,4 +1,5 @@ #include "communicationModules/CommunicationGamepadModule.h" +#ifdef USE_BLUEPAD32 CommunicationGamepadModule* CommunicationGamepadModule::instance = nullptr; void CommunicationGamepadModule::onConnectedGamepad(GamepadPtr gp) { @@ -45,4 +46,5 @@ void CommunicationGamepadModule::SendData(SensorsData* data){ } void CommunicationGamepadModule::SetGamepad(GamepadPtr gp) { myGamepad = gp; -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/WST-FC/src/communicationModules/CommunicationSerialModule.cpp b/WST-FC/src/communicationModules/CommunicationSerialModule.cpp index c5ac2b9..7e75cee 100644 --- a/WST-FC/src/communicationModules/CommunicationSerialModule.cpp +++ b/WST-FC/src/communicationModules/CommunicationSerialModule.cpp @@ -8,20 +8,18 @@ CommunicationSerialModule::CommunicationSerialModule(DroneControlData *dataPtr, } void CommunicationSerialModule::Init() { - + } void CommunicationSerialModule::Loop() { - if (sharedData == nullptr) return; - if (Serial.available() < sizeof(DroneControlData) + 2) return; - if (Serial.read() != HEADER_BYTE_1) return; - if (Serial.read() != HEADER_BYTE_2) return; - - Serial.readBytes(inputBuffer, sizeof(DroneControlData)); - memcpy(sharedData, inputBuffer, sizeof(DroneControlData)); - lastUpdate = millis(); - + int bytesAvailable = Serial.available(); + if (bytesAvailable > 0) + { + size_t bytesToRead = min(bytesAvailable, (int)sizeof(inputBuffer)); + size_t bytesRead = Serial.readBytes(inputBuffer, bytesToRead); + ParseIncomingBytes((uint8_t*)inputBuffer, bytesRead); + } if ((millis() - lastUpdate) > MAX_ROGUE_TIME) { diff --git a/WST-FC/src/communicationModules/CommunicationWiFiUDPModule.cpp b/WST-FC/src/communicationModules/CommunicationWiFiUDPModule.cpp index ffc7697..15ccd3b 100644 --- a/WST-FC/src/communicationModules/CommunicationWiFiUDPModule.cpp +++ b/WST-FC/src/communicationModules/CommunicationWiFiUDPModule.cpp @@ -12,6 +12,7 @@ CommunicationWiFiUDPModule::CommunicationWiFiUDPModule(DroneControlData *dataPtr void CommunicationWiFiUDPModule::Init() { Serial.print("Connecting to WiFi"); + WiFi.mode(WIFI_STA); WiFi.begin(WIFI_SSID, WIFI_PASSWORD); delay(500); while (WiFi.status() != WL_CONNECTED) @@ -57,15 +58,8 @@ void CommunicationWiFiUDPModule::Loop() if (packetSize) { - int len = udp.read(packetBuffer, 255); + ParseIncomingBytes((uint8_t*)packetBuffer, packetSize); - if (len != sizeof(DroneControlData)) - { - Serial.printf("Error: invalid packet"); - return; - } - memcpy(sharedData, packetBuffer, sizeof(DroneControlData)); - lastUpdate = millis(); remoteIP = udp.remoteIP(); remotePort = udp.remotePort(); } diff --git a/WST-FC/src/main.cpp b/WST-FC/src/main.cpp index 18f992b..e258cba 100644 --- a/WST-FC/src/main.cpp +++ b/WST-FC/src/main.cpp @@ -5,26 +5,8 @@ #include "SensorsModule.h" #include "SensorsData.h" #include "modules/IModule.h" - -#ifdef VEHICLE_TYPE_BICOPTER - #include "BicopterMixer.h" - #include "sensors/MpuSensor.h" - MpuSensor mpuSensor; -#endif - -#ifdef VEHICLE_TYPE_AIRBOAT - #include "AirBoatMixer.h" - #include "sensors/AdxlSensor.h" - DCMotor motorL(16, 17, 4, 0); - DCMotor motorR(18, 19, 5, 1); -#endif - -#ifdef VEHICLE_TYPE_TANK - #include "AirBoatMixer.h" - #include "modules/CameraModule.h" - DCMotor motorL(13, 14, 0); - DCMotor motorR(15, 2, 1); -#endif +#include "IMixer.h" +#include "DroneFactory.h" DroneControlData droneControllData{}; SensorsData sensorsData{}; @@ -43,30 +25,25 @@ unsigned long lastTelemetryTimestamp {0}; void setup() { Serial.begin(115200); - - #ifdef VEHICLE_TYPE_BICOPTER - Serial.println("Configuring as BICOPTER"); - sensorsModule.AddSensor(&mpuSensor); - droneMixer = new BicopterMixer(); - #endif - #ifdef VEHICLE_TYPE_AIRBOAT - Serial.println("Configuring as AIRBOAT"); - sensorsModule.AddSensor(&adxlSensor); - droneMixer = new BoatMixer(&motorL, &motorR); - modules.push_back(new CameraModule()); - #endif - #ifdef VEHICLE_TYPE_TANK - Serial.println("Configuring as TANK"); - droneMixer = new BoatMixer(&motorL, &motorR); - #endif - + Serial.println("Starting"); + Serial.flush(); comms.Init(); + Serial.println("Comms initiated"); + Serial.flush(); sensorsModule.Init(); - if(droneMixer != nullptr) droneMixer->Init(); - for (auto module : modules) - { + Serial.println("Sensors initiated"); + Serial.flush(); + droneMixer = DroneFactory::BuildVehicle(sensorsModule, modules); + if(droneMixer != nullptr) + droneMixer->Init(); + Serial.println("Mixer initiated"); + Serial.flush(); + for (auto module : modules) module->Init(); - } + Serial.println("Modules initiated"); + Serial.flush(); + Serial.println("Ok"); + Serial.flush(); } void loop() diff --git a/WST-FC/src/modules/CameraModule.cpp b/WST-FC/src/modules/CameraModule.cpp index 00f661d..917ebc9 100644 --- a/WST-FC/src/modules/CameraModule.cpp +++ b/WST-FC/src/modules/CameraModule.cpp @@ -28,13 +28,13 @@ void CameraModule::Init() config.pin_reset = RESET_GPIO_NUM; config.xclk_freq_hz = XCLK_FREQ_HZ; config.pixel_format = PIXFORMAT_JPEG; - config.frame_size = FRAMESIZE_HVGA; + config.frame_size = FRAMESIZE_QVGA; config.jpeg_quality = JPEG_QUALITY; config.fb_count = FB_COUNT; config.grab_mode = CAMERA_GRAB_LATEST; - esp_camera_init(&config); - startCameraServer(); + esp_err_t err = esp_camera_init(&config); + if (err == ESP_OK) startCameraServer(); } void CameraModule::Loop(CommunicationModule* interface, SensorsData *data){} @@ -46,7 +46,7 @@ esp_err_t CameraModule::stream_handler(httpd_req_t *req) char part_buf[64]; TickType_t xLastWakeTime = xTaskGetTickCount(); - const TickType_t xFrequency = pdMS_TO_TICKS(33); + const TickType_t xFrequency = pdMS_TO_TICKS(66); res = httpd_resp_set_type(req, _STREAM_CONTENT_TYPE);