1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

OP-82: GPS info includes HDOP as well. PFD plugin is now pretty much ready feature-wise. Additional features such as waypoint/home display will be added then OpenPilot supports this too.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1094 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2010-07-14 12:36:22 +00:00 committed by edouard
parent be63c71de4
commit 57fe878b64

View File

@ -47,17 +47,22 @@ PFDGadgetWidget::PFDGadgetWidget(QWidget *parent) : QGraphicsView(parent)
headingObj = NULL; headingObj = NULL;
gcsBatteryObj = NULL; gcsBatteryObj = NULL;
compassBandWidth = 0; compassBandWidth = 0;
/* pfdError = true;
obj2 = NULL; rollTarget = 0;
obj3 = NULL; rollValue = 0;
*/ pitchTarget = 0;
pitchValue = 0;
headingTarget = 0;
headingValue = 0;
groundspeedTarget = 0;
groundspeedValue = 0;
altitudeTarget = 0;
altitudeValue = 0;
// This timer mechanism makes needles rotate smoothly // This timer mechanism makes needles rotate smoothly
connect(&dialTimer, SIGNAL(timeout()), this, SLOT(moveNeedles())); connect(&dialTimer, SIGNAL(timeout()), this, SLOT(moveNeedles()));
dialTimer.start(20); dialTimer.start(20);
/*
connect(&dialTimer2,SIGNAL(timeout()), this, SLOT(moveVerticalScales()));
dialTimer2.start(20);
*/
} }
@ -69,7 +74,8 @@ PFDGadgetWidget::~PFDGadgetWidget()
/*! /*!
\brief Connects the widget to the relevant UAVObjects \brief Connects the widget to the relevant UAVObjects
We want: AttitudeActual, FlightBattery, Location Should only be called after the PFD artwork is loaded.
We want: AttitudeActual, FlightBattery, Location.
*/ */
void PFDGadgetWidget::connectNeedles() { void PFDGadgetWidget::connectNeedles() {
@ -102,18 +108,23 @@ void PFDGadgetWidget::connectNeedles() {
qDebug() << "Error: Object is unknown (PositionActual)."; qDebug() << "Error: Object is unknown (PositionActual).";
} }
gcsTelemetryObj = dynamic_cast<UAVDataObject*>(objManager->getObject("GCSTelemetryStats")); if (gcsTelemetryArrow || gcsTelemetryStats ) {
if (gcsTelemetryObj != NULL ) { // Only register if the PFD wants link stats/status
connect(gcsTelemetryObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateLinkStatus(UAVObject*))); gcsTelemetryObj = dynamic_cast<UAVDataObject*>(objManager->getObject("GCSTelemetryStats"));
} else { if (gcsTelemetryObj != NULL ) {
qDebug() << "Error: Object is unknown (GCSTelemetryStats)."; connect(gcsTelemetryObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateLinkStatus(UAVObject*)));
} } else {
qDebug() << "Error: Object is unknown (GCSTelemetryStats).";
}
}
gcsBatteryObj = dynamic_cast<UAVDataObject*>(objManager->getObject("FlightBatteryState")); if (gcsBatteryStats) { // Only register if the PFD wants battery display
if (gcsBatteryObj != NULL ) { gcsBatteryObj = dynamic_cast<UAVDataObject*>(objManager->getObject("FlightBatteryState"));
connect(gcsBatteryObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateBattery(UAVObject*))); if (gcsBatteryObj != NULL ) {
} else { connect(gcsBatteryObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateBattery(UAVObject*)));
qDebug() << "Error: Object is unknown (FlightBatteryState)."; } else {
qDebug() << "Error: Object is unknown (FlightBatteryState).";
}
} }
} }
@ -131,7 +142,7 @@ void PFDGadgetWidget::updateLinkStatus(UAVObject *object1) {
UAVObjectField* field3 = object1->getField(rdr); UAVObjectField* field3 = object1->getField(rdr);
if (field && field2 && field3) { if (field && field2 && field3) {
QString s = field->getValue().toString(); QString s = field->getValue().toString();
if (m_renderer->elementExists("gcstelemetry-" + s)) { if (m_renderer->elementExists("gcstelemetry-" + s) && gcsTelemetryArrow) {
gcsTelemetryArrow->setElementId("gcstelemetry-" + s); gcsTelemetryArrow->setElementId("gcstelemetry-" + s);
} else { // Safeguard } else { // Safeguard
gcsTelemetryArrow->setElementId("gcstelemetry-Disconnected"); gcsTelemetryArrow->setElementId("gcstelemetry-Disconnected");
@ -139,7 +150,7 @@ void PFDGadgetWidget::updateLinkStatus(UAVObject *object1) {
double v1 = field2->getDouble(); double v1 = field2->getDouble();
double v2 = field3->getDouble(); double v2 = field3->getDouble();
s.sprintf("%.0f/%.0f",v1,v2); s.sprintf("%.0f/%.0f",v1,v2);
gcsTelemetryStats->setPlainText(s); if (gcsTelemetryStats) gcsTelemetryStats->setPlainText(s);
} else { } else {
qDebug() << "UpdateLinkStatus: Wrong field, maybe an issue with object disconnection ?"; qDebug() << "UpdateLinkStatus: Wrong field, maybe an issue with object disconnection ?";
} }
@ -159,6 +170,8 @@ void PFDGadgetWidget::updateAttitude(UAVObject *object1) {
// - Roll value in degrees // - Roll value in degrees
// - Pitch lines are 300px high for a +20/-20 range, which means // - Pitch lines are 300px high for a +20/-20 range, which means
// 7.5 pixels per pitch degree. // 7.5 pixels per pitch degree.
// TODO: loosen this constraint and only require a +/- 20 deg range,
// and compute the height from the SVG element.
rollTarget = field->getDouble()*(-1); rollTarget = field->getDouble()*(-1);
pitchTarget = field2->getDouble()*7.5; pitchTarget = field2->getDouble()*7.5;
if (!dialTimer.isActive()) if (!dialTimer.isActive())
@ -205,16 +218,20 @@ void PFDGadgetWidget::updateHeading(UAVObject *object1) {
} }
// GPS Stats // GPS Stats
fieldname = QString("Satellites"); if (gcsGPSStats) {
field = object1->getField(fieldname); fieldname = QString("Satellites");
if (field) { field = object1->getField(fieldname);
QString s = QString("GPS: ") + field->getValue().toString(); fieldname = QString("HDOP");
gcsGPSStats->setPlainText(s); UAVObjectField* field1 = object1->getField(fieldname);
if (field && field1) {
QString s = QString("GPS: ") + field->getValue().toString() + "\nHDP: "
+ field1->getValue().toString();
gcsGPSStats->setPlainText(s);
}
} }
if (!dialTimer.isActive()) if (!dialTimer.isActive())
dialTimer.start(); // Rearm the dial Timer which might be stopped. dialTimer.start(); // Rearm the dial Timer which might be stopped.
} }
/*! /*!
@ -530,28 +547,37 @@ void PFDGadgetWidget::setDialFile(QString dfn)
//////////////// ////////////////
// GCS Telemetry Indicator // GCS Telemetry Indicator
//////////////// ////////////////
compassMatrix = m_renderer->matrixForElement("gcstelemetry-Disconnected"); if (m_renderer->elementExists("gcstelemetry-Disconnected")) {
startX = compassMatrix.mapRect(m_renderer->boundsOnElement("gcstelemetry-Disconnected")).x(); compassMatrix = m_renderer->matrixForElement("gcstelemetry-Disconnected");
startY = compassMatrix.mapRect(m_renderer->boundsOnElement("gcstelemetry-Disconnected")).y(); startX = compassMatrix.mapRect(m_renderer->boundsOnElement("gcstelemetry-Disconnected")).x();
gcsTelemetryArrow = new QGraphicsSvgItem(); startY = compassMatrix.mapRect(m_renderer->boundsOnElement("gcstelemetry-Disconnected")).y();
gcsTelemetryArrow->setSharedRenderer(m_renderer); gcsTelemetryArrow = new QGraphicsSvgItem();
gcsTelemetryArrow->setElementId("gcstelemetry-Disconnected"); gcsTelemetryArrow->setSharedRenderer(m_renderer);
l_scene->addItem(gcsTelemetryArrow); gcsTelemetryArrow->setElementId("gcstelemetry-Disconnected");
matrix.reset(); l_scene->addItem(gcsTelemetryArrow);
matrix.translate(startX,startY); matrix.reset();
gcsTelemetryArrow->setTransform(matrix,false); matrix.translate(startX,startY);
gcsTelemetryArrow->setTransform(matrix,false);
} else {
gcsTelemetryArrow = NULL;
}
if (m_renderer->elementExists("linkrate")) {
compassMatrix = m_renderer->matrixForElement("linkrate");
startX = compassMatrix.mapRect(m_renderer->boundsOnElement("linkrate")).x();
startY = compassMatrix.mapRect(m_renderer->boundsOnElement("linkrate")).y();
qreal linkRateHeight = compassMatrix.mapRect(m_renderer->boundsOnElement("linkrate")).height();
gcsTelemetryStats = new QGraphicsTextItem();
gcsTelemetryStats->setDefaultTextColor(QColor("White"));
gcsTelemetryStats->setFont(QFont("Arial",(int) linkRateHeight));
l_scene->addItem(gcsTelemetryStats);
matrix.reset();
matrix.translate(startX,startY-linkRateHeight/2);
gcsTelemetryStats->setTransform(matrix,false);
} else {
gcsTelemetryStats = NULL;
}
compassMatrix = m_renderer->matrixForElement("linkrate");
startX = compassMatrix.mapRect(m_renderer->boundsOnElement("linkrate")).x();
startY = compassMatrix.mapRect(m_renderer->boundsOnElement("linkrate")).y();
qreal linkRateHeight = compassMatrix.mapRect(m_renderer->boundsOnElement("linkrate")).height();
gcsTelemetryStats = new QGraphicsTextItem();
gcsTelemetryStats->setDefaultTextColor(QColor("White"));
gcsTelemetryStats->setFont(QFont("Arial",(int) linkRateHeight));
l_scene->addItem(gcsTelemetryStats);
matrix.reset();
matrix.translate(startX,startY-linkRateHeight/2);
gcsTelemetryStats->setTransform(matrix,false);
//////////////// ////////////////
// GCS Battery Indicator // GCS Battery Indicator
@ -569,17 +595,21 @@ void PFDGadgetWidget::setDialFile(QString dfn)
gcsTelemetryArrow->setTransform(matrix,false); gcsTelemetryArrow->setTransform(matrix,false);
*/ */
compassMatrix = m_renderer->matrixForElement("battery-txt"); if (m_renderer->elementExists("battery-txt")) {
startX = compassMatrix.mapRect(m_renderer->boundsOnElement("battery-txt")).x(); compassMatrix = m_renderer->matrixForElement("battery-txt");
startY = compassMatrix.mapRect(m_renderer->boundsOnElement("battery-txt")).y(); startX = compassMatrix.mapRect(m_renderer->boundsOnElement("battery-txt")).x();
qreal batStatHeight = compassMatrix.mapRect(m_renderer->boundsOnElement("battery-txt")).height(); startY = compassMatrix.mapRect(m_renderer->boundsOnElement("battery-txt")).y();
gcsBatteryStats = new QGraphicsTextItem(); qreal batStatHeight = compassMatrix.mapRect(m_renderer->boundsOnElement("battery-txt")).height();
gcsBatteryStats->setDefaultTextColor(QColor("White")); gcsBatteryStats = new QGraphicsTextItem();
gcsBatteryStats->setFont(QFont("Arial",(int) batStatHeight)); gcsBatteryStats->setDefaultTextColor(QColor("White"));
l_scene->addItem(gcsBatteryStats); gcsBatteryStats->setFont(QFont("Arial",(int) batStatHeight));
matrix.reset(); l_scene->addItem(gcsBatteryStats);
matrix.translate(startX,startY-batStatHeight/2); matrix.reset();
gcsBatteryStats->setTransform(matrix,false); matrix.translate(startX,startY-batStatHeight/2);
gcsBatteryStats->setTransform(matrix,false);
} else {
gcsBatteryStats = NULL;
}
//////////////// ////////////////
// GCS GPS Indicator // GCS GPS Indicator
@ -597,19 +627,21 @@ void PFDGadgetWidget::setDialFile(QString dfn)
gcsTelemetryArrow->setTransform(matrix,false); gcsTelemetryArrow->setTransform(matrix,false);
*/ */
compassMatrix = m_renderer->matrixForElement("gps-txt"); if (m_renderer->elementExists("gps-txt")) {
startX = compassMatrix.mapRect(m_renderer->boundsOnElement("gps-txt")).x(); compassMatrix = m_renderer->matrixForElement("gps-txt");
startY = compassMatrix.mapRect(m_renderer->boundsOnElement("gps-txt")).y(); startX = compassMatrix.mapRect(m_renderer->boundsOnElement("gps-txt")).x();
qreal gpsStatHeight = compassMatrix.mapRect(m_renderer->boundsOnElement("gps-txt")).height(); startY = compassMatrix.mapRect(m_renderer->boundsOnElement("gps-txt")).y();
gcsGPSStats = new QGraphicsTextItem(); qreal gpsStatHeight = compassMatrix.mapRect(m_renderer->boundsOnElement("gps-txt")).height();
gcsGPSStats->setDefaultTextColor(QColor("White")); gcsGPSStats = new QGraphicsTextItem();
gcsGPSStats->setFont(QFont("Arial",(int) gpsStatHeight)); gcsGPSStats->setDefaultTextColor(QColor("White"));
l_scene->addItem(gcsGPSStats); gcsGPSStats->setFont(QFont("Arial",(int) gpsStatHeight));
matrix.reset(); l_scene->addItem(gcsGPSStats);
matrix.translate(startX,startY-gpsStatHeight/2); matrix.reset();
gcsGPSStats->setTransform(matrix,false); matrix.translate(startX,startY-gpsStatHeight/2);
gcsGPSStats->setTransform(matrix,false);
} else {
gcsGPSStats = NULL;
}
l_scene->setSceneRect(m_background->boundingRect()); l_scene->setSceneRect(m_background->boundingRect());