Commit 26bca59d authored by lm's avatar lm

Finished 2D HSI widget, now displays waypoints, satellites and critical system states

parent 19f73a78
...@@ -9,7 +9,8 @@ namespace QGC ...@@ -9,7 +9,8 @@ namespace QGC
const QColor colorCyan(55, 154, 195); const QColor colorCyan(55, 154, 195);
const QColor colorRed(154, 20, 20); const QColor colorRed(154, 20, 20);
const QColor colorGreen(20, 200, 20); const QColor colorGreen(20, 200, 20);
const QColor colorYellow(195, 154, 55); const QColor colorYellow(255, 255, 0);
const QColor colorDarkYellow(180, 180, 0);
/** @brief Get the current ground time in microseconds */ /** @brief Get the current ground time in microseconds */
quint64 groundTimeUsecs(); quint64 groundTimeUsecs();
......
...@@ -37,6 +37,7 @@ This file is part of the PIXHAWK project ...@@ -37,6 +37,7 @@ This file is part of the PIXHAWK project
#include "MG.h" #include "MG.h"
#include "QGC.h" #include "QGC.h"
#include "Waypoint.h" #include "Waypoint.h"
#include "UASWaypointManager.h"
#include <QDebug> #include <QDebug>
...@@ -136,19 +137,6 @@ void HSIDisplay::paintDisplay() ...@@ -136,19 +137,6 @@ void HSIDisplay::paintDisplay()
// Draw background // Draw background
painter.fillRect(QRect(0, 0, width(), height()), backgroundColor); painter.fillRect(QRect(0, 0, width(), height()), backgroundColor);
// Draw status flags
drawStatusFlag(2, 1, tr("ATT"), attControlEnabled, painter);
drawStatusFlag(22, 1, tr("PXY"), xyControlEnabled, painter);
drawStatusFlag(44, 1, tr("PZ"), zControlEnabled, painter);
drawStatusFlag(66, 1, tr("YAW"), yawControlEnabled, painter);
// Draw position lock indicators
drawPositionLock(2, 5, tr("POS"), positionFix, painter);
drawPositionLock(22, 5, tr("VIS"), visionFix, painter);
drawPositionLock(44, 5, tr("GPS"), gpsFix, painter);
drawPositionLock(66, 5, tr("IRU"), iruFix, painter);
// Draw base instrument // Draw base instrument
// ---------------------- // ----------------------
painter.setBrush(Qt::NoBrush); painter.setBrush(Qt::NoBrush);
...@@ -164,6 +152,17 @@ void HSIDisplay::paintDisplay() ...@@ -164,6 +152,17 @@ void HSIDisplay::paintDisplay()
drawCircle(xCenterPos, yCenterPos, radius, 0.1f, ringColor, &painter); drawCircle(xCenterPos, yCenterPos, radius, 0.1f, ringColor, &painter);
} }
// Draw orientation labels
// Translate and rotate coordinate frame
painter.translate((xCenterPos)*scalingFactor, (yCenterPos)*scalingFactor);
painter.rotate((-yaw/(M_PI))*180.0f);
paintText(tr("N"), ringColor, 3.5f, - 1.0f, - baseRadius - 5.5f, &painter);
paintText(tr("S"), ringColor, 3.5f, - 1.0f, + baseRadius + 1.5f, &painter);
paintText(tr("E"), ringColor, 3.5f, + baseRadius + 2.0f, - 1.75f, &painter);
paintText(tr("W"), ringColor, 3.5f, - baseRadius - 5.5f, - 1.75f, &painter);
painter.rotate((yaw/(M_PI))*180.0f);
painter.translate(-(xCenterPos)*scalingFactor, -(yCenterPos)*scalingFactor);
// Draw center indicator // Draw center indicator
QPolygonF p(3); QPolygonF p(3);
p.replace(0, QPointF(xCenterPos, yCenterPos-2.8484f)); p.replace(0, QPointF(xCenterPos, yCenterPos-2.8484f));
...@@ -208,9 +207,6 @@ void HSIDisplay::paintDisplay() ...@@ -208,9 +207,6 @@ void HSIDisplay::paintDisplay()
drawLine(s.x(), s.y(), xCenterPos, yCenterPos, 1.5f, QGC::colorCyan, &painter); drawLine(s.x(), s.y(), xCenterPos, yCenterPos, 1.5f, QGC::colorCyan, &painter);
} }
// Draw waypoints
drawWaypoints(painter);
// Labels on outer part and bottom // Labels on outer part and bottom
if (localAvailable > 0) if (localAvailable > 0)
...@@ -225,20 +221,20 @@ void HSIDisplay::paintDisplay() ...@@ -225,20 +221,20 @@ void HSIDisplay::paintDisplay()
paintText(str, ringColor, 3.0f, 10.0f, vheight - 5.0f, &painter); paintText(str, ringColor, 3.0f, 10.0f, vheight - 5.0f, &painter);
} }
// Draw orientation labels // Draw waypoints
// Translate and rotate coordinate frame drawWaypoints(painter);
painter.translate((xCenterPos)*scalingFactor, (yCenterPos)*scalingFactor);
painter.rotate((-yaw/(M_PI))*180.0f); // Draw status flags
paintText(tr("N"), ringColor, 3.5f, - 1.0f, - baseRadius - 5.5f, &painter); drawStatusFlag(2, 1, tr("ATT"), attControlEnabled, painter);
paintText(tr("S"), ringColor, 3.5f, - 1.0f, + baseRadius + 1.5f, &painter); drawStatusFlag(22, 1, tr("PXY"), xyControlEnabled, painter);
paintText(tr("E"), ringColor, 3.5f, + baseRadius + 2.0f, - 1.75f, &painter); drawStatusFlag(44, 1, tr("PZ"), zControlEnabled, painter);
paintText(tr("W"), ringColor, 3.5f, - baseRadius - 5.5f, - 1.75f, &painter); drawStatusFlag(66, 1, tr("YAW"), yawControlEnabled, painter);
// // Just for testing // Draw position lock indicators
// bodyXSetCoordinate = 0.95 * bodyXSetCoordinate + 0.05 * uiXSetCoordinate; drawPositionLock(2, 5, tr("POS"), positionFix, painter);
// bodyYSetCoordinate = 0.95 * bodyYSetCoordinate + 0.05 * uiYSetCoordinate; drawPositionLock(22, 5, tr("VIS"), visionFix, painter);
// bodyZSetCoordinate = 0.95 * bodyZSetCoordinate + 0.05 * uiZSetCoordinate; drawPositionLock(44, 5, tr("GPS"), gpsFix, painter);
// bodyYawSet = 0.95 * bodyYawSet + 0.05 * uiYawSet; drawPositionLock(66, 5, tr("IRU"), iruFix, painter);
} }
void HSIDisplay::drawStatusFlag(float x, float y, QString label, bool status, QPainter& painter) void HSIDisplay::drawStatusFlag(float x, float y, QString label, bool status, QPainter& painter)
...@@ -251,7 +247,7 @@ void HSIDisplay::drawStatusFlag(float x, float y, QString label, bool status, QP ...@@ -251,7 +247,7 @@ void HSIDisplay::drawStatusFlag(float x, float y, QString label, bool status, QP
} }
else else
{ {
painter.setBrush(QGC::colorYellow); painter.setBrush(QGC::colorDarkYellow);
} }
painter.setPen(Qt::NoPen); painter.setPen(Qt::NoPen);
painter.drawRect(QRect(refToScreenX(x+7.3f), refToScreenY(y+0.05), refToScreenX(7.0f), refToScreenY(4.0f))); painter.drawRect(QRect(refToScreenX(x+7.3f), refToScreenY(y+0.05), refToScreenX(7.0f), refToScreenY(4.0f)));
...@@ -320,7 +316,8 @@ QPointF HSIDisplay::metricWorldToBody(QPointF world) ...@@ -320,7 +316,8 @@ QPointF HSIDisplay::metricWorldToBody(QPointF world)
{ {
// First translate to body-centered coordinates // First translate to body-centered coordinates
// Rotate around -yaw // Rotate around -yaw
QPointF result(cos(yaw) * (x - world.x()) + -sin(yaw) * (x - world.x()), sin(yaw) * (y - world.y()) + cos(yaw) * (y - world.y())); float angle = yaw + M_PI;
QPointF result(cos(angle) * (x - world.x()) - sin(angle) * (y - world.y()), sin(angle) * (x - world.x()) + cos(angle) * (y - world.y()));
return result; return result;
} }
...@@ -328,7 +325,7 @@ QPointF HSIDisplay::metricBodyToWorld(QPointF body) ...@@ -328,7 +325,7 @@ QPointF HSIDisplay::metricBodyToWorld(QPointF body)
{ {
// First rotate into world coordinates // First rotate into world coordinates
// then translate to world position // then translate to world position
QPointF result((cos(yaw) * body.x()) + (sin(yaw) * body.x()) + x, (-sin(yaw) * body.y()) + (cos(yaw) * body.y()) + y); QPointF result((cos(yaw) * body.x()) + (sin(yaw) * body.y()) + x, (-sin(yaw) * body.x()) + (cos(yaw) * body.y()) + y);
return result; return result;
} }
...@@ -634,9 +631,7 @@ void HSIDisplay::drawWaypoints(QPainter& painter) ...@@ -634,9 +631,7 @@ void HSIDisplay::drawWaypoints(QPainter& painter)
{ {
if (uas) if (uas)
{ {
QVector<Waypoint*> list = QVector<Waypoint*>(); QVector<Waypoint*>& list = uas->getWaypointManager().getWaypointList();
list.append(new Waypoint(0, x, y, z, yaw, false, false, 0.5f, 2000));
list.append(new Waypoint(0, x+0.1, y+0.1, z, yaw, true, true, 0.5f, 2000));
QColor color; QColor color;
painter.setBrush(Qt::NoBrush); painter.setBrush(Qt::NoBrush);
...@@ -651,43 +646,50 @@ void HSIDisplay::drawWaypoints(QPainter& painter) ...@@ -651,43 +646,50 @@ void HSIDisplay::drawWaypoints(QPainter& painter)
// Scale from metric to screen reference coordinates // Scale from metric to screen reference coordinates
QPointF p = metricBodyToRef(in); QPointF p = metricBodyToRef(in);
// Setup pen
QPen pen(color);
painter.setBrush(Qt::NoBrush);
// DRAW WAYPOINT
//drawCircle(p.x(), p.y(), radius, 0.4f, color, &painter);
float waypointSize = vwidth / 20.0f * 2.0f;
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 // Select color based on if this is the current waypoint
if (list.at(i)->getCurrent()) if (list.at(i)->getCurrent())
{ {
color = uas->getColor().lighter().lighter(); color = QGC::colorCyan;//uas->getColor();
pen.setWidthF(refLineWidthToPen(0.8f));
} }
else else
{ {
color = uas->getColor(); color = uas->getColor();
pen.setWidthF(refLineWidthToPen(0.4f));
} }
// Setup pen pen.setColor(color);
QPen pen(color);
pen.setWidthF(refLineWidthToPen(0.4f));
painter.setPen(pen); painter.setPen(pen);
painter.setBrush(Qt::NoBrush); float radius = (waypointSize/2.0f) * 0.8 * (1/sqrt(2.0f));
drawLine(p.x(), p.y(), p.x()+sin(yaw) * radius, p.y()-cos(yaw) * radius, refLineWidthToPen(0.4f), color, &painter);
drawPolygon(poly, &painter);
// DRAW CONNECTING LINE
// Draw line from last waypoint to this one // Draw line from last waypoint to this one
if (!lastWaypoint.isNull()) if (!lastWaypoint.isNull())
{ {
pen.setWidthF(refLineWidthToPen(0.4f));
painter.setPen(pen);
color = uas->getColor();
drawLine(lastWaypoint.x(), lastWaypoint.y(), p.x(), p.y(), refLineWidthToPen(0.4f), color, &painter); drawLine(lastWaypoint.x(), lastWaypoint.y(), p.x(), p.y(), refLineWidthToPen(0.4f), color, &painter);
} }
lastWaypoint = p; lastWaypoint = p;
//drawCircle(p.x(), p.y(), radius, 0.4f, color, &painter);
float waypointSize = vwidth / 20.0f * 2.0f;
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()));
drawPolygon(poly, &painter);
float radius = (waypointSize/2.0f) * 0.8 * (1/sqrt(2.0f));
drawLine(p.x(), p.y(), p.x()+sin(yaw) * radius, p.y()-cos(yaw) * radius, refLineWidthToPen(0.4f), color, &painter);
painter.setBrush(color);
} }
} }
} }
......
...@@ -269,6 +269,7 @@ void QGCParamWidget::requestParameterList() ...@@ -269,6 +269,7 @@ void QGCParamWidget::requestParameterList()
{ {
// Clear view and request param list // Clear view and request param list
clear(); clear();
parameters.clear();
mav->requestParameters(); mav->requestParameters();
} }
......
...@@ -125,7 +125,7 @@ void UASInfoWidget::updateCPULoad(UASInterface* uas, double load) ...@@ -125,7 +125,7 @@ void UASInfoWidget::updateCPULoad(UASInterface* uas, double load)
{ {
if (activeUAS == uas) if (activeUAS == uas)
{ {
this->load = this->load * 0.8f + load * 0.2f; this->load = load;
} }
} }
......
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