Browse Source

merged. Added Waypoint changes, only retrieving waypoints works at the moment

QGC4.4
pixhawk 15 years ago
parent
commit
34290c0538
  1. BIN
      patterns/a.bmp
  2. BIN
      patterns/board-center.png
  3. BIN
      patterns/board-left.png
  4. BIN
      patterns/board-right.png
  5. BIN
      patterns/einstein.bmp
  6. BIN
      patterns/face1.png
  7. BIN
      patterns/face1_fisheye.png
  8. BIN
      patterns/face1_light.png
  9. BIN
      patterns/face1_noise.png
  10. BIN
      patterns/face1_noise_fisheye.png
  11. BIN
      patterns/face1_noise_light.png
  12. BIN
      patterns/face1_noise_light_fisheye.png
  13. BIN
      patterns/face2.png
  14. BIN
      patterns/face3.png
  15. BIN
      patterns/face3_perspect1.png
  16. BIN
      patterns/face3_perspect2.png
  17. BIN
      patterns/face3_perspect3.png
  18. BIN
      patterns/face4.png
  19. BIN
      patterns/face4_treshold1.png
  20. BIN
      patterns/face4_treshold2.png
  21. BIN
      patterns/face5.png
  22. BIN
      patterns/face5_perspect1.png
  23. BIN
      patterns/face5_threshold.png
  24. BIN
      patterns/floors1.png
  25. BIN
      patterns/floors2.png
  26. BIN
      patterns/floors5.png
  27. BIN
      patterns/floors6.png
  28. BIN
      patterns/frame_2010-03-17_2_rect.bmp
  29. BIN
      patterns/frame_2010-03-17_3_rect.bmp
  30. BIN
      patterns/frog.bmp
  31. BIN
      patterns/letterB.png
  32. BIN
      patterns/letterD.png
  33. BIN
      patterns/letterP.png
  34. BIN
      patterns/letterP_light.png
  35. BIN
      patterns/letterP_noise.png
  36. BIN
      patterns/letterR.png
  37. BIN
      patterns/letterR_strongnoise.png
  38. BIN
      patterns/letterS.png
  39. BIN
      patterns/santa-delft.png
  40. BIN
      patterns/stereo_left01.png
  41. BIN
      patterns/stereo_right01.png
  42. BIN
      patterns/white.png
  43. 15
      qgroundcontrol.pri
  44. 25
      qgroundcontrol.pro
  45. 39
      src/Core.cc
  46. 5
      src/plugins/.gitignore
  47. 114
      src/plugins/PxMAV.cc
  48. 24
      src/plugins/PxMAV.h
  49. 22
      src/plugins/pixhawk_plugins.pro
  50. 1
      src/uas/PxQuadMAV.h
  51. 3
      src/uas/UAS.cc
  52. 6
      src/uas/UASInterface.h
  53. 8
      src/ui/HDDisplay.cc
  54. 174
      src/ui/HSIDisplay.cc
  55. 65
      src/ui/HSIDisplay.h
  56. 2
      src/ui/MainWindow.cc
  57. 2
      src/ui/MainWindow.h
  58. 12
      src/ui/ObjectDetectionView.cc
  59. 2
      src/ui/ObjectDetectionView.h
  60. 63
      src/ui/UASInfo.ui
  61. 6
      src/ui/WaypointList.cc
  62. 8
      src/ui/generated/CommSettings.h
  63. 8
      src/ui/generated/MainWindow.h
  64. 8
      src/ui/generated/SerialSettings.h
  65. 8
      src/ui/generated/UASControl.h
  66. 8
      src/ui/generated/UASInfo.h
  67. 8
      src/ui/generated/UASList.h
  68. 15
      src/ui/uas/UASInfoWidget.cc

BIN
patterns/a.bmp

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 KiB

BIN
patterns/board-center.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 KiB

BIN
patterns/board-left.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 KiB

BIN
patterns/board-right.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 KiB

BIN
patterns/einstein.bmp

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 KiB

BIN
patterns/face1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

BIN
patterns/face1_fisheye.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 KiB

BIN
patterns/face1_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

BIN
patterns/face1_noise.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 KiB

BIN
patterns/face1_noise_fisheye.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 KiB

BIN
patterns/face1_noise_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 317 KiB

BIN
patterns/face1_noise_light_fisheye.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 328 KiB

BIN
patterns/face2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 KiB

BIN
patterns/face3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 KiB

BIN
patterns/face3_perspect1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

BIN
patterns/face3_perspect2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

BIN
patterns/face3_perspect3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

BIN
patterns/face4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 KiB

BIN
patterns/face4_treshold1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
patterns/face4_treshold2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

BIN
patterns/face5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 KiB

BIN
patterns/face5_perspect1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 KiB

BIN
patterns/face5_threshold.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

BIN
patterns/floors1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 KiB

