custom_type.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. //
  2. // Created by gf on 23-7-21.
  3. // 自定义类型
  4. //
  5. #ifndef NAVIGATION_CUSTOM_TYPE_H
  6. #define NAVIGATION_CUSTOM_TYPE_H
  7. #include <map>
  8. //////////////////////////////////////////////////
  9. /// 封装的enum模板类,解决原生enum无法参与位运算问题
  10. template<typename Enum>
  11. class MyEnum {
  12. using Self = MyEnum<Enum>;
  13. using EnumType = Enum;
  14. public:
  15. MyEnum(const MyEnum &other)
  16. : i(other.i) {
  17. }
  18. MyEnum(const Enum &e)
  19. : i((int) e) {
  20. }
  21. MyEnum(const int ival)
  22. : i(ival) {
  23. }
  24. operator int() const {
  25. return i;
  26. }
  27. MyEnum operator|(const MyEnum &another) {
  28. MyEnum g;
  29. g.i = another.i | Self::i;
  30. return g;
  31. }
  32. MyEnum operator|(const EnumType f) {
  33. return *this | MyEnum(f);
  34. }
  35. MyEnum operator&(const MyEnum &another) {
  36. MyEnum g;
  37. g.i = another.i & Self::i;
  38. return g;
  39. }
  40. MyEnum operator&(const EnumType f) {
  41. return *this & MyEnum(f);
  42. }
  43. private:
  44. int i;
  45. };
  46. //////////////////////////////////////////////////
  47. //////////////////////////////////////////////////
  48. /// MPC返回值
  49. enum MpcError {
  50. success = 0,
  51. no_solution = 1,
  52. failed
  53. };
  54. //////////////////////////////////////////////////
  55. //////////////////////////////////////////////////
  56. /// 基准可选方向
  57. enum Direction {
  58. eForward = 0x0001,
  59. eBackward = 0x0002,
  60. eLeft = 0x0004,
  61. eRight = 0x0008
  62. };
  63. //////////////////////////////////////////////////
  64. //////////////////////////////////////////////////
  65. /// AGV运动模式(最低1位:0单车,1整车。低2位:0同向,1反向。低3位:0主车在前,1主车在后)
  66. enum ActionMode{
  67. eSingle = 0x0000,
  68. eDouble = 0x0001,
  69. eMainInForward = 0x0000,
  70. eMainInBackward = 0x0008,
  71. eChildSameToMain = 0x0000,
  72. eChildOppositeToMain = 0x0002
  73. };
  74. //using ActionModes = MyEnum<ActionMode>;
  75. //////////////////////////////////////////////////
  76. //////////////////////////////////////////////////
  77. /// AGV指令类型
  78. enum ActionType {
  79. eReady = 0,
  80. eStop = 0,
  81. eRotation = 1,
  82. eHorizontal = 2,
  83. eVertical = 3,
  84. eClampClose = 5,
  85. eClampHalfOpen = 6,
  86. eLifterRise = 7, //提升机构上升
  87. eLifterDown =8,
  88. eClampFullyOpen = 9
  89. };
  90. //////////////////////////////////////////////////
  91. //////////////////////////////////////////////////
  92. /// 提升机构运动状态
  93. enum LifterStatus {
  94. eInvalid = 0,
  95. eRose = 1,//上升到位
  96. eDowned = 2//下降到位
  97. };
  98. //////////////////////////////////////////////////
  99. //////////////////////////////////////////////////
  100. /// 并行夹持和提升机构运作
  101. enum eClamLiftActionType{
  102. eByteCLampClose = 1,
  103. eByteClampHalfOpen=2,
  104. eByteClampFullyOpen=4,
  105. eByteLifterDown=8,
  106. eByteLifterUp=16
  107. };
  108. //////////////////////////////////////////////////
  109. //////////////////////////////////////////////////
  110. /// plc区域+编号载车板 对应 车位表
  111. enum eRegionId{
  112. eRegion0 = 0,
  113. eRegion1 = 1,
  114. eRegion2,
  115. eRegion3,
  116. eRegion4,
  117. eRegion5,
  118. eRegion6,
  119. eRegion7,
  120. eRegion8,
  121. eRegion9,
  122. eRegion10,
  123. eRegion11
  124. };
  125. enum eCarrierIdInRegionId{
  126. eCarrier0 = 0,
  127. eCarrier1 = 1,
  128. eCarrier2,
  129. eCarrier3,
  130. eCarrier4,
  131. eCarrier5,
  132. eCarrier6,
  133. eCarrier7,
  134. eCarrier8,
  135. eCarrier9,
  136. eCarrier10,
  137. eCarrier11
  138. };
  139. typedef std::pair<short, short > Region_Carry;
  140. typedef std::map<int ,Region_Carry> SpaceNo2Region_Carry;
  141. //////////////////////////////////////////////////
  142. #endif //NAVIGATION_CUSTOM_TYPE_H