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.
120 lines
3.5 KiB
120 lines
3.5 KiB
#pragma once
|
|
#include <stdint.h>
|
|
|
|
#include <functional>
|
|
|
|
#include "basic_type.hpp"
|
|
//
|
|
|
|
namespace iflytop {
|
|
using namespace std;
|
|
class I_MiniServoModule {
|
|
public:
|
|
typedef enum { kNormalStop, kBreakStop } StopType_t;
|
|
#pragma pack(1)
|
|
typedef struct {
|
|
u8 id;
|
|
u8 status;
|
|
s32 has_run_time;
|
|
} rotate_cb_status_t;
|
|
|
|
typedef struct {
|
|
u8 id;
|
|
u8 status;
|
|
s32 pos;
|
|
} move_to_cb_status_t;
|
|
|
|
typedef struct {
|
|
u8 id;
|
|
u8 status;
|
|
s32 dpos;
|
|
} move_by_cb_status_t;
|
|
|
|
typedef struct {
|
|
u8 id;
|
|
u8 status;
|
|
s32 has_run_time;
|
|
} run_with_torque_cb_status_t;
|
|
|
|
typedef struct {
|
|
u8 id;
|
|
u8 status;
|
|
s32 pos;
|
|
} move_by_nolimit_cb_status_t;
|
|
|
|
/*******************************************************************************
|
|
* READ *
|
|
*******************************************************************************/
|
|
typedef struct {
|
|
int32_t version;
|
|
} version_t;
|
|
|
|
typedef struct {
|
|
uint8_t status; // 0:normal 1:ÔËÐÐÖÐ 2:offline 3:¹ÊÕÏ
|
|
uint8_t io_state; //
|
|
int16_t torque; //
|
|
int16_t speed; //
|
|
int16_t pos; //
|
|
} status_t;
|
|
|
|
typedef struct {
|
|
uint8_t status;
|
|
uint8_t io_state;
|
|
int16_t torque;
|
|
int16_t speed;
|
|
int16_t pos;
|
|
int16_t voltage;
|
|
int16_t current;
|
|
int16_t temperature;
|
|
int16_t error_flag;
|
|
|
|
} detailed_status_t;
|
|
|
|
/*******************************************************************************
|
|
* CFG *
|
|
*******************************************************************************/
|
|
|
|
typedef struct {
|
|
s16 pos_calibrate;
|
|
} basic_param_t;
|
|
|
|
typedef struct {
|
|
s16 minlimit;
|
|
s16 maxlimit;
|
|
} run_param_t;
|
|
|
|
typedef struct {
|
|
s16 mintemp;
|
|
s16 maxtemp;
|
|
s16 minvoltage;
|
|
s16 maxvoltage;
|
|
s16 mincurrent;
|
|
s16 maxcurrent;
|
|
} warning_limit_param_t;
|
|
|
|
#pragma pack()
|
|
|
|
public:
|
|
virtual int32_t enable(u8 enable) = 0;
|
|
virtual int32_t stop(u8 stop_type) = 0;
|
|
virtual int32_t position_calibrate(s32 calibrate_pos) = 0;
|
|
|
|
virtual int32_t rotate(s32 speed, s32 torque, s32 run_time, function<void(rotate_cb_status_t& status)> status_cb) = 0;
|
|
virtual int32_t move_to(s32 pos, s32 speed, s32 torque, function<void(move_to_cb_status_t& status)> status_cb) = 0;
|
|
virtual int32_t move_by(s32 pos, s32 speed, s32 torque, function<void(move_by_cb_status_t& status)> status_cb) = 0;
|
|
virtual int32_t run_with_torque(s32 torque, s32 run_time, function<void(run_with_torque_cb_status_t& status)> status_cb) = 0;
|
|
virtual int32_t move_by_nolimit(s32 pos, s32 speed, s32 torque, function<void(move_by_nolimit_cb_status_t& status)> status_cb) = 0;
|
|
|
|
virtual int32_t read_version(version_t& version) = 0;
|
|
virtual int32_t read_status(status_t& status) = 0;
|
|
virtual int32_t read_detailed_status(detailed_status_t& debug_info) = 0;
|
|
|
|
virtual int32_t set_run_param(run_param_t& param) = 0;
|
|
virtual int32_t set_basic_param(basic_param_t& param) = 0;
|
|
virtual int32_t set_warning_limit_param(warning_limit_param_t& param) = 0;
|
|
|
|
virtual int32_t get_run_param(run_param_t& param) = 0;
|
|
virtual int32_t get_basic_param(basic_param_t& param) = 0;
|
|
virtual int32_t get_warning_limit_param(warning_limit_param_t& param) = 0;
|
|
};
|
|
} // namespace iflytop
|