BIN
patterns/floors2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 KiB

BIN
patterns/floors5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 487 KiB

BIN
patterns/floors6.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 KiB

BIN
patterns/frame_2010-03-17_2_rect.bmp

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 KiB

BIN
patterns/frame_2010-03-17_3_rect.bmp

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 KiB

BIN
patterns/frog.bmp

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 KiB

BIN
patterns/letterB.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

BIN
patterns/letterD.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

BIN
patterns/letterP.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

BIN
patterns/letterP_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
patterns/letterP_noise.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

BIN
patterns/letterR.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

BIN
patterns/letterR_strongnoise.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 KiB

BIN
patterns/letterS.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
patterns/santa-delft.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 KiB

BIN
patterns/stereo_left01.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

BIN
patterns/stereo_right01.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

BIN
patterns/white.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B

15
qgroundcontrol.pri

@ -25,21 +25,6 @@ @@ -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

25
qgroundcontrol.pro

@ -8,6 +8,22 @@ @@ -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) @@ -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 \ @@ -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 \ @@ -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

39
src/Core.cc

@ -131,7 +131,7 @@ Core::Core(int &argc, char* argv[]) : QApplication(argc, argv) @@ -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() @@ -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());
}
}
}

5
src/plugins/.gitignore vendored

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
moc_*
*.o
Makefile
Makefile.Debug
Makefile.Release

114
src/plugins/PxMAV.cc

@ -0,0 +1,114 @@ @@ -0,0 +1,114 @@
#include "PxMAV.h"
#include <QtCore>
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)

24
src/plugins/PxMAV.h

@ -0,0 +1,24 @@ @@ -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

22
src/plugins/pixhawk_plugins.pro

@ -0,0 +1,22 @@ @@ -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

1
src/uas/PxQuadMAV.h

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
class PxQuadMAV : public UAS
{
Q_OBJECT
Q_INTERFACES(UASInterface)
public:
PxQuadMAV(MAVLinkProtocol* mavlink, int id);
public slots:

3
src/uas/UAS.cc

@ -43,7 +43,7 @@ This file is part of the PIXHAWK project @@ -43,7 +43,7 @@ This file is part of the PIXHAWK project
#include "MAVLinkProtocol.h"
#include <mavlink.h>
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) : @@ -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()));

6
src/uas/UASInterface.h

@ -51,10 +51,6 @@ class UASInterface : public QObject @@ -51,10 +51,6 @@ class UASInterface : public QObject
{
Q_OBJECT
public:
UASInterface() :
color(UASInterface::getNextColor())
{
}
virtual ~UASInterface() {}
/* MANAGEMENT */
@ -315,4 +311,6 @@ signals: @@ -315,4 +311,6 @@ signals:
void systemTypeSet(UASInterface* uas, unsigned int type);
};
Q_DECLARE_INTERFACE(UASInterface, "org.qgroundcontrol/1.0");
#endif // _UASINTERFACE_H_

8
src/ui/HDDisplay.cc

@ -74,6 +74,12 @@ HDDisplay::HDDisplay(QStringList* plotList, QWidget *parent) : @@ -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() @@ -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);

174
src/ui/HSIDisplay.cc

@ -0,0 +1,174 @@ @@ -0,0 +1,174 @@
/*=====================================================================
PIXHAWK Micro Air Vehicle Flying Robotics Toolkit
(c) 2009, 2010 PIXHAWK PROJECT <http://pixhawk.ethz.ch>
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 <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Implementation of Horizontal Situation Indicator class
*
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#include <QFile>
#include <QStringList>
#include <QPainter>
#include "UASManager.h"
#include "HSIDisplay.h"
#include "MG.h"
#include <QDebug>
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);
}

65
src/ui/HSIDisplay.h

@ -0,0 +1,65 @@ @@ -0,0 +1,65 @@
/*=====================================================================
PIXHAWK Micro Air Vehicle Flying Robotics Toolkit
(c) 2009, 2010 PIXHAWK PROJECT <http://pixhawk.ethz.ch>
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 <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Definition of of Horizontal Situation Indicator class
*
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#ifndef HSIDISPLAY_H
#define HSIDISPLAY_H
#include <QtGui/QWidget>
#include <QColor>
#include <QTimer>
#include <QMap>
#include <QPair>
#include <cmath>
#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

2
src/ui/MainWindow.cc

@ -100,6 +100,8 @@ settings() @@ -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");

2
src/ui/MainWindow.h

@ -61,6 +61,7 @@ This file is part of the PIXHAWK project @@ -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: @@ -148,6 +149,7 @@ protected:
HDDisplay* headDown1;
HDDisplay* headDown2;
WatchdogControl* watchdogControl;
HSIDisplay* hsi;
// Popup widgets
JoystickWidget* joystickWidget;

12
src/ui/ObjectDetectionView.cc

@ -38,6 +38,8 @@ This file is part of the PIXHAWK project @@ -38,6 +38,8 @@ This file is part of the PIXHAWK project
#include <QDebug>
#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 @@ -90,8 +92,9 @@ void ObjectDetectionView::newDetection(int uasId, QString patternPath, int x1, i
{
if (patternList.contains(patternPath))
{
qDebug() << "REDETECTED";
//qDebug() << "REDETECTED";
/*
QList<QAction*> 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 @@ -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 @@ -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()));

2
src/ui/ObjectDetectionView.h

@ -48,7 +48,7 @@ class ObjectDetectionView : public QWidget { @@ -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 */

