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.

106 lines
3.2 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. #pragma once
  2. #include <stdint.h>
  3. #include <functional>
  4. #include "basic_type.hpp"
  5. //
  6. namespace iflytop {
  7. using namespace std;
  8. class I_XYRobotCtrlModule {
  9. public:
  10. typedef enum { hbot, corexy } RobotType_t;
  11. typedef enum { kNormalStop, kBreakStop } StopType_t;
  12. /*******************************************************************************
  13. * ACTION *
  14. *******************************************************************************/
  15. #pragma pack(1)
  16. /*******************************************************************************
  17. * READ *
  18. *******************************************************************************/
  19. typedef struct {
  20. int32_t version;
  21. } version_t;
  22. typedef struct {
  23. uint8_t status;
  24. u8 iostate; // x_zero_io y_zero_io
  25. int32_t x;
  26. int32_t y;
  27. } status_t;
  28. typedef struct {
  29. uint8_t status;
  30. u8 iostate; // x_zero_io y_zero_io
  31. int32_t x;
  32. int32_t y;
  33. } detailed_status_t;
  34. /*******************************************************************************
  35. * CFG *
  36. *******************************************************************************/
  37. typedef struct {
  38. s32 robot_type;
  39. s32 x_shaft;
  40. s32 y_shaft;
  41. s32 ihold;
  42. s32 irun;
  43. s32 iholddelay;
  44. s32 distance_scale; // 0.001
  45. s32 shift_x;
  46. s32 shift_y;
  47. // limit
  48. s32 acc;
  49. s32 dec;
  50. s32 breakdec;
  51. s32 maxspeed;
  52. s32 min_x;
  53. s32 max_x;
  54. s32 min_y;
  55. s32 max_y;
  56. s32 run_to_zero_max_d;
  57. s32 run_to_zero_speed;
  58. s32 run_to_zero_dec;
  59. s32 look_zero_edge_max_d;
  60. s32 look_zero_edge_speed;
  61. s32 look_zero_edge_dec;
  62. } base_param_t;
  63. typedef struct {
  64. uint8_t pad;
  65. } warning_limit_param_t;
  66. typedef struct {
  67. base_param_t basecfg;
  68. } flash_config_t;
  69. #pragma pack()
  70. public:
  71. virtual int32_t move_to(int32_t x, int32_t y, int speed, action_cb_status_t status_cb) = 0;
  72. virtual int32_t move_by(int32_t dx, int32_t dy, int speed, action_cb_status_t status_cb) = 0;
  73. virtual int32_t move_by_no_limit(int32_t dx, int32_t dy, int speed, action_cb_status_t status_cb) = 0;
  74. virtual int32_t move_to_zero(action_cb_status_t status_cb) = 0;
  75. virtual int32_t move_to_zero_with_calibrate(int32_t nowx, int32_t nowxy, action_cb_status_t status_cb) = 0;
  76. virtual int32_t enable(bool venable) = 0;
  77. virtual int32_t stop(uint8_t stopType) = 0;
  78. virtual int32_t force_change_current_pos(int32_t x, int32_t y) = 0;
  79. virtual int32_t read_version(version_t& version) = 0;
  80. virtual int32_t read_status(status_t& status) = 0;
  81. virtual int32_t read_detailed_status(detailed_status_t& debug_info) = 0;
  82. virtual int32_t set_base_param(const base_param_t& param) = 0;
  83. virtual int32_t get_base_param(base_param_t& ack) = 0;
  84. virtual int32_t flush() = 0;
  85. virtual int32_t factory_reset() = 0;
  86. virtual ~I_XYRobotCtrlModule() {}
  87. };
  88. } // namespace iflytop