mirror of
https://github.com/azaion/autopilot.git
synced 2026-04-22 10:06:34 +00:00
Removed blocking code from a8 and a8 remote.
This commit is contained in:
@@ -48,7 +48,7 @@ void RemoteControl::openNamedPipe()
|
||||
}
|
||||
}
|
||||
|
||||
mFifoFdIn = open(FIFO_TO_GIMBAL, O_RDONLY | O_NONBLOCK);
|
||||
mFifoFdIn = open(FIFO_TO_GIMBAL, O_RDWR | O_NONBLOCK);
|
||||
if (mFifoFdIn == -1) {
|
||||
qCritical().noquote().nospace() << "Error opening pipe for reading: " << FIFO_TO_GIMBAL;
|
||||
} else {
|
||||
@@ -206,14 +206,38 @@ void RemoteControl::zoomToTarget(QJsonObject &commandObject)
|
||||
|
||||
RectangleProperties RemoteControl::calculateRectangleProperties(uint16_t top, uint16_t left, uint16_t bottom, uint16_t right)
|
||||
{
|
||||
RectangleProperties properties;
|
||||
// Sanity check
|
||||
// top cannot be greater than bottom
|
||||
// left cannot be greater than right
|
||||
if (top > bottom) {
|
||||
uint16_t temp = top;
|
||||
top = bottom;
|
||||
bottom = temp;
|
||||
qWarning().noquote().nospace() << "calculateRectangleProperties(): top and bottom mixed?";
|
||||
}
|
||||
if (left > right) {
|
||||
uint16_t temp = left;
|
||||
left = right;
|
||||
right = temp;
|
||||
qWarning().noquote().nospace() << "calculateRectangleProperties(): left and right mixed?";
|
||||
}
|
||||
|
||||
RectangleProperties properties;
|
||||
properties.width = right - left;
|
||||
properties.height = bottom - top;
|
||||
|
||||
properties.middleX = static_cast<uint16_t>(left + properties.width / 2);
|
||||
properties.middleY = static_cast<uint16_t>(top + properties.height / 2);
|
||||
|
||||
// Sanity check, none cannot be 0
|
||||
// If that is the case, we will not turn or zoom
|
||||
if (properties.height == 0 || properties.width == 0 || properties.middleX == 0 || properties.middleY == 0) {
|
||||
properties.height = CAMERA_RESOLUTION_HEIGHT;
|
||||
properties.width = CAMERA_RESOLUTION_WIDTH;
|
||||
properties.middleX = CAMERA_RESOLUTION_WIDTH / 2;
|
||||
properties.middleY = CAMERA_RESOLUTION_HEIGHT / 2;
|
||||
qWarning().noquote().nospace() << "calculateRectangleProperties(): Something was zero -> No zoom, no turn!";
|
||||
}
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
@@ -265,6 +289,10 @@ void RemoteControl::run()
|
||||
commandObject["target_y"] = rectangle.middleY;
|
||||
commandObject["target_pixel_height"] = rectangle.height;
|
||||
commandObject["target_pixel_width"] = rectangle.width;
|
||||
qInfo() << "target_x: " << commandObject["target_x"];
|
||||
qInfo() << "target_y: " << commandObject["target_y"];
|
||||
qInfo() << "target_pixel_height: " << commandObject["target_pixel_height"];
|
||||
qInfo() << "target_pixel_width: " << commandObject["target_pixel_width"];
|
||||
|
||||
mIsBusy = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user