...
This commit is contained in:
@@ -128,11 +128,14 @@ public:
|
||||
// coordinates difference to stop slewing (in radians)
|
||||
coord_t slewToleranceRadius{(double)MccAngle{5.0_arcsecs}};
|
||||
|
||||
// coordinates polling interval in seconds
|
||||
std::chrono::duration<double> coordPollingInterval{0.1};
|
||||
bool stopAfterSlew{false};
|
||||
// slew process timeout
|
||||
std::chrono::seconds slewTimeout{3600};
|
||||
|
||||
std::chrono::duration<double> telemetryPollingInterval{0.1};
|
||||
|
||||
// if true - stop mount after the slewing
|
||||
bool stopAfterSlew{false};
|
||||
|
||||
coord_t slewXRate{0.0}; // maximal slewing rate (0 means move with maximal allowed rate)
|
||||
coord_t slewYRate{0.0}; // maximal slewing rate (0 means move with maximal allowed rate)
|
||||
|
||||
@@ -141,8 +144,9 @@ public:
|
||||
coord_t adjustYRate{
|
||||
(double)MccAngle{5.0_arcmins}}; // maximal adjusting rate (a rate at the final slewing stage)
|
||||
|
||||
// number of consecutive measurements within slewPrecision radius to stop adjusting of slewing
|
||||
// number of consecutive measurements within slewToleranceRadius radius to stop adjusting of slewing
|
||||
size_t withinToleranceCycleNumber{10};
|
||||
|
||||
// maximal allowed number of adjusting cycles
|
||||
size_t maxAdjustingCycleNumber{100};
|
||||
};
|
||||
@@ -208,6 +212,8 @@ protected:
|
||||
|
||||
|
||||
_slewFunc = [p_mount_controls, this](slew_point_t slew_point) {
|
||||
_stopRequested = false;
|
||||
|
||||
auto& astrom_engine = p_mount_controls->astrometryEngine;
|
||||
auto& hardware = p_mount_controls->hardware;
|
||||
auto& pec = p_mount_controls->PEC;
|
||||
@@ -254,6 +260,7 @@ protected:
|
||||
// start moving the mount (it is assumed this is asynchronous operation!!!)
|
||||
ax_pos.xrate = slew_point.slewXRate;
|
||||
ax_pos.yrate = slew_point.slewYRate;
|
||||
ax_pos.moving_type = hardware_t::hw_moving_type_t::HW_MOVE_SLEWING;
|
||||
typename hardware_t::error_t hw_err = hardware->setPos(ax_pos);
|
||||
|
||||
if (hw_err) {
|
||||
@@ -270,11 +277,12 @@ protected:
|
||||
}
|
||||
|
||||
|
||||
typename hardware_t::axes_pos_t::time_point_t prev_time_point{};
|
||||
// typename hardware_t::axes_pos_t::time_point_t prev_time_point{};
|
||||
|
||||
auto adj_ax_pos = ax_pos; // to prevent possible effects in hardware 'setPos' method
|
||||
adj_ax_pos.xrate = slew_point.adjustXRate;
|
||||
adj_ax_pos.yrate = slew_point.adjustYRate;
|
||||
adj_ax_pos.moving_type = hardware_t::hw_moving_type_t::HW_MOVE_ADJUSTING;
|
||||
|
||||
typename telemetry_t::mount_telemetry_data_t::coord_t xr, yr, coord_diff2,
|
||||
adj_rad2 = slew_point.adjustCoordDiff * slew_point.adjustCoordDiff,
|
||||
@@ -286,19 +294,20 @@ protected:
|
||||
size_t i_in_tol_cycle = 0;
|
||||
bool in_adj_mode = false;
|
||||
|
||||
auto coord_diff_func = [](auto& t_data) {
|
||||
typename telemetry_t::mount_telemetry_data_t::coord_t xr, yr;
|
||||
// compute new hardware coordinate of target
|
||||
auto compute_new_coord = [](auto const& t_data, typename hardware_t::axes_pos_t& hw_pos) {
|
||||
// current celestial position of target is already computed for given time point
|
||||
// so one needs only correct apparent coordinates for PEC corrections
|
||||
hw_pos.time_point = t_data.time_point;
|
||||
if constexpr (mccIsEquatorialMount(pec_t::mountType)) {
|
||||
xr = t_data.tagRA - t_data.mntHA;
|
||||
yr = t_data.tagDEC - t_data.mntDEC;
|
||||
hw_pos.x = t_data.tagHA - t_data.pecX;
|
||||
hw_pos.y = t_data.tagDEC - t_data.pecY;
|
||||
} else if constexpr (mccIsAltAzMount(pec_t::mountType)) {
|
||||
xr = t_data.tagAZ - t_data.mntAZ;
|
||||
yr = t_data.tagALT - t_data.mntALT;
|
||||
hw_pos.x = t_data.tagAZ - t_data.pecX;
|
||||
hw_pos.y = t_data.tagALT - t_data.pecY;
|
||||
} else {
|
||||
static_assert(false, "UNSUPPORTED MOUNT TYPE!");
|
||||
}
|
||||
|
||||
return xr * xr + yr * yr;
|
||||
};
|
||||
|
||||
auto cycle_func = [&](auto t_data) mutable {
|
||||
@@ -307,36 +316,28 @@ protected:
|
||||
}
|
||||
|
||||
// check for prohibited zones
|
||||
auto t_err = mccCheckInZonePZTuple(*telemetry, p_mount_controls->prohibitedZones, in_zone_flag);
|
||||
if (mccCheckInZonePZTuple(t_data, p_mount_controls->prohibitedZones, in_zone_flag)) {
|
||||
return MccSimpleSlewModelErrorCode::ERROR_IN_PROHIBITED_ZONE;
|
||||
};
|
||||
|
||||
if (t_err) {
|
||||
if constexpr (std::same_as<decltype(t_err), error_t>) {
|
||||
logError(
|
||||
std::format("An telemetry error occured: code = {} ({})", t_err.value(), t_err.message()));
|
||||
res_err = t_err;
|
||||
} else {
|
||||
if constexpr (traits::mcc_formattable<decltype(t_err)>) {
|
||||
logError(std::format("An telemetry error occured: code = {}", t_err));
|
||||
}
|
||||
res_err = MccSimpleSlewModelErrorCode::ERROR_TELEMETRY_DATA;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// t_data was updated in caller!!!
|
||||
coord_diff2 = coord_diff_func(t_data);
|
||||
auto coord_diff = telemetry.targetToMountDiff();
|
||||
|
||||
if (_stopRequested) {
|
||||
res_err = MccSimpleSlewModelErrorCode::ERROR_SLEW_STOPPED;
|
||||
}
|
||||
|
||||
if (coord_diff2 < adj_rad2) { // adjusting mode
|
||||
if (coord_diff.r2 < adj_rad2) { // adjusting mode
|
||||
in_adj_mode = true;
|
||||
|
||||
compute_new_coord(t_data, adj_ax_pos);
|
||||
|
||||
hw_err = hardware->setPos(adj_ax_pos);
|
||||
|
||||
if (!hw_err) {
|
||||
++i_adj_cycle;
|
||||
if (coord_diff2 < tol_rad2) {
|
||||
if (coord_diff.r2 < tol_rad2) {
|
||||
++i_in_tol_cycle;
|
||||
|
||||
if (i_in_tol_cycle == slew_point.withinToleranceCycleNumber) {
|
||||
@@ -346,7 +347,7 @@ protected:
|
||||
}
|
||||
|
||||
if (i_adj_cycle == slew_point.maxAdjustingCycleNumber) {
|
||||
// res_err = max iter number was exceeded
|
||||
res_err = MccSimpleSlewModelErrorCode::ERROR_SLEW_ADJ_MAXITER;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -364,8 +365,27 @@ protected:
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (in_adj_mode) { // ?!!!!!!!!!!!!!
|
||||
} else { // continue to slewing
|
||||
if (in_adj_mode) { // ?!!!!!!!!!!!!! slew again?!!!
|
||||
in_adj_mode = false;
|
||||
i_adj_cycle = 0;
|
||||
i_in_tol_cycle = 0;
|
||||
|
||||
compute_new_coord(t_data, ax_pos);
|
||||
typename hardware_t::error_t hw_err = hardware->setPos(ax_pos);
|
||||
|
||||
if (hw_err) {
|
||||
if constexpr (std::same_as<decltype(hw_err), error_t>) {
|
||||
logError(std::format("An hardware error occured: code = {} ({})", hw_err.value(),
|
||||
hw_err.message()));
|
||||
return hw_err;
|
||||
} else {
|
||||
if constexpr (traits::mcc_formattable<decltype(hw_err)>) {
|
||||
logError(std::format("An hardware error occured: code = {}", hw_err));
|
||||
}
|
||||
return MccSimpleSlewModelErrorCode::ERROR_HARDWARE_SETPOS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -385,7 +405,6 @@ protected:
|
||||
|
||||
if (t_err) {
|
||||
std::string err_str = "An error occured while waiting for updated telemetry";
|
||||
logError(std::format("An error occured while waiting for updated telemetry: {}", t_err));
|
||||
if constexpr (std::same_as<decltype(t_err), error_t>) {
|
||||
std::format_to(std::back_inserter(err_str), ": code = {} ({})", t_err.value(), t_err.message());
|
||||
logError(err_str);
|
||||
@@ -401,6 +420,10 @@ protected:
|
||||
|
||||
cycle_func(t_data);
|
||||
|
||||
if (res_err) {
|
||||
return res_err;
|
||||
}
|
||||
|
||||
if ((std::chrono::steady_clock::now() - start_poll_tm) > slew_point.slewTimeout) {
|
||||
logError("Waiting time for completion of slewing expired!");
|
||||
return MccSimpleSlewModelErrorCode::ERROR_SLEW_TIMEOUT;
|
||||
@@ -414,6 +437,6 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
// static_assert(traits::mcc_slew_model_c<>);
|
||||
static_assert(traits::mcc_slew_model_c<MccSimpleSlewModel<>>, "");
|
||||
|
||||
} // namespace mcc
|
||||
|
||||
Reference in New Issue
Block a user