radar_sim.cpp 759 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <stdint.h>
  2. #include "Protocol.pb.h"
  3. #include "../common/comm.h"
  4. #include "./include/EgoInterface.h"
  5. #include "EgoClient.h"
  6. #include "radar_sim.h"
  7. CRadarSim::CRadarSim(CEgoClient* radar) :_radar(radar)
  8. {
  9. }
  10. void CRadarSim::Start()
  11. {
  12. }
  13. void CRadarSim::Stop()
  14. {
  15. }
  16. void CRadarSim::OnPeerMessage(int16_t cmd, int16_t length, const void* data)
  17. {
  18. RemoNet::CCSensor Req;
  19. Req.ParseFromArray(data, length);
  20. int32_t range[7] = { 0 };
  21. int32_t count = Req.node_size();
  22. for (int32_t i = 0; i < count; i++)
  23. {
  24. //range[i] = Req.range(i);
  25. auto& n = Req.node(i);
  26. range[n.id()] = n.range();
  27. }
  28. _radar->OnRadarData(range[0], range[1], range[2], range[3], range[4], range[5],range[6]);
  29. _radar->OnEncodeData(Req.left_encode(), Req.right_encode());
  30. }