Line-Following-Robot/lfr_state_machine.h

39 lines
925 B
C
Raw Normal View History

2023-01-16 03:04:15 +01:00
#pragma once
2023-01-16 03:57:23 +01:00
#include <iostream>
2023-01-16 06:37:39 +01:00
#include <algorithm>
2023-01-16 03:57:23 +01:00
#include <lfr.h>
#include <lfr_socket.h>
#include <uart_communication.h>
2023-01-16 03:34:25 +01:00
#include "lfr_state_interface.h"
2023-01-16 06:37:39 +01:00
#include "lfr_states.h"
2023-01-16 03:04:15 +01:00
class LFR_StateMachine
{
2023-01-16 03:34:25 +01:00
LFR_IState* currentState;
2023-01-16 03:57:23 +01:00
const int thresholdBinary = 140;
const int videoHeight = 720;
const int videoWidth = 1280;
const int gaussKernelSize = 11;
2023-01-31 12:45:08 +01:00
const double maxSpeed = 0.5;
2023-01-16 03:57:23 +01:00
std::mutex mutex;
LFR autonomousMode;
LFR_UART uartCommunicator;
LFR_Socket socket;
2023-01-16 06:37:39 +01:00
vector<string> split (string s, string delimiter) const;
void sanitize (string& s) const;
bool checkStringValidity (const std::vector<std::string>& s) const;
void parseString(string s);
2023-01-16 03:57:23 +01:00
2023-01-16 03:04:15 +01:00
public:
void enterAutonomous();
void exitAutonomous();
2023-01-16 06:37:39 +01:00
LFR_StateMachine();
2023-01-16 03:34:25 +01:00
inline LFR_IState* getCurrentState() const {return currentState;}
2023-01-16 06:37:39 +01:00
void setState(LFR_IState& newState);
2023-01-16 03:04:15 +01:00
};