Commit 6015f664 authored by Bryan Godbolt's avatar Bryan Godbolt

merged upstream

parents d018be5d 3ce833b4
......@@ -8,7 +8,7 @@ obj
bin/*.exe
bin/*.txt
bin/mac
*pro.user
*pro.user*
qrc_*.cpp
*.Debug
*.Release
......
......@@ -69,6 +69,7 @@ macx {
-framework SDL \
-framework CoreFoundation \
-framework ApplicationServices \
# -framework GLUT \
-lm
ICON = $$BASEDIR/images/icons/macx.icns
......@@ -107,8 +108,48 @@ linux-g++ {
LIBS += \
-L/usr/lib \
-lm \
-lflite_cmu_us_kal16 \
-lflite_usenglish \
-lflite_cmulex \
-lflite \
-lSDL \
-lSDLmain
#-lflite_cmu_us_rms \
#-lflite_cmu_us_slt \
}
linux-g++-64 {
CONFIG += debug
debug {
DESTDIR = $$BASEDIR
}
release {
DESTDIR = $$BASEDIR
}
INCLUDEPATH += /usr/include \
/usr/include/qt4/phonon
# $$BASEDIR/lib/flite/include \
# $$BASEDIR/lib/flite/lang
HARDWARE_PLATFORM = $$system(uname -a)
contains( HARDWARE_PLATFORM, x86_64 ) {
# 64-bit Linux
#LIBS += \
#-L$$BASEDIR/lib/flite/linux64
message(Building for GNU/Linux 64bit/x64)
} else {
# 32-bit Linux
#LIBS += \
#-L$$BASEDIR/lib/flite/linux32
message(Building for GNU/Linux 32bit/i386)
}
LIBS += \
-L/usr/lib \
-lm \
-lflite_cmu_us_kal16 \
-lflite_usenglish \
-lflite_cmulex \
......
......@@ -18,10 +18,9 @@ TARGET = qgroundcontrol
BASEDIR = .
BUILDDIR = build
LANGUAGE = C++
CONFIG += debug_and_release \ # console
OBJECTS_DIR \
= \
$$BUILDDIR/obj
CONFIG += debug_and_release \
console
OBJECTS_DIR = $$BUILDDIR/obj
MOC_DIR = $$BUILDDIR/moc
UI_HEADERS_DIR = src/ui/generated
......@@ -56,7 +55,7 @@ FORMS += src/ui/MainWindow.ui \
src/ui/UASControl.ui \
src/ui/UASList.ui \
src/ui/UASInfo.ui \
src/ui/LineChart.ui \
src/ui/Linechart.ui \
src/ui/UASView.ui \
src/ui/ParameterInterface.ui \
src/ui/WaypointList.ui \
......@@ -90,7 +89,8 @@ INCLUDEPATH += src \
src/lib/qmapcontrol \
src/ui/mavlink \
src/ui/param \
src/ui/watchdog
src/ui/watchdog \
src/ui/map3D
HEADERS += src/MG.h \
src/Core.h \
src/uas/UASInterface.h \
......@@ -158,7 +158,6 @@ HEADERS += src/MG.h \
src/ui/linechart/IncrementalPlot.h \
src/ui/map/Waypoint2DIcon.h \
src/ui/map/MAV2DIcon.h \
src/ui/map/QGC2DIcon.h \
src/ui/QGCRemoteControlView.h \
src/WaypointGlobal.h \
src/ui/WaypointGlobalView.h \
......@@ -167,7 +166,11 @@ HEADERS += src/MG.h \
src/ui/RadioCalibration/AirfoilServoCalibrator.h \
src/ui/RadioCalibration/SwitchCalibrator.h \
src/ui/RadioCalibration/CurveCalibrator.h \
src/ui/RadioCalibration/AbstractCalibrator.h
src/ui/RadioCalibration/AbstractCalibrator.h \
src/ui/map3D/Q3DWidget.h \
src/ui/map3D/CheetahModel.h \
src/ui/map3D/CheetahGL.h \
src/ui/map3D/QMap3DWidget.h
SOURCES += src/main.cc \
src/Core.cc \
src/uas/UASManager.cc \
......@@ -230,7 +233,6 @@ SOURCES += src/main.cc \
src/ui/linechart/IncrementalPlot.cc \
src/ui/map/Waypoint2DIcon.cc \
src/ui/map/MAV2DIcon.cc \
src/ui/map/QGC2DIcon.cc \
src/ui/QGCRemoteControlView.cc \
src/WaypointGlobal.cpp \
src/ui/WaypointGlobalView.cpp \
......@@ -239,7 +241,11 @@ SOURCES += src/main.cc \
src/ui/RadioCalibration/SwitchCalibrator.cc \
src/ui/RadioCalibration/CurveCalibrator.cc \
src/ui/RadioCalibration/AbstractCalibrator.cc \
src/ui/RadioCalibration/RadioCalibrationData.cc
src/ui/RadioCalibration/RadioCalibrationData.cc \
src/ui/map3D/Q3DWidget.cc \
src/ui/map3D/CheetahModel.cc \
src/ui/map3D/CheetahGL.cc \
src/ui/map3D/QMap3DWidget.cc
RESOURCES = mavground.qrc
# Include RT-LAB Library
......
......@@ -123,8 +123,8 @@ Core::Core(int &argc, char* argv[]) : QApplication(argc, argv)
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText("Could not connect UDP port. Is an instance of " + qAppName() + "already running?");
msgBox.setInformativeText("You will not be able to receive data via UDP. Please check that you're running the right executable and then re-start " + qAppName() + ". Do you want to close the application?");
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Cancel);
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
int ret = msgBox.exec();
// Close the message box shortly after the click to prevent accidental clicks
......
......@@ -405,14 +405,14 @@ void MAVLinkSimulationLink::mainloop()
streampointer += bufferlength;
// GPS RAW
mavlink_msg_gps_raw_pack(systemId, componentId, &ret, 0, 3, 47.376417+x*0.001f, 8.548103+y*0.001f, z, 0, 0, 2.5f, 0.1f);
mavlink_msg_gps_raw_pack(systemId, componentId, &ret, 0, 3, 47.376417+(x*0.001), 8.548103+(y*0.001), z, 0, 0, 2.5f, 0.1f);
bufferlength = mavlink_msg_to_send_buffer(buffer, &ret);
//add data into datastream
memcpy(stream+streampointer,buffer, bufferlength);
streampointer += bufferlength;
// GLOBAL POSITION
mavlink_msg_global_position_pack(systemId, componentId, &ret, 0, 3, 47.376417+x*0.001f, 8.548103+y*0.001f, z, 0, 0);
mavlink_msg_global_position_pack(systemId, componentId, &ret, 0, 3, 47.376417+(x*0.001), 8.548103+(y*0.001), z, 0, 0);
bufferlength = mavlink_msg_to_send_buffer(buffer, &ret);
//add data into datastream
memcpy(stream+streampointer,buffer, bufferlength);
......
......@@ -57,7 +57,7 @@ class SerialLink : public SerialLinkInterface {
//Q_INTERFACES(SerialLinkInterface:LinkInterface)
public:
SerialLink(QString portname=NULL, BaudRateType baudrate=BAUD57600, FlowType flow=FLOW_OFF, ParityType parity=PAR_NONE, DataBitsType dataBits=DATA_8, StopBitsType stopBits=STOP_1);
SerialLink(QString portname = "", BaudRateType baudrate=BAUD57600, FlowType flow=FLOW_OFF, ParityType parity=PAR_NONE, DataBitsType dataBits=DATA_8, StopBitsType stopBits=STOP_1);
~SerialLink();
static const int poll_interval = SERIAL_POLL_INTERVAL; ///< Polling interval, defined in configuration.h
......
......@@ -73,6 +73,12 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(),
sendDropRate(0),
lowBattAlarm(false),
positionLock(false),
localX(0),
localY(0),
localZ(0),
roll(0),
pitch(0),
yaw(0),
statusTimeout(new QTimer(this))
{
color = UASInterface::getNextColor();
......@@ -281,6 +287,9 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
mavlink_attitude_t attitude;
mavlink_msg_attitude_decode(&message, &attitude);
quint64 time = getUnixTime(attitude.usec);
roll = attitude.roll;
pitch = attitude.pitch;
yaw = attitude.yaw;
emit valueChanged(uasId, "roll IMU", mavlink_msg_attitude_get_roll(&message), time);
emit valueChanged(uasId, "pitch IMU", mavlink_msg_attitude_get_pitch(&message), time);
emit valueChanged(uasId, "yaw IMU", mavlink_msg_attitude_get_yaw(&message), time);
......@@ -300,6 +309,9 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
mavlink_local_position_t pos;
mavlink_msg_local_position_decode(&message, &pos);
quint64 time = getUnixTime(pos.usec);
localX = pos.x;
localY = pos.y;
localZ = pos.z;
emit valueChanged(uasId, "x", pos.x, time);
emit valueChanged(uasId, "y", pos.y, time);
emit valueChanged(uasId, "z", pos.z, time);
......@@ -353,28 +365,34 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
// only accept values in a realistic range
// quint64 time = getUnixTime(pos.usec);
quint64 time = MG::TIME::getGroundTimeNow();
emit valueChanged(uasId, "lat", pos.lat, time);
emit valueChanged(uasId, "lon", pos.lon, time);
// Check for NaN
int alt = pos.alt;
if (alt != alt)
{
alt = 0;
emit textMessageReceived(uasId, message.compid, 255, "GCS ERROR: RECEIVED NaN FOR ALTITUDE");
}
emit valueChanged(uasId, "alt", pos.alt, time);
// Smaller than threshold and not NaN
if (pos.v < 1000000 && pos.v == pos.v)
{
emit valueChanged(uasId, "speed", pos.v, time);
//qDebug() << "GOT GPS RAW";
emit speedChanged(this, (double)pos.v, 0.0, 0.0, time);
}
else
if (pos.fix_type > 0)
{
emit textMessageReceived(uasId, message.compid, 255, QString("GCS ERROR: RECEIVED INVALID SPEED OF %1 m/s").arg(pos.v));
emit globalPositionChanged(this, pos.lon, pos.lat, pos.alt, time);
// Check for NaN
int alt = pos.alt;
if (alt != alt)
{
alt = 0;
emit textMessageReceived(uasId, message.compid, 255, "GCS ERROR: RECEIVED NaN FOR ALTITUDE");
}
emit valueChanged(uasId, "alt", pos.alt, time);
// Smaller than threshold and not NaN
if (pos.v < 1000000 && pos.v == pos.v)
{
emit valueChanged(uasId, "speed", pos.v, time);
//qDebug() << "GOT GPS RAW";
emit speedChanged(this, (double)pos.v, 0.0, 0.0, time);
}
else
{
emit textMessageReceived(uasId, message.compid, 255, QString("GCS ERROR: RECEIVED INVALID SPEED OF %1 m/s").arg(pos.v));
}
}
emit globalPositionChanged(this, pos.lon, pos.lat, alt, time);
}
break;
case MAVLINK_MSG_ID_GPS_STATUS:
......@@ -1159,8 +1177,8 @@ void UAS::setManualControlCommands(double roll, double pitch, double yaw, double
manualYawAngle = yaw * yawScaling;
manualThrust = thrust * thrustScaling;
if(mode == (int)MAV_MODE_MANUAL)
{
// if(mode == (int)MAV_MODE_MANUAL)
// {
#ifdef MAVLINK_ENABLED_PIXHAWK_MESSAGES
mavlink_message_t message;
mavlink_msg_manual_control_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &message, this->uasId, (float)manualRollAngle, (float)manualPitchAngle, (float)manualYawAngle, (float)manualThrust, controlRollManual, controlPitchManual, controlYawManual, controlThrustManual);
......@@ -1169,7 +1187,7 @@ void UAS::setManualControlCommands(double roll, double pitch, double yaw, double
emit attitudeThrustSetPointChanged(this, roll, pitch, yaw, thrust, MG::TIME::getGroundTimeNow());
#endif
}
// }
}
int UAS::getSystemType()
......@@ -1363,6 +1381,16 @@ void UAS::shutdown()
}
}
void UAS::setTargetPosition(float x, float y, float z, float yaw)
{
mavlink_message_t msg;
mavlink_msg_position_target_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, x, y, z, yaw);
// Send message twice to increase chance of reception
sendMessage(msg);
sendMessage(msg);
}
/**
* @return The name of this system as string in human-readable form
*/
......
......@@ -79,6 +79,15 @@ public:
/** @brief Get the links associated with this robot */
QList<LinkInterface*>* getLinks();
double getLocalX() const { return localX; };
double getLocalY() const { return localY; };
double getLocalZ() const { return localZ; };
double getRoll() const { return roll; };
double getPitch() const { return pitch; };
double getYaw() const { return yaw; };
friend class UASWaypointManager;
protected:
int uasId; ///< Unique system ID
......@@ -127,6 +136,12 @@ protected:
float sendDropRate; ///< Percentage of packets that were not received from the MAV by the GCS
bool lowBattAlarm; ///< Switch if battery is low
bool positionLock; ///< Status if position information is available or not
double localX;
double localY;
double localZ;
double roll;
double pitch;
double yaw;
QTimer* statusTimeout; ///< Timer for various status timeouts
/** @brief Set the current battery type */
......@@ -164,6 +179,9 @@ public slots:
/** @brief Shut the system cleanly down. Will shut down any onboard computers **/
void shutdown();
/** @brief Set the target position for the robot to navigate to. */
void setTargetPosition(float x, float y, float z, float yaw);
void startLowBattAlarm();
void stopLowBattAlarm();
......
......@@ -66,6 +66,14 @@ public:
/** @brief Get the status flag for the communication **/
virtual int getCommunicationStatus() const = 0;
virtual double getLocalX() const = 0;
virtual double getLocalY() const = 0;
virtual double getLocalZ() const = 0;
virtual double getRoll() const = 0;
virtual double getPitch() const = 0;
virtual double getYaw() const = 0;
/** @brief Get reference to the waypoint manager **/
virtual UASWaypointManager &getWaypointManager(void) = 0;
......@@ -171,6 +179,13 @@ public slots:
* Works only if already landed and will cleanly shut down all onboard computers.
*/
virtual void shutdown() = 0;
/** @brief Set the target position for the robot to navigate to.
* @param x x-coordinate of the target position
* @param y y-coordinate of the target position
* @param z z-coordinate of the target position
* @param yaw heading of the target position
*/
virtual void setTargetPosition(float x, float y, float z, float yaw) = 0;
/** @brief Request the list of stored waypoints from the robot */
//virtual void requestWaypoints() = 0;
/** @brief Clear all existing waypoints on the robot */
......
......@@ -100,7 +100,7 @@ HSIDisplay::HSIDisplay(QWidget *parent) :
topMargin(3.0f)
{
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*)));
refreshTimer->setInterval(60);
refreshTimer->setInterval(120);
// this->setScene(new QGraphicsScene(-metricWidth/2.0f, -metricWidth/2.0f, metricWidth, metricWidth, this));
......
......@@ -448,7 +448,7 @@ void HUD::paintText(QString text, QColor color, float fontSize, float refX, floa
QFont font("Bitstream Vera Sans");
// Enforce minimum font size of 5 pixels
int fSize = qMax(1, (int)(fontSize*scalingFactor*1.26f));
int fSize = qMax(5, (int)(fontSize*scalingFactor*1.26f));
font.setPixelSize(fSize);
QFontMetrics metrics = QFontMetrics(font);
......
......@@ -45,6 +45,7 @@ This file is part of the QGROUNDCONTROL project
#include "MainWindow.h"
#include "JoystickWidget.h"
#include "GAudioOutput.h"
#include "QMap3DWidget.h"
// FIXME Move
#include "PxQuadMAV.h"
......@@ -131,7 +132,7 @@ void MainWindow::buildWidgets()
mapWidget = new MapWidget(this);
protocolWidget = new XMLCommProtocolWidget(this);
dataplotWidget = new QGCDataPlot2D(this);
map3DWidget = new QWidget(this); // FIXME Lionel, insert visualizer here
map3DWidget = new QMap3DWidget(this);
// Dock widgets
controlDockWidget = new QDockWidget(tr("Control"), this);
......@@ -216,6 +217,7 @@ void MainWindow::arrangeCenterStack()
if (linechartWidget) centerStack->addWidget(linechartWidget);
if (protocolWidget) centerStack->addWidget(protocolWidget);
if (mapWidget) centerStack->addWidget(mapWidget);
if (map3DWidget) centerStack->addWidget(map3DWidget);
if (hudWidget) centerStack->addWidget(hudWidget);
if (dataplotWidget) centerStack->addWidget(dataplotWidget);
......@@ -655,14 +657,14 @@ void MainWindow::loadPixhawkView()
clearView();
// Engineer view, used in EMAV2009
// LINE CHART
if (linechartWidget)
// 3D map
if (map3DWidget)
{
QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
if (centerStack)
{
linechartWidget->setActive(true);
centerStack->setCurrentWidget(linechartWidget);
//map3DWidget->setActive(true);
centerStack->setCurrentWidget(map3DWidget);
}
}
......@@ -673,6 +675,18 @@ void MainWindow::loadPixhawkView()
controlDockWidget->show();
}
// HORIZONTAL SITUATION INDICATOR
if (hsiDockWidget)
{
HSIDisplay* hsi = dynamic_cast<HSIDisplay*>( hsiDockWidget->widget() );
if (hsi)
{
hsi->start();
addDockWidget(Qt::LeftDockWidgetArea, hsiDockWidget);
hsiDockWidget->show();
}
}
// UAS LIST
if (listDockWidget)
{
......@@ -694,18 +708,6 @@ void MainWindow::loadPixhawkView()
waypointsDockWidget->show();
}
// HORIZONTAL SITUATION INDICATOR
if (hsiDockWidget)
{
HSIDisplay* hsi = dynamic_cast<HSIDisplay*>( hsiDockWidget->widget() );
if (hsi)
{
hsi->start();
addDockWidget(Qt::BottomDockWidgetArea, hsiDockWidget);
hsiDockWidget->show();
}
}
// DEBUG CONSOLE
if (debugConsoleDockWidget)
{
......@@ -713,13 +715,6 @@ void MainWindow::loadPixhawkView()
debugConsoleDockWidget->show();
}
// RADIO CONTROL VIEW
if (rcViewDockWidget)
{
addDockWidget(Qt::BottomDockWidgetArea, rcViewDockWidget);
rcViewDockWidget->show();
}
// ONBOARD PARAMETERS
if (parametersDockWidget)
{
......
......@@ -63,6 +63,7 @@ This file is part of the QGROUNDCONTROL project
#include "HSIDisplay.h"
#include "QGCDataPlot2D.h"
#include "QGCRemoteControlView.h"
#include "QMap3DWidget.h"
#include "LogCompressor.h"
......@@ -160,7 +161,7 @@ protected:
QPointer<MapWidget> mapWidget;
QPointer<XMLCommProtocolWidget> protocolWidget;
QPointer<QGCDataPlot2D> dataplotWidget;
QPointer<QWidget> map3DWidget;
QPointer<QMap3DWidget> map3DWidget;
// Dock widgets
QPointer<QDockWidget> controlDockWidget;
QPointer<QDockWidget> infoDockWidget;
......
......@@ -38,7 +38,7 @@
<x>0</x>
<y>0</y>
<width>1000</width>
<height>23</height>
<height>25</height>
</rect>
</property>
<widget class="QMenu" name="menuMGround">
......@@ -113,7 +113,7 @@
<widget class="QStatusBar" name="statusBar"/>
<action name="actionExit">
<property name="icon">
<iconset>
<iconset resource="../../mavground.qrc">
<normaloff>:/images/actions/system-log-out.svg</normaloff>:/images/actions/system-log-out.svg</iconset>
</property>
<property name="text">
......@@ -123,22 +123,9 @@
<string>Ctrl+Q</string>
</property>
</action>
<action name="actionSettings">
<property name="icon">
<iconset>
<normaloff>:/images/categories/preferences-system.svg</normaloff>
<normalon>:/images/categories/preferences-system.svg</normalon>:/images/categories/preferences-system.svg</iconset>
</property>
<property name="text">
<string>Settings</string>
</property>
<property name="shortcut">
<string>Ctrl+P</string>
</property>
</action>
<action name="actionLiftoff">
<property name="icon">
<iconset>
<iconset resource="../../mavground.qrc">
<normaloff>:/images/control/launch.svg</normaloff>
<normalon>:/images/control/launch.svg</normalon>:/images/control/launch.svg</iconset>
</property>
......@@ -148,7 +135,7 @@
</action>
<action name="actionLand">
<property name="icon">
<iconset>
<iconset resource="../../mavground.qrc">
<normaloff>:/images/control/land.svg</normaloff>:/images/control/land.svg</iconset>
</property>
<property name="text">
......@@ -173,7 +160,7 @@
</action>
<action name="actionAdd_Link">
<property name="icon">
<iconset>
<iconset resource="../../mavground.qrc">
<normaloff>:/images/actions/list-add.svg</normaloff>:/images/actions/list-add.svg</iconset>
</property>
<property name="text">
......@@ -182,7 +169,7 @@
</action>
<action name="actionConfiguration">
<property name="icon">
<iconset>
<iconset resource="../../mavground.qrc">
<normaloff>:/images/categories/applications-system.svg</normaloff>:/images/categories/applications-system.svg</iconset>
</property>
<property name="text">
......@@ -194,7 +181,7 @@
</action>
<action name="actionEngineerView">
<property name="icon">
<iconset>
<iconset resource="../../mavground.qrc">
<normaloff>:/images/apps/utilities-system-monitor.svg</normaloff>:/images/apps/utilities-system-monitor.svg</iconset>
</property>
<property name="text">
......@@ -203,7 +190,7 @@
</action>
<action name="actionPilotView">
<property name="icon">
<iconset>
<iconset resource="../../mavground.qrc">
<normaloff>:/images/status/weather-overcast.svg</normaloff>:/images/status/weather-overcast.svg</iconset>
</property>
<property name="text">
......@@ -212,7 +199,7 @@
</action>
<action name="actionStyleConfig">
<property name="icon">
<iconset>
<iconset resource="../../mavground.qrc">
<normaloff>:/images/categories/applications-internet.svg</normaloff>:/images/categories/applications-internet.svg</iconset>
</property>
<property name="text">
......@@ -221,7 +208,7 @@
</action>
<action name="actionJoystickSettings">
<property name="icon">
<iconset>
<iconset resource="../../mavground.qrc">
<normaloff>:/images/devices/input-gaming.svg</normaloff>:/images/devices/input-gaming.svg</iconset>
</property>
<property name="text">
......@@ -230,7 +217,7 @@
</action>
<action name="actionOperatorView">
<property name="icon">
<iconset>
<iconset resource="../../mavground.qrc">
<normaloff>:/images/status/network-wireless-encrypted.svg</normaloff>:/images/status/network-wireless-encrypted.svg</iconset>
</property>
<property name="text">
......@@ -242,7 +229,7 @@
</action>
<action name="action3DView">
<property name="icon">
<iconset>
<iconset resource="../../mavground.qrc">
<normaloff>:/images/categories/preferences-system.svg</normaloff>:/images/categories/preferences-system.svg</iconset>
</property>
<property name="text">
......@@ -257,7 +244,7 @@
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<iconset resource="../../mavground.qrc">
<normaloff>:/images/control/launch.svg</normaloff>:/images/control/launch.svg</iconset>
</property>
<property name="text">
......@@ -269,7 +256,7 @@
</action>
<action name="actionShow_full_view">
<property name="icon">
<iconset>
<iconset resource="../../mavground.qrc">
<normaloff>:/images/status/network-transmit-receive.svg</normaloff>:/images/status/network-transmit-receive.svg</iconset>
</property>
<property name="text">
......@@ -278,7 +265,7 @@
</action>
<action name="actionShow_MAVLink_view">
<property name="icon">
<iconset>
<iconset resource="../../mavground.qrc">
<normaloff>:/images/devices/network-wired.svg</normaloff>:/images/devices/network-wired.svg</iconset>
</property>
<property name="text">
......@@ -287,7 +274,7 @@
</action>
<action name="actionOnline_documentation">
<property name="icon">
<iconset>
<iconset resource="../../mavground.qrc">
<normaloff>:/images/categories/applications-internet.svg</normaloff>:/images/categories/applications-internet.svg</iconset>
</property>
<property name="text">
......@@ -296,7 +283,7 @@
</action>
<action name="actionShow_data_analysis_view">
<property name="icon">
<iconset>
<iconset resource="../../mavground.qrc">
<normaloff>:/images/apps/utilities-system-monitor.svg</normaloff>:/images/apps/utilities-system-monitor.svg</iconset>
</property>
<property name="text">
......@@ -305,7 +292,7 @@
</action>
<action name="actionProject_Roadmap">
<property name="icon">
<iconset>
<iconset resource="../../mavground.qrc">
<normaloff>:/images/status/software-update-available.svg</normaloff>:/images/status/software-update-available.svg</iconset>
</property>
<property name="text">
......@@ -314,7 +301,7 @@
</action>
<action name="actionCredits_Developers">
<property name="icon">
<iconset>
<iconset resource="../../mavground.qrc">
<normaloff>:/images/categories/preferences-system.svg</normaloff>:/images/categories/preferences-system.svg</iconset>
</property>
<property name="text">
......@@ -323,7 +310,9 @@
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<resources>
<include location="../../mavground.qrc"/>
</resources>
<connections>
<connection>
<sender>actionExit</sender>
......
......@@ -37,6 +37,8 @@ This file is part of the QGROUNDCONTROL project
#include "ui_MapWidget.h"
#include "UASInterface.h"
#include "UASManager.h"
#include "MAV2DIcon.h"
#include "Waypoint2DIcon.h"
#include "MG.h"
......@@ -53,7 +55,7 @@ MapWidget::MapWidget(QWidget *parent) :
this->setFocusPolicy(Qt::StrongFocus);
// create MapControl
mc = new MapControl(QSize(320, 240));
mc = new qmapcontrol::MapControl(QSize(320, 240));
mc->showScale(true);
mc->showCoord(true);
mc->enablePersistentCache();
......@@ -62,21 +64,21 @@ MapWidget::MapWidget(QWidget *parent) :
// create MapAdapter to get maps from
//TileMapAdapter* osmAdapter = new TileMapAdapter("tile.openstreetmap.org", "/%1/%2/%3.png", 256, 0, 17);
MapAdapter* mapadapter_overlay = new YahooMapAdapter("us.maps3.yimg.com", "/aerial.maps.yimg.com/png?v=2.2&t=h&s=256&x=%2&y=%3&z=%1");
qmapcontrol::MapAdapter* mapadapter_overlay = new qmapcontrol::YahooMapAdapter("us.maps3.yimg.com", "/aerial.maps.yimg.com/png?v=2.2&t=h&s=256&x=%2&y=%3&z=%1");
// MAP BACKGROUND
mapadapter = new GoogleSatMapAdapter();
l = new MapLayer("Google Satellite", mapadapter);
mapadapter = new qmapcontrol::GoogleSatMapAdapter();
l = new qmapcontrol::MapLayer("Google Satellite", mapadapter);
mc->addLayer(l);
// STREET OVERLAY
overlay = new MapLayer("Overlay", mapadapter_overlay);
overlay = new qmapcontrol::MapLayer("Overlay", mapadapter_overlay);
overlay->setVisible(false);
mc->addLayer(overlay);
// WAYPOINT LAYER
// create a layer with the mapadapter and type GeometryLayer (for waypoints)
geomLayer = new GeometryLayer("Waypoints", mapadapter);
geomLayer = new qmapcontrol::GeometryLayer("Waypoints", mapadapter);
mc->addLayer(geomLayer);
//
......@@ -188,6 +190,7 @@ MapWidget::MapWidget(QWidget *parent) :
connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)),
this, SLOT(addUAS(UASInterface*)));
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(activeUASSet(UASInterface*)));
connect(mc, SIGNAL(mouseEventCoordinate(const QMouseEvent*, const QPointF)),
this, SLOT(captureMapClick(const QMouseEvent*, const QPointF)));
......@@ -208,7 +211,7 @@ MapWidget::MapWidget(QWidget *parent) :
pointPen = new QPen(QColor(0, 255,0));
pointPen->setWidth(3);
path = new LineString (wps, "UAV Path", pointPen);
path = new qmapcontrol::LineString (wps, "UAV Path", pointPen);
mc->layer("Waypoints")->addGeometry(path);
this->setVisible(false);
......@@ -224,7 +227,7 @@ void MapWidget::mapproviderSelected(QAction* action)
int zoom = mapadapter->adaptedZoom();
mc->setZoom(0);
mapadapter = new OSMMapAdapter();
mapadapter = new qmapcontrol::OSMMapAdapter();
l->setMapAdapter(mapadapter);
geomLayer->setMapAdapter(mapadapter);
......@@ -240,7 +243,7 @@ void MapWidget::mapproviderSelected(QAction* action)
int zoom = mapadapter->adaptedZoom();
mc->setZoom(0);
mapadapter = new YahooMapAdapter();
mapadapter = new qmapcontrol::YahooMapAdapter();
l->setMapAdapter(mapadapter);
geomLayer->setMapAdapter(mapadapter);
......@@ -256,7 +259,7 @@ void MapWidget::mapproviderSelected(QAction* action)
QPointF a = mc->currentCoordinate();
mc->setZoom(0);
mapadapter = new YahooMapAdapter("us.maps3.yimg.com", "/aerial.maps.yimg.com/png?v=1.7&t=a&s=256&x=%2&y=%3&z=%1");
mapadapter = new qmapcontrol::YahooMapAdapter("us.maps3.yimg.com", "/aerial.maps.yimg.com/png?v=1.7&t=a&s=256&x=%2&y=%3&z=%1");
l->setMapAdapter(mapadapter);
mc->updateRequestNew();
......@@ -267,7 +270,7 @@ void MapWidget::mapproviderSelected(QAction* action)
{
int zoom = mapadapter->adaptedZoom();
mc->setZoom(0);
mapadapter = new GoogleMapAdapter();
mapadapter = new qmapcontrol::GoogleMapAdapter();
l->setMapAdapter(mapadapter);
geomLayer->setMapAdapter(mapadapter);
......@@ -281,7 +284,7 @@ void MapWidget::mapproviderSelected(QAction* action)
{
int zoom = mapadapter->adaptedZoom();
mc->setZoom(0);
mapadapter = new GoogleSatMapAdapter();
mapadapter = new qmapcontrol::GoogleSatMapAdapter();
l->setMapAdapter(mapadapter);
geomLayer->setMapAdapter(mapadapter);
......@@ -342,10 +345,19 @@ void MapWidget::captureMapClick(const QMouseEvent* event, const QPointF coordina
str = QString("%1").arg(path->numberOfPoints());
// create the WP and set everything in the LineString to display the path
CirclePoint* tempCirclePoint = new CirclePoint(coordinate.x(), coordinate.y(), 10, str);
Waypoint2DIcon* tempCirclePoint;
if (mav)
{
tempCirclePoint = new Waypoint2DIcon(coordinate.x(), coordinate.y(), 20, str, qmapcontrol::Point::Middle, new QPen(mav->getColor()));
}
else
{
tempCirclePoint = new Waypoint2DIcon(coordinate.x(), coordinate.y(), 20, str, qmapcontrol::Point::Middle);
}
mc->layer("Waypoints")->addGeometry(tempCirclePoint);
Point* tempPoint = new Point(coordinate.x(), coordinate.y(),str);
qmapcontrol::Point* tempPoint = new qmapcontrol::Point(coordinate.x(), coordinate.y(),str);
wps.append(tempPoint);
path->addPoint(tempPoint);
......@@ -360,7 +372,7 @@ void MapWidget::captureMapClick(const QMouseEvent* event, const QPointF coordina
}
}
void MapWidget::captureGeometryClick(Geometry* geom, QPoint point){
void MapWidget::captureGeometryClick(qmapcontrol::Geometry* geom, QPoint point){
Q_UNUSED(geom);
Q_UNUSED(point);
......@@ -369,29 +381,35 @@ void MapWidget::captureGeometryClick(Geometry* geom, QPoint point){
}
void MapWidget::captureGeometryDrag(Geometry* geom, QPointF coordinate){
void MapWidget::captureGeometryDrag(qmapcontrol::Geometry* geom, QPointF coordinate){
Q_UNUSED(coordinate);
// Refresh the screen
mc->updateRequestNew();
int temp = 0;
Point* point2Find;
qmapcontrol::Point* point2Find;
point2Find = wpIndex[geom->name()];
point2Find->setCoordinate(coordinate);
point2Find = dynamic_cast <Point*> (geom);
point2Find->setCoordinate(coordinate);
if (point2Find)
{
point2Find->setCoordinate(coordinate);
// qDebug() << geom->name();
temp = geom->get_myIndex();
//qDebug() << temp;
emit sendGeometryEndDrag(coordinate,temp);
point2Find = dynamic_cast <qmapcontrol::Point*> (geom);
if (point2Find)
{
point2Find->setCoordinate(coordinate);
// qDebug() << geom->name();
temp = geom->get_myIndex();
//qDebug() << temp;
emit sendGeometryEndDrag(coordinate,temp);
}
}
}
void MapWidget::captureGeometryEndDrag(Geometry* geom, QPointF coordinate)
void MapWidget::captureGeometryEndDrag(qmapcontrol::Geometry* geom, QPointF coordinate)
{
mc->setMouseMode(qmapcontrol::MapControl::Panning);
......@@ -411,10 +429,18 @@ MapWidget::~MapWidget()
*/
void MapWidget::addUAS(UASInterface* uas)
{
mav = uas;
connect(uas, SIGNAL(globalPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateGlobalPosition(UASInterface*,double,double,double,quint64)));
}
void MapWidget::activeUASSet(UASInterface* uas)
{
if (uas)
{
mav = uas;
path->setPen(new QPen(mav->getColor()));
}
}
/**
* Updates the global position of one MAV and append the last movement to the trail
*
......@@ -446,19 +472,19 @@ void MapWidget::updateGlobalPosition(UASInterface* uas, double lat, double lon,
// Icon
QPen* pointpen = new QPen(uasColor);
CirclePoint* p = new CirclePoint(lat, lon, 10, uas->getUASName(), Point::Middle, pointpen);
MAV2DIcon* p = new MAV2DIcon(lat, lon, 20, uas->getUASName(), qmapcontrol::Point::Middle, pointpen);
uasIcons.insert(uas->getUASID(), p);
geomLayer->addGeometry(p);
// Line
// A QPen also can use transparency
QList<Point*> points;
points.append(new Point(lat, lon, QString("lat: %1 lon: %2").arg(lat, lon)));
QList<qmapcontrol::Point*> points;
points.append(new qmapcontrol::Point(lat, lon, QString("lat: %1 lon: %2").arg(lat, lon)));
QPen* linepen = new QPen(uasColor.darker());
linepen->setWidth(2);
// Add the Points and the QPen to a LineString
LineString* ls = new LineString(points, uas->getUASName(), linepen);
qmapcontrol::LineString* ls = new qmapcontrol::LineString(points, uas->getUASName(), linepen);
uasTrails.insert(uas->getUASID(), ls);
// Add the LineString to the layer
......@@ -466,10 +492,14 @@ void MapWidget::updateGlobalPosition(UASInterface* uas, double lat, double lon,
}
else
{
CirclePoint* p = uasIcons.value(uas->getUASID());
p->setCoordinate(QPointF(lat, lon));
MAV2DIcon* p = dynamic_cast<MAV2DIcon*>(uasIcons.value(uas->getUASID()));
if (p)
{
p->setCoordinate(QPointF(lat, lon));
p->setYaw(uas->getYaw());
}
// Extend trail
uasTrails.value(uas->getUASID())->addPoint(new Point(lat, lon, QString("lat: %1 lon: %2").arg(lat, lon)));
uasTrails.value(uas->getUASID())->addPoint(new qmapcontrol::Point(lat, lon, QString("lat: %1 lon: %2").arg(lat, lon)));
}
// points.append(new CirclePoint(8.275145, 50.016992, 15, "Wiesbaden-Mainz-Kastel, Johannes-Goßner-Straße", Point::Middle, pointpen));
......
......@@ -44,8 +44,6 @@ namespace Ui {
class MapWidget;
}
using namespace qmapcontrol;
/**
* @brief 2D Moving map
*
......@@ -60,6 +58,7 @@ public:
public slots:
void addUAS(UASInterface* uas);
void activeUASSet(UASInterface* uas);
void updateGlobalPosition(UASInterface* uas, double lat, double lon, double alt, quint64 usec);
void updatePosition(float time, double lat, double lon);
......@@ -86,8 +85,8 @@ protected:
QMenu* mapMenu;
QPushButton* mapButton;
MapControl* mc; ///< QMapControl widget
MapAdapter* mapadapter; ///< Adapter to load the map data
qmapcontrol::MapControl* mc; ///< QMapControl widget
qmapcontrol::MapAdapter* mapadapter; ///< Adapter to load the map data
qmapcontrol::Layer* l; ///< Current map layer (background)
qmapcontrol::Layer* overlay; ///< Street overlay (foreground)
qmapcontrol::GeometryLayer* geomLayer; ///< Layer for waypoints
......@@ -98,18 +97,18 @@ protected:
//Layer* gSatLayer;
QMap<int, CirclePoint*> uasIcons;
QMap<int, LineString*> uasTrails;
QMap<int, qmapcontrol::Point*> uasIcons;
QMap<int, qmapcontrol::LineString*> uasTrails;
UASInterface* mav;
quint64 lastUpdate;
protected slots:
void captureMapClick (const QMouseEvent* event, const QPointF coordinate);
void createPathButtonClicked(bool checked);
void captureGeometryClick(Geometry*, QPoint);
void captureGeometryClick(qmapcontrol::Geometry*, QPoint);
void mapproviderSelected(QAction* action);
void captureGeometryDrag(Geometry* geom, QPointF coordinate);
void captureGeometryEndDrag(Geometry* geom, QPointF coordinate);
void captureGeometryDrag(qmapcontrol::Geometry* geom, QPointF coordinate);
void captureGeometryEndDrag(qmapcontrol::Geometry* geom, QPointF coordinate);
......@@ -122,9 +121,9 @@ protected:
private:
Ui::MapWidget *m_ui;
QList<Point*> wps;
QHash <QString, Point*> wpIndex;
LineString* path;
QList<qmapcontrol::Point*> wps;
QHash <QString, qmapcontrol::Point*> wpIndex;
qmapcontrol::LineString* path;
QPen* pointPen;
};
......
......@@ -213,8 +213,8 @@ public:
static const int SCALE_BEST_FIT = 1;
static const int SCALE_LOGARITHMIC = 2;
static const int DEFAULT_REFRESH_RATE = 40; ///< The default refresh rate is 25 Hz / every 100 ms
static const int DEFAULT_PLOT_INTERVAL = 1000 * 15; ///< The default plot interval is 15 seconds
static const int DEFAULT_REFRESH_RATE = 50; ///< The default refresh rate is 25 Hz / every 100 ms
static const int DEFAULT_PLOT_INTERVAL = 1000 * 12; ///< The default plot interval is 15 seconds
static const int DEFAULT_SCALE_INTERVAL = 1000 * 5;
public slots:
......
......@@ -90,7 +90,7 @@ updateTimer(new QTimer())
connect(this, SIGNAL(plotWindowPositionUpdated(int)), scrollbar, SLOT(setValue(int)));
connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(setPlotWindowPosition(int)));
updateTimer->setInterval(100);
updateTimer->setInterval(300);
connect(updateTimer, SIGNAL(timeout()), this, SLOT(refresh()));
updateTimer->start();
}
......@@ -247,13 +247,13 @@ void LinechartWidget::refresh()
str.sprintf("%+.2f", activePlot->getMean(j.key()));
j.value()->setText(str);
}
QMap<QString, QLabel*>::iterator k;
for (k = curveMedians->begin(); k != curveMedians->end(); ++k)
{
// Median
str.sprintf("%+.2f", activePlot->getMedian(k.key()));
k.value()->setText(str);
}
// QMap<QString, QLabel*>::iterator k;
// for (k = curveMedians->begin(); k != curveMedians->end(); ++k)
// {
// // Median
// str.sprintf("%+.2f", activePlot->getMedian(k.key()));
// k.value()->setText(str);
// }
}
......@@ -397,11 +397,11 @@ QWidget* LinechartWidget::createCurveItem(QString curve)
curveMeans->insert(curve, mean);
horizontalLayout->addWidget(mean);
// Median
median = new QLabel(form);
value->setNum(0.00);
curveMedians->insert(curve, median);
horizontalLayout->addWidget(median);
// // Median
// median = new QLabel(form);
// value->setNum(0.00);
// curveMedians->insert(curve, median);
// horizontalLayout->addWidget(median);
/* Color picker
QColor color = QColorDialog::getColor(Qt::green, this);
......@@ -418,7 +418,7 @@ QWidget* LinechartWidget::createCurveItem(QString curve)
horizontalLayout->setStretchFactor(label, 80);
horizontalLayout->setStretchFactor(value, 50);
horizontalLayout->setStretchFactor(mean, 50);
horizontalLayout->setStretchFactor(median, 50);
// horizontalLayout->setStretchFactor(median, 50);
// Connect actions
QObject::connect(checkBox, SIGNAL(clicked(bool)), this, SLOT(takeButtonClick(bool)));
......
#include "MAV2DIcon.h"
#include <QPainter>
MAV2DIcon::MAV2DIcon(QGraphicsItem* parent) :
QGC2DIcon(parent)
MAV2DIcon::MAV2DIcon(qreal x, qreal y, int radius, QString name, Alignment alignment, QPen* pen)
: Point(x, y, name, alignment),
yaw(0.0f)
{
size = QSize(radius, radius);
drawIcon(pen);
}
/**
* @return the bounding rectangle of the icon
*/
QRectF MAV2DIcon::boundingRect() const
MAV2DIcon::MAV2DIcon(qreal x, qreal y, QString name, Alignment alignment, QPen* pen)
: Point(x, y, name, alignment)
{
int radius = 10;
size = QSize(radius, radius);
drawIcon(pen);
}
MAV2DIcon::~MAV2DIcon()
{
delete mypixmap;
}
void MAV2DIcon::setPen(QPen* pen)
{
qreal penWidth = 1;
return QRectF(-10 - penWidth / 2, -10 - penWidth / 2,
20 + penWidth, 20 + penWidth);
mypen = pen;
drawIcon(pen);
}
/**
* @param painter QPainter to draw with
* @param option Visual style
* @param widget Parent widget
* @param yaw in radians, 0 = north, positive = clockwise
*/
void MAV2DIcon::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
void MAV2DIcon::setYaw(float yaw)
{
painter->drawRoundedRect(-10, -10, 20, 20, 5, 5);
this->yaw = yaw;
}
void MAV2DIcon::drawIcon(QPen* pen)
{
mypixmap = new QPixmap(radius+1, radius+1);
mypixmap->fill(Qt::transparent);
QPainter painter(mypixmap);
// DRAW MICRO AIR VEHICLE
QPointF p(radius/2, radius/2);
float waypointSize = radius;
QPolygonF poly(3);
// Top point
poly.replace(0, QPointF(p.x(), p.y()+waypointSize/2.0f));
// Right point
poly.replace(1, QPointF(p.x()-waypointSize/2.0f, p.y()-waypointSize/2.0f));
// Left point
poly.replace(2, QPointF(p.x()+waypointSize/2.0f, p.y() + waypointSize/2.0f));
// // Select color based on if this is the current waypoint
// if (list.at(i)->getCurrent())
// {
// color = QGC::colorCyan;//uas->getColor();
// pen.setWidthF(refLineWidthToPen(0.8f));
// }
// else
// {
// color = uas->getColor();
// pen.setWidthF(refLineWidthToPen(0.4f));
// }
//pen.setColor(color);
if (pen)
{
pen->setWidthF(2);
painter.setPen(*pen);
}
else
{
QPen pen2(Qt::yellow);
pen2.setWidth(2);
painter.setPen(pen2);
}
painter.setBrush(Qt::NoBrush);
painter.drawPolygon(poly);
}
#ifndef MAV2DICON_H
#define MAV2DICON_H
#include "QGC2DIcon.h"
#include "qmapcontrol.h"
class MAV2DIcon : public QGC2DIcon
class MAV2DIcon : public qmapcontrol::Point
{
public:
explicit MAV2DIcon(QGraphicsItem* parent = 0);
/*!
*
* @param x longitude
* @param y latitude
* @param name name of the circle point
* @param alignment alignment (Middle or TopLeft)
* @param pen QPen for drawing
*/
MAV2DIcon(qreal x, qreal y, QString name = QString(), Alignment alignment = Middle, QPen* pen=0);
//!
/*!
*
* @param x longitude
* @param y latitude
* @param radius the radius of the circle
* @param name name of the circle point
* @param alignment alignment (Middle or TopLeft)
* @param pen QPen for drawing
*/
MAV2DIcon(qreal x, qreal y, int radius = 10, QString name = QString(), Alignment alignment = Middle, QPen* pen=0);
virtual ~MAV2DIcon();
//! sets the QPen which is used for drawing the circle
/*!
* A QPen can be used to modify the look of the drawn circle
* @param pen the QPen which should be used for drawing
* @see http://doc.trolltech.com/4.3/qpen.html
*/
virtual void setPen(QPen* pen);
void setYaw(float yaw);
void drawIcon(QPen* pen);
protected:
float yaw; ///< Yaw angle of the MAV
int radius; ///< Maximum dimension of the MAV icon
QRectF boundingRect() const;
void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
};
......
#include "QGC2DIcon.h"
QGC2DIcon::QGC2DIcon(QPointF localOriginInGlobalCoords, bool onlyLocal, QGraphicsItem* parent) :
QGraphicsItem(parent),
localOriginInGlobalCoords(localOriginInGlobalCoords),
local(onlyLocal)
{
}
QGC2DIcon::QGC2DIcon(bool onlyLocal, QGraphicsItem* parent) :
QGraphicsItem(parent),
localOriginInGlobalCoords(QPointF(0, 0)),
local(onlyLocal)
{
}
QGC2DIcon::QGC2DIcon(QGraphicsItem* parent) :
QGraphicsItem(parent),
localOriginInGlobalCoords(QPointF(0, 0)),
local(false)
{
}
QGC2DIcon::~QGC2DIcon()
{
}
QPointF QGC2DIcon::getGlobalPosition()
{
}
QPointF QGC2DIcon::getLocalPosition()
{
}
void QGC2DIcon::setGlobalPosition(QPointF pos)
{
}
void QGC2DIcon::setLocalPosition(QPointF pos)
{
}
void QGC2DIcon::setLocalPosition(float x, float y)
{
}
bool QGC2DIcon::isLocal()
{
return local;
}
#ifndef QGC2DICON_H
#define QGC2DICON_H
#include <QGraphicsItem>
#include <QPointF>
class QGC2DIcon : public QGraphicsItem
{
public:
QGC2DIcon(QPointF localOriginInGlobalCoords, bool onlyLocal=false, QGraphicsItem* parent = 0);
QGC2DIcon(bool onlyLocal=false, QGraphicsItem* parent = 0);
explicit QGC2DIcon(QGraphicsItem* parent = 0);
~QGC2DIcon();
QPointF getGlobalPosition();
QPointF getLocalPosition();
void setGlobalPosition(QPointF pos);
void setLocalPosition(QPointF pos);
void setLocalPosition(float x, float y);
bool isLocal();
virtual QRectF boundingRect() const = 0;
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) = 0;
signals:
public slots:
protected:
QPointF localOriginInGlobalCoords;
QPointF globalPosition;
QPointF localPosition;
bool local;
};
#endif // QGC2DICON_H
#include "Waypoint2DIcon.h"
#include <QPainter>
#include <QDebug>
Waypoint2DIcon::Waypoint2DIcon(qreal x, qreal y, int radius, QString name, Alignment alignment, QPen* pen)
: Point(x, y, name, alignment),
yaw(0.0f),
radius(radius)
{
size = QSize(radius, radius);
drawIcon(pen);
}
Waypoint2DIcon::Waypoint2DIcon(QGraphicsItem* parent) :
QGC2DIcon(parent)
Waypoint2DIcon::Waypoint2DIcon(qreal x, qreal y, QString name, Alignment alignment, QPen* pen)
: Point(x, y, name, alignment)
{
int radius = 10;
size = QSize(radius, radius);
drawIcon(pen);
}
/**
* @return the bounding rectangle of the icon
*/
QRectF Waypoint2DIcon::boundingRect() const
Waypoint2DIcon::~Waypoint2DIcon()
{
qreal penWidth = 1;
return QRectF(-10 - penWidth / 2, -10 - penWidth / 2,
20 + penWidth, 20 + penWidth);
delete mypixmap;
}
void Waypoint2DIcon::setPen(QPen* pen)
{
mypen = pen;
drawIcon(pen);
}
/**
* @param painter QPainter to draw with
* @param option Visual style
* @param widget Parent widget
* @param yaw in radians, 0 = north, positive = clockwise
*/
void Waypoint2DIcon::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
void Waypoint2DIcon::setYaw(float yaw)
{
qDebug() << __FILE__ << __LINE__ << "DRAWING";
painter->setPen(QPen(Qt::red));
painter->drawRoundedRect(-10, -10, 20, 20, 5, 5);
this->yaw = yaw;
}
void Waypoint2DIcon::drawIcon(QPen* pen)
{
mypixmap = new QPixmap(radius+1, radius+1);
mypixmap->fill(Qt::transparent);
QPainter painter(mypixmap);
// DRAW WAYPOINT
QPointF p(radius/2, radius/2);
float waypointSize = radius;
QPolygonF poly(4);
// Top point
poly.replace(0, QPointF(p.x(), p.y()-waypointSize/2.0f));
// Right point
poly.replace(1, QPointF(p.x()+waypointSize/2.0f, p.y()));
// Bottom point
poly.replace(2, QPointF(p.x(), p.y() + waypointSize/2.0f));
poly.replace(3, QPointF(p.x() - waypointSize/2.0f, p.y()));
// // Select color based on if this is the current waypoint
// if (list.at(i)->getCurrent())
// {
// color = QGC::colorCyan;//uas->getColor();
// pen.setWidthF(refLineWidthToPen(0.8f));
// }
// else
// {
// color = uas->getColor();
// pen.setWidthF(refLineWidthToPen(0.4f));
// }
//pen.setColor(color);
if (pen)
{
pen->setWidthF(2);
painter.setPen(*pen);
}
else
{
QPen pen2(Qt::red);
pen2.setWidth(2);
painter.setPen(pen2);
}
painter.setBrush(Qt::NoBrush);
float rad = (waypointSize/2.0f) * 0.8 * (1/sqrt(2.0f));
painter.drawLine(p.x(), p.y(), p.x()+sin(yaw) * radius, p.y()-cos(yaw) * rad);
painter.drawPolygon(poly);
}
......@@ -2,16 +2,49 @@
#define WAYPOINT2DICON_H
#include <QGraphicsItem>
#include "QGC2DIcon.h"
#include "qmapcontrol.h"
class Waypoint2DIcon : public QGC2DIcon
class Waypoint2DIcon : public qmapcontrol::Point
{
public:
explicit Waypoint2DIcon(QGraphicsItem* parent = 0);
/*!
*
* @param x longitude
* @param y latitude
* @param name name of the circle point
* @param alignment alignment (Middle or TopLeft)
* @param pen QPen for drawing
*/
Waypoint2DIcon(qreal x, qreal y, QString name = QString(), Alignment alignment = Middle, QPen* pen=0);
QRectF boundingRect() const;
void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
//!
/*!
*
* @param x longitude
* @param y latitude
* @param radius the radius of the circle
* @param name name of the circle point
* @param alignment alignment (Middle or TopLeft)
* @param pen QPen for drawing
*/
Waypoint2DIcon(qreal x, qreal y, int radius = 10, QString name = QString(), Alignment alignment = Middle, QPen* pen=0);
virtual ~Waypoint2DIcon();
//! sets the QPen which is used for drawing the circle
/*!
* A QPen can be used to modify the look of the drawn circle
* @param pen the QPen which should be used for drawing
* @see http://doc.trolltech.com/4.3/qpen.html
*/
virtual void setPen(QPen* pen);
void setYaw(float yaw);
void drawIcon(QPen* pen);
protected:
float yaw; ///< Yaw angle of the MAV
int radius; ///<
};
......
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
* @brief Generates a display list which renders a Pixhawk Cheetah MAV.
*
* @author Lionel Heng <hengli@student.ethz.ch>
*
*/
#ifndef CHEETAHGL_H_
#define CHEETAHGL_H_
#if (defined __APPLE__) & (defined __MACH__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
/**
* @brief Creates a display list which renders a Pixhawk Cheetah MAV.
* @param red Red intensity of the MAV model
* @param green Green intensity of the MAV model
* @param blue Blue intensity of the MAV model
*
* @return The index of the display list.
**/
GLint generatePixhawkCheetah(float red, float green, float blue);
#endif
/*=====================================================================
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
* @brief Definition of the class CheetahModel.
*
* @author Lionel Heng <hengli@student.ethz.ch>
*
*/
#include "CheetahModel.h"
#include "CheetahGL.h"
CheetahModel::CheetahModel()
: cheetah_dl(-1)
{
}
void
CheetahModel::init(float red, float green, float blue)
{
cheetah_dl = generatePixhawkCheetah(red, green, blue);
}
void
CheetahModel::draw(void)
{
glPushMatrix();
glScalef(0.5f, 0.5f, -0.5f);
glCallList(cheetah_dl);
glPopMatrix();
}
/*=====================================================================
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
* @brief Definition of the class CheetahModel.
*
* @author Lionel Heng <hengli@student.ethz.ch>
*
*/
#ifndef CHEETAHMODEL_H_
#define CHEETAHMODEL_H_
#if (defined __APPLE__) & (defined __MACH__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
/**
* @brief Container for display list which renders the Pixhawk Cheetah MAV.
**/
class CheetahModel
{
public:
CheetahModel();
/**
* @brief Initializes the display list.
* @param red Red intensity of the MAV model
* @param green Green intensity of the MAV model
* @param blue Blue intensity of the MAV model
**/
void init(float red, float green, float blue);
/**
* @brief Executes the display list.
**/
void draw(void);
private:
GLint cheetah_dl;
};
#endif /* CHEETAHMODEL_H_ */
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
* @brief Definition of the class Q3DWidget.
*
* @author Lionel Heng <hengli@student.ethz.ch>
*
*/
#ifndef Q3DWIDGET_H_
#define Q3DWIDGET_H_
#include <inttypes.h>
#include <string>
#include <QtOpenGL>
#include <QtGui>
//class GLUquadricObj;
enum CameraState
{
IDLE = 0,
ROTATING = 1,
MOVING = 2,
ZOOMING = 3
};
struct CameraPose
{
CameraState state;
float pan, tilt, distance;
float xOffset, yOffset, zOffset;
float xOffset2D, yOffset2D, rotation2D, zoom, warpX, warpY;
};
struct CameraParams
{
float zoomSensitivity;
float rotateSensitivity;
float moveSensitivity;
float minZoomRange;
float cameraFov;
float minClipRange;
float maxClipRange;
float zoomSensitivity2D;
float rotateSensitivity2D;
float moveSensitivity2D;
};
enum MouseState
{
MOUSE_STATE_UP = 0,
MOUSE_STATE_DOWN = 1
};
typedef void (*DisplayFunc)(void *);
typedef void (*KeyboardFunc)(char, void *);
typedef void (*MouseFunc)(Qt::MouseButton, MouseState, int32_t, int32_t, void *);
typedef void (*MotionFunc)(int32_t, int32_t, void *);
/**
* @brief A base 3D widget which executes OpenGL commands.
**/
class Q3DWidget: public QGLWidget
{
Q_OBJECT
public:
explicit Q3DWidget(QWidget* parent);
~Q3DWidget();
void initialize(int32_t windowX, int32_t windowY,
int32_t windowWidth, int32_t windowHeight, float fps);
void setCameraParams(float zoomSensitivity, float rotateSensitivity,
float moveSensitivity, float minZoomRange,
float cameraFov, float minClipRange,
float maxClipRange);
void setCameraLimit(bool onoff);
void set2DCameraParams(float zoomSensitivity,
float rotateSensitivity,
float moveSensitivity);
void set3D(bool onoff);
bool is3D(void) const;
void setInitialCameraPos(float pan, float tilt, float range,
float xOffset, float yOffset, float zOffset);
void setInitial2DCameraPos(float xOffset, float yOffset,
float rotation, float zoom);
void setCameraPose(const CameraPose& cameraPose);
CameraPose getCameraPose(void) const;
void setDisplayFunc(DisplayFunc func, void* clientData);
void setKeyboardFunc(KeyboardFunc func, void* clientData);
void setMouseFunc(MouseFunc func, void* clientData);
void setMotionFunc(MotionFunc func, void* clientData);
void addTimerFunc(uint32_t msecs, void(*func)(void *),
void* clientData);
void forceRedraw(void);
void set2DWarping(float warpX, float warpY);
void recenter(void);
void recenter2D(void);
void set2DRotation(bool onoff);
void setDisplayMode2D(void);
std::pair<float,float> getPositionIn3DMode(int32_t mouseX,
int32_t mouseY);
std::pair<float,float> getPositionIn2DMode(int32_t mouseX,
int32_t mouseY);
int32_t getWindowWidth(void);
int32_t getWindowHeight(void);
int32_t getLastMouseX(void);
int32_t getLastMouseY(void);
int32_t getMouseX(void);
int32_t getMouseY(void);
private Q_SLOTS:
void userTimer(void);
protected:
void rotateCamera(float dx, float dy);
void zoomCamera(float dy);
void moveCamera(float dx, float dy);
void rotateCamera2D(float dx);
void zoomCamera2D(float dx);
void moveCamera2D(float dx, float dy);
void switchTo3DMode(void);
void setDisplayMode3D(void);
float r2d(float angle);
float d2r(float angle);
void Q3DWidget::wireSphere(double radius, int slices, int stacks);
void solidSphere(double radius, int slices, int stacks);
void wireCone(double base, double height, int slices, int stacks);
void solidCone(double base, double height, int slices, int stacks);
void drawBox(float size, GLenum type);
void wireCube(double size);
void solidCube(double size);
void doughnut(float r, float R, int nsides, int rings);
void wireTorus(double innerRadius, double outerRadius, int nsides, int rings);
void solidTorus(double innerRadius, double outerRadius, int nsides, int rings);
GLUquadricObj* quadObj;
private:
// QGLWidget events
void initializeGL(void);
void paintGL(void);
void resizeGL(int32_t width, int32_t height);
// Qt events
void keyPressEvent(QKeyEvent* event);
void mousePressEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event);
void wheelEvent(QWheelEvent *wheel);
void timerEvent(QTimerEvent* event);
void closeEvent(QCloseEvent* event);
DisplayFunc userDisplayFunc;
KeyboardFunc userKeyboardFunc;
MouseFunc userMouseFunc;
MotionFunc userMotionFunc;
void* userDisplayFuncData;
void* userKeyboardFuncData;
void* userMouseFuncData;
void* userMotionFuncData;
int32_t windowWidth, windowHeight;
float requestedFps;
CameraPose cameraPose;
int32_t lastMouseX, lastMouseY;
bool _is3D;
bool _forceRedraw;
bool allow2DRotation;
bool limitCamera;
CameraParams cameraParams;
QBasicTimer timer;
void (*timerFunc)(void *);
void* timerFuncData;
};
#endif
This diff is collapsed.
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
* @brief Definition of the class QMap3DWidget.
*
* @author Lionel Heng <hengli@student.ethz.ch>
*
*/
#ifndef QMAP3DWIDGET_H
#define QMAP3DWIDGET_H
#include <QLabel>
#include "Q3DWidget.h"
class CheetahModel;
class UASInterface;
/**
* @brief A 3D View widget which displays vehicle-centric information.
**/
class QMap3DWidget : public Q3DWidget
{
Q_OBJECT
public:
explicit QMap3DWidget(QWidget* parent);
~QMap3DWidget();
void buildLayout(void);
static void display(void* clientData);
void displayHandler(void);
static void mouse(Qt::MouseButton button, MouseState state,
int32_t x, int32_t y, void* clientData);
void mouseHandler(Qt::MouseButton button, MouseState state,
int32_t x, int32_t y);
static void timer(void* clientData);
void timerHandler(void);
double getTime(void) const;
public slots:
void setActiveUAS(UASInterface* uas);
void markTarget(void);
private slots:
void showGrid(int state);
void showTrail(int state);
void recenterCamera(void);
void toggleLockCamera(int state);
protected:
UASInterface* uas;
void paintText(QString text, QColor color, float fontSize, float refX, float refY, QPainter* painter);
private:
void drawPlatform(float roll, float pitch, float yaw);
void drawGrid(void);
void drawTrail(float x, float y, float z);
void drawTarget(float x, float y, float z);
double lastRedrawTime;
bool displayGrid;
bool displayTrail;
typedef struct
{
float x;
float y;
float z;
} Pose3D;
bool lockCamera;
Pose3D lastUnlockedPose;
bool updateLastUnlockedPose;
Pose3D camOffset;
QVarLengthArray<Pose3D, 10000> trail;
bool displayTarget;
Pose3D targetPosition;
QScopedPointer<CheetahModel> cheetahModel;
};
#endif // QMAP3DWIDGET_H
......@@ -109,7 +109,7 @@ UASView::UASView(UASInterface* uas, QWidget *parent) :
// Heartbeat fade
refreshTimer = new QTimer(this);
connect(refreshTimer, SIGNAL(timeout()), this, SLOT(refresh()));
refreshTimer->start(180);
refreshTimer->start(updateInterval);
}
UASView::~UASView()
......@@ -195,7 +195,7 @@ void UASView::receiveHeartbeat(UASInterface* uas)
m_ui->heartbeatIcon->setStyleSheet(colorstyle);
m_ui->heartbeatIcon->setAutoFillBackground(true);
refreshTimer->stop();
refreshTimer->start(100);
refreshTimer->start(updateInterval);
}
}
......@@ -330,6 +330,21 @@ void UASView::updateLoad(UASInterface* uas, double load)
void UASView::refresh()
{
//setUpdatesEnabled(false);
//setUpdatesEnabled(true);
//repaint();
static quint64 lastupdate = 0;
qDebug() << "UASVIEW update diff: " << MG::TIME::getGroundTimeNow() - lastupdate;
lastupdate = MG::TIME::getGroundTimeNow();
// FIXME
static int generalUpdateCount = 0;
if (generalUpdateCount == 4)
{
generalUpdateCount = 0;
qDebug() << "UPDATING EVERYTHING";
// State
m_ui->stateLabel->setText(state);
m_ui->statusTextLabel->setText(stateDesc);
......@@ -411,6 +426,8 @@ void UASView::refresh()
QString timeText;
timeText = timeText.sprintf("%02d:%02d:%02d", hours, min, sec);
m_ui->timeElapsedLabel->setText(timeText);
}
generalUpdateCount++;
// Fade heartbeat icon
// Make color darker
......@@ -421,6 +438,9 @@ void UASView::refresh()
heartbeatColor.red(), heartbeatColor.green(), heartbeatColor.blue());
m_ui->heartbeatIcon->setStyleSheet(colorstyle);
m_ui->heartbeatIcon->setAutoFillBackground(true);
//setUpdatesEnabled(true);
//setUpdatesEnabled(false);
}
void UASView::changeEvent(QEvent *e)
......
......@@ -99,6 +99,7 @@ protected:
float lon;
float alt;
float groundDistance;
static const int updateInterval = 300;
void mouseDoubleClickEvent (QMouseEvent * event);
......
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