63
src/ui/UASInfo.ui

@ -66,7 +66,7 @@ @@ -66,7 +66,7 @@
</property>
</widget>
</item>
<item row="0" column="4" colspan="4">
<item row="0" column="4" colspan="2">
<widget class="QProgressBar" name="batteryBar">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@ -109,7 +109,7 @@ @@ -109,7 +109,7 @@
</property>
</widget>
</item>
<item row="0" column="8" rowspan="6">
<item row="0" column="6" rowspan="6">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -171,7 +171,7 @@ @@ -171,7 +171,7 @@
</property>
</widget>
</item>
<item row="1" column="4" colspan="4">
<item row="1" column="4" colspan="2">
<widget class="QProgressBar" name="receiveLossBar">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@ -257,7 +257,7 @@ @@ -257,7 +257,7 @@
</property>
</widget>
</item>
<item row="2" column="4" colspan="4">
<item row="2" column="4" colspan="2">
<widget class="QProgressBar" name="sendLossBar">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@ -343,7 +343,7 @@ @@ -343,7 +343,7 @@
</property>
</widget>
</item>
<item row="3" column="4" colspan="4">
<item row="3" column="4" colspan="2">
<widget class="QProgressBar" name="loadBar">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@ -380,56 +380,14 @@ @@ -380,56 +380,14 @@
</property>
</widget>
</item>
<item row="4" column="0" colspan="8">
<item row="4" column="0" colspan="6">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>I2C Errors</string>
</property>
</widget>
</item>
<item row="5" column="1" colspan="2">
<widget class="QLabel" name="i2cErrorLabel">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="5" column="4">
<widget class="QLabel" name="label_5">
<property name="text">
<string>SPI Errors</string>
</property>
</widget>
</item>
<item row="5" column="5">
<widget class="QLabel" name="spiErrorLabel">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="5" column="6">
<widget class="QLabel" name="label_10">
<property name="text">
<string>UART Errors</string>
</property>
</widget>
</item>
<item row="5" column="7">
<widget class="QLabel" name="uartErrorLabel">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="9">
<item row="6" column="0" colspan="7">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -445,6 +403,13 @@ @@ -445,6 +403,13 @@
</property>
</spacer>
</item>
<item row="5" column="0" colspan="6">
<widget class="QLabel" name="errorLabel">
<property name="text">
<string>No error status received yet</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>

6
src/ui/WaypointList.cc

@ -85,8 +85,8 @@ void WaypointList::setUAS(UASInterface* uas) @@ -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) @@ -315,7 +315,7 @@ void WaypointList::setCurrentWaypoint(Waypoint* wp)
{
waypoints[i]->current = true;
// Retransmit waypoint
uas->setWaypointActive(i);
//uas->getWaypointManager().setWaypointActive(i);
}
else
{

8
src/ui/generated/CommSettings.h

@ -0,0 +1,8 @@ @@ -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!
****************************************************************************/

8
src/ui/generated/MainWindow.h

@ -0,0 +1,8 @@ @@ -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!
****************************************************************************/

8
src/ui/generated/SerialSettings.h

@ -0,0 +1,8 @@ @@ -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!
****************************************************************************/

8
src/ui/generated/UASControl.h

@ -0,0 +1,8 @@ @@ -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!
****************************************************************************/

8
src/ui/generated/UASInfo.h

@ -0,0 +1,8 @@ @@ -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!
****************************************************************************/

8
src/ui/generated/UASList.h

@ -0,0 +1,8 @@ @@ -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!
****************************************************************************/

15
src/ui/uas/UASInfoWidget.cc

@ -110,7 +110,7 @@ void UASInfoWidget::updateBattery(UASInterface* uas, double voltage, double perc @@ -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() @@ -182,5 +182,16 @@ void UASInfoWidget::refresh()
ui.sendLossLabel->setText(QString::number(sendLoss, 'f', 2));
QString errorString;
// ui.
QMapIterator<QString, int> i(errors);
while (i.hasNext())
{
i.next();
errorString += QString(i.key() + ": %1 ").arg(i.value());
// FIXME
errorString.replace("IMU:", "");
}
ui.errorLabel->setText(errorString);
}

Loading…
Cancel
Save