diff --git a/README b/README index 09bae4c61322521d1a14c370d26e72509299c9bb..f412e023a23edd2139e4f3832b9602eaa627fc87 100644 --- a/README +++ b/README @@ -1,6 +1,17 @@ QGroundControl Open Source Micro Air Vehicle Ground Control Station -http://pixhawk.ethz.ch +Project: +http://qgroundcontrol.org + +Files: +http://github.com/pixhawk/qgroundcontrol +http://github.com/pixhawk/mavlink + + +********************************************************************************************** +* PLEASE NOTE: YOU NEED TO DOWNLOAD THE MAVLINK LIBRARY IN ORDER TO COMPILE THIS APPLICATION * +********************************************************************************************** + Mac OS X ======== @@ -21,7 +32,7 @@ Install QT with Cocoa Get the MAVLINK Library ----------------------- -1) Clone the MAVLINK repository : `git clone git@pixhawk.ethz.ch:mavlink.git` (You need to have emailed your ssh key). **NOTE:** Make sure that the mavlink directory is in the same directory as groundcontrol. QGround control will look for mavlink library in ../mavlink +1) Clone the MAVLINK repository : `git clone git@github.com:pixhawk/mavlink.git`. **NOTE:** Make sure that the mavlink directory is in the same directory as groundcontrol. QGround control will look for mavlink library in ../mavlink Build QGroundControl -------------------- @@ -35,13 +46,28 @@ Build QGroundControl Linux ===== -********************************************************************************************** -* PLEASE NOTE: YOU NEED TO DOWNLOAD THE MAVLINK LIBRARY IN ORDER TO COMPILE THIS APPLICATION * -********************************************************************************************** - To build on Linux: - + +sudo apt-get install phonon libqt4-dev libqt4-phonon-dev \ +libqt4-phonon libphonon-dev libphonon4 phonon-backend-gstreamer \ +qt-creator libsdl1.2-dev libflite1 flite1-dev + +cd directory + +git clone git@github.com:pixhawk/mavlink.git +git clone git@github.com:pixhawk/qgroundcontrol.git + +Ubuntu Application Menu -> Development -> Qt Creator + +QtCreator Menu File -> Open File or Project.. + +Open directory/qgroundcontrol/qgroundcontrol.pro + +Hit the green play button to compile and launch it + +Done. + Windows ======= diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 90fbdff81a749a11ce6f5e0732b6a8a367025dd8..2a6e331a9a03b80dd7b756293df95007b2d19400 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -45,11 +45,9 @@ INCLUDEPATH += . \ $$BASEDIR/../mavlink/contrib/slugs/include \ $$BASEDIR/../mavlink/include - - # ../mavlink/include \ - #MAVLink/include \ - #mavlink/include - +# ../mavlink/include \ +# MAVLink/include \ +# mavlink/include # Input FORMS += src/ui/MainWindow.ui \ src/ui/CommSettings.ui \ @@ -73,7 +71,9 @@ FORMS += src/ui/MainWindow.ui \ src/ui/QGCSensorSettingsWidget.ui \ src/ui/watchdog/WatchdogControl.ui \ src/ui/watchdog/WatchdogProcessView.ui \ - src/ui/watchdog/WatchdogView.ui + src/ui/watchdog/WatchdogView.ui \ + src/ui/QGCFirmwareUpdate.ui \ + src/ui/QGCPxImuFirmwareUpdate.ui INCLUDEPATH += src \ src/ui \ src/ui/linechart \ @@ -147,7 +147,9 @@ HEADERS += src/MG.h \ src/ui/watchdog/WatchdogView.h \ src/uas/UASWaypointManager.h \ src/ui/HSIDisplay.h \ - src/QGC.h + src/QGC.h \ + src/ui/QGCFirmwareUpdate.h \ + src/ui/QGCPxImuFirmwareUpdate.h SOURCES += src/main.cc \ src/Core.cc \ src/uas/UASManager.cc \ @@ -203,5 +205,7 @@ SOURCES += src/main.cc \ src/ui/watchdog/WatchdogView.cc \ src/uas/UASWaypointManager.cc \ src/ui/HSIDisplay.cc \ - src/QGC.cc + src/QGC.cc \ + src/ui/QGCFirmwareUpdate.cc \ + src/ui/QGCPxImuFirmwareUpdate.cc RESOURCES = mavground.qrc diff --git a/src/Core.cc b/src/Core.cc index 55d701e151ed3fe2a6cbf2cc5d32831609c43651..41a099fab6593ff5167122ec3acae44e5e7956b7 100644 --- a/src/Core.cc +++ b/src/Core.cc @@ -115,7 +115,7 @@ Core::Core(int &argc, char* argv[]) : QApplication(argc, argv) { QMessageBox msgBox; msgBox.setIcon(QMessageBox::Critical); - msgBox.setText("Could not connect UDP port. Is already an instance of " + qAppName() + " running?"); + msgBox.setText("Could not connect UDP port. Is an instance of " + qAppName() + "already running?"); msgBox.setInformativeText("You will not be able to receive data via UDP. Please check that you're running the right executable and then re-start " + qAppName() + ". Do you want to close the application?"); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Cancel); diff --git a/src/comm/LinkManager.cc b/src/comm/LinkManager.cc index c67453f4a6fef167b003ba0dcf4823a3739ef033..ad4860aa06e58306456e41ea5996c02dc2ea3e4a 100644 --- a/src/comm/LinkManager.cc +++ b/src/comm/LinkManager.cc @@ -33,6 +33,8 @@ This file is part of the PIXHAWK project #include #include "LinkManager.h" +#include + LinkManager* LinkManager::instance() { static LinkManager* _instance = 0; if(_instance == 0) { @@ -79,7 +81,8 @@ void LinkManager::addProtocol(LinkInterface* link, ProtocolInterface* protocol) // the protocol will receive new bytes from the link connect(link, SIGNAL(bytesReady(LinkInterface*)), protocol, SLOT(receiveBytes(LinkInterface*))); // Store the connection information in the protocol links map - protocolLinks.insert(protocol, link); + protocolLinks.insertMulti(protocol, link); + //qDebug() << __FILE__ << __LINE__ << "ADDED LINK TO PROTOCOL" << link->getName() << protocol->getName() << "NEW SIZE OF LINK LIST:" << protocolLinks.size(); } QList LinkManager::getLinksForProtocol(ProtocolInterface* protocol) diff --git a/src/comm/MAVLinkProtocol.cc b/src/comm/MAVLinkProtocol.cc index 06c1d218069786b1c02ba96717e8eeef72d3c6f2..4bbf0a19c0c21ff66341fc83c390ce3b70acab99 100644 --- a/src/comm/MAVLinkProtocol.cc +++ b/src/comm/MAVLinkProtocol.cc @@ -323,6 +323,7 @@ void MAVLinkProtocol::sendMessage(mavlink_message_t message) for (i = links.begin(); i != links.end(); ++i) { sendMessage(*i, message); + qDebug() << __FILE__ << __LINE__ << "SENT HEARTBEAT MESSAGE OVER" << ((LinkInterface*)*i)->getName() << "LIST SIZE:" << links.size(); } } diff --git a/src/comm/MAVLinkXMLParser.cc b/src/comm/MAVLinkXMLParser.cc index 62a47ee5571492543d0aaa46994a8f222fc2bd79..a49af8042b0539e94b24e9eb6fefbb47429bd718 100644 --- a/src/comm/MAVLinkXMLParser.cc +++ b/src/comm/MAVLinkXMLParser.cc @@ -4,6 +4,7 @@ #include #include #include +#include #include "MAVLinkXMLParser.h" #include @@ -205,7 +206,7 @@ bool MAVLinkXMLParser::generate() QString encode = "static inline uint16_t mavlink_msg_%1_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const %2* %1)\n{\n\treturn mavlink_msg_%1_pack(%3);\n}\n"; QString decode = "static inline void mavlink_msg_%1_decode(const mavlink_message_t* msg, %2* %1)\n{\n%3}\n"; - QString pack = "static inline uint16_t mavlink_msg_%1_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg%2)\n{\n\tmsg->msgid = MAVLINK_MSG_ID_%3;\n\tuint16_t i = 0;\n\n%4\n\treturn mavlink_finalize_message(msg, system_id, component_id, i);\n}\n\n"; + QString pack = "static inline uint16_t mavlink_msg_%1_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg%2)\n{\n\tuint16_t i = 0;\n\tmsg->msgid = MAVLINK_MSG_ID_%3;\n\n%4\n\treturn mavlink_finalize_message(msg, system_id, component_id, i);\n}\n\n"; QString compactSend = "#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS\n\nstatic inline void mavlink_msg_%3_send(%1 chan%5)\n{\n\t%2 msg;\n\tmavlink_msg_%3_pack(mavlink_system.sysid, mavlink_system.compid, &msg%4);\n\tmavlink_send_uart(chan, &msg);\n}\n\n#endif"; //QString compactStructSend = "#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS\n\nstatic inline void mavlink_msg_%3_struct_send(%1 chan%5)\n{\n\t%2 msg;\n\tmavlink_msg_%3_encode(mavlink_system.sysid, mavlink_system.compid, &msg%4);\n\tmavlink_send_uart(chan, &msg);\n}\n\n#endif"; QString unpacking = ""; @@ -222,7 +223,7 @@ bool MAVLinkXMLParser::generate() while (!f.isNull()) { QDomElement e2 = f.toElement(); - if (!e2.isNull()) + if (!e2.isNull() && e2.tagName() == "field") { QString fieldType = e2.attribute("type", ""); QString fieldName = e2.attribute("name", ""); @@ -362,8 +363,9 @@ bool MAVLinkXMLParser::generate() // XML parsed and converted to C code. Now generating the files QDateTime now = QDateTime::currentDateTime().toUTC(); + QLocale loc(QLocale::English); QString dateFormat = "dddd, MMMM d yyyy, hh:mm UTC"; - QString date = now.toString(dateFormat); + QString date = loc.toString(now, dateFormat); QString mainHeader = QString("/** @file\n *\t@brief MAVLink comm protocol.\n *\t@see http://pixhawk.ethz.ch/software/mavlink\n *\t Generated on %1\n */\n#ifndef MAVLINK_H\n#define MAVLINK_H\n\n").arg(date); // The main header includes all messages // Mark all code as C code mainHeader += "#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n"; diff --git a/src/comm/UDPLink.cc b/src/comm/UDPLink.cc index fb942987679be87994f36192bac4ecdbb99c4ff3..61c1ed5170f53465baa46da113cc32e843b0a5e2 100644 --- a/src/comm/UDPLink.cc +++ b/src/comm/UDPLink.cc @@ -209,7 +209,11 @@ bool UDPLink::connect() connectState = socket->bind(host, port); emit connected(connectState); - if (connectState) emit connected(); + if (connectState) + { + emit connected(); + connectionStartTime = MG::TIME::getGroundTimeNow(); + } start(HighPriority); return connectState; @@ -247,8 +251,9 @@ qint64 UDPLink::getNominalDataRate() { qint64 UDPLink::getTotalUpstream() { statisticsMutex.lock(); - return bitsSentTotal / ((MG::TIME::getGroundTimeNow() - connectionStartTime) / 1000); + qint64 totalUpstream = bitsSentTotal / ((MG::TIME::getGroundTimeNow() - connectionStartTime) / 1000); statisticsMutex.unlock(); + return totalUpstream; } qint64 UDPLink::getCurrentUpstream() { @@ -269,8 +274,9 @@ qint64 UDPLink::getBitsReceived() { qint64 UDPLink::getTotalDownstream() { statisticsMutex.lock(); - return bitsReceivedTotal / ((MG::TIME::getGroundTimeNow() - connectionStartTime) / 1000); + qint64 totalDownstream = bitsReceivedTotal / ((MG::TIME::getGroundTimeNow() - connectionStartTime) / 1000); statisticsMutex.unlock(); + return totalDownstream; } qint64 UDPLink::getCurrentDownstream() { diff --git a/src/main.cc b/src/main.cc index dbb457cb0ffc8b25b15ff88f393a9e46d8b61ab2..7db249d8317a26d4828aaa92156ec2a31faa720f 100644 --- a/src/main.cc +++ b/src/main.cc @@ -36,7 +36,7 @@ This file is part of the PIXHAWK project /* SDL does ugly things to main() */ #ifdef main -# undef main + #undef main #endif /** diff --git a/src/uas/SlugsMAV.cc b/src/uas/SlugsMAV.cc index 801a84df114cced429d932c67df71b4285a9c069..f053345f2e77a6a0bad1abd83c4131119bc00ad6 100644 --- a/src/uas/SlugsMAV.cc +++ b/src/uas/SlugsMAV.cc @@ -38,10 +38,9 @@ void SlugsMAV::receiveMessage(LinkInterface* link, mavlink_message_t message) quint64 time = getUnixTime(0); mavlink_msg_cpu_load_decode(&message,&cpu_load); - emit valueChanged(uasId, "CPU Load", cpu_load.target, time); - emit valueChanged(uasId, "SensorDSC Load", cpu_load.sensLoad, time); - emit valueChanged(uasId, "ControlDSC Load", cpu_load.ctrlLoad, time); - emit valueChanged(uasId, "Battery Volt", cpu_load.batVolt, time); + emit valueChanged(uasId, tr("SensorDSC Load"), cpu_load.sensLoad, time); + emit valueChanged(uasId, tr("ControlDSC Load"), cpu_load.ctrlLoad, time); + emit valueChanged(uasId, tr("Battery Volt"), cpu_load.batVolt, time); break; } @@ -50,10 +49,9 @@ void SlugsMAV::receiveMessage(LinkInterface* link, mavlink_message_t message) mavlink_air_data_t air_data; quint64 time = getUnixTime(0); mavlink_msg_air_data_decode(&message,&air_data); - emit valueChanged(uasId, "Air Data",air_data.target,time); - emit valueChanged(uasId, "Presion Dinamica", air_data.dynamicPressure,time); - emit valueChanged(uasId, "Presion Estatica",air_data.staticPressure, time); - emit valueChanged(uasId, "Temperatura",air_data.temperature,time); + emit valueChanged(uasId, tr("Dynamic Pressure"), air_data.dynamicPressure,time); + emit valueChanged(uasId, tr("Static Pressure"),air_data.staticPressure, time); + emit valueChanged(uasId, tr("Temp"),air_data.temperature,time); break; } @@ -62,13 +60,12 @@ void SlugsMAV::receiveMessage(LinkInterface* link, mavlink_message_t message) mavlink_sensor_bias_t sensor_bias; quint64 time = getUnixTime(0); mavlink_msg_sensor_bias_decode(&message,&sensor_bias); - emit valueChanged(uasId,"Sensor Bias",sensor_bias.target, time); - emit valueChanged(uasId,"Acelerometro X",sensor_bias.axBias, time); - emit valueChanged(uasId,"Acelerometro y",sensor_bias.ayBias,time); - emit valueChanged(uasId,"Acelerometro Z",sensor_bias.azBias,time); - emit valueChanged(uasId,"Gyro X",sensor_bias.gxBias,time); - emit valueChanged(uasId,"Gyro Y",sensor_bias.gyBias,time); - emit valueChanged(uasId,"Gyro Z",sensor_bias.gzBias,time); + emit valueChanged(uasId,tr("Ax Bias"),sensor_bias.axBias, time); + emit valueChanged(uasId,tr("Ay Bias"),sensor_bias.ayBias,time); + emit valueChanged(uasId,tr("Az Bias"),sensor_bias.azBias,time); + emit valueChanged(uasId,tr("Gx Bias"),sensor_bias.gxBias,time); + emit valueChanged(uasId,tr("Gy Bias"),sensor_bias.gyBias,time); + emit valueChanged(uasId,tr("Gz Bias"),sensor_bias.gzBias,time); break; } @@ -77,13 +74,12 @@ void SlugsMAV::receiveMessage(LinkInterface* link, mavlink_message_t message) mavlink_diagnostic_t diagnostic; quint64 time = getUnixTime(0); mavlink_msg_diagnostic_decode(&message,&diagnostic); - emit valueChanged(uasId,"Diagnostico",diagnostic.target,time); - emit valueChanged(uasId,"Diagnostico F1",diagnostic.diagFl1,time); - emit valueChanged(uasId,"Diagnostico F2",diagnostic.diagFl2,time); - emit valueChanged(uasId,"Diagnostico F3",diagnostic.diagFl3,time); - emit valueChanged(uasId,"Diagnostico S1",diagnostic.diagSh1,time); - emit valueChanged(uasId,"Diagnostico S2",diagnostic.diagSh2,time); - emit valueChanged(uasId,"Diagnostico S3",diagnostic.diagSh3,time); + emit valueChanged(uasId,tr("Diag F1"),diagnostic.diagFl1,time); + emit valueChanged(uasId,tr("Diag F2"),diagnostic.diagFl2,time); + emit valueChanged(uasId,tr("Diag F3"),diagnostic.diagFl3,time); + emit valueChanged(uasId,tr("Diag S1"),diagnostic.diagSh1,time); + emit valueChanged(uasId,tr("Diag S2"),diagnostic.diagSh2,time); + emit valueChanged(uasId,tr("Diag S3"),diagnostic.diagSh3,time); break; } @@ -92,12 +88,11 @@ void SlugsMAV::receiveMessage(LinkInterface* link, mavlink_message_t message) mavlink_pilot_console_t pilot; quint64 time = getUnixTime(0); mavlink_msg_pilot_console_decode(&message,&pilot); - emit valueChanged(uasId,"Mensajes PWM",pilot.target,time); - emit valueChanged(uasId,"Aceleracion Consola",pilot.dt,time); - emit valueChanged(uasId,"Aleron Izq Consola",pilot.dla,time); - emit valueChanged(uasId,"Aleron Der Consola",pilot.dra,time); - emit valueChanged(uasId,"Timon Consola",pilot.dr,time); - emit valueChanged(uasId,"Elevador Consola",pilot.de,time); + emit valueChanged(uasId,"dt",pilot.dt,time); + emit valueChanged(uasId,"dla",pilot.dla,time); + emit valueChanged(uasId,"dra",pilot.dra,time); + emit valueChanged(uasId,"dr",pilot.dr,time); + emit valueChanged(uasId,"de",pilot.de,time); break; } @@ -106,17 +101,16 @@ void SlugsMAV::receiveMessage(LinkInterface* link, mavlink_message_t message) mavlink_pwm_commands_t pwm; quint64 time = getUnixTime(0); mavlink_msg_pwm_commands_decode(&message,&pwm); - emit valueChanged(uasId,"Superficies de Control",pwm.target,time); - emit valueChanged(uasId,"Comando Aceleracion PA",pwm.dt_c,time); - emit valueChanged(uasId,"Comando Aleron Izq PA",pwm.dla_c,time); - emit valueChanged(uasId,"Comando Aleron Der PA",pwm.dra_c,time); - emit valueChanged(uasId,"Comando Timon PA",pwm.dr_c,time); - emit valueChanged(uasId,"Comando elevador Izq PA",pwm.dle_c,time); - emit valueChanged(uasId,"Comando Elevador Der PA",pwm.dre_c,time); - emit valueChanged(uasId,"Comando Flap Izq PA",pwm.dlf_c,time); - emit valueChanged(uasId,"Comando Flap Der PA",pwm.drf_c,time); - emit valueChanged(uasId,"Comando Aux1 PA",pwm.aux1,time); - emit valueChanged(uasId,"Comando Aux2 PA",pwm.aux2,time); + emit valueChanged(uasId,"dt_c",pwm.dt_c,time); + emit valueChanged(uasId,"dla_c",pwm.dla_c,time); + emit valueChanged(uasId,"dra_c",pwm.dra_c,time); + emit valueChanged(uasId,"dr_c",pwm.dr_c,time); + emit valueChanged(uasId,"dle_c",pwm.dle_c,time); + emit valueChanged(uasId,"dre_c",pwm.dre_c,time); + emit valueChanged(uasId,"dlf_c",pwm.dlf_c,time); + emit valueChanged(uasId,"drf_c",pwm.drf_c,time); + emit valueChanged(uasId,"da1_c",pwm.aux1,time); + emit valueChanged(uasId,"da2_c",pwm.aux2,time); break; diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index cc0f235c884da99f4b5a592f0a6870de11c25d41..b08c495404e2c7dc83ad9b608c3884b59eef0baf 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -118,9 +118,14 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) if (!links->contains(link)) { addLink(link); +// qDebug() << __FILE__ << __LINE__ << "ADDED LINK!" << link->getName(); } +// else +// { +// qDebug() << __FILE__ << __LINE__ << "DID NOT ADD LINK" << link->getName() << "ALREADY IN LIST"; +// } - //qDebug() << "UAS RECEIVED" << message.sysid << message.compid << message.msgid; +// qDebug() << "UAS RECEIVED from" << message.sysid << "component" << message.compid << "msg id" << message.msgid << "seq no" << message.seq; if (message.sysid == uasId) { diff --git a/src/uas/UASWaypointManager.cc b/src/uas/UASWaypointManager.cc index 71924316ad6c2606df3b0c35a767ee94c4616324..9e5ea343b12d1e60d45687dad4918d0ff570e5b3 100644 --- a/src/uas/UASWaypointManager.cc +++ b/src/uas/UASWaypointManager.cc @@ -497,7 +497,7 @@ void UASWaypointManager::sendWaypointClearAll() mavlink_msg_waypoint_clear_all_encode(uas.mavlink->getSystemId(), uas.mavlink->getComponentId(), &message, &wpca); uas.sendMessage(message); - usleep(PROTOCOL_DELAY_MS * 1000); + MG::SLEEP::usleep(PROTOCOL_DELAY_MS * 1000); qDebug() << "sent waypoint clear all to ID " << wpca.target_system; } @@ -515,7 +515,7 @@ void UASWaypointManager::sendWaypointSetCurrent(quint16 seq) mavlink_msg_waypoint_set_current_encode(uas.mavlink->getSystemId(), uas.mavlink->getComponentId(), &message, &wpsc); uas.sendMessage(message); - usleep(PROTOCOL_DELAY_MS * 1000); + MG::SLEEP::usleep(PROTOCOL_DELAY_MS * 1000); qDebug() << "sent waypoint set current (" << wpsc.seq << ") to ID " << wpsc.target_system; } @@ -533,7 +533,7 @@ void UASWaypointManager::sendWaypointCount() mavlink_msg_waypoint_count_encode(uas.mavlink->getSystemId(), uas.mavlink->getComponentId(), &message, &wpc); uas.sendMessage(message); - usleep(PROTOCOL_DELAY_MS * 1000); + MG::SLEEP::usleep(PROTOCOL_DELAY_MS * 1000); qDebug() << "sent waypoint count (" << wpc.count << ") to ID " << wpc.target_system; } @@ -550,7 +550,7 @@ void UASWaypointManager::sendWaypointRequestList() mavlink_msg_waypoint_request_list_encode(uas.mavlink->getSystemId(), uas.mavlink->getComponentId(), &message, &wprl); uas.sendMessage(message); - usleep(PROTOCOL_DELAY_MS * 1000); + MG::SLEEP::usleep(PROTOCOL_DELAY_MS * 1000); qDebug() << "sent waypoint list request to ID " << wprl.target_system; } @@ -568,7 +568,7 @@ void UASWaypointManager::sendWaypointRequest(quint16 seq) mavlink_msg_waypoint_request_encode(uas.mavlink->getSystemId(), uas.mavlink->getComponentId(), &message, &wpr); uas.sendMessage(message); - usleep(PROTOCOL_DELAY_MS * 1000); + MG::SLEEP::usleep(PROTOCOL_DELAY_MS * 1000); qDebug() << "sent waypoint request (" << wpr.seq << ") to ID " << wpr.target_system; } @@ -589,7 +589,7 @@ void UASWaypointManager::sendWaypoint(quint16 seq) mavlink_msg_waypoint_encode(uas.mavlink->getSystemId(), uas.mavlink->getComponentId(), &message, wp); uas.sendMessage(message); - usleep(PROTOCOL_DELAY_MS * 1000); + MG::SLEEP::usleep(PROTOCOL_DELAY_MS * 1000); qDebug() << "sent waypoint (" << wp->seq << ") to ID " << wp->target_system; } @@ -606,7 +606,7 @@ void UASWaypointManager::sendWaypointAck(quint8 type) mavlink_msg_waypoint_ack_encode(uas.mavlink->getSystemId(), uas.mavlink->getComponentId(), &message, &wpa); uas.sendMessage(message); - usleep(PROTOCOL_DELAY_MS * 1000); + MG::SLEEP::usleep(PROTOCOL_DELAY_MS * 1000); qDebug() << "sent waypoint ack (" << wpa.type << ") to ID " << wpa.target_system; } diff --git a/src/ui/CommConfigurationWindow.cc b/src/ui/CommConfigurationWindow.cc index 3b97555aeb9a1ef5927d8066c76b2b1d08e7fdc9..3b325ced1b835049de6d6bd7dda8b7562abb0f73 100644 --- a/src/ui/CommConfigurationWindow.cc +++ b/src/ui/CommConfigurationWindow.cc @@ -99,7 +99,7 @@ CommConfigurationWindow::CommConfigurationWindow(LinkInterface* link, ProtocolIn } else if (dynamic_cast(link) != 0) { - ui.linkGroupBox->setTitle(tr("serial link")); + ui.linkGroupBox->setTitle(tr("udp link")); } else { diff --git a/src/ui/DebugConsole.cc b/src/ui/DebugConsole.cc index 598f7b63f48dca96001fe7dddf6a15e845905ad5..2a0199ced1ced456a1fa712f6992b46245551519 100644 --- a/src/ui/DebugConsole.cc +++ b/src/ui/DebugConsole.cc @@ -101,6 +101,8 @@ DebugConsole::DebugConsole(QWidget *parent) : connect(m_ui->holdCheckBox, SIGNAL(clicked(bool)), this, SLOT(setAutoHold(bool))); // Connect hold button connect(m_ui->holdButton, SIGNAL(toggled(bool)), this, SLOT(hold(bool))); + + this->setVisible(false); } DebugConsole::~DebugConsole() diff --git a/src/ui/HDDisplay.cc b/src/ui/HDDisplay.cc index 0b7574fb9ade780bce5ee8d1aa6d8cc979eaa8fa..dd996b640a8452f27c9e7fe7d7c4606027af27b8 100644 --- a/src/ui/HDDisplay.cc +++ b/src/ui/HDDisplay.cc @@ -100,6 +100,8 @@ HDDisplay::HDDisplay(QStringList* plotList, QWidget *parent) : // Connect with UAS connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*))); //start(); + + this->setVisible(false); } HDDisplay::~HDDisplay() diff --git a/src/ui/HSIDisplay.cc b/src/ui/HSIDisplay.cc index 7ec88638fe9587a7dfb3db446bd07165803db95d..590ddcd9b1e142cb511dfd7fd54f167173d01dac 100644 --- a/src/ui/HSIDisplay.cc +++ b/src/ui/HSIDisplay.cc @@ -100,6 +100,7 @@ HSIDisplay::HSIDisplay(QWidget *parent) : xCenterPos = vwidth/2.0f; yCenterPos = vheight/2.0f + topMargin - bottomMargin; + this->setVisible(false); } void HSIDisplay::paintEvent(QPaintEvent * event) diff --git a/src/ui/HUD.cc b/src/ui/HUD.cc index 11ce1208df0247ee826edda3d98aa616581e7348..dfd9864702385b9c0a39c8196b1e19fe4555ec33 100644 --- a/src/ui/HUD.cc +++ b/src/ui/HUD.cc @@ -153,6 +153,8 @@ HUD::HUD(int width, int height, QWidget* parent) // Connect with UAS UASManager* manager = UASManager::instance(); connect(manager, SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*))); + + this->setVisible(false); } HUD::~HUD() diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index e94b180a912200bad3f63abaf8da29315c3fe193..198c6e098868eb6a4d1cde106a1bc394c8115086 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -62,94 +62,23 @@ This file is part of the QGROUNDCONTROL project * * @see QMainWindow::show() **/ -MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), -settings() +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + settings() { this->hide(); this->setVisible(false); - mavlink = new MAVLinkProtocol(); - // Setup user interface ui.setupUi(this); - // Initialize views, NOT show them yet, only initialize model and controller - centerStack = new QStackedWidget(this); - linechart = new Linecharts(this); - linechart->setActive(false); - connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), linechart, SLOT(addSystem(UASInterface*))); - connect(UASManager::instance(), SIGNAL(activeUASSet(int)), linechart, SLOT(selectSystem(int))); - centerStack->addWidget(linechart); - control = new UASControlWidget(this); - //controlDock = new QDockWidget(this); - //controlDock->setWidget(control); - list = new UASListWidget(this); - list->setVisible(false); - waypoints = new WaypointList(this, NULL); - waypoints->setVisible(false); - info = new UASInfoWidget(this); - info->setVisible(false); - detection = new ObjectDetectionView("patterns", this); - detection->setVisible(false); - hud = new HUD(640, 480, this); - hud->setVisible(false); - debugConsole = new DebugConsole(this); - debugConsole->setVisible(false); - map = new MapWidget(this); - map->setVisible(false); - protocol = new XMLCommProtocolWidget(this); - protocol->setVisible(false); - centerStack->addWidget(protocol); - parameters = new ParameterInterface(this); - 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"); - acceptList->append("pitch IMU"); - acceptList->append("yaw IMU"); - acceptList->append("rollspeed IMU"); - acceptList->append("pitchspeed IMU"); - acceptList->append("yawspeed IMU"); - headDown1 = new HDDisplay(acceptList, this); - headDown1->setVisible(false); - - QStringList* acceptList2 = new QStringList(); - acceptList2->append("Battery"); - acceptList2->append("Pressure"); - headDown2 = new HDDisplay(acceptList2, this); - headDown2->setVisible(false); - centerStack->addWidget(map); - centerStack->addWidget(hud); - setCentralWidget(centerStack); - - // Get IPs - QList hostAddresses = QNetworkInterface::allAddresses(); - - QString windowname = qApp->applicationName() + " " + qApp->applicationVersion(); - - windowname.append(" (" + QHostInfo::localHostName() + ": "); - bool prevAddr = false; - for (int i = 0; i < hostAddresses.size(); i++) - { - // Exclude loopback IPv4 and all IPv6 addresses - if (hostAddresses.at(i) != QHostAddress("127.0.0.1") && !hostAddresses.at(i).toString().contains(":")) - { - if(prevAddr) windowname.append("/"); - windowname.append(hostAddresses.at(i).toString()); - prevAddr = true; - } - } + buildWidgets(); - windowname.append(")"); + connectWidgets(); - setWindowTitle(windowname); -#ifndef Q_WS_MAC - //qApp->setWindowIcon(QIcon(":/core/images/qtcreator_logo_128.png")); -#endif + arrangeCenterStack(); + + configureWindowName(); // Add status bar setStatusBar(createStatusBar()); @@ -157,10 +86,10 @@ settings() // Set the application style (not the same as a style sheet) // Set the style to Plastique qApp->setStyle("plastique"); + // Set style sheet as last step reloadStylesheet(); - joystick = new JoystickInput(); // Create actions connectActions(); @@ -170,9 +99,6 @@ settings() // Adjust the size adjustSize(); - - // - connect(mavlink, SIGNAL(receiveLossChanged(int, float)), info, SLOT(updateSendLoss(int, float))); } MainWindow::~MainWindow() @@ -181,6 +107,86 @@ MainWindow::~MainWindow() statusBar = NULL; } + +void MainWindow::buildWidgets() +{ + QStringList* acceptList = new QStringList(); + acceptList->append("roll IMU"); + acceptList->append("pitch IMU"); + acceptList->append("yaw IMU"); + acceptList->append("rollspeed IMU"); + acceptList->append("pitchspeed IMU"); + acceptList->append("yawspeed IMU"); + + QStringList* acceptList2 = new QStringList(); + acceptList2->append("Battery"); + acceptList2->append("Pressure"); + + + mavlink = new MAVLinkProtocol(); + linechart = new Linecharts(this); + control = new UASControlWidget(this); + list = new UASListWidget(this); + waypoints = new WaypointList(this, NULL); + info = new UASInfoWidget(this); + detection = new ObjectDetectionView("patterns", this); + hud = new HUD(640, 480, this); + debugConsole= new DebugConsole(this); + map = new MapWidget(this); + protocol = new XMLCommProtocolWidget(this); + parameters = new ParameterInterface(this); + watchdogControl = new WatchdogControl(this); + hsi = new HSIDisplay(this); + headDown1 = new HDDisplay(acceptList, this); + headDown2 = new HDDisplay(acceptList2, this); + joystick = new JoystickInput(); +} + +void MainWindow::connectWidgets(){ + connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), linechart, SLOT(addSystem(UASInterface*))); + connect(UASManager::instance(), SIGNAL(activeUASSet(int)), linechart, SLOT(selectSystem(int))); + connect(mavlink, SIGNAL(receiveLossChanged(int, float)), info, SLOT(updateSendLoss(int, float))); +} + +void MainWindow::arrangeCenterStack(){ + + centerStack = new QStackedWidget(this); + + centerStack->addWidget(linechart); + centerStack->addWidget(protocol); + centerStack->addWidget(map); + centerStack->addWidget(hud); + + setCentralWidget(centerStack); +} + +void MainWindow::configureWindowName(){ + QList hostAddresses = QNetworkInterface::allAddresses(); + QString windowname = qApp->applicationName() + " " + qApp->applicationVersion(); + bool prevAddr = false; + + windowname.append(" (" + QHostInfo::localHostName() + ": "); + + for (int i = 0; i < hostAddresses.size(); i++) + { + // Exclude loopback IPv4 and all IPv6 addresses + if (hostAddresses.at(i) != QHostAddress("127.0.0.1") && !hostAddresses.at(i).toString().contains(":")) + { + if(prevAddr) windowname.append("/"); + windowname.append(hostAddresses.at(i).toString()); + prevAddr = true; + } + } + + windowname.append(")"); + + setWindowTitle(windowname); + +#ifndef Q_WS_MAC + //qApp->setWindowIcon(QIcon(":/core/images/qtcreator_logo_128.png")); +#endif +} + QStatusBar* MainWindow::createStatusBar() { QStatusBar* bar = new QStatusBar(); diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 4576384f7ef5126ddfbf539d1d9e915e41d8f608..d611fe095e971fd9f32093d0daaa2705a6341bd3 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -129,6 +129,10 @@ protected: void loadWidgets(); void connectActions(); void clearView(); + void buildWidgets(); + void connectWidgets(); + void arrangeCenterStack(); + void configureWindowName(); // TODO Should be moved elsewhere, as the protocol does not belong to the UI MAVLinkProtocol* mavlink; @@ -178,6 +182,7 @@ protected: private: Ui::MainWindow ui; + }; #endif /* _MAINWINDOW_H_ */ diff --git a/src/ui/MapWidget.cc b/src/ui/MapWidget.cc index d73b7b181e17f1857976812782faa8bd68b1c136..df6e8fd8b954efa8adb0bbf696c3a4232877d118 100644 --- a/src/ui/MapWidget.cc +++ b/src/ui/MapWidget.cc @@ -107,6 +107,8 @@ MapWidget::MapWidget(QWidget *parent) : mc->setZoom(3); connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(addUAS(UASInterface*))); + + this->setVisible(false); } MapWidget::~MapWidget() diff --git a/src/ui/ObjectDetectionView.cc b/src/ui/ObjectDetectionView.cc index 68e9f3c2e08141079c36c08602cbad5ab08fcc44..f5a80e80416291a0e0593ec48d48c0ef0119dc34 100644 --- a/src/ui/ObjectDetectionView.cc +++ b/src/ui/ObjectDetectionView.cc @@ -57,6 +57,8 @@ ObjectDetectionView::ObjectDetectionView(QString folder, QWidget *parent) : letterTimer.start(1000); connect(&letterTimer, SIGNAL(timeout()), this, SLOT(decreaseLetterTime())); connect(m_ui->clearButton, SIGNAL(clicked()), this, SLOT(clearLists())); + + this->setVisible(false); } ObjectDetectionView::~ObjectDetectionView() diff --git a/src/ui/ParameterInterface.cc b/src/ui/ParameterInterface.cc index 777034f4d4f9635a5dcda1cffa3970b77b992dd0..33a63c74033533de57c13a0be191c518b602cb91 100644 --- a/src/ui/ParameterInterface.cc +++ b/src/ui/ParameterInterface.cc @@ -23,6 +23,7 @@ ParameterInterface::ParameterInterface(QWidget *parent) : // Setup MAV connections connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(addUAS(UASInterface*))); + this->setVisible(false); } ParameterInterface::~ParameterInterface() diff --git a/src/ui/QGCFirmwareUpdate.cc b/src/ui/QGCFirmwareUpdate.cc new file mode 100644 index 0000000000000000000000000000000000000000..7e943d71738a3b880b2afe782dcc5a391d35f377 --- /dev/null +++ b/src/ui/QGCFirmwareUpdate.cc @@ -0,0 +1,26 @@ +#include "QGCFirmwareUpdate.h" +#include "ui_QGCFirmwareUpdate.h" + +QGCFirmwareUpdate::QGCFirmwareUpdate(QWidget *parent) : + QWidget(parent), + ui(new Ui::QGCFirmwareUpdate) +{ + ui->setupUi(this); +} + +QGCFirmwareUpdate::~QGCFirmwareUpdate() +{ + delete ui; +} + +void QGCFirmwareUpdate::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} diff --git a/src/ui/QGCFirmwareUpdate.h b/src/ui/QGCFirmwareUpdate.h new file mode 100644 index 0000000000000000000000000000000000000000..c03b05bc04ac8c4b083b8655bab62c4a081f67cd --- /dev/null +++ b/src/ui/QGCFirmwareUpdate.h @@ -0,0 +1,23 @@ +#ifndef QGCFIRMWAREUPDATE_H +#define QGCFIRMWAREUPDATE_H + +#include + +namespace Ui { + class QGCFirmwareUpdate; +} + +class QGCFirmwareUpdate : public QWidget { + Q_OBJECT +public: + QGCFirmwareUpdate(QWidget *parent = 0); + ~QGCFirmwareUpdate(); + +protected: + void changeEvent(QEvent *e); + +private: + Ui::QGCFirmwareUpdate *ui; +}; + +#endif // QGCFIRMWAREUPDATE_H diff --git a/src/ui/QGCFirmwareUpdate.ui b/src/ui/QGCFirmwareUpdate.ui new file mode 100644 index 0000000000000000000000000000000000000000..389514f63575fadc1cb8f0fa20265d467d0ce9db --- /dev/null +++ b/src/ui/QGCFirmwareUpdate.ui @@ -0,0 +1,21 @@ + + + + + QGCFirmwareUpdate + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + diff --git a/src/ui/QGCPxImuFirmwareUpdate.cc b/src/ui/QGCPxImuFirmwareUpdate.cc new file mode 100644 index 0000000000000000000000000000000000000000..91a9e3466ef3896d49b25c7716f21b49cae51076 --- /dev/null +++ b/src/ui/QGCPxImuFirmwareUpdate.cc @@ -0,0 +1,26 @@ +#include "QGCPxImuFirmwareUpdate.h" +#include "ui_QGCPxImuFirmwareUpdate.h" + +QGCPxImuFirmwareUpdate::QGCPxImuFirmwareUpdate(QWidget *parent) : + QWidget(parent), + ui(new Ui::QGCPxImuFirmwareUpdate) +{ + ui->setupUi(this); +} + +QGCPxImuFirmwareUpdate::~QGCPxImuFirmwareUpdate() +{ + delete ui; +} + +void QGCPxImuFirmwareUpdate::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} diff --git a/src/ui/QGCPxImuFirmwareUpdate.h b/src/ui/QGCPxImuFirmwareUpdate.h new file mode 100644 index 0000000000000000000000000000000000000000..c48ce1763cec72551e02a9ad1edfc52a9340bb85 --- /dev/null +++ b/src/ui/QGCPxImuFirmwareUpdate.h @@ -0,0 +1,23 @@ +#ifndef QGCPXIMUFIRMWAREUPDATE_H +#define QGCPXIMUFIRMWAREUPDATE_H + +#include + +namespace Ui { + class QGCPxImuFirmwareUpdate; +} + +class QGCPxImuFirmwareUpdate : public QWidget { + Q_OBJECT +public: + QGCPxImuFirmwareUpdate(QWidget *parent = 0); + ~QGCPxImuFirmwareUpdate(); + +protected: + void changeEvent(QEvent *e); + +private: + Ui::QGCPxImuFirmwareUpdate *ui; +}; + +#endif // QGCPXIMUFIRMWAREUPDATE_H diff --git a/src/ui/QGCPxImuFirmwareUpdate.ui b/src/ui/QGCPxImuFirmwareUpdate.ui new file mode 100644 index 0000000000000000000000000000000000000000..8f4111ca52456f73771b6da6790f32e157cb1185 --- /dev/null +++ b/src/ui/QGCPxImuFirmwareUpdate.ui @@ -0,0 +1,108 @@ + + + QGCPxImuFirmwareUpdate + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + Instructions + + + + 2 + + + + + <h1>pxIMU Firmware Update</h1> + +<li> + <item>Item 1</item> +</li> + + + + + + + + + + + From File + + + + + + + Choose file.. + + + + + + + Choose File + + + + + + + From Internet + + + + + + + Firmware v.0.2.1 + + + + + + + Download + + + + + + + + + + + + + + Waiting for first user action + + + + + + + Flash Firmware + + + + + + + + diff --git a/src/ui/WaypointList.cc b/src/ui/WaypointList.cc index f9fdace476f2857f813c7444ee19e802b9c3b4de..44da836045d045a4293d3715615d54d88835877a 100644 --- a/src/ui/WaypointList.cc +++ b/src/ui/WaypointList.cc @@ -82,6 +82,8 @@ WaypointList::WaypointList(QWidget *parent, UASInterface* uas) : // STATUS LABEL updateStatusLabel(""); + + this->setVisible(false); } WaypointList::~WaypointList() diff --git a/src/ui/XMLCommProtocolWidget.cc b/src/ui/XMLCommProtocolWidget.cc index 907cd0fd69929a5f2c2678764265ad4277f628a5..582c74ac639480592dfbd36dca607fb5db4c7b7c 100644 --- a/src/ui/XMLCommProtocolWidget.cc +++ b/src/ui/XMLCommProtocolWidget.cc @@ -24,6 +24,8 @@ XMLCommProtocolWidget::XMLCommProtocolWidget(QWidget *parent) : connect(m_ui->selectOutputButton, SIGNAL(clicked()), this, SLOT(selectOutputDirectory())); connect(m_ui->generateButton, SIGNAL(clicked()), this, SLOT(generate())); connect(m_ui->saveButton, SIGNAL(clicked()), this, SLOT(save())); + + this->setVisible(false); } void XMLCommProtocolWidget::selectXMLFile() diff --git a/src/ui/linechart/Linecharts.cc b/src/ui/linechart/Linecharts.cc index fa88d9d2f4ec45680f96038f27214aa93f89b43e..d904a1973da4aaba9b1dc465e85fccc73bbf32e2 100644 --- a/src/ui/linechart/Linecharts.cc +++ b/src/ui/linechart/Linecharts.cc @@ -5,6 +5,7 @@ Linecharts::Linecharts(QWidget *parent) : plots(), active(true) { + this->setVisible(false); } diff --git a/src/ui/uas/UASInfoWidget.cc b/src/ui/uas/UASInfoWidget.cc index c835c5f64daa52f7f9734ef94e2e1e118ef8aaa3..08f176cd4a7c9a09d14bf1e0b3a57ad4b5558a3d 100644 --- a/src/ui/uas/UASInfoWidget.cc +++ b/src/ui/uas/UASInfoWidget.cc @@ -75,6 +75,8 @@ UASInfoWidget::UASInfoWidget(QWidget *parent, QString name) : QWidget(parent) connect(updateTimer, SIGNAL(timeout()), this, SLOT(refresh())); updateTimer->start(50); + this->setVisible(false); + } UASInfoWidget::~UASInfoWidget() diff --git a/src/ui/uas/UASListWidget.cc b/src/ui/uas/UASListWidget.cc index 7369341e2b6cdf3c2a08d63708a95c7d387feae6..e4fb0026fecea3cbf4974d4e12a5fff1e2c7749f 100644 --- a/src/ui/uas/UASListWidget.cc +++ b/src/ui/uas/UASListWidget.cc @@ -51,6 +51,8 @@ UASListWidget::UASListWidget(QWidget *parent) : QWidget(parent), m_ui(new Ui::UA this->setMinimumWidth(250); uasViews = QMap(); + + this->setVisible(false); } UASListWidget::~UASListWidget() diff --git a/src/ui/watchdog/WatchdogControl.cc b/src/ui/watchdog/WatchdogControl.cc index 572ecb8d87878241e49a4caf50becb8e173bb3b7..50cde8fed94d88f126408a79e99f881619fc31af 100644 --- a/src/ui/watchdog/WatchdogControl.cc +++ b/src/ui/watchdog/WatchdogControl.cc @@ -24,6 +24,8 @@ WatchdogControl::WatchdogControl(QWidget *parent) : ui->mainWidget->setLayout(listLayout); connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(setUAS(UASInterface*))); + + this->setVisible(false); } WatchdogControl::~WatchdogControl()