diff --git a/patterns/a.bmp b/patterns/a.bmp new file mode 100644 index 0000000000000000000000000000000000000000..34a902cd2b1f907b86e3f1a863e9ef9f66bc8d67 Binary files /dev/null and b/patterns/a.bmp differ diff --git a/patterns/board-center.png b/patterns/board-center.png new file mode 100644 index 0000000000000000000000000000000000000000..59d7ebf7e5d7346c7ab400bbbe7d5697fd482403 Binary files /dev/null and b/patterns/board-center.png differ diff --git a/patterns/board-left.png b/patterns/board-left.png new file mode 100644 index 0000000000000000000000000000000000000000..9026eea200f975bb453b6c0c538c41e97eb8b9c8 Binary files /dev/null and b/patterns/board-left.png differ diff --git a/patterns/board-right.png b/patterns/board-right.png new file mode 100644 index 0000000000000000000000000000000000000000..6d21644cc8b6d5f79606e4945d75f4cc7972d6f7 Binary files /dev/null and b/patterns/board-right.png differ diff --git a/patterns/einstein.bmp b/patterns/einstein.bmp new file mode 100644 index 0000000000000000000000000000000000000000..ee30094cfd507445ddf6078984fb29958f6d601d Binary files /dev/null and b/patterns/einstein.bmp differ diff --git a/patterns/face1.png b/patterns/face1.png new file mode 100644 index 0000000000000000000000000000000000000000..7c9c97d82774f7084839da868af8c8b6d152fefa Binary files /dev/null and b/patterns/face1.png differ diff --git a/patterns/face1_fisheye.png b/patterns/face1_fisheye.png new file mode 100644 index 0000000000000000000000000000000000000000..2d078e155ac848ae661175f11f365c26c3b3cf3d Binary files /dev/null and b/patterns/face1_fisheye.png differ diff --git a/patterns/face1_light.png b/patterns/face1_light.png new file mode 100644 index 0000000000000000000000000000000000000000..8ef441620019d68b714fd573f14f53d1f2cd79a9 Binary files /dev/null and b/patterns/face1_light.png differ diff --git a/patterns/face1_noise.png b/patterns/face1_noise.png new file mode 100644 index 0000000000000000000000000000000000000000..8d6eae061d1ba74921681f9ab7b7ebd9cf129470 Binary files /dev/null and b/patterns/face1_noise.png differ diff --git a/patterns/face1_noise_fisheye.png b/patterns/face1_noise_fisheye.png new file mode 100644 index 0000000000000000000000000000000000000000..1c1e678a5eee2fad868d0a33fbbb4c24710c6de6 Binary files /dev/null and b/patterns/face1_noise_fisheye.png differ diff --git a/patterns/face1_noise_light.png b/patterns/face1_noise_light.png new file mode 100644 index 0000000000000000000000000000000000000000..817520fc53fd0c9382cce78031e659d8a5f65c93 Binary files /dev/null and b/patterns/face1_noise_light.png differ diff --git a/patterns/face1_noise_light_fisheye.png b/patterns/face1_noise_light_fisheye.png new file mode 100644 index 0000000000000000000000000000000000000000..247e26372a5f983430b5cbab8b871feeb695197c Binary files /dev/null and b/patterns/face1_noise_light_fisheye.png differ diff --git a/patterns/face2.png b/patterns/face2.png new file mode 100644 index 0000000000000000000000000000000000000000..63a87d5cfee4d00e8e3ba5c1a6f2a95bf34d3515 Binary files /dev/null and b/patterns/face2.png differ diff --git a/patterns/face3.png b/patterns/face3.png new file mode 100644 index 0000000000000000000000000000000000000000..1c61d580271d2553ef5f17da08fd5963d601e50f Binary files /dev/null and b/patterns/face3.png differ diff --git a/patterns/face3_perspect1.png b/patterns/face3_perspect1.png new file mode 100644 index 0000000000000000000000000000000000000000..5d1be767d2d2fb6b42216458dd17cb9796877605 Binary files /dev/null and b/patterns/face3_perspect1.png differ diff --git a/patterns/face3_perspect2.png b/patterns/face3_perspect2.png new file mode 100644 index 0000000000000000000000000000000000000000..ff24a14fcd1462122ec306eaf95627203efe5949 Binary files /dev/null and b/patterns/face3_perspect2.png differ diff --git a/patterns/face3_perspect3.png b/patterns/face3_perspect3.png new file mode 100644 index 0000000000000000000000000000000000000000..72fbd8ef620775a5ac118afcec4a777555be216c Binary files /dev/null and b/patterns/face3_perspect3.png differ diff --git a/patterns/face4.png b/patterns/face4.png new file mode 100644 index 0000000000000000000000000000000000000000..b18858f7c3635f4cccd20afd7b38ca346327bcc9 Binary files /dev/null and b/patterns/face4.png differ diff --git a/patterns/face4_treshold1.png b/patterns/face4_treshold1.png new file mode 100644 index 0000000000000000000000000000000000000000..c133f17fd13512354571fbcf7cac8dcf84d25c6e Binary files /dev/null and b/patterns/face4_treshold1.png differ diff --git a/patterns/face4_treshold2.png b/patterns/face4_treshold2.png new file mode 100644 index 0000000000000000000000000000000000000000..3fb48b68458be4ad1718df1473690599b3a95747 Binary files /dev/null and b/patterns/face4_treshold2.png differ diff --git a/patterns/face5.png b/patterns/face5.png new file mode 100644 index 0000000000000000000000000000000000000000..b42231e5da8b46f492e58f22f24fe2e96ca55bd7 Binary files /dev/null and b/patterns/face5.png differ diff --git a/patterns/face5_perspect1.png b/patterns/face5_perspect1.png new file mode 100644 index 0000000000000000000000000000000000000000..e7b183531f7f46344f0580cb3823bd32ba0bbb27 Binary files /dev/null and b/patterns/face5_perspect1.png differ diff --git a/patterns/face5_threshold.png b/patterns/face5_threshold.png new file mode 100644 index 0000000000000000000000000000000000000000..b997043cdfae8d2b2659ba42d07db5ba2e556d8f Binary files /dev/null and b/patterns/face5_threshold.png differ diff --git a/patterns/floors1.png b/patterns/floors1.png new file mode 100644 index 0000000000000000000000000000000000000000..90023f3faa63fdd7a1659674083510e0dbaf20c2 Binary files /dev/null and b/patterns/floors1.png differ diff --git a/patterns/floors2.png b/patterns/floors2.png new file mode 100644 index 0000000000000000000000000000000000000000..3f1051de6e004cd3a2f47c837d4d2cd9ae057c89 Binary files /dev/null and b/patterns/floors2.png differ diff --git a/patterns/floors5.png b/patterns/floors5.png new file mode 100644 index 0000000000000000000000000000000000000000..8316e972058c1820661ef216190c25fef85ea998 Binary files /dev/null and b/patterns/floors5.png differ diff --git a/patterns/floors6.png b/patterns/floors6.png new file mode 100644 index 0000000000000000000000000000000000000000..92e6121f404d28d897b653cd4d09959ee8ee6f35 Binary files /dev/null and b/patterns/floors6.png differ diff --git a/patterns/frame_2010-03-17_2_rect.bmp b/patterns/frame_2010-03-17_2_rect.bmp new file mode 100644 index 0000000000000000000000000000000000000000..bdb9178ce8c82935fda1f161dada6e3466a3d66c Binary files /dev/null and b/patterns/frame_2010-03-17_2_rect.bmp differ diff --git a/patterns/frame_2010-03-17_3_rect.bmp b/patterns/frame_2010-03-17_3_rect.bmp new file mode 100644 index 0000000000000000000000000000000000000000..8a02375941b5b74210b465d6485765f5ad61c9a3 Binary files /dev/null and b/patterns/frame_2010-03-17_3_rect.bmp differ diff --git a/patterns/frog.bmp b/patterns/frog.bmp new file mode 100644 index 0000000000000000000000000000000000000000..8de068b7a51d429080d25e48208ae929b046d882 Binary files /dev/null and b/patterns/frog.bmp differ diff --git a/patterns/letterB.png b/patterns/letterB.png new file mode 100644 index 0000000000000000000000000000000000000000..de8dec9cf8d4b7ff09031ab77b19a5d637b65549 Binary files /dev/null and b/patterns/letterB.png differ diff --git a/patterns/letterD.png b/patterns/letterD.png new file mode 100644 index 0000000000000000000000000000000000000000..f96b3e8fe696a9e3164923779125d37101ca57bf Binary files /dev/null and b/patterns/letterD.png differ diff --git a/patterns/letterP.png b/patterns/letterP.png new file mode 100644 index 0000000000000000000000000000000000000000..4ee1a56ad59ebb9de8cc7ef7429d867858ce7419 Binary files /dev/null and b/patterns/letterP.png differ diff --git a/patterns/letterP_light.png b/patterns/letterP_light.png new file mode 100644 index 0000000000000000000000000000000000000000..976e6f38c6a29d16cd4dfcba368b5543f503213a Binary files /dev/null and b/patterns/letterP_light.png differ diff --git a/patterns/letterP_noise.png b/patterns/letterP_noise.png new file mode 100644 index 0000000000000000000000000000000000000000..cdb9da9a1a10f20fcbc783f3571706c7ae88ff16 Binary files /dev/null and b/patterns/letterP_noise.png differ diff --git a/patterns/letterR.png b/patterns/letterR.png new file mode 100644 index 0000000000000000000000000000000000000000..2329f1464f23bd6ecd2d3b39f73c6392266c53ba Binary files /dev/null and b/patterns/letterR.png differ diff --git a/patterns/letterR_strongnoise.png b/patterns/letterR_strongnoise.png new file mode 100644 index 0000000000000000000000000000000000000000..eaa1b9e3ca54905d6a1c9b7eb7dc19418efa44d4 Binary files /dev/null and b/patterns/letterR_strongnoise.png differ diff --git a/patterns/letterS.png b/patterns/letterS.png new file mode 100644 index 0000000000000000000000000000000000000000..4cb14b1b69909e6d943e471d3a0c6ae4086706b0 Binary files /dev/null and b/patterns/letterS.png differ diff --git a/patterns/santa-delft.png b/patterns/santa-delft.png new file mode 100644 index 0000000000000000000000000000000000000000..c3a30e662e853199d63e7390ef8cac102d671f64 Binary files /dev/null and b/patterns/santa-delft.png differ diff --git a/patterns/stereo_left01.png b/patterns/stereo_left01.png new file mode 100644 index 0000000000000000000000000000000000000000..6fc657c9d5a057fa419bd9b236903c05bcba49b4 Binary files /dev/null and b/patterns/stereo_left01.png differ diff --git a/patterns/stereo_right01.png b/patterns/stereo_right01.png new file mode 100644 index 0000000000000000000000000000000000000000..5680912e725e98f3231bfe7f229c9e5de7d1b9f2 Binary files /dev/null and b/patterns/stereo_right01.png differ diff --git a/patterns/white.png b/patterns/white.png new file mode 100644 index 0000000000000000000000000000000000000000..0fbbc057e184b0227da45ee8df7a027f43906524 Binary files /dev/null and b/patterns/white.png differ diff --git a/qgroundcontrol.pri b/qgroundcontrol.pri index 9a7571da56511fc14262998ce130a68af0116a6b..1189c7aef19abcfc6abf3f3b548b93f7a4a93d55 100644 --- a/qgroundcontrol.pri +++ b/qgroundcontrol.pri @@ -25,21 +25,6 @@ # #------------------------------------------------- -QT += network opengl svg xml phonon - -TEMPLATE = app -TARGET = qgroundcontrol - -BASEDIR = . -BUILDDIR = build -LANGUAGE = C++ - -CONFIG += debug_and_release console - -OBJECTS_DIR = $$BUILDDIR/obj -MOC_DIR = $$BUILDDIR/moc -UI_HEADERS_DIR = src/ui/generated - #$$BASEDIR/lib/qextserialport/include # $$BASEDIR/lib/openjaus/libjaus/include \ # $$BASEDIR/lib/openjaus/libopenJaus/include diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 7407e706fef07701ee7dd8c1da675567cb510fd2..5d47625c18cc95d68b68ada88d284b7cc3637225 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -8,6 +8,22 @@ include(lib/QMapControl/QMapControl.pri) message("Including bundled QMapControl version as FALLBACK. This is fine on Linux and MacOS, but not the best choice in Windows") + +QT += network opengl svg xml phonon + +TEMPLATE = app +TARGET = qgroundcontrol + +BASEDIR = . +BUILDDIR = build +LANGUAGE = C++ + +CONFIG += debug_and_release console + +OBJECTS_DIR = $$BUILDDIR/obj +MOC_DIR = $$BUILDDIR/moc +UI_HEADERS_DIR = src/ui/generated + # } # Include general settings for MAVGround # necessary as last include to override any non-acceptable settings @@ -22,7 +38,8 @@ include(src/lib/qextserialport/qextserialport.pri) include(src/lib/qwt/qwt.pri) DEPENDPATH += . \ lib/QMapControl \ - lib/QMapControl/src + lib/QMapControl/src \ + plugins INCLUDEPATH += . \ lib/QMapControl \ ../mavlink/include \ @@ -124,7 +141,8 @@ HEADERS += src/MG.h \ src/ui/watchdog/WatchdogControl.h \ src/ui/watchdog/WatchdogProcessView.h \ src/ui/watchdog/WatchdogView.h \ - src/uas/UASWaypointManager.h + src/uas/UASWaypointManager.h \ + src/ui/HSIDisplay.h SOURCES += src/main.cc \ src/Core.cc \ src/uas/UASManager.cc \ @@ -178,5 +196,6 @@ SOURCES += src/main.cc \ src/ui/watchdog/WatchdogControl.cc \ src/ui/watchdog/WatchdogProcessView.cc \ src/ui/watchdog/WatchdogView.cc \ - src/uas/UASWaypointManager.cc + src/uas/UASWaypointManager.cc \ + src/ui/HSIDisplay.cc RESOURCES = mavground.qrc diff --git a/src/Core.cc b/src/Core.cc index 9ae80bb01fc085f4dd1fc8bbec8b21ecc4deda28..5cccf453a959a6f2a999ccfd8cd772de81c843e7 100644 --- a/src/Core.cc +++ b/src/Core.cc @@ -131,7 +131,7 @@ Core::Core(int &argc, char* argv[]) : QApplication(argc, argv) } } - // MAVLinkSimulationLink* simulationLink = new MAVLinkSimulationLink(MG::DIR::getSupportFilesDirectory() + "/demo-log.txt"); + // MAVLinkSimulationLink* simulationLink = new MAVLinkSimulationLink(MG::DIR::getSupportFilesDirectory() + "/demo-log.txt"); MAVLinkSimulationLink* simulationLink = new MAVLinkSimulationLink(":/demo-log.txt"); mainWindow->addLink(simulationLink); } @@ -164,7 +164,42 @@ void Core::startLinkManager() **/ void Core::startUASManager() { - UASManager::instance(); + // Load UAS plugins + QDir pluginsDir = QDir(qApp->applicationDirPath()); + +#if defined(Q_OS_WIN) + if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release") + pluginsDir.cdUp(); +#elif defined(Q_OS_LINUX) + if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release") + pluginsDir.cdUp(); +#elif defined(Q_OS_MAC) + if (pluginsDir.dirName() == "MacOS") + { + pluginsDir.cdUp(); + pluginsDir.cdUp(); + pluginsDir.cdUp(); + } +#endif + pluginsDir.cd("plugins"); + + UASManager* m = UASManager::instance(); + + // Load plugins + + QStringList pluginFileNames; + + foreach (QString fileName, pluginsDir.entryList(QDir::Files)) + { + QPluginLoader loader(pluginsDir.absoluteFilePath(fileName)); + QObject *plugin = loader.instance(); + if (plugin) + { + //populateMenus(plugin); + pluginFileNames += fileName; + printf(QString("Loaded plugin from " + fileName + "\n").toStdString().c_str()); + } + } } diff --git a/src/plugins/.gitignore b/src/plugins/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d32bef15ffee7c4a8bbdd9511fdd3b7bed7d0ad1 --- /dev/null +++ b/src/plugins/.gitignore @@ -0,0 +1,5 @@ +moc_* +*.o +Makefile +Makefile.Debug +Makefile.Release diff --git a/src/plugins/PxMAV.cc b/src/plugins/PxMAV.cc new file mode 100644 index 0000000000000000000000000000000000000000..a761a4e004cd7ee02f0f49ccb3745d7c769e9183 --- /dev/null +++ b/src/plugins/PxMAV.cc @@ -0,0 +1,114 @@ +#include "PxMAV.h" + +#include + +PxMAV::PxMAV() : + UAS(NULL, 0) +{ +} + +PxMAV::PxMAV(MAVLinkProtocol* mavlink, int id) : + UAS(mavlink, id) +{ +} + +/** + * This function is called by MAVLink once a complete, uncorrupted (CRC check valid) + * mavlink packet is received. + * + * @param link Hardware link the message came from (e.g. /dev/ttyUSB0 or UDP port). + * messages can be sent back to the system via this link + * @param message MAVLink message, as received from the MAVLink protocol stack + */ +void PxMAV::receiveMessage(LinkInterface* link, mavlink_message_t message) +{ + // Let UAS handle the default message set + UAS::receiveMessage(link, message); + mavlink_message_t* msg = &message; + + //qDebug() << "PX RECEIVED" << msg->sysid << msg->compid << msg->msgid; + + + // Handle your special messages + switch (msg->msgid) + { + case MAVLINK_MSG_ID_WATCHDOG_HEARTBEAT: + { + mavlink_watchdog_heartbeat_t payload; + mavlink_msg_watchdog_heartbeat_decode(msg, &payload); + + emit watchdogReceived(this->uasId, payload.watchdog_id, payload.process_count); + } + break; + + case MAVLINK_MSG_ID_WATCHDOG_PROCESS_INFO: + { + mavlink_watchdog_process_info_t payload; + mavlink_msg_watchdog_process_info_decode(msg, &payload); + + emit processReceived(this->uasId, payload.watchdog_id, payload.process_id, QString((const char*)payload.name), QString((const char*)payload.arguments), payload.timeout); + } + break; + + case MAVLINK_MSG_ID_WATCHDOG_PROCESS_STATUS: + { + mavlink_watchdog_process_status_t payload; + mavlink_msg_watchdog_process_status_decode(msg, &payload); + emit processChanged(this->uasId, payload.watchdog_id, payload.process_id, payload.state, (payload.muted == 1) ? true : false, payload.crashes, payload.pid); + } + break; + case MAVLINK_MSG_ID_DEBUG_VECT: + { + mavlink_debug_vect_t vect; + mavlink_msg_debug_vect_decode(msg, &vect); + QString str((const char*)vect.name); + emit valueChanged(uasId, str+".x", vect.x, MG::TIME::getGroundTimeNow()); + emit valueChanged(uasId, str+".y", vect.y, MG::TIME::getGroundTimeNow()); + emit valueChanged(uasId, str+".z", vect.z, MG::TIME::getGroundTimeNow()); + } + break; + case MAVLINK_MSG_ID_VISION_POSITION_ESTIMATE: + { + mavlink_vision_position_estimate_t pos; + mavlink_msg_vision_position_estimate_decode(&message, &pos); + quint64 time = getUnixTime(pos.usec); + emit valueChanged(uasId, "vis. time", pos.usec, time); + emit valueChanged(uasId, "vis. roll", pos.roll, time); + emit valueChanged(uasId, "vis. pitch", pos.pitch, time); + emit valueChanged(uasId, "vis. yaw", pos.yaw, time); + emit valueChanged(uasId, "vis. x", pos.x, time); + emit valueChanged(uasId, "vis. y", pos.y, time); + emit valueChanged(uasId, "vis. z", pos.z, time); + emit valueChanged(uasId, "vis. vx", pos.vx, time); + emit valueChanged(uasId, "vis. vy", pos.vy, time); + emit valueChanged(uasId, "vis. vz", pos.vz, time); + emit valueChanged(uasId, "vis. vyaw", pos.vyaw, time); + // Set internal state + if (!positionLock) + { + // If position was not locked before, notify positive + // GAudioOutput::instance()->notifyPositive(); + } + positionLock = true; + } + break; + default: + // Do nothing + break; + } +} + +void PxMAV::sendProcessCommand(int watchdogId, int processId, unsigned int command) +{ + mavlink_watchdog_command_t payload; + payload.target_system_id = uasId; + payload.watchdog_id = watchdogId; + payload.process_id = processId; + payload.command_id = (uint8_t)command; + + mavlink_message_t msg; + mavlink_msg_watchdog_command_encode(mavlink->getSystemId(), mavlink->getComponentId(), &msg, &payload); + sendMessage(msg); +} + + Q_EXPORT_PLUGIN2(pixhawk_plugins, PxMAV) diff --git a/src/plugins/PxMAV.h b/src/plugins/PxMAV.h new file mode 100644 index 0000000000000000000000000000000000000000..a3639ea9c25cb3b863a8ef8f677e6f6837703a36 --- /dev/null +++ b/src/plugins/PxMAV.h @@ -0,0 +1,24 @@ +#ifndef PXMAV_H +#define PXMAV_H + +#include "UAS.h" + +class PxMAV : public UAS +{ + Q_OBJECT + Q_INTERFACES(UASInterface) +public: + PxMAV(MAVLinkProtocol* mavlink, int id); + PxMAV(); +public slots: + /** @brief Receive a MAVLink message from this MAV */ + void receiveMessage(LinkInterface* link, mavlink_message_t message); + /** @brief Send a command to an onboard process */ + void sendProcessCommand(int watchdogId, int processId, unsigned int command); +signals: + void watchdogReceived(int systemId, int watchdogId, unsigned int processCount); + void processReceived(int systemId, int watchdogId, int processId, QString name, QString arguments, int timeout); + void processChanged(int systemId, int watchdogId, int processId, int state, bool muted, int crashed, int pid); +}; + +#endif // PXMAV_H diff --git a/src/plugins/pixhawk_plugins.pro b/src/plugins/pixhawk_plugins.pro new file mode 100644 index 0000000000000000000000000000000000000000..3698d92ba66f70433a945aa3bbe7733e17541560 --- /dev/null +++ b/src/plugins/pixhawk_plugins.pro @@ -0,0 +1,22 @@ +# This plugin is also identified by this line in PxMAV.cc +# Q_EXPORT_PLUGIN2(pixhawk_plugins, PxMAV) + +include(../../qgroundcontrol.pri) + +TEMPLATE = lib +CONFIG += plugin +QT += phonon +INCLUDEPATH += ../. \ + ../../../mavlink/include \ + ../../MAVLink/include \ + ../../mavlink/include \ + ../uas \ + ../comm +HEADERS = PxMAV.h +SOURCES = PxMAV.cc \ + ../uas/UAS.cc \ + ../GAudioOutput.cc \ + ../comm/MAVLinkProtocol.cc \ + ../uas/UASManager.cc +TARGET = $$qtLibraryTarget(pixhawk_plugins) +DESTDIR = ../../plugins diff --git a/src/uas/PxQuadMAV.h b/src/uas/PxQuadMAV.h index 65552eeb237cceef22908dc46c8fab8f5b37f6c2..6170bc86397e63d9165b542a2748ae40a1a6031b 100644 --- a/src/uas/PxQuadMAV.h +++ b/src/uas/PxQuadMAV.h @@ -6,6 +6,7 @@ class PxQuadMAV : public UAS { Q_OBJECT + Q_INTERFACES(UASInterface) public: PxQuadMAV(MAVLinkProtocol* mavlink, int id); public slots: diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index 2820a463db7ee4c9209c9c565520a5cce7e5e17f..983e24023faf40f11365b6d0a871a8e3315142e3 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -43,7 +43,7 @@ This file is part of the PIXHAWK project #include "MAVLinkProtocol.h" #include -UAS::UAS(MAVLinkProtocol* protocol, int id) : +UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(), uasId(id), startTime(MG::TIME::getGroundTimeNow()), commStatus(COMM_DISCONNECTED), @@ -74,6 +74,7 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : positionLock(false), statusTimeout(new QTimer(this)) { + color = UASInterface::getNextColor(); setBattery(LIPOLY, 3); statusTimeout->setInterval(500); connect(statusTimeout, SIGNAL(timeout()), this, SLOT(updateState())); diff --git a/src/uas/UASInterface.h b/src/uas/UASInterface.h index 40b5799d6c8851a83c299b0adf73259d96851166..5599f0b6e9267017955e89aadb995692eba0f143 100644 --- a/src/uas/UASInterface.h +++ b/src/uas/UASInterface.h @@ -51,10 +51,6 @@ class UASInterface : public QObject { Q_OBJECT public: - UASInterface() : - color(UASInterface::getNextColor()) - { - } virtual ~UASInterface() {} /* MANAGEMENT */ @@ -315,4 +311,6 @@ signals: void systemTypeSet(UASInterface* uas, unsigned int type); }; +Q_DECLARE_INTERFACE(UASInterface, "org.qgroundcontrol/1.0"); + #endif // _UASINTERFACE_H_ diff --git a/src/ui/HDDisplay.cc b/src/ui/HDDisplay.cc index 8e74d1d4245a81f22eb929c1dddfe04eb86af3c1..6bbe2f4e87a57650549aba1a5ef2897e12f55b4a 100644 --- a/src/ui/HDDisplay.cc +++ b/src/ui/HDDisplay.cc @@ -74,6 +74,12 @@ HDDisplay::HDDisplay(QStringList* plotList, QWidget *parent) : { //m_ui->setupUi(this); + // Check if acceptlist exists + if (!acceptList) + { + acceptList = new QStringList(); + } + this->setMinimumHeight(125); this->setMinimumWidth(100); @@ -146,7 +152,7 @@ void HDDisplay::paintDisplay() painter.fillRect(QRect(0, 0, width(), height()), backgroundColor); const int columns = 3; const float spacing = 0.4f; // 40% of width - const float gaugeWidth = vwidth / (((float)columns) + (((float)columns+1) * spacing + spacing * 0.1f)); + const float gaugeWidth = vwidth / (((float)columns) + (((float)columns+1) * spacing + spacing * 0.5f)); const QColor gaugeColor = QColor(200, 200, 200); //drawSystemIndicator(10.0f-gaugeWidth/2.0f, 20.0f, 10.0f, 40.0f, 15.0f, &painter); //drawGauge(15.0f, 15.0f, gaugeWidth/2.0f, 0, 1.0f, "thrust", values.value("thrust", 0.0f), gaugeColor, &painter, qMakePair(0.45f, 0.8f), qMakePair(0.8f, 1.0f), true); diff --git a/src/ui/HSIDisplay.cc b/src/ui/HSIDisplay.cc new file mode 100644 index 0000000000000000000000000000000000000000..88af81f977525a118ec51ab5ca57b214696aede2 --- /dev/null +++ b/src/ui/HSIDisplay.cc @@ -0,0 +1,174 @@ +/*===================================================================== + +PIXHAWK Micro Air Vehicle Flying Robotics Toolkit + +(c) 2009, 2010 PIXHAWK PROJECT + +This file is part of the PIXHAWK project + + PIXHAWK is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + PIXHAWK is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with PIXHAWK. If not, see . + +======================================================================*/ + +/** + * @file + * @brief Implementation of Horizontal Situation Indicator class + * + * @author Lorenz Meier + * + */ + +#include +#include +#include +#include "UASManager.h" +#include "HSIDisplay.h" +#include "MG.h" + +#include + +HSIDisplay::HSIDisplay(QWidget *parent) : + HDDisplay(NULL, parent) +{ + +} + +void HSIDisplay::paintDisplay() +{ + quint64 refreshInterval = 100; + quint64 currTime = MG::TIME::getGroundTimeNow(); + if (currTime - lastPaintTime < refreshInterval) + { + // FIXME Need to find the source of the spurious paint events + //return; + } + lastPaintTime = currTime; + // Draw instruments + // TESTING THIS SHOULD BE MOVED INTO A QGRAPHICSVIEW + // Update scaling factor + // adjust scaling to fit both horizontally and vertically + scalingFactor = this->width()/vwidth; + double scalingFactorH = this->height()/vheight; + if (scalingFactorH < scalingFactor) scalingFactor = scalingFactorH; + + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setRenderHint(QPainter::HighQualityAntialiasing, true); + painter.fillRect(QRect(0, 0, width(), height()), backgroundColor); + const int columns = 3; + const float spacing = 0.4f; // 40% of width + const float gaugeWidth = vwidth / (((float)columns) + (((float)columns+1) * spacing + spacing * 0.1f)); + const QColor ringColor = QColor(200, 200, 200); + //drawSystemIndicator(10.0f-gaugeWidth/2.0f, 20.0f, 10.0f, 40.0f, 15.0f, &painter); + //drawGauge(15.0f, 15.0f, gaugeWidth/2.0f, 0, 1.0f, "thrust", values.value("thrust", 0.0f), gaugeColor, &painter, qMakePair(0.45f, 0.8f), qMakePair(0.8f, 1.0f), true); + //drawGauge(15.0f+gaugeWidth*1.7f, 15.0f, gaugeWidth/2.0f, 0, 10.0f, "altitude", values.value("altitude", 0.0f), gaugeColor, &painter, qMakePair(1.0f, 2.5f), qMakePair(0.0f, 0.5f), true); + + // Left spacing from border / other gauges, measured from left edge to center +// float leftSpacing = gaugeWidth * spacing; +// float xCoord = leftSpacing + gaugeWidth/2.0f; +// +// float topSpacing = leftSpacing; +// float yCoord = topSpacing + gaugeWidth/2.0f; +// +// for (int i = 0; i < acceptList->size(); ++i) +// { +// QString value = acceptList->at(i); +// drawGauge(xCoord, yCoord, gaugeWidth/2.0f, minValues.value(value, -1.0f), maxValues.value(value, 1.0f), value, values.value(value, minValues.value(value, 0.0f)), gaugeColor, &painter, goodRanges.value(value, qMakePair(0.0f, 0.5f)), critRanges.value(value, qMakePair(0.7f, 1.0f)), true); +// xCoord += gaugeWidth + leftSpacing; +// // Move one row down if necessary +// if (xCoord + gaugeWidth > vwidth) +// { +// yCoord += topSpacing + gaugeWidth; +// xCoord = leftSpacing + gaugeWidth/2.0f; +// } +// } +} + +/** + * + * @param uas the UAS/MAV to monitor/display with the HUD + */ +void HSIDisplay::setActiveUAS(UASInterface* uas) +{ + HDDisplay::setActiveUAS(uas); + //qDebug() << "ATTEMPTING TO SET UAS"; + if (this->uas != NULL && this->uas != uas) + { + // Disconnect any previously connected active MAV + //disconnect(uas, SIGNAL(valueChanged(UASInterface*,QString,double,quint64)), this, SLOT(updateValue(UASInterface*,QString,double,quint64))); + } + + // Now connect the new UAS + + //if (this->uas != uas) + // { + //qDebug() << "UAS SET!" << "ID:" << uas->getUASID(); + // Setup communication + //connect(uas, SIGNAL(valueChanged(UASInterface*,QString,double,quint64)), this, SLOT(updateValue(UASInterface*,QString,double,quint64))); + //} +} + +void HSIDisplay::drawGPS() +{ + +} + +void HSIDisplay::drawObjects() +{ + +} + +void HSIDisplay::drawBaseLines(float xRef, float yRef, float radius, float yaw, const QColor& color, QPainter* painter, bool solid) +{ + // Draw the circle + QPen circlePen(Qt::SolidLine); + if (!solid) circlePen.setStyle(Qt::DotLine); + circlePen.setWidth(refLineWidthToPen(0.5f)); + circlePen.setColor(defaultColor); + painter->setBrush(Qt::NoBrush); + painter->setPen(circlePen); + drawCircle(xRef, yRef, radius, 200.0f, color, painter); + //drawCircle(xRef, yRef, radius, 200.0f, 170.0f, 1.0f, color, painter); + +// // Draw the value +// QString label; +// label.sprintf("%05.1f", value); +// paintText(label, color, 4.5f, xRef-7.5f, yRef-2.0f, painter); + + // Draw the needle + // Scale the rotation so that the gauge does one revolution + // per max. change + const float rangeScale = (2.0f * M_PI); + const float maxWidth = radius / 10.0f; + const float minWidth = maxWidth * 0.3f; + + QPolygonF p(6); + + p.replace(0, QPointF(xRef-maxWidth/2.0f, yRef-radius * 0.5f)); + p.replace(1, QPointF(xRef-minWidth/2.0f, yRef-radius * 0.9f)); + p.replace(2, QPointF(xRef+minWidth/2.0f, yRef-radius * 0.9f)); + p.replace(3, QPointF(xRef+maxWidth/2.0f, yRef-radius * 0.5f)); + p.replace(4, QPointF(xRef, yRef-radius * 0.46f)); + p.replace(5, QPointF(xRef-maxWidth/2.0f, yRef-radius * 0.5f)); + + rotatePolygonClockWiseRad(p, yaw*rangeScale, QPointF(xRef, yRef)); + + QBrush indexBrush; + indexBrush.setColor(defaultColor); + indexBrush.setStyle(Qt::SolidPattern); + painter->setPen(Qt::SolidLine); + painter->setPen(defaultColor); + painter->setBrush(indexBrush); + drawPolygon(p, painter); +} diff --git a/src/ui/HSIDisplay.h b/src/ui/HSIDisplay.h new file mode 100644 index 0000000000000000000000000000000000000000..69c257a632b86ec8b1c09c883d512aa01ea18309 --- /dev/null +++ b/src/ui/HSIDisplay.h @@ -0,0 +1,65 @@ +/*===================================================================== + +PIXHAWK Micro Air Vehicle Flying Robotics Toolkit + +(c) 2009, 2010 PIXHAWK PROJECT + +This file is part of the PIXHAWK project + + PIXHAWK is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + PIXHAWK is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with PIXHAWK. If not, see . + +======================================================================*/ + +/** + * @file + * @brief Definition of of Horizontal Situation Indicator class + * + * @author Lorenz Meier + * + */ + +#ifndef HSIDISPLAY_H +#define HSIDISPLAY_H + +#include +#include +#include +#include +#include +#include + +#include "HDDisplay.h" + +class HSIDisplay : public HDDisplay { + Q_OBJECT +public: + HSIDisplay(QWidget *parent = 0); + // ~HSIDisplay(); + +public slots: + void setActiveUAS(UASInterface* uas); + +protected slots: + void paintDisplay(); + void drawGPS(); + void drawObjects(); + void drawBaseLines(float xRef, float yRef, float radius, float yaw, const QColor& color, QPainter* painter, bool solid); + + +protected: + +private: +}; + +#endif // HSIDISPLAY_H diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 9e7584b25d2f77383a711608217987c8bf60f288..11d49940fec25ced58a692d5d6261dbdb07a33c1 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -100,6 +100,8 @@ settings() parameters->setVisible(false); watchdogControl = new WatchdogControl(this); watchdogControl->setVisible(false); + hsi = new HSIDisplay(this); + hsi->setVisible(false); QStringList* acceptList = new QStringList(); acceptList->append("roll IMU"); diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 2a0d62f02b5971f27485972fe3d9b8a6d3cb0be3..a6149cfb12236b212022c2ecfcf3fa4aa96d764d 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -61,6 +61,7 @@ This file is part of the PIXHAWK project #include "XMLCommProtocolWidget.h" #include "HDDisplay.h" #include "WatchdogControl.h" +#include "HSIDisplay.h" #include "LogCompressor.h" @@ -148,6 +149,7 @@ protected: HDDisplay* headDown1; HDDisplay* headDown2; WatchdogControl* watchdogControl; + HSIDisplay* hsi; // Popup widgets JoystickWidget* joystickWidget; diff --git a/src/ui/ObjectDetectionView.cc b/src/ui/ObjectDetectionView.cc index e9c3c7eb99aeae3b5858dc6d29aa1b1029fbfc2b..7b4d9be521b860497eb4ecd7bba9274116fc1ff1 100644 --- a/src/ui/ObjectDetectionView.cc +++ b/src/ui/ObjectDetectionView.cc @@ -38,6 +38,8 @@ This file is part of the PIXHAWK project #include +#include "MG.h" + ObjectDetectionView::ObjectDetectionView(QString folder, QWidget *parent) : QWidget(parent), patternList(), @@ -90,8 +92,9 @@ void ObjectDetectionView::newDetection(int uasId, QString patternPath, int x1, i { if (patternList.contains(patternPath)) { - qDebug() << "REDETECTED"; + //qDebug() << "REDETECTED"; + /* QList actions = m_ui->listWidget->actions(); // Find action and update it foreach (QAction* act, actions) @@ -112,6 +115,7 @@ void ObjectDetectionView::newDetection(int uasId, QString patternPath, int x1, i // Set name and label m_ui->nameLabel->setText(patternName); + */ } else { @@ -120,7 +124,11 @@ void ObjectDetectionView::newDetection(int uasId, QString patternPath, int x1, i patternList.insert(patternPath, confidence); patternCount.insert(patternPath, 1); - QPixmap image = QPixmap(patternFolder + "/" + patternPath); + + QString filePath = MG::DIR::getSupportFilesDirectory() + "/" + patternFolder + "/" + patternPath.split("/").last(); + + qDebug() << "Loading:" << filePath; + QPixmap image = QPixmap(filePath); QIcon ico(image); QAction* act = new QAction(ico, patternPath + separator + "(#" + QString::number(1) + ")" + separator + QString::number(confidence), this); connect(act, SIGNAL(triggered()), this, SLOT(takeAction())); diff --git a/src/ui/ObjectDetectionView.h b/src/ui/ObjectDetectionView.h index 5492dcacbf5e0b5d9334d55e556c6b3cec6c489b..910e748972250ab83575b147e3d63143d0090a08 100644 --- a/src/ui/ObjectDetectionView.h +++ b/src/ui/ObjectDetectionView.h @@ -48,7 +48,7 @@ class ObjectDetectionView : public QWidget { Q_OBJECT Q_DISABLE_COPY(ObjectDetectionView) public: - explicit ObjectDetectionView(QString folder="test", QWidget *parent = 0); + explicit ObjectDetectionView(QString folder="patterns", QWidget *parent = 0); virtual ~ObjectDetectionView(); /** @brief Resize widget contents */ diff --git a/src/ui/UASInfo.ui b/src/ui/UASInfo.ui index 9c7fb89a3e6ff6a5cebc3fa867659f03b885f9e2..a9a5a93cfe51181f49a950cc022084b0ce1e6ffc 100644 --- a/src/ui/UASInfo.ui +++ b/src/ui/UASInfo.ui @@ -66,7 +66,7 @@ - + @@ -109,7 +109,7 @@ - + Qt::Horizontal @@ -171,7 +171,7 @@ - + @@ -257,7 +257,7 @@ - + @@ -343,7 +343,7 @@ - + @@ -380,56 +380,14 @@ - + Qt::Horizontal - - - - I2C Errors - - - - - - - 0 - - - - - - - SPI Errors - - - - - - - 0 - - - - - - - UART Errors - - - - - - - 0 - - - - + Qt::Vertical @@ -445,6 +403,13 @@ + + + + No error status received yet + + + diff --git a/src/ui/WaypointList.cc b/src/ui/WaypointList.cc index 75a7bc743d4ead5d7e31181a58af79bbc1695e68..ddd141a6c6e16a4fab4f91d03dbe2910bc55f4a7 100644 --- a/src/ui/WaypointList.cc +++ b/src/ui/WaypointList.cc @@ -85,8 +85,8 @@ void WaypointList::setUAS(UASInterface* uas) if (this->uas == NULL && uas != NULL) { this->uas = uas; - connect(uas, SIGNAL(waypointUpdated(int,int,double,double,double,double,bool,bool)), this, SLOT(setWaypoint(int,int,double,double,double,double,bool,bool))); - connect(uas, SIGNAL(waypointReached(UASInterface*,int)), this, SLOT(waypointReached(UASInterface*,int))); + connect(&uas->getWaypointManager(), SIGNAL(waypointUpdated(int,int,double,double,double,double,bool,bool)), this, SLOT(setWaypoint(int,int,double,double,double,double,bool,bool))); + connect(&uas->getWaypointManager(), SIGNAL(waypointReached(UASInterface*,int)), this, SLOT(waypointReached(UASInterface*,int))); connect(this, SIGNAL(waypointChanged(Waypoint*)), &uas->getWaypointManager(), SLOT(setWaypoint(Waypoint*))); connect(this, SIGNAL(currentWaypointChanged(int)), &uas->getWaypointManager(), SLOT(setWaypointActive(int))); // This slot is not implemented in UAS: connect(this, SIGNAL(removeWaypointId(int)), uas, SLOT(removeWaypoint(Waypoint*))); @@ -315,7 +315,7 @@ void WaypointList::setCurrentWaypoint(Waypoint* wp) { waypoints[i]->current = true; // Retransmit waypoint - uas->setWaypointActive(i); + //uas->getWaypointManager().setWaypointActive(i); } else { diff --git a/src/ui/generated/CommSettings.h b/src/ui/generated/CommSettings.h new file mode 100644 index 0000000000000000000000000000000000000000..2c7267c282d9ef194e4fc0174a866e22dcd3dcc2 --- /dev/null +++ b/src/ui/generated/CommSettings.h @@ -0,0 +1,8 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'src/ui/CommSettings.ui' +** +** Created: Tue Jun 1 20:21:32 2010 +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ + diff --git a/src/ui/generated/MainWindow.h b/src/ui/generated/MainWindow.h new file mode 100644 index 0000000000000000000000000000000000000000..4aaa634d148254d361daea139b648d6e465c0adb --- /dev/null +++ b/src/ui/generated/MainWindow.h @@ -0,0 +1,8 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'src/ui/MainWindow.ui' +** +** Created: Tue Jun 1 20:21:32 2010 +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ + diff --git a/src/ui/generated/SerialSettings.h b/src/ui/generated/SerialSettings.h new file mode 100644 index 0000000000000000000000000000000000000000..df2ed91f7de2a9474f2d212d897ca776a8b25a6e --- /dev/null +++ b/src/ui/generated/SerialSettings.h @@ -0,0 +1,8 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'src/ui/SerialSettings.ui' +** +** Created: Tue Jun 1 20:21:32 2010 +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ + diff --git a/src/ui/generated/UASControl.h b/src/ui/generated/UASControl.h new file mode 100644 index 0000000000000000000000000000000000000000..db65dafc8cc36522d0eab40f353f4cdec11d7795 --- /dev/null +++ b/src/ui/generated/UASControl.h @@ -0,0 +1,8 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'src/ui/UASControl.ui' +** +** Created: Tue Jun 1 20:21:32 2010 +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ + diff --git a/src/ui/generated/UASInfo.h b/src/ui/generated/UASInfo.h new file mode 100644 index 0000000000000000000000000000000000000000..154ac2f99502d42859373541644bea60bd264787 --- /dev/null +++ b/src/ui/generated/UASInfo.h @@ -0,0 +1,8 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'src/ui/UASInfo.ui' +** +** Created: Tue Jun 1 20:21:32 2010 +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ + diff --git a/src/ui/generated/UASList.h b/src/ui/generated/UASList.h new file mode 100644 index 0000000000000000000000000000000000000000..bad34bce7ea22de0b7d3590d63cdb69fb4ac95bd --- /dev/null +++ b/src/ui/generated/UASList.h @@ -0,0 +1,8 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'src/ui/UASList.ui' +** +** Created: Tue Jun 1 20:21:32 2010 +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ + diff --git a/src/ui/uas/UASInfoWidget.cc b/src/ui/uas/UASInfoWidget.cc index 7dfe56913d5eb71ad6f66613ce76ed0efdd6c884..c835c5f64daa52f7f9734ef94e2e1e118ef8aaa3 100644 --- a/src/ui/uas/UASInfoWidget.cc +++ b/src/ui/uas/UASInfoWidget.cc @@ -110,7 +110,7 @@ void UASInfoWidget::updateBattery(UASInterface* uas, double voltage, double perc void UASInfoWidget::updateErrorCount(int uasid, QString component, QString device, int count) { - qDebug() << __FILE__ << __LINE__ << activeUAS->getUASID() << "=" << uasid; + //qDebug() << __FILE__ << __LINE__ << activeUAS->getUASID() << "=" << uasid; if (activeUAS->getUASID() == uasid) { errors.remove(component + ":" + device); @@ -182,5 +182,16 @@ void UASInfoWidget::refresh() ui.sendLossLabel->setText(QString::number(sendLoss, 'f', 2)); QString errorString; - // ui. + QMapIterator i(errors); + while (i.hasNext()) + { + i.next(); + errorString += QString(i.key() + ": %1 ").arg(i.value()); + + // FIXME + errorString.replace("IMU:", ""); + + + } + ui.errorLabel->setText(errorString); }