Commit d94341d9 authored by pixhawk's avatar pixhawk

Merge branch 'master' of git@pixhawk.ethz.ch:qgroundcontrol

parents 11fa19c3 0a242d66
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:
<instructions to be written>
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
=======
......
......@@ -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
......@@ -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);
......
......@@ -33,6 +33,8 @@ This file is part of the PIXHAWK project
#include <QApplication>
#include "LinkManager.h"
#include <QDebug>
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<LinkInterface*> LinkManager::getLinksForProtocol(ProtocolInterface* protocol)
......
......@@ -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();
}
}
......
......@@ -4,6 +4,7 @@
#include <QList>
#include <QMap>
#include <QDateTime>
#include <QLocale>
#include "MAVLinkXMLParser.h"
#include <QDebug>
......@@ -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";
......
......@@ -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() {
......
......@@ -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
/**
......
......@@ -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;
......
......@@ -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)
{
......
......@@ -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;
}
......@@ -99,7 +99,7 @@ CommConfigurationWindow::CommConfigurationWindow(LinkInterface* link, ProtocolIn
}
else if (dynamic_cast<UDPLink*>(link) != 0)
{
ui.linkGroupBox->setTitle(tr("serial link"));
ui.linkGroupBox->setTitle(tr("udp link"));
}
else
{
......
......@@ -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()
......
......@@ -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()
......
......@@ -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)
......
......@@ -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()
......
......@@ -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<QHostAddress> 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<QHostAddress> 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();
......
......@@ -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_ */
......@@ -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()
......
......@@ -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()
......
......@@ -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()
......
#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;
}
}
#ifndef QGCFIRMWAREUPDATE_H
#define QGCFIRMWAREUPDATE_H
#include <QWidget>
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
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>QGCFirmwareUpdate</class>
<widget class="QWidget" name="QGCFirmwareUpdate">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<pixmapfunction/>
<connections/>
</ui>
#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;
}
}
#ifndef QGCPXIMUFIRMWAREUPDATE_H
#define QGCPXIMUFIRMWAREUPDATE_H
#include <QWidget>
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
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QGCPxImuFirmwareUpdate</class>
<widget class="QWidget" name="QGCPxImuFirmwareUpdate">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="5">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Instructions</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin">
<number>2</number>
</property>
<item>
<widget class="QPlainTextEdit" name="plainTextEdit">
<property name="plainText">
<string>&lt;h1&gt;pxIMU Firmware Update&lt;/h1&gt;
&lt;li&gt;
&lt;item&gt;Item 1&lt;/item&gt;
&lt;/li&gt;
</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QRadioButton" name="radioButton">
<property name="text">
<string>From File</string>
</property>
</widget>
</item>
<item row="1" column="2" colspan="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Choose file..</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>Choose File</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QRadioButton" name="radioButton_2">
<property name="text">
<string>From Internet</string>
</property>
</widget>
</item>
<item row="2" column="2" colspan="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Firmware v.0.2.1</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>Download</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Waiting for first user action</string>
</property>
</widget>
</item>
<item row="3" column="3" colspan="2">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Flash Firmware</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -82,6 +82,8 @@ WaypointList::WaypointList(QWidget *parent, UASInterface* uas) :
// STATUS LABEL
updateStatusLabel("");
this->setVisible(false);
}
WaypointList::~WaypointList()
......
......@@ -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()
......
......@@ -5,6 +5,7 @@ Linecharts::Linecharts(QWidget *parent) :
plots(),
active(true)
{
this->setVisible(false);
}
......
......@@ -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()
......
......@@ -51,6 +51,8 @@ UASListWidget::UASListWidget(QWidget *parent) : QWidget(parent), m_ui(new Ui::UA
this->setMinimumWidth(250);
uasViews = QMap<UASInterface*, UASView*>();
this->setVisible(false);
}
UASListWidget::~UASListWidget()
......
......@@ -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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment