mirror of
https://github.com/azaion/autopilot.git
synced 2026-04-23 00:26:33 +00:00
Minor improvements
This commit is contained in:
@@ -6,8 +6,8 @@ CONFIG += c++17 console
|
||||
|
||||
TARGET = a8
|
||||
|
||||
QMAKE_CXXFLAGS = -O0 -g -ggdb -fsanitize=undefined,bounds,float-divide-by-zero,integer-divide-by-zero,null,return,signed-integer-overflow,unreachable,shift,alignment,nonnull-attribute,returns-nonnull-attribute,enum
|
||||
QMAKE_LFLAGS = -O0 -g -ggdb -fsanitize=undefined,bounds,float-divide-by-zero,integer-divide-by-zero,null,return,signed-integer-overflow,unreachable,shift,alignment,nonnull-attribute,returns-nonnull-attribute,enum
|
||||
QMAKE_CXXFLAGS = -O0 -g -ggdb -fsanitize=address,bounds,float-divide-by-zero,integer-divide-by-zero,null,return,signed-integer-overflow,unreachable,shift,alignment,nonnull-attribute,returns-nonnull-attribute,enum
|
||||
QMAKE_LFLAGS = -O0 -g -ggdb -fsanitize=address,bounds,float-divide-by-zero,integer-divide-by-zero,null,return,signed-integer-overflow,unreachable,shift,alignment,nonnull-attribute,returns-nonnull-attribute,enum
|
||||
|
||||
QMAKE_CXX = clang++
|
||||
QMAKE_CC = clang
|
||||
|
||||
@@ -83,14 +83,17 @@ void RemoteControl::sendResponse(void)
|
||||
{
|
||||
QJsonDocument responseDocument(mResponseObject);
|
||||
std::string response = responseDocument.toJson(QJsonDocument::Compact).toStdString();
|
||||
write(mFifoFdOut, response.c_str(), response.size());
|
||||
qDebug().noquote().nospace() << "Sent: " << response;
|
||||
|
||||
qDebug().noquote().nospace() << "Sending responce: " << response;
|
||||
|
||||
write(mFifoFdOut, response.c_str(), response.size());
|
||||
mIsBusy = false;
|
||||
}
|
||||
|
||||
void RemoteControl::restoreOrientation(void)
|
||||
{
|
||||
qDebug().noquote().nospace() << "Restoring orientation";
|
||||
|
||||
QByteArray serialCommandAngle = Config::getCommand()->getCommandForInternal(COMMAND_ID::TURN_TO_DEGREES);
|
||||
|
||||
int16_t degreesVal = Config::getCurrentYaw() * 10;
|
||||
@@ -100,7 +103,6 @@ void RemoteControl::restoreOrientation(void)
|
||||
serialCommandAngle[10] = degreesVal & 0xFF;
|
||||
serialCommandAngle[11] = degreesVal >> 8;
|
||||
|
||||
qDebug().noquote().nospace() << serialCommandAngle;
|
||||
Config::getSerial()->sendCommand(serialCommandAngle);
|
||||
|
||||
QTimer::singleShot(1000, this, [this]() mutable { sendResponse(); });
|
||||
@@ -108,6 +110,8 @@ void RemoteControl::restoreOrientation(void)
|
||||
|
||||
void RemoteControl::restoreZoom(void)
|
||||
{
|
||||
qDebug().noquote().nospace() << "Restoring zoom";
|
||||
|
||||
QByteArray serialCommandZoom = Config::getCommand()->getCommandForInternal(COMMAND_ID::ZOOM_TO_X);
|
||||
|
||||
uint8_t integerPart = static_cast<uint8_t>(Config::getCurrentZoom());
|
||||
@@ -117,7 +121,6 @@ void RemoteControl::restoreZoom(void)
|
||||
serialCommandZoom[8] = integerPart;
|
||||
serialCommandZoom[9] = scaledFractional;
|
||||
|
||||
qDebug().noquote().nospace() << serialCommandZoom.toStdString();
|
||||
Config::getSerial()->sendCommand(serialCommandZoom);
|
||||
|
||||
QTimer::singleShot(3000, this, [this]() mutable { restoreOrientation(); });
|
||||
@@ -125,7 +128,7 @@ void RemoteControl::restoreZoom(void)
|
||||
|
||||
void RemoteControl::calculateTargetPosition(QJsonObject &commandObject)
|
||||
{
|
||||
qDebug().noquote().nospace() << "Calculating?";
|
||||
qDebug().noquote().nospace() << "Getting target location";
|
||||
|
||||
float latitude = commandObject["latitude"].toDouble();
|
||||
float longitude = commandObject["longitude"].toDouble();
|
||||
@@ -147,7 +150,7 @@ void RemoteControl::calculateTargetPosition(QJsonObject &commandObject)
|
||||
|
||||
void RemoteControl::turnToTarget(QJsonObject &commandObject)
|
||||
{
|
||||
qDebug().noquote().nospace() << "Turning?";
|
||||
qDebug().noquote().nospace() << "Turning to target";
|
||||
|
||||
uint16_t targetX = commandObject["target_x"].toInt();
|
||||
uint16_t targetY = commandObject["target_y"].toInt();
|
||||
@@ -173,7 +176,7 @@ void RemoteControl::turnToTarget(QJsonObject &commandObject)
|
||||
|
||||
void RemoteControl::zoomToTarget(QJsonObject &commandObject)
|
||||
{
|
||||
qDebug().noquote().nospace() << "Zooming?";
|
||||
qDebug().noquote().nospace() << "Zooming to target";
|
||||
|
||||
float fillRatio = 0.5;
|
||||
float targetPixelWidth = commandObject["target_pixel_width"].toInt();
|
||||
@@ -229,7 +232,7 @@ void RemoteControl::run()
|
||||
|
||||
// Exit with exit message
|
||||
if (commandObject.contains("extra") == true && commandObject["extra"] == "EXIT") {
|
||||
return;
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
mIsBusy = true;
|
||||
|
||||
@@ -35,7 +35,8 @@ QHash<QString, QVariant> SerialResponse::getResponceValues(QByteArray response)
|
||||
QHash<QString, QVariant> results;
|
||||
|
||||
if (response.size() == 0) {
|
||||
qCritical().noquote().nospace() << "Response is empty, exiting...";
|
||||
qWarning().noquote().nospace() << "Response is empty, exiting...";
|
||||
return results;
|
||||
}
|
||||
|
||||
// Check response data validity
|
||||
|
||||
@@ -72,3 +72,6 @@ CMakeLists.txt.user*
|
||||
*.dll
|
||||
*.exe
|
||||
|
||||
# Folders
|
||||
build/
|
||||
|
||||
|
||||
@@ -103,6 +103,10 @@ void RemoteControl::startCommunication()
|
||||
write(mFifoFdOut, command.c_str(), command.size());
|
||||
qDebug().noquote().nospace() << "Sent: " << command;
|
||||
|
||||
if (commandObject["extra"] == "EXIT") {
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
while (true) {
|
||||
char buffer[1024];
|
||||
ssize_t bytesRead = read(mFifoFdIn, buffer, sizeof(buffer) - 1);
|
||||
|
||||
Reference in New Issue
Block a user