radar_sensor.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #pragma once
  2. #include "../common/notifier.h"
  3. #include <thread>
  4. #include <unordered_map>
  5. #include <mutex>
  6. #pragma pack(1)
  7. struct Radar_Frame
  8. {
  9. uint8_t Addr=0x01;
  10. uint8_t Func=0x03;
  11. uint8_t RegAddr[2]={0x01,0x06};
  12. uint8_t RegData[2]={0x00,0x04};
  13. uint16_t crc;
  14. };
  15. struct Radar_Ret
  16. {
  17. uint8_t Addr=0x01;
  18. uint8_t Func=0x03;
  19. uint8_t RegAddr={0x06};
  20. uint8_t RegData[8];
  21. uint16_t crc;
  22. };
  23. #pragma pack()
  24. struct radar_node
  25. {
  26. // int32_t rid;
  27. uint32_t range;
  28. int64_t radar_tick=0;//std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();;
  29. };
  30. class CMessageQueue;
  31. class CRadarSensor//:public ISensorNotify
  32. {
  33. public:
  34. CRadarSensor(CMessageQueue *q);
  35. void Notify(int8_t * buffer,int32_t size);
  36. void SetSensorSocket(SensorSocket<CRadarSensor>* can);
  37. void Start();
  38. void Stop();
  39. void SetChannelReady(bool ret){_channelReady=ret;}
  40. const radar_node* GetRadarInfo(){ return _node;}
  41. private:
  42. private:
  43. CMessageQueue* _message;
  44. SensorSocket<CRadarSensor> * _socket;
  45. //std::mutex _lock;
  46. //int32_t _info[7]={-1,-1,-1,-1,-1,-1,-1};
  47. bool _channelReady;
  48. radar_node _node[7];
  49. int64_t _tick=0;
  50. int16_t mask=0x0;
  51. };