This commit is contained in:
2025-09-02 16:49:58 +03:00
parent de80acf315
commit fe6492e4fc
11 changed files with 484 additions and 161 deletions

View File

@@ -80,18 +80,9 @@ public:
}
_trackingFunc = [telemetry, hardware, pcm, pz_cont, this]() -> error_t {
MccCelestialPoint cpt;
typename HardwareT::hardware_state_t hw_state;
if constexpr (mccIsEquatorialMount(PcmT::mountType)) {
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!");
}
MccEqtHrzCoords intsc_coords;
MccTelemetryData tdata;
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);
}
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::chrono::duration<double> min_time{0.0};
std::vector<MccCelestialPoint> intsc_pt(pz_cont->sizePZones(), cpt);
// 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) {
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)) {
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
mcc_tp2tp(cpt.time_point, hw_state.time_point);
mcc_tp2tp(tdata.time_point, hw_state.time_point);
{
std::lock_guard lock{*_currentTrackParamsMutex};
@@ -199,8 +186,8 @@ public:
}
if (no_intersects) {
if ((cpt.X - tdata.HA) < 10.0_mins) { // recompute target point
cpt.X += 11.0_hours;
if ((intsc_coords.HA - tdata.HA) < 10.0_mins) { // recompute target point
intsc_coords.X += 11.0_hours;
hw_err = hardware->hardwareGetState(&hw_state);
if (hw_err) {
@@ -208,7 +195,7 @@ public:
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) {
return mcc_deduce_error<error_t>(pcm_err,
MccSimpleTrackingModelErrorCode::ERROR_PCM_COMP);