...
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "mcc_defaults.h"
|
||||
#include "mcc_generics.h"
|
||||
|
||||
#include "mcc_moving_model_common.h"
|
||||
|
||||
namespace mcc
|
||||
{
|
||||
@@ -48,16 +48,18 @@ class MccSimpleTrackingModel
|
||||
public:
|
||||
typedef std::error_code error_t;
|
||||
|
||||
struct tracking_params_t {
|
||||
static constexpr double sideralRate = 15.0410686_arcsecs; // in radians per second
|
||||
typedef MccSimpleMovingModelParams tracking_params_t;
|
||||
|
||||
double trackSpeedX{};
|
||||
double trackSpeedY{};
|
||||
// struct tracking_params_t {
|
||||
// static constexpr double sideralRate = 15.0410686_arcsecs; // in radians per second
|
||||
|
||||
std::chrono::seconds telemetryTimeout{3};
|
||||
// minimal time to prohibited zone. if it is lesser then exit with error
|
||||
std::chrono::seconds minTimeToPZone{10};
|
||||
};
|
||||
// double trackSpeedX{};
|
||||
// double trackSpeedY{};
|
||||
|
||||
// std::chrono::seconds telemetryTimeout{3};
|
||||
// // minimal time to prohibited zone. if it is lesser then exit with error
|
||||
// std::chrono::seconds minTimeToPZone{10};
|
||||
// };
|
||||
|
||||
template <mcc_telemetry_data_c TelemetryT,
|
||||
mcc_hardware_c HardwareT,
|
||||
@@ -99,6 +101,7 @@ public:
|
||||
|
||||
mcc_tp2tp(tdata.time_point, cpt.time_point);
|
||||
|
||||
bool no_intersects = false;
|
||||
|
||||
std::vector<std::chrono::duration<double>> pz_timeto; // in seconds
|
||||
std::chrono::duration<double> min_time{0.0};
|
||||
@@ -132,14 +135,15 @@ public:
|
||||
}
|
||||
|
||||
if (utils::isEqual(dha_min, 0.0)) { // no intersections
|
||||
cpt.X = tdata.HA - 1.0_mins;
|
||||
no_intersects = true;
|
||||
cpt.X = tdata.HA + 710.0_mins; // 12h - 10min
|
||||
cpt.Y = tdata.DEC_APP;
|
||||
}
|
||||
|
||||
// compute position in future
|
||||
auto err = hardware->hardwareGetState(&hw_state);
|
||||
if (err) {
|
||||
return mcc_deduce_error<error_t>(err, MccSimpleTrackingModelErrorCode::ERROR_HW_GETSTATE);
|
||||
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;
|
||||
@@ -161,9 +165,9 @@ public:
|
||||
hw_state.moving_type = HardwareT::hardware_moving_state_t::HW_MOVE_TRACKING;
|
||||
|
||||
// start tracking
|
||||
err = hardware->hardwareSetState(std::move(hw_state));
|
||||
if (err) {
|
||||
return mcc_deduce_error<error_t>(err, MccSimpleTrackingModelErrorCode::ERROR_HW_SETSTATE);
|
||||
hw_err = hardware->hardwareSetState(std::move(hw_state));
|
||||
if (hw_err) {
|
||||
return mcc_deduce_error<error_t>(hw_err, MccSimpleTrackingModelErrorCode::ERROR_HW_SETSTATE);
|
||||
}
|
||||
|
||||
|
||||
@@ -194,14 +198,44 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
// check for current axis speed
|
||||
if (utils::isEqual(tdata.speedX, 0.0) && utils::isEqual(tdata.speedY, 0.0)) {
|
||||
// unhandled stop state?!!!
|
||||
return MccSimpleTrackingModelErrorCode::ERROR_UNEXPECTED_AXIS_RATES;
|
||||
if (no_intersects) {
|
||||
if ((cpt.X - tdata.HA) < 10.0_mins) { // recompute target point
|
||||
cpt.X += 11.0_hours;
|
||||
|
||||
hw_err = hardware->hardwareGetState(&hw_state);
|
||||
if (hw_err) {
|
||||
return mcc_deduce_error<error_t>(hw_err,
|
||||
MccSimpleTrackingModelErrorCode::ERROR_HW_GETSTATE);
|
||||
}
|
||||
|
||||
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(tdata.time_point, hw_state.time_point);
|
||||
{
|
||||
std::lock_guard lock{*_currentTrackParamsMutex};
|
||||
|
||||
hw_state.speedX = _currentTrackParams.trackSpeedX;
|
||||
hw_state.speedY = _currentTrackParams.trackSpeedY;
|
||||
}
|
||||
hw_state.moving_type = HardwareT::hardware_moving_state_t::HW_MOVE_TRACKING;
|
||||
|
||||
// start tracking
|
||||
hw_err = hardware->hardwareSetState(std::move(hw_state));
|
||||
if (hw_err) {
|
||||
return mcc_deduce_error<error_t>(hw_err,
|
||||
MccSimpleTrackingModelErrorCode::ERROR_HW_SETSTATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return MccSimpleTrackingModelErrorCode::ERROR_OK;
|
||||
|
||||
} else if constexpr (mccIsAltAzMount(PcmT::mountType)) {
|
||||
static_assert(false, "NOT IMPLEMENTED!");
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user