control_sensor.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #pragma once
  2. #include "../common/comm.h"
  3. #include "../common/notifier.h"
  4. #include "../common/sensor_socket.h"
  5. #include <thread>
  6. #include <mutex>
  7. class CEgoWindow;
  8. class CMessageQueue;
  9. //表示传感器数据
  10. enum Sensor_Collection
  11. {
  12. Sensor_None = 0x0,
  13. Sensor_ER = 0x1, //0x181
  14. Sensor_Steer = 0x2, //0x185
  15. Sensor_Signal = 0x4, //0x281
  16. Sensor_Drive = 0x8, //0x381
  17. Sensor_Arm =0x10 ,//0x481
  18. //Sensor_Switch=0x20,
  19. Sensor_All = 0x1F
  20. };
  21. enum OpSide
  22. {
  23. Empty,
  24. Arm,
  25. Bucket
  26. };
  27. /*
  28. 舱端车辆控制
  29. 下发指令到车端
  30. */
  31. class CControlSensor
  32. {
  33. public:
  34. CControlSensor(CMessageQueue * window);
  35. bool Start();
  36. void Stop();
  37. void Notify(TPCANMsg& canmsg,uint64_t timestamp);
  38. void SetEngineRPM(int32_t rpm);
  39. ControlStatus CheckStatus();
  40. TPCANStatus SendCANMessage(TPCANMsg* CANMsg);
  41. bool _automous = true;
  42. private:
  43. void Run();
  44. TPCANStatus ReadMessage();
  45. //TPCANStatus ReadMessageFD();
  46. void ReadMessages();
  47. private:
  48. CEgoWindow* _window;
  49. Sensor_Collection _collection;
  50. TPCANHandle _handle=-1;
  51. bool _isFD;
  52. std::thread _thread;
  53. bool _run;
  54. int16_t _last_speed = 0xF000;
  55. int64_t _startup = 0;
  56. int32_t _rpm = 0;
  57. /*
  58. bool _er_enabling = false;
  59. bool _er_motoring = false;
  60. bool _er_gear = false;
  61. bool _er_turnl = false;
  62. bool _er_turnr = false;
  63. bool _F1 = false;
  64. bool _F2 = false;
  65. bool _F3 = false;
  66. bool _F4 = false;
  67. bool _R1 = false;
  68. bool _R2 = false;
  69. bool _R3 = false;
  70. bool _R4 = false;
  71. bool _N1 = false;
  72. bool _N2 = false;
  73. bool _N3 = false;
  74. bool _N4 = false;
  75. bool _keycc = false;
  76. bool _keyC = false;
  77. bool _keyR = false;
  78. bool _switchF = false;
  79. bool _switchR = false;
  80. bool _startup=false;
  81. bool _horn = false; //喇叭
  82. bool _emergeny=false; //急停
  83. bool _colddown = false; //冷却
  84. bool _firewarning = false;
  85. bool _hyp = false; //液压使能
  86. bool _flight = false;
  87. bool _blight = false;
  88. bool _beamlight = false;
  89. bool _nearlight = false;
  90. bool _smalllight = false;
  91. bool _leftturn = false;
  92. bool _rightturn = false;
  93. bool _louver_open = false;
  94. bool _louver_close = false;
  95. bool _lock_on_off = false; //锁销
  96. bool _jar_on_off = false; //敲罐
  97. bool _park_lift = false;
  98. bool _chain_lift = false;
  99. bool _enabling = false;
  100. bool _emergency = false;
  101. bool _resume=false;
  102. int16_t _gear = 1;
  103. int16_t _accel = 0;
  104. int16_t _steer = 0;
  105. int16_t _flip = 0;
  106. int16_t _armL = 0;
  107. int16_t _armR = 0;
  108. */
  109. cannet_frame frames[8];
  110. int32_t _old_steer = 0;
  111. uint64_t _old_timestamp = 0;
  112. bool isFront = false;
  113. bool isSliping = false;
  114. bool _remote_active = false;
  115. uint64_t _active_tick = 0;
  116. };