Ejemplo n.º 1
0
bool StepGuider::BeginCalibration(const PHD_Point& currentLocation)
{
    bool bError = false;

    try
    {
        if (!IsConnected())
        {
            throw ERROR_INFO("Not connected");
        }

        if (!currentLocation.IsValid())
        {
            throw ERROR_INFO("Must have a valid start position");
        }

        ClearCalibration();
        m_calibrationState = CALIBRATION_STATE_GOTO_LOWER_RIGHT_CORNER;
        m_calibrationStartingLocation.Invalidate();
        m_calibrationDetails.raSteps.clear();
        m_calibrationDetails.decSteps.clear();
    }
    catch (wxString Msg)
    {
        POSSIBLY_UNUSED(Msg);
        bError = true;
    }

    return bError;
}
Ejemplo n.º 2
0
void GuidingLog::NotifyLockShiftParams(const LockPosShiftParams& shiftParams, const PHD_Point& cameraRate)
{
    if (!m_enabled || !m_isGuiding)
        return;

    wxString details;
    if (shiftParams.shiftEnabled)
    {
        details = wxString::Format("%s rate (%.2f,%.2f) %s/hr (%.2f,%.2f) px/hr",
                                    shiftParams.shiftIsMountCoords ? "RA,Dec" : "X,Y",
                                    shiftParams.shiftRate.IsValid() ? shiftParams.shiftRate.X : 0.0,
                                    shiftParams.shiftRate.IsValid() ? shiftParams.shiftRate.Y : 0.0,
                                    shiftParams.shiftUnits == UNIT_ARCSEC ? "arc-sec" : "pixels",
                                    cameraRate.IsValid() ? cameraRate.X * 3600.0 : 0.0,
                                    cameraRate.IsValid() ? cameraRate.Y * 3600.0 : 0.0);
    }
    m_file.Write(wxString::Format("INFO: LOCK SHIFT, enabled = %d %s\n", shiftParams.shiftEnabled, details));
    m_keepFile = true;
    Flush();
}
Ejemplo n.º 3
0
bool GuiderOneStar::SetCurrentPosition(usImage *pImage, const PHD_Point& position)
{
    bool bError = true;

    try
    {
        if (!position.IsValid())
        {
            throw ERROR_INFO("position is invalid");
        }

        double x = position.X;
        double y = position.Y;

        Debug.AddLine(wxString::Format("SetCurrentPosition(%.2f,%.2f)", x, y ));

        if ((x <= 0) || (x >= pImage->Size.x))
        {
            throw ERROR_INFO("invalid x value");
        }

        if ((y <= 0) || (y >= pImage->Size.y))
        {
            throw ERROR_INFO("invalid y value");
        }

        m_massChecker->Reset();
        bError = !m_star.Find(pImage, m_searchRegion, x, y, pFrame->GetStarFindMode());
    }
    catch (wxString Msg)
    {
        POSSIBLY_UNUSED(Msg);
    }

    return bError;
}
Ejemplo n.º 4
0
Mount::MOVE_RESULT StepGuider::Move(const PHD_Point& cameraVectorEndpoint, bool normalMove)
{
    MOVE_RESULT result = MOVE_OK;

    try
    {
        MOVE_RESULT mountResult = Mount::Move(cameraVectorEndpoint, normalMove);
        if (mountResult != MOVE_OK)
            Debug.AddLine("StepGuider::Move: Mount::Move failed!");

        if (!m_guidingEnabled)
        {
            throw THROW_INFO("Guiding disabled");
        }

        // keep a moving average of the AO position
        if (m_avgOffset.IsValid())
        {
            static double const alpha = .33; // moderately high weighting for latest sample
            m_avgOffset.X += alpha * (m_xOffset - m_avgOffset.X);
            m_avgOffset.Y += alpha * (m_yOffset - m_avgOffset.Y);
        }
        else
        {
            m_avgOffset.SetXY((double) m_xOffset, (double) m_yOffset);
        }

        pFrame->pStepGuiderGraph->AppendData(m_xOffset, m_yOffset, m_avgOffset);

        // consider bumping the secondary mount if this is a normal move
        if (normalMove && pSecondaryMount && pSecondaryMount->IsConnected())
        {
            int absX = abs(CurrentPosition(RIGHT));
            int absY = abs(CurrentPosition(UP));
            bool isOutside = absX > m_xBumpPos1 || absY > m_yBumpPos1;
            bool forceStartBump = false;
            if (m_forceStartBump)
            {
                Debug.Write("stepguider::Move: will start forced bump\n");
                forceStartBump = true;
                m_forceStartBump = false;
            }

            // if the current bump has not brought us in, increase the bump size
            if (isOutside && m_bumpInProgress)
            {
                if (absX > m_xBumpPos2 || absY > m_yBumpPos2)
                {
                    Debug.AddLine("FAR outside bump range, increase bump weight %.2f => %.2f", m_bumpStepWeight, m_bumpStepWeight + 1.0);
                    m_bumpStepWeight += 1.0;
                }
                else
                {
                    Debug.AddLine("outside bump range, increase bump weight %.2f => %.2f", m_bumpStepWeight, m_bumpStepWeight + 1./6.);
                    m_bumpStepWeight += 1./6.;
                }
            }

            // if we are back inside, decrease the bump weight
            if (!isOutside && m_bumpStepWeight > 1.0)
            {
                double prior = m_bumpStepWeight;
                m_bumpStepWeight *= 0.5;
                if (m_bumpStepWeight < 1.0)
                    m_bumpStepWeight = 1.0;
                Debug.AddLine("back inside bump range: decrease bump weight %.2f => %.2f", prior, m_bumpStepWeight);
            }

            if (m_bumpInProgress && !m_bumpTimeoutAlertSent)
            {
                long now = ::wxGetUTCTime();
                if (now - m_bumpStartTime > BumpWarnTime)
                {
                    pFrame->Alert(_("A mount \"bump\" was needed to bring the AO back to its center position,\n"
                        "but the bump did not complete in a reasonable amount of time.\n"
                        "You probably need to increase the AO Bump Step setting."), wxICON_INFORMATION);
                    m_bumpTimeoutAlertSent = true;
                }
            }

            if ((isOutside || forceStartBump) && !m_bumpInProgress)
            {
                // start a new bump
                m_bumpInProgress = true;
                m_bumpStartTime = ::wxGetUTCTime();
                m_bumpTimeoutAlertSent = false;

                Debug.AddLine("starting a new bump");
            }

            // stop the bump if we are "close enough" to the center position
            if ((!isOutside || forceStartBump) && m_bumpInProgress)
            {
                int minDist = m_bumpCenterTolerance;
                if (m_avgOffset.X * m_avgOffset.X + m_avgOffset.Y * m_avgOffset.Y <= minDist * minDist)
                {
                    Debug.AddLine("Stop bumping, close enough to center -- clearing m_bumpInProgress");
                    m_bumpInProgress = false;
                    pFrame->pStepGuiderGraph->ShowBump(PHD_Point());
                }
            }
        }

        if (m_bumpInProgress && pSecondaryMount->IsBusy())
            Debug.AddLine("secondary mount is busy, cannot bump");

        // if we have a bump in progress and the secondary mount is not moving,
        // schedule another move
        if (m_bumpInProgress && !pSecondaryMount->IsBusy())
        {
            // compute incremental bump based on average position
            PHD_Point vectorEndpoint(xRate() * -m_avgOffset.X, yRate() * -m_avgOffset.Y);

            // we have to transform our notion of where we are (which is in "AO Coordinates")
            // into "Camera Coordinates" so we can bump the secondary mount to put us closer
            // to the center of the AO

            PHD_Point bumpVec;

            if (TransformMountCoordinatesToCameraCoordinates(vectorEndpoint, bumpVec))
            {
                throw ERROR_INFO("MountToCamera failed");
            }

            Debug.AddLine("incremental bump (%.3f, %.3f) isValid = %d", bumpVec.X, bumpVec.Y, bumpVec.IsValid());

            double maxBumpPixelsX = m_calibration.xRate * m_bumpMaxStepsPerCycle * m_bumpStepWeight;
            double maxBumpPixelsY = m_calibration.yRate * m_bumpMaxStepsPerCycle * m_bumpStepWeight;
            double len = bumpVec.Distance();
            double xBumpSize = bumpVec.X * maxBumpPixelsX / len;
            double yBumpSize = bumpVec.Y * maxBumpPixelsY / len;

            PHD_Point thisBump(xBumpSize, yBumpSize);

            // display the current bump vector on the stepguider graph
            {
                PHD_Point tcur;
                TransformCameraCoordinatesToMountCoordinates(thisBump, tcur);
                tcur.X /= xRate();
                tcur.Y /= yRate();
                pFrame->pStepGuiderGraph->ShowBump(tcur);
            }

            Debug.AddLine("Scheduling Mount bump of (%.3f, %.3f)", thisBump.X, thisBump.Y);

            pFrame->ScheduleSecondaryMove(pSecondaryMount, thisBump, false);
        }
    }
    catch (wxString Msg)
    {
        POSSIBLY_UNUSED(Msg);
        result = MOVE_ERROR;
    }

    return result;
}