Commit 2d8aacd0 authored by lm's avatar lm

Merge branch 'experimental' of pixhawk.ethz.ch:qgroundcontrol

parents 363fe653 73b9e202
......@@ -27,7 +27,7 @@ R13=0.005927
R21=-0.000563
R22=0.999999
R23=0.001235
R33=-0.005926
R31=-0.005926
R32=-0.001239
R33=0.999982
Tx=-0.024287
......
......@@ -12,6 +12,7 @@ cp -r ../bin/mac/qgroundcontrol.app mac/.
cp -r ../audio mac/qgroundcontrol.app/Contents/MacOs/.
mkdir -p mac/qgroundcontrol.app/Contents/Frameworks/
# SDL is not copied by Qt - for whatever reason
cp -r SDL.framework mac/qgroundcontrol.app/Contents/Frameworks/.
echo -e '\n\nStarting to create disk image. This may take a while..\n'
macdeployqt mac/qgroundcontrol.app -dmg
......
......@@ -16,20 +16,20 @@ LicenseData ..\license.txt
Section ""
SetOutPath $INSTDIR
File qgroundcontrol\*.*
WriteUninstaller $INSTDIR\QGroundcontrol_uninstall.exe
File ..\release\*.*
WriteUninstaller $INSTDIR\QGroundControl_uninstall.exe
SectionEnd
Section "Uninstall"
Delete $INSTDIR\QGroundcontrol_uninstall.exe
Delete $INSTDIR\QGroundControl_uninstall.exe
Delete $INSTDIR\*.*
RMDir $INSTDIR
Delete "$SMPROGRAMS\QGroundcontrol\*.*"
RMDir "$SMPROGRAMS\QGroundcontrol\"
Delete "$SMPROGRAMS\QGroundControl\*.*"
RMDir "$SMPROGRAMS\QGroundControl\"
SectionEnd
Section "create Start Menu Shortcuts"
CreateDirectory "$SMPROGRAMS\QGroundcontrol"
CreateShortCut "$SMPROGRAMS\QGroundcontrol\uninstall.lnk" "$INSTDIR\QGroundcontrol_uninstall.exe" "" "$INSTDIR\QGroundcontrol_uninstall.exe" 0
CreateShortCut "$SMPROGRAMS\QGroundcontrol\QGroundcontrol.lnk" "$INSTDIR\qgroundcontrol.exe" "" "$INSTDIR\qgroundcontrol.exe" 0
CreateDirectory "$SMPROGRAMS\QGroundControl"
CreateShortCut "$SMPROGRAMS\QGroundControl\uninstall.lnk" "$INSTDIR\QGroundControl_uninstall.exe" "" "$INSTDIR\QGroundControl_uninstall.exe" 0
CreateShortCut "$SMPROGRAMS\QGroundControl\QGroundControl.lnk" "$INSTDIR\qgroundcontrol.exe" "" "$INSTDIR\qgroundcontrol.exe" 0
SectionEnd
\ No newline at end of file
......@@ -7,6 +7,7 @@
<!-- QGroundControl -->
<title>QGroundControl Google Earth View</title>
<!-- *** Replace the key below below with your own API key, available at http://code.google.com/apis/maps/signup.html *** -->
<script type="text/javascript" src="https://getfirebug.com/firebug-lite-beta.js"></script>
<script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAAwbkbZLyhsmTCWXbTcjbgbRSzHs7K5SvaUdm8ua-Xxy_-2dYwMxQMhnagaawTo7L1FE1-amhuQxIlXw"></script>
<script type="text/javascript">
google.load("earth", "1", { 'language': 'en'});
......@@ -47,8 +48,10 @@ var aircraft = [];
var attitudes = [];
var locations = [];
var trails = [];
var trail;
var lineStringPlacemark;
var trailPlacemarks = [];
var trailsVisible = [];
var trailColors = [];
//var trailPlacemarks[id];
var lineStyle;
// Aircraft class
......@@ -134,54 +137,72 @@ function createAircraft(id, type, color)
locations[id] = planeLoc;
//planeColor = color;
//createTrail(id, color);
createTrail(id, color);
console.log(color);
}
function createTrail(id, color)
{
lineStringPlacemark = ge.createPlacemark('');
trailPlacemarks[id] = ge.createPlacemark('');
// Create the placemark
// Create the LineString; set it to extend down to the ground
// and set the altitude mode
trail = ge.createLineString('');
lineStringPlacemark.setGeometry(trail);
trail.setExtrude(false);
trail.setAltitudeMode(ge.ALTITUDE_ABSOLUTE);
trails[id] = ge.createLineString('');
trailPlacemarks[id].setGeometry(trails[id]);
trails[id].setExtrude(false);
trails[id].setAltitudeMode(ge.ALTITUDE_ABSOLUTE);
// Add LineString points
//lineString.getCoordinates().pushLatLngAlt(48.754, -121.835, 700);
// Create a style and set width and color of line
lineStringPlacemark.setStyleSelector(ge.createStyle(''));
lineStyle = lineStringPlacemark.getStyleSelector().getLineStyle();
trailPlacemarks[id].setStyleSelector(ge.createStyle(''));
lineStyle = trailPlacemarks[id].getStyleSelector().getLineStyle();
lineStyle.setWidth(5);
lineStyle.getColor().set(planeColor);  // aabbggrr format
//lineStyle.getColor().set(color);
//lineStyle.getColor().set(color);  // aabbggrr format
trailColors[id] = color;
lineStyle.getColor().set('00000000');  // aabbggrr format
trailsVisible[id] = false;
// Add the feature to Earth
ge.getFeatures().appendChild(lineStringPlacemark);
//ge.getFeatures().appendChild(trailPlacemarks[id]);
}
function hideTrail(id)
{
trailsVisible[id] = false;
ge.getFeatures().removeChild(trailPlacemarks[id]);
}
function showTrail(id)
{
ge.getFeatures().appendChild(trailPlacemarks[id]);
trailsVisible[id] = true;
}
function setViewRange(dist)
{
currViewRange = dist;
}
function addTrailPosition(id, lat, lon, alt)
{
trail.setExtrude(false);
trail.setAltitudeMode(ge.ALTITUDE_ABSOLUTE);
trails[id].setExtrude(false);
trails[id].setAltitudeMode(ge.ALTITUDE_ABSOLUTE);
// Add LineString points
//lineString.getCoordinates().pushLatLngAlt(48.754, -121.835, 700);
trail.getCoordinates().pushLatLngAlt(currLat, currLon, currAlt);
trails[id].getCoordinates().pushLatLngAlt(lat, lon, alt);
// Create a style and set width and color of line
lineStringPlacemark.setStyleSelector(ge.createStyle(''));
lineStyle = lineStringPlacemark.getStyleSelector().getLineStyle();
trailPlacemarks[id].setStyleSelector(ge.createStyle(''));
lineStyle = trailPlacemarks[id].getStyleSelector().getLineStyle();
lineStyle.setWidth(5);
lineStyle.getColor().set(planeColor);  // aabbggrr format
lineStyle.getColor().set(trailColors[id]);  // aabbggrr format
//lineStyle.getColor().set(color);  // aabbggrr format
// Add the feature to Earth
ge.getFeatures().replaceChild(lineStringPlacemark, lineStringPlacemark);
if (trailsVisible[id] == true) ge.getFeatures().replaceChild(trailPlacemarks[id], trailPlacemarks[id]);
}
function initCallback(object)
......@@ -199,9 +220,6 @@ function initCallback(object)
ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
ge.getLayerRoot().enableLayerById(ge.LAYER_TREES, true);
createTrail(220, 'bb2222ff');
createAircraft(220);
initialized = true;
......
......@@ -99,9 +99,10 @@ namespace qmapcontrol
Geometry* Layer::get_Geometry(int index)
{
Geometry* geo = NULL;
if(geometrySelected)
{
return geometrySelected;
geo = geometrySelected;
}
else
{
......@@ -110,7 +111,7 @@ namespace qmapcontrol
Geometry *geometry = geometries[i];
if(geometry->name() == QString::number(index))
{
return geometry;
geo = geometry;
}
}
......@@ -124,7 +125,7 @@ namespace qmapcontrol
// }
}
return geo;
}
bool Layer::isVisible() const
......
......@@ -112,7 +112,14 @@ namespace qmapcontrol
void LayerManager::setView(const QPointF& coordinate)
{
QPoint oldMapPx = mapmiddle_px;
mapmiddle_px = layer()->mapadapter()->coordinateToDisplay(coordinate);
scroll += mapmiddle_px - oldMapPx;
zoomImageScroll+= mapmiddle_px - oldMapPx;
mapmiddle = coordinate;
//TODO: muss wegen moveTo() raus
......@@ -125,7 +132,8 @@ namespace qmapcontrol
//TODO:
// verschiebung ausrechnen
// oder immer neues offscreenimage
newOffscreenImage();
//newOffscreenImage();
moveWidgets();
}
}
......
......@@ -29,6 +29,7 @@
# $$BASEDIR/lib/openjaus/libopenJaus/include
message(Qt version $$[QT_VERSION])
message(Using Qt from $QTDIR)
release {
# DEFINES += QT_NO_DEBUG_OUTPUT
......@@ -50,6 +51,7 @@ macx {
contains( HARDWARE_PLATFORM, 9.6.0 ) || contains( HARDWARE_PLATFORM, 9.7.0 ) || contains( HARDWARE_PLATFORM, 9.8.0 ) || contains( HARDWARE_PLATFORM, 9.9.0 ) {
# x86 Mac OS X Leopard 10.5 and earlier
CONFIG += x86 cocoa phonon
CONFIG -= x86_64
message(Building for Mac OS X 32bit/Leopard 10.5 and earlier)
# Enable function-profiling with the OS X saturn tool
......
......@@ -145,13 +145,15 @@ FORMS += src/ui/MainWindow.ui \
src/ui/QGCWebView.ui \
src/ui/map3D/QGCGoogleEarthView.ui \
src/ui/map3D/QGCGoogleEarthViewWin.ui \
src/ui/map3D/QGCGoogleEarthControls.ui \
src/ui/SlugsDataSensorView.ui \
src/ui/SlugsHilSim.ui \
src/ui/SlugsPIDControl.ui \
src/ui/SlugsVideoCamControl.ui \
src/ui/SlugsPadCameraControl.ui \
src/ui/uas/QGCUnconnectedInfoWidget.ui
src/ui/uas/QGCUnconnectedInfoWidget.ui \
src/ui/designer/QGCToolWidget.ui \
src/ui/designer/QGCParamSlider.ui \
src/ui/designer/QGCActionButton.ui
INCLUDEPATH += src \
src/ui \
......@@ -166,7 +168,8 @@ INCLUDEPATH += src \
src/ui/mavlink \
src/ui/param \
src/ui/watchdog \
src/ui/map3D
src/ui/map3D \
src/ui/designer
HEADERS += src/MG.h \
src/Core.h \
......@@ -252,7 +255,11 @@ HEADERS += src/MG.h \
src/ui/SlugsPadCameraControl.h \
src/ui/QGCMainWindowAPConfigurator.h \
src/comm/MAVLinkSwarmSimulationLink.h \
src/ui/uas/QGCUnconnectedInfoWidget.h
src/ui/uas/QGCUnconnectedInfoWidget.h \
src/ui/designer/QGCToolWidget.h \
src/ui/designer/QGCParamSlider.h \
src/ui/designer/QGCActionButton.h \
src/ui/designer/QGCToolWidgetItem.h
# Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler
macx|win32-msvc2008: {
......@@ -369,7 +376,11 @@ SOURCES += src/main.cc \
src/ui/SlugsPadCameraControl.cpp \
src/ui/QGCMainWindowAPConfigurator.cc \
src/comm/MAVLinkSwarmSimulationLink.cc \
src/ui/uas/QGCUnconnectedInfoWidget.cc
src/ui/uas/QGCUnconnectedInfoWidget.cc \
src/ui/designer/QGCToolWidget.cc \
src/ui/designer/QGCParamSlider.cc \
src/ui/designer/QGCActionButton.cc \
src/ui/designer/QGCToolWidgetItem.cc
macx|win32-msvc2008: {
SOURCES += src/ui/map3D/QGCGoogleEarthView.cc
......
......@@ -122,6 +122,7 @@ Core::Core(int &argc, char* argv[]) : QApplication(argc, argv)
#endif
// MAVLinkSimulationLink* simulationLink = new MAVLinkSimulationLink(MG::DIR::getSupportFilesDirectory() + "/demo-log.txt");
MAVLinkSimulationLink* simulationLink = new MAVLinkSimulationLink(":/demo-log.txt");
simulationLink->disconnect();
//mainWindow->addLink(simulationLink);
mainWindow = MainWindow::instance();
......
......@@ -30,6 +30,7 @@ This file is part of the QGROUNDCONTROL project
*/
#include <QApplication>
#include <QSettings>
#include <QTemporaryFile>
#include "GAudioOutput.h"
#include "MG.h"
......@@ -85,10 +86,19 @@ GAudioOutput* GAudioOutput::instance()
return _instance;
}
#define QGC_GAUDIOOUTPUT_KEY QString("QGC_AUDIOOUTPUT_")
GAudioOutput::GAudioOutput(QObject* parent) : QObject(parent),
voiceIndex(0),
emergency(false)
emergency(false),
muted(false)
{
// Load settings
QSettings settings;
settings.sync();
muted = settings.value(QGC_GAUDIOOUTPUT_KEY+"muted", muted).toBool();
#ifdef Q_OS_LINUX
flite_init();
#endif
......@@ -134,13 +144,28 @@ emergency(false)
GAudioOutput::~GAudioOutput()
{
QSettings settings;
settings.setValue(QGC_GAUDIOOUTPUT_KEY+"muted", muted);
settings.sync();
#ifdef _MSC_VER2
::CoUninitialize();
#endif
}
void GAudioOutput::mute(bool mute)
{
this->muted = mute;
}
bool GAudioOutput::isMuted()
{
return this->muted;
}
bool GAudioOutput::say(QString text, int severity)
{
if (!muted)
{
// TODO Add severity filter
Q_UNUSED(severity);
bool res = false;
......@@ -183,13 +208,18 @@ bool GAudioOutput::say(QString text, int severity)
}
return res;
}
else
{
return false;
}
}
/**
* @param text This message will be played after the alert beep
*/
bool GAudioOutput::alert(QString text)
{
if (!emergency)
if (!emergency || !muted)
{
// Play alert sound
beep();
......@@ -205,19 +235,25 @@ bool GAudioOutput::alert(QString text)
void GAudioOutput::notifyPositive()
{
if (!muted)
{
// Use QFile to transform path for all OS
QFile f(QCoreApplication::applicationDirPath()+QString("/audio/double_notify.wav"));
m_media->setCurrentSource(Phonon::MediaSource(f.fileName().toStdString().c_str()));
m_media->play();
}
}
void GAudioOutput::notifyNegative()
{
if (!muted)
{
// Use QFile to transform path for all OS
QFile f(QCoreApplication::applicationDirPath()+QString("/audio/flat_notify.wav"));
m_media->setCurrentSource(Phonon::MediaSource(f.fileName().toStdString().c_str()));
m_media->play();
}
}
/**
* The emergency sound will be played continously during the emergency.
......@@ -232,7 +268,7 @@ bool GAudioOutput::startEmergency()
{
emergency = true;
// Beep immediately and then start timer
beep();
if (!muted) beep();
emergencyTimer->start(1500);
QTimer::singleShot(5000, this, SLOT(stopEmergency()));
}
......@@ -257,11 +293,14 @@ bool GAudioOutput::stopEmergency()
void GAudioOutput::beep()
{
if (!muted)
{
// Use QFile to transform path for all OS
QFile f(QCoreApplication::applicationDirPath()+QString("/audio/alert.wav"));
m_media->setCurrentSource(Phonon::MediaSource(f.fileName().toStdString().c_str()));
m_media->play();
}
}
void GAudioOutput::selectFemaleVoice()
{
......
......@@ -99,6 +99,10 @@ public slots:
void notifyPositive();
/** @brief Notify about negative event */
void notifyNegative();
/** @brief Mute/unmute sound */
void mute(bool mute);
/** @brief Get the mute state */
bool isMuted();
protected:
#ifdef Q_OS_MAC
......@@ -112,6 +116,7 @@ protected:
Phonon::AudioOutput* m_audioOutput;
bool emergency; ///< Emergency status flag
QTimer* emergencyTimer;
bool muted;
private:
GAudioOutput(QObject* parent=NULL);
~GAudioOutput();
......
......@@ -11,6 +11,7 @@ namespace QGC
const QColor colorGreen(20, 200, 20);
const QColor colorYellow(255, 255, 0);
const QColor colorDarkYellow(180, 180, 0);
const QColor colorBackground("#050508");
/** @brief Get the current ground time in microseconds */
quint64 groundTimeUsecs();
......
......@@ -42,6 +42,7 @@ along with PIXHAWK. If not, see <http://www.gnu.org/licenses/>.
class LinkInterface : public QThread {
Q_OBJECT
public:
LinkInterface(QObject* parent = 0) : QThread(parent) {}
//virtual ~LinkInterface() = 0;
/* Connection management */
......
......@@ -33,6 +33,7 @@ This file is part of the QGROUNDCONTROL project
#include <QDebug>
#include <QTime>
#include <QApplication>
#include <QMessageBox>
#include "MG.h"
#include "MAVLinkProtocol.h"
......@@ -45,6 +46,7 @@ This file is part of the QGROUNDCONTROL project
#include "ArduPilotMegaMAV.h"
#include "configuration.h"
#include "LinkManager.h"
#include "MainWindow.h"
#include <QGCMAVLink.h>
#include "QGC.h"
......@@ -141,8 +143,7 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
// of its existence, as it only then can send and receive
// it's first messages.
// FIXME Current debugging
// check if the UAS has the same id like this system
// Check if the UAS has the same id like this system
if (message.sysid == getSystemId())
{
qDebug() << "WARNING\nWARNING\nWARNING\nWARNING\nWARNING\nWARNING\nWARNING\n\n RECEIVED MESSAGE FROM THIS SYSTEM WITH ID" << message.msgid << "FROM COMPONENT" << message.compid;
......@@ -155,7 +156,26 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
// First create new UAS object
// Decode heartbeat message
mavlink_heartbeat_t heartbeat;
// Reset version field to 0
heartbeat.mavlink_version = 0;
mavlink_msg_heartbeat_decode(&message, &heartbeat);
// Check if the UAS has a different protocol version
if (heartbeat.mavlink_version != MAVLINK_VERSION)
{
// Bring up dialog to inform user
QMessageBox msgBox(MainWindow::instance());
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(tr("The MAVLink protocol version on the MAV and QGroundControl mismatch!"));
msgBox.setInformativeText(tr("It is unsafe to use different MAVLink versions. QGroundControl therefore refuses to connect to system %1, which sends MAVLink version %2 (QGroundControl uses version %3).").arg(message.sysid).arg(heartbeat.mavlink_version).arg(MAVLINK_VERSION));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
// Ignore this message and continue gracefully
continue;
}
switch (heartbeat.autopilot)
{
case MAV_AUTOPILOT_GENERIC:
......
......@@ -55,7 +55,7 @@ This file is part of the QGROUNDCONTROL project
* @param writeFile The received messages are written to that file
* @param rate The rate at which the messages are sent (in intervals of milliseconds)
**/
MAVLinkSimulationLink::MAVLinkSimulationLink(QString readFile, QString writeFile, int rate) :
MAVLinkSimulationLink::MAVLinkSimulationLink(QString readFile, QString writeFile, int rate, QObject* parent) : LinkInterface(parent),
readyBytes(0),
timeOffset(0)
{
......@@ -289,16 +289,19 @@ void MAVLinkSimulationLink::mainloop()
if (keys.value(i, "") == "Gyro_Phi")
{
rawImuValues.xgyro = d;
attitude.rollspeed = ((d-29.000)/15000.0)*2.7-2.7-2.65;
}
if (keys.value(i, "") == "Gyro_Theta")
{
rawImuValues.ygyro = d;
attitude.pitchspeed = ((d-29.000)/15000.0)*2.7-2.7-2.65;
}
if (keys.value(i, "") == "Gyro_Psi")
{
rawImuValues.zgyro = d;
attitude.yawspeed = ((d-29.000)/3000.0)*2.7-2.7-2.65;
}
#ifdef MAVLINK_ENABLED_PIXHAWK
if (keys.value(i, "") == "Pressure")
......@@ -419,6 +422,20 @@ void MAVLinkSimulationLink::mainloop()
memcpy(stream+streampointer,buffer, bufferlength);
streampointer += bufferlength;
// GLOBAL POSITION VEHICLE 2
mavlink_msg_global_position_int_pack(54, componentId, &ret, (473780.28137103+(x+0.002))*1E3, (85489.9892510421+((y/2)+0.3))*1E3, (z+570.0)*1000.0, 0*100.0, 0*100.0, 0*100.0);
bufferlength = mavlink_msg_to_send_buffer(buffer, &ret);
//add data into datastream
memcpy(stream+streampointer,buffer, bufferlength);
streampointer += bufferlength;
// // GLOBAL POSITION VEHICLE 3
// mavlink_msg_global_position_int_pack(60, componentId, &ret, (473780.28137103+(x/2+0.002))*1E3, (85489.9892510421+((y*2)+0.3))*1E3, (z+590.0)*1000.0, 0*100.0, 0*100.0, 0*100.0);
// bufferlength = mavlink_msg_to_send_buffer(buffer, &ret);
// //add data into datastream
// memcpy(stream+streampointer,buffer, bufferlength);
// streampointer += bufferlength;
static int rcCounter = 0;
if (rcCounter == 2)
{
......@@ -431,6 +448,7 @@ void MAVLinkSimulationLink::mainloop()
chan.chan6_raw = (chan.chan3_raw + chan.chan2_raw) / 2.0f;
chan.chan7_raw = (chan.chan4_raw + chan.chan2_raw) / 2.0f;
chan.chan8_raw = (chan.chan6_raw + chan.chan2_raw) / 2.0f;
chan.rssi = 100;
messageSize = mavlink_msg_rc_channels_raw_encode(systemId, componentId, &msg, &chan);
// Allocate buffer with packet data
bufferlength = mavlink_msg_to_send_buffer(buffer, &msg);
......@@ -594,6 +612,16 @@ void MAVLinkSimulationLink::mainloop()
memcpy(stream+streampointer,buffer, bufferlength);
streampointer += bufferlength;
// // HEARTBEAT VEHICLE 3
// // Pack message and get size of encoded byte string
// messageSize = mavlink_msg_heartbeat_pack(60, componentId, &msg, MAV_FIXED_WING, MAV_AUTOPILOT_PIXHAWK);
// // Allocate buffer with packet data
// bufferlength = mavlink_msg_to_send_buffer(buffer, &msg);
// //add data into datastream
// memcpy(stream+streampointer,buffer, bufferlength);
// streampointer += bufferlength;
// STATUS VEHICLE 2
mavlink_sys_status_t status2;
status2.mode = MAV_MODE_LOCKED;
......
......@@ -47,7 +47,7 @@ class MAVLinkSimulationLink : public LinkInterface
{
Q_OBJECT
public:
MAVLinkSimulationLink(QString readFile="", QString writeFile="", int rate=5);
MAVLinkSimulationLink(QString readFile="", QString writeFile="", int rate=5, QObject* parent = 0);
~MAVLinkSimulationLink();
bool isConnected();
qint64 bytesAvailable();
......@@ -128,7 +128,7 @@ protected:
void enqueue(uint8_t* stream, uint8_t* index, mavlink_message_t* msg);
static const uint8_t systemId = 220;
static const uint8_t componentId = 0;
static const uint8_t componentId = 200;
static const uint16_t version = 1000;
signals:
......
#include "MAVLinkSwarmSimulationLink.h"
MAVLinkSwarmSimulationLink::MAVLinkSwarmSimulationLink(QObject *parent) :
MAVLinkSimulationLink()
MAVLinkSwarmSimulationLink::MAVLinkSwarmSimulationLink(QString readFile, QString writeFile, int rate, QObject *parent) :
MAVLinkSimulationLink(readFile, writeFile, rate, parent)
{
}
......
......@@ -7,7 +7,7 @@ class MAVLinkSwarmSimulationLink : public MAVLinkSimulationLink
{
Q_OBJECT
public:
explicit MAVLinkSwarmSimulationLink(QObject *parent = 0);
MAVLinkSwarmSimulationLink(QString readFile="", QString writeFile="", int rate=5, QObject *parent = 0);
signals:
......
This diff is collapsed.
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL 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.
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
......@@ -58,34 +38,16 @@ SerialLink::SerialLink(QString portname, BaudRateType baudrate, FlowType flow, P
// Set unique ID and add link to the list of links
this->id = getNextLinkId();
// Load defaults from settings
QSettings settings(QGC::COMPANYNAME, QGC::APPNAME);
settings.sync();
if (settings.contains("SERIALLINK_COMM_PORT"))
{
this->porthandle = settings.value("SERIALLINK_COMM_PORT").toString();
}
// *nix (Linux, MacOS tested) serial port support
port = new QextSerialPort(porthandle, QextSerialPort::Polling);
//port = new QextSerialPort(porthandle, QextSerialPort::EventDriven);
if (settings.contains("SERIALLINK_COMM_PORT"))
{
setBaudRate(settings.value("SERIALLINK_COMM_BAUD").toInt());
setParityType(settings.value("SERIALLINK_COMM_PARITY").toInt());
setStopBitsType(settings.value("SERIALLINK_COMM_STOPBITS").toInt());
setDataBitsType(settings.value("SERIALLINK_COMM_DATABITS").toInt());
}
else
{
this->baudrate = baudrate;
this->flow = flow;
this->parity = parity;
this->dataBits = dataBits;
this->stopBits = stopBits;
this->timeout = 1; ///< The timeout controls how long the program flow should wait for new serial bytes. As we're polling, we don't want to wait at all.
}
port->setTimeout(timeout); // Timeout of 0 ms, we don't want to wait for data, we just poll again next time
port->setBaudRate(baudrate);
port->setFlowControl(flow);
......@@ -96,7 +58,7 @@ SerialLink::SerialLink(QString portname, BaudRateType baudrate, FlowType flow, P
// Set the port name
if (porthandle == "")
{
// name = tr("serial link ") + QString::number(getId()) + tr(" (unconfigured)");
// name = tr("serial link ") + QString::number(getId()) + tr(" (unconfigured)");
name = tr("Serial Link ") + QString::number(getId());
}
else
......@@ -134,6 +96,33 @@ SerialLink::~SerialLink()
port = NULL;
}
void SerialLink::loadSettings()
{
// Load defaults from settings
QSettings settings(QGC::COMPANYNAME, QGC::APPNAME);
settings.sync();
if (settings.contains("SERIALLINK_COMM_PORT"))
{
setPortName(settings.value("SERIALLINK_COMM_PORT").toString());
setBaudRateType(settings.value("SERIALLINK_COMM_BAUD").toInt());
setParityType(settings.value("SERIALLINK_COMM_PARITY").toInt());
setStopBitsType(settings.value("SERIALLINK_COMM_STOPBITS").toInt());
setDataBitsType(settings.value("SERIALLINK_COMM_DATABITS").toInt());
}
}
void SerialLink::writeSettings()
{
// Store settings
QSettings settings(QGC::COMPANYNAME, QGC::APPNAME);
settings.setValue("SERIALLINK_COMM_PORT", this->porthandle);
settings.setValue("SERIALLINK_COMM_BAUD", getBaudRateType());
settings.setValue("SERIALLINK_COMM_PARITY", getParityType());
settings.setValue("SERIALLINK_COMM_STOPBITS", getStopBitsType());
settings.setValue("SERIALLINK_COMM_DATABITS", getDataBitsType());
settings.sync();
}
/**
* @brief Runs the thread
......@@ -189,13 +178,13 @@ void SerialLink::writeBytes(const char* data, qint64 size)
// Increase write counter
bitsSentTotal += size * 8;
// int i;
// for (i=0; i<size; i++)
// {
// unsigned char v=data[i];
// int i;
// for (i=0; i<size; i++)
// {
// unsigned char v=data[i];
// //fprintf(stderr,"%02x ", v);
// }
// //fprintf(stderr,"%02x ", v);
// }
}
}
......@@ -321,18 +310,12 @@ bool SerialLink::hardwareConnect()
statisticsMutex.unlock();
bool connectionUp = isConnected();
if(connectionUp) {
if(connectionUp)
{
emit connected();
emit connected(true);
// Store settings
QSettings settings(QGC::COMPANYNAME, QGC::APPNAME);
settings.setValue("SERIALLINK_COMM_PORT", this->porthandle);
settings.setValue("SERIALLINK_COMM_BAUD", getBaudRate());
settings.setValue("SERIALLINK_COMM_PARITY", getParityType());
settings.setValue("SERIALLINK_COMM_STOPBITS", getStopBitsType());
settings.setValue("SERIALLINK_COMM_DATABITS", getDataBitsType());
settings.sync();
writeSettings();
}
return connectionUp;
......@@ -376,7 +359,8 @@ void SerialLink::setName(QString name)
qint64 SerialLink::getNominalDataRate()
{
qint64 dataRate = 0;
switch (baudrate) {
switch (baudrate)
{
case BAUD50:
dataRate = 50;
break;
......@@ -442,6 +426,13 @@ qint64 SerialLink::getNominalDataRate()
break;
case BAUD256000:
dataRate = 256000;
// Windows-specific high-end baudrates
case BAUD230400:
dataRate = 230400;
case BAUD460800:
dataRate = 460800;
case BAUD921600:
dataRate = 921600;
break;
}
return dataRate;
......@@ -543,7 +534,8 @@ bool SerialLink::setPortName(QString portName)
if(portName.trimmed().length() > 0)
{
bool reconnect = false;
if(isConnected()) {
if(isConnected())
{
disconnect();
reconnect = true;
}
......@@ -650,8 +642,17 @@ bool SerialLink::setBaudRateType(int rateIndex)
baudrate = BAUD128000;
break;
case 21:
baudrate = BAUD230400;
break;
case 22:
baudrate = BAUD256000;
break;
case 23:
baudrate = BAUD460800;
break;
case 24:
baudrate = BAUD921600;
break;
default:
// If none of the above cases matches, there must be an error
accepted = false;
......@@ -671,12 +672,14 @@ bool SerialLink::setBaudRate(int rate)
{
bool reconnect = false;
bool accepted = true; // This is changed if none of the data rates matches
if(isConnected()) {
if(isConnected())
{
disconnect();
reconnect = true;
}
switch (rate) {
switch (rate)
{
case 50:
baudrate = BAUD50;
break;
......@@ -740,9 +743,18 @@ bool SerialLink::setBaudRate(int rate)
case 128000:
baudrate = BAUD128000;
break;
case 230400:
baudrate = BAUD230400;
break;
case 256000:
baudrate = BAUD256000;
break;
case 460800:
baudrate = BAUD460800;
break;
case 921600:
baudrate = BAUD921600;
break;
default:
// If none of the above cases matches, there must be an error
accepted = false;
......@@ -765,12 +777,14 @@ bool SerialLink::setFlowType(int flow)
{
bool reconnect = false;
bool accepted = true;
if(isConnected()) {
if(isConnected())
{
disconnect();
reconnect = true;
}
switch (flow) {
switch (flow)
{
case FLOW_OFF:
this->flow = FLOW_OFF;
break;
......@@ -794,12 +808,14 @@ bool SerialLink::setParityType(int parity)
{
bool reconnect = false;
bool accepted = true;
if(isConnected()) {
if(isConnected())
{
disconnect();
reconnect = true;
}
switch (parity) {
switch (parity)
{
case PAR_NONE:
this->parity = PAR_NONE;
break;
......@@ -826,11 +842,14 @@ bool SerialLink::setParityType(int parity)
return accepted;
}
// FIXME Works not as anticipated by user!
bool SerialLink::setDataBitsType(int dataBits)
{
bool accepted = true;
switch (dataBits) {
switch (dataBits)
{
case 5:
this->dataBits = DATA_5;
break;
......@@ -858,6 +877,7 @@ bool SerialLink::setDataBitsType(int dataBits)
return accepted;
}
// FIXME WORKS NOT AS ANTICIPATED BY USER!
bool SerialLink::setStopBitsType(int stopBits)
{
bool reconnect = false;
......@@ -867,7 +887,8 @@ bool SerialLink::setStopBitsType(int stopBits)
reconnect = true;
}
switch (stopBits) {
switch (stopBits)
{
case 1:
this->stopBits = STOP_1;
break;
......
......@@ -91,6 +91,9 @@ public:
qint64 getBitsSent();
qint64 getBitsReceived();
void loadSettings();
void writeSettings();
void run();
int getLinkQuality();
......
......@@ -57,6 +57,8 @@ public slots:
virtual bool setParityType(int parity) = 0;
virtual bool setDataBitsType(int dataBits) = 0;
virtual bool setStopBitsType(int stopBits) = 0;
virtual void loadSettings() = 0;
virtual void writeSettings() = 0;
};
......
......@@ -41,7 +41,7 @@ This constructor assigns the device name to the name of the first port on the sp
See the other constructors if you need to open a different port.
*/
Posix_QextSerialPort::Posix_QextSerialPort(QextSerialBase::QueryMode mode)
: QextSerialBase()
: QextSerialBase()
{
setQueryMode(mode);
init();
......@@ -123,7 +123,7 @@ Posix_QextSerialPort::Posix_QextSerialPort(const QString & name, const PortSetti
Override the = operator.
*/
Posix_QextSerialPort& Posix_QextSerialPort::operator=(const Posix_QextSerialPort& s)
{
{
setOpenMode(s.openMode());
port = s.port;
Settings.BaudRate=s.Settings.BaudRate;
......@@ -194,7 +194,10 @@ BAUD1800.
BAUD76800 57600 76800
*BAUD115200 115200 115200
BAUD128000 128000 115200
BAUD230400 230400 115200
BAUD256000 256000 115200
BAUD460800 460800 115200
BAUD921600 921600 115200
\endverbatim
*/
void Posix_QextSerialPort::setBaudRate(BaudRateType baudRate)
......@@ -220,6 +223,9 @@ void Posix_QextSerialPort::setBaudRate(BaudRateType baudRate)
break;
case BAUD128000:
case BAUD230400:
case BAUD460800:
case BAUD921600:
case BAUD256000:
Settings.BaudRate=BAUD115200;
break;
......@@ -486,8 +492,11 @@ void Posix_QextSerialPort::setBaudRate(BaudRateType baudRate)
break;
/*256000 baud*/
case BAUD230400:
case BAUD460800:
case BAUD921600:
case BAUD256000:
TTY_WARNING("Posix_QextSerialPort: POSIX does not support 256000 baud operation. Switching to 115200 baud.");
TTY_WARNING("Posix_QextSerialPort: POSIX does not support baud rates above 115200 baud. Switching to 115200 baud.");
#ifdef CBAUD
Posix_CommConfig.c_cflag&=(~CBAUD);
Posix_CommConfig.c_cflag|=B115200;
......
......@@ -92,8 +92,11 @@ enum BaudRateType
BAUD57600,
BAUD76800, //POSIX ONLY
BAUD115200,
BAUD128000, //WINDOWS ONLY
BAUD256000 //WINDOWS ONLY
BAUD128000, // WINDOWS ONLY
BAUD230400, // WINDOWS ONLY
BAUD256000, // WINDOWS ONLY
BAUD460800, // WINDOWS ONLY
BAUD921600 // WINDOWS ONLY
};
enum DataBitsType
......
......@@ -713,6 +713,10 @@ are speeds that are usable on both Windows and POSIX.
*BAUD115200 115200 115200
BAUD128000 128000 115200
BAUD256000 256000 115200
BAUD230400 230400 115200
BAUD256000 256000 115200
BAUD460800 460800 115200
BAUD921600 921600 115200
\endverbatim
*/
void Win_QextSerialPort::setBaudRate(BaudRateType baudRate) {
......@@ -863,6 +867,21 @@ void Win_QextSerialPort::setBaudRate(BaudRateType baudRate) {
TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: POSIX does not support 256000 baud operation.");
Win_CommConfig.dcb.BaudRate=CBR_256000;
break;
/*230400 baud*/
case BAUD230400:
TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: POSIX does not support 230400 baud operation.");
Win_CommConfig.dcb.BaudRate=CBR_230400;
break;
/*460800 baud*/
case BAUD460800:
TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: POSIX does not support 460800 baud operation.");
Win_CommConfig.dcb.BaudRate=CBR_460800;
break;
/*921600 baud*/
case BAUD921600:
TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: POSIX does not support 921600 baud operation.");
Win_CommConfig.dcb.BaudRate=CBR_921600;
break;
}
SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
}
......
......@@ -5,6 +5,16 @@
#include <windows.h>
#include <QThread>
/* These baudrates work on windows, but are not part of the windows headers */
#ifndef CBR_230400
#define CBR_230400 230400
#endif
#ifndef CBR_460800
#define CBR_460800 460800
#endif
#ifndef CBR_921600
#define CBR_921600 921600
#endif
/*if all warning messages are turned off, flag portability warnings to be turned off as well*/
#ifdef _TTY_NOWARN_
......
......@@ -54,11 +54,11 @@ void ArduPilotMegaMAV::receiveMessage(LinkInterface* link, mavlink_message_t mes
{
case MAVLINK_MSG_ID_HEARTBEAT:
{
qDebug() << "ARDUPILOT RECEIVED HEARTBEAT";
//qDebug() << "ARDUPILOT RECEIVED HEARTBEAT";
break;
}
default:
qDebug() << "\nARDUPILOT RECEIVED MESSAGE WITH ID" << message.msgid;
//qDebug() << "\nARDUPILOT RECEIVED MESSAGE WITH ID" << message.msgid;
break;
}
}
......
This diff is collapsed.
......@@ -153,6 +153,8 @@ protected:
double pitch;
double yaw;
QTimer* statusTimeout; ///< Timer for various status timeouts
QMap<int, QMap<QString, float>* > parameters; ///< All parameters
bool paramsOnceRequested; ///< If the parameter list has been read at least once
/** @brief Set the current battery type */
void setBattery(BatteryType type, int cells);
......@@ -199,7 +201,7 @@ public slots:
//void requestWaypoints(); FIXME tbd
//void clearWaypointList(); FIXME tbd
void requestParameters();
/** @brief Enable the motors */
void enable_motors();
/** @brief Disable the motors */
......@@ -230,6 +232,9 @@ public slots:
/** @brief Set current mode of operation, e.g. auto or manual */
void setMode(int mode);
/** @brief Request all parameters */
void requestParameters();
/** @brief Set a system parameter */
void setParameter(int component, QString id, float value);
......@@ -238,6 +243,12 @@ public slots:
/** @brief Read parameters from permanent storage */
void readParametersFromStorage();
/** @brief Get the names of all parameters */
QList<QString> getParameterNames(int component);
/** @brief Get the ids of all components */
QList<int> getComponentIds();
void enableAllDataTransmission(int rate);
void enableRawSensorDataTransmission(int rate);
void enableExtendedSystemStatusTransmission(int rate);
......
......@@ -126,6 +126,7 @@ public:
///> Map will start from beginning when the first 20 colors are exceeded
colors.append(QColor(231,72,28));
colors.append(QColor(104,64,240));
colors.append(QColor(203,254,121));
colors.append(QColor(161,252,116));
colors.append(QColor(232,33,47));
......@@ -140,11 +141,10 @@ public:
colors.append(QColor(87,231,246));
colors.append(QColor(151,59,239));
colors.append(QColor(81,183,244));
colors.append(QColor(104,64,240));
colors.append(QColor(75,133,243));
colors.append(QColor(242,255,128));
colors.append(QColor(230,126,23));
nextColor++;
nextColor = 0;
}
return colors[nextColor++];
}
......
......@@ -104,12 +104,12 @@ QList<UASInterface*> UASManager::getUASList()
UASInterface* UASManager::getActiveUAS()
{
if(!activeUAS)
{
QMessageBox msgBox;
msgBox.setText(tr("No Micro Air Vehicle connected. Please connect one first."));
msgBox.exec();
}
// if(!activeUAS)
// {
// QMessageBox msgBox;
// msgBox.setText(tr("No Micro Air Vehicle connected. Please connect one first."));
// msgBox.exec();
// }
return activeUAS; ///< Return zero pointer if no UAS has been loaded
}
......
......@@ -394,11 +394,14 @@ void UASWaypointManager::loadWaypoints(const QString &loadFile)
void UASWaypointManager::globalAddWaypoint(Waypoint *wp)
{
// FIXME Will be removed
Q_UNUSED(wp);
}
int UASWaypointManager::globalRemoveWaypoint(quint16 seq)
{
// FIXME Will be removed
Q_UNUSED(seq);
return 0;
}
......
This diff is collapsed.
......@@ -37,6 +37,7 @@ This file is part of the QGROUNDCONTROL project
#include <QTimer>
#include <QFontDatabase>
#include <QMap>
#include <QContextMenuEvent>
#include <QPair>
#include <cmath>
......@@ -58,14 +59,31 @@ class HDDisplay : public QGraphicsView
{
Q_OBJECT
public:
HDDisplay(QStringList* plotList, QWidget *parent = 0);
HDDisplay(QStringList* plotList, QString title="", QWidget *parent = 0);
~HDDisplay();
public slots:
/** @brief Update a HDD value */
void updateValue(UASInterface* uas, QString name, double value, quint64 msec);
void updateValue(int uasId, QString name, double value, quint64 msec);
void setActiveUAS(UASInterface* uas);
/** @brief Removes a plot item by the action data */
void removeItemByAction();
/** @brief Bring up the menu to add a gauge */
void addGauge();
/** @brief Add a gauge using this spec string */
void addGauge(const QString& gauge);
/** @brief Set the title of this widget and any existing parent dock widget */
void setTitle();
/** @brief Set the number of colums via popup */
void setColumns();
/** @brief Set the number of colums */
void setColumns(int cols);
/** @brief Save the current layout and state to disk */
void saveState();
/** @brief Restore the last layout and state from disk */
void restoreState();
protected slots:
void enableGLRendering(bool enable);
//void render(QPainter* painter, const QRectF& target = QRectF(), const QRect& source = QRect(), Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio);
......@@ -73,10 +91,13 @@ protected slots:
void triggerUpdate();
protected:
void changeEvent(QEvent *e);
void paintEvent(QPaintEvent * event);
void changeEvent(QEvent* e);
void paintEvent(QPaintEvent* event);
void showEvent(QShowEvent* event);
void hideEvent(QHideEvent* event);
void contextMenuEvent(QContextMenuEvent* event);
QList<QAction*> getItemRemoveActions();
void createActions();
float refLineWidthToPen(float line);
float refToScreenX(float x);
float refToScreenY(float y);
......@@ -155,6 +176,11 @@ protected:
QStringList* acceptList; ///< Variable names to plot
quint64 lastPaintTime; ///< Last time this widget was refreshed
int columns; ///< Number of instrument columns
QAction* addGaugeAction; ///< Action adding a gauge
QAction* setTitleAction; ///< Action setting the title
QAction* setColumnsAction; ///< Action setting the number of columns
private:
Ui::HDDisplay *m_ui;
......
......@@ -46,7 +46,7 @@ This file is part of the QGROUNDCONTROL project
#include <QDebug>
HSIDisplay::HSIDisplay(QWidget *parent) :
HDDisplay(NULL, parent),
HDDisplay(NULL, "", parent),
gpsSatellites(),
satellitesUsed(0),
attXSet(0),
......
......@@ -26,6 +26,7 @@
#include "MainWindow.h"
#include "JoystickWidget.h"
#include "GAudioOutput.h"
#include "QGCToolWidget.h"
#ifdef QGC_OSG_ENABLED
#include "Q3DWidgetFactory.h"
......@@ -107,6 +108,11 @@ MainWindow::MainWindow(QWidget *parent):
// Create actions
connectCommonActions();
// Add option for custom widgets
connect(ui.actionNewCustomWidget, SIGNAL(triggered()), this, SLOT(createCustomWidget()));
// Allow to mute audio
ui.actionMuteAudioOutput->setChecked(GAudioOutput::instance()->isMuted());
connect(ui.actionMuteAudioOutput, SIGNAL(triggered(bool)), GAudioOutput::instance(), SLOT(mute(bool)));
// Set dock options
setDockOptions(AnimatedDocks | AllowTabbedDocks | AllowNestedDocks);
......@@ -201,17 +207,19 @@ void MainWindow::buildPxWidgets()
{
//FIXME: memory of acceptList will never be freed again
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");
acceptList->append("-180,roll (deg),+180");
acceptList->append("-180,pitch (deg),+180");
acceptList->append("-180,yaw (deg),+180");
acceptList->append("-500,roll V (deg/s),+500");
acceptList->append("-500,pitch V (deg/s),+500");
acceptList->append("-500,yaw V (deg/s),+500");
//FIXME: memory of acceptList2 will never be freed again
QStringList* acceptList2 = new QStringList();
acceptList2->append("Battery");
acceptList2->append("Pressure");
acceptList2->append("0,Abs pressure,65500");
acceptList2->append("-2000,Accel. X, 2000");
acceptList2->append("-2000,Accel. Y, 2000");
if (!linechartWidget)
{
......@@ -290,15 +298,15 @@ void MainWindow::buildPxWidgets()
if (!headDown1DockWidget)
{
headDown1DockWidget = new QDockWidget(tr("System Stats"), this);
headDown1DockWidget->setWidget( new HDDisplay(acceptList, this) );
headDown1DockWidget = new QDockWidget(tr("Flight Display"), this);
headDown1DockWidget->setWidget( new HDDisplay(acceptList, "Flight Display", this) );
addToToolsMenu (headDown1DockWidget, tr("Flight Display"), SLOT(showToolWidget()), MENU_HDD_1, Qt::RightDockWidgetArea);
}
if (!headDown2DockWidget)
{
headDown2DockWidget = new QDockWidget(tr("Payload Status"), this);
headDown2DockWidget->setWidget( new HDDisplay(acceptList2, this) );
headDown2DockWidget->setWidget( new HDDisplay(acceptList2, "Payload Status", this) );
addToToolsMenu (headDown2DockWidget, tr("Payload Status"), SLOT(showToolWidget()), MENU_HDD_2, Qt::RightDockWidgetArea);
}
......@@ -694,7 +702,16 @@ void MainWindow::connectCommonWidgets()
// it notifies that a waypoint global goes to do create and a map graphic too
connect(waypointsDockWidget->widget(), SIGNAL(createWaypointAtMap(QPointF)), mapWidget, SLOT(createWaypointGraphAtMap(QPointF)));
}
}
void MainWindow::createCustomWidget()
{
qDebug() << "ADDING CUSTOM WIDGET";
QGCToolWidget* tool = new QGCToolWidget(this);
QDockWidget* dock = new QDockWidget("Unnamed Tool", this);
dock->setWidget(tool);
this->addDockWidget(Qt::LeftDockWidgetArea, dock);
dock->setVisible(true);
}
void MainWindow::connectPxWidgets()
......
......@@ -140,6 +140,9 @@ public slots:
/** @brief Reload the CSS style sheet */
void reloadStylesheet();
/** @brief Add a custom tool widget */
void createCustomWidget();
void closeEvent(QCloseEvent* event);
/*
......
......@@ -46,6 +46,8 @@
<string>File</string>
</property>
<addaction name="actionJoystick_Settings"/>
<addaction name="actionNewCustomWidget"/>
<addaction name="actionMuteAudioOutput"/>
<addaction name="actionSimulate"/>
<addaction name="separator"/>
<addaction name="actionExit"/>
......@@ -108,7 +110,6 @@
<addaction name="menuPerspectives"/>
<addaction name="menuHelp"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionExit">
<property name="icon">
......@@ -430,6 +431,27 @@
<string>Pilot</string>
</property>
</action>
<action name="actionNewCustomWidget">
<property name="text">
<string>New Custom Widget</string>
</property>
</action>
<action name="actionMuteAudioOutput">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../../mavground.qrc">
<normaloff>:/images/status/audio-volume-high.svg</normaloff>
<normalon>:/images/status/audio-volume-muted.svg</normalon>
<activeon>:/images/status/audio-volume-muted.svg</activeon>
<selectedoff>:/images/status/audio-volume-high.svg</selectedoff>
<selectedon>:/images/status/audio-volume-muted.svg</selectedon>:/images/status/audio-volume-high.svg</iconset>
</property>
<property name="text">
<string>Mute Audio Output</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
......@@ -454,5 +476,3 @@
</connection>
</connections>
</ui>
This diff is collapsed.
......@@ -81,6 +81,10 @@ protected:
void wheelEvent(QWheelEvent *event);
void keyPressEvent(QKeyEvent *event);
void resizeEvent(QResizeEvent* event);
/** @brief Start widget updating */
void showEvent(QShowEvent* event);
/** @brief Stop widget updating */
void hideEvent(QHideEvent* event);
QAction* osmAction;
QAction* yahooActionMap;
......
......@@ -10,7 +10,7 @@ AirfoilServoCalibrator::AirfoilServoCalibrator(AirfoilType type, QWidget *parent
/* Add title */
QHBoxLayout *titleLayout = new QHBoxLayout();
QLabel *title;
QLabel* title;
if (type == AILERON)
{
title = new QLabel(tr("Aileron"));
......@@ -23,6 +23,10 @@ AirfoilServoCalibrator::AirfoilServoCalibrator(AirfoilType type, QWidget *parent
{
title = new QLabel(tr("Rudder"));
}
else
{
title = new QLabel(tr("Unknown"));
}
titleLayout->addWidget(title);
grid->addLayout(titleLayout, 0, 0, 1, 3, Qt::AlignHCenter);
......
......@@ -55,6 +55,9 @@ const QVector<float>& RadioCalibrationData::operator ()(int i) const
return (*data)[i];
}
// FIXME Bryan
// FIXME James
// This is not good. If it is ever used after being returned it will cause a crash
// return QVector<float>();
}
......
......@@ -84,6 +84,9 @@ void RadioCalibrationWindow::setChannelRaw(int ch, float raw)
void RadioCalibrationWindow::setChannelScaled(int ch, float normalized)
{
// FIXME James
// FIXME Bryan
// /** this expects a particular channel to function mapping
// \todo allow run-time channel mapping
// */
......
......@@ -234,6 +234,7 @@ userConfigured(false)
if(serialLink != 0)
{
serialLink->loadSettings();
this->link = serialLink;
// Setup the user interface according to link type
......
......@@ -159,11 +159,26 @@
<string>128000</string>
</property>
</item>
<item>
<property name="text">
<string>230400</string>
</property>
</item>
<item>
<property name="text">
<string>256000</string>
</property>
</item>
<item>
<property name="text">
<string>460800</string>
</property>
</item>
<item>
<property name="text">
<string>921600</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
......
......@@ -136,7 +136,9 @@ void SlugsHilSim::activeUasSet(UASInterface* uas){
}
void SlugsHilSim::processHilDatagram(const QByteArray* datagram){
void SlugsHilSim::processHilDatagram(const QByteArray* datagram)
{
#ifdef MAVLINK_ENABLED_SLUGS
unsigned char i = 0;
mavlink_message_t msg;
......@@ -144,7 +146,6 @@ void SlugsHilSim::processHilDatagram(const QByteArray* datagram){
// GPS
mavlink_gps_raw_t tmpGpsRaw;
#ifdef MAVLINK_ENABLED_SLUGS
mavlink_gps_date_time_t tmpGpsTime;
tmpGpsTime.year = datagram->at(i++);
......@@ -167,7 +168,6 @@ void SlugsHilSim::processHilDatagram(const QByteArray* datagram){
mavlink_msg_gps_date_time_encode(MG::SYSTEM::ID,MG::SYSTEM::COMPID, &msg, &tmpGpsTime);
activeUas->sendMessage(hilLink, msg);
#endif
memset(&msg, 0, sizeof(mavlink_message_t));
......@@ -180,6 +180,9 @@ void SlugsHilSim::processHilDatagram(const QByteArray* datagram){
ui->ed_1->setText(QString::number(tmpGpsRaw.hdg));
ui->ed_2->setText(QString::number(tmpGpsRaw.v));
ui->ed_3->setText(QString::number(tmpGpsRaw.eph));
#else
Q_UNUSED(datagram);
#endif
}
float SlugsHilSim::getFloatFromDatagram (const QByteArray* datagram, unsigned char * i){
......@@ -205,4 +208,5 @@ uint16_t SlugsHilSim::getUint16FromDatagram (const QByteArray* datagram, unsigne
void SlugsHilSim::linkSelected(int cbIndex){
//hilLink = linksAvailable
// FIXME Mariano
}
......@@ -640,6 +640,8 @@ void SlugsPIDControl::sendMessagePIDStatus(int PIDtype)
}
}
#else
Q_UNUSED(PIDtype);
#endif // MAVLINK_ENABLED_SLUG
}
......
......@@ -221,7 +221,8 @@ double SlugsPadCameraControl::getDistPixel(int x1, int y1, int x2, int y2)
*/
QPointF SlugsPadCameraControl::ObtenerMarcacionDistanciaPixel(double lon1, double lat1, double lon2, double lat2)
{
double cateto_opuesto,cateto_adyacente, hipotenusa, distancia, marcacion;
double cateto_opuesto,cateto_adyacente, hipotenusa, distancia;
double marcacion = 0.0;
//latitude and longitude first point
......@@ -234,7 +235,7 @@ QPointF SlugsPadCameraControl::ObtenerMarcacionDistanciaPixel(double lon1, doubl
cateto_adyacente = abs((lon1-lon2));
hipotenusa = sqrt(pow(cateto_opuesto,2) + pow(cateto_adyacente,2));
distancia = hipotenusa*60;
distancia = hipotenusa*60.0;
if ((lat1 < lat2) && (lon1 > lon2)) //primer cuadrante
......
......@@ -570,5 +570,7 @@ void WaypointList::setIsLoadFileWP()
void WaypointList::setIsReadGlobalWP(bool value)
{
// FIXME James Check this
Q_UNUSED(value);
// readGlobalWP = value;
}
#include "QGCActionButton.h"
#include "ui_QGCActionButton.h"
QGCActionButton::QGCActionButton(QWidget *parent) :
QGCToolWidgetItem(parent),
ui(new Ui::QGCActionButton)
{
ui->setupUi(this);
connect(ui->editFinishButton, SIGNAL(clicked()), this, SLOT(endEditMode()));
endEditMode();
}
QGCActionButton::~QGCActionButton()
{
delete ui;
}
void QGCActionButton::startEditMode()
{
ui->editActionComboBox->show();
ui->editActionsRefreshButton->show();
ui->editFinishButton->show();
isInEditMode = true;
}
void QGCActionButton::endEditMode()
{
ui->editActionComboBox->hide();
ui->editActionsRefreshButton->hide();
ui->editFinishButton->hide();
isInEditMode = false;
}
#ifndef QGCACTIONBUTTON_H
#define QGCACTIONBUTTON_H
#include "QGCToolWidgetItem.h"
namespace Ui {
class QGCActionButton;
}
class QGCActionButton : public QGCToolWidgetItem
{
Q_OBJECT
public:
explicit QGCActionButton(QWidget *parent = 0);
~QGCActionButton();
public slots:
void startEditMode();
void endEditMode();
private:
Ui::QGCActionButton *ui;
};
#endif // QGCACTIONBUTTON_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QGCActionButton</class>
<widget class="QWidget" name="QGCActionButton">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>111</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="nameLabel">
<property name="text">
<string>Description</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="actionButton">
<property name="text">
<string>Button name</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QComboBox" name="editActionComboBox"/>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="editActionsRefreshButton">
<property name="text">
<string>Refresh Actions</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="editFinishButton">
<property name="text">
<string>Done</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="editButtonName">
<property name="text">
<string>Button name</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLineEdit" name="editNameLabel">
<property name="text">
<string>Description</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>editButtonName</sender>
<signal>textChanged(QString)</signal>
<receiver>actionButton</receiver>
<slot>setWindowTitle(QString)</slot>
<hints>
<hint type="sourcelabel">
<x>310</x>
<y>22</y>
</hint>
<hint type="destinationlabel">
<x>310</x>
<y>55</y>
</hint>
</hints>
</connection>
<connection>
<sender>editNameLabel</sender>
<signal>textChanged(QString)</signal>
<receiver>nameLabel</receiver>
<slot>setText(QString)</slot>
<hints>
<hint type="sourcelabel">
<x>116</x>
<y>22</y>
</hint>
<hint type="destinationlabel">
<x>116</x>
<y>55</y>
</hint>
</hints>
</connection>
</connections>
</ui>
#include <QMenu>
#include <QContextMenuEvent>
#include "QGCParamSlider.h"
#include "ui_QGCParamSlider.h"
QGCParamSlider::QGCParamSlider(QWidget *parent) :
QWidget(parent),
QGCToolWidgetItem(parent),
ui(new Ui::QGCParamSlider)
{
ui->setupUi(this);
endEditMode();
connect(ui->doneButton, SIGNAL(clicked()), this, SLOT(endEditMode()));
}
QGCParamSlider::~QGCParamSlider()
......@@ -13,6 +18,36 @@ QGCParamSlider::~QGCParamSlider()
delete ui;
}
void QGCParamSlider::startEditMode()
{
ui->doneButton->show();
ui->maxLabel->show();
ui->minLabel->show();
ui->nameLineEdit->show();
ui->instructionsLabel->show();
ui->refreshParamsButton->show();
ui->selectParamComboBox->show();
ui->minSpinBox->show();
ui->maxSpinBox->show();
ui->typeComboBox->show();
isInEditMode = true;
}
void QGCParamSlider::endEditMode()
{
ui->doneButton->hide();
ui->maxLabel->hide();
ui->minLabel->hide();
ui->nameLineEdit->hide();
ui->instructionsLabel->hide();
ui->refreshParamsButton->hide();
ui->selectParamComboBox->hide();
ui->minSpinBox->hide();
ui->maxSpinBox->hide();
ui->typeComboBox->hide();
isInEditMode = false;
}
void QGCParamSlider::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
......
......@@ -2,13 +2,16 @@
#define QGCPARAMSLIDER_H
#include <QWidget>
#include <QAction>
#include <QtDesigner/QDesignerExportWidget>
#include "QGCToolWidgetItem.h"
namespace Ui {
class QGCParamSlider;
}
class QDESIGNER_WIDGET_EXPORT QGCParamSlider : public QWidget
class QGCParamSlider : public QGCToolWidgetItem
{
Q_OBJECT
......@@ -16,6 +19,10 @@ public:
explicit QGCParamSlider(QWidget *parent = 0);
~QGCParamSlider();
public slots:
void startEditMode();
void endEditMode();
protected:
void changeEvent(QEvent *e);
......
......@@ -6,41 +6,124 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>22</height>
<width>436</width>
<height>136</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>8</number>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLineEdit" name="nameLineEdit">
<property name="text">
<string>Informal Name..</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="typeComboBox">
<item>
<property name="text">
<string>Float</string>
</property>
</item>
<item>
<property name="text">
<string>Integer</string>
</property>
<property name="margin">
<number>0</number>
</item>
<item>
<property name="text">
<string>Double</string>
</property>
</item>
<item>
<property name="text">
<string>Short</string>
</property>
</item>
<item>
<property name="text">
<string>Byte/Char</string>
</property>
</item>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="minLabel">
<property name="text">
<string>Min</string>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QLabel" name="maxLabel">
<property name="text">
<string>Max</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="nameLabel">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item>
<item row="2" column="1">
<widget class="QLabel" name="valueLabel">
<property name="text">
<string>0.00</string>
</property>
</widget>
</item>
<item>
<item row="2" column="2" colspan="2">
<widget class="QDoubleSpinBox" name="minSpinBox"/>
</item>
<item row="2" column="4">
<widget class="QSlider" name="valueSlider">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="5">
<widget class="QDoubleSpinBox" name="maxSpinBox"/>
</item>
<item row="3" column="5">
<widget class="QPushButton" name="doneButton">
<property name="text">
<string>Done</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QComboBox" name="selectParamComboBox">
<item>
<property name="text">
<string>Select Parameter..</string>
</property>
</item>
</widget>
</item>
<item row="3" column="2" colspan="2">
<widget class="QPushButton" name="refreshParamsButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Refresh</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="6">
<widget class="QLabel" name="instructionsLabel">
<property name="text">
<string>Please configure the parameter slider now:</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
......
#include "QGCToolWidget.h"
#include "ui_QGCToolWidget.h"
#include <QMenu>
#include <QList>
#include <QInputDialog>
#include <QDockWidget>
#include <QContextMenuEvent>
#include "QGCParamSlider.h"
#include "QGCActionButton.h"
#include "UASManager.h"
QGCToolWidget::QGCToolWidget(QWidget *parent) :
QWidget(parent),
toolLayout(new QVBoxLayout(this)),
mav(NULL),
ui(new Ui::QGCToolWidget)
{
ui->setupUi(this);
createActions();
toolLayout->setAlignment(Qt::AlignTop);
QList<UASInterface*> systems = UASManager::instance()->getUASList();
foreach (UASInterface* uas, systems)
{
UAS* newMav = dynamic_cast<UAS*>(uas);
if (newMav)
{
addUAS(uas);
}
}
connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(addUAS(UASInterface*)));
}
QGCToolWidget::~QGCToolWidget()
{
delete ui;
}
void QGCToolWidget::addUAS(UASInterface* uas)
{
UAS* newMav = dynamic_cast<UAS*>(uas);
if (newMav)
{
// FIXME Convert to list
if (mav == NULL) mav = newMav;
}
}
void QGCToolWidget::contextMenuEvent (QContextMenuEvent* event)
{
QMenu menu(this);
menu.addAction(addParamAction);
menu.addAction(addButtonAction);
menu.addAction(setTitleAction);
menu.exec(event->globalPos());
}
void QGCToolWidget::createActions()
{
addParamAction = new QAction(tr("New &Parameter Slider"), this);
addParamAction->setStatusTip(tr("Add a parameter setting slider widget to the tool"));
connect(addParamAction, SIGNAL(triggered()), this, SLOT(addParam()));
addButtonAction = new QAction(tr("New MAV &Action Button"), this);
addButtonAction->setStatusTip(tr("Add a new action button to the tool"));
connect(addButtonAction, SIGNAL(triggered()), this, SLOT(addAction()));
setTitleAction = new QAction(tr("Set Widget Title"), this);
setTitleAction->setStatusTip(tr("Set the title caption of this tool widget"));
connect(setTitleAction, SIGNAL(triggered()), this, SLOT(setTitle()));
}
void QGCToolWidget::addParam()
{
QGCParamSlider* slider = new QGCParamSlider(this);
toolLayout->addWidget(slider);
slider->startEditMode();
}
void QGCToolWidget::addAction()
{
QGCActionButton* button = new QGCActionButton(this);
toolLayout->addWidget(button);
button->startEditMode();
}
void QGCToolWidget::setTitle()
{
QDockWidget* parent = dynamic_cast<QDockWidget*>(this->parentWidget());
if (parent)
{
bool ok;
QString text = QInputDialog::getText(this, tr("QInputDialog::getText()"),
tr("Widget title:"), QLineEdit::Normal,
parent->windowTitle(), &ok);
if (ok && !text.isEmpty())
parent->setWindowTitle(text);
}
}
#ifndef QGCTOOLWIDGET_H
#define QGCTOOLWIDGET_H
#include <QWidget>
#include <QAction>
#include <QVBoxLayout>
#include "UAS.h"
namespace Ui {
class QGCToolWidget;
}
class QGCToolWidget : public QWidget
{
Q_OBJECT
public:
explicit QGCToolWidget(QWidget *parent = 0);
~QGCToolWidget();
public slots:
void addUAS(UASInterface* uas);
protected:
QAction* addParamAction;
QAction* addButtonAction;
QAction* setTitleAction;
QVBoxLayout* toolLayout;
UAS* mav;
void contextMenuEvent(QContextMenuEvent* event);
void createActions();
protected slots:
void addParam();
void addAction();
void setTitle();
private:
Ui::QGCToolWidget *ui;
};
#endif // QGCTOOLWIDGET_H
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>Form</class>
<widget class="QWidget" name="Form" >
<property name="geometry" >
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>QGCToolWidget</class>
<widget class="QWidget" name="QGCToolWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
......@@ -12,10 +12,10 @@
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<pixmapfunction></pixmapfunction>
<pixmapfunction/>
<connections/>
</ui>
#include "QGCToolWidgetItem.h"
#include <QMenu>
#include <QContextMenuEvent>
QGCToolWidgetItem::QGCToolWidgetItem(QWidget *parent) :
QWidget(parent),
isInEditMode(false),
_component(-1)
{
startEditAction = new QAction("Edit Slider", this);
connect(startEditAction, SIGNAL(triggered()), this, SLOT(startEditMode()));
stopEditAction = new QAction("Finish Editing Slider", this);
connect(stopEditAction, SIGNAL(triggered()), this, SLOT(endEditMode()));
endEditMode();
}
QGCToolWidgetItem::~QGCToolWidgetItem()
{
delete startEditAction;
delete stopEditAction;
}
void QGCToolWidgetItem::contextMenuEvent (QContextMenuEvent* event)
{
QMenu menu(this);
if (!isInEditMode)
{
menu.addAction(startEditAction);
}
else
{
menu.addAction(stopEditAction);
}
menu.exec(event->globalPos());
}
#ifndef QGCTOOLWIDGETITEM_H
#define QGCTOOLWIDGETITEM_H
#include <QWidget>
#include <QAction>
class QGCToolWidgetItem : public QWidget
{
Q_OBJECT
public:
explicit QGCToolWidgetItem(QWidget *parent = 0);
~QGCToolWidgetItem();
int component() {return _component;}
public slots:
virtual void startEditMode() {}
virtual void endEditMode() {}
virtual void setComponent(int comp) {_component = comp;}
protected:
QAction* startEditAction;
QAction* stopEditAction;
bool isInEditMode;
int _component; ///< The MAV component (the process or device ID)
void contextMenuEvent (QContextMenuEvent* event);
};
#endif // QGCTOOLWIDGETITEM_H
......@@ -72,7 +72,7 @@ public:
public slots:
void addCurve(QString curve);
void removeCurve(QString curve);
void appendData(int sysId, QString curve, double data, quint64 usec);
void appendData(int uasId, QString curve, double data, quint64 usec);
void takeButtonClick(bool checked);
void setPlotWindowPosition(int scrollBarValue);
void setPlotWindowPosition(quint64 position);
......
......@@ -75,7 +75,7 @@ Imagery::prefetch2D(double windowWidth, double windowHeight,
return;
}
double tileResolution;
double tileResolution = 1.0;
if (currentImageryType == GOOGLE_SATELLITE ||
currentImageryType == GOOGLE_MAP)
{
......@@ -131,7 +131,7 @@ Imagery::draw2D(double windowWidth, double windowHeight,
return;
}
double tileResolution;
double tileResolution = 1.0;
if (currentImageryType == GOOGLE_SATELLITE ||
currentImageryType == GOOGLE_MAP)
{
......
......@@ -241,7 +241,7 @@ Pixhawk3DWidget::insertWaypoint(void)
{
if (uas)
{
Waypoint* wp;
Waypoint* wp = NULL;
if (frame == MAV_FRAME_GLOBAL)
{
double latitude = uas->getLatitude();
......
......@@ -59300,9 +59300,10 @@ static GLfloat normals [22155][3] = {
GLfloat textures[1][2]={{0.0f,0.0f}};
/*Material indicies*/
/*{material index,face count}*/
static int material_ref [1][2] = {
{0,77848}
};
//static int material_ref [1][2] = {
//{0,77848}
//};
void MyMaterial(GLenum mode, GLfloat * f, GLfloat alpha)
{
GLfloat d[4];
......@@ -74,26 +74,14 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) :
ui->setupUi(this);
#if (defined Q_OS_MAC)
ui->webViewLayout->addWidget(webViewMac);
connect(webViewMac, SIGNAL(loadFinished(bool)), this, SLOT(initializeGoogleEarth(bool)));
//connect(webViewMac, SIGNAL(loadFinished(bool)), this, SLOT(initializeGoogleEarth(bool)));
#endif
#ifdef _MSC_VER
ui->webViewLayout->addWidget(webViewWin);
#endif
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*)));
connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateState()));
// Follow checkbox
ui->followAirplaneCheckbox->setChecked(followCamera);
connect(ui->followAirplaneCheckbox, SIGNAL(toggled(bool)), this, SLOT(follow(bool)));
// Trail checkbox
ui->trailCheckbox->setChecked(trailEnabled);
connect(ui->trailCheckbox, SIGNAL(toggled(bool)), this, SLOT(showTrail(bool)));
// Go home
connect(ui->goHomeButton, SIGNAL(clicked()), this, SLOT(goHome()));
}
QGCGoogleEarthView::~QGCGoogleEarthView()
......@@ -102,13 +90,45 @@ QGCGoogleEarthView::~QGCGoogleEarthView()
settings.setValue(QGCGOOGLEEARTHVIEWSETTINGS + "follow", followCamera);
settings.setValue(QGCGOOGLEEARTHVIEWSETTINGS + "trail", trailEnabled);
settings.sync();
#if (defined Q_OS_MAC)
delete webViewMac;
#endif
#ifdef _MSC_VER
delete webViewWin;
#endif
delete ui;
}
/**
* @param range in centimeters
*/
void QGCGoogleEarthView::setViewRangeScaledInt(int range)
{
setViewRange(range/100.0f);
}
/**
* @param range in meters (SI-units)
*/
void QGCGoogleEarthView::setViewRange(float range)
{
javaScript(QString("setViewRange(%1);").arg(range, 0, 'f', 5));
}
void QGCGoogleEarthView::addUAS(UASInterface* uas)
{
// uasid, type, color (in aarrbbgg format)
javaScript(QString("createAircraft(%1, %2, %3);").arg(uas->getUASID()).arg(uas->getSystemType()).arg(uas->getColor().name().remove(0, 1).prepend("50")));
// uasid, type, color (in #rrbbgg format)
QString uasColor = uas->getColor().name().remove(0, 1);
// Convert to bbggrr format
QString rChannel = uasColor.mid(0, 2);
uasColor.remove(0, 2);
uasColor.prepend(rChannel);
// Set alpha value to 0x66, append JavaScript quotes ('')
uasColor.prepend("'66").append("'");
javaScript(QString("createAircraft(%1, %2, %3);").arg(uas->getUASID()).arg(uas->getSystemType()).arg(uasColor));
if (trailEnabled) javaScript(QString("showTrail(%1);").arg(uas->getUASID()));
//javaScript(QString("createAircraft(%1, %2, %3);").arg(uas->getUASID()).arg(uas->getSystemType()).arg("0"));
// Automatically receive further position updates
connect(uas, SIGNAL(globalPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateGlobalPosition(UASInterface*,double,double,double,quint64)));
......@@ -123,7 +143,7 @@ void QGCGoogleEarthView::setActiveUAS(UASInterface* uas)
}
}
void QGCGoogleEarthView::updateGlobalPosition(UASInterface* uas, double lat, double lon, double alt, quint64 usec)
void QGCGoogleEarthView::updateGlobalPosition(UASInterface* uas, double lon, double lat, double alt, quint64 usec)
{
Q_UNUSED(usec);
javaScript(QString("addTrailPosition(%1, %2, %3, %4);").arg(uas->getUASID()).arg(lat, 0, 'f', 15).arg(lon, 0, 'f', 15).arg(alt, 0, 'f', 15));
......@@ -133,12 +153,32 @@ void QGCGoogleEarthView::updateGlobalPosition(UASInterface* uas, double lat, dou
void QGCGoogleEarthView::showTrail(bool state)
{
// Check if the current trail has to be hidden
if (trailEnabled && !state)
{
QList<UASInterface*> mavs = UASManager::instance()->getUASList();
foreach (UASInterface* currMav, mavs)
{
javaScript(QString("hideTrail(%1);").arg(currMav->getUASID()));
}
}
// Check if the current trail has to be shown
if (!trailEnabled && state)
{
QList<UASInterface*> mavs = UASManager::instance()->getUASList();
foreach (UASInterface* currMav, mavs)
{
javaScript(QString("showTrail(%1);").arg(currMav->getUASID()));
}
}
trailEnabled = state;
ui->trailCheckbox->setChecked(state);
}
void QGCGoogleEarthView::showWaypoints(bool state)
{
waypointsEnabled = state;
}
void QGCGoogleEarthView::follow(bool follow)
......@@ -163,7 +203,8 @@ void QGCGoogleEarthView::setHome(double lat, double lon, double alt)
void QGCGoogleEarthView::hideEvent(QHideEvent* event)
{
Q_UNUSED(event) updateTimer->stop();
Q_UNUSED(event);
updateTimer->stop();
}
void QGCGoogleEarthView::showEvent(QShowEvent* event)
......@@ -171,14 +212,14 @@ void QGCGoogleEarthView::showEvent(QShowEvent* event)
// React only to internal (pre-display)
// events
Q_UNUSED(event)
{
// Enable widget, initialize on first run
if (!webViewInitialized)
{
#if (defined Q_OS_MAC)
webViewMac->setPage(new QGCWebPage(webViewMac));
webViewMac->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
webViewMac->load(QUrl("earth.html"));
webViewMac->load(QUrl(QCoreApplication::applicationDirPath()+"/earth.html"));
#endif
#ifdef _MSC_VER
......@@ -190,9 +231,11 @@ void QGCGoogleEarthView::showEvent(QShowEvent* event)
// Reloading the webpage, this resets Google Earth
gEarthInitialized = false;
QTimer::singleShot(2000, this, SLOT(initializeGoogleEarth()));
updateTimer->start(refreshRateMs);
QTimer::singleShot(10000, this, SLOT(initializeGoogleEarth()));
}
else
{
updateTimer->start(refreshRateMs);
}
}
......@@ -276,18 +319,39 @@ void QGCGoogleEarthView::initializeGoogleEarth()
// Move to home location
goHome();
// Set current UAS
setActiveUAS(mav);
// Add all MAVs
QList<UASInterface*> mavs = UASManager::instance()->getUASList();
foreach (UASInterface* mav, mavs)
foreach (UASInterface* currMav, mavs)
{
addUAS(mav);
addUAS(currMav);
}
// Set current UAS
setActiveUAS(UASManager::instance()->getActiveUAS());
// Add any further MAV automatically
connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(addUAS(UASInterface*)));
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*)));
// Connect UI signals/slots
// Follow checkbox
ui->followAirplaneCheckbox->setChecked(followCamera);
connect(ui->followAirplaneCheckbox, SIGNAL(toggled(bool)), this, SLOT(follow(bool)));
// Trail checkbox
ui->trailCheckbox->setChecked(trailEnabled);
connect(ui->trailCheckbox, SIGNAL(toggled(bool)), this, SLOT(showTrail(bool)));
// Go home
connect(ui->goHomeButton, SIGNAL(clicked()), this, SLOT(goHome()));
// Cam distance slider
connect(ui->camDistanceSlider, SIGNAL(valueChanged(int)), this, SLOT(setViewRangeScaledInt(int)));
setViewRangeScaledInt(ui->camDistanceSlider->value());
// Start update timer
updateTimer->start(refreshRateMs);
gEarthInitialized = true;
}
......@@ -312,15 +376,15 @@ void QGCGoogleEarthView::updateState()
// Update all MAVs
QList<UASInterface*> mavs = UASManager::instance()->getUASList();
foreach (UASInterface* mav, mavs)
foreach (UASInterface* currMav, mavs)
{
uasId = mav->getUASID();
lat = mav->getLatitude();
lon = mav->getLongitude();
alt = mav->getAltitude();
roll = mav->getRoll();
pitch = mav->getPitch();
yaw = mav->getYaw();
uasId = currMav->getUASID();
lat = currMav->getLatitude();
lon = currMav->getLongitude();
alt = currMav->getAltitude();
roll = currMav->getRoll();
pitch = currMav->getPitch();
yaw = currMav->getYaw();
javaScript(QString("setAircraftPositionAttitude(%1, %2, %3, %4, %6, %7, %8);")
.arg(uasId)
......
......@@ -81,7 +81,7 @@ public slots:
/** @brief Set the currently selected UAS */
void setActiveUAS(UASInterface* uas);
/** @brief Update the global position */
void updateGlobalPosition(UASInterface* uas, double lat, double lon, double alt, quint64 usec);
void updateGlobalPosition(UASInterface* uas, double lon, double lat, double alt, quint64 usec);
/** @brief Show the vehicle trail */
void showTrail(bool state);
/** @brief Show the waypoints */
......@@ -92,6 +92,11 @@ public slots:
void goHome();
/** @brief Set the home location */
void setHome(double lat, double lon, double alt);
/** @brief Set camera view range to aircraft in meters */
void setViewRange(float range);
/** @brief Set camera view range to aircraft in centimeters */
void setViewRangeScaledInt(int range);
/** @brief Initialize Google Earth */
void initializeGoogleEarth();
/** @brief Print a Windows exception */
......@@ -108,6 +113,7 @@ protected:
UASInterface* mav;
bool followCamera;
bool trailEnabled;
bool waypointsEnabled;
bool webViewInitialized;
bool jScriptInitialized;
bool gEarthInitialized;
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>597</width>
<width>828</width>
<height>300</height>
</rect>
</property>
......@@ -23,7 +23,7 @@
<property name="margin">
<number>2</number>
</property>
<item row="0" column="0" colspan="6">
<item row="0" column="0" colspan="10">
<layout class="QVBoxLayout" name="webViewLayout"/>
</item>
<item row="1" column="0">
......@@ -50,14 +50,14 @@
</property>
</widget>
</item>
<item row="1" column="4">
<item row="1" column="5">
<widget class="QPushButton" name="clearWPButton">
<property name="text">
<string>Clear WPs</string>
</property>
</widget>
</item>
<item row="1" column="5">
<item row="1" column="9">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -70,6 +70,49 @@
</property>
</spacer>
</item>
<item row="1" column="8">
<widget class="QSlider" name="camDistanceSlider">
<property name="minimum">
<number>30</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="value">
<number>3000</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="7">
<widget class="QLabel" name="camDistanceLabel">
<property name="text">
<string>Cam Distance</string>
</property>
</widget>
</item>
<item row="1" column="6">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="4">
<widget class="QCheckBox" name="waypointsCheckbox">
<property name="text">
<string>Waypoints</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
......
......@@ -26,7 +26,7 @@ QOSGWidget::QOSGWidget( QWidget * parent, const char * name, WindowFlags f, bool
QWidget(parent, f), _overrideTraits (overrideTraits)
{
createContext();
Q_UNUSED(name);
setAttribute(Qt::WA_PaintOnScreen);
setAttribute(Qt::WA_NoSystemBackground);
setFocusPolicy(Qt::ClickFocus);
......@@ -95,6 +95,8 @@ void QOSGWidget::createContext()
#ifndef WIN32
void QOSGWidget::destroyEvent(bool destroyWindow, bool destroySubWindows)
{
Q_UNUSED(destroyWindow);
Q_UNUSED(destroySubWindows);
_gw->getEventQueue()->closeWindow();
}
......@@ -236,7 +238,7 @@ class QViewerTimer : public QWidget
_timer.stop ();
}
virtual void paintEvent (QPaintEvent * event) { _viewer->frame(); }
virtual void paintEvent (QPaintEvent * event) { Q_UNUSED(event); _viewer->frame(); }
osg::ref_ptr <osgViewer::CompositeViewer> _viewer;
QTimer _timer;
......
......@@ -53,7 +53,9 @@ WaypointGroupNode::update(MAV_FRAME frame, UASInterface *uas)
{
if (uas)
{
double robotX, robotY, robotZ;
double robotX = 0.0;
double robotY = 0.0;
double robotZ = 0.0;
if (frame == MAV_FRAME_GLOBAL)
{
double latitude = uas->getLatitude();
......
......@@ -215,6 +215,7 @@ void UASView::hideEvent(QHideEvent* event)
void UASView::receiveHeartbeat(UASInterface* uas)
{
Q_UNUSED(uas);
QString colorstyle;
heartbeatColor = QColor(20, 200, 20);
colorstyle = colorstyle.sprintf("QGroupBox { border: 1px solid #EEEEEE; border-radius: 4px; padding: 0px; margin: 0px; background-color: #%02X%02X%02X;}",
......
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