Changed serial connection to UDP connection.

Added ZR10 support.
Added automation to choose configuration.
This commit is contained in:
Nffj84
2024-10-14 21:18:27 +03:00
parent 2b2af3044e
commit a3d9137b77
16 changed files with 380 additions and 305 deletions
+29 -6
View File
@@ -8,8 +8,22 @@ AiEngineGimbalServer::AiEngineGimbalServer(QObject *parent)
: QObject{parent}
{
// TODO!! Setup and use serial port....
mIsAvailable = true;
mActions.setup(&mSerialPort, &mSerialCommand, &mSerialResponse, &mGimbalStatus);
mIsAvailable = false;
qDebug() << "Initial is available: " << mIsAvailable;
QTimer::singleShot(5000, this, [this]() {
mIsAvailable = true;
qDebug() << "Initial is available: " << mIsAvailable;
});
mActions.setup(&mUdpSocket, &mUdpCommand, &mUdpResponse, &mGimbalStatus);
// TODO: Remove after testing
mDronePosition.position.alt = 1000;
mDronePosition.position.lat = 49.8397;
mDronePosition.position.lon = 24.0319;
mDronePosition.pitch = 0.0;
mDronePosition.yaw = 90.0;
connect(&mActions, &AiEngineGimbalServerActions::aiTargetZoomed, this, &AiEngineGimbalServer::aiTargetZoomed);
}
@@ -32,8 +46,10 @@ void AiEngineGimbalServer::dronePositionSlot(AiEngineDronePosition dronePosition
// This is actually called from the client.
void AiEngineGimbalServer::zoomToAiTargetSlot(AiEngineCameraTarget target)
{
qDebug() << "zoomToAiTargetSlot called";
if (mIsAvailable == true) {
mIsAvailable = false;
qDebug() << "Is available: " << mIsAvailable;
qDebug() << "AiEngineGimbalServer::zoomToAiTargetSlot() Move camera to the new target:"
<< "index:" << target.index
@@ -41,12 +57,16 @@ void AiEngineGimbalServer::zoomToAiTargetSlot(AiEngineCameraTarget target)
// Rectangle calculation for having proper zoom on group / target
AiEngineRectangleProperties rectangle = mActions.calculateRectangleProperties(target.rectangle.top, target.rectangle.left, target.rectangle.bottom, target.rectangle.right);
qDebug() << "rectangle.middleX: " << rectangle.middleX;
qDebug() << "rectangle.middleY: " << rectangle.middleY;
qDebug() << "rectangle.width: " << rectangle.width;
qDebug() << "rectangle.height: " << rectangle.height;
// Turn
mActions.turnToTarget(rectangle);
// Calculate location
int delay1 = 1000; // Adjust this value as needed
int delay1 = 3000; // Adjust this value as needed
AiEngineDronePosition dronePosition = mDronePosition;
int targetIndex = target.index;
QTimer::singleShot(delay1, this, [this, dronePosition, targetIndex]() { mActions.getLocation(dronePosition, targetIndex); });
@@ -61,8 +81,11 @@ void AiEngineGimbalServer::zoomToAiTargetSlot(AiEngineCameraTarget target)
QTimer::singleShot(delay3, this, [this, gimbalStatus]() { mActions.restoreOrientationAndZoom(gimbalStatus); });
// Allow calls
int delay4 = delay3 + 100; // Adjust this value as needed
QTimer::singleShot(delay4, this, [this]() { mIsAvailable = true; });
int delay4 = delay3 + 3000; // Adjust this value as needed
QTimer::singleShot(delay4, this, [this]() {
mIsAvailable = true;
qDebug() << "Is available: " << mIsAvailable;
});
}
}
@@ -76,5 +99,5 @@ bool AiEngineGimbalServer::isAvailable(void)
// TODO!! Not sent from the client yet.
void AiEngineGimbalServer::cameraPositionSlot(AiEngineCameraPosition position)
{
qDebug() << "SAiEngineGimbalServer::cameraPositionSlot() Move camera to:" << position.pitch << position.yaw << "zoom:" << position.zoom;
qDebug() << "AiEngineGimbalServer::cameraPositionSlot() Move camera to:" << position.pitch << position.yaw << "zoom:" << position.zoom;
}