From ad478a4e954dc524854cd4ae38d28fcea16e347c Mon Sep 17 00:00:00 2001 From: Davide Mor <davide.mor@skywarder.eu> Date: Thu, 15 Aug 2024 18:29:47 +0200 Subject: [PATCH] [OrientationVisualizer] Added Rocket VN100 as a possible source --- .../OrientationVisualizer.cpp | 51 ++++++++++++------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/src/shared/Modules/OrientationVisualizer/OrientationVisualizer.cpp b/src/shared/Modules/OrientationVisualizer/OrientationVisualizer.cpp index 9d0ca4a8..78ea1c8b 100644 --- a/src/shared/Modules/OrientationVisualizer/OrientationVisualizer.cpp +++ b/src/shared/Modules/OrientationVisualizer/OrientationVisualizer.cpp @@ -41,15 +41,28 @@ OrientationVisualizer::OrientationVisualizer() if (nullptr == sourceComboBox) return; - if (sourceComboBox->currentText() != "Rocket" && - sourceComboBox->currentText() != "Both") - return; - QQuaternion q( - static_cast<float>(message.getField("nas_qw").getDouble()), - static_cast<float>(message.getField("nas_qx").getDouble()), - static_cast<float>(message.getField("nas_qy").getDouble()), - static_cast<float>(message.getField("nas_qz").getDouble())); - updateOrientation(q); + if (sourceComboBox->currentText() == "Rocket") + { + QQuaternion q( + static_cast<float>(message.getField("nas_qw").getDouble()), + static_cast<float>(message.getField("nas_qx").getDouble()), + static_cast<float>(message.getField("nas_qy").getDouble()), + static_cast<float>(message.getField("nas_qz").getDouble())); + updateOrientation(q); + } + + if (sourceComboBox->currentText() == "Rocket VN100") + { + QQuaternion q(static_cast<float>( + message.getField("vn100_qw").getDouble()), + static_cast<float>( + message.getField("vn100_qx").getDouble()), + static_cast<float>( + message.getField("vn100_qy").getDouble()), + static_cast<float>( + message.getField("vn100_qz").getDouble())); + updateOrientation(q); + } }); MessageBroker::getInstance().subscribe( Filter::fromString("Mav/PAYLOAD_FLIGHT_TM"), this, @@ -58,15 +71,15 @@ OrientationVisualizer::OrientationVisualizer() if (nullptr == sourceComboBox) return; - if (sourceComboBox->currentText() != "Payload" && - sourceComboBox->currentText() != "Both") - return; - QQuaternion q( - static_cast<float>(message.getField("nas_qw").getDouble()), - static_cast<float>(message.getField("nas_qx").getDouble()), - static_cast<float>(message.getField("nas_qy").getDouble()), - static_cast<float>(message.getField("nas_qz").getDouble())); - updateOrientation(q); + if (sourceComboBox->currentText() == "Payload") + { + QQuaternion q( + static_cast<float>(message.getField("nas_qw").getDouble()), + static_cast<float>(message.getField("nas_qx").getDouble()), + static_cast<float>(message.getField("nas_qy").getDouble()), + static_cast<float>(message.getField("nas_qz").getDouble())); + updateOrientation(q); + } }); } @@ -116,7 +129,7 @@ void OrientationVisualizer::setupUi() QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); sourceComboBox = new QComboBox; sourceComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents); - sourceComboBox->addItems({"Rocket", "Payload", "Both"}); + sourceComboBox->addItems({"Rocket", "Rocket VN100", "Payload"}); lower->addWidget(sourceLabel); lower->addWidget(sourceComboBox); -- GitLab