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.

115 lines
3.9 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
  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. typedef struct {
  17. int32_t exec_status;
  18. int32_t tox;
  19. int32_t toy;
  20. } move_to_cb_status_t;
  21. typedef struct {
  22. int32_t exec_status;
  23. int32_t dx;
  24. int32_t dy;
  25. } move_by_cb_status_t;
  26. typedef struct {
  27. int32_t exec_status;
  28. } move_to_zero_cb_status_t;
  29. typedef struct {
  30. int32_t exec_status;
  31. int32_t zero_shift_x;
  32. int32_t zero_shift_y;
  33. } move_to_zero_with_calibrate_cb_status_t;
  34. /*******************************************************************************
  35. * READ *
  36. *******************************************************************************/
  37. typedef struct {
  38. int32_t version;
  39. } version_t;
  40. typedef struct {
  41. uint8_t status;
  42. int32_t x;
  43. int32_t y;
  44. u8 iostate; // x_zero_io y_zero_io
  45. } status_t;
  46. typedef struct {
  47. uint8_t status;
  48. int32_t x;
  49. int32_t y;
  50. u8 iostate; // x_zero_io y_zero_io
  51. } detailed_status_t;
  52. /*******************************************************************************
  53. * CFG *
  54. *******************************************************************************/
  55. typedef struct {
  56. u8 robot_type;
  57. u8 x_shaft;
  58. u8 y_shaft;
  59. u8 ihold;
  60. u8 irun;
  61. u16 iholddelay;
  62. s32 distance_scale; // 0.001
  63. s32 shift_x;
  64. s32 shift_y;
  65. s32 acc;
  66. s32 dec;
  67. s32 maxspeed;
  68. s32 min_x;
  69. s32 max_x;
  70. s32 min_y;
  71. s32 max_y;
  72. } run_param_t;
  73. typedef struct {
  74. uint8_t pad;
  75. } warning_limit_param_t;
  76. typedef struct {
  77. u32 move_to_zero_max_d;
  78. u32 leave_from_zero_max_d;
  79. u32 speed;
  80. u32 dec;
  81. } run_to_zero_param_t;
  82. #pragma pack()
  83. public:
  84. virtual int32_t move_to(int32_t x, int32_t y, function<void(move_to_cb_status_t& status)> status_cb) = 0;
  85. virtual int32_t move_by(int32_t dx, int32_t dy, function<void(move_by_cb_status_t& status)> status_cb) = 0;
  86. virtual int32_t move_to_zero(function<void(move_to_zero_cb_status_t& status)> status_cb) = 0;
  87. 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;
  88. virtual int32_t enable(bool venable) = 0;
  89. virtual int32_t stop(uint8_t stopType) = 0;
  90. virtual int32_t force_change_current_pos(int32_t x, int32_t y) = 0;
  91. virtual int32_t read_version(version_t& version) = 0;
  92. virtual int32_t read_status(status_t& status) = 0;
  93. virtual int32_t read_detailed_status(detailed_status_t& debug_info) = 0;
  94. virtual int32_t set_run_param(uint8_t operation, const run_param_t& param, run_param_t& ack) = 0;
  95. 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;
  96. virtual int32_t set_warning_limit_param(uint8_t operation, const warning_limit_param_t& param, warning_limit_param_t& ack) = 0;
  97. };
  98. } // namespace iflytop