remove guiding model
now it are only slewing and tracking states
This commit is contained in:
15
asibfm700/CMakeLists.txt
Normal file
15
asibfm700/CMakeLists.txt
Normal file
@@ -0,0 +1,15 @@
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
|
||||
# set(CMAKE_BUILD_TYPE Release)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
||||
|
||||
|
||||
set(ASIBFM700_LIB_SRC asibfm700_common.h asibfm700_servocontroller.h asibfm700_servocontroller.cpp)
|
||||
|
||||
set(ASIBFM700_LIB asibfm700mount)
|
||||
add_library(${ASIBFM700_LIB} STATIC ${ASIBFM700_LIB_SRC})
|
||||
target_link_libraries(${ASIBFM700_LIB} PRIVATE mcc1)
|
||||
11
asibfm700/asibfm700_common.h
Normal file
11
asibfm700/asibfm700_common.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
/* AstroSib FORK MOUNT FM-700 CONTROL LIBRARY */
|
||||
|
||||
|
||||
/* COMMON LIBRARY DEFINITIONS */
|
||||
|
||||
namespace asibfm700
|
||||
{
|
||||
|
||||
} // namespace asibfm700
|
||||
84
asibfm700/asibfm700_servocontroller.cpp
Normal file
84
asibfm700/asibfm700_servocontroller.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
#include "asibfm700_servocontroller.h"
|
||||
|
||||
namespace asibfm700
|
||||
{
|
||||
|
||||
AsibFM700ServoController::AsibFM700ServoController() : _hardwareConfig(), _setStateMutex(new std::mutex) {}
|
||||
|
||||
AsibFM700ServoController::AsibFM700ServoController(hardware_config_t config) : AsibFM700ServoController()
|
||||
{
|
||||
_hardwareConfig = std::move(config);
|
||||
|
||||
_hardwareConfig.devConfig.MountDevPath = const_cast<char*>(_hardwareConfig.MountDevPath.c_str());
|
||||
_hardwareConfig.devConfig.EncoderDevPath = const_cast<char*>(_hardwareConfig.EncoderDevPath.c_str());
|
||||
_hardwareConfig.devConfig.EncoderXDevPath = const_cast<char*>(_hardwareConfig.EncoderXDevPath.c_str());
|
||||
_hardwareConfig.devConfig.EncoderYDevPath = const_cast<char*>(_hardwareConfig.EncoderYDevPath.c_str());
|
||||
}
|
||||
|
||||
|
||||
constexpr std::string_view AsibFM700ServoController::hardwareName() const
|
||||
{
|
||||
return "Sidereal-ServoControllerII";
|
||||
}
|
||||
|
||||
AsibFM700ServoController::error_t AsibFM700ServoController::hardwareStop()
|
||||
{
|
||||
return static_cast<AsibFM700ServoControllerErrorCode>(Mount.stop());
|
||||
}
|
||||
|
||||
AsibFM700ServoController::error_t AsibFM700ServoController::hardwareInit()
|
||||
{
|
||||
return static_cast<AsibFM700ServoControllerErrorCode>(Mount.init(&_hardwareConfig.devConfig));
|
||||
}
|
||||
|
||||
|
||||
AsibFM700ServoController::error_t AsibFM700ServoController::hardwareSetState(hardware_state_t state)
|
||||
{
|
||||
// time point from sidservo library is 'double' number represented UNIXTIME with
|
||||
// microseconds/nanoseconds precision
|
||||
double tp = std::chrono::duration<double>(state.time_point.time_since_epoch()).count();
|
||||
|
||||
std::lock_guard lock{*_setStateMutex};
|
||||
|
||||
// according to"SiTech protocol notes" X is DEC-axis and Y is HA-axis
|
||||
coordval_pair_t cvalpair{.X{.val = state.Y, .t = tp}, .Y{.val = state.X, .t = tp}};
|
||||
coordpair_t cpair{.X = state.Y, .Y = state.X};
|
||||
|
||||
// correctTo is asynchronous function!!!
|
||||
//
|
||||
// according to the Eddy's implementation of the LibSidServo library it is safe
|
||||
// to pass the addresses of 'cvalpair' and 'cpair' automatic variables
|
||||
auto err = static_cast<AsibFM700ServoControllerErrorCode>(Mount.correctTo(&cvalpair, &cpair));
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
AsibFM700ServoController::error_t AsibFM700ServoController::hardwareGetState(hardware_state_t* state)
|
||||
{
|
||||
using tp_t = decltype(hardware_state_t::time_point);
|
||||
|
||||
mountdata_t mdata;
|
||||
|
||||
error_t err = static_cast<AsibFM700ServoControllerErrorCode>(Mount.getMountData(&mdata));
|
||||
if (!err) {
|
||||
// time point from sidservo library is 'double' number represented UNIXTIME with
|
||||
// microseconds/nanoseconds precision (must be equal for encXposition and encYposition)
|
||||
|
||||
using secs_t = std::chrono::duration<double>;
|
||||
|
||||
secs_t secs = secs_t{mdata.encXposition.t};
|
||||
state->time_point = tp_t{std::chrono::duration_cast<tp_t::duration>(secs)};
|
||||
|
||||
// according to "SiTech protocol notes" X is DEC-axis and Y is HA-axis
|
||||
state->X = mdata.encYposition.val;
|
||||
state->Y = mdata.encXposition.val;
|
||||
|
||||
state->speedX = mdata.encYspeed.val;
|
||||
state->speedY = mdata.encXspeed.val;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
} // namespace asibfm700
|
||||
124
asibfm700/asibfm700_servocontroller.h
Normal file
124
asibfm700/asibfm700_servocontroller.h
Normal file
@@ -0,0 +1,124 @@
|
||||
#pragma once
|
||||
|
||||
#include <mcc_defaults.h>
|
||||
#include <mcc_generics.h>
|
||||
|
||||
#include "../LibSidServo/sidservo.h"
|
||||
|
||||
|
||||
namespace asibfm700
|
||||
{
|
||||
|
||||
/* error codes enum definition */
|
||||
|
||||
enum class AsibFM700ServoControllerErrorCode : int {
|
||||
// error codes from sidservo library
|
||||
ERROR_OK = MCC_E_OK,
|
||||
ERROR_FATAL = MCC_E_FATAL,
|
||||
ERROR_BADFORMAT = MCC_E_BADFORMAT,
|
||||
ERROR_ENCODERDEV = MCC_E_ENCODERDEV,
|
||||
ERROR_MOUNTDEV = MCC_E_MOUNTDEV,
|
||||
ERROR_FAILED = MCC_E_FAILED,
|
||||
// my codes ...
|
||||
};
|
||||
|
||||
// error category
|
||||
struct AsibFM700HardwareErrorCategory : public std::error_category {
|
||||
const char* name() const noexcept;
|
||||
std::string message(int ec) const;
|
||||
|
||||
static const AsibFM700HardwareErrorCategory& get();
|
||||
};
|
||||
|
||||
|
||||
static inline std::error_code make_error_code(AsibFM700ServoControllerErrorCode ec)
|
||||
{
|
||||
return std::error_code(static_cast<int>(ec), AsibFM700HardwareErrorCategory::get());
|
||||
}
|
||||
|
||||
} // namespace asibfm700
|
||||
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
template <>
|
||||
class is_error_code_enum<asibfm700::AsibFM700ServoControllerErrorCode> : public true_type
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
||||
|
||||
namespace asibfm700
|
||||
{
|
||||
|
||||
class AsibFM700ServoController final
|
||||
{
|
||||
public:
|
||||
typedef std::error_code error_t;
|
||||
|
||||
enum class hardware_moving_state_t : int {
|
||||
HW_MOVE_STOPPED,
|
||||
HW_MOVE_SLEWING,
|
||||
HW_MOVE_ADJUSTING,
|
||||
HW_MOVE_TRACKING,
|
||||
HW_MOVE_GUIDING
|
||||
};
|
||||
|
||||
struct hardware_state_t {
|
||||
static constexpr mcc::MccCoordPairKind pair_kind = mcc::MccCoordPairKind::COORDS_KIND_HADEC_APP;
|
||||
mcc::MccTimePoint time_point;
|
||||
|
||||
double X, Y, speedX, speedY;
|
||||
|
||||
hardware_moving_state_t moving_state;
|
||||
};
|
||||
|
||||
|
||||
struct hardware_config_t {
|
||||
// the 'char*' fields from conf_t:
|
||||
// wrap it to std::string
|
||||
std::string MountDevPath;
|
||||
std::string EncoderDevPath;
|
||||
std::string EncoderXDevPath;
|
||||
std::string EncoderYDevPath;
|
||||
|
||||
conf_t devConfig;
|
||||
hardware_configuration_t hwConfig;
|
||||
};
|
||||
|
||||
/* constructors and destructor */
|
||||
|
||||
AsibFM700ServoController();
|
||||
|
||||
AsibFM700ServoController(hardware_config_t config);
|
||||
|
||||
AsibFM700ServoController(const AsibFM700ServoController&) = delete;
|
||||
AsibFM700ServoController& operator=(const AsibFM700ServoController&) = delete;
|
||||
|
||||
AsibFM700ServoController(AsibFM700ServoController&&);
|
||||
AsibFM700ServoController& operator=(AsibFM700ServoController&&);
|
||||
|
||||
~AsibFM700ServoController();
|
||||
|
||||
/* public methods */
|
||||
|
||||
constexpr std::string_view hardwareName() const;
|
||||
|
||||
error_t hardwareSetState(hardware_state_t state);
|
||||
error_t hardwareGetState(hardware_state_t* state);
|
||||
|
||||
error_t hardwareStop();
|
||||
error_t hardwareInit();
|
||||
|
||||
void hardwareUpdateConfig(conf_t cfg);
|
||||
void hardwareUpdateConfig(hardware_configuration_t cfg);
|
||||
|
||||
private:
|
||||
hardware_config_t _hardwareConfig;
|
||||
|
||||
std::unique_ptr<std::mutex> _setStateMutex;
|
||||
};
|
||||
|
||||
} // namespace asibfm700
|
||||
Reference in New Issue
Block a user