mirror of
https://github.com/azaion/autopilot.git
synced 2026-04-22 22:56:33 +00:00
Removed build folder.
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QThread>
|
#include <QObject>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "defines.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)
|
void RemoteControl::restoreOrientation(void)
|
||||||
@@ -97,6 +102,8 @@ void RemoteControl::restoreOrientation(void)
|
|||||||
|
|
||||||
qDebug().noquote().nospace() << serialCommandAngle;
|
qDebug().noquote().nospace() << serialCommandAngle;
|
||||||
Config::getSerial()->sendCommand(serialCommandAngle);
|
Config::getSerial()->sendCommand(serialCommandAngle);
|
||||||
|
|
||||||
|
QTimer::singleShot(1000, this, [this]() mutable { sendResponse(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteControl::restoreZoom(void)
|
void RemoteControl::restoreZoom(void)
|
||||||
@@ -112,9 +119,11 @@ void RemoteControl::restoreZoom(void)
|
|||||||
|
|
||||||
qDebug().noquote().nospace() << serialCommandZoom.toStdString();
|
qDebug().noquote().nospace() << serialCommandZoom.toStdString();
|
||||||
Config::getSerial()->sendCommand(serialCommandZoom);
|
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?";
|
qDebug().noquote().nospace() << "Calculating?";
|
||||||
|
|
||||||
@@ -129,11 +138,11 @@ QJsonObject RemoteControl::calculateTargetPosition(QJsonObject &commandObject, Q
|
|||||||
//float targetRealHeight = commandObject["target_real_height"].toDouble();
|
//float targetRealHeight = commandObject["target_real_height"].toDouble();
|
||||||
|
|
||||||
GPSData gpsData = UtilsTargetLocation::getLocation(altitude, latitude, longitude, yaw, pitch, 0.0f, targetRealWidth, targetPixelWidth);
|
GPSData gpsData = UtilsTargetLocation::getLocation(altitude, latitude, longitude, yaw, pitch, 0.0f, targetRealWidth, targetPixelWidth);
|
||||||
responseObject["altitude"] = gpsData.altitude;
|
mResponseObject["altitude"] = gpsData.altitude;
|
||||||
responseObject["latitude"] = gpsData.latitude;
|
mResponseObject["latitude"] = gpsData.latitude;
|
||||||
responseObject["longitude"] = gpsData.longitude;
|
mResponseObject["longitude"] = gpsData.longitude;
|
||||||
|
|
||||||
return responseObject;
|
QTimer::singleShot(3000, this, [this, commandObject]() mutable { zoomToTarget(commandObject); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteControl::turnToTarget(QJsonObject &commandObject)
|
void RemoteControl::turnToTarget(QJsonObject &commandObject)
|
||||||
@@ -158,6 +167,8 @@ void RemoteControl::turnToTarget(QJsonObject &commandObject)
|
|||||||
serialCommandTurn[11] = degreesVal >> 8;
|
serialCommandTurn[11] = degreesVal >> 8;
|
||||||
|
|
||||||
Config::getSerial()->sendCommand(serialCommandTurn);
|
Config::getSerial()->sendCommand(serialCommandTurn);
|
||||||
|
|
||||||
|
QTimer::singleShot(3000, this, [this, commandObject]() mutable { calculateTargetPosition(commandObject); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteControl::zoomToTarget(QJsonObject &commandObject)
|
void RemoteControl::zoomToTarget(QJsonObject &commandObject)
|
||||||
@@ -186,79 +197,56 @@ void RemoteControl::zoomToTarget(QJsonObject &commandObject)
|
|||||||
serialCommandNewZoom[9] = scaledFractional;
|
serialCommandNewZoom[9] = scaledFractional;
|
||||||
|
|
||||||
Config::getSerial()->sendCommand(serialCommandNewZoom);
|
Config::getSerial()->sendCommand(serialCommandNewZoom);
|
||||||
|
|
||||||
|
QTimer::singleShot(10000, this, [this, commandObject]() mutable { restoreZoom(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteControl::run()
|
void RemoteControl::run()
|
||||||
{
|
{
|
||||||
|
mIsBusy = false;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
char buffer[1024];
|
if (mIsBusy == false) {
|
||||||
ssize_t bytesRead = read(mFifoFdIn, buffer, sizeof(buffer) - 1);
|
char buffer[1024];
|
||||||
|
ssize_t bytesRead = read(mFifoFdIn, buffer, sizeof(buffer) - 1);
|
||||||
|
|
||||||
if (bytesRead > 0) {
|
if (bytesRead > 0) {
|
||||||
buffer[bytesRead] = '\0';
|
buffer[bytesRead] = '\0';
|
||||||
|
|
||||||
QJsonDocument commandDoc = QJsonDocument::fromJson(buffer);
|
QJsonDocument commandDoc = QJsonDocument::fromJson(buffer);
|
||||||
|
|
||||||
// Ignore non json messages
|
// Ignore non json messages
|
||||||
if (commandDoc.isNull() == false) {
|
if (commandDoc.isNull() == false) {
|
||||||
QJsonObject commandObject = commandDoc.object();
|
QJsonObject commandObject = commandDoc.object();
|
||||||
|
|
||||||
// Ignore own messages and messages that don't have sender
|
// Ignore own messages and messages that don't have sender
|
||||||
if (commandObject.contains("sender") == false || commandObject["sender"] == FIFO_WHO_AM_I) {
|
if (commandObject.contains("sender") == false || commandObject["sender"] == FIFO_WHO_AM_I) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString message = QString::fromUtf8(buffer);
|
||||||
|
qDebug().noquote().nospace() << "Received: " << message;
|
||||||
|
|
||||||
|
// Exit with exit message
|
||||||
|
if (commandObject.contains("extra") == true && commandObject["extra"] == "EXIT") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mIsBusy = true;
|
||||||
|
|
||||||
|
// Prepare responce object
|
||||||
|
mResponseObject = QJsonObject();
|
||||||
|
mResponseObject["sender"] = FIFO_WHO_AM_I;
|
||||||
|
mResponseObject["status"] = "OK";
|
||||||
|
|
||||||
|
// Get current orientation and zoom
|
||||||
|
Config::updateState();
|
||||||
|
|
||||||
|
QTimer::singleShot(0, this, [this, commandObject]() mutable { turnToTarget(commandObject); });
|
||||||
}
|
}
|
||||||
|
|
||||||
QString message = QString::fromUtf8(buffer);
|
|
||||||
qDebug().noquote().nospace() << "Received: " << message;
|
|
||||||
|
|
||||||
// Exit with exit message
|
|
||||||
if (commandObject.contains("EXIT") == true) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prepare responce object
|
|
||||||
QJsonObject responseObject;
|
|
||||||
responseObject["sender"] = FIFO_WHO_AM_I;
|
|
||||||
responseObject["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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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();
|
QCoreApplication::processEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
class RemoteControl : public QObject
|
class RemoteControl : public QObject
|
||||||
{
|
{
|
||||||
@@ -11,18 +12,20 @@ class RemoteControl : public QObject
|
|||||||
public:
|
public:
|
||||||
RemoteControl();
|
RemoteControl();
|
||||||
~RemoteControl();
|
~RemoteControl();
|
||||||
void openNamedPipe(void);
|
|
||||||
void run();
|
void run();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
QJsonObject calculateTargetPosition(QJsonObject &commandObject, QJsonObject &responseObject);
|
void sendResponse(void);
|
||||||
|
void calculateTargetPosition(QJsonObject &commandObject);
|
||||||
void turnToTarget(QJsonObject &commandObject);
|
void turnToTarget(QJsonObject &commandObject);
|
||||||
void zoomToTarget(QJsonObject &commandObject);
|
void zoomToTarget(QJsonObject &commandObject);
|
||||||
void restoreOrientation(void);
|
void restoreOrientation(void);
|
||||||
void restoreZoom(void);
|
void restoreZoom(void);
|
||||||
void whenDone(void);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void openNamedPipe(void);
|
||||||
|
bool mIsBusy;
|
||||||
int mFifoFdIn;
|
int mFifoFdIn;
|
||||||
int mFifoFdOut;
|
int mFifoFdOut;
|
||||||
|
QJsonObject mResponseObject;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "serialPort.hpp"
|
#include "serialPort.hpp"
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QTimer>
|
||||||
#include "defines.hpp"
|
#include "defines.hpp"
|
||||||
#include "utilsCRC16.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