mirror of
https://github.com/azaion/autopilot.git
synced 2026-04-22 08:36:33 +00:00
Removed build folder.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
#include <QDebug>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QThread>
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
#include "config.hpp"
|
||||
#include "defines.hpp"
|
||||
@@ -79,9 +79,14 @@ void RemoteControl::openNamedPipe()
|
||||
}
|
||||
}
|
||||
|
||||
void RemoteControl::whenDone(void)
|
||||
void RemoteControl::sendResponse(void)
|
||||
{
|
||||
// All is done, no it's time to rest
|
||||
QJsonDocument responseDocument(mResponseObject);
|
||||
std::string response = responseDocument.toJson(QJsonDocument::Compact).toStdString();
|
||||
write(mFifoFdOut, response.c_str(), response.size());
|
||||
qDebug().noquote().nospace() << "Sent: " << response;
|
||||
|
||||
mIsBusy = false;
|
||||
}
|
||||
|
||||
void RemoteControl::restoreOrientation(void)
|
||||
@@ -97,6 +102,8 @@ void RemoteControl::restoreOrientation(void)
|
||||
|
||||
qDebug().noquote().nospace() << serialCommandAngle;
|
||||
Config::getSerial()->sendCommand(serialCommandAngle);
|
||||
|
||||
QTimer::singleShot(1000, this, [this]() mutable { sendResponse(); });
|
||||
}
|
||||
|
||||
void RemoteControl::restoreZoom(void)
|
||||
@@ -112,9 +119,11 @@ void RemoteControl::restoreZoom(void)
|
||||
|
||||
qDebug().noquote().nospace() << serialCommandZoom.toStdString();
|
||||
Config::getSerial()->sendCommand(serialCommandZoom);
|
||||
|
||||
QTimer::singleShot(3000, this, [this]() mutable { restoreOrientation(); });
|
||||
}
|
||||
|
||||
QJsonObject RemoteControl::calculateTargetPosition(QJsonObject &commandObject, QJsonObject &responseObject)
|
||||
void RemoteControl::calculateTargetPosition(QJsonObject &commandObject)
|
||||
{
|
||||
qDebug().noquote().nospace() << "Calculating?";
|
||||
|
||||
@@ -129,11 +138,11 @@ QJsonObject RemoteControl::calculateTargetPosition(QJsonObject &commandObject, Q
|
||||
//float targetRealHeight = commandObject["target_real_height"].toDouble();
|
||||
|
||||
GPSData gpsData = UtilsTargetLocation::getLocation(altitude, latitude, longitude, yaw, pitch, 0.0f, targetRealWidth, targetPixelWidth);
|
||||
responseObject["altitude"] = gpsData.altitude;
|
||||
responseObject["latitude"] = gpsData.latitude;
|
||||
responseObject["longitude"] = gpsData.longitude;
|
||||
mResponseObject["altitude"] = gpsData.altitude;
|
||||
mResponseObject["latitude"] = gpsData.latitude;
|
||||
mResponseObject["longitude"] = gpsData.longitude;
|
||||
|
||||
return responseObject;
|
||||
QTimer::singleShot(3000, this, [this, commandObject]() mutable { zoomToTarget(commandObject); });
|
||||
}
|
||||
|
||||
void RemoteControl::turnToTarget(QJsonObject &commandObject)
|
||||
@@ -158,6 +167,8 @@ void RemoteControl::turnToTarget(QJsonObject &commandObject)
|
||||
serialCommandTurn[11] = degreesVal >> 8;
|
||||
|
||||
Config::getSerial()->sendCommand(serialCommandTurn);
|
||||
|
||||
QTimer::singleShot(3000, this, [this, commandObject]() mutable { calculateTargetPosition(commandObject); });
|
||||
}
|
||||
|
||||
void RemoteControl::zoomToTarget(QJsonObject &commandObject)
|
||||
@@ -186,11 +197,16 @@ void RemoteControl::zoomToTarget(QJsonObject &commandObject)
|
||||
serialCommandNewZoom[9] = scaledFractional;
|
||||
|
||||
Config::getSerial()->sendCommand(serialCommandNewZoom);
|
||||
|
||||
QTimer::singleShot(10000, this, [this, commandObject]() mutable { restoreZoom(); });
|
||||
}
|
||||
|
||||
void RemoteControl::run()
|
||||
{
|
||||
mIsBusy = false;
|
||||
|
||||
while (true) {
|
||||
if (mIsBusy == false) {
|
||||
char buffer[1024];
|
||||
ssize_t bytesRead = read(mFifoFdIn, buffer, sizeof(buffer) - 1);
|
||||
|
||||
@@ -212,53 +228,25 @@ void RemoteControl::run()
|
||||
qDebug().noquote().nospace() << "Received: " << message;
|
||||
|
||||
// Exit with exit message
|
||||
if (commandObject.contains("EXIT") == true) {
|
||||
if (commandObject.contains("extra") == true && commandObject["extra"] == "EXIT") {
|
||||
return;
|
||||
}
|
||||
|
||||
mIsBusy = true;
|
||||
|
||||
// Prepare responce object
|
||||
QJsonObject responseObject;
|
||||
responseObject["sender"] = FIFO_WHO_AM_I;
|
||||
responseObject["status"] = "OK";
|
||||
mResponseObject = QJsonObject();
|
||||
mResponseObject["sender"] = FIFO_WHO_AM_I;
|
||||
mResponseObject["status"] = "OK";
|
||||
|
||||
// Get current orientation and zoom
|
||||
Config::updateState();
|
||||
|
||||
// Turn to target
|
||||
if (commandObject.contains("target_x") == true && commandObject.contains("target_y") == true) {
|
||||
QTimer::singleShot(100, this, [this, commandObject]() mutable { turnToTarget(commandObject); });
|
||||
QTimer::singleShot(1000, this, &RemoteControl::whenDone);
|
||||
QTimer::singleShot(0, this, [this, commandObject]() mutable { turnToTarget(commandObject); });
|
||||
}
|
||||
|
||||
// Calculate target location
|
||||
if (commandObject.contains("latitude") == true && commandObject.contains("longitude") == true && commandObject.contains("altitude") == true && commandObject.contains("yaw") == true && commandObject.contains("pitch") == true && commandObject.contains("target_pixel_width") == true && commandObject.contains("target_pixel_height") == true && commandObject.contains("target_real_width") == true && commandObject.contains("target_real_height") == true) {
|
||||
responseObject = calculateTargetPosition(commandObject, responseObject);
|
||||
QTimer::singleShot(1000, this, &RemoteControl::whenDone);
|
||||
}
|
||||
|
||||
// Zoom to target
|
||||
if (commandObject.contains("target_pixel_width") == true && commandObject.contains("target_pixel_height") == true) {
|
||||
QTimer::singleShot(100, this, [this, commandObject]() mutable { zoomToTarget(commandObject); });
|
||||
QTimer::singleShot(1000, this, &RemoteControl::whenDone);
|
||||
}
|
||||
|
||||
// Restore previous zoom and orientation
|
||||
QTimer::singleShot(100, this, &RemoteControl::restoreZoom);
|
||||
QTimer::singleShot(1000, this, &RemoteControl::whenDone);
|
||||
|
||||
QTimer::singleShot(100, this, &RemoteControl::restoreOrientation);
|
||||
QTimer::singleShot(1000, this, &RemoteControl::whenDone);
|
||||
|
||||
// Respond after doing camera things
|
||||
QJsonDocument responseDocument(responseObject);
|
||||
std::string response = responseDocument.toJson(QJsonDocument::Compact).toStdString();
|
||||
write(mFifoFdOut, response.c_str(), response.size());
|
||||
qDebug().noquote().nospace() << "Sent: " << response;
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
}
|
||||
|
||||
// Sleep for a while
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <QJsonObject>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QThread>
|
||||
|
||||
class RemoteControl : public QObject
|
||||
{
|
||||
@@ -11,18 +12,20 @@ class RemoteControl : public QObject
|
||||
public:
|
||||
RemoteControl();
|
||||
~RemoteControl();
|
||||
void openNamedPipe(void);
|
||||
void run();
|
||||
|
||||
private slots:
|
||||
QJsonObject calculateTargetPosition(QJsonObject &commandObject, QJsonObject &responseObject);
|
||||
void sendResponse(void);
|
||||
void calculateTargetPosition(QJsonObject &commandObject);
|
||||
void turnToTarget(QJsonObject &commandObject);
|
||||
void zoomToTarget(QJsonObject &commandObject);
|
||||
void restoreOrientation(void);
|
||||
void restoreZoom(void);
|
||||
void whenDone(void);
|
||||
|
||||
private:
|
||||
void openNamedPipe(void);
|
||||
bool mIsBusy;
|
||||
int mFifoFdIn;
|
||||
int mFifoFdOut;
|
||||
QJsonObject mResponseObject;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "serialPort.hpp"
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
#include "defines.hpp"
|
||||
#include "utilsCRC16.hpp"
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
QMAKE_CXX.QT_COMPILER_STDCXX = 201402L
|
||||
QMAKE_CXX.QMAKE_CLANG_MAJOR_VERSION = 14
|
||||
QMAKE_CXX.QMAKE_CLANG_MINOR_VERSION = 0
|
||||
QMAKE_CXX.QMAKE_CLANG_PATCH_VERSION = 0
|
||||
QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 4
|
||||
QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 2
|
||||
QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 1
|
||||
QMAKE_CXX.COMPILER_MACROS = \
|
||||
QT_COMPILER_STDCXX \
|
||||
QMAKE_CLANG_MAJOR_VERSION \
|
||||
QMAKE_CLANG_MINOR_VERSION \
|
||||
QMAKE_CLANG_PATCH_VERSION \
|
||||
QMAKE_GCC_MAJOR_VERSION \
|
||||
QMAKE_GCC_MINOR_VERSION \
|
||||
QMAKE_GCC_PATCH_VERSION
|
||||
QMAKE_CXX.INCDIRS = \
|
||||
/usr/include/c++/11 \
|
||||
/usr/include/x86_64-linux-gnu/c++/11 \
|
||||
/usr/include/c++/11/backward \
|
||||
/usr/lib/llvm-14/lib/clang/14.0.0/include \
|
||||
/usr/local/include \
|
||||
/usr/include/x86_64-linux-gnu \
|
||||
/usr/include
|
||||
QMAKE_CXX.LIBDIRS = \
|
||||
/usr/lib/llvm-14/lib/clang/14.0.0 \
|
||||
/usr/lib/gcc/x86_64-linux-gnu/11 \
|
||||
/usr/lib64 \
|
||||
/lib/x86_64-linux-gnu \
|
||||
/lib64 \
|
||||
/usr/lib/x86_64-linux-gnu \
|
||||
/usr/lib/llvm-14/lib \
|
||||
/lib \
|
||||
/usr/lib
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user