diff --git a/qgcunittest.pro b/qgcunittest.pro new file mode 100644 index 0000000000000000000000000000000000000000..d8612b2b1efdbd57d02d67461f26ab79bffadae4 --- /dev/null +++ b/qgcunittest.pro @@ -0,0 +1,137 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2011-01-11T08:54:37 +# +#------------------------------------------------- + +QT += network \ + phonon \ + testlib \ + svg + +TEMPLATE = app + +TARGET = tst_uasunittest + +BASEDIR = $$IN_PWD +TESTDIR = $$BASEDIR/qgcunittest +TARGETDIR = $$OUT_PWD +BUILDDIR = $$TARGETDIR/build +LANGUAGE = C++ + +CONFIG += console +CONFIG -= app_bundle + +OBJECTS_DIR = $$BUILDDIR/obj +MOC_DIR = $$BUILDDIR/moc +UI_HEADERS_DIR = src/ui/generated +MAVLINK_CONF = "" + +# If the user config file exists, it will be included. +# if the variable MAVLINK_CONF contains the name of an +# additional project, QGroundControl includes the support +# of custom MAVLink messages of this project +exists(user_config.pri) { + include(user_config.pri) + message("----- USING CUSTOM USER QGROUNDCONTROL CONFIG FROM user_config.pri -----") + message("Adding support for additional MAVLink messages for: " $$MAVLINK_CONF) + message("------------------------------------------------------------------------") +} + +INCLUDEPATH += $$BASEDIR/../mavlink/include/common +contains(MAVLINK_CONF, pixhawk) { + # Remove the default set - it is included anyway + INCLUDEPATH -= $$BASEDIR/../mavlink/include/common + + # PIXHAWK SPECIAL MESSAGES + INCLUDEPATH += $$BASEDIR/../mavlink/include/pixhawk + DEFINES += QGC_USE_PIXHAWK_MESSAGES +} +contains(MAVLINK_CONF, slugs) { + # Remove the default set - it is included anyway + INCLUDEPATH -= $$BASEDIR/../mavlink/include/common + + # SLUGS SPECIAL MESSAGES + INCLUDEPATH += $$BASEDIR/../mavlink/include/slugs + DEFINES += QGC_USE_SLUGS_MESSAGES +} +contains(MAVLINK_CONF, ualberta) { + # Remove the default set - it is included anyway + INCLUDEPATH -= $$BASEDIR/../mavlink/include/common + + # UALBERTA SPECIAL MESSAGES + INCLUDEPATH += $$BASEDIR/../mavlink/include/ualberta + DEFINES += QGC_USE_UALBERTA_MESSAGES +} +contains(MAVLINK_CONF, ardupilotmega) { + # Remove the default set - it is included anyway + INCLUDEPATH -= $$BASEDIR/../mavlink/include/common + + # UALBERTA SPECIAL MESSAGES + INCLUDEPATH += $$BASEDIR/../mavlink/include/ardupilotmega + DEFINES += QGC_USE_ARDUPILOTMEGA_MESSAGES +} + +# Include general settings for MAVGround +# necessary as last include to override any non-acceptable settings +# done by the plugins above +include(qgroundcontrol.pri) + +# QWT plot and QExtSerial depend on paths set by qgroundcontrol.pri +# Include serial port library +include(src/lib/qextserialport/qextserialport.pri) + +# Include QWT plotting library +include(src/lib/qwt/qwt.pri) +DEPENDPATH += . \ + lib/QMapControl \ + lib/QMapControl/src \ + plugins +INCLUDEPATH += . \ + lib/QMapControl \ + $$BASEDIR/../mavlink/include \ + $$BASEDIR/src/uas \ + $$BASEDIR/src/comm \ + $$BASEDIR/src/ \ + $$BASEDIR/src/ui/RadioCalibration \ + $$BASEDIR/src/ui/ \ + + +SOURCES += $$TESTDIR/tst_uasunittest.cc \ + src/uas/UAS.cc \ + src/comm/MAVLinkProtocol.cc \ + src/uas/UASWaypointManager.cc \ + src/Waypoint.cc \ + src/ui/RadioCalibration/RadioCalibrationData.cc \ + src/uas/SlugsMAV.cc \ + src/uas/PxQuadMAV.cc \ + src/uas/ArduPilotMegaMAV.cc \ + src/GAudioOutput.cc \ + src/uas/UASManager.cc \ + src/comm/LinkManager.cc \ + src/QGC.cc \ + src/comm/SerialLink.cc \ + +HEADERS += src/uas/UASInterface.h \ + src/uas/UAS.h \ + src/comm/MAVLinkProtocol.h \ + src/comm/ProtocolInterface.h \ + src/uas/UASWaypointManager.h \ + src/Waypoint.h \ + src/ui/RadioCalibration/RadioCalibrationData.h \ + src/uas/SlugsMAV.h \ + src/uas/PxQuadMAV.h \ + src/uas/ArduPilotMegaMAV.h \ + src/GAudioOutput.h \ + src/uas/UASManager.h \ + src/comm/LinkManager.h \ + src/comm/LinkInterface.h \ + src/QGC.h \ + src/comm/SerialLinkInterface.h \ + src/comm/SerialLink.h \ + + + + + +DEFINES += SRCDIR=\\\"$$PWD/\\\" diff --git a/qgcunittest/tst_uasunittest.cc b/qgcunittest/tst_uasunittest.cc new file mode 100644 index 0000000000000000000000000000000000000000..d2d7e91f70d2fb7f99997f0d1a7f4fe69e403502 --- /dev/null +++ b/qgcunittest/tst_uasunittest.cc @@ -0,0 +1,186 @@ +#include +#include +#include "UAS.h" +#include "MAVLinkProtocol.h" +#include "UASInterface.h" + +class UASUnitTest : public QObject +{ + Q_OBJECT + +public: + #define UASID 50 + MAVLinkProtocol* mav; + UAS* uas; + UASUnitTest(); + +private Q_SLOTS: + void initTestCase(); + void cleanupTestCase(); + void getUASID_test(); + void getUASName_test(); + void getUpTime_test(); + void getCommunicationStatus_test(); + void filterVoltage_test(); + void getAutopilotType_test(); + void setAutopilotType_test(); + void getStatusForCode_test(); + void getLocalX_test(); + void getLocalY_test(); + void getLocalZ_test(); + void getLatitude_test(); + void getLongitude_test(); + void getAltitude_test(); + void getRoll_test(); + void getPitch_test(); + void getYaw_test(); + void calculateTimeRemaining_test(); + + +private: + +protected: + UAS *prueba; +}; + +UASUnitTest::UASUnitTest() +{ +} + +void UASUnitTest::initTestCase() +{ + mav= new MAVLinkProtocol(); + uas=new UAS(mav,UASID); +} + +void UASUnitTest::cleanupTestCase() +{ + delete uas; + delete mav; + +} + +void UASUnitTest::getUASID_test() +{ + // Test a default ID of zero is assigned + UAS* uas2 = new UAS(mav); + QCOMPARE(uas2->getUASID(), 0); + delete uas2; + + // Test that the chosen ID was assigned at construction + QCOMPARE(uas->getUASID(), UASID); + + // Make sure that no other ID was sert + QEXPECT_FAIL("", "When you set an ID it does not use the default ID of 0", Continue); + QCOMPARE(uas->getUASID(), 0); +} + +void UASUnitTest::getUASName_test() +{ + // Test that the name is build as MAV + ID + QCOMPARE(uas->getUASName(), "MAV 0" + QString::number(UASID)); + +} + +void UASUnitTest::getUpTime_test() +{ + UAS* uas2 = new UAS(mav); + // Test that the uptime starts at zero to a + // precision of seconds + QCOMPARE(floor(uas2->getUptime()/1000.0), 0.0); + + // Sleep for three seconds + QTest::qSleep(3000); + + // Test that the up time is computed correctly to a + // precision of seconds + QCOMPARE(floor(uas2->getUptime()/1000.0), 3.0); + + delete uas2; +} + +void UASUnitTest::getCommunicationStatus_test() +{ + // Verify that upon construction the Comm status is disconnected + QCOMPARE(uas->getCommunicationStatus(), static_cast(UASInterface::COMM_DISCONNECTED)); +} + +void UASUnitTest::filterVoltage_test() +{ + float verificar=uas->filterVoltage(0.4f); + // Verify that upon construction the Comm status is disconnected + QCOMPARE(verificar, 8.52f); +} +void UASUnitTest:: getAutopilotType_test() +{ + int verificar=uas->getAutopilotType(); + // Verify that upon construction the Comm status is disconnected + QCOMPARE(verificar, -1); +} +void UASUnitTest::setAutopilotType_test() +{ + uas->setAutopilotType(2); + // Verify that upon construction the Comm status is disconnected + QCOMPARE(uas->getAutopilotType(), 2); +} +void UASUnitTest::getStatusForCode_test() +{ + // Verify that upon construction the Comm status is disconnected + QCOMPARE(uas->getYaw(), 0.0); +} +void UASUnitTest::getLocalX_test() +{ + + // Verify that upon construction the Comm status is disconnected + QCOMPARE(uas->getLocalX(), 0.0); +} +void UASUnitTest::getLocalY_test() +{ + + // Verify that upon construction the Comm status is disconnected + QCOMPARE(uas->getLocalY(), 0.0); +} +void UASUnitTest::getLocalZ_test() +{ + + // Verify that upon construction the Comm status is disconnected + QCOMPARE(uas->getLocalZ(), 0.0); +} +void UASUnitTest::getLatitude_test() +{ + // Verify that upon construction the Comm status is disconnected + QCOMPARE(uas->getLatitude(), 0.0); +} +void UASUnitTest::getLongitude_test() +{ + // Verify that upon construction the Comm status is disconnected + QCOMPARE(uas->getLongitude(), 0.0); +} +void UASUnitTest::getAltitude_test() +{ + // Verify that upon construction the Comm status is disconnected + QCOMPARE(uas->getAltitude(), 0.0); +} +void UASUnitTest::getRoll_test() +{ + // Verify that upon construction the Comm status is disconnected + QCOMPARE(uas->getRoll(), 0.0); +} +void UASUnitTest::getPitch_test() +{ + // Verify that upon construction the Comm status is disconnected + QCOMPARE(uas->getPitch(), 0.0); +} +void UASUnitTest::getYaw_test() +{ + // Verify that upon construction the Comm status is disconnected + QCOMPARE(uas->getYaw(), 0.0); +} +void UASUnitTest::calculateTimeRemaining_test() +{ + /* + */ +} +QTEST_APPLESS_MAIN(UASUnitTest); + +#include "tst_uasunittest.moc" diff --git a/qgroundcontrol.pri b/qgroundcontrol.pri index 3d9f79f864ebb9ab1e4db81e158cf49ab72c73fd..f846c60db2671460785bc69f416384ec14913d81 100644 --- a/qgroundcontrol.pri +++ b/qgroundcontrol.pri @@ -86,12 +86,12 @@ macx { ICON = $$BASEDIR/images/icons/macx.icns # Copy audio files if needed - QMAKE_POST_LINK += && cp -rf $$BASEDIR/audio $$TARGETDIR/qgroundcontrol.app/Contents/MacOs + QMAKE_POST_LINK += && cp -rf $$BASEDIR/audio $$TARGETDIR/qgroundcontrol.app/Contents/MacOS # Copy google earth starter file - QMAKE_POST_LINK += && cp -f $$BASEDIR/images/earth.html $$TARGETDIR/qgroundcontrol.app/Contents/MacOs + QMAKE_POST_LINK += && cp -f $$BASEDIR/images/earth.html $$TARGETDIR/qgroundcontrol.app/Contents/MacOS # Copy CSS stylesheets - QMAKE_POST_LINK += && cp -f $$BASEDIR/images/style-mission.css $$TARGETDIR/qgroundcontrol.app/Contents/MacOs/style-indoor.css - QMAKE_POST_LINK += && cp -f $$BASEDIR/images/style-outdoor.css $$TARGETDIR/qgroundcontrol.app/Contents/MacOs + QMAKE_POST_LINK += && cp -f $$BASEDIR/images/style-mission.css $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/style-indoor.css + QMAKE_POST_LINK += && cp -f $$BASEDIR/images/style-outdoor.css $$TARGETDIR/qgroundcontrol.app/Contents/MacOS # Copy model files #QMAKE_POST_LINK += && cp -f $$BASEDIR/models/*.dae $$TARGETDIR/qgroundcontrol.app/Contents/MacOs @@ -171,8 +171,10 @@ linux-g++ { QMAKE_POST_LINK += cp -rf $$BASEDIR/audio $$DESTDIR/. +message("Compiling for linux 32") + INCLUDEPATH += /usr/include \ - /usr/local/include \ + /usr/local/include \ /usr/include/qt4/phonon # $$BASEDIR/lib/flite/include \ # $$BASEDIR/lib/flite/lang diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index d7f08375fbce77bee367e19b085630ce33e68c05..e93696961c71989ce10c33d982a0cb80621dde63 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -54,6 +54,7 @@ exists(user_config.pri) { message("Adding support for additional MAVLink messages for: " $$MAVLINK_CONF) message("------------------------------------------------------------------------") } + INCLUDEPATH += $$BASEDIR/../mavlink/include/common contains(MAVLINK_CONF, pixhawk) { # Remove the default set - it is included anyway diff --git a/src/GAudioOutput.h b/src/GAudioOutput.h index a4889829d3ddcb14c8964b8ca616bc930fccf396..b30a26c7b34eab9987bac77f7c094a9e6016a0dd 100644 --- a/src/GAudioOutput.h +++ b/src/GAudioOutput.h @@ -40,8 +40,8 @@ This file is part of the PIXHAWK project #endif #ifdef Q_OS_LINUX //#include -#include -#include +#include +#include #endif #ifdef Q_OS_WIN #include diff --git a/src/comm/MAVLinkProtocol.cc b/src/comm/MAVLinkProtocol.cc index a8d5184f7b5e0772832214c83cf2092d9d424a93..187681fc0f9fcbac098a152b20b48e3db86f1e1d 100644 --- a/src/comm/MAVLinkProtocol.cc +++ b/src/comm/MAVLinkProtocol.cc @@ -26,7 +26,7 @@ #include "ArduPilotMegaMAV.h" #include "configuration.h" #include "LinkManager.h" -#include "MainWindow.h" +//#include "MainWindow.h" #include #include "QGC.h" @@ -242,6 +242,7 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) } else { + // TODO: This if-else block can (should) be greatly simplified if (lastIndex[message.sysid][message.compid] == 255) { lastIndex[message.sysid][message.compid] = 0; diff --git a/src/uas/SlugsMAV.cc b/src/uas/SlugsMAV.cc index 7692bd4966a2ffa7e301131d75c0831fccf676ff..6126ab0a88df410225c934f01e7f1dd8bb7e9d1e 100644 --- a/src/uas/SlugsMAV.cc +++ b/src/uas/SlugsMAV.cc @@ -60,98 +60,100 @@ SlugsMAV::SlugsMAV(MAVLinkProtocol* mavlink, int id) : void SlugsMAV::receiveMessage(LinkInterface* link, mavlink_message_t message) { // Let UAS handle the default message set - UAS::receiveMessage(link, message); + UAS::receiveMessage(link, message); if (message.sysid == uasId) { - // Handle your special messages mavlink_message_t* msg = &message; - switch (message.msgid) - { + // Handle your special messages mavlink_message_t* msg = &message; + switch (message.msgid) + { #ifdef MAVLINK_ENABLED_SLUGS - case MAVLINK_MSG_ID_BOOT: - mavlink_msg_boot_decode(&message,&mlBoot); - emit slugsBootMsg(uasId, mlBoot); - break; + case MAVLINK_MSG_ID_RAW_IMU: + mavlink_msg_raw_imu_decode(&message, &mlRawImuData); + break; - case MAVLINK_MSG_ID_ATTITUDE: - mavlink_msg_attitude_decode(&message, &mlAttitude); - break; + case MAVLINK_MSG_ID_BOOT: + mavlink_msg_boot_decode(&message,&mlBoot); + emit slugsBootMsg(uasId, mlBoot); + break; - case MAVLINK_MSG_ID_GPS_RAW: - mavlink_msg_gps_raw_decode(&message, &mlGpsData); - break; + case MAVLINK_MSG_ID_ATTITUDE: + mavlink_msg_attitude_decode(&message, &mlAttitude); + break; - case MAVLINK_MSG_ID_ACTION_ACK: // 62 - mavlink_msg_action_ack_decode(&message,&mlActionAck); + case MAVLINK_MSG_ID_GPS_RAW: + mavlink_msg_gps_raw_decode(&message, &mlGpsData); break; - case MAVLINK_MSG_ID_CPU_LOAD: //170 - mavlink_msg_cpu_load_decode(&message,&mlCpuLoadData); + case MAVLINK_MSG_ID_ACTION_ACK: // 62 + mavlink_msg_action_ack_decode(&message,&mlActionAck); break; - case MAVLINK_MSG_ID_AIR_DATA: //171 - mavlink_msg_air_data_decode(&message,&mlAirData); + case MAVLINK_MSG_ID_CPU_LOAD: //170 + mavlink_msg_cpu_load_decode(&message,&mlCpuLoadData); break; - case MAVLINK_MSG_ID_SENSOR_BIAS: //172 - mavlink_msg_sensor_bias_decode(&message,&mlSensorBiasData); + case MAVLINK_MSG_ID_AIR_DATA: //171 + mavlink_msg_air_data_decode(&message,&mlAirData); break; - case MAVLINK_MSG_ID_DIAGNOSTIC: //173 - mavlink_msg_diagnostic_decode(&message,&mlDiagnosticData); - break; + case MAVLINK_MSG_ID_SENSOR_BIAS: //172 + mavlink_msg_sensor_bias_decode(&message,&mlSensorBiasData); + break; - case MAVLINK_MSG_ID_PILOT_CONSOLE: //174 - mavlink_msg_pilot_console_decode(&message,&mlPilotConsoleData); - break; - - case MAVLINK_MSG_ID_PWM_COMMANDS: //175 - mavlink_msg_pwm_commands_decode(&message,&mlPwmCommands); - break; + case MAVLINK_MSG_ID_DIAGNOSTIC: //173 + mavlink_msg_diagnostic_decode(&message,&mlDiagnosticData); + break; - case MAVLINK_MSG_ID_SLUGS_NAVIGATION://176 - mavlink_msg_slugs_navigation_decode(&message,&mlNavigation); + case MAVLINK_MSG_ID_PILOT_CONSOLE: //174 + mavlink_msg_pilot_console_decode(&message,&mlPilotConsoleData); break; - case MAVLINK_MSG_ID_DATA_LOG: //177 - mavlink_msg_data_log_decode(&message,&mlDataLog); - break; + case MAVLINK_MSG_ID_PWM_COMMANDS: //175 + mavlink_msg_pwm_commands_decode(&message,&mlPwmCommands); + break; - case MAVLINK_MSG_ID_FILTERED_DATA: //178 - mavlink_msg_filtered_data_decode(&message,&mlFilteredData); + case MAVLINK_MSG_ID_SLUGS_NAVIGATION://176 + mavlink_msg_slugs_navigation_decode(&message,&mlNavigation); break; - case MAVLINK_MSG_ID_GPS_DATE_TIME: //179 - mavlink_msg_gps_date_time_decode(&message,&mlGpsDateTime); - break; + case MAVLINK_MSG_ID_DATA_LOG: //177 + mavlink_msg_data_log_decode(&message,&mlDataLog); + break; - case MAVLINK_MSG_ID_MID_LVL_CMDS: //180 + case MAVLINK_MSG_ID_FILTERED_DATA: //178 + mavlink_msg_filtered_data_decode(&message,&mlFilteredData); + break; + case MAVLINK_MSG_ID_GPS_DATE_TIME: //179 + mavlink_msg_gps_date_time_decode(&message,&mlGpsDateTime); break; - case MAVLINK_MSG_ID_CTRL_SRFC_PT: //181 + case MAVLINK_MSG_ID_MID_LVL_CMDS: //180 - break; + break; - case MAVLINK_MSG_ID_PID: //182 - memset(&mlSinglePid,0,sizeof(mavlink_pid_t)); - mavlink_msg_pid_decode(&message, &mlSinglePid); - qDebug() << "\nSLUGS RECEIVED PID Message = "<target_system = uas.getUASID(); wp->target_component = MAV_COMP_ID_WAYPOINTPLANNER; emit updateStatusString(QString("Sending waypoint ID %1 of %2 total").arg(wp->seq).arg(current_count)); + qDebug() << "sent waypoint (" << wp->seq << ") to ID " << wp->target_system<<" WP Buffer count: "<getSystemId(), uas.mavlink->getComponentId(), &message, wp); uas.sendMessage(message); MG::SLEEP::usleep(PROTOCOL_DELAY_MS * 1000); - qDebug() << "sent waypoint (" << wp->seq << ") to ID " << wp->target_system; } } diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 74b9f660bcc3e68cb9358ce9f65a0ac24acf8140..2fd26ce8d733413928efa0f5cb920fc496bdca13 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -172,11 +172,6 @@ MainWindow::MainWindow(QWidget *parent): // Create actions connectCommonActions(); - // Add option for custom widgets - connect(ui.actionNewCustomWidget, SIGNAL(triggered()), this, SLOT(createCustomWidget())); - // Allow to mute audio - ui.actionMuteAudioOutput->setChecked(GAudioOutput::instance()->isMuted()); - connect(ui.actionMuteAudioOutput, SIGNAL(triggered(bool)), GAudioOutput::instance(), SLOT(mute(bool))); // Set dock options setDockOptions(AnimatedDocks | AllowTabbedDocks | AllowNestedDocks); @@ -344,6 +339,21 @@ void MainWindow::buildCommonWidgets() addToCentralWidgetsMenu (protocolWidget, "Mavlink Generator", SLOT(showCentralWidget()),CENTRAL_PROTOCOL); } + //TODO temporaly debug + if (!slugsHilSimWidget) + { + slugsHilSimWidget = new QDockWidget(tr("Slugs Hil Sim"), this); + slugsHilSimWidget->setWidget( new SlugsHilSim(this)); + addToToolsMenu (slugsHilSimWidget, tr("HIL Sim Configuration"), SLOT(showToolWidget()), MENU_SLUGS_HIL, Qt::LeftDockWidgetArea); + } + + //TODO temporaly debug + if (!slugsCamControlWidget) + { + slugsCamControlWidget = new QDockWidget(tr("Slugs Video Camera Control"), this); + slugsCamControlWidget->setWidget(new SlugsVideoCamControl(this)); + addToToolsMenu (slugsCamControlWidget, tr("Camera Control"), SLOT(showToolWidget()), MENU_SLUGS_CAMERA, Qt::BottomDockWidgetArea); + } if (!dataplotWidget) { dataplotWidget = new QGCDataPlot2D(this); @@ -695,8 +705,8 @@ void MainWindow::addToToolsMenu ( QWidget* widget, // connect the action connect(tempAction,SIGNAL(triggered()),this, slotName); - connect(qobject_cast (dockWidgets[tool]), - SIGNAL(visibilityChanged(bool)), this, SLOT(updateVisibilitySettings(bool))); +// connect(qobject_cast (dockWidgets[tool]), +// SIGNAL(visibilityChanged(bool)), this, SLOT(updateVisibilitySettings(bool))); connect(qobject_cast (dockWidgets[tool]), SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), this, SLOT(updateLocationSettings(Qt::DockWidgetArea))); @@ -720,6 +730,7 @@ void MainWindow::showToolWidget() removeDockWidget(qobject_cast(dockWidgets[tool])); } } + } @@ -798,11 +809,9 @@ void MainWindow::updateVisibilitySettings (bool vis) if (temp) { QHashIterator i(dockWidgets); - while (i.hasNext()) - { + while (i.hasNext()) { i.next(); - if ((static_cast (dockWidgets[i.key()])) == temp) - { + if ((static_cast (dockWidgets[i.key()])) == temp) { QString chKey = buildMenuKey (SUB_SECTION_CHECKED,static_cast(i.key()), currentView); settings.setValue(chKey,vis); toolsMenuActions[i.key()]->setChecked(vis); @@ -851,6 +860,12 @@ void MainWindow::connectCommonWidgets() // it notifies that a waypoint global goes to do create and a map graphic too connect(waypointsDockWidget->widget(), SIGNAL(createWaypointAtMap(QPointF)), mapWidget, SLOT(createWaypointGraphAtMap(QPointF))); } + + //TODO temporaly debug + if (slugsHilSimWidget && slugsHilSimWidget->widget()){ + connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), + slugsHilSimWidget->widget(), SLOT(activeUasSet(UASInterface*))); + } } void MainWindow::createCustomWidget() @@ -1363,10 +1378,10 @@ void MainWindow::UASCreated(UASInterface* uas) // Connect Pixhawk Actions connectPxActions(); - } break; + loadOperatorView(); } // Change the view only if this is the first UAS @@ -1388,7 +1403,7 @@ void MainWindow::UASCreated(UASInterface* uas) if (settings.contains(getWindowStateKey())) { restoreState(settings.value(getWindowStateKey()).toByteArray(), QGC::applicationVersion()); - } + } } else @@ -1460,11 +1475,11 @@ void MainWindow::loadEngineerView() { if (currentView != VIEW_ENGINEER) { - clearView(); + clearView(); - currentView = VIEW_ENGINEER; + currentView = VIEW_ENGINEER; - presentView(); + presentView(); } } @@ -1472,11 +1487,11 @@ void MainWindow::loadOperatorView() { if (currentView != VIEW_OPERATOR) { - clearView(); + clearView(); - currentView = VIEW_OPERATOR; + currentView = VIEW_OPERATOR; - presentView(); + presentView(); } } @@ -1484,11 +1499,11 @@ void MainWindow::loadPilotView() { if (currentView != VIEW_PILOT) { - clearView(); + clearView(); - currentView = VIEW_PILOT; + currentView = VIEW_PILOT; - presentView(); + presentView(); } } @@ -1496,11 +1511,11 @@ void MainWindow::loadMAVLinkView() { if (currentView != VIEW_MAVLINK) { - clearView(); + clearView(); - currentView = VIEW_MAVLINK; + currentView = VIEW_MAVLINK; - presentView(); + presentView(); } } @@ -1568,7 +1583,7 @@ void MainWindow::presentView() if (settings.value(buildMenuKey (SUB_SECTION_CHECKED,MENU_HUD,currentView)).toBool()) { addDockWidget(static_cast (settings.value(buildMenuKey (SUB_SECTION_LOCATION,MENU_HUD, currentView)).toInt()), - hsiDockWidget); + headUpDockWidget); headUpDockWidget->show(); } else @@ -1646,7 +1661,7 @@ void MainWindow::loadDataView(QString fileName) if (dataplotWidget) { dataplotWidget->loadFile(fileName); - } + } // QStackedWidget *centerStack = dynamic_cast(centralWidget()); // if (centerStack) // { diff --git a/src/ui/MapWidget.cc b/src/ui/MapWidget.cc index e2a95a1043576057ac5fef607f6e186b0d1d5792..9608b2809b5c42aa9b933d41f5b74a4b3e2998af 100644 --- a/src/ui/MapWidget.cc +++ b/src/ui/MapWidget.cc @@ -813,7 +813,8 @@ void MapWidget::changeGlobalWaypointPositionBySpinBox(int index, float lat, floa void MapWidget::updateCameraPosition(double radio, double bearing, QString dir) { - // FIXME Mariano + Q_UNUSED(bearing); + Q_UNUSED(dir); //camPoints.clear(); QPointF currentPos = mc->currentCoordinate(); // QPointF actualPos = getPointxBearing_Range(currentPos.y(),currentPos.x(),bearing,distance); diff --git a/src/ui/SlugsDataSensorView.cc b/src/ui/SlugsDataSensorView.cc index c8a12cd56a61860670c546e09003cc47e434be98..f975cc0b142fadc74cc394058b0a4885eb34633f 100644 --- a/src/ui/SlugsDataSensorView.cc +++ b/src/ui/SlugsDataSensorView.cc @@ -28,7 +28,7 @@ SlugsDataSensorView::~SlugsDataSensorView() void SlugsDataSensorView::addUAS(UASInterface* uas) { - SlugsMAV* slugsMav = dynamic_cast(uas); + SlugsMAV* slugsMav = qobject_cast(uas); if (slugsMav != NULL) { @@ -104,7 +104,7 @@ void SlugsDataSensorView::slugsGlobalPositionChanged(UASInterface *uas, ui->m_GpsLongitude->setText(QString::number(lon)); ui->m_GpsHeight->setText(QString::number(alt)); - qDebug()<<"GPS Position = "<m_Pitch->setPlainText(QString::number(slugpitch)); ui->m_Yaw->setPlainText(QString::number(slugyaw)); - qDebug()<<"Attitude change = "<0 0 399 - 604 + 598 @@ -31,18 +31,18 @@ Form - + - 1 + 0 Tab 1 - - + + @@ -2904,1003 +2904,995 @@ Tab 3 - - - - - - - - 0 - 0 - - - - - 132123 - 123123 - - - - CPU Load - - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - Sensor - - - - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - Control - - - - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - Batt Volt - - - - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - + + + + + + 0 + 0 + + + + + 132123 + 123123 + + + + CPU Load + + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + Sensor + + - - - - - - - - 0 - 0 - - - - - 132123 - 123123 - - - - Air Data - - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - Dynamic - - - - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - Static - - - - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - Temperature - - - - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - + + + + + 60 + 18 + + + + + 80 + 18 + + + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + Control + + + + + + + + 60 + 18 + + + + + 80 + 18 + + + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + Batt Volt + + + + + + + + 60 + 18 + + + + + 80 + 18 + + + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + - - - + + + - - + + - 311 - 213 + 0 + 0 - 371 - 213 + 132123 + 123123 - Filtered Data + Air Data - - - + + + - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - Ax - - - - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - Ay - - - - - - - - 0 - 0 - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - Az - - - - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + Dynamic + + - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - Gx - - - - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - Gy - - - - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - Gz - - - - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - + + + + + 60 + 18 + + + + + 80 + 18 + + + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + Static + + + + + + + + 60 + 18 + + + + + 80 + 18 + + + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + Temperature + + + + + + + + 60 + 18 + + + + + 80 + 18 + + + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + + + + + + + + 311 + 213 + + + + + 371 + 213 + + + + Filtered Data + + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + Ax + + + + + + + + 60 + 18 + + + + + 80 + 18 + + + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + Ay + + + + + + + + 0 + 0 + + + + + 60 + 18 + + + + + 80 + 18 + + + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - Mx - - - - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - My - - - - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - Mz - - - - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + Az + + + + + + + + 60 + 18 + + + + + 80 + 18 + + + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + Gx + + + + + + + + 60 + 18 + + + + + 80 + 18 + + + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + Gy + + + + + + + + 60 + 18 + + + + + 80 + 18 + + + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + Gz + + + + + + + + 60 + 18 + + + + + 80 + 18 + + + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + Mx + + + + + + + + 60 + 18 + + + + + 80 + 18 + + + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + My + + + + + + + + 60 + 18 + + + + + 80 + 18 + + + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + Mz + + - - - Qt::Vertical + + + + 60 + 18 + - + - 20 - 40 + 80 + 18 - + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + Qt::Vertical + + + + 20 + 84 + + + + - + @@ -3917,567 +3909,563 @@ Raw Data - - - + + + - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - Ax - - - - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - Ay - - - - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - Az - - - - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + Ax + + + + + + + + 60 + 18 + + + + + 80 + 18 + + + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - Gx - - - - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - Gy - - - - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - Gz - - - - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + Ay + + + + + + + + 60 + 18 + + + + + 80 + 18 + + + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + Az + + + + + + + + 60 + 18 + + + + + 80 + 18 + + + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + Gx + + + + + + + + 60 + 18 + + + + + 80 + 18 + + + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + Gy + + + + + + + + 60 + 18 + + + + + 80 + 18 + + + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - Mx - - - - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - My - - - - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - Mz - - - - - - - - 60 - 18 - - - - - 80 - 18 - - - - - 10 - - - - QFrame::WinPanel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + Gz + + + + + + + + 60 + 18 + + + + + 80 + 18 + + + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + Mx + + + + + + + + 60 + 18 + + + + + 80 + 18 + + + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + My + + + + + + + + 60 + 18 + + + + + 80 + 18 + + + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + 75 + true + + + + Mz + + - - - Qt::Vertical + + + + 60 + 18 + - + - 20 - 40 + 80 + 18 - + + + 10 + + + + QFrame::WinPanel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + Qt::Vertical + + + + 20 + 84 + + + + diff --git a/src/ui/SlugsHilSim.cc b/src/ui/SlugsHilSim.cc index a5c584f7c85689c1b8ba114de62316ed12ee4107..bec83ea050975990412794f767a6606fec761a9f 100644 --- a/src/ui/SlugsHilSim.cc +++ b/src/ui/SlugsHilSim.cc @@ -25,12 +25,13 @@ This file is part of the QGROUNDCONTROL project * @file * @brief Configuration Window for Slugs' HIL Simulator * @author Mariano Lizarraga + * @author Alejandro Molina */ #include "SlugsHilSim.h" #include "ui_SlugsHilSim.h" -#include "LinkManager.h" + SlugsHilSim::SlugsHilSim(QWidget *parent) : QWidget(parent), @@ -49,6 +50,18 @@ SlugsHilSim::SlugsHilSim(QWidget *parent) : connect(rxSocket, SIGNAL(readyRead()), this, SLOT(readDatagram())); linksAvailable.clear(); + + memset(&tmpAirData, 0, sizeof(mavlink_air_data_t)); + memset(&tmpAttitudeData, 0, sizeof(mavlink_attitude_t)); + memset(&tmpGpsData, 0, sizeof(mavlink_gps_raw_t)); + memset(&tmpGpsTime, 0, sizeof(mavlink_gps_date_time_t)); + memset(&tmpLocalPositionData, 0, sizeof(mavlink_sensor_bias_t)); + memset(&tmpRawImuData, 0, sizeof(mavlink_raw_imu_t)); + + foreach (LinkInterface* link, LinkManager::instance()->getLinks()) + { + addToCombo(link); + } } SlugsHilSim::~SlugsHilSim() @@ -59,8 +72,8 @@ SlugsHilSim::~SlugsHilSim() void SlugsHilSim::addToCombo(LinkInterface* theLink){ - ui->cb_mavlinkLinks->addItem(theLink->getName()); linksAvailable.insert(ui->cb_mavlinkLinks->count(),theLink); + ui->cb_mavlinkLinks->addItem(theLink->getName()); if (hilLink == NULL){ hilLink = theLink; @@ -121,6 +134,10 @@ void SlugsHilSim::readDatagram(void){ if (datagram.size() == 113) { processHilDatagram(&datagram); + + sendMessageToSlugs(); + + commandDatagramToSimulink(); } ui->ed_count->setText(QString::number(count++)); @@ -141,12 +158,6 @@ void SlugsHilSim::processHilDatagram(const QByteArray* datagram) #ifdef MAVLINK_ENABLED_SLUGS unsigned char i = 0; - mavlink_message_t msg; - - // GPS - mavlink_gps_raw_t tmpGpsRaw; - - mavlink_gps_date_time_t tmpGpsTime; tmpGpsTime.year = datagram->at(i++); tmpGpsTime.month = datagram->at(i++); @@ -155,31 +166,64 @@ void SlugsHilSim::processHilDatagram(const QByteArray* datagram) tmpGpsTime.min = datagram->at(i++); tmpGpsTime.sec = datagram->at(i++); - tmpGpsRaw.lat = getFloatFromDatagram(datagram, &i); - tmpGpsRaw.lon = getFloatFromDatagram(datagram, &i); - tmpGpsRaw.alt = getFloatFromDatagram(datagram, &i); + tmpGpsData.lat = getFloatFromDatagram(datagram, &i); + tmpGpsData.lon = getFloatFromDatagram(datagram, &i); + tmpGpsData.alt = getFloatFromDatagram(datagram, &i); - tmpGpsRaw.hdg = getUint16FromDatagram(datagram, &i); - tmpGpsRaw.v = getUint16FromDatagram(datagram, &i); - tmpGpsRaw.eph = getUint16FromDatagram(datagram, &i); + tmpGpsData.hdg = getUint16FromDatagram(datagram, &i); + tmpGpsData.v = getUint16FromDatagram(datagram, &i); - tmpGpsRaw.fix_type = datagram->at(i++); + tmpGpsData.eph = getUint16FromDatagram(datagram, &i); + tmpGpsData.fix_type = datagram->at(i++); tmpGpsTime.visSat = datagram->at(i++); + i++; - mavlink_msg_gps_date_time_encode(MG::SYSTEM::ID,MG::SYSTEM::COMPID, &msg, &tmpGpsTime); - activeUas->sendMessage(hilLink, msg); - - memset(&msg, 0, sizeof(mavlink_message_t)); - - mavlink_msg_gps_raw_encode(MG::SYSTEM::ID,MG::SYSTEM::COMPID, &msg, &tmpGpsRaw); - activeUas->sendMessage(hilLink,msg); + tmpAirData.dynamicPressure= getFloatFromDatagram(datagram, &i); + tmpAirData.staticPressure= getFloatFromDatagram(datagram, &i); + tmpAirData.temperature= getUint16FromDatagram(datagram, &i); + + // TODO Salto en el Datagrama + i=i+8; + + tmpRawImuData.xgyro = getUint16FromDatagram(datagram, &i); + tmpRawImuData.ygyro = getUint16FromDatagram(datagram, &i); + tmpRawImuData.zgyro = getUint16FromDatagram(datagram, &i); + tmpRawImuData.xacc = getUint16FromDatagram(datagram, &i); + tmpRawImuData.yacc = getUint16FromDatagram(datagram, &i); + tmpRawImuData.zacc = getUint16FromDatagram(datagram, &i); + tmpRawImuData.xmag = getUint16FromDatagram(datagram, &i); + tmpRawImuData.ymag = getUint16FromDatagram(datagram, &i); + tmpRawImuData.zmag = getUint16FromDatagram(datagram, &i); + + tmpAttitudeData.roll = getFloatFromDatagram(datagram, &i); + tmpAttitudeData.pitch = getFloatFromDatagram(datagram, &i); + tmpAttitudeData.yaw = getFloatFromDatagram(datagram, &i); + + tmpAttitudeData.rollspeed = getFloatFromDatagram(datagram, &i); + tmpAttitudeData.pitchspeed = getFloatFromDatagram(datagram, &i); + tmpAttitudeData.yawspeed = getFloatFromDatagram(datagram, &i); + + // TODO Crear Paquete SYNC TIME + i=i+2; + + tmpLocalPositionData.x = getFloatFromDatagram(datagram, &i); + tmpLocalPositionData.y = getFloatFromDatagram(datagram, &i); + tmpLocalPositionData.z = getFloatFromDatagram(datagram, &i); + tmpLocalPositionData.vx = getFloatFromDatagram(datagram, &i); + tmpLocalPositionData.vy = getFloatFromDatagram(datagram, &i); + tmpLocalPositionData.vz = getFloatFromDatagram(datagram, &i); // TODO: this is legacy of old HIL datagram. Need to remove from Simulink model i++; - ui->ed_1->setText(QString::number(tmpGpsRaw.hdg)); - ui->ed_2->setText(QString::number(tmpGpsRaw.v)); - ui->ed_3->setText(QString::number(tmpGpsRaw.eph)); + ui->ed_1->setText(QString::number(tmpRawImuData.xacc)); + ui->ed_2->setText(QString::number(tmpRawImuData.yacc)); + ui->ed_3->setText(QString::number(tmpRawImuData.zacc)); + + ui->tbA->setText(QString::number(tmpRawImuData.xgyro)); + ui->tbB->setText(QString::number(tmpRawImuData.ygyro)); + ui->tbC->setText(QString::number(tmpRawImuData.zgyro)); + #else Q_UNUSED(datagram); #endif @@ -207,6 +251,97 @@ uint16_t SlugsHilSim::getUint16FromDatagram (const QByteArray* datagram, unsigne } void SlugsHilSim::linkSelected(int cbIndex){ + #ifdef MAVLINK_ENABLED_SLUGS + // HIL code to go here... //hilLink = linksAvailable // FIXME Mariano + + hilLink =linksAvailable.value(cbIndex); + + #endif +} + +void SlugsHilSim::sendMessageToSlugs() +{ + mavlink_message_t msg; + + mavlink_msg_local_position_encode(MG::SYSTEM::ID, + MG::SYSTEM::COMPID, + &msg, + &tmpLocalPositionData); + activeUas->sendMessage(hilLink, msg); + memset(&msg, 0, sizeof(mavlink_message_t)); + + mavlink_msg_attitude_encode(MG::SYSTEM::ID, + MG::SYSTEM::COMPID, + &msg, + &tmpAttitudeData); + activeUas->sendMessage(hilLink, msg); + memset(&msg, 0, sizeof(mavlink_message_t)); + + mavlink_msg_raw_imu_encode(MG::SYSTEM::ID, + MG::SYSTEM::COMPID, + &msg, + &tmpRawImuData); + activeUas->sendMessage(hilLink, msg); + memset(&msg, 0, sizeof(mavlink_message_t)); + + mavlink_msg_air_data_encode(MG::SYSTEM::ID, + MG::SYSTEM::COMPID, + &msg, + &tmpAirData); + activeUas->sendMessage(hilLink, msg); + memset(&msg, 0, sizeof(mavlink_message_t)); + + mavlink_msg_gps_raw_encode(MG::SYSTEM::ID, + MG::SYSTEM::COMPID, + &msg, + &tmpGpsData); + activeUas->sendMessage(hilLink, msg); + memset(&msg, 0, sizeof(mavlink_message_t)); + + mavlink_msg_gps_date_time_encode(MG::SYSTEM::ID, + MG::SYSTEM::COMPID, + &msg, + &tmpGpsTime); + activeUas->sendMessage(hilLink, msg); + memset(&msg, 0, sizeof(mavlink_message_t)); +} + + +void SlugsHilSim::commandDatagramToSimulink() +{ + //mavlink_pwm_commands_t* pwdC = (static_cast(activeUas))->getPwmCommands(); + + mavlink_pwm_commands_t* pwdC; + + if(pwdC != NULL){ + } + + QByteArray data; + data.resize(22); + + unsigned char i=0; + setUInt16ToDatagram(data, &i, 1);//pwdC->dt_c); + setUInt16ToDatagram(data, &i, 2);//pwdC->dla_c); + setUInt16ToDatagram(data, &i, 3);//pwdC->dra_c); + setUInt16ToDatagram(data, &i, 4);//pwdC->dr_c); + setUInt16ToDatagram(data, &i, 5);//pwdC->dle_c); + setUInt16ToDatagram(data, &i, 6);//pwdC->dre_c); + setUInt16ToDatagram(data, &i, 7);//pwdC->dlf_c); + setUInt16ToDatagram(data, &i, 8);//pwdC->drf_c); + setUInt16ToDatagram(data, &i, 9);//pwdC->aux1); + setUInt16ToDatagram(data, &i, 10);//pwdC->aux2); + setUInt16ToDatagram(data, &i, 11);//value default + + txSocket->writeDatagram(data, QHostAddress::Broadcast, ui->ed_txPort->text().toInt()); +} + +void SlugsHilSim::setUInt16ToDatagram(QByteArray& datagram, unsigned char* pos, uint16_t value) +{ + tUint16ToChar tmpUnion; + tmpUnion.uiData= value; + + datagram[(*pos)++]= tmpUnion.chData[0]; + datagram[(*pos)++]= tmpUnion.chData[1]; } diff --git a/src/ui/SlugsHilSim.h b/src/ui/SlugsHilSim.h index dc0d8d1d7a90909656c29145de053c7231470cb3..16f42f223b953844d7210f2bec840fc84d2134e7 100644 --- a/src/ui/SlugsHilSim.h +++ b/src/ui/SlugsHilSim.h @@ -30,14 +30,19 @@ This file is part of the QGROUNDCONTROL project #ifndef SLUGSHILSIM_H #define SLUGSHILSIM_H +#include + #include #include #include #include +#include + #include "LinkInterface.h" #include "UAS.h" -#include +#include "LinkManager.h" +#include "SlugsMAV.h" namespace Ui { @@ -52,6 +57,8 @@ public: explicit SlugsHilSim(QWidget *parent = 0); ~SlugsHilSim(); + + protected: LinkInterface* hilLink; QHostAddress* simulinkIp; @@ -59,6 +66,13 @@ protected: QUdpSocket* rxSocket; UAS* activeUas; + mavlink_local_position_t tmpLocalPositionData; + mavlink_attitude_t tmpAttitudeData; + mavlink_raw_imu_t tmpRawImuData; + mavlink_air_data_t tmpAirData; + mavlink_gps_raw_t tmpGpsData; + mavlink_gps_date_time_t tmpGpsTime; + public slots: /** @@ -121,11 +135,18 @@ private: } tUint16ToChar; Ui::SlugsHilSim *ui; + QHash linksAvailable; void processHilDatagram (const QByteArray* datagram); float getFloatFromDatagram (const QByteArray* datagram, unsigned char * i); uint16_t getUint16FromDatagram (const QByteArray* datagram, unsigned char * i); + void setUInt16ToDatagram(QByteArray& datagram, unsigned char* pos, uint16_t value); + + + void sendMessageToSlugs(); + + void commandDatagramToSimulink(); }; diff --git a/src/ui/SlugsHilSim.ui b/src/ui/SlugsHilSim.ui index 6ed975ca47e28fd913cb87f1326346dac1ba5d51..7edcb1ea7f22c4b8a1c2443c6145572307063668 100644 --- a/src/ui/SlugsHilSim.ui +++ b/src/ui/SlugsHilSim.ui @@ -6,7 +6,7 @@ 0 0 - 325 + 337 278 @@ -349,6 +349,19 @@ + + + + + + + + + + + + + diff --git a/src/ui/SlugsPIDControl.cpp b/src/ui/SlugsPIDControl.cpp index d9abe37f37838c034f42a48a5e5e0610f1cf5e31..dd6b2fccc2c83b707669c21b12884ea125e7eac6 100644 --- a/src/ui/SlugsPIDControl.cpp +++ b/src/ui/SlugsPIDControl.cpp @@ -23,7 +23,7 @@ SlugsPIDControl::SlugsPIDControl(QWidget *parent) : setGreenColorStyle(); refreshTimerGet = new QTimer(this); - refreshTimerGet->setInterval(100); // 20 Hz + refreshTimerGet->setInterval(100); // 10 Hz connect(refreshTimerGet, SIGNAL(timeout()), this, SLOT(slugsGetGeneral())); @@ -47,9 +47,9 @@ SlugsPIDControl::SlugsPIDControl(QWidget *parent) : void SlugsPIDControl::activeUasSet(UASInterface* uas) { #ifdef MAVLINK_ENABLED_SLUGS - SlugsMAV* slugsMav = dynamic_cast(uas); + SlugsMAV* slugsMav = qobject_cast(uas); - if (slugsMav != NULL) + if (slugsMav) { connect(slugsMav,SIGNAL(slugsActionAck(int,const mavlink_action_ack_t&)),this,SLOT(recibeMensaje(int,mavlink_action_ack_t))); connect(slugsMav,SIGNAL(slugsPidValues(int,mavlink_pid_t)),this, SLOT(receivePidValues(int,mavlink_pid_t)) ); @@ -58,15 +58,14 @@ void SlugsPIDControl::activeUasSet(UASInterface* uas) connect(ui->getGeneral_pushButton,SIGNAL(clicked()),this,SLOT(slugsTimerStartGet())); } -#endif // MAVLINK_ENABLED_SLUG + #endif // MAVLINK_ENABLED_SLUG + // Set this UAS as active if it is the first one - if(activeUAS == 0) + if(!activeUAS) { activeUAS = uas; systemId = activeUAS->getUASID(); connect_editLinesPDIvalues(); - - //qDebug()<<"------------------->Active UAS ID: "<getUASID(); } } @@ -507,6 +506,7 @@ void SlugsPIDControl::get_Pitch2dT_PID() void SlugsPIDControl::recibeMensaje(int systemId, const mavlink_action_ack_t& action) { + Q_UNUSED(systemId); ui->recepcion_label->setText(QString::number(action.action) + ":" + QString::number(action.result)); } diff --git a/src/ui/SlugsPadCameraControl.cpp b/src/ui/SlugsPadCameraControl.cpp index fdbad00146e75f9d1f76b97662392f12c2fb782c..bee159a52c6e0231623309595d609ff5ae3eeac7 100644 --- a/src/ui/SlugsPadCameraControl.cpp +++ b/src/ui/SlugsPadCameraControl.cpp @@ -26,16 +26,14 @@ SlugsPadCameraControl::~SlugsPadCameraControl() void SlugsPadCameraControl::mouseMoveEvent(QMouseEvent *event) { + Q_UNUSED(event); //emit mouseMoveCoord(event->x(),event->y()); + if(dragging) { - if(abs(x1-event->x())>20 || abs(y1-event->y())>20) - { - getDeltaPositionPad(event->x(), event->y()); - x1 = event->x(); - y1 = event->y(); - } + // getDeltaPositionPad(event->x(), event->y()); + } @@ -54,7 +52,7 @@ void SlugsPadCameraControl::mouseReleaseEvent(QMouseEvent *event) { dragging = false; //emit mouseReleaseCoord(event->x(),event->y()); - //getDeltaPositionPad(event->x(), event->y()); + getDeltaPositionPad(event->x(), event->y()); xFin = event->x(); yFin = event->y(); @@ -105,6 +103,10 @@ void SlugsPadCameraControl::getDeltaPositionPad(int x2, int y2) double bearing = localMeasures.x(); double dist = getDistPixel(y1,x1,y2,x2); + // this only convert real bearing to frame widget bearing + bearing = bearing +90; + if(bearing>= 360) bearing = bearing - 360; + if(((bearing > 330)&&(bearing < 360)) || ((bearing >= 0)&&(bearing <= 30))) @@ -210,16 +212,9 @@ double SlugsPadCameraControl::getDistPixel(int x1, int y1, int x2, int y2) // distancia = (float) hipotenusa; } -/** - * Esta función xxxxxxxxx - * @param double lat1 --> - * @param double lon1 --> - * @param double lat2 --> - * @param double lon2 --> - * @param ref double rumbo --> - * @param ref double distancia --> - */ -QPointF SlugsPadCameraControl::ObtenerMarcacionDistanciaPixel(double lon1, double lat1, double lon2, double lat2) + +QPointF SlugsPadCameraControl::ObtenerMarcacionDistanciaPixel(double lon1, double lat1, + double lon2, double lat2) { double cateto_opuesto,cateto_adyacente, hipotenusa, distancia; double marcacion = 0.0; @@ -257,9 +252,7 @@ QPointF SlugsPadCameraControl::ObtenerMarcacionDistanciaPixel(double lon1, doubl else if((lat1 == lat2) && (lon1 == lon2)) //0 marcacion = 0.0; - // this only convert real bearing to frame widget bearing - marcacion = marcacion +90; - if(marcacion>= 360) marcacion = marcacion - 360; + return QPointF(marcacion,distancia); diff --git a/src/ui/SlugsPadCameraControl.h b/src/ui/SlugsPadCameraControl.h index bb35976cf2952d27c775f7ba1e6b7174e1f83495..dbf555088868714785ea3b04530003f55d1658a4 100644 --- a/src/ui/SlugsPadCameraControl.h +++ b/src/ui/SlugsPadCameraControl.h @@ -19,12 +19,16 @@ public: public slots: void getDeltaPositionPad(int x, int y); + + + double getDistPixel(int x1, int y1, int x2, int y2); QPointF ObtenerMarcacionDistanciaPixel(double lon1, double lat1, double lon2, double lat2); QPointF getPointBy_BearingDistance(double lat1, double lon1, double rumbo, double distancia); + signals: void mouseMoveCoord(int x, int y); void mousePressCoord(int x, int y); diff --git a/src/ui/SlugsVideoCamControl.ui b/src/ui/SlugsVideoCamControl.ui index c89c2e7ef26e6c05ecb9e103c616c02506d1934b..7bbe214933ae49d2fc3bc199e2161806de3d4178 100644 --- a/src/ui/SlugsVideoCamControl.ui +++ b/src/ui/SlugsVideoCamControl.ui @@ -22,10 +22,10 @@ Form - - - - + + + + true @@ -35,7 +35,7 @@ - + true @@ -45,21 +45,17 @@ - - + + - Camera Pos + Camera at Map - - - - - - + + - Camera at Map + Camera Pos diff --git a/src/ui/designer/QGCParamSlider.cc b/src/ui/designer/QGCParamSlider.cc index 6164cfcf1891d4e039eb71a27124a771fc38ecae..a78728008d720e2fded5288f7bcc03caf86d9141 100644 --- a/src/ui/designer/QGCParamSlider.cc +++ b/src/ui/designer/QGCParamSlider.cc @@ -1,10 +1,12 @@ #include #include +#include #include "QGCParamSlider.h" #include "ui_QGCParamSlider.h" #include "UASInterface.h" + QGCParamSlider::QGCParamSlider(QWidget *parent) : QGCToolWidgetItem("Slider", parent), parameterName(""),