time_manager.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #ifndef TIME_MANAGER_H
  2. #define TIME_MANAGER_H
  3. #include "radarobjectarray.pb.h"
  4. //#include "cameraobjectarray.pb.h"
  5. #include "objectarray.pb.h"
  6. #include "obstacles.pb.h"
  7. #include "worker.h"
  8. #include <memory>
  9. #include <chrono>
  10. #include <mutex>
  11. #include <algorithm>
  12. namespace iv {
  13. class TimeManager: public Worker
  14. {
  15. public:
  16. typedef iv::radar::radarobjectarray RadarDataType;
  17. typedef iv::lidar::objectarray LidarDataType;
  18. // typedef iv::vision::cameraobjectarray CameraDataType;
  19. typedef iv::vision::ObstacleInfo VisionDataType;
  20. typedef std::chrono::system_clock::time_point TimeType;
  21. // typedef std::function<void(RadarDataType&, LidarDataType&,CameraDataType&)> DataCallback;
  22. // typedef std::function<void(RadarDataType&,CameraDataType&)> RVCallback;
  23. typedef std::function<void(RadarDataType&, LidarDataType&,VisionDataType&)> DataCallback;
  24. typedef std::function<void(RadarDataType&,VisionDataType&)> RVCallback;
  25. TimeManager(const float hz);
  26. void SetDataCallback(DataCallback rlvcallback);
  27. void SetRVCallback(RVCallback rvcallback);
  28. void DoWork();
  29. void CacheRadarData(const iv::radar::radarobjectarray& radar_object_array);
  30. void CacheLidarData(const iv::lidar::objectarray& lidar_object_array);
  31. // void CacheCameraData(const iv::vision::cameraobjectarray& camera_object_array);
  32. void CacheCameraData(const iv::vision::ObstacleInfo& vision_object_array);
  33. void GetDataRLV(void);
  34. void GetDataRV(void);
  35. private:
  36. std::mutex mutex_data_;
  37. private:
  38. ///cache data
  39. std::vector<iv::lidar::objectarray> lidar_cache_;
  40. std::vector<iv::radar::radarobjectarray> radar_cache_;
  41. std::vector<iv::vision::ObstacleInfo> vision_cache_;
  42. private:
  43. iv::lidar::objectarray lidar_objects_;
  44. iv::radar::radarobjectarray radar_objects_;
  45. iv::vision::ObstacleInfo vision_objects_;
  46. static const int lidarCacheSize = 10;
  47. static const int radarCacheSzie = 30;
  48. static const int cameraCacheSzie = 20;
  49. private:
  50. DataCallback data_call_back_;
  51. RVCallback rv_call_back_;
  52. };
  53. }
  54. #endif // TIME_MANAGER_H