Commit 998e753c authored by Lionel Heng's avatar Lionel Heng

Added timeout to overlay visualization.

parent 63a6b200
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
GLOverlayGeode::GLOverlayGeode() GLOverlayGeode::GLOverlayGeode()
: mDrawable(new GLOverlayDrawable) : mDrawable(new GLOverlayDrawable)
, mMessageTimestamp(0.0)
{ {
addDrawable(mDrawable); addDrawable(mDrawable);
} }
...@@ -21,6 +22,18 @@ GLOverlayGeode::coordinateFrameType(void) const ...@@ -21,6 +22,18 @@ GLOverlayGeode::coordinateFrameType(void) const
return mCoordinateFrameType; return mCoordinateFrameType;
} }
void
GLOverlayGeode::setMessageTimestamp(qreal timestamp)
{
mMessageTimestamp = timestamp;
}
qreal
GLOverlayGeode::messageTimestamp(void) const
{
return mMessageTimestamp;
}
GLOverlayGeode::GLOverlayDrawable::GLOverlayDrawable() GLOverlayGeode::GLOverlayDrawable::GLOverlayDrawable()
{ {
setUseDisplayList(true); setUseDisplayList(true);
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <mavlink_protobuf_manager.hpp> #include <mavlink_protobuf_manager.hpp>
#include <osg/Geode> #include <osg/Geode>
#include <QtGlobal>
class GLOverlayGeode : public osg::Geode class GLOverlayGeode : public osg::Geode
{ {
...@@ -13,6 +14,9 @@ public: ...@@ -13,6 +14,9 @@ public:
px::GLOverlay::CoordinateFrameType coordinateFrameType(void) const; px::GLOverlay::CoordinateFrameType coordinateFrameType(void) const;
void setMessageTimestamp(qreal timestamp);
qreal messageTimestamp(void) const;
private: private:
class GLOverlayDrawable : public osg::Drawable class GLOverlayDrawable : public osg::Drawable
{ {
...@@ -39,6 +43,7 @@ private: ...@@ -39,6 +43,7 @@ private:
osg::ref_ptr<GLOverlayDrawable> mDrawable; osg::ref_ptr<GLOverlayDrawable> mDrawable;
px::GLOverlay::CoordinateFrameType mCoordinateFrameType; px::GLOverlay::CoordinateFrameType mCoordinateFrameType;
qreal mMessageTimestamp;
}; };
#endif // GLOVERLAYGEODE_H #endif // GLOVERLAYGEODE_H
...@@ -563,7 +563,8 @@ Pixhawk3DWidget::addOverlay(UASInterface *uas) ...@@ -563,7 +563,8 @@ Pixhawk3DWidget::addOverlay(UASInterface *uas)
SystemContainer& systemData = mSystemContainerMap[systemId]; SystemContainer& systemData = mSystemContainerMap[systemId];
px::GLOverlay overlay = uas->getOverlay(); qreal receivedTimestamp;
px::GLOverlay overlay = uas->getOverlay(receivedTimestamp);
QString overlayName = QString::fromStdString(overlay.name()); QString overlayName = QString::fromStdString(overlay.name());
...@@ -580,7 +581,9 @@ Pixhawk3DWidget::addOverlay(UASInterface *uas) ...@@ -580,7 +581,9 @@ Pixhawk3DWidget::addOverlay(UASInterface *uas)
emit overlayCreatedSignal(systemId, overlayName); emit overlayCreatedSignal(systemId, overlayName);
} }
systemData.overlayNodeMap()[overlayName]->setOverlay(overlay); osg::ref_ptr<GLOverlayGeode>& overlayNode = systemData.overlayNodeMap()[overlayName];
overlayNode->setOverlay(overlay);
overlayNode->setMessageTimestamp(receivedTimestamp);
} }
#endif #endif
...@@ -953,11 +956,15 @@ Pixhawk3DWidget::update(void) ...@@ -953,11 +956,15 @@ Pixhawk3DWidget::update(void)
bool displayOverlay = systemViewParams->displayOverlay().value(itOverlay.key()); bool displayOverlay = systemViewParams->displayOverlay().value(itOverlay.key());
bool visible; bool visible;
visible = (overlayNode->coordinateFrameType() == px::GLOverlay::GLOBAL) && displayOverlay; visible = (overlayNode->coordinateFrameType() == px::GLOverlay::GLOBAL) &&
displayOverlay &&
(QGC::groundTimeSeconds() - overlayNode->messageTimestamp() < kMessageTimeout);
allocentricMap->setChildValue(overlayNode, visible); allocentricMap->setChildValue(overlayNode, visible);
visible = (overlayNode->coordinateFrameType() == px::GLOverlay::LOCAL) && displayOverlay; visible = (overlayNode->coordinateFrameType() == px::GLOverlay::LOCAL) &&
displayOverlay &&
(QGC::groundTimeSeconds() - overlayNode->messageTimestamp() < kMessageTimeout);;
rollingMap->setChildValue(overlayNode, visible); rollingMap->setChildValue(overlayNode, visible);
} }
......
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