...
This commit is contained in:
parent
8f36f89d7a
commit
7e1709727a
@ -110,16 +110,17 @@ AsibFM700Hardware::error_t AsibFM700Hardware::getState(AsibFM700Hardware::hw_sta
|
||||
|
||||
AsibFM700Hardware::error_t AsibFM700Hardware::setPos(AsibFM700Hardware::axes_pos_t pos)
|
||||
{
|
||||
// according to"SiTech protocol notes" X is DEC-axis and Y is HA-axis
|
||||
double X = pos.y, Y = pos.x;
|
||||
error_t err = static_cast<AsibFM700HardwareErrorCode>(Mount.moveTo(&X, &Y));
|
||||
error_t err;
|
||||
|
||||
// according to"SiTech protocol notes" X is DEC-axis and Y is HA-axis
|
||||
coordpair_t hw_pos{.X = pos.y, .Y = pos.x};
|
||||
|
||||
switch (pos.state) {
|
||||
case hw_state_t::HW_STATE_SLEW: // slew mount
|
||||
err = static_cast<AsibFM700HardwareErrorCode>(Mount.slewTo(&hw_pos, pos.flags));
|
||||
break;
|
||||
case hw_state_t::HW_STATE_TRACK: // interpretate as guiding correction
|
||||
err = static_cast<AsibFM700HardwareErrorCode>(Mount.correctBy(&hw_pos));
|
||||
break;
|
||||
case hw_state_t::HW_STATE_STOP:
|
||||
break;
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
|
||||
|
||||
#include "mcc_mount_concepts.h"
|
||||
#include "mcc_slew_guiding_model_common.h"
|
||||
|
||||
|
||||
namespace mcc
|
||||
@ -192,7 +193,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
std::function<error_t()> _guidingFunc{};
|
||||
std::function<error_t(guiding_point_t)> _guidingFunc{};
|
||||
std::atomic_bool _doCorrection{true};
|
||||
|
||||
|
||||
@ -447,11 +448,11 @@ protected:
|
||||
// compare t_data with computed coordinates ...
|
||||
if (_doCorrection) {
|
||||
if constexpr (mccIsEquatorialMount(pec_t::mountType)) {
|
||||
xr = t_data.mntHA - ha;
|
||||
yr = t_data.mntDEC - dec_app;
|
||||
xr = ha - t_data.mntHA;
|
||||
yr = dec_app - t_data.mntDEC;
|
||||
} else if constexpr (mccIsAltAzMount(pec_t::mountType)) {
|
||||
xr = t_data.mntAZ - az;
|
||||
yr = t_data.mntALT - alt;
|
||||
xr = az - t_data.mntAZ;
|
||||
yr = alt - t_data.mntALT;
|
||||
} else {
|
||||
static_assert(false, "UNSUPPORTED MOUNT TYPE!");
|
||||
}
|
||||
@ -470,9 +471,13 @@ protected:
|
||||
}
|
||||
|
||||
// do correction
|
||||
ax_pos.state = hardware_t::hw_state_t::HW_STATE_TRACK;
|
||||
ax_pos.x = t_data.mntPosX;
|
||||
ax_pos.y = t_data.mntPosY;
|
||||
ax_pos.state = hardware_t::hw_state_t::HW_STATE_TRACK; // indicates to hardware level
|
||||
ax_pos.x = xr;
|
||||
ax_pos.y = yr;
|
||||
// ax_pos.x = t_data.mntPosX;
|
||||
// ax_pos.y = t_data.mntPosY;
|
||||
ax_pos.time_point = t_data.time_point;
|
||||
|
||||
|
||||
// asynchronous operation!
|
||||
auto err = hardware.setPos(std::move(ax_pos));
|
||||
|
||||
@ -73,13 +73,6 @@ struct MccNullLogger {
|
||||
};
|
||||
|
||||
|
||||
struct MccCelestialPoint {
|
||||
typedef double coord_t;
|
||||
|
||||
MccCoordPairKind coordPairKind{MccCoordPairKind::COORDS_KIND_RADEC_ICRS};
|
||||
coord_t x{0.0}, y{0.0};
|
||||
};
|
||||
|
||||
|
||||
} // namespace mcc
|
||||
|
||||
@ -257,8 +250,8 @@ concept mcc_mount_hardware_c = !std::copyable<T> && std::movable<T> && requires(
|
||||
|
||||
{ t_const.getState(std::declval<typename T::hw_state_t&>()) } -> std::same_as<typename T::error_t>;
|
||||
|
||||
{ t.stop() } -> std::same_as<typename T::error_t>;
|
||||
{ t.init() } -> std::same_as<typename T::error_t>;
|
||||
{ t.stop() } -> std::same_as<typename T::error_t>; // stop any moving
|
||||
{ t.init() } -> std::same_as<typename T::error_t>; // initialize hardware
|
||||
};
|
||||
|
||||
|
||||
@ -545,6 +538,5 @@ namespace mcc
|
||||
{
|
||||
|
||||
static_assert(traits::mcc_logger_c<MccNullLogger>, "MccNullLogger INVALID DECLARATION!");
|
||||
static_assert(traits::mcc_celestial_point_c<MccCelestialPoint>, "MccCelestialPoint INVALID DECLARATION!");
|
||||
|
||||
} // namespace mcc
|
||||
|
||||
67
cxx/mcc_slew_guiding_model_common.h
Normal file
67
cxx/mcc_slew_guiding_model_common.h
Normal file
@ -0,0 +1,67 @@
|
||||
#pragma once
|
||||
|
||||
/* MOUNT CONTROL COMPONENTS LIBRARY */
|
||||
|
||||
|
||||
|
||||
/* COMMON DECLARATION FOR SLEW AND GUIDING MODELS GENERIC IMPLEMENTATIONS */
|
||||
|
||||
|
||||
#include "mcc_mount_concepts.h"
|
||||
|
||||
namespace mcc
|
||||
{
|
||||
|
||||
/* DEFAULT CLASS TO REPRESENT CELESTIAL POINT */
|
||||
|
||||
struct MccCelestialPoint {
|
||||
typedef double coord_t;
|
||||
|
||||
MccCoordPairKind coordPairKind{MccCoordPairKind::COORDS_KIND_RADEC_ICRS};
|
||||
coord_t x{0.0}, y{0.0};
|
||||
};
|
||||
|
||||
static_assert(traits::mcc_celestial_point_c<MccCelestialPoint>, "MccCelestialPoint INVALID DECLARATION!");
|
||||
|
||||
|
||||
|
||||
/* CHECK FOR CURRENT MOUNT POSITION IN PROHIBITED ZONES */
|
||||
|
||||
/*
|
||||
* WARNING: if an error occured during telemetry data request
|
||||
* result 'in zone' flags cannot be interpretated correctly!
|
||||
*/
|
||||
template <traits::mcc_mount_telemetry_c TelemetryT,
|
||||
traits::mcc_prohibited_zone_c<typename TelemetryT::mount_telemetry_data_t>... ZTs>
|
||||
auto mccCheckInZonePZTuple(TelemetryT& telemetry,
|
||||
std::tuple<ZTs...>& tuple_zones,
|
||||
std::array<bool, sizeof...(ZTs)>& in_zone)
|
||||
{
|
||||
const auto p_telemetry = &telemetry;
|
||||
const auto p_tuple_zones = &tuple_zones;
|
||||
const auto p_in_zone = &in_zone;
|
||||
|
||||
return [p_telemetry, p_tuple_zones, p_in_zone]<size_t... Is>(std::index_sequence<Is...>) {
|
||||
typename TelemetryT::error_t t_err;
|
||||
(
|
||||
[&t_err]() {
|
||||
if constexpr (Is) {
|
||||
if (t_err) {
|
||||
(*p_in_zone)[Is] = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
typename TelemetryT::mount_telemetry_data_t tdata;
|
||||
t_err = p_telemetry->data(tdata);
|
||||
|
||||
if (!t_err) {
|
||||
(*p_in_zone)[Is] = std::get<Is>(p_tuple_zones).inZone(tdata);
|
||||
}
|
||||
}(),
|
||||
...);
|
||||
}(std::make_index_sequence<sizeof...(ZTs)>{});
|
||||
}
|
||||
|
||||
|
||||
} // namespace mcc
|
||||
@ -9,6 +9,7 @@
|
||||
|
||||
#include "mcc_mount_concepts.h"
|
||||
|
||||
#include "mcc_slew_guiding_model_common.h"
|
||||
|
||||
namespace mcc
|
||||
{
|
||||
@ -431,34 +432,33 @@ protected:
|
||||
// typename telemetry_t::mount_telemetry_data_t::time_point_t prev_time_point{};
|
||||
// typename telemetry_t::mount_telemetry_data_t::coord_t xrate, yrate, mount_rate2;
|
||||
|
||||
std::array<bool, Nzones> in_zone_flag;
|
||||
auto start_poll_tm = std::chrono::steady_clock::now();
|
||||
|
||||
|
||||
while (true) {
|
||||
// check prohibited zones
|
||||
res_err = check_zones(std::make_index_sequence<Nzones>{});
|
||||
if (res_err) {
|
||||
hardware.stop();
|
||||
// res_err = check_zones(std::make_index_sequence<Nzones>{});
|
||||
// if (res_err) {
|
||||
// return res_err;
|
||||
// }
|
||||
|
||||
return res_err;
|
||||
}
|
||||
t_err = mccCheckInZonePZTuple(*telemetry, p_mount_controls->prohibitedZones, in_zone_flag);
|
||||
|
||||
// it is assumed here that telemetry data is in actual state!
|
||||
// t_err = telemetry.data(t_data);
|
||||
// if (t_err) {
|
||||
// hardware.stop();
|
||||
|
||||
// if constexpr (std::same_as<decltype(t_err), error_t>) {
|
||||
// logError(
|
||||
// std::format("An telemetry error occured: code = {} ({})", t_err.value(),
|
||||
// t_err.message()));
|
||||
// return t_err;
|
||||
// } else {
|
||||
// if constexpr (traits::mcc_formattable<decltype(t_err)>) {
|
||||
// logError(std::format("An telemetry error occured: code = {}", t_err));
|
||||
// }
|
||||
// return MccSimpleSlewModelErrorCode::ERROR_TELEMETRY_DATA;
|
||||
// }
|
||||
// }
|
||||
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()));
|
||||
return t_err;
|
||||
} else {
|
||||
if constexpr (traits::mcc_formattable<decltype(t_err)>) {
|
||||
logError(std::format("An telemetry error occured: code = {}", t_err));
|
||||
}
|
||||
return MccSimpleSlewModelErrorCode::ERROR_TELEMETRY_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
err = hardware->getPos(ax_pos);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user