Adjust telegramm

This commit is contained in:
Tim Zeuner 2023-02-03 20:38:52 +01:00
parent a929bbebed
commit 60e19a8968

View File

@ -25,12 +25,10 @@ void LFR_StateMachine::sanitize (string& s) const
bool LFR_StateMachine::checkStringValidity (const std::vector<std::string>& s) const
{
if(s.size() != 5)
{
return false;
}
try
{
int i = stoi(s[0]);
if(i == 0 && s.size() == 5)
{
for(int i = 0; i < 4; i ++)
{
@ -39,8 +37,12 @@ bool LFR_StateMachine::checkStringValidity (const std::vector<std::string>& s) c
return false;
}
}
int i = stoi(s[4]);
if(i != 0 && i != 1)
}
else if(i == 1)
{
return true;
}
else
{
return false;
}
@ -59,12 +61,12 @@ void LFR_StateMachine::parseString(string s)
return;
}
double wheels[4] = {0.0, 0.0, 0.0, 0.0};
int mode = std::stoi(splitStr[4]);
for(int i = 0; i < 3; i++)
int mode = std::stoi(splitStr[0]);
if(mode == 0) {
for(int i = 1; i < 4; i++)
{
wheels[i] = std::stod(splitStr[i]);
}
if(mode == 0) {
setState(State::Manual::getInstance());
uartCommunicator.sendTelegram(wheels[0], wheels[1], wheels[2], wheels[3]);
}