Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 52 additions & 6 deletions src/modules/navigator/navigator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,15 @@ void Navigator::OnNewImage()
folders.append("/usr/share/astrometry/");
stellarSolver.setIndexFolderPaths(folders);
stellarSolver.setProperty("UseScale", true);
stellarSolver.setSearchScale(ech * 0.9, ech * 1.1, ScaleUnits::ARCSEC_PER_PIX);
stellarSolver.setSearchScale(ech * 0.8, ech * 1.2, ScaleUnits::ARCSEC_PER_PIX);
stellarSolver.setProperty("UsePosition", true);
stellarSolver.setSearchPositionInDegrees(wra, wde);
stellarSolver.setParameters(StellarSolver::getBuiltInProfiles()[SSolver::Parameters::DEFAULT]);
stellarSolver.setProperty("ProcessType", SOLVE);
stellarSolver.setProperty("ExtractorType", EXTRACTOR_INTERNAL);
stellarSolver.setProperty("SolverType", SOLVER_STELLARSOLVER);
stellarSolver.setLogLevel(LOG_ALL);
stellarSolver.setSSLogLevel(LOG_VERBOSE);
stellarSolver.setLogLevel(LOG_MSG);
stellarSolver.setSSLogLevel(LOG_NORMAL);
stellarSolver.setProperty("LogToFile", true);
stellarSolver.setProperty("LogFileName", getWebroot() + "/navigator_solver.log");
stellarSolver.start();
Expand All @@ -216,6 +216,16 @@ void Navigator::updateProperty(INDI::Property property)
sendWarning("cameraAlert");
emit cameraAlert();
}
if (
(property.getDeviceName() == getString("devices", "mount"))
&& (property.getName() == std::string("EQUATORIAL_EOD_COORD"))
)
{
// Update mount position
INDI::PropertyNumber prop = property;
getEltFloat("mountposition", "RA")->setValue(prop.findWidgetByName("RA")->value, false);
getEltFloat("mountposition", "DEC")->setValue(prop.findWidgetByName("DEC")->value, true);
}
if (
(property.getDeviceName() == getString("devices", "mount"))
&& (property.getName() == std::string("EQUATORIAL_EOD_COORD"))
Expand Down Expand Up @@ -266,7 +276,7 @@ void Navigator::OnSucessSolve()
{
if (stellarSolver.failed())
{
sendError("Image NOT solved - centering aborted");
sendError("Image NOT solved - Centering aborted");
stellarSolver.abort();
getProperty("actions")->setState(OST::Error);
mState = "idle";
Expand All @@ -293,6 +303,7 @@ void Navigator::OnSucessSolve()
sendMessage(QString("Centering successful after %1 iteration(s) - within tolerance")
.arg(mCurrentIteration));
getProperty("actions")->setState(OST::Ok);
syncMountIfNeeded(solvedRA, solvedDEC);
mState = "idle";
mCurrentIteration = 0;
return;
Expand Down Expand Up @@ -458,8 +469,6 @@ void Navigator::correctOffset(double solvedRA, double solvedDEC)
.arg(newDEC, 0, 'f', 2));

// Send corrected position to mount
qDebug() << prop.findWidgetByName("RA")->value << "->" << newRA;
qDebug() << prop.findWidgetByName("DEC")->value << "->" << newDEC;
prop.findWidgetByName("RA")->value = newRA;
prop.findWidgetByName("DEC")->value = newDEC;
mWaitingSlew = true;
Expand All @@ -468,3 +477,40 @@ void Navigator::correctOffset(double solvedRA, double solvedDEC)
// Mount will trigger updateProperty when slew is complete
// which will call Shoot() again for next iteration
}
void Navigator::syncMountIfNeeded(double solvedRA, double solvedDEC)
{

// Get mount device
QString mount = getString("devices", "mount");
INDI::BaseDevice dp = getDevice(mount.toStdString().c_str());
if (!(dp.getDriverInterface() & INDI::BaseDevice::TELESCOPE_INTERFACE))
{
sendError( "Device " + mount + " has no telescope interface");
return;
}

if (!sendModNewSwitch(mount, "ON_COORD_SET", "SYNC", ISS_ON)) return;

INDI::PropertyNumber prop = dp.getProperty("EQUATORIAL_EOD_COORD");
if (!prop.isValid())
{
sendError("Error - unable to find " + mount + " / EQUATORIAL_EOD_COORD property. Aborting.");
return;
}
double jd = ln_get_julian_from_sys();
INDI::IEquatorialCoordinates j2000pos;
INDI::IEquatorialCoordinates observed;
observed.rightascension = solvedRA;
observed.declination = solvedDEC;
INDI::ObservedToJ2000(&observed, jd, &j2000pos);

prop.findWidgetByName("RA")->value = j2000pos.declination;
prop.findWidgetByName("DEC")->value = j2000pos.rightascension;
sendNewNumber(prop);

//restore slew
if (!sendModNewSwitch(mount, "ON_COORD_SET", "SLEW", ISS_ON)) return;

sendMessage("Mount successfully synchronized with solved field");

}
1 change: 1 addition & 0 deletions src/modules/navigator/navigator.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class MODULE_INIT Navigator : public IndiModule
void convertSelection(void);
void correctOffset(double solvedRA, double solvedDEC);
bool checkCentering(double solvedRA, double solvedDEC, double targetRA, double targetDEC);
void syncMountIfNeeded(double solvedRA, double solvedDEC);


QString mState = "idle";
Expand Down
34 changes: 33 additions & 1 deletion src/modules/navigator/navigator.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"group": "",
"permission": 2,
"hasprofile":true,
"rule":0,
"rule":2,
"label": "Centering parameters",
"elements": {
"maxiterations": {
Expand Down Expand Up @@ -35,7 +35,17 @@
"slider":2,
"format":"%.1f",
"hint":"Centering tolerance in arcseconds"
},
"syncafter": {
"autoupdate":true,
"directedit":true,
"type": "bool",
"label": "Sync mount after sucess",
"order": "3",
"value":false,
"hint":"Synchronise mount coordinates after centering"
}

}
},
"search": {
Expand Down Expand Up @@ -198,6 +208,28 @@
]
}
}
},
"mountposition": {
"devcat": "Control",
"order": "Control0000",
"group": "",
"permission": 0,
"rule":0,
"label": "Mount position",
"elements": {
"RA": {
"type": "float",
"label": "RA",
"order": "10",
"value": 0.0
},
"DEC": {
"type": "float",
"label": "DEC",
"order": "20",
"value": 0.0
}
}
}
}
}