mirror of
https://github.com/azaion/autopilot.git
synced 2026-04-22 22:36:34 +00:00
Fixes for A8 remote control. Added logging messages
This commit is contained in:
@@ -33,9 +33,12 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Remote mode will read commands from pipe
|
// Remote mode will read commands from pipe
|
||||||
if (useRemoteMode == true) {
|
if (useRemoteMode == true) {
|
||||||
RemoteControl remoteControl;
|
qDebug() << "Creating new RemoteControl object";
|
||||||
} else {
|
new RemoteControl();
|
||||||
LocalControl localControl;
|
}
|
||||||
|
else {
|
||||||
|
qDebug() << "Creating new LocalControl object";
|
||||||
|
new LocalControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
#include "remoteControl.hpp"
|
#include "remoteControl.hpp"
|
||||||
|
|
||||||
RemoteControl::RemoteControl(QObject *parent)
|
RemoteControl::RemoteControl(QObject *parent)
|
||||||
: QObject{parent}
|
: QObject{parent}, mIsBusy(false)
|
||||||
{
|
{
|
||||||
mUdpSocket = new QUdpSocket(this);
|
mUdpSocket = new QUdpSocket(this);
|
||||||
connect(mUdpSocket, &QUdpSocket::readyRead, this, &RemoteControl::readPendingDatagrams);
|
connect(mUdpSocket, &QUdpSocket::readyRead, this, &RemoteControl::readPendingDatagrams);
|
||||||
@@ -23,6 +23,8 @@ RemoteControl::RemoteControl(QObject *parent)
|
|||||||
|
|
||||||
void RemoteControl::readPendingDatagrams()
|
void RemoteControl::readPendingDatagrams()
|
||||||
{
|
{
|
||||||
|
qDebug() << "readPendingDatagrams() Got UDP message!";
|
||||||
|
|
||||||
while (mUdpSocket->hasPendingDatagrams()) {
|
while (mUdpSocket->hasPendingDatagrams()) {
|
||||||
QByteArray datagram;
|
QByteArray datagram;
|
||||||
datagram.resize(mUdpSocket->pendingDatagramSize());
|
datagram.resize(mUdpSocket->pendingDatagramSize());
|
||||||
@@ -37,9 +39,11 @@ void RemoteControl::readPendingDatagrams()
|
|||||||
|
|
||||||
if (jsonDoc.isObject()) {
|
if (jsonDoc.isObject()) {
|
||||||
if (mIsBusy == false) {
|
if (mIsBusy == false) {
|
||||||
|
qDebug() << "readPendingDatagrams() mIsBusy == false! Processing JSON";
|
||||||
processJSON(jsonDoc);
|
processJSON(jsonDoc);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
qWarning().noquote().nospace() << "Received data was not JSON object.";
|
qWarning().noquote().nospace() << "Received data was not JSON object.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#include "remoteControl.hpp"
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
@@ -7,9 +6,7 @@
|
|||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QUdpSocket>
|
#include <QUdpSocket>
|
||||||
#include <fcntl.h>
|
#include "remoteControl.hpp"
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
uint8_t RemoteControl::sendData(uint16_t top, uint16_t left, uint16_t bottom, uint16_t right)
|
uint8_t RemoteControl::sendData(uint16_t top, uint16_t left, uint16_t bottom, uint16_t right)
|
||||||
{
|
{
|
||||||
@@ -23,8 +20,6 @@ uint8_t RemoteControl::sendData(uint16_t top, uint16_t left, uint16_t bottom, ui
|
|||||||
if (bytesSent == -1) {
|
if (bytesSent == -1) {
|
||||||
qWarning("Failed to send the datagram: %s", qPrintable(udpSocket.errorString()));
|
qWarning("Failed to send the datagram: %s", qPrintable(udpSocket.errorString()));
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
|
||||||
qDebug("Datagram sent successfully");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -53,18 +53,21 @@ void AiEngineGimbalControl::inferenceResultSlot(AiEngineInferenceResult result)
|
|||||||
groupRect.right *= 2;
|
groupRect.right *= 2;
|
||||||
|
|
||||||
if (groupRect.top > 720 || groupRect.bottom > 720) {
|
if (groupRect.top > 720 || groupRect.bottom > 720) {
|
||||||
|
qDebug() << "ERROR! inferenceResultSlot() groupRect.top > 720 || groupRect.bottom > 720";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groupRect.left > 1280 || groupRect.right > 1280) {
|
if (groupRect.left > 1280 || groupRect.right > 1280) {
|
||||||
|
qDebug() << "ERROR! inferenceResultSlot() groupRect.left > 1280 || groupRect.right > 1280";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((groupRect.bottom <= groupRect.top) || (groupRect.right <= groupRect.left)) {
|
if ((groupRect.bottom <= groupRect.top) || (groupRect.right <= groupRect.left)) {
|
||||||
|
qDebug() << "ERROR! (groupRect.bottom <= groupRect.top) || (groupRect.right <= groupRect.left)";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "TUOMAS!! Zooming to square" << groupRect.top << "x" << groupRect.left << "and" << groupRect.bottom << "x" << groupRect.right;
|
qDebug() << "TUOMAS!! Zooming to square top=" << groupRect.top << "x" << groupRect.left << "and bottom:" << groupRect.bottom << "x" << groupRect.right;
|
||||||
|
|
||||||
mRemoteControl.sendData(groupRect.top, groupRect.left, groupRect.left, groupRect.right);
|
mRemoteControl.sendData(groupRect.top, groupRect.left, groupRect.bottom, groupRect.right);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user