...
This commit is contained in:
parent
45f655dc90
commit
2e5e1918e1
@ -70,7 +70,7 @@ include_directories(${BSPLINES_INCLUDE_DIR})
|
||||
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_telemetry.h
|
||||
mcc_angle.h mcc_pzone.h mcc_pzone_container.h mcc_finite_state_machine.h
|
||||
mcc_generic_mount.h)
|
||||
mcc_generic_mount.h mcc_tracking_model.h)
|
||||
|
||||
list(APPEND MCC_LIBRARY_SRC1 mcc_spdlog.h)
|
||||
|
||||
|
||||
@ -323,6 +323,125 @@ concept mcc_ccte_c = std::derived_from<T, mcc_CCTE_interface_t<typename T::error
|
||||
|
||||
|
||||
|
||||
/* POINTING CORRECTION MODEL CLASS CONCEPT */
|
||||
|
||||
template <typename T>
|
||||
concept mcc_PCM_result_c = requires(T t) {
|
||||
requires mcc_angle_c<decltype(t.dx)>;
|
||||
requires mcc_angle_c<decltype(t.dy)>;
|
||||
};
|
||||
|
||||
template <mcc_error_c RetT, mcc_PCM_result_c ResT>
|
||||
struct mcc_PCM_interface_t {
|
||||
virtual ~mcc_PCM_interface_t() = default;
|
||||
|
||||
template <std::derived_from<mcc_PCM_interface_t> SelfT>
|
||||
RetT computePCM(this SelfT&& self, mcc_celestial_point_c auto pt, ResT* result)
|
||||
{
|
||||
return std::forward<SelfT>(self).computePCM(std::move(pt), result);
|
||||
}
|
||||
|
||||
protected:
|
||||
mcc_PCM_interface_t() = default;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
concept mcc_PCM_c =
|
||||
std::derived_from<T, mcc_PCM_interface_t<typename T::error_t, typename T::pcm_result_t>> && requires {
|
||||
// the 'T' class must contain static constexpr member of 'MccMountType' type
|
||||
requires std::same_as<decltype(T::mountType), const MccMountType>;
|
||||
[]() {
|
||||
static constexpr MccMountType val = T::mountType;
|
||||
return val;
|
||||
}(); // to ensure 'mountType' can be used in compile-time context
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* MOUNT HARDWARE ABSTRACTION CLASS CONCEPT */
|
||||
|
||||
template <typename T>
|
||||
concept mcc_hardware_c = requires(T t, const T t_const) {
|
||||
requires mcc_error_c<typename T::error_t>;
|
||||
|
||||
{ t_const.hardwareName() } -> std::formattable<char>;
|
||||
|
||||
// a type that defines at least HW_MOVE_STOPPED, HW_MOVE_SLEWING, HW_MOVE_ADJUSTING, HW_MOVE_TRACKING
|
||||
// and HW_MOVE_GUIDING compile-time constants. The main purpose of this type is a
|
||||
// possible tunning of hardware hardwareSetState-related commands and detect stop-state
|
||||
//
|
||||
// e.g. an implementations can be as follows:
|
||||
// enum class hardware_moving_state_t: int {HW_MOVE_STOPPED, HW_MOVE_SLEWING, HW_MOVE_ADJUSTING,
|
||||
// HW_MOVE_TRACKING, HW_MOVE_GUIDING}
|
||||
//
|
||||
// struct hardware_moving_state_t {
|
||||
// uint16_t HW_MOVE_STOPPED = 0;
|
||||
// uint16_t HW_MOVE_SLEWING = 111;
|
||||
// uint16_t HW_MOVE_ADJUSTING = 222;
|
||||
// uint16_t HW_MOVE_TRACKING = 333;
|
||||
// uint16_t HW_MOVE_GUIDING = 444;
|
||||
// }
|
||||
requires requires(typename T::hardware_moving_state_t type) {
|
||||
[]() {
|
||||
// mount axes were stopped
|
||||
static constexpr auto v0 = T::hardware_moving_state_t::HW_MOVE_STOPPED;
|
||||
|
||||
// hardware was asked for slewing (move to given celestial point)
|
||||
static constexpr auto v1 = T::hardware_moving_state_t::HW_MOVE_SLEWING;
|
||||
|
||||
// hardware was asked for adjusting after slewing
|
||||
// (adjusting actual mount position to align with target celestial point at the end of slewing process)
|
||||
static constexpr auto v2 = T::hardware_moving_state_t::HW_MOVE_ADJUSTING;
|
||||
|
||||
// hardware was asked for tracking (track target celestial point)
|
||||
static constexpr auto v3 = T::hardware_moving_state_t::HW_MOVE_TRACKING;
|
||||
|
||||
// hardware was asked for guiding
|
||||
// (small corrections to align actual mount position with target celestial point)
|
||||
static constexpr auto v4 = T::hardware_moving_state_t::HW_MOVE_GUIDING;
|
||||
}();
|
||||
};
|
||||
|
||||
|
||||
|
||||
// a class that contains at least time point of measurement, coordinates for x,y axes, its moving rates and moving
|
||||
// type
|
||||
requires requires(typename T::hardware_state_t state) {
|
||||
requires mcc_time_point_c<decltype(state.time_point)>; // time point
|
||||
|
||||
requires mcc_angle_c<decltype(state.X)>; // target or current co-longitude coordinate
|
||||
requires mcc_angle_c<decltype(state.Y)>; // target or current co-latitude coordinate
|
||||
|
||||
requires mcc_angle_c<decltype(state.speedX)>; // moving speed along co-longitude coordinate
|
||||
requires mcc_angle_c<decltype(state.speedY)>; // moving speed along co-latitude coordinate
|
||||
|
||||
requires std::same_as<typename T::hardware_moving_state_t, decltype(state.moving_type)>;
|
||||
};
|
||||
|
||||
// set hardware state:
|
||||
// i.g. set positions (angles) of mount axes with given speeds
|
||||
// NOTE: exact interpretation (or even ignoring) of the given moving speeds is subject of a hardware-class
|
||||
// implementation, e.g. it can be maximal speeds at slewing ramp
|
||||
{ t.hardwareSetState(std::declval<typename T::hardware_state_t>()) } -> std::same_as<typename T::error_t>;
|
||||
|
||||
// get current state
|
||||
{ t.hardwareGetState(std::declval<typename T::hardware_state_t*>()) } -> std::same_as<typename T::error_t>;
|
||||
|
||||
{ t.hardwareStop() } -> std::same_as<typename T::error_t>; // stop any moving
|
||||
{ t.hardwareInit() } -> std::same_as<typename T::error_t>; // initialize hardware
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* AUXILIARY COORDINATE-TRANSFORMATON CLASS CONCEPT */
|
||||
|
||||
// a concept of class that consist of the full set of coordinate transformation mount control components
|
||||
// (celestial coordinate transformation engine, mount hardware encoders readings and pointing correction model)
|
||||
// the set of methods of this class is enough to transform coordinates from ICRS to hardware and back
|
||||
template <typename T>
|
||||
concept mcc_coord_trfm_controls_c = mcc_ccte_c<T> && mcc_hardware_c<T> && mcc_PCM_c<T>;
|
||||
|
||||
|
||||
/* MOUNT TELEMETRY DATA CLASS CONCEPT */
|
||||
|
||||
template <typename T>
|
||||
@ -493,116 +612,6 @@ concept mcc_telemetry_c = std::derived_from<T, mcc_telemetry_interface_t<typenam
|
||||
|
||||
|
||||
|
||||
/* POINTING CORRECTION MODEL CLASS CONCEPT */
|
||||
|
||||
template <typename T>
|
||||
concept mcc_PCM_result_c = requires(T t) {
|
||||
requires mcc_angle_c<decltype(t.dx)>;
|
||||
requires mcc_angle_c<decltype(t.dy)>;
|
||||
};
|
||||
|
||||
template <mcc_error_c RetT, mcc_PCM_result_c ResT>
|
||||
struct mcc_PCM_interface_t {
|
||||
virtual ~mcc_PCM_interface_t() = default;
|
||||
|
||||
template <std::derived_from<mcc_PCM_interface_t> SelfT>
|
||||
RetT computePCM(this SelfT&& self, mcc_celestial_point_c auto pt, ResT* result)
|
||||
{
|
||||
return std::forward<SelfT>(self).computePCM(std::move(pt), result);
|
||||
}
|
||||
|
||||
protected:
|
||||
mcc_PCM_interface_t() = default;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
concept mcc_PCM_c =
|
||||
std::derived_from<T, mcc_PCM_interface_t<typename T::error_t, typename T::pcm_result_t>> && requires {
|
||||
// the 'T' class must contain static constexpr member of 'MccMountType' type
|
||||
requires std::same_as<decltype(T::mountType), const MccMountType>;
|
||||
[]() {
|
||||
static constexpr MccMountType val = T::mountType;
|
||||
return val;
|
||||
}(); // to ensure 'mountType' can be used in compile-time context
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* MOUNT HARDWARE ABSTRACTION CLASS CONCEPT */
|
||||
|
||||
template <typename T>
|
||||
concept mcc_hardware_c = requires(T t, const T t_const) {
|
||||
requires mcc_error_c<typename T::error_t>;
|
||||
|
||||
{ t_const.hardwareName() } -> std::formattable<char>;
|
||||
|
||||
// a type that defines at least HW_MOVE_STOPPED, HW_MOVE_SLEWING, HW_MOVE_ADJUSTING, HW_MOVE_TRACKING
|
||||
// and HW_MOVE_GUIDING compile-time constants. The main purpose of this type is a
|
||||
// possible tunning of hardware hardwareSetState-related commands and detect stop-state
|
||||
//
|
||||
// e.g. an implementations can be as follows:
|
||||
// enum class hardware_moving_state_t: int {HW_MOVE_STOPPED, HW_MOVE_SLEWING, HW_MOVE_ADJUSTING,
|
||||
// HW_MOVE_TRACKING, HW_MOVE_GUIDING}
|
||||
//
|
||||
// struct hardware_moving_state_t {
|
||||
// uint16_t HW_MOVE_STOPPED = 0;
|
||||
// uint16_t HW_MOVE_SLEWING = 111;
|
||||
// uint16_t HW_MOVE_ADJUSTING = 222;
|
||||
// uint16_t HW_MOVE_TRACKING = 333;
|
||||
// uint16_t HW_MOVE_GUIDING = 444;
|
||||
// }
|
||||
requires requires(typename T::hardware_moving_state_t type) {
|
||||
[]() {
|
||||
// mount axes were stopped
|
||||
static constexpr auto v0 = T::hardware_moving_state_t::HW_MOVE_STOPPED;
|
||||
|
||||
// hardware was asked for slewing (move to given celestial point)
|
||||
static constexpr auto v1 = T::hardware_moving_state_t::HW_MOVE_SLEWING;
|
||||
|
||||
// hardware was asked for adjusting after slewing
|
||||
// (adjusting actual mount position to align with target celestial point at the end of slewing process)
|
||||
static constexpr auto v2 = T::hardware_moving_state_t::HW_MOVE_ADJUSTING;
|
||||
|
||||
// hardware was asked for tracking (track target celestial point)
|
||||
static constexpr auto v3 = T::hardware_moving_state_t::HW_MOVE_TRACKING;
|
||||
|
||||
// hardware was asked for guiding
|
||||
// (small corrections to align actual mount position with target celestial point)
|
||||
static constexpr auto v4 = T::hardware_moving_state_t::HW_MOVE_GUIDING;
|
||||
}();
|
||||
};
|
||||
|
||||
|
||||
|
||||
// a class that contains at least time point of measurement, coordinates for x,y axes, its moving rates and moving
|
||||
// type
|
||||
requires requires(typename T::hardware_state_t state) {
|
||||
requires mcc_time_point_c<decltype(state.time_point)>; // time point
|
||||
|
||||
requires mcc_angle_c<decltype(state.X)>; // target or current co-longitude coordinate
|
||||
requires mcc_angle_c<decltype(state.Y)>; // target or current co-latitude coordinate
|
||||
|
||||
requires mcc_angle_c<decltype(state.speedX)>; // moving speed along co-longitude coordinate
|
||||
requires mcc_angle_c<decltype(state.speedY)>; // moving speed along co-latitude coordinate
|
||||
|
||||
requires std::same_as<typename T::hardware_moving_state_t, decltype(state.moving_type)>;
|
||||
};
|
||||
|
||||
// set hardware state:
|
||||
// i.g. set positions (angles) of mount axes with given speeds
|
||||
// NOTE: exact interpretation (or even ignoring) of the given moving speeds is subject of a hardware-class
|
||||
// implementation, e.g. it can be maximal speeds at slewing ramp
|
||||
{ t.hardwareSetState(std::declval<typename T::hardware_state_t>()) } -> std::same_as<typename T::error_t>;
|
||||
|
||||
// get current state
|
||||
{ t.hardwareGetState(std::declval<typename T::hardware_state_t*>()) } -> std::same_as<typename T::error_t>;
|
||||
|
||||
{ t.hardwareStop() } -> std::same_as<typename T::error_t>; // stop any moving
|
||||
{ t.hardwareInit() } -> std::same_as<typename T::error_t>; // initialize hardware
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* PROHIBITED ZONE CLASS CONCEPT */
|
||||
|
||||
template <mcc_error_c RetT>
|
||||
@ -831,6 +840,7 @@ concept mcc_guiding_model_c = requires(T t) {
|
||||
// = 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>
|
||||
concept mcc_generic_mount_c = mcc_hardware_c<T> && mcc_telemetry_c<T> && mcc_pzone_container_c<T> && requires(T t) {
|
||||
requires mcc_error_c<typename T::error_t>;
|
||||
|
||||
@ -15,6 +15,7 @@ namespace mcc
|
||||
enum class MccPZoneContainerErrorCode : int {
|
||||
ERROR_OK,
|
||||
ERROR_NULLPTR,
|
||||
ERROR_INVALID_SIZE,
|
||||
ERROR_INZONE_FUNC,
|
||||
ERROR_TIMETO_FUNC,
|
||||
ERROR_TIMEFROM_FUNC,
|
||||
@ -61,6 +62,8 @@ struct MccPZoneContainerCategory : public std::error_category {
|
||||
return "OK";
|
||||
case MccPZoneContainerErrorCode::ERROR_NULLPTR:
|
||||
return "nullptr argument";
|
||||
case MccPZoneContainerErrorCode::ERROR_INVALID_SIZE:
|
||||
return "invalid range size of input argument";
|
||||
case MccPZoneContainerErrorCode::ERROR_INZONE_FUNC:
|
||||
return "inPZone method error";
|
||||
case MccPZoneContainerErrorCode::ERROR_TIMETO_FUNC:
|
||||
@ -308,16 +311,20 @@ public:
|
||||
return MccPZoneContainerErrorCode::ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
using CPT = std::ranges::range_value_t<R>;
|
||||
if (traits::mcc_range_size(*result) < sizePZones()) {
|
||||
return MccPZoneContainerErrorCode::ERROR_INVALID_SIZE;
|
||||
}
|
||||
|
||||
// using CPT = std::ranges::range_value_t<R>;
|
||||
|
||||
MccCelestialPoint pt;
|
||||
|
||||
auto apply_func = [&](auto& func, auto& pt_arg, size_t i) {
|
||||
error_t ret = func(pt_arg, &pt);
|
||||
if (!ret) {
|
||||
if (traits::mcc_range_size(*result) == i) {
|
||||
std::back_inserter(*result) = CPT();
|
||||
}
|
||||
// if (traits::mcc_range_size(*result) == i) {
|
||||
// std::back_inserter(*result) = CPT();
|
||||
// }
|
||||
|
||||
auto ptr = result->begin();
|
||||
std::ranges::advance(ptr, i);
|
||||
|
||||
@ -129,6 +129,42 @@ public:
|
||||
using hardware_t = std::remove_cvref_t<decltype(*hardware)>;
|
||||
|
||||
|
||||
_toHardwareFunc = [ccte, pcm](const MccCelestialPoint& from_pt, MccCelestialPoint* to_pt) -> error_t {
|
||||
if (to_pt == nullptr) {
|
||||
return MccTelemetryErrorCode::ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
if constexpr (mccIsEquatorialMount(pcm_t::mountType)) {
|
||||
to_pt->pair_kind = MccCoordPairKind::COORDS_KIND_HADEC_APP;
|
||||
} else if constexpr (mccIsAltAzMount(pcm_t::mountType)) {
|
||||
to_pt->pair_kind = MccCoordPairKind::COORDS_KIND_AZALT;
|
||||
} else {
|
||||
static_assert(false, "UNKNOWN MOUNT TYPE!");
|
||||
}
|
||||
|
||||
auto err = ccte->transformCoordinates(from_pt, to_pt);
|
||||
if (err) {
|
||||
return mcc_deduce_error(err, MccTelemetryErrorCode::ERROR_COORD_TRANSFORM);
|
||||
}
|
||||
|
||||
// compute hardware coordinates
|
||||
// WARNING: It is assumed here that PCM corrections have small (arcseconds-arcminutes) values
|
||||
// since ususaly there is no reverse transformation for "hardware-to-apparent" relation!
|
||||
struct {
|
||||
double dx, dy;
|
||||
} pcm_res;
|
||||
|
||||
auto pcm_err = pcm->compute(from_pt, &pcm_res);
|
||||
if (pcm_err) {
|
||||
return mcc_deduce_error<error_t>(pcm_err, MccTelemetryErrorCode::ERROR_PCM_COMP);
|
||||
}
|
||||
|
||||
to_pt->X -= pcm_res.dx;
|
||||
to_pt->Y -= pcm_res.dy;
|
||||
|
||||
return MccTelemetryErrorCode::ERROR_OK;
|
||||
};
|
||||
|
||||
_updateTargetFunc = [ccte, pcm, this](bool only_hw, std::stop_token stop_token) -> error_t {
|
||||
if (!only_hw) {
|
||||
//
|
||||
@ -562,6 +598,23 @@ public:
|
||||
}
|
||||
|
||||
|
||||
error_t transformToHardwareCoords(mcc_celestial_point_c auto pt, mcc_celestial_point_c auto* res)
|
||||
{
|
||||
MccCelestialPoint cpt, rcpt;
|
||||
mcc_copy_celestial_point(pt, &cpt);
|
||||
|
||||
rcpt.time_point = std::chrono::time_point_cast<decltype(rcpt.time_point)>(res->time_point);
|
||||
auto err = _toHardwareFunc(cpt, &rcpt);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
mcc_copy_celestial_point(rcpt, res);
|
||||
|
||||
return MccTelemetryErrorCode::ERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
error_t targetToMountDiff(MccCoordPairKind pair_kind, mcc_angle_c auto* dx, mcc_angle_c auto* dy)
|
||||
{
|
||||
std::lock_guard lock{*_updateMutex};
|
||||
@ -594,6 +647,7 @@ protected:
|
||||
std ::function<error_t(bool, std::stop_token)> _updateTargetFunc{};
|
||||
std::function<error_t(std::stop_token)> _updateFunc{};
|
||||
std::function<error_t()> _setTargetFunc{};
|
||||
std::function<error_t(const MccCelestialPoint&, MccCelestialPoint*)> _toHardwareFunc{};
|
||||
|
||||
std::unique_ptr<std::mutex> _updateMutex;
|
||||
std::unique_ptr<std::condition_variable> _updateCondVar;
|
||||
|
||||
@ -17,9 +17,11 @@ enum class MccSimpleTrackingModelErrorCode : int {
|
||||
ERROR_OK,
|
||||
ERROR_HW_GETSTATE,
|
||||
ERROR_HW_SETSTATE,
|
||||
ERROR_PCM_COMP,
|
||||
ERROR_TELEMETRY_TIMEOUT,
|
||||
ERROR_PZONE_CONTAINER_COMP,
|
||||
ERROR_IN_PZONE,
|
||||
ERROR_NEAR_PZONE,
|
||||
ERROR_UNEXPECTED_AXIS_RATES
|
||||
};
|
||||
|
||||
@ -41,12 +43,9 @@ class is_error_code_enum<mcc::MccSimpleTrackingModelErrorCode> : public true_typ
|
||||
namespace mcc
|
||||
{
|
||||
|
||||
template <MccMountType MOUNT_TYPE>
|
||||
class MccSimpleTrackingModel
|
||||
{
|
||||
public:
|
||||
static constexpr MccMountType mountType = MOUNT_TYPE;
|
||||
|
||||
typedef std::error_code error_t;
|
||||
|
||||
struct tracking_params_t {
|
||||
@ -56,68 +55,126 @@ public:
|
||||
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_generic_mount_c MountT>
|
||||
MccSimpleTrackingModel(MountT* mount) : _stopTracking(new std::atomic_bool())
|
||||
template <mcc_telemetry_data_c TelemetryT,
|
||||
mcc_hardware_c HardwareT,
|
||||
mcc_PCM_c PcmT,
|
||||
mcc_pzone_container_c PZoneContT>
|
||||
MccSimpleTrackingModel(TelemetryT* telemetry, HardwareT* hardware, PcmT* pcm, PZoneContT* pz_cont)
|
||||
: _stopTracking(new std::atomic_bool())
|
||||
{
|
||||
*_stopTracking = false;
|
||||
|
||||
if constexpr (mccIsEquatorialMount(mountType)) {
|
||||
if constexpr (mccIsEquatorialMount(PcmT::mountType)) {
|
||||
_currentTrackParams.trackSpeedX = tracking_params_t::sideralRate; // move along HA-axis with sideral rate
|
||||
_currentTrackParams.trackSpeedY = 0.0;
|
||||
}
|
||||
|
||||
_trackingFunc = [mount, this]() -> error_t {
|
||||
typename MountT::hardware_state_t hw_state;
|
||||
_trackingFunc = [telemetry, hardware, pcm, pz_cont, this]() -> error_t {
|
||||
MccCelestialPoint cpt;
|
||||
typename HardwareT::hardware_state_t hw_state;
|
||||
|
||||
// compute position in future
|
||||
auto err = hardware->hardwareGetState(&hw_state);
|
||||
if (err) {
|
||||
return mcc_deduce_error(err, MccSimpleTrackingModelErrorCode::ERROR_HW_GETSTATE);
|
||||
}
|
||||
|
||||
cpt.time_point = std::chrono::time_point_cast<decltype(cpt.time_point)>(hw_state.time_point);
|
||||
|
||||
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!");
|
||||
}
|
||||
|
||||
cpt.X = hw_state.X;
|
||||
cpt.Y = hw_state.Y;
|
||||
|
||||
struct {
|
||||
double dx, dy;
|
||||
} pcm_res;
|
||||
|
||||
auto pcm_err = pcm->computePCM(cpt, &pcm_res);
|
||||
if (pcm_err) {
|
||||
return mcc_deduce_error(pcm_err, MccSimpleTrackingModelErrorCode::ERROR_PCM_COMP);
|
||||
}
|
||||
|
||||
// to celestial coordinates
|
||||
cpt.X += pcm_res.dx;
|
||||
cpt.Y += pcm_res.dy;
|
||||
|
||||
|
||||
|
||||
if constexpr (mccIsEquatorialMount(PcmT::mountType)) {
|
||||
cpt.pair_kind = MccCoordPairKind::COORDS_KIND_HADEC_APP;
|
||||
|
||||
|
||||
|
||||
if constexpr (mccIsEquatorialMount(mountType)) {
|
||||
// just set sideral rate once
|
||||
auto err = mount->hardwareGetState(&hw_state);
|
||||
if (err) {
|
||||
return mcc_deduce_error(err, MccSimpleTrackingModelErrorCode::ERROR_HW_GETSTATE);
|
||||
}
|
||||
|
||||
// hw_state.time_point;
|
||||
hw_state.speedX = _currentTrackParams.trackSpeedX;
|
||||
hw_state.speedY = _currentTrackParams.trackSpeedY;
|
||||
hw_state.moving_type = MountT::hardware_moving_state_t::HW_MOVE_TRACKING;
|
||||
hw_state.moving_type = HardwareT::hardware_moving_state_t::HW_MOVE_TRACKING;
|
||||
|
||||
err = mount->hardwareSetState(std::move(hw_state));
|
||||
err = hardware->hardwareSetState(std::move(hw_state));
|
||||
if (err) {
|
||||
return mcc_deduce_error(err, MccSimpleTrackingModelErrorCode::ERROR_HW_SETSTATE);
|
||||
}
|
||||
|
||||
// control prohibited zones
|
||||
MccTelemetryData tdata;
|
||||
std::vector<bool> pz_flags;
|
||||
bool inzone_flag;
|
||||
std::vector<std::chrono::duration<double>> pz_timeto; // in seconds
|
||||
|
||||
// std::vector<bool> pz_flags;
|
||||
// bool inzone_flag;
|
||||
|
||||
while (!*_stopTracking) {
|
||||
auto t_err = mount->waitForTelemetryData(&tdata, _currentTrackParams.telemetryTimeout);
|
||||
auto pz_err = pz_cont->timeToPZone(tdata, &pz_timeto);
|
||||
if (pz_err) {
|
||||
return mcc_deduce_error(pz_err, MccSimpleTrackingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < pz_cont->sizePZones(); ++i) {
|
||||
if (pz_timeto[i] <= _currentTrackParams.minTimeToPZone) {
|
||||
return MccSimpleTrackingModelErrorCode::ERROR_NEAR_PZONE;
|
||||
}
|
||||
}
|
||||
|
||||
auto t_err = telemetry->waitForTelemetryData(&tdata, _currentTrackParams.telemetryTimeout);
|
||||
if (t_err) {
|
||||
return mcc_deduce_error(t_err, MccSimpleTrackingModelErrorCode::ERROR_TELEMETRY_TIMEOUT);
|
||||
}
|
||||
|
||||
if (*_stopTracking) {
|
||||
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;
|
||||
}
|
||||
|
||||
auto pz_err = mount->inPZone(tdata, &inzone_flag, &pz_flags);
|
||||
if (pz_err) {
|
||||
return mcc_deduce_error(t_err, MccSimpleTrackingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
||||
}
|
||||
// auto pz_err = mount->inPZone(tdata, &inzone_flag, &pz_flags);
|
||||
// if (pz_err) {
|
||||
// return mcc_deduce_error(t_err, MccSimpleTrackingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
||||
// }
|
||||
|
||||
if (inzone_flag) {
|
||||
// logging
|
||||
return MccSimpleTrackingModelErrorCode::ERROR_IN_PZONE;
|
||||
}
|
||||
// if (inzone_flag) {
|
||||
// // logging
|
||||
// return MccSimpleTrackingModelErrorCode::ERROR_IN_PZONE;
|
||||
// }
|
||||
}
|
||||
|
||||
return MccSimpleTrackingModelErrorCode::ERROR_OK;
|
||||
} else if constexpr (mccIsAltAzMount(mountType)) {
|
||||
} else if constexpr (mccIsAltAzMount(PcmT::mountType)) {
|
||||
static_assert(false, "NOT IMPLEMENTED!");
|
||||
} else {
|
||||
static_assert(false, "UNKNOW MOUNT TYPE!");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user