|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool LFR_StateMachine::checkStringValidity (const std::vector<std::string>& s) const |
|
|
bool LFR_StateMachine::checkStringValidity (const std::vector<std::string>& s) const |
|
|
{ |
|
|
{ |
|
|
if(s.size() != 5) |
|
|
|
|
|
{ |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
for(int i = 0; i < 4; i ++) |
|
|
|
|
|
|
|
|
int i = stoi(s[0]); |
|
|
|
|
|
if(i == 0 && s.size() == 5) |
|
|
{ |
|
|
{ |
|
|
if(stod(s[i]) > 1.0 || stod(s[i]) < -1.0) |
|
|
|
|
|
|
|
|
for(int i = 0; i < 4; i ++) |
|
|
{ |
|
|
{ |
|
|
return false; |
|
|
|
|
|
|
|
|
if(stod(s[i]) > 1.0 || stod(s[i]) < -1.0) |
|
|
|
|
|
{ |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
int i = stoi(s[4]); |
|
|
|
|
|
if(i != 0 && i != 1) |
|
|
|
|
|
|
|
|
else if(i == 1) |
|
|
{ |
|
|
{ |
|
|
return false; |
|
|
|
|
|
|
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
catch(const std::exception& e) {return false;} |
|
|
catch(const std::exception& e) {return false;} |
|
|
return true; |
|
|
return true; |
|
|
|
|
|
|
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
double wheels[4] = {0.0, 0.0, 0.0, 0.0}; |
|
|
double wheels[4] = {0.0, 0.0, 0.0, 0.0}; |
|
|
int mode = std::stoi(splitStr[4]); |
|
|
|
|
|
for(int i = 0; i < 3; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
wheels[i] = std::stod(splitStr[i]); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
int mode = std::stoi(splitStr[0]); |
|
|
if(mode == 0) { |
|
|
if(mode == 0) { |
|
|
|
|
|
for(int i = 1; i < 4; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
wheels[i] = std::stod(splitStr[i]); |
|
|
|
|
|
} |
|
|
setState(State::Manual::getInstance()); |
|
|
setState(State::Manual::getInstance()); |
|
|
uartCommunicator.sendTelegram(wheels[0], wheels[1], wheels[2], wheels[3]); |
|
|
uartCommunicator.sendTelegram(wheels[0], wheels[1], wheels[2], wheels[3]); |
|
|
} |
|
|
} |