custom_type.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. //
  2. // Created by gf on 23-7-21.
  3. // 自定义类型
  4. //
  5. #ifndef NAVIGATION_CUSTOM_TYPE_H
  6. #define NAVIGATION_CUSTOM_TYPE_H
  7. //////////////////////////////////////////////////
  8. /// 封装的enum模板类,解决原生enum无法参与位运算问题
  9. template<typename Enum>
  10. class MyEnum {
  11. using Self = MyEnum<Enum>;
  12. using EnumType = Enum;
  13. public:
  14. MyEnum(const MyEnum &other)
  15. : i(other.i) {
  16. }
  17. MyEnum(const Enum &e)
  18. : i((int) e) {
  19. }
  20. MyEnum(const int ival)
  21. : i(ival) {
  22. }
  23. operator int() const {
  24. return i;
  25. }
  26. MyEnum operator|(const MyEnum &another) {
  27. MyEnum g;
  28. g.i = another.i | Self::i;
  29. return g;
  30. }
  31. MyEnum operator|(const EnumType f) {
  32. return *this | MyEnum(f);
  33. }
  34. MyEnum operator&(const MyEnum &another) {
  35. MyEnum g;
  36. g.i = another.i & Self::i;
  37. return g;
  38. }
  39. MyEnum operator&(const EnumType f) {
  40. return *this & MyEnum(f);
  41. }
  42. private:
  43. int i;
  44. };
  45. //////////////////////////////////////////////////
  46. //////////////////////////////////////////////////
  47. /// MPC返回值
  48. enum MpcError {
  49. success = 0,
  50. no_solution = 1,
  51. failed
  52. };
  53. //////////////////////////////////////////////////
  54. //////////////////////////////////////////////////
  55. /// 基准可选方向
  56. enum Direction {
  57. eForward = 0x0001,
  58. eBackward = 0x0002,
  59. eLeft = 0x0004,
  60. eRight = 0x0008
  61. };
  62. //////////////////////////////////////////////////
  63. //////////////////////////////////////////////////
  64. /// AGV运动模式(最低1位:0单车,1整车。低2位:0同向,1反向。低3位:0主车在前,1主车在后)
  65. enum ActionMode{
  66. eSingle = 0x0000,
  67. eDouble = 0x0001,
  68. eMainInForward = 0x0000,
  69. eMainInBackward = 0x0008,
  70. eChildSameToMain = 0x0000,
  71. eChildOppositeToMain = 0x0002
  72. };
  73. //using ActionModes = MyEnum<ActionMode>;
  74. //////////////////////////////////////////////////
  75. //////////////////////////////////////////////////
  76. /// AGV指令类型
  77. enum ActionType {
  78. eReady = 0,
  79. eStop = 0,
  80. eRotation = 1,
  81. eHorizontal = 2,
  82. eVertical = 3,
  83. eClampClose = 5,
  84. eClampOpen = 6,
  85. eLifterRise = 7, //提升机构上升
  86. eLifterDown =8
  87. };
  88. ///////////////////////////////////////////////
  89. ///////////////////////////////////////////////
  90. /// 提升机构运动状态
  91. enum LifterStatus {
  92. eInvalid = 0,
  93. eRose = 1,//上升到位
  94. eDowned = 2//下降到位
  95. };
  96. //////////////////////////////////////////////////
  97. #endif //NAVIGATION_CUSTOM_TYPE_H