Commit 6f61d394 authored by Jasem Mutlaq's avatar Jasem Mutlaq

Adding support to Rapid Guide, a new feature of INDI in which the guide star...

Adding support to Rapid Guide, a new feature of INDI in which the guide star is determined automatically by the CCD driver, and can be useful especially if you are guiding via adaptive optics.
parent 858cfb0b
......@@ -38,6 +38,7 @@ Guide::Guide() : QWidget()
currentTelescope = NULL;
ccd_hor_pixel = ccd_ver_pixel = focal_length = aperture = -1;
useGuideHead = false;
rapidGuideReticleSet = false;
tabWidget = new QTabWidget(this);
......@@ -225,13 +226,20 @@ bool Guide::capture()
return false;
}
connect(currentCCD, SIGNAL(BLOBUpdated(IBLOB*)), this, SLOT(newFITS(IBLOB*)));
targetChip->setCaptureMode(FITS_GUIDE);
targetChip->setCaptureFilter( (FITSScale) filterCombo->currentIndex());
targetChip->setFrameType(ccdFrame);
targetChip->capture(seqExpose);
if (guider->is_guiding() && guider->isRapidGuide())
{
targetChip->capture(seqExpose);
}
else
{
connect(currentCCD, SIGNAL(BLOBUpdated(IBLOB*)), this, SLOT(newFITS(IBLOB*)));
targetChip->capture(seqExpose);
}
return true;
......@@ -346,6 +354,69 @@ void Guide::viewerClosed()
calibration->set_image(NULL);
}
void Guide::processRapidStarData(ISD::CCDChip *targetChip, double dx, double dy, double fit)
{
INDI_UNUSED(targetChip);
INDI_UNUSED(fit);
/*if (dx <= 0 || dy <= 0 || fit <= 0)
{
guider->onStartStopButtonClick();
appendLogText(i18n("Guide star lost. Autoguide aborted."));
}*/
if (rapidGuideReticleSet == false)
{
// Let's set reticle parameter on first capture to those of the star, then we check if there
// is any deviation
double x,y,angle;
pmath->get_reticle_params(&x, &y, &angle);
pmath->set_reticle_params(dx, dy, angle);
rapidGuideReticleSet = true;
}
pmath->setRapidStarData(dx, dy);
guider->guide();
capture();
}
void Guide::startRapidGuide()
{
ISD::CCDChip *targetChip = currentCCD->getChip(useGuideHead ? ISD::CCDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD);
if (currentCCD->setRapidGuide(targetChip, true) == false)
{
appendLogText(i18n("The CCD does not support Rapid Guiding. Aborting..."));
guider->abort();
return;
}
rapidGuideReticleSet = false;
pmath->setRapidGuide(true);
currentCCD->configureRapidGuide(targetChip, true);
connect(currentCCD, SIGNAL(newGuideStarData(ISD::CCDChip*,double,double,double)), this, SLOT(processRapidStarData(ISD::CCDChip*,double,double,double)));
}
void Guide::stopRapidGuide()
{
ISD::CCDChip *targetChip = currentCCD->getChip(useGuideHead ? ISD::CCDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD);
pmath->setRapidGuide(false);
rapidGuideReticleSet = false;
currentCCD->disconnect(SIGNAL(newGuideStarData(ISD::CCDChip*,double,double,double)));
currentCCD->configureRapidGuide(targetChip, false, false, false);
currentCCD->setRapidGuide(targetChip, false);
}
}
#include "guide.moc"
......@@ -62,10 +62,14 @@ public:
double getReticleAngle();
void startRapidGuide();
void stopRapidGuide();
public slots:
void newFITS(IBLOB*);
void newST4(int index);
void processRapidStarData(ISD::CCDChip *targetChip, double dx, double dy, double fit);
bool capture();
void viewerClosed();
......@@ -94,6 +98,7 @@ private:
QStringList logText;
double ccd_hor_pixel, ccd_ver_pixel, focal_length, aperture;
bool rapidGuideReticleSet;
};
......
......@@ -338,9 +338,6 @@ bool cgmath::reset( void )
void cgmath::move_square( double newx, double newy )
{
if (pimage == NULL)
return;
square_pos.x = newx;
square_pos.y = newy;
......@@ -355,7 +352,8 @@ void cgmath::move_square( double newx, double newy )
square_pos.y = (double)(video_height - square_size);
// FITS Image takes center coords
pimage->setGuideSquare(square_pos.x+square_size/2, square_pos.y+square_size/2);
if (pimage)
pimage->setGuideSquare(square_pos.x+square_size/2, square_pos.y+square_size/2);
}
......@@ -369,7 +367,8 @@ void cgmath::resize_square( int size_idx )
square_idx = size_idx;
// check position
pimage->setGuideBoxSize(square_size);
if (pimage)
pimage->setGuideBoxSize(square_size);
// TODO: FIXME
//move_square( square_pos.x, square_pos.y );
......@@ -596,6 +595,11 @@ Vector cgmath::find_star_local_pos( void ) const
float *psrc = NULL, *porigin = NULL;
float *pptr;
if (useRapidGuide)
{
return (ret = Vector(rapidDX , rapidDY, 0));
}
psrc = porigin = pdata + (int)square_pos.y*video_width + (int)square_pos.x;
resx = resy = 0;
......@@ -1024,8 +1028,19 @@ void cgmath::calc_square_err( void )
}
void cgmath::setRapidGuide(bool enable)
{
useRapidGuide = enable;
}
void cgmath::setRapidStarData(double dx, double dy)
{
rapidDX = dx;
rapidDY = dy;
}
......@@ -1076,3 +1091,5 @@ void cproc_out_params::reset( void )
......@@ -144,6 +144,9 @@ public:
ovr_params_t *prepare_overlays( void );
void move_square( double newx, double newy );
void resize_square( int size_idx );
void setRapidGuide(bool enable);
void setRapidStarData(double dx, double dy);
// proc
void start( void );
......@@ -204,6 +207,10 @@ private:
Vector find_star_local_pos( void ) const;
void process_axes( void );
void calc_square_err( void );
// rapid guide
bool useRapidGuide;
double rapidDX, rapidDY;
};
......
......@@ -36,6 +36,8 @@ rguider::rguider(Ekos::Guide *parent)
pimage = NULL;
useRapidGuide = false;
lost_star_try=0;
ui.comboBox_SquareSize->clear();
......@@ -69,6 +71,7 @@ rguider::rguider(Ekos::Guide *parent)
connect( ui.spinBox_MaxPulseDEC, SIGNAL(editingFinished()), this, SLOT(onInputParamChanged()) );
connect( ui.spinBox_MinPulseRA, SIGNAL(editingFinished()), this, SLOT(onInputParamChanged()) );
connect( ui.spinBox_MinPulseDEC, SIGNAL(editingFinished()), this, SLOT(onInputParamChanged()) );
connect( ui.kfcg_useRapidGuide, SIGNAL(toggled(bool)), this, SLOT(onRapidGuideChanged(bool)));
connect(ui.captureB, SIGNAL(clicked()), pmain_wnd, SLOT(capture()));
......@@ -363,6 +366,9 @@ void rguider::onStartStopButtonClick()
pmath->start();
lost_star_try=0;
is_started = true;
if (useRapidGuide)
pmain_wnd->startRapidGuide();
pmain_wnd->capture();
}
// stop
......@@ -373,11 +379,9 @@ void rguider::onStartStopButtonClick()
ui.pushButton_StartStop->setText( i18n("Start Autoguide") );
pmain_wnd->appendLogText(i18n("Autoguiding stopped."));
pmath->stop();
// stop pulses immediately
// if( !DBG_VERBOSITY )
// pmain_wnd->m_driver->reset();
if (useRapidGuide)
pmain_wnd->stopRapidGuide();
is_started = false;
}
......@@ -466,5 +470,37 @@ void rguider::guideStarSelected(int x, int y)
}
void rguider::onRapidGuideChanged(bool enable)
{
if (is_started)
{
pmain_wnd->appendLogText(i18n("You must stop auto guiding before changing this setting."));
return;
}
useRapidGuide = enable;
if (useRapidGuide)
{
pmain_wnd->appendLogText(i18n("Rapid Guiding is enabled. Guide star will be determined automatically by the CCD driver. No frames are sent to Ekos unless explicity enabled by the user in the CCD driver settings."));
}
else
pmain_wnd->appendLogText(i18n("Rapid Guiding is disabled."));
}
void rguider::start()
{
if (is_started == false)
onStartStopButtonClick();
}
void rguider::abort()
{
if (is_started == true)
onStartStopButtonClick();
}
......@@ -30,12 +30,15 @@ public:
~rguider();
void guide( void );
void start();
void abort();
void set_half_refresh_rate( bool is_half );
bool is_guiding( void ) const;
void set_math( cgmath *math );
void fill_interface( void );
void set_image(FITSView *image);
void set_ready(bool enable) { is_ready = enable;}
bool isRapidGuide() { return useRapidGuide;}
protected slots:
void onXscaleChanged( int i );
......@@ -46,6 +49,7 @@ protected slots:
void onEnableDirRA( int state );
void onEnableDirDEC( int state );
void onInputParamChanged();
void onRapidGuideChanged(bool enable);
void guideStarSelected(int x, int y);
......@@ -63,6 +67,7 @@ private:
bool is_ready;
bool half_refresh_rate;
int lost_star_try;
bool useRapidGuide;
......
......@@ -453,40 +453,64 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QPushButton" name="captureB">
<property name="text">
<string>Capture</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pushButton_StartStop">
<property name="text">
<string>Start Autoguide</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QPushButton" name="captureB">
<property name="text">
<string>Capture</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pushButton_StartStop">
<property name="text">
<string>Start Autoguide</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="l_18">
<property name="text">
<string>Square size</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBox_SquareSize"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="l_19">
<property name="text">
<string>Algorithm</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBox_ThresholdAlg"/>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="kfcg_useRapidGuide">
<property name="text">
<string>Use Rapid Guide</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="l_18">
<property name="text">
<string>Square size</string>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBox_SquareSize"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="l_19">
<property name="text">
<string>Algorithm</string>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBox_ThresholdAlg"/>
</spacer>
</item>
</layout>
</item>
......
......@@ -603,6 +603,44 @@ void CCD::processNumber(INumberVectorProperty *nvp)
}
}
if (!strcmp(nvp->name, "CCD_RAPID_GUIDE_DATA"))
{
double dx=-1,dy=-1,fit=-1;
INumber *np=NULL;
np = IUFindNumber(nvp, "GUIDESTAR_X");
if (np)
dx = np->value;
np = IUFindNumber(nvp, "GUIDESTAR_Y");
if (np)
dy = np->value;
np = IUFindNumber(nvp, "GUIDESTAR_FIT");
if (np)
fit = np->value;
if (dx >= 0 && dy >= 0 && fit >= 0)
emit newGuideStarData(primaryChip, dx, dy, fit);
}
if (!strcmp(nvp->name, "GUIDER_RAPID_GUIDE_DATA"))
{
double dx=-1,dy=-1,fit=-1;
INumber *np=NULL;
np = IUFindNumber(nvp, "GUIDESTAR_X");
if (np)
dx = np->value;
np = IUFindNumber(nvp, "GUIDESTAR_Y");
if (np)
dy = np->value;
np = IUFindNumber(nvp, "GUIDESTAR_FIT");
if (np)
fit = np->value;
if (dx >= 0 && dy >= 0 && fit >= 0)
emit newGuideStarData(guideChip, dx, dy, fit);
}
DeviceDecorator::processNumber(nvp);
}
......@@ -891,6 +929,73 @@ CCDChip * CCD::getChip(CCDChip::ChipType cType)
return NULL;
}
bool CCD::setRapidGuide(CCDChip *targetChip, bool enable)
{
ISwitchVectorProperty *rapidSP=NULL;
ISwitch *enableS=NULL;
if (targetChip == primaryChip)
rapidSP = baseDevice->getSwitch("CCD_RAPID_GUIDE");
else
rapidSP = baseDevice->getSwitch("GUIDER_RAPID_GUIDE");
if (rapidSP == NULL)
return false;
enableS = IUFindSwitch(rapidSP, "ENABLE");
if (enableS == NULL)
return false;
// Already updated, return OK
if ((enable && enableS->s == ISS_ON) || (!enable && enableS->s == ISS_OFF))
return true;
IUResetSwitch(rapidSP);
rapidSP->sp[0].s = enable ? ISS_ON : ISS_OFF;
rapidSP->sp[1].s = enable ? ISS_OFF : ISS_ON;
clientManager->sendNewSwitch(rapidSP);
return true;
}
bool CCD::configureRapidGuide(CCDChip *targetChip, bool autoLoop, bool sendImage, bool showMarker)
{
ISwitchVectorProperty *rapidSP=NULL;
ISwitch *autoLoopS=NULL, *sendImageS=NULL, *showMarkerS=NULL;
if (targetChip == primaryChip)
rapidSP = baseDevice->getSwitch("CCD_RAPID_GUIDE_SETUP");
else
rapidSP = baseDevice->getSwitch("GUIDER_RAPID_GUIDE_SETUP");
if (rapidSP == NULL)
return false;
autoLoopS = IUFindSwitch(rapidSP, "AUTO_LOOP" );
sendImageS = IUFindSwitch(rapidSP, "SEND_IMAGE" );
showMarkerS = IUFindSwitch(rapidSP, "SHOW_MARKER" );
if (!autoLoopS || !sendImageS || !showMarkerS)
return false;
// If everything is already set, let's return.
if ( ( (autoLoop && autoLoopS->s == ISS_ON) || (!autoLoop && autoLoopS->s == ISS_OFF) ) &&
( (sendImage && sendImageS->s == ISS_ON) || (!sendImage && sendImageS->s == ISS_OFF) ) &&
( (showMarker && showMarkerS->s == ISS_ON) || (!showMarker && showMarkerS->s == ISS_OFF) ))
return true;
autoLoopS->s = autoLoop ? ISS_ON : ISS_OFF;
sendImageS->s = sendImage ? ISS_ON : ISS_OFF;
showMarkerS->s = showMarker ? ISS_ON : ISS_OFF;
clientManager->sendNewSwitch(rapidSP);
return true;
}
}
......@@ -94,6 +94,8 @@ public:
void setSeqPrefix(const QString &preFix) { seqPrefix = preFix; }
void setSeqCount(int count) { seqCount = count; }
void setFilter(const QString & newFilter) { filter = newFilter;}
bool configureRapidGuide(CCDChip *targetChip, bool autoLoop, bool sendImage=false, bool showMarker=false);
bool setRapidGuide(CCDChip *targetChip, bool enable);
FITSViewer *getViewer() { return fv;}
CCDChip * getChip(CCDChip::ChipType cType);
......@@ -105,6 +107,7 @@ public slots:
signals:
void FITSViewerClosed();
void newExposureValue(ISD::CCDChip *chip, double value);
void newGuideStarData(ISD::CCDChip *chip, double dx, double dy, double fit);
private:
void addFITSKeywords(QString filename);
......
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