mirror of
https://github.com/azaion/autopilot.git
synced 2026-04-22 11:26:35 +00:00
Removed blocking code from a8 and a8 remote.
This commit is contained in:
@@ -85,13 +85,7 @@ void RemoteControl::createNamedPipe()
|
||||
|
||||
void RemoteControl::sendData(uint16_t top, uint16_t left, uint16_t bottom, uint16_t right)
|
||||
{
|
||||
qInfo().noquote().nospace() << "Enter a command (0 to exit): ";
|
||||
std::string input;
|
||||
std::cin >> input;
|
||||
|
||||
// Send command
|
||||
QJsonObject commandObject = {{"sender", FIFO_WHO_AM_I}, {"top", top}, {"left", left}, {"bottom", bottom}, {"right", right}};
|
||||
|
||||
QJsonDocument commandDocument(commandObject);
|
||||
std::string command = commandDocument.toJson(QJsonDocument::Compact).toStdString();
|
||||
write(mFifoFdOut, command.c_str(), command.size());
|
||||
@@ -101,31 +95,38 @@ void RemoteControl::sendData(uint16_t top, uint16_t left, uint16_t bottom, uint1
|
||||
#ifdef FIFO_TEST
|
||||
void RemoteControl::startTest()
|
||||
{
|
||||
qInfo().noquote().nospace() << "Enter a command (0 to exit): ";
|
||||
std::string input;
|
||||
std::cin >> input;
|
||||
QJsonObject commandObject;
|
||||
for (uint8_t i = 0; i < 5; i++) {
|
||||
qInfo().noquote().nospace() << "Enter a command (EXIT to exit): ";
|
||||
std::string input;
|
||||
std::cin >> input;
|
||||
|
||||
// Send command
|
||||
QJsonObject commandObject = {
|
||||
{"sender", FIFO_WHO_AM_I},
|
||||
{"latitude", 63.155653611},
|
||||
{"longitude", 23.827191389},
|
||||
{"altitude", randomFloatBetween(10, 11)},
|
||||
{"yaw", randomFloatBetween(0.0f, 360.0f)},
|
||||
{"pitch", 0.0},
|
||||
{"target_x", (uint16_t) randomFloatBetween(300, 979)},
|
||||
{"target_y", (uint16_t) randomFloatBetween(200, 519)},
|
||||
{"target_pixel_width", 20},
|
||||
{"target_pixel_height", 10},
|
||||
{"target_real_width", 5},
|
||||
{"target_real_height", 2.5},
|
||||
{"extra", input.c_str()},
|
||||
};
|
||||
// Send command
|
||||
QJsonObject commandObject = {
|
||||
{"sender", FIFO_WHO_AM_I},
|
||||
{"latitude", 63.155653611},
|
||||
{"longitude", 23.827191389},
|
||||
{"altitude", randomFloatBetween(10, 11)},
|
||||
{"yaw", randomFloatBetween(0.0f, 360.0f)},
|
||||
{"pitch", 0.0},
|
||||
{"target_x", (uint16_t) randomFloatBetween(300, 979)},
|
||||
{"target_y", (uint16_t) randomFloatBetween(200, 519)},
|
||||
{"target_pixel_width", 20},
|
||||
{"target_pixel_height", 10},
|
||||
{"target_real_width", 5},
|
||||
{"target_real_height", 2.5},
|
||||
{"extra", input.c_str()},
|
||||
{"top", 100},
|
||||
{"left", 100},
|
||||
{"bottom", 200},
|
||||
{"right", 200},
|
||||
};
|
||||
|
||||
QJsonDocument commandDocument(commandObject);
|
||||
std::string command = commandDocument.toJson(QJsonDocument::Compact).toStdString();
|
||||
write(mFifoFdOut, command.c_str(), command.size());
|
||||
qDebug().noquote().nospace() << "Sent: " << command;
|
||||
QJsonDocument commandDocument(commandObject);
|
||||
std::string command = commandDocument.toJson(QJsonDocument::Compact).toStdString();
|
||||
write(mFifoFdOut, command.c_str(), command.size());
|
||||
qDebug().noquote().nospace() << "Sent: " << command;
|
||||
}
|
||||
|
||||
if (commandObject["extra"] == "EXIT") {
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
Reference in New Issue
Block a user