Commit e0085289 authored by pixhawk's avatar pixhawk

Working on QGraphicsView-based local waypoints interface supporting...

Working on QGraphicsView-based local waypoints interface supporting drag-and-drop, commented code, fixed Google Maps interface, added mouse and SpinBox zoom to HSIWidget, fixed MAV-based coloring and stylesheets - MEGA COMMIT
parent 937caddc
......@@ -101,8 +101,46 @@ QSeparator {
QSpinBox {
min-height: 12 px;
}
min-height: 14px;
max-height: 18px;
border: 1px solid #4A4A4F;
border-radius: 5px;
}
QSpinBox::up-button {
subcontrol-origin: border;
subcontrol-position: top right; /* position at the top right corner */
border-image: url(:/images/actions/go-up.svg) 1;
border-width: 1px;
}
QSpinBox::down-button {
subcontrol-origin: border;
subcontrol-position: bottom right; /* position at the top right corner */
border-image: url(:/images/actions/go-down.svg) 1;
border-width: 1px;
}
QDoubleSpinBox {
min-height: 14px;
max-height: 18px;
border: 1px solid #4A4A4F;
border-radius: 5px;
}
QDoubleSpinBox::up-button {
subcontrol-origin: border;
subcontrol-position: top right; /* position at the top right corner */
border-image: url(:/images/actions/go-up.svg) 1;
border-width: 1px;
max-width: 5px;
}
QDoubleSpinBox::down-button {
subcontrol-origin: border;
subcontrol-position: bottom right; /* position at the top right corner */
border-image: url(:/images/actions/go-down.svg) 1;
border-width: 1px;
max-width: 5px;
}
QPushButton {
font-weight: bold;
......
......@@ -27,8 +27,7 @@
namespace qmapcontrol
{
GoogleMapAdapter::GoogleMapAdapter()
: TileMapAdapter("mt2.google.com", "/mt?n=404&x=%2&y=%3&zoom=%1", 256, 17, 0)
//: TileMapAdapter("tile.openstreetmap.org", "/%1/%2/%3.png", 256, 0, 17)
: TileMapAdapter("mt0.google.com", "/vt/lyrs=&x=%2&s=&y=%3&z=%1", 256, 0, 17)
{
}
......
......@@ -29,155 +29,155 @@
namespace qmapcontrol
{
GoogleSatMapAdapter::GoogleSatMapAdapter()
: TileMapAdapter("kh2.google.com", "/kh?n=404&v=8&t=trtqtt", 256, 0, 19)
: TileMapAdapter("khm.google.com", "/kh?v=51&x=%2&s=&y=%3&z=%1", 256, 0, 17)
{
// name = "googlesat";
numberOfTiles = pow(2, current_zoom+0.0);
coord_per_x_tile = 360. / numberOfTiles;
coord_per_y_tile = 180. / numberOfTiles;
// // name = "googlesat";
//
// numberOfTiles = pow(2, current_zoom+0.0);
// coord_per_x_tile = 360. / numberOfTiles;
// coord_per_y_tile = 180. / numberOfTiles;
}
GoogleSatMapAdapter::~GoogleSatMapAdapter()
{
}
QString GoogleSatMapAdapter::getHost() const
{
int random = qrand() % 4;
return QString("kh%1.google.com").arg(random);
}
QPoint GoogleSatMapAdapter::coordinateToDisplay(const QPointF& coordinate) const
{
//double x = ((coordinate.x()+180)*(tilesize*numberOfTiles/360));
//double y = (((coordinate.y()*-1)+90)*(tilesize*numberOfTiles/180));
qreal x = (coordinate.x()+180.) * (numberOfTiles*mytilesize)/360.; // coord to pixel!
//double y = -1*(coordinate.y()-90) * (numberOfTiles*tilesize)/180.; // coord to pixel!
qreal y = (getMercatorYCoord(coordinate.y())-M_PI) * -1 * (numberOfTiles*mytilesize)/(2*M_PI); // coord to pixel!
return QPoint(int(x), int(y));
}
QPointF GoogleSatMapAdapter::displayToCoordinate(const QPoint& point) const
{
//double lon = ((point.x()/tilesize*numberOfTiles)*360)-180;
//double lat = (((point.y()/tilesize*numberOfTiles)*180)-90)*-1;
qreal lon = (point.x()*(360.0/(numberOfTiles*mytilesize)))-180.0;
// qreal lat = -(point.y()*(180.0/(numberOfTiles*mytilesize)))+90.0;
// FIXME Looks buggy
qreal lat = getMercatorLatitude(point.y()*-1*(2*M_PI/(numberOfTiles*mytilesize)) + M_PI);
//qreal lat = lat *180./M_PI;
return QPointF(lon, lat);
}
qreal GoogleSatMapAdapter::getMercatorLatitude(qreal YCoord) const
{
//http://welcome.warnercnr.colostate.edu/class_info/nr502/lg4/projection_mathematics/converting.html
if (YCoord > M_PI) return 9999.;
if (YCoord < -M_PI) return -9999.;
qreal t = atan(exp(YCoord));
qreal res = (2.*(t))-(M_PI/2.);
return res;
}
qreal GoogleSatMapAdapter::getMercatorYCoord(qreal lati) const
{
qreal lat = lati;
// conversion degre=>radians
qreal phi = M_PI * lat / 180;
qreal res;
//double temp = Math.Tan(Math.PI / 4 - phi / 2);
//res = Math.Log(temp);
res = 0.5 * log((1 + sin(phi)) / (1 - sin(phi)));
return res;
}
void GoogleSatMapAdapter::zoom_in()
{
current_zoom+=1;
numberOfTiles = pow(2, current_zoom+0.0);
coord_per_x_tile = 360. / numberOfTiles;
coord_per_y_tile = 180. / numberOfTiles;
}
void GoogleSatMapAdapter::zoom_out()
{
current_zoom-=1;
numberOfTiles = pow(2, current_zoom+0.0);
coord_per_x_tile = 360. / numberOfTiles;
coord_per_y_tile = 180. / numberOfTiles;
}
bool GoogleSatMapAdapter::isValid(int x, int y, int z) const
{
if ((x>=0 && x < numberOfTiles) && (y>=0 && y < numberOfTiles) && z>=0)
{
return true;
}
return false;
}
QString GoogleSatMapAdapter::query(int i, int j, int z) const
{
return getQ(-180+i*coord_per_x_tile,
90-(j+1)*coord_per_y_tile, z);
}
QString GoogleSatMapAdapter::getQ(qreal longitude, qreal latitude, int zoom) const
{
qreal xmin=-180;
qreal xmax=180;
qreal ymin=-90;
qreal ymax=90;
qreal xmoy=0;
qreal ymoy=0;
QString location="t";
//Google uses a latitude divided by 2;
qreal halflat = latitude;
for (int i = 0; i < zoom; i++)
{
xmoy = (xmax + xmin) / 2;
ymoy = (ymax + ymin) / 2;
if (halflat >= ymoy) //upper part (q or r)
{
ymin = ymoy;
if (longitude < xmoy)
{ /*q*/
location+= "q";
xmax = xmoy;
}
else
{/*r*/
location+= "r";
xmin = xmoy;
}
}
else //lower part (t or s)
{
ymax = ymoy;
if (longitude < xmoy)
{ /*t*/
location+= "t";
xmax = xmoy;
}
else
{/*s*/
location+= "s";
xmin = xmoy;
}
}
}
return QString("/kh?n=404&v=24&t=%1").arg(location);
}
//
// QString GoogleSatMapAdapter::getHost() const
// {
// int random = qrand() % 4;
// return QString("kh%1.google.com").arg(random);
// }
//
// QPoint GoogleSatMapAdapter::coordinateToDisplay(const QPointF& coordinate) const
// {
// //double x = ((coordinate.x()+180)*(tilesize*numberOfTiles/360));
// //double y = (((coordinate.y()*-1)+90)*(tilesize*numberOfTiles/180));
//
// qreal x = (coordinate.x()+180.) * (numberOfTiles*mytilesize)/360.; // coord to pixel!
// //double y = -1*(coordinate.y()-90) * (numberOfTiles*tilesize)/180.; // coord to pixel!
// qreal y = (getMercatorYCoord(coordinate.y())-M_PI) * -1 * (numberOfTiles*mytilesize)/(2*M_PI); // coord to pixel!
// return QPoint(int(x), int(y));
// }
//
// QPointF GoogleSatMapAdapter::displayToCoordinate(const QPoint& point) const
// {
// //double lon = ((point.x()/tilesize*numberOfTiles)*360)-180;
// //double lat = (((point.y()/tilesize*numberOfTiles)*180)-90)*-1;
//
// qreal lon = (point.x()*(360.0/(numberOfTiles*mytilesize)))-180.0;
// // qreal lat = -(point.y()*(180.0/(numberOfTiles*mytilesize)))+90.0;
// // FIXME Looks buggy
//
// qreal lat = getMercatorLatitude(point.y()*-1*(2*M_PI/(numberOfTiles*mytilesize)) + M_PI);
// //qreal lat = lat *180./M_PI;
// return QPointF(lon, lat);
// }
//
// qreal GoogleSatMapAdapter::getMercatorLatitude(qreal YCoord) const
// {
// //http://welcome.warnercnr.colostate.edu/class_info/nr502/lg4/projection_mathematics/converting.html
// if (YCoord > M_PI) return 9999.;
// if (YCoord < -M_PI) return -9999.;
//
// qreal t = atan(exp(YCoord));
// qreal res = (2.*(t))-(M_PI/2.);
// return res;
// }
//
// qreal GoogleSatMapAdapter::getMercatorYCoord(qreal lati) const
// {
// qreal lat = lati;
//
// // conversion degre=>radians
// qreal phi = M_PI * lat / 180;
//
// qreal res;
// //double temp = Math.Tan(Math.PI / 4 - phi / 2);
// //res = Math.Log(temp);
// res = 0.5 * log((1 + sin(phi)) / (1 - sin(phi)));
//
// return res;
// }
//
// void GoogleSatMapAdapter::zoom_in()
// {
// current_zoom+=1;
// numberOfTiles = pow(2, current_zoom+0.0);
// coord_per_x_tile = 360. / numberOfTiles;
// coord_per_y_tile = 180. / numberOfTiles;
// }
//
// void GoogleSatMapAdapter::zoom_out()
// {
// current_zoom-=1;
// numberOfTiles = pow(2, current_zoom+0.0);
// coord_per_x_tile = 360. / numberOfTiles;
// coord_per_y_tile = 180. / numberOfTiles;
// }
//
// bool GoogleSatMapAdapter::isValid(int x, int y, int z) const
// {
// if ((x>=0 && x < numberOfTiles) && (y>=0 && y < numberOfTiles) && z>=0)
// {
// return true;
// }
// return false;
// }
// QString GoogleSatMapAdapter::query(int i, int j, int z) const
// {
// return getQ(-180+i*coord_per_x_tile,
// 90-(j+1)*coord_per_y_tile, z);
// }
//
// QString GoogleSatMapAdapter::getQ(qreal longitude, qreal latitude, int zoom) const
// {
// qreal xmin=-180;
// qreal xmax=180;
// qreal ymin=-90;
// qreal ymax=90;
//
// qreal xmoy=0;
// qreal ymoy=0;
// QString location="t";
//
// //Google uses a latitude divided by 2;
// qreal halflat = latitude;
//
// for (int i = 0; i < zoom; i++)
// {
// xmoy = (xmax + xmin) / 2;
// ymoy = (ymax + ymin) / 2;
// if (halflat >= ymoy) //upper part (q or r)
// {
// ymin = ymoy;
// if (longitude < xmoy)
// { /*q*/
// location+= "q";
// xmax = xmoy;
// }
// else
// {/*r*/
// location+= "r";
// xmin = xmoy;
// }
// }
// else //lower part (t or s)
// {
// ymax = ymoy;
// if (longitude < xmoy)
// { /*t*/
//
// location+= "t";
// xmax = xmoy;
// }
// else
// {/*s*/
// location+= "s";
// xmin = xmoy;
// }
// }
// }
// return QString("/kh?n=404&v=24&t=%1").arg(location);
// }
}
......@@ -44,31 +44,31 @@ namespace qmapcontrol
*/
GoogleSatMapAdapter();
virtual ~GoogleSatMapAdapter();
virtual QPoint coordinateToDisplay(const QPointF&) const;
virtual QPointF displayToCoordinate(const QPoint&) const;
//! returns the host of this MapAdapter
/*!
* @return the host of this MapAdapter
*/
QString getHost () const;
protected:
virtual void zoom_in();
virtual void zoom_out();
virtual QString query(int x, int y, int z) const;
virtual bool isValid(int x, int y, int z) const;
private:
virtual QString getQ(qreal longitude, qreal latitude, int zoom) const;
qreal getMercatorLatitude(qreal YCoord) const;
qreal getMercatorYCoord(qreal lati) const;
qreal coord_per_x_tile;
qreal coord_per_y_tile;
int srvNum;
//
// virtual QPoint coordinateToDisplay(const QPointF&) const;
// virtual QPointF displayToCoordinate(const QPoint&) const;
//
// //! returns the host of this MapAdapter
// /*!
// * @return the host of this MapAdapter
// */
// QString getHost () const;
//
//
// protected:
// virtual void zoom_in();
// virtual void zoom_out();
// virtual QString query(int x, int y, int z) const;
// virtual bool isValid(int x, int y, int z) const;
//
// private:
// virtual QString getQ(qreal longitude, qreal latitude, int zoom) const;
// qreal getMercatorLatitude(qreal YCoord) const;
// qreal getMercatorYCoord(qreal lati) const;
//
// qreal coord_per_x_tile;
// qreal coord_per_y_tile;
// int srvNum;
};
}
#endif
......@@ -31,7 +31,10 @@
message(Qt version $$[QT_VERSION])
release {
# DEFINES += QT_NO_DEBUG_OUTPUT
# DEFINES += QT_NO_WARNING_OUTPUT
}
# MAC OS X
macx {
......
......@@ -152,7 +152,10 @@ HEADERS += src/MG.h \
src/ui/QGCPxImuFirmwareUpdate.h \
src/comm/MAVLinkLightProtocol.h \
src/ui/QGCDataPlot2D.h \
src/ui/linechart/IncrementalPlot.h
src/ui/linechart/IncrementalPlot.h \
src/ui/map/Waypoint2DIcon.h \
src/ui/map/MAV2DIcon.h \
src/ui/map/QGC2DIcon.h
SOURCES += src/main.cc \
src/Core.cc \
src/uas/UASManager.cc \
......@@ -212,7 +215,10 @@ SOURCES += src/main.cc \
src/ui/QGCPxImuFirmwareUpdate.cc \
src/comm/MAVLinkLightProtocol.cc \
src/ui/QGCDataPlot2D.cc \
src/ui/linechart/IncrementalPlot.cc
src/ui/linechart/IncrementalPlot.cc \
src/ui/map/Waypoint2DIcon.cc \
src/ui/map/MAV2DIcon.cc \
src/ui/map/QGC2DIcon.cc
RESOURCES = mavground.qrc
# Include RT-LAB Library
......
......@@ -258,7 +258,7 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
//if ()
// If a new loss was detected or we just hit one 128th packet step
if (lastLoss != totalLossCounter || (totalReceiveCounter & 0x7F) == 0)
if (lastLoss != totalLossCounter || (totalReceiveCounter == 128))
{
// Calculate new loss ratio
// Receive loss
......
......@@ -40,6 +40,7 @@ This file is part of the QGROUNDCONTROL project
#include "ProtocolInterface.h"
#include "LinkInterface.h"
#include "protocol.h"
#include "mavlink.h"
/**
* @brief MAVLink micro air vehicle protocol reference implementation.
......
/*=====================================================================
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/>.
======================================================================*/
#ifndef ARDUPILOTMAV_H
#define ARDUPILOTMAV_H
......
/*=====================================================================
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/>.
======================================================================*/
#ifndef PXQUADMAV_H
#define PXQUADMAV_H
......
/*=====================================================================
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/>.
======================================================================*/
#ifndef SLUGSMAV_H
#define SLUGSMAV_H
......
......@@ -1038,6 +1038,11 @@ void UAS::setManualControlCommands(double roll, double pitch, double yaw, double
}
}
int UAS::getSystemType()
{
return this->type;
}
void UAS::receiveButton(int buttonIndex)
{
switch (buttonIndex)
......
/*=====================================================================
PIXHAWK Micro Air Vehicle Flying Robotics Toolkit
QGroundControl Open Source Ground Control Station
(c) 2009, 2010 PIXHAWK PROJECT <http://pixhawk.ethz.ch>
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the PIXHAWK project
This file is part of the QGROUNDCONTROL project
PIXHAWK is free software: you can redistribute it and/or modify
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.
PIXHAWK is distributed in the hope that it will be useful,
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 PIXHAWK. If not, see <http://www.gnu.org/licenses/>.
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
......@@ -142,6 +142,7 @@ protected:
public:
UASWaypointManager &getWaypointManager(void) { return waypointManager; }
int getSystemType();
public slots:
/** @brief Launches the system **/
......
/*=====================================================================
PIXHAWK Micro Air Vehicle Flying Robotics Toolkit
QGroundControl Open Source Ground Control Station
(c) 2009, 2010 PIXHAWK PROJECT <http://pixhawk.ethz.ch>
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the PIXHAWK project
This file is part of the QGROUNDCONTROL project
PIXHAWK is free software: you can redistribute it and/or modify
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.
PIXHAWK is distributed in the hope that it will be useful,
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 PIXHAWK. If not, see <http://www.gnu.org/licenses/>.
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
......@@ -135,6 +135,9 @@ public:
return colors[nextColor++];
}
/** @brief Get the type of the system (airplane, quadrotor, helicopter,..)*/
virtual int getSystemType() = 0;
QColor getColor()
{
return color;
......
......@@ -23,7 +23,7 @@ This file is part of the PIXHAWK project
/**
* @file
* @brief Implementation of central manager for all connected aerial vehicles
* @brief Implementation of class UASManager
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
......@@ -81,9 +81,7 @@ void UASManager::addUAS(UASInterface* uas)
// If there is no active UAS yet, set the first one as the active UAS
if (activeUAS == NULL)
{
activeUAS = uas;
emit activeUASSet(uas);
emit activeUASSet(uas->getUASID());
setActiveUAS(uas);
}
}
......@@ -165,6 +163,11 @@ void UASManager::setActiveUAS(UASInterface* uas)
if (uas != NULL)
{
activeUASMutex.lock();
if (activeUAS != NULL)
{
emit activeUASStatusChanged(activeUAS, false);
emit activeUASStatusChanged(activeUAS->getUASID(), false);
}
activeUAS = uas;
activeUASMutex.unlock();
......@@ -172,6 +175,8 @@ void UASManager::setActiveUAS(UASInterface* uas)
emit activeUASSet(uas);
emit activeUASSet(uas->getUASID());
emit activeUASStatusChanged(uas, true);
emit activeUASStatusChanged(uas->getUASID(), true);
}
}
/*=====================================================================
PIXHAWK Micro Air Vehicle Flying Robotics Toolkit
QGroundControl Open Source Ground Control Station
(c) 2009 PIXHAWK PROJECT <http://pixhawk.ethz.ch>
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the PIXHAWK project
This file is part of the QGROUNDCONTROL project
PIXHAWK is free software: you can redistribute it and/or modify
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.
PIXHAWK is distributed in the hope that it will be useful,
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 PIXHAWK. If not, see <http://www.gnu.org/licenses/>.
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Definition of central manager for all connected aerial vehicles
* @brief Definition of class UASManager
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
......@@ -37,7 +37,7 @@ This file is part of the PIXHAWK project
#include <UASInterface.h>
/**