diff --git a/lfr_state_machine.cpp b/lfr_state_machine.cpp index 8c6b7d5..e155aea 100644 --- a/lfr_state_machine.cpp +++ b/lfr_state_machine.cpp @@ -1 +1,40 @@ #include "lfr_state_machine.h" + +LFR_StateMachine::LFR_StateMachine(LFR_IState& startState): + autonomousMode(videoHeight, videoWidth, thresholdBinary, gaussKernelSize, [&](std::exception const &ex) + { + std::unique_lock lock(mutex); + std::cerr<<"camera exception:"< lock(mutex); + std::cerr<<"socket exception:"< lock(mutex); + std::cout << telegram; + }, &mutex); + socket.startLoop(); + + currentState = &startState; + currentState->enter(this); + + //Start the permanent loop + char input; + std::cout << "press q to quit" << std::endl; + std::cin >> input; + std::cout << "binned" << std::endl; + while (input != 'q') + { + std::cin >> input; + std::cout << "binned" << std::endl; + } + std::cout << "Exiting central" << std::endl; +} \ No newline at end of file diff --git a/lfr_state_machine.h b/lfr_state_machine.h index 3f3fe36..717ceeb 100644 --- a/lfr_state_machine.h +++ b/lfr_state_machine.h @@ -1,15 +1,29 @@ #pragma once +#include +#include +#include +#include #include "lfr_state_interface.h" class LFR_StateMachine { LFR_IState* currentState; LFR_StateMachine() = delete; + + const int thresholdBinary = 140; + const int videoHeight = 720; + const int videoWidth = 1280; + const int gaussKernelSize = 11; + + std::mutex mutex; + + LFR autonomousMode; + LFR_UART uartCommunicator; + LFR_Socket socket; + + public: - LFR_StateMachine(LFR_IState& startState){ - currentState = &startState; - currentState->enter(this); - } + LFR_StateMachine(LFR_IState& startState); inline LFR_IState* getCurrentState() const {return currentState;} void setState(LFR_IState& newState) { diff --git a/main.cpp b/main.cpp index eb1d4fe..3e8b6d7 100644 --- a/main.cpp +++ b/main.cpp @@ -1,66 +1,14 @@ #include -#include -#include -#include #include "lfr_state_machine.h" #include "lfr_states.h" + + int main(void) { std::cout << "started central" << std::endl; - - const int thresholdBinary = 140; - const int videoHeight = 720; - const int videoWidth = 1280; - const int gaussKernelSize = 11; - - std::mutex mutex; - // Init State Machine; std::cout << "create State Machine" << std::endl; LFR_StateMachine stateMachine(State::Idle::getInstance()); - - // Init LFR Autonomous mode - std::cout << "create lfr" << std::endl; - LFR lfr(videoHeight, videoWidth, thresholdBinary, gaussKernelSize, [&](std::exception const &ex) - { - std::unique_lock lock(mutex); - std::cerr<<"camera exception:"< lock(mutex); - std::cerr<<"socket exception:"< lock(mutex); - std::cout << telegram; - }, &mutex); - socket.startLoop(); - - - //Start the permanent loop - char input; - std::cout << "press q to quit" << std::endl; - std::cin >> input; - std::cout << "cinned" << std::endl; - while (input != 'q') - { - std::cin >> input; - std::cout << "cinned" << std::endl; - } - std::cout << "Exiting central" << std::endl; return 0; } \ No newline at end of file