[kstars] kstars/ekos/guide: As I said, I would try to take care of the Dither issues with PHD2. This patch should prevent the observed problems.

Jasem Mutlaq null at kde.org
Sun Dec 31 07:08:51 UTC 2017


Git commit b991d240b077afe4462d2135414bdf00cc2a5081 by Jasem Mutlaq, on behalf of Robert Lancaster.
Committed on 31/12/2017 at 07:07.
Pushed by mutlaqja into branch 'master'.

As I said, I would try to take care of the Dither issues with PHD2.  This patch should prevent the observed problems.

1. It adds a Timer that will keep track of the amount of time since the dither request was initiated.  Then if PHD2 doesn’t respond within the dither timeout that it dithered, then either the capture sequence will continue or it will be aborted depending on whether the user selected ditherFailAbortsAutoGuide.
2. It eliminates some of the dither messages I added when dithering wasn’t working so well.
3. It adds a “Dither” label to the drift graph so that you know when dithering occurred.
4. It prevents GuideSteps during the dither and settle time from being added to the drift Graph.
5. It changes conditions of the dither failure after settle occurs so that if the user didn’t select that ditherFailAbortsAutoGuide it won’t abort the sequence

CCMAIL:kstars-devel at kde.org

M  +28   -7    kstars/ekos/guide/externalguide/phd2.cpp
M  +1    -0    kstars/ekos/guide/externalguide/phd2.h
M  +13   -0    kstars/ekos/guide/guide.cpp

https://commits.kde.org/kstars/b991d240b077afe4462d2135414bdf00cc2a5081

diff --git a/kstars/ekos/guide/externalguide/phd2.cpp b/kstars/ekos/guide/externalguide/phd2.cpp
index 8e1996f3d..ab09556bc 100644
--- a/kstars/ekos/guide/externalguide/phd2.cpp
+++ b/kstars/ekos/guide/externalguide/phd2.cpp
@@ -112,6 +112,23 @@ PHD2::PHD2()
 
     abortTimer = new QTimer(this);
     connect(abortTimer, &QTimer::timeout, this, [=]{abort();});
+
+    ditherTimer = new QTimer(this);
+    connect(ditherTimer, &QTimer::timeout, this, [=]
+    {
+        ditherTimer->stop();
+        if (Options::ditherFailAbortsAutoGuide())
+        {
+            state = DITHER_FAILED;
+            emit newStatus(GUIDE_DITHERING_ERROR);
+        }
+        else
+        {
+            emit newLog(i18n("PHD2: There was no dithering response from PHD2, but continue guiding."));
+            state = GUIDING;
+            emit newStatus(Ekos::GUIDE_DITHERING_SUCCESS);
+        }
+    });
 }
 
 PHD2::~PHD2()
@@ -309,14 +326,17 @@ void PHD2::processPHD2Event(const QJsonObject &jsonEvent)
             }
             else if (state == DITHERING)
             {
-                if (error)
+                ditherTimer->stop();
+                if (error && Options::ditherFailAbortsAutoGuide())
                 {
                     state = DITHER_FAILED;
                     emit newStatus(GUIDE_DITHERING_ERROR);
                 }
                 else
                 {
-                    state = DITHER_SUCCESSFUL;
+                    if(error)
+                         emit newLog(i18n("PHD2: There was a dithering error, but continue guiding."));
+                    state = GUIDING;
                     emit newStatus(Ekos::GUIDE_DITHERING_SUCCESS);
                 }
             }
@@ -328,12 +348,11 @@ void PHD2::processPHD2Event(const QJsonObject &jsonEvent)
             break;
 
         case StarLost:
-            emit newLog(i18n("PHD2: Star Lost."));
+            emit newLog(i18n("PHD2: Star Lost. Trying to reacquire."));
             if(state != LOSTLOCK)
             {
                 state = LOSTLOCK;
                 abortTimer->start(starReAcquisitionTime);
-                //emit newStatus(Ekos::GUIDE_ABORTED);
             }
             break;
 
