diff options
author | Your Name <you@example.com> | 2023-01-28 13:22:41 +0000 |
---|---|---|
committer | Your Name <you@example.com> | 2023-01-28 13:22:41 +0000 |
commit | 5c0ead2447835109417269372bf365873b358e35 (patch) | |
tree | aa60567acec5043109b6335203d37f0efe2b1432 /indi-celestronaux/celestronaux.cpp | |
parent | b0f53621f469b655666d9405bd9bbce710821a46 (diff) | |
download | indi_mount_driver-5c0ead2447835109417269372bf365873b358e35.tar.gz indi_mount_driver-5c0ead2447835109417269372bf365873b358e35.tar.bz2 indi_mount_driver-5c0ead2447835109417269372bf365873b358e35.zip |
wip
Diffstat (limited to 'indi-celestronaux/celestronaux.cpp')
-rw-r--r-- | indi-celestronaux/celestronaux.cpp | 232 |
1 files changed, 140 insertions, 92 deletions
diff --git a/indi-celestronaux/celestronaux.cpp b/indi-celestronaux/celestronaux.cpp index a806fcd..51583ad 100644 --- a/indi-celestronaux/celestronaux.cpp +++ b/indi-celestronaux/celestronaux.cpp @@ -32,12 +32,10 @@ #include <sys/ioctl.h> #include <thread> #include <chrono> -extern "C" { -#include <syslog.h> -} #include <alignment/DriverCommon.h> #include "celestronaux.h" +#include "syslog_proxy.h" #include "config.h" #define DEBUG_PID @@ -81,7 +79,7 @@ CelestronAUX::CelestronAUX() //Both communication available, Serial and network (tcp/ip). setTelescopeConnection(CONNECTION_TCP | CONNECTION_SERIAL); - openlog("indi_celestron_aux",0,LOG_DAEMON); + openlog_proxy("indi_celestron_aux"); } ///////////////////////////////////////////////////////////////////////////////////// @@ -240,6 +238,20 @@ bool CelestronAUX::initProperties() SetTelescopeCapability(GetTelescopeCapability() | TELESCOPE_HAS_PIER_SIDE, 8); } + MountTypeSP[EQUATORIAL].fill("EQUATORIAL", "Equatorial", configMountType == EQUATORIAL ? ISS_ON : ISS_OFF); + MountTypeSP[ALTAZ].fill("ALTAZ", "AltAz", configMountType == ALTAZ ? ISS_ON : ISS_OFF); + MountTypeSP.fill(getDeviceName(), "MOUNT_TYPE", "Mount Type", MAIN_CONTROL_TAB, IP_RW, ISR_1OFMANY, 60, IPS_IDLE); + + TrackMethodSP[TRACK_METHOD_NONE].fill("NONE", "None", ISS_OFF); + TrackMethodSP[TRACK_METHOD_MOUNT].fill("MOUNT", "Mount", ISS_OFF); + TrackMethodSP[TRACK_METHOD_DRIVER].fill("DRIVER", "Driver", ISS_ON); + TrackMethodSP.fill(getDeviceName(), "TRACK_METHOD", "Tracking Method", MAIN_CONTROL_TAB, IP_RW, ISR_1OFMANY, 60, IPS_IDLE); + + DriverTrackMethodSP[TRACK_METHOD_UNALIGNED].fill("DUMB", "Unaligned", ISS_OFF); + DriverTrackMethodSP[TRACK_METHOD_ALIGNED].fill("RADEC", "Aligned", ISS_ON); + DriverTrackMethodSP[TRACK_METHOD_ALIGNED_RA_ONLY].fill("RAONLY", "Aligned RA Only", ISS_OFF); + DriverTrackMethodSP.fill(getDeviceName(), "DRIVER_TRACK_METHOD", "Driver Tracking Method", MAIN_CONTROL_TAB, IP_RW, ISR_1OFMANY, 60, IPS_IDLE); + // Horizontal Coords HorizontalCoordsNP[AXIS_AZ].fill("AZ", "Az D:M:S", "%10.6m", 0.0, 360.0, 0.0, 0); HorizontalCoordsNP[AXIS_ALT].fill("ALT", "Alt D:M:S", "%10.6m", -90., 90.0, 0.0, 0); @@ -400,6 +412,9 @@ bool CelestronAUX::updateProperties() defineProperty(&HorizontalCoordsNP); defineProperty(&HomeSP); + defineProperty(&TrackMethodSP); + defineProperty(&DriverTrackMethodSP); + // Guide defineProperty(&GuideNSNP); defineProperty(&GuideWENP); @@ -475,6 +490,9 @@ bool CelestronAUX::updateProperties() deleteProperty(HorizontalCoordsNP.getName()); deleteProperty(HomeSP.getName()); + deleteProperty(DriverTrackMethodSP.getName()); + deleteProperty(TrackMethodSP.getName()); + deleteProperty(GuideNSNP.name); deleteProperty(GuideWENP.name); deleteProperty(GuideRateNP.getName()); @@ -517,6 +535,8 @@ bool CelestronAUX::saveConfigItems(FILE *fp) IUSaveConfigSwitch(fp, &CordWrapPositionSP); IUSaveConfigSwitch(fp, &CordWrapBaseSP); IUSaveConfigSwitch(fp, &GPSEmuSP); + IUSaveConfigSwitch(fp, &TrackMethodSP); + IUSaveConfigSwitch(fp, &DriverTrackMethodSP); if (MountTypeSP[ALTAZ].getState() == ISS_ON) { @@ -762,6 +782,25 @@ bool CelestronAUX::ISNewSwitch(const char *dev, const char *name, ISState *state return true; } + // Tracking Method Emulation + if (TrackMethodSP.isNameMatch(name)) + { + TrackMethodSP.update(states, names, n); + TrackMethodSP.setState(IPS_OK); + TrackMethodSP.apply(); + return true; + } + + // Tracking Method Emulation + if (DriverTrackMethodSP.isNameMatch(name)) + { + DriverTrackMethodSP.update(states, names, n); + DriverTrackMethodSP.setState(IPS_OK); + DriverTrackMethodSP.apply(); + return true; + } + + // GPS Emulation if (GPSEmuSP.isNameMatch(name)) { @@ -1171,9 +1210,11 @@ bool CelestronAUX::ReadScopeStatus() TrackState = SCOPE_TRACKING; resetTracking(); + // For equatorial mounts, engage tracking. - if (MountTypeSP[EQUATORIAL].getState() == ISS_ON) - SetTrackMode(IUFindOnSwitchIndex(&TrackModeSP)); + if ((TrackMethodSP[TRACK_METHOD_MOUNT].getState() == ISS_ON) && \ + (MountTypeSP[EQUATORIAL].getState() == ISS_ON)) + SetTrackMode(IUFindOnSwitchIndex(&TrackModeSP)); LOG_INFO("Tracking started."); } else @@ -1450,6 +1491,60 @@ bool CelestronAUX::mountToSkyCoords() return true; } +void CelestronAUX::calculate_tracking_vector(double &mt_ra, double &mt_dec) +{ + double delta = 1./3600.; + double ra1 = m_SkyTrackingTarget.rightascension; + double ra2 = ra1 + delta; + double dec= m_SkyTrackingTarget.declination; + + TelescopeDirectionVector TDV; + INDI::IEquatorialCoordinates m1 { ra1, dec }; + INDI::IEquatorialCoordinates m2 { ra2, dec }; + + + if (DriverTrackMethodSP[TRACK_METHOD_UNALIGNED].getState() == ISS_OFF) { + if (TransformCelestialToTelescope(ra1, dec, 0.0, TDV)) + { + EquatorialCoordinatesFromTelescopeDirectionVector(TDV, m1); + } + + + if (TransformCelestialToTelescope(ra2, dec, 0.0, TDV)) + { + EquatorialCoordinatesFromTelescopeDirectionVector(TDV, m2); + } + } + + double r_ra = (m2.rightascension - m1.rightascension) / delta; + double r_dec = (m2.declination - m1.declination) / delta; + + uint32_t e1[2]; + CelestronAUX::RADEToEncoders(m1,e1[0],e1[1]); + + uint32_t e2[2]; + CelestronAUX::RADEToEncoders(m2,e2[0],e2[1]); + + int d_a1 = e2[0] - e1[0]; + int d_a2 = e2[1] - e1[1]; + + r_ra *= TRACKRATE_SIDEREAL; + r_dec *= TRACKRATE_SIDEREAL * (24. / 360.); + + mt_ra = std::abs(r_ra); + mt_dec = std::abs(r_dec); + + if (d_a1>0) + mt_ra = -mt_ra; + if (d_a2>0) + mt_dec = -mt_dec; + + if (DriverTrackMethodSP[TRACK_METHOD_ALIGNED_RA_ONLY].getState() == ISS_ON) + mt_dec = 0; + + syslog_proxy("sidereal tracking vectors RA %.4e DEC %.4e -> mount %.4e %.4e", r_ra, r_dec, mt_ra, mt_dec); +} + ///////////////////////////////////////////////////////////////////////////////////// /// ///////////////////////////////////////////////////////////////////////////////////// @@ -1457,7 +1552,7 @@ void CelestronAUX::TimerHit() { INDI::Telescope::TimerHit(); -syslog(LOG_ERR,"Timer hit state=%d",(int)TrackState); + syslog_proxy("Timer hit state = %d",(int)TrackState); switch (TrackState) { @@ -1572,79 +1667,27 @@ syslog(LOG_ERR,"Timer hit state=%d",(int)TrackState); #endif trackByRate(AXIS_ALT, trackRates[AXIS_ALT]); } - } else { - double delta=1./3600.; + } else if (TrackMethodSP[TRACK_METHOD_DRIVER].getState() == ISS_ON) { + double r_ra, r_dec; - double ra1 = m_SkyTrackingTarget.rightascension; - double ra2=ra1+delta; - double dec= m_SkyTrackingTarget.declination; + calculate_tracking_vector(r_ra, r_dec); - - -/* - - INDI::IEquatorialCoordinates m1; - if (!SkyToTelescopeEquatorial(ra1,dec,m1.rightascension,m1.declination)) { - m1.rightascension=ra1; - m1.declination=dec; - } - - uint32_t e1[2]; - CelestronAUX::RADEToEncoders(m1,e1[0],e1[1]); - - INDI::IEquatorialCoordinates m2; - if (!SkyToTelescopeEquatorial(ra2,dec,m2.rightascension,m2.declination)) { - m2.rightascension=ra2; - m2.declination=dec; + if ((TrackRateN[AXIS_AZ].value != r_ra) || (TrackRateN[AXIS_ALT].value != r_dec)) { + TrackRateN[AXIS_AZ].value = r_ra; + TrackRateN[AXIS_ALT].value = r_dec; + IDSetNumber(&TrackRateNP, nullptr); } - uint32_t e2[2]; - CelestronAUX::RADEToEncoders(m2,e2[0],e2[1]); -*/ - - - - TelescopeDirectionVector TDV; - INDI::IEquatorialCoordinates m1 { ra1, dec }; - - if (TransformCelestialToTelescope(ra1, dec, 0.0, TDV)) - { - EquatorialCoordinatesFromTelescopeDirectionVector(TDV, m1); - } - uint32_t e1[2]; - CelestronAUX::RADEToEncoders(m1,e1[0],e1[1]); - - INDI::IEquatorialCoordinates m2 { ra2, dec }; - - if (TransformCelestialToTelescope(ra2, dec, 0.0, TDV)) - { - EquatorialCoordinatesFromTelescopeDirectionVector(TDV, m2); - } - uint32_t e2[2]; - CelestronAUX::RADEToEncoders(m2,e2[0],e2[1]); - - double r_ra=(m2.rightascension-m1.rightascension)/delta; - double r_dec=(m2.declination-m1.declination)/delta; - - syslog(LOG_ERR,"tracking vectors %.4e %.4e",r_ra,r_dec); - - int d_a1=e2[0]-e1[0]; - int d_a2=e2[1]-e1[1]; - - syslog(LOG_ERR,"tracking e vectors %d %d",d_a1,d_a2); - r_ra*=TRACKRATE_SIDEREAL; - r_dec*=TRACKRATE_SIDEREAL*(24./360.); - r_dec=0; - - r_ra=std::abs(r_ra); - r_dec=std::abs(r_dec); - - syslog(LOG_ERR,"tracking %.4e %.4e",r_ra,r_dec); - if (d_a1>0) r_ra=-r_ra; - if (d_a2>0) r_dec=-r_dec; - - CelestronAUX::SetTrackRate(r_ra,r_dec); +#if 0 + if (IUFindOnSwitchIndex(&TrackModeSP) != TRACK_CUSTOM) { + IUResetSwitch(&TrackModeSP); + TrackModeS[TRACK_CUSTOM].s=ISS_ON; + TrackModeSP.s = IPS_ALERT; + IDSetSwitch(&TrackModeSP, nullptr); + } +#endif + CelestronAUX::SetTrackRate(r_ra, r_dec); } } break; @@ -2175,10 +2218,12 @@ bool CelestronAUX::SetTrackEnabled(bool enabled) m_SkyTrackingTarget.rightascension = EqN[AXIS_RA].value; m_SkyTrackingTarget.declination = EqN[AXIS_DE].value; - if (IUFindOnSwitchIndex(&TrackModeSP) == TRACK_CUSTOM) - return SetTrackRate(TrackRateN[AXIS_AZ].value, TrackRateN[AXIS_ALT].value); - else - return SetTrackMode(IUFindOnSwitchIndex(&TrackModeSP)); + if (TrackMethodSP[TRACK_METHOD_MOUNT].getState() == ISS_ON) { + if (IUFindOnSwitchIndex(&TrackModeSP) == TRACK_CUSTOM) + return SetTrackRate(TrackRateN[AXIS_AZ].value, TrackRateN[AXIS_ALT].value); + else + return SetTrackMode(IUFindOnSwitchIndex(&TrackModeSP)); + } } else { @@ -2211,6 +2256,7 @@ bool CelestronAUX::SetTrackRate(double raRate, double deRate) // rate = (steps) * gain steps[AXIS_AZ] = raRate * STEPS_PER_ARCSEC * GAIN_STEPS; steps[AXIS_ALT] = deRate * STEPS_PER_ARCSEC * GAIN_STEPS; + syslog_proxy("CelestronAUX::trackByRate %.2f %.2f", steps[AXIS_AZ], step[AXIS_ALT]); trackByRate(AXIS_AZ, steps[AXIS_AZ]); trackByRate(AXIS_ALT, steps[AXIS_ALT]); } @@ -2222,9 +2268,6 @@ bool CelestronAUX::SetTrackRate(double raRate, double deRate) ///////////////////////////////////////////////////////////////////////////// bool CelestronAUX::SetTrackMode(uint8_t mode) { - - return true; - if (mode == TRACK_SIDEREAL) m_TrackRates[AXIS_AZ] = TRACKRATE_SIDEREAL; else if (mode == TRACK_SOLAR) @@ -2239,17 +2282,22 @@ bool CelestronAUX::SetTrackMode(uint8_t mode) if (TrackState == SCOPE_TRACKING) { - if (mode == TRACK_CUSTOM) - { - double steps[2] = {0, 0}; - // rate = (steps) * gain - steps[AXIS_AZ] = m_TrackRates[AXIS_AZ] * STEPS_PER_ARCSEC * GAIN_STEPS; - steps[AXIS_ALT] = m_TrackRates[AXIS_ALT] * STEPS_PER_ARCSEC * GAIN_STEPS; - trackByRate(AXIS_AZ, steps[AXIS_AZ]); - trackByRate(AXIS_ALT, steps[AXIS_ALT]); + if (TrackMethodSP[TRACK_METHOD_MOUNT].getState() == ISS_ON) { + if (mode == TRACK_CUSTOM) + { + double steps[2] = {0, 0}; + // rate = (steps) * gain + steps[AXIS_AZ] = m_TrackRates[AXIS_AZ] * STEPS_PER_ARCSEC * GAIN_STEPS; + steps[AXIS_ALT] = m_TrackRates[AXIS_ALT] * STEPS_PER_ARCSEC * GAIN_STEPS; + syslog_proxy("CelestronAUX::trackByRate %.2f %.2f", steps[AXIS_AZ], step[AXIS_ALT]); + trackByRate(AXIS_AZ, steps[AXIS_AZ]); + trackByRate(AXIS_ALT, steps[AXIS_ALT]); + } + else { + syslog_proxy("CelestronAUX::trackByMode %d", mode); + trackByMode(AXIS_AZ, mode); + } } - else - trackByMode(AXIS_AZ, mode); } return true; |