...
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
/* SIMPLE Tracking MODEL IMPLEMENTATION */
|
||||
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "mcc_defaults.h"
|
||||
#include "mcc_moving_model_common.h"
|
||||
|
||||
@@ -133,6 +135,10 @@ public:
|
||||
MccEqtHrzCoords intsc_coords;
|
||||
MccCelestialPoint target_in_future_pt;
|
||||
|
||||
bool store_path = false;
|
||||
std::ofstream fst;
|
||||
using path_tp_t = std::chrono::duration<double>; // seconds represented as double
|
||||
|
||||
if constexpr (mccIsEquatorialMount(CONTROLS_T::mountType)) {
|
||||
target_in_future_pt.pair_kind = MccCoordPairKind::COORDS_KIND_HADEC_APP;
|
||||
} else if constexpr (mccIsAltAzMount(CONTROLS_T::mountType)) {
|
||||
@@ -144,6 +150,7 @@ public:
|
||||
// double dist, dx, dy;
|
||||
|
||||
logger.logInfo("Start tracking:");
|
||||
logger.logInfo(" timesift: {} millisecs", _currentParams.timeShiftToTargetPoint.count());
|
||||
logger.logInfo(" min time to pzone: {} secs", _currentParams.minTimeToPZone.count());
|
||||
|
||||
|
||||
@@ -153,6 +160,8 @@ public:
|
||||
return mcc_deduce_error_code(t_err, MccSimpleTrackingModelErrorCode::ERROR_GET_TELEMETRY);
|
||||
}
|
||||
|
||||
auto start_point = tdata.time_point; // needed for trajectory file
|
||||
|
||||
bool in_zone;
|
||||
auto pz_err = controls->inPZone(tdata, &in_zone);
|
||||
if (pz_err) {
|
||||
@@ -257,7 +266,7 @@ public:
|
||||
return mcc_deduce_error_code(pcm_err, MccSimpleTrackingModelErrorCode::ERROR_PCM_COMP);
|
||||
}
|
||||
|
||||
mcc_tp2tp(tdata.time_point, hw_state.time_point);
|
||||
mcc_tp2tp(tdata.time_point + tp_dt, hw_state.time_point);
|
||||
}
|
||||
|
||||
return MccSimpleTrackingModelErrorCode::ERROR_OK;
|
||||
@@ -275,6 +284,8 @@ public:
|
||||
{
|
||||
std::lock_guard lock{*_currentParamsMutex};
|
||||
|
||||
mcc_copy_eqt_hrz_coord(tdata, &tdata.target);
|
||||
|
||||
auto ccte_err = target_point(&target_in_future_pt);
|
||||
if (ccte_err) {
|
||||
*_stopTracking = true;
|
||||
@@ -296,6 +307,29 @@ public:
|
||||
} else {
|
||||
static_assert(false, "UNKNOWN MOUNT TYPE!");
|
||||
}
|
||||
|
||||
if (!_currentParams.trackingPathFilename.empty()) { // open tracking trajectory file
|
||||
fst.open(_currentParams.trackingPathFilename);
|
||||
if (fst.is_open()) {
|
||||
store_path = true;
|
||||
logger.logInfo(" timesift: {} millisecs", _currentParams.timeShiftToTargetPoint.count());
|
||||
logger.logInfo(" min time to pzone: {} secs", _currentParams.minTimeToPZone.count());
|
||||
|
||||
fst << "# \n";
|
||||
fst << "# Tracking trajectory, " << std::chrono::system_clock::now() << "\n";
|
||||
fst << "# Config:\n";
|
||||
fst << "# timeshift: " << _currentParams.timeShiftToTargetPoint.count() << " millisecs\n";
|
||||
fst << "# min time to pzone: " << _currentParams.minTimeToPZone.count() << " secs\n";
|
||||
fst << "# \n";
|
||||
fst << "# Format (time is in seconds, coordinates are in radians): \n";
|
||||
fst << "# <time-since-start> <target X> <target Y> <mount X> <mount Y> <dX_{target-mount}> "
|
||||
"<dY_{target-mount}> <moving state>\n";
|
||||
|
||||
} else {
|
||||
logger.logError(std::format("Cannot open tracking path file: {}! Do not save it!",
|
||||
_currentParams.trackingPathFilename));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// move mount
|
||||
@@ -328,6 +362,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
if (store_path) {
|
||||
fst << std::chrono::duration_cast<path_tp_t>(tdata.time_point - start_point).count() << " "
|
||||
<< tdata.target.HA << " " << tdata.target.DEC_APP << " " << tdata.HA << " " << tdata.DEC_APP
|
||||
<< " " << (tdata.target.HA - tdata.HA) << " " << (tdata.target.DEC_APP - tdata.DEC_APP) << " "
|
||||
<< (int)hw_state.moving_state << "\n";
|
||||
}
|
||||
|
||||
|
||||
if constexpr (mccIsEquatorialMount(CONTROLS_T::mountType)) {
|
||||
logger.logTrace(std::format(" current target: HA = {}, DEC = {}",
|
||||
mcc::MccAngle(tdata.target.HA).sexagesimal(true),
|
||||
@@ -353,52 +395,72 @@ public:
|
||||
}
|
||||
|
||||
// control prohibited zones
|
||||
if (mcc_is_near_pzones(controls, tdata, _currentParams.minTimeToPZone, pz_err)) {
|
||||
*_stopTracking = true;
|
||||
return MccSimpleTrackingModelErrorCode::ERROR_NEAR_PZONE;
|
||||
}
|
||||
if (pz_err) {
|
||||
*_stopTracking = true;
|
||||
return mcc_deduce_error_code(pz_err, MccSimpleTrackingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
||||
}
|
||||
// if (mcc_is_near_pzones(controls, tdata, _currentParams.minTimeToPZone, pz_err)) {
|
||||
// logger.logError("Mount is near zone!");
|
||||
// *_stopTracking = true;
|
||||
// return MccSimpleTrackingModelErrorCode::ERROR_NEAR_PZONE;
|
||||
// }
|
||||
// if (pz_err) {
|
||||
// *_stopTracking = true;
|
||||
// return mcc_deduce_error_code(pz_err,
|
||||
// MccSimpleTrackingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
||||
// }
|
||||
|
||||
if (*_stopTracking) {
|
||||
break;
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard lock{*_currentParamsMutex};
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
// {
|
||||
// std::lock_guard lock{*_currentParamsMutex};
|
||||
// auto now = std::chrono::steady_clock::now();
|
||||
|
||||
if ((now - last_corr_tp) > _currentParams.trackingCycleInterval) {
|
||||
// update prohibited zones intersection point
|
||||
if ((now - last_ipzone_update_tp) < _currentParams.updatingPZoneInterval) {
|
||||
pz_err = update_pzones_ipoint();
|
||||
if (pz_err) {
|
||||
*_stopTracking = true;
|
||||
return mcc_deduce_error_code(
|
||||
pz_err, MccSimpleTrackingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
||||
}
|
||||
}
|
||||
// if ((now - last_corr_tp) > _currentParams.trackingCycleInterval) {
|
||||
// // update prohibited zones intersection point
|
||||
// if ((now - last_ipzone_update_tp) < _currentParams.updatingPZoneInterval) {
|
||||
// pz_err = update_pzones_ipoint();
|
||||
// if (pz_err) {
|
||||
// *_stopTracking = true;
|
||||
// return mcc_deduce_error_code(
|
||||
// pz_err, MccSimpleTrackingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
||||
// }
|
||||
// }
|
||||
|
||||
// compute new target-in-future point
|
||||
auto ccte_err = target_point(&target_in_future_pt);
|
||||
if (ccte_err) {
|
||||
*_stopTracking = true;
|
||||
return mcc_deduce_error_code(ccte_err, MccSimpleTrackingModelErrorCode::ERROR_CCTE);
|
||||
}
|
||||
// // compute new target-in-future point
|
||||
// auto ccte_err = target_point(&target_in_future_pt);
|
||||
// if (ccte_err) {
|
||||
// *_stopTracking = true;
|
||||
// return mcc_deduce_error_code(ccte_err, MccSimpleTrackingModelErrorCode::ERROR_CCTE);
|
||||
// }
|
||||
|
||||
logger.logTrace("The updated target point:");
|
||||
if constexpr (mccIsEquatorialMount(CONTROLS_T::mountType)) {
|
||||
logger.logTrace(" HA, DEC: {} {}", MccAngle(target_in_future_pt.X).sexagesimal(true),
|
||||
MccAngle(target_in_future_pt.Y).sexagesimal());
|
||||
} else if constexpr (mccIsAltAzMount(CONTROLS_T::mountType)) {
|
||||
logger.logTrace(" AZ, ZD: {} {}", MccAngle(target_in_future_pt.X).sexagesimal(),
|
||||
MccAngle(target_in_future_pt.Y).sexagesimal());
|
||||
} else {
|
||||
static_assert(false, "UNKNOWN MOUNT TYPE!");
|
||||
}
|
||||
}
|
||||
// logger.logTrace("The updated target point:");
|
||||
// if constexpr (mccIsEquatorialMount(CONTROLS_T::mountType)) {
|
||||
// logger.logTrace(" HA, DEC: {} {}", MccAngle(target_in_future_pt.X).sexagesimal(true),
|
||||
// MccAngle(target_in_future_pt.Y).sexagesimal());
|
||||
// } else if constexpr (mccIsAltAzMount(CONTROLS_T::mountType)) {
|
||||
// logger.logTrace(" AZ, ZD: {} {}", MccAngle(target_in_future_pt.X).sexagesimal(),
|
||||
// MccAngle(target_in_future_pt.Y).sexagesimal());
|
||||
// } else {
|
||||
// static_assert(false, "UNKNOWN MOUNT TYPE!");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// compute new target-in-future point
|
||||
auto ccte_err = target_point(&target_in_future_pt);
|
||||
if (ccte_err) {
|
||||
*_stopTracking = true;
|
||||
return mcc_deduce_error_code(ccte_err, MccSimpleTrackingModelErrorCode::ERROR_CCTE);
|
||||
}
|
||||
|
||||
logger.logTrace("The updated target point:");
|
||||
if constexpr (mccIsEquatorialMount(CONTROLS_T::mountType)) {
|
||||
logger.logTrace(" HA, DEC: {} {}", MccAngle(target_in_future_pt.X).sexagesimal(true),
|
||||
MccAngle(target_in_future_pt.Y).sexagesimal());
|
||||
} else if constexpr (mccIsAltAzMount(CONTROLS_T::mountType)) {
|
||||
logger.logTrace(" AZ, ZD: {} {}", MccAngle(target_in_future_pt.X).sexagesimal(),
|
||||
MccAngle(target_in_future_pt.Y).sexagesimal());
|
||||
} else {
|
||||
static_assert(false, "UNKNOWN MOUNT TYPE!");
|
||||
}
|
||||
|
||||
// send corrections
|
||||
|
||||
Reference in New Issue
Block a user