@@ -351,13 +370,15 @@ void PHD2::processPHD2Event(const QJsonObject &jsonEvent)
 
         case GuideStep:
         {
+            if(state == DITHERING)
+                    return;
             if( state == LOSTLOCK)
             {
                 emit newLog(i18n("PHD2: Star found, guiding resumed."));
                 abortTimer->stop();  
                 state = GUIDING;
             }
-            if(state != GUIDING)
+            else if(state != GUIDING)
             {
                 emit newLog(i18n("PHD2: Guiding started up again."));
                 emit newStatus(Ekos::GUIDE_GUIDING);
@@ -418,7 +439,6 @@ void PHD2::processPHD2Event(const QJsonObject &jsonEvent)
         break;
 
         case GuidingDithered:
-            emit newLog(i18n("PHD2: Dither Completed. Settling. . ."));
             if(state == GUIDING)
             {
                 state = DITHERING;
@@ -490,7 +510,6 @@ void PHD2::processPHD2Result(const QJsonObject &jsonObj, QString rawString)
             break;
 
         case DITHER_COMMAND_RECEIVED:               //dither
-            emit newLog(i18n("PHD2: Guide Dithering. . ."));
             state = DITHERING;
             emit newStatus(Ekos::GUIDE_DITHERING);
             break;
@@ -638,6 +657,7 @@ void PHD2::processPHD2Error(const QJsonObject &jsonError)
         }
         else if(resultRequest == DITHER_COMMAND_RECEIVED && state == DITHERING)
         {
+            ditherTimer->stop();
             state = DITHER_FAILED;
             emit newStatus(GUIDE_DITHERING_ERROR);
 
@@ -775,6 +795,7 @@ bool PHD2::dither(double pixels)
     args << settle;
 
     state = DITHERING;
+    ditherTimer->start(static_cast<int>(Options::ditherTimeout())*1000); //Timer is in ms, timeout is in sec
 
     sendPHD2Request("dither", args);
 
diff --git a/kstars/ekos/guide/externalguide/phd2.h b/kstars/ekos/guide/externalguide/phd2.h
index ddeb77ce2..6a414f904 100644
--- a/kstars/ekos/guide/externalguide/phd2.h
+++ b/kstars/ekos/guide/externalguide/phd2.h
@@ -227,6 +227,7 @@ class PHD2 : public GuideInterface
     void updateGuideParameters();
 
     QTimer *abortTimer;
+    QTimer *ditherTimer;
     int starReAcquisitionTime=5000;
 
     double pixelScale=0;
diff --git a/kstars/ekos/guide/guide.cpp b/kstars/ekos/guide/guide.cpp
index df36106ba..5ba889ce7 100644
--- a/kstars/ekos/guide/guide.cpp
+++ b/kstars/ekos/guide/guide.cpp
@@ -564,6 +564,7 @@ void Guide::clearGuideGraphs(){
     driftGraph->graph(5)->data()->clear(); //DEC Pulses
     driftPlot->graph(0)->data()->clear(); //Guide data
     driftPlot->graph(1)->data()->clear(); //Guide highlighted point
+    driftGraph->clearItems();  //Clears dither text items from the graph
     driftGraph->replot();
     driftPlot->replot();
 }
@@ -1622,6 +1623,18 @@ bool Guide::dither()
     if (state == GUIDE_DITHERING || state == GUIDE_DITHERING_SETTLE)
         return true;
 
+    //This adds a dither text item to the graph where dithering occurred.
+    double time = guideTimer.elapsed() / 1000.0;
+    QCPItemText *ditherLabel = new QCPItemText(driftGraph);
+    ditherLabel->setPositionAlignment(Qt::AlignVCenter | Qt::AlignLeft);
+    ditherLabel->position->setType(QCPItemPosition::ptPlotCoords);
+    ditherLabel->position->setCoords(time, 1.5);
+    ditherLabel->setColor(Qt::white);
+    ditherLabel->setBrush(Qt::NoBrush);
+    ditherLabel->setPen(Qt::NoPen);
+    ditherLabel->setText("Dither");
+    ditherLabel->setFont(QFont(font().family(), 10));
+
     if (guiderType == GUIDE_INTERNAL)
     {
         if (state != GUIDE_GUIDING)


More information about the Kstars-devel mailing list