...
This commit is contained in:
parent
de80acf315
commit
fe6492e4fc
@ -70,7 +70,8 @@ include_directories(${BSPLINES_INCLUDE_DIR})
|
|||||||
set(MCC_LIBRARY_SRC1 mcc_generics.h mcc_defaults.h mcc_traits.h mcc_utils.h
|
set(MCC_LIBRARY_SRC1 mcc_generics.h mcc_defaults.h mcc_traits.h mcc_utils.h
|
||||||
mcc_ccte_iers.h mcc_ccte_iers_default.h mcc_ccte_erfa.h mcc_pcm.h mcc_telemetry.h
|
mcc_ccte_iers.h mcc_ccte_iers_default.h mcc_ccte_erfa.h mcc_pcm.h mcc_telemetry.h
|
||||||
mcc_angle.h mcc_pzone.h mcc_pzone_container.h mcc_finite_state_machine.h
|
mcc_angle.h mcc_pzone.h mcc_pzone_container.h mcc_finite_state_machine.h
|
||||||
mcc_generic_mount.h mcc_tracking_model.h)
|
mcc_generic_mount.h mcc_tracking_model.h mcc_slewing_model.h mcc_guiding_model.h
|
||||||
|
mcc_moving_model_common.h)
|
||||||
|
|
||||||
list(APPEND MCC_LIBRARY_SRC1 mcc_spdlog.h)
|
list(APPEND MCC_LIBRARY_SRC1 mcc_spdlog.h)
|
||||||
|
|
||||||
|
|||||||
@ -137,6 +137,12 @@ typedef MccGenericTelemetryData<MccCelestialPoint::coord_t> MccTelemetryData;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template <mcc_ccte_c CCTE_T, mcc_hardware_c HARDWARE_T, mcc_PCM_c PCM_T>
|
||||||
|
struct MccPositionControls : CCTE_T, HARDWARE_T, PCM_T {
|
||||||
|
virtual ~MccPositionControls() = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* JUST CHECK FOR CONCEPT CONSISTENCY */
|
/* JUST CHECK FOR CONCEPT CONSISTENCY */
|
||||||
|
|
||||||
static_assert(mcc_julday_c<MccJulianDay>, "");
|
static_assert(mcc_julday_c<MccJulianDay>, "");
|
||||||
|
|||||||
@ -19,6 +19,8 @@
|
|||||||
namespace mcc
|
namespace mcc
|
||||||
{
|
{
|
||||||
|
|
||||||
|
static constexpr double mcc_sideral_to_UT1_ratio = 1.002737909350795; // sideral/UT1
|
||||||
|
|
||||||
|
|
||||||
// mount construction type (only the most common ones)
|
// mount construction type (only the most common ones)
|
||||||
enum class MccMountType : uint8_t { GERMAN_TYPE, FORK_TYPE, CROSSAXIS_TYPE, ALTAZ_TYPE };
|
enum class MccMountType : uint8_t { GERMAN_TYPE, FORK_TYPE, CROSSAXIS_TYPE, ALTAZ_TYPE };
|
||||||
@ -879,56 +881,18 @@ concept mcc_guiding_model_c = requires(T t) {
|
|||||||
/* GENERIC MOUNT CLASS CONCEPT */
|
/* GENERIC MOUNT CLASS CONCEPT */
|
||||||
|
|
||||||
|
|
||||||
|
// a class containing mount position related controls
|
||||||
|
template <typename T>
|
||||||
|
concept mcc_position_controls_c = mcc_ccte_c<T> && mcc_hardware_c<T> && mcc_PCM_c<T>;
|
||||||
|
|
||||||
// template <mcc_error_c RetT, typename StopReasonT>
|
// a class containing full set of mount controls
|
||||||
// struct mcc_generic_mount_interface_t {
|
template <typename T>
|
||||||
// virtual ~mcc_generic_mount_interface_t() = default;
|
concept mcc_all_controls_c = mcc_position_controls_c<T> && mcc_telemetry_c<T> && mcc_pzone_container_c<T>;
|
||||||
|
|
||||||
// // slew mount to target (target coordinates were defined in telemetry data)
|
|
||||||
// template <std::derived_from<mcc_generic_mount_interface_t> SelfT>
|
|
||||||
// RetT slewToTarget(this SelfT&& self, mcc_slewing_model_c auto model)
|
|
||||||
// {
|
|
||||||
// return std::forward<SelfT>(self).slewToTarget(std::move(model));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // track target, i.e., the mount moves with celestial speed
|
|
||||||
// template <std::derived_from<mcc_generic_mount_interface_t> SelfT>
|
|
||||||
// RetT trackTarget(this SelfT&& self, mcc_tracking_model_c auto model)
|
|
||||||
// {
|
|
||||||
// return std::forward<SelfT>(self).trackTarget(std::move(model));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// template <std::derived_from<mcc_generic_mount_interface_t> SelfT>
|
|
||||||
// RetT startGuidingTarget(this SelfT&& self, mcc_guiding_model_c auto model)
|
|
||||||
// {
|
|
||||||
// return std::forward<SelfT>(self).startGuidingTarget(std::move(model));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// template <std::derived_from<mcc_generic_mount_interface_t> SelfT>
|
|
||||||
// RetT stopGuidingTarget(this SelfT&& self)
|
|
||||||
// {
|
|
||||||
// return std::forward<SelfT>(self).stopGuidingTarget();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// template <std::derived_from<mcc_generic_mount_interface_t> SelfT>
|
|
||||||
// RetT stopMount(this SelfT&& self, StopReasonT reason)
|
|
||||||
// {
|
|
||||||
// return std::forward<SelfT>(self).stopMount(std::move(reason));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// protected:
|
|
||||||
// mcc_generic_mount_interface_t() = default;
|
|
||||||
// };
|
|
||||||
|
|
||||||
|
|
||||||
// template<typename T>
|
|
||||||
// concept mcc_generic_mount_c
|
|
||||||
// = std::derived_from<T, mcc_generic_mount_interface_t<typename T::error_t, typename T::stop_reason_t>>
|
|
||||||
// && mcc_telemetry_c<T> && mcc_pzone_container_c<T>;
|
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept mcc_generic_mount_c = mcc_hardware_c<T> && mcc_telemetry_c<T> && mcc_pzone_container_c<T> && requires(T t) {
|
concept mcc_generic_mount_c = mcc_telemetry_c<T> && mcc_pzone_container_c<T> && requires(T t) {
|
||||||
requires mcc_error_c<typename T::error_t>;
|
requires mcc_error_c<typename T::error_t>;
|
||||||
|
|
||||||
// slew mount to target (target coordinates were defined in telemetry data)
|
// slew mount to target (target coordinates were defined in telemetry data)
|
||||||
|
|||||||
@ -54,74 +54,89 @@ public:
|
|||||||
typedef MccSimpleMovingModelParams guiding_params_t;
|
typedef MccSimpleMovingModelParams guiding_params_t;
|
||||||
|
|
||||||
|
|
||||||
template <mcc_telemetry_data_c TelemetryT,
|
template <mcc_all_controls_c CONTROLS_T>
|
||||||
mcc_hardware_c HardwareT,
|
MccSimpleGuidingModel(CONTROLS_T* controls)
|
||||||
mcc_PCM_c PcmT,
|
|
||||||
mcc_pzone_container_c PZoneContT>
|
|
||||||
MccSimpleGuidingModel(TelemetryT* telemetry, HardwareT* hardware, PcmT* pcm, PZoneContT* pz_cont)
|
|
||||||
: _stopGuiding(new std::atomic_bool()), _currentParamsMutex(new std::mutex())
|
: _stopGuiding(new std::atomic_bool()), _currentParamsMutex(new std::mutex())
|
||||||
{
|
{
|
||||||
_guidingFunc = [telemetry, hardware, pcm, pz_cont, this]() -> error_t {
|
_guidingFunc = [controls, this]() -> error_t {
|
||||||
typename HardwareT::hardware_state_t hw_state;
|
typename CONTROLS_T::hardware_state_t hw_state;
|
||||||
|
|
||||||
MccTelemetryData tdata;
|
MccTelemetryData tdata;
|
||||||
MccEqtHrzCoords intsc_coords;
|
MccEqtHrzCoords intsc_coords;
|
||||||
double dist;
|
double dist, dx, dy;
|
||||||
|
|
||||||
auto t_err = telemetry->waitForTelemetryData(&tdata, _currentParams.telemetryTimeout);
|
auto t_err = controls->telemetryData(&tdata);
|
||||||
if (t_err) {
|
if (t_err) {
|
||||||
return mcc_deduce_error<error_t>(t_err, MccSimpleGuidingModelErrorCode::ERROR_GET_TELEMETRY);
|
return mcc_deduce_error<error_t>(t_err, MccSimpleGuidingModelErrorCode::ERROR_GET_TELEMETRY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// compute intersection points with the prohibited zones
|
bool no_intersects = false;
|
||||||
auto pz_err = mcc_find_closest_pzone(pz_cont, tdata, &intsc_coords);
|
|
||||||
|
// function to update the closest prohibited zone intersect point
|
||||||
|
auto update_pzones_ipoint = [controls, &tdata, &intsc_coords, &no_intersects, &hw_state,
|
||||||
|
this]() -> error_t {
|
||||||
|
// compute intersection points with the prohibited zones
|
||||||
|
auto pz_err = mcc_find_closest_pzone(controls, tdata, &intsc_coords);
|
||||||
|
if (pz_err) {
|
||||||
|
return mcc_deduce_error<error_t>(pz_err,
|
||||||
|
MccSimpleGuidingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
||||||
|
}
|
||||||
|
|
||||||
|
if constexpr (mccIsEquatorialMount(CONTROLS_T::mountType)) {
|
||||||
|
if (std::isfinite(intsc_coords.HA)) {
|
||||||
|
intsc_coords.X = intsc_coords.HA;
|
||||||
|
intsc_coords.Y = intsc_coords.DEC_APP;
|
||||||
|
} else {
|
||||||
|
no_intersects = true;
|
||||||
|
intsc_coords.X = tdata.HA + 710.0_mins; // 12h - 10min
|
||||||
|
intsc_coords.Y = tdata.DEC_APP;
|
||||||
|
}
|
||||||
|
} else if constexpr (mccIsAltAzMount(CONTROLS_T::mountType)) {
|
||||||
|
if (std::isfinite(intsc_coords.AZ)) {
|
||||||
|
intsc_coords.X = intsc_coords.AZ;
|
||||||
|
intsc_coords.Y = intsc_coords.ZD;
|
||||||
|
} else {
|
||||||
|
no_intersects = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
static_assert(false, "UNKNOW MOUNT TYPE!");
|
||||||
|
}
|
||||||
|
|
||||||
|
MccPCMResult pcm_inv_res;
|
||||||
|
|
||||||
|
// endpoint of the mount moving
|
||||||
|
auto pcm_err = controls->computeInversePCM(intsc_coords, &pcm_inv_res, &hw_state);
|
||||||
|
if (pcm_err) {
|
||||||
|
return mcc_deduce_error<error_t>(pcm_err, MccSimpleGuidingModelErrorCode::ERROR_PCM_COMP);
|
||||||
|
}
|
||||||
|
|
||||||
|
if constexpr (mccIsEquatorialMount(CONTROLS_T::mountType)) {
|
||||||
|
hw_state.speedX = _currentParams.trackSpeedX;
|
||||||
|
hw_state.speedY = _currentParams.trackSpeedY;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
auto pz_err = update_pzones_ipoint();
|
||||||
if (pz_err) {
|
if (pz_err) {
|
||||||
return mcc_deduce_error<error_t>(pz_err, MccSimpleGuidingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
return mcc_deduce_error<error_t>(pz_err, MccSimpleGuidingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool no_intersects = false;
|
hw_state.moving_type = CONTROLS_T::hardware_moving_state_t::HW_MOVE_GUIDING;
|
||||||
|
auto hw_err = controls->hardwareSetState(hw_state);
|
||||||
if constexpr (mccIsEquatorialMount(HardwareT::mountType)) {
|
|
||||||
if (std::isfinite(intsc_coords.HA)) {
|
|
||||||
intsc_coords.X = intsc_coords.HA;
|
|
||||||
intsc_coords.Y = intsc_coords.DEC_APP;
|
|
||||||
} else {
|
|
||||||
no_intersects = true;
|
|
||||||
intsc_coords.X = tdata.HA + 710.0_mins; // 12h - 10min
|
|
||||||
intsc_coords.Y = tdata.DEC_APP;
|
|
||||||
}
|
|
||||||
} else if constexpr (mccIsAltAzMount(HardwareT::mountType)) {
|
|
||||||
if (std::isfinite(intsc_coords.AZ)) {
|
|
||||||
intsc_coords.X = intsc_coords.AZ;
|
|
||||||
intsc_coords.Y = intsc_coords.ZD;
|
|
||||||
} else {
|
|
||||||
no_intersects = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
static_assert(false, "UNKNOW MOUNT TYPE!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// compute position in future
|
|
||||||
auto hw_err = hardware->hardwareGetState(&hw_state);
|
|
||||||
if (hw_err) {
|
if (hw_err) {
|
||||||
return mcc_deduce_error<error_t>(hw_err, MccSimpleGuidingModelErrorCode::ERROR_HW_GETSTATE);
|
return mcc_deduce_error<error_t>(hw_err, MccSimpleGuidingModelErrorCode::ERROR_HW_SETSTATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
MccPCMResult pcm_inv_res;
|
|
||||||
|
|
||||||
// endpoint of the mount moving
|
std::chrono::steady_clock::time_point last_corr_tp;
|
||||||
auto pcm_err = pcm->computeInversePCM(intsc_coords, &pcm_inv_res, &hw_state);
|
|
||||||
if (pcm_err) {
|
|
||||||
return mcc_deduce_error<error_t>(pcm_err, MccSimpleGuidingModelErrorCode::ERROR_PCM_COMP);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (*_stopGuiding) {
|
while (*_stopGuiding) {
|
||||||
// wait for updated telemetry data
|
// wait for updated telemetry data
|
||||||
{
|
{
|
||||||
std::lock_guard lock{*_currentParamsMutex};
|
std::lock_guard lock{*_currentParamsMutex};
|
||||||
|
|
||||||
t_err = telemetry->waitForTelemetryData(&tdata, _currentParams.telemetryTimeout);
|
t_err = controls->waitForTelemetryData(&tdata, _currentParams.telemetryTimeout);
|
||||||
|
|
||||||
if (t_err) {
|
if (t_err) {
|
||||||
return mcc_deduce_error<error_t>(t_err, MccSimpleGuidingModelErrorCode::ERROR_GET_TELEMETRY);
|
return mcc_deduce_error<error_t>(t_err, MccSimpleGuidingModelErrorCode::ERROR_GET_TELEMETRY);
|
||||||
@ -133,7 +148,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// control prohibited zones
|
// control prohibited zones
|
||||||
if (mcc_is_near_pzones(pz_cont, tdata, _currentParams.minTimeToPZone, pz_err)) {
|
if (mcc_is_near_pzones(controls, tdata, _currentParams.minTimeToPZone, pz_err)) {
|
||||||
return MccSimpleGuidingModelErrorCode::ERROR_NEAR_PZONE;
|
return MccSimpleGuidingModelErrorCode::ERROR_NEAR_PZONE;
|
||||||
}
|
}
|
||||||
if (pz_err) {
|
if (pz_err) {
|
||||||
@ -141,10 +156,74 @@ public:
|
|||||||
MccSimpleGuidingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
MccSimpleGuidingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
t_err = telemetry->targetToMountDist(&dist);
|
if (*_stopGuiding) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
t_err = controls->targetToMountDist(&dist);
|
||||||
if (t_err) {
|
if (t_err) {
|
||||||
return mcc_deduce_error<error_t>(t_err, MccSimpleGuidingModelErrorCode::ERROR_DIST_TELEMETRY);
|
return mcc_deduce_error<error_t>(t_err, MccSimpleGuidingModelErrorCode::ERROR_DIST_TELEMETRY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (*_stopGuiding) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::lock_guard lock{*_currentParamsMutex};
|
||||||
|
|
||||||
|
if (dist < _currentParams.guidingCorrectionRange[0] ||
|
||||||
|
dist > _currentParams.guidingCorrectionRange[1]) { // moving with sideral speed
|
||||||
|
|
||||||
|
hw_state.moving_type = CONTROLS_T::hardware_moving_state_t::HW_MOVE_TRACKING;
|
||||||
|
if constexpr (mccIsEquatorialMount(CONTROLS_T::mountType)) {
|
||||||
|
hw_state.speedX = _currentParams.trackSpeedX;
|
||||||
|
hw_state.speedY = _currentParams.trackSpeedY;
|
||||||
|
} else if constexpr (mccIsAltAzMount(CONTROLS_T::mountType)) {
|
||||||
|
static_assert(false, "NOT IMPLEMENTED!");
|
||||||
|
} else {
|
||||||
|
static_assert(false, "UNKNOW MOUNT TYPE!");
|
||||||
|
}
|
||||||
|
|
||||||
|
hw_err = controls->hardwareSetState(hw_state);
|
||||||
|
if (hw_err) {
|
||||||
|
return mcc_deduce_error<error_t>(hw_err, MccSimpleGuidingModelErrorCode::ERROR_HW_SETSTATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto now = std::chrono::steady_clock::now();
|
||||||
|
if ((now - last_corr_tp) < _currentParams.guidingMinInterval) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
hw_state.X = tdata.target.X;
|
||||||
|
|
||||||
|
if constexpr (mccIsEquatorialMount(CONTROLS_T::mountType)) {
|
||||||
|
if (_currentParams.dualAxisGuiding) {
|
||||||
|
hw_state.Y = tdata.target.Y;
|
||||||
|
} else { // only along HA-axis
|
||||||
|
hw_state.Y = tdata.Y;
|
||||||
|
}
|
||||||
|
} else if constexpr (mccIsAltAzMount(CONTROLS_T::mountType)) {
|
||||||
|
hw_state.Y = tdata.target.Y;
|
||||||
|
} else {
|
||||||
|
static_assert(false, "UNKNOW MOUNT TYPE!");
|
||||||
|
}
|
||||||
|
if (t_err) {
|
||||||
|
return mcc_deduce_error<error_t>(t_err, MccSimpleGuidingModelErrorCode::ERROR_DIFF_TELEMETRY);
|
||||||
|
}
|
||||||
|
|
||||||
|
last_corr_tp = now;
|
||||||
|
}
|
||||||
|
|
||||||
|
// send corrections
|
||||||
|
hw_state.moving_type = CONTROLS_T::hardware_moving_state_t::HW_MOVE_GUIDING;
|
||||||
|
hw_err = controls->hardwareSetState(hw_state);
|
||||||
|
if (hw_err) {
|
||||||
|
return mcc_deduce_error<error_t>(hw_err, MccSimpleGuidingModelErrorCode::ERROR_HW_SETSTATE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return MccSimpleGuidingModelErrorCode::ERROR_OK;
|
return MccSimpleGuidingModelErrorCode::ERROR_OK;
|
||||||
|
|||||||
253
mcc/mcc_guiding_model.h.split
Normal file
253
mcc/mcc_guiding_model.h.split
Normal file
@ -0,0 +1,253 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
/* MOUNT CONTROL COMPONENTS LIBRARY */
|
||||||
|
|
||||||
|
|
||||||
|
/* SIMPLE GUIDING MODEL IMPLEMENTATION */
|
||||||
|
|
||||||
|
|
||||||
|
#include "mcc_defaults.h"
|
||||||
|
#include "mcc_moving_model_common.h"
|
||||||
|
|
||||||
|
namespace mcc
|
||||||
|
{
|
||||||
|
|
||||||
|
enum class MccSimpleGuidingModelErrorCode : int {
|
||||||
|
ERROR_OK,
|
||||||
|
ERROR_HW_GETSTATE,
|
||||||
|
ERROR_HW_SETSTATE,
|
||||||
|
ERROR_PCM_COMP,
|
||||||
|
ERROR_GET_TELEMETRY,
|
||||||
|
ERROR_DIST_TELEMETRY,
|
||||||
|
ERROR_DIFF_TELEMETRY,
|
||||||
|
ERROR_PZONE_CONTAINER_COMP,
|
||||||
|
ERROR_IN_PZONE,
|
||||||
|
ERROR_NEAR_PZONE,
|
||||||
|
ERROR_TIMEOUT,
|
||||||
|
ERROR_UNEXPECTED_AXIS_RATES,
|
||||||
|
ERROR_STOPPED
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mcc
|
||||||
|
|
||||||
|
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
|
||||||
|
template <>
|
||||||
|
class is_error_code_enum<mcc::MccSimpleGuidingModelErrorCode> : public true_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace std
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace mcc
|
||||||
|
{
|
||||||
|
|
||||||
|
class MccSimpleGuidingModel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef std::error_code error_t;
|
||||||
|
|
||||||
|
typedef MccSimpleMovingModelParams guiding_params_t;
|
||||||
|
|
||||||
|
|
||||||
|
template <mcc_telemetry_data_c TelemetryT,
|
||||||
|
mcc_hardware_c HardwareT,
|
||||||
|
mcc_PCM_c PcmT,
|
||||||
|
mcc_pzone_container_c PZoneContT>
|
||||||
|
MccSimpleGuidingModel(TelemetryT* telemetry, HardwareT* hardware, PcmT* pcm, PZoneContT* pz_cont)
|
||||||
|
: _stopGuiding(new std::atomic_bool()), _currentParamsMutex(new std::mutex())
|
||||||
|
{
|
||||||
|
_guidingFunc = [telemetry, hardware, pcm, pz_cont, this]() -> error_t {
|
||||||
|
typename HardwareT::hardware_state_t hw_state;
|
||||||
|
|
||||||
|
MccTelemetryData tdata;
|
||||||
|
MccEqtHrzCoords intsc_coords;
|
||||||
|
double dist, dx, dy;
|
||||||
|
|
||||||
|
auto t_err = telemetry->waitForTelemetryData(&tdata, _currentParams.telemetryTimeout);
|
||||||
|
if (t_err) {
|
||||||
|
return mcc_deduce_error<error_t>(t_err, MccSimpleGuidingModelErrorCode::ERROR_GET_TELEMETRY);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// compute intersection points with the prohibited zones
|
||||||
|
auto pz_err = mcc_find_closest_pzone(pz_cont, tdata, &intsc_coords);
|
||||||
|
if (pz_err) {
|
||||||
|
return mcc_deduce_error<error_t>(pz_err, MccSimpleGuidingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool no_intersects = false;
|
||||||
|
|
||||||
|
if constexpr (mccIsEquatorialMount(HardwareT::mountType)) {
|
||||||
|
if (std::isfinite(intsc_coords.HA)) {
|
||||||
|
intsc_coords.X = intsc_coords.HA;
|
||||||
|
intsc_coords.Y = intsc_coords.DEC_APP;
|
||||||
|
} else {
|
||||||
|
no_intersects = true;
|
||||||
|
intsc_coords.X = tdata.HA + 710.0_mins; // 12h - 10min
|
||||||
|
intsc_coords.Y = tdata.DEC_APP;
|
||||||
|
}
|
||||||
|
} else if constexpr (mccIsAltAzMount(HardwareT::mountType)) {
|
||||||
|
if (std::isfinite(intsc_coords.AZ)) {
|
||||||
|
intsc_coords.X = intsc_coords.AZ;
|
||||||
|
intsc_coords.Y = intsc_coords.ZD;
|
||||||
|
} else {
|
||||||
|
no_intersects = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
static_assert(false, "UNKNOW MOUNT TYPE!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// compute position in future
|
||||||
|
auto hw_err = hardware->hardwareGetState(&hw_state);
|
||||||
|
if (hw_err) {
|
||||||
|
return mcc_deduce_error<error_t>(hw_err, MccSimpleGuidingModelErrorCode::ERROR_HW_GETSTATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccPCMResult pcm_inv_res;
|
||||||
|
|
||||||
|
// endpoint of the mount moving
|
||||||
|
auto pcm_err = pcm->computeInversePCM(intsc_coords, &pcm_inv_res, &hw_state);
|
||||||
|
if (pcm_err) {
|
||||||
|
return mcc_deduce_error<error_t>(pcm_err, MccSimpleGuidingModelErrorCode::ERROR_PCM_COMP);
|
||||||
|
}
|
||||||
|
|
||||||
|
if constexpr (mccIsEquatorialMount(HardwareT::mountType)) {
|
||||||
|
hw_state.speedX = _currentParams.trackSpeedX;
|
||||||
|
hw_state.speedY = _currentParams.trackSpeedY;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::chrono::steady_clock::time_point last_corr_tp;
|
||||||
|
|
||||||
|
while (*_stopGuiding) {
|
||||||
|
// wait for updated telemetry data
|
||||||
|
{
|
||||||
|
std::lock_guard lock{*_currentParamsMutex};
|
||||||
|
|
||||||
|
t_err = telemetry->waitForTelemetryData(&tdata, _currentParams.telemetryTimeout);
|
||||||
|
|
||||||
|
if (t_err) {
|
||||||
|
return mcc_deduce_error<error_t>(t_err, MccSimpleGuidingModelErrorCode::ERROR_GET_TELEMETRY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*_stopGuiding) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// control prohibited zones
|
||||||
|
if (mcc_is_near_pzones(pz_cont, tdata, _currentParams.minTimeToPZone, pz_err)) {
|
||||||
|
return MccSimpleGuidingModelErrorCode::ERROR_NEAR_PZONE;
|
||||||
|
}
|
||||||
|
if (pz_err) {
|
||||||
|
return mcc_deduce_error<error_t>(pz_err,
|
||||||
|
MccSimpleGuidingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*_stopGuiding) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
t_err = telemetry->targetToMountDist(&dist);
|
||||||
|
if (t_err) {
|
||||||
|
return mcc_deduce_error<error_t>(t_err, MccSimpleGuidingModelErrorCode::ERROR_DIST_TELEMETRY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*_stopGuiding) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::lock_guard lock{*_currentParamsMutex};
|
||||||
|
|
||||||
|
if (dist < _currentParams.guidingCorrectionRange[0] ||
|
||||||
|
dist > _currentParams.guidingCorrectionRange[1]) { // moving with sideral speed
|
||||||
|
|
||||||
|
hw_state.moving_type = HardwareT::hardware_moving_state_t::HW_MOVE_TRACKING;
|
||||||
|
if constexpr (mccIsEquatorialMount(HardwareT::mountType)) {
|
||||||
|
hw_state.speedX = _currentParams.trackSpeedX;
|
||||||
|
hw_state.speedY = _currentParams.trackSpeedY;
|
||||||
|
} else if constexpr (mccIsAltAzMount(HardwareT::mountType)) {
|
||||||
|
static_assert(false, "NOT IMPLEMENTED!");
|
||||||
|
} else {
|
||||||
|
static_assert(false, "UNKNOW MOUNT TYPE!");
|
||||||
|
}
|
||||||
|
|
||||||
|
hw_err = hardware->hardwareSetState(hw_state);
|
||||||
|
if (hw_err) {
|
||||||
|
return mcc_deduce_error<error_t>(hw_err, MccSimpleGuidingModelErrorCode::ERROR_HW_SETSTATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto now = std::chrono::steady_clock::now();
|
||||||
|
if ((now - last_corr_tp) < _currentParams.guidingMinInterval) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
hw_state.X = tdata.target.X;
|
||||||
|
|
||||||
|
if constexpr (mccIsEquatorialMount(HardwareT::mountType)) {
|
||||||
|
if (_currentParams.dualAxisGuiding) {
|
||||||
|
hw_state.Y = tdata.target.Y;
|
||||||
|
} else { // only along HA-axis
|
||||||
|
hw_state.Y = tdata.Y;
|
||||||
|
}
|
||||||
|
} else if constexpr (mccIsAltAzMount(HardwareT::mountType)) {
|
||||||
|
hw_state.Y = tdata.target.Y;
|
||||||
|
} else {
|
||||||
|
static_assert(false, "UNKNOW MOUNT TYPE!");
|
||||||
|
}
|
||||||
|
if (t_err) {
|
||||||
|
return mcc_deduce_error<error_t>(t_err, MccSimpleGuidingModelErrorCode::ERROR_DIFF_TELEMETRY);
|
||||||
|
}
|
||||||
|
|
||||||
|
last_corr_tp = now;
|
||||||
|
}
|
||||||
|
|
||||||
|
// send corrections
|
||||||
|
hw_state.moving_type = HardwareT::hardware_moving_state_t::HW_MOVE_GUIDING;
|
||||||
|
hw_err = hardware->hardwareSetState(hw_state);
|
||||||
|
if (hw_err) {
|
||||||
|
return mcc_deduce_error<error_t>(hw_err, MccSimpleGuidingModelErrorCode::ERROR_HW_SETSTATE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccSimpleGuidingModelErrorCode::ERROR_OK;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
MccSimpleGuidingModel(MccSimpleGuidingModel&&) = default;
|
||||||
|
MccSimpleGuidingModel& operator=(MccSimpleGuidingModel&&) = default;
|
||||||
|
|
||||||
|
MccSimpleGuidingModel(const MccSimpleGuidingModel&) = delete;
|
||||||
|
MccSimpleGuidingModel& operator=(const MccSimpleGuidingModel&) = delete;
|
||||||
|
|
||||||
|
error_t startGuidingTarget()
|
||||||
|
{
|
||||||
|
*_stopGuiding = false;
|
||||||
|
|
||||||
|
return _guidingFunc();
|
||||||
|
}
|
||||||
|
|
||||||
|
error_t stoptGuidingTarget()
|
||||||
|
{
|
||||||
|
*_stopGuiding = true;
|
||||||
|
|
||||||
|
return MccSimpleGuidingModelErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::function<error_t()> _guidingFunc{};
|
||||||
|
std::unique_ptr<std::atomic_bool> _stopGuiding;
|
||||||
|
|
||||||
|
guiding_params_t _currentParams{};
|
||||||
|
std::unique_ptr<std::mutex> _currentParamsMutex{};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mcc
|
||||||
@ -9,6 +9,7 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
#include "mcc_angle.h"
|
#include "mcc_angle.h"
|
||||||
|
#include "mcc_defaults.h"
|
||||||
#include "mcc_generics.h"
|
#include "mcc_generics.h"
|
||||||
|
|
||||||
namespace mcc
|
namespace mcc
|
||||||
@ -26,6 +27,9 @@ struct MccSimpleMovingModelParams {
|
|||||||
// minimal time to prohibited zone (at current speed in slewing mode). if it is lesser then exit with error
|
// minimal time to prohibited zone (at current speed in slewing mode). if it is lesser then exit with error
|
||||||
std::chrono::seconds minTimeToPZone{10};
|
std::chrono::seconds minTimeToPZone{10};
|
||||||
|
|
||||||
|
// time interval to update prohibited zones related quantities (e.g. intersection points)
|
||||||
|
std::chrono::milliseconds updatingPZoneInterval{5000};
|
||||||
|
|
||||||
|
|
||||||
// ******* slewing mode *******
|
// ******* slewing mode *******
|
||||||
|
|
||||||
@ -57,7 +61,8 @@ struct MccSimpleMovingModelParams {
|
|||||||
|
|
||||||
// ******* guiding mode *******
|
// ******* guiding mode *******
|
||||||
|
|
||||||
double correctionRange[2]{0.3_arcsecs, 3.0_arcsecs};
|
double guidingCorrectionRange[2]{0.3_arcsecs, 3.0_arcsecs};
|
||||||
|
std::chrono::milliseconds guidingMinInterval{500}; // minimum time between two successive corrections
|
||||||
bool dualAxisGuiding{true}; // mount must be of an equatorial type: false means guiding along only HA-axis
|
bool dualAxisGuiding{true}; // mount must be of an equatorial type: false means guiding along only HA-axis
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -112,7 +117,7 @@ typename PZoneContT::error_t mcc_find_closest_pzone(PZoneContT* pz_cont,
|
|||||||
closest_coords->ZD = std::numeric_limits<double>::quiet_NaN();
|
closest_coords->ZD = std::numeric_limits<double>::quiet_NaN();
|
||||||
closest_coords->ALT = std::numeric_limits<double>::quiet_NaN();
|
closest_coords->ALT = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
|
||||||
std::vector<res_t> pz_coords(c, pz_cont->sizePZones());
|
std::vector<res_t> pz_coords(pz_cont->sizePZones(), c);
|
||||||
|
|
||||||
double dha, dha_min = std::numeric_limits<double>::max();
|
double dha, dha_min = std::numeric_limits<double>::max();
|
||||||
|
|
||||||
@ -136,5 +141,22 @@ typename PZoneContT::error_t mcc_find_closest_pzone(PZoneContT* pz_cont,
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto mcc_compute_target_point(mcc_ccte_c auto const& ccte,
|
||||||
|
mcc_telemetry_c auto const& tdata,
|
||||||
|
traits::mcc_time_duration_c auto const& time_dist,
|
||||||
|
mcc_celestial_point_c auto* point)
|
||||||
|
{
|
||||||
|
auto dt = std::chrono::duration<double>{tdata.HA} + time_dist * mcc_sideral_to_UT1_ratio; // hour seconds
|
||||||
|
|
||||||
|
// point in +time_dist future
|
||||||
|
MccCelestialPoint pt{.pair_kind = point->pair_kind,
|
||||||
|
.time_point = point->time_point + time_dist,
|
||||||
|
.X = dt.count() * std::numbers::pi / 3600.0 / 15.0,
|
||||||
|
.Y = tdata.DEC_APP};
|
||||||
|
|
||||||
|
point->time_point = pt.time_point;
|
||||||
|
|
||||||
|
return ccte.transformCoordinates(std::move(pt), point);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace mcc
|
} // namespace mcc
|
||||||
|
|||||||
@ -14,7 +14,12 @@
|
|||||||
namespace mcc
|
namespace mcc
|
||||||
{
|
{
|
||||||
|
|
||||||
enum class MccDefaultPCMErrorCode : int { ERROR_OK, ERROR_INVALID_INPUTS_BISPLEV, ERROR_EXCEED_MAX_ITERS };
|
enum class MccDefaultPCMErrorCode : int {
|
||||||
|
ERROR_OK,
|
||||||
|
ERROR_INVALID_INPUTS_BISPLEV,
|
||||||
|
ERROR_EXCEED_MAX_ITERS,
|
||||||
|
ERROR_NULLPTR
|
||||||
|
};
|
||||||
|
|
||||||
/* error category definition */
|
/* error category definition */
|
||||||
|
|
||||||
@ -38,6 +43,8 @@ struct MccDefaultPCMCategory : public std::error_category {
|
|||||||
return "invalid input arguments for bispev";
|
return "invalid input arguments for bispev";
|
||||||
case MccDefaultPCMErrorCode::ERROR_EXCEED_MAX_ITERS:
|
case MccDefaultPCMErrorCode::ERROR_EXCEED_MAX_ITERS:
|
||||||
return "exceed maximum of iterations number";
|
return "exceed maximum of iterations number";
|
||||||
|
case MccDefaultPCMErrorCode::ERROR_NULLPTR:
|
||||||
|
return "nullptr input argument";
|
||||||
default:
|
default:
|
||||||
return "UNKNOWN";
|
return "UNKNOWN";
|
||||||
}
|
}
|
||||||
@ -183,10 +190,18 @@ public:
|
|||||||
error_t computePCM(mcc_celestial_point_c auto pt, mcc_PCM_c auto* res, T* app_pt = nullptr)
|
error_t computePCM(mcc_celestial_point_c auto pt, mcc_PCM_c auto* res, T* app_pt = nullptr)
|
||||||
requires(mcc_celestial_point_c<T> || mcc_eqt_hrz_coord_c<T> || std::same_as<T, std::nullptr_t>)
|
requires(mcc_celestial_point_c<T> || mcc_eqt_hrz_coord_c<T> || std::same_as<T, std::nullptr_t>)
|
||||||
{
|
{
|
||||||
|
if (res == nullptr) {
|
||||||
|
return MccDefaultPCMErrorCode::ERROR_NULLPTR;
|
||||||
|
}
|
||||||
|
|
||||||
std::lock_guard lock(*_pcmDataMutex);
|
std::lock_guard lock(*_pcmDataMutex);
|
||||||
|
|
||||||
|
res->pcmX = 0.0;
|
||||||
|
res->pcmY = 0.0;
|
||||||
|
|
||||||
if constexpr (mcc_is_equatorial_mount<MOUNT_TYPE>) { // equatorial
|
if constexpr (mcc_is_equatorial_mount<MOUNT_TYPE>) { // equatorial
|
||||||
if (_pcmData.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY) {
|
if (_pcmData.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY ||
|
||||||
|
_pcmData.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE) {
|
||||||
const auto cosPhi = std::cos(_pcmData.siteLatitude);
|
const auto cosPhi = std::cos(_pcmData.siteLatitude);
|
||||||
const auto sinPhi = std::sin(_pcmData.siteLatitude);
|
const auto sinPhi = std::sin(_pcmData.siteLatitude);
|
||||||
const auto tanY = std::tan(pt.Y);
|
const auto tanY = std::tan(pt.Y);
|
||||||
|
|||||||
@ -11,8 +11,6 @@
|
|||||||
namespace mcc
|
namespace mcc
|
||||||
{
|
{
|
||||||
|
|
||||||
static constexpr double mcc_sideral_to_UT1_ratio = 1.002737909350795; // sideral/UT1
|
|
||||||
|
|
||||||
|
|
||||||
enum MccAltLimitPZErrorCode : int { ERROR_OK, ERROR_NULLPTR, ERROR_COORD_TRANSFROM };
|
enum MccAltLimitPZErrorCode : int { ERROR_OK, ERROR_NULLPTR, ERROR_COORD_TRANSFROM };
|
||||||
|
|
||||||
|
|||||||
@ -164,7 +164,7 @@ public:
|
|||||||
return mcc_deduce_error<error_t>(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_SETSTATE);
|
return mcc_deduce_error<error_t>(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_SETSTATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::chrono::system_clock::time_point start_slewing_tp, last_adjust_tp;
|
std::chrono::steady_clock::time_point start_slewing_tp, last_adjust_tp;
|
||||||
mcc_tp2tp(hw_state.time_point, start_slewing_tp);
|
mcc_tp2tp(hw_state.time_point, start_slewing_tp);
|
||||||
|
|
||||||
double dist, dx, dy, sinY, rate2, xrate;
|
double dist, dx, dy, sinY, rate2, xrate;
|
||||||
@ -230,7 +230,7 @@ public:
|
|||||||
{
|
{
|
||||||
std::lock_guard lock{*_currentParamsMutex};
|
std::lock_guard lock{*_currentParamsMutex};
|
||||||
|
|
||||||
if ((std::chrono::system_clock::now() - start_slewing_tp) > _currentParams.slewTimeout) {
|
if ((std::chrono::steady_clock::now() - start_slewing_tp) > _currentParams.slewTimeout) {
|
||||||
return MccSimpleSlewingModelErrorCode::ERROR_TIMEOUT;
|
return MccSimpleSlewingModelErrorCode::ERROR_TIMEOUT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,7 +284,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dist <= _currentParams.adjustCoordDiff) { // adjust mount pointing
|
if (dist <= _currentParams.adjustCoordDiff) { // adjust mount pointing
|
||||||
if ((std::chrono::system_clock::now() - last_adjust_tp) < _currentParams.adjustCycleInterval) {
|
auto now = std::chrono::steady_clock::now();
|
||||||
|
if ((now - last_adjust_tp) < _currentParams.adjustCycleInterval) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,7 +302,7 @@ public:
|
|||||||
return mcc_deduce_error<error_t>(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_SETSTATE);
|
return mcc_deduce_error<error_t>(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_SETSTATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
last_adjust_tp = std::chrono::system_clock::now();
|
last_adjust_tp = now;
|
||||||
|
|
||||||
adjust_mode = true;
|
adjust_mode = true;
|
||||||
|
|
||||||
|
|||||||
@ -16,9 +16,6 @@
|
|||||||
namespace mcc
|
namespace mcc
|
||||||
{
|
{
|
||||||
|
|
||||||
static constexpr double mcc_sideral_to_UT1_ratio = 1.002737909350795; // sideral/UT1
|
|
||||||
|
|
||||||
|
|
||||||
enum MccTelemetryErrorCode : int {
|
enum MccTelemetryErrorCode : int {
|
||||||
ERROR_OK,
|
ERROR_OK,
|
||||||
ERROR_NULLPTR,
|
ERROR_NULLPTR,
|
||||||
|
|||||||
@ -80,18 +80,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
_trackingFunc = [telemetry, hardware, pcm, pz_cont, this]() -> error_t {
|
_trackingFunc = [telemetry, hardware, pcm, pz_cont, this]() -> error_t {
|
||||||
MccCelestialPoint cpt;
|
|
||||||
typename HardwareT::hardware_state_t hw_state;
|
typename HardwareT::hardware_state_t hw_state;
|
||||||
|
|
||||||
if constexpr (mccIsEquatorialMount(PcmT::mountType)) {
|
MccEqtHrzCoords intsc_coords;
|
||||||
cpt.pair_kind = MccCoordPairKind::COORDS_KIND_HADEC_APP;
|
|
||||||
} else if constexpr (mccIsAltAzMount(PcmT::mountType)) {
|
|
||||||
cpt.pair_kind = MccCoordPairKind::COORDS_KIND_AZALT;
|
|
||||||
static_assert(false, "NOT IMPLEMENTED!");
|
|
||||||
} else {
|
|
||||||
static_assert(false, "UNKNOW MOUNT TYPE!");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
MccTelemetryData tdata;
|
MccTelemetryData tdata;
|
||||||
auto t_err = telemetry->waitForTelemetryData(&tdata, _currentTrackParams.telemetryTimeout);
|
auto t_err = telemetry->waitForTelemetryData(&tdata, _currentTrackParams.telemetryTimeout);
|
||||||
@ -99,63 +90,59 @@ public:
|
|||||||
return mcc_deduce_error<error_t>(t_err, MccSimpleTrackingModelErrorCode::ERROR_GET_TELEMETRY);
|
return mcc_deduce_error<error_t>(t_err, MccSimpleTrackingModelErrorCode::ERROR_GET_TELEMETRY);
|
||||||
}
|
}
|
||||||
|
|
||||||
mcc_tp2tp(tdata.time_point, cpt.time_point);
|
mcc_tp2tp(tdata.time_point, intsc_coords.time_point);
|
||||||
|
|
||||||
bool no_intersects = false;
|
|
||||||
|
|
||||||
std::vector<std::chrono::duration<double>> pz_timeto; // in seconds
|
std::vector<std::chrono::duration<double>> pz_timeto; // in seconds
|
||||||
std::chrono::duration<double> min_time{0.0};
|
std::chrono::duration<double> min_time{0.0};
|
||||||
std::vector<MccCelestialPoint> intsc_pt(pz_cont->sizePZones(), cpt);
|
|
||||||
|
|
||||||
// compute intersection points with the prohibited zones
|
// compute intersection points with the prohibited zones
|
||||||
auto pz_err = pz_cont->intersectPZone(tdata, &intsc_pt);
|
auto pz_err = mcc_find_closest_pzone(pz_cont, tdata, &intsc_coords);
|
||||||
if (pz_err) {
|
if (pz_err) {
|
||||||
return mcc_deduce_error<error_t>(pz_err, MccSimpleTrackingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
return mcc_deduce_error<error_t>(pz_err, MccSimpleTrackingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool no_intersects = false;
|
||||||
|
|
||||||
|
if constexpr (mccIsEquatorialMount(HardwareT::mountType)) {
|
||||||
|
if (std::isfinite(intsc_coords.HA)) {
|
||||||
|
intsc_coords.X = intsc_coords.HA;
|
||||||
|
intsc_coords.Y = intsc_coords.DEC_APP;
|
||||||
|
} else {
|
||||||
|
no_intersects = true;
|
||||||
|
intsc_coords.X = tdata.HA + 710.0_mins; // 12h - 10min
|
||||||
|
intsc_coords.Y = tdata.DEC_APP;
|
||||||
|
}
|
||||||
|
} else if constexpr (mccIsAltAzMount(HardwareT::mountType)) {
|
||||||
|
if (std::isfinite(intsc_coords.AZ)) {
|
||||||
|
intsc_coords.X = intsc_coords.AZ;
|
||||||
|
intsc_coords.Y = intsc_coords.ZD;
|
||||||
|
} else {
|
||||||
|
no_intersects = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
static_assert(false, "UNKNOW MOUNT TYPE!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// compute position in future
|
||||||
|
auto hw_err = hardware->hardwareGetState(&hw_state);
|
||||||
|
if (hw_err) {
|
||||||
|
return mcc_deduce_error<error_t>(hw_err, MccSimpleTrackingModelErrorCode::ERROR_HW_GETSTATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccPCMResult pcm_inv_res;
|
||||||
|
|
||||||
|
// endpoint of the mount moving
|
||||||
|
auto pcm_err = pcm->computeInversePCM(intsc_coords, &pcm_inv_res, &hw_state);
|
||||||
|
if (pcm_err) {
|
||||||
|
return mcc_deduce_error<error_t>(pcm_err, MccSimpleTrackingModelErrorCode::ERROR_PCM_COMP);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if constexpr (mccIsEquatorialMount(PcmT::mountType)) {
|
if constexpr (mccIsEquatorialMount(PcmT::mountType)) {
|
||||||
double dha_min = std::numbers::pi * 2.0, dha;
|
|
||||||
|
|
||||||
// find the closest pzone
|
|
||||||
|
|
||||||
for (auto& ipt : intsc_pt) {
|
|
||||||
if (std::isfinite(ipt.X) && std::isfinite(ipt.Y)) {
|
|
||||||
dha = ipt.X - tdata.HA;
|
|
||||||
if (dha < 0.0) {
|
|
||||||
dha += std::numbers::pi * 2.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dha < dha_min) {
|
|
||||||
dha_min = dha;
|
|
||||||
cpt.X = ipt.X;
|
|
||||||
cpt.Y = ipt.Y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (utils::isEqual(dha_min, std::numbers::pi * 2.0)) { // no intersections
|
|
||||||
no_intersects = true;
|
|
||||||
cpt.X = tdata.HA + 710.0_mins; // 12h - 10min
|
|
||||||
cpt.Y = tdata.DEC_APP;
|
|
||||||
}
|
|
||||||
|
|
||||||
// compute position in future
|
|
||||||
auto hw_err = hardware->hardwareGetState(&hw_state);
|
|
||||||
if (hw_err) {
|
|
||||||
return mcc_deduce_error<error_t>(hw_err, MccSimpleTrackingModelErrorCode::ERROR_HW_GETSTATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
MccPCMResult pcm_inv_res;
|
|
||||||
|
|
||||||
// endpoint of the mount moving
|
|
||||||
auto pcm_err = pcm->computeInversePCM(cpt, &pcm_inv_res, &hw_state);
|
|
||||||
if (pcm_err) {
|
|
||||||
return mcc_deduce_error<error_t>(pcm_err, MccSimpleTrackingModelErrorCode::ERROR_PCM_COMP);
|
|
||||||
}
|
|
||||||
|
|
||||||
// just set sideral rate once
|
// just set sideral rate once
|
||||||
mcc_tp2tp(cpt.time_point, hw_state.time_point);
|
mcc_tp2tp(tdata.time_point, hw_state.time_point);
|
||||||
{
|
{
|
||||||
std::lock_guard lock{*_currentTrackParamsMutex};
|
std::lock_guard lock{*_currentTrackParamsMutex};
|
||||||
|
|
||||||
@ -199,8 +186,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (no_intersects) {
|
if (no_intersects) {
|
||||||
if ((cpt.X - tdata.HA) < 10.0_mins) { // recompute target point
|
if ((intsc_coords.HA - tdata.HA) < 10.0_mins) { // recompute target point
|
||||||
cpt.X += 11.0_hours;
|
intsc_coords.X += 11.0_hours;
|
||||||
|
|
||||||
hw_err = hardware->hardwareGetState(&hw_state);
|
hw_err = hardware->hardwareGetState(&hw_state);
|
||||||
if (hw_err) {
|
if (hw_err) {
|
||||||
@ -208,7 +195,7 @@ public:
|
|||||||
MccSimpleTrackingModelErrorCode::ERROR_HW_GETSTATE);
|
MccSimpleTrackingModelErrorCode::ERROR_HW_GETSTATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
pcm_err = pcm->computeInversePCM(cpt, &pcm_inv_res, &hw_state);
|
pcm_err = pcm->computeInversePCM(intsc_coords, &pcm_inv_res, &hw_state);
|
||||||
if (pcm_err) {
|
if (pcm_err) {
|
||||||
return mcc_deduce_error<error_t>(pcm_err,
|
return mcc_deduce_error<error_t>(pcm_err,
|
||||||
MccSimpleTrackingModelErrorCode::ERROR_PCM_COMP);
|
MccSimpleTrackingModelErrorCode::ERROR_PCM_COMP);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user