You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
3.9 KiB

#pragma once
#include <stdint.h>
#include <functional>
#include "basic_type.hpp"
//
namespace iflytop {
using namespace std;
class I_XYRobotCtrlModule {
public:
typedef enum { hbot, corexy } RobotType_t;
typedef enum { kNormalStop, kBreakStop } StopType_t;
/*******************************************************************************
* ACTION *
*******************************************************************************/
#pragma pack(1)
typedef struct {
int32_t exec_status;
int32_t tox;
int32_t toy;
} move_to_cb_status_t;
typedef struct {
int32_t exec_status;
int32_t dx;
int32_t dy;
} move_by_cb_status_t;
typedef struct {
int32_t exec_status;
} move_to_zero_cb_status_t;
typedef struct {
int32_t exec_status;
int32_t zero_shift_x;
int32_t zero_shift_y;
} move_to_zero_with_calibrate_cb_status_t;
/*******************************************************************************
* READ *
*******************************************************************************/
typedef struct {
int32_t version;
} version_t;
typedef struct {
uint8_t status;
int32_t x;
int32_t y;
u8 iostate; // x_zero_io y_zero_io
} status_t;
typedef struct {
uint8_t status;
int32_t x;
int32_t y;
u8 iostate; // x_zero_io y_zero_io
} debug_info_t;
/*******************************************************************************
* CFG *
*******************************************************************************/
typedef struct {
u8 robot_type;
u8 x_shaft;
u8 y_shaft;
u8 ihold;
u8 irun;
u16 iholddelay;
s32 distance_scale; // 0.001
s32 shift_x;
s32 shift_y;
s32 acc;
s32 dec;
s32 maxspeed;
s32 min_x;
s32 max_x;
s32 min_y;
s32 max_y;
} run_param_t;
typedef struct {
uint8_t pad;
} warning_limit_param_t;
typedef struct {
u32 move_to_zero_max_d;
u32 leave_from_zero_max_d;
u32 speed;
u32 dec;
} run_to_zero_param_t;
#pragma pack()
public:
virtual int32_t move_to(int32_t x, int32_t y, function<void(move_to_cb_status_t& status)> status_cb) = 0;
virtual int32_t move_by(int32_t dx, int32_t dy, function<void(move_by_cb_status_t& status)> status_cb) = 0;
virtual int32_t move_to_zero(function<void(move_to_zero_cb_status_t& status)> status_cb) = 0;
virtual int32_t move_to_zero_with_calibrate(int32_t x, int32_t y, function<void(move_to_zero_with_calibrate_cb_status_t& status)> status_cb) = 0;
virtual int32_t enable(bool venable) = 0;
virtual int32_t stop(uint8_t stopType) = 0;
virtual int32_t force_change_current_pos(int32_t x, int32_t y) = 0;
virtual int32_t read_version(version_t& version) = 0;
virtual int32_t read_status(status_t& status) = 0;
virtual int32_t read_debug_info(debug_info_t& debug_info) = 0;
virtual int32_t set_run_param(uint8_t operation, const run_param_t& param, run_param_t& ack) = 0;
virtual int32_t set_run_to_zero_param(uint8_t operation, const run_to_zero_param_t& param, run_to_zero_param_t& ack) = 0;
virtual int32_t set_warning_limit_param(uint8_t operation, const warning_limit_param_t& param, warning_limit_param_t& ack) = 0;
};
} // namespace iflytop