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.

113 lines
3.8 KiB

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