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.

84 lines
2.6 KiB

2 years ago
2 years ago
2 years ago
1 year 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 year 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_MiniServoModule {
  9. public:
  10. typedef enum { kNormalStop, kBreakStop } StopType_t;
  11. #pragma pack(1)
  12. /*******************************************************************************
  13. * READ *
  14. *******************************************************************************/
  15. typedef struct {
  16. int32_t version;
  17. } version_t;
  18. typedef struct {
  19. uint8_t status; // 0:normal 1:运行中 2:offline 3:故障
  20. uint8_t ioState; //
  21. int16_t torque; //
  22. int16_t speed; //
  23. int16_t pos; //
  24. } status_t;
  25. typedef struct {
  26. uint8_t status;
  27. uint8_t ioState;
  28. int16_t torque;
  29. int16_t speed;
  30. int16_t pos;
  31. int16_t voltage;
  32. int16_t current;
  33. int16_t temperature;
  34. int16_t error_flag;
  35. } detailed_status_t;
  36. /*******************************************************************************
  37. * CFG *
  38. *******************************************************************************/
  39. typedef struct {
  40. u16 posCalibrate;
  41. u16 minlimit;
  42. u16 maxlimit;
  43. u16 maxtemp;
  44. u16 minvoltage;
  45. u16 maxvoltage;
  46. u16 protectCurrent;
  47. u16 protectTorque;
  48. } basic_param_t;
  49. #pragma pack()
  50. public:
  51. // virtual int32_t enable(u8 enable) = 0;
  52. // virtual int32_t stop(u8 stop_type) = 0;
  53. // virtual int32_t position_calibrate(s32 calibrate_pos) = 0;
  54. // virtual int32_t rotate(s32 speed, s32 torque, s32 run_time, action_cb_status_t status_cb) = 0;
  55. // virtual int32_t move_to(s32 pos, s32 speed, s32 torque, action_cb_status_t status_cb) = 0;
  56. // virtual int32_t move_by(s32 pos, s32 speed, s32 torque, action_cb_status_t status_cb) = 0;
  57. // virtual int32_t run_with_torque(s32 torque, s32 run_time, action_cb_status_t status_cb) = 0;
  58. // virtual int32_t move_by_nolimit(s32 pos, s32 speed, s32 torque, action_cb_status_t status_cb) = 0;
  59. // virtual int32_t move_forward(s32 torque) = 0;
  60. // virtual int32_t move_backward(s32 torque) = 0;
  61. // virtual int32_t read_version(version_t& version) = 0;
  62. // virtual int32_t read_status(status_t& status) = 0;
  63. // virtual int32_t read_detailed_status(detailed_status_t& debug_info) = 0;
  64. // virtual int32_t set_basic_param(basic_param_t& param) = 0;
  65. // virtual int32_t get_basic_param(basic_param_t& param) = 0;
  66. virtual ~I_MiniServoModule() {}
  67. };
  68. } // namespace iflytop