loc_message.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. #ifndef __LOC_MESSAGE__HPP
  2. #define __LOC_MESSAGE__HPP
  3. #include "ant.h"
  4. struct loc_message
  5. {
  6. std::shared_ptr<site> m_sit;
  7. uint64_t m_num_ticks; //tof时间片m_tof或tdoa相对root时间
  8. uint64_t m_loc_time;
  9. uint64_t m_time_tmp;
  10. uint32_t m_card_id;
  11. int32_t m_card_ct;
  12. int8_t m_card_type;
  13. int8_t m_ant_id;
  14. int16_t m_rav;
  15. float m_acc;
  16. uint16_t m_sync_ct;
  17. uint16_t m_rssi;
  18. uint16_t m_batstatus;
  19. // tdoa内容
  20. uint64_t m_interpolation; // 线性插值
  21. uint8_t m_loc_type; // 数据类型:0为tof,1为tdoa
  22. uint8_t m_loc_dimension; // 定位维度
  23. double m_freq; // 卡定位频率值
  24. // pdoa内容
  25. double m_poa[3]; // 三天线的相位值
  26. double m_angle; // 天线角度
  27. loc_message()
  28. :m_num_ticks(0)
  29. {
  30. }
  31. int tool_index()const
  32. {
  33. return m_sit->index();
  34. }
  35. loc_message(std::shared_ptr<site> s,uint64_t num_ticks,uint64_t timestamp,uint64_t time_tmp,
  36. uint32_t cardid,int32_t ct,int8_t type,int8_t antid,
  37. int16_t rav,float acc,uint16_t sync_ct,uint16_t rssi,uint16_t batstatus)
  38. :m_sit(s)
  39. ,m_num_ticks(num_ticks)
  40. ,m_loc_time(timestamp)
  41. ,m_time_tmp(time_tmp)
  42. ,m_card_id(cardid)
  43. ,m_card_ct(ct)
  44. ,m_card_type(type)
  45. ,m_ant_id(antid)
  46. ,m_rav(rav)
  47. ,m_acc(acc)
  48. ,m_sync_ct(sync_ct)
  49. ,m_rssi(rssi)
  50. ,m_batstatus(batstatus)
  51. ,m_interpolation(0)
  52. ,m_loc_type(0)
  53. ,m_loc_dimension(0)
  54. ,m_freq(0.0)
  55. {
  56. m_poa[0] = m_poa[1] = m_poa[2] = 0.0;
  57. }
  58. // tdoa定位数据,16
  59. loc_message(std::shared_ptr<site> s, uint64_t num_ticks, uint64_t timestamp,
  60. uint32_t cardid,int32_t ct,int8_t type,int8_t antid,
  61. int16_t rav,float acc,uint16_t sync_ct,uint16_t rssi,uint16_t batstatus,
  62. uint64_t _interpolation, uint8_t _loc_type, uint8_t _dim, uint8_t _freq)
  63. :m_sit(s)
  64. ,m_num_ticks(num_ticks)
  65. ,m_loc_time(timestamp)
  66. ,m_card_id(cardid)
  67. ,m_card_ct(ct)
  68. ,m_card_type(type)
  69. ,m_ant_id(antid)
  70. ,m_rav(rav)
  71. ,m_acc(acc)
  72. ,m_sync_ct(sync_ct)
  73. ,m_rssi(rssi)
  74. ,m_batstatus(batstatus)
  75. ,m_interpolation(_interpolation)
  76. ,m_loc_type(_loc_type)
  77. ,m_loc_dimension(_dim)
  78. ,m_freq(_freq)
  79. {
  80. m_poa[0] = m_poa[1] = m_poa[2] = 0.0;
  81. }
  82. // pdoa定位数据,17
  83. loc_message(std::shared_ptr<site> s,uint64_t num_ticks,uint64_t timestamp,uint64_t time_tmp,
  84. uint32_t cardid,int32_t ct,int8_t type,int8_t antid,
  85. int16_t rav,float acc,uint16_t sync_ct,uint16_t rssi,uint16_t batstatus
  86. ,uint8_t _loc_type, uint8_t _dim, double _poa0, double _poa1, double _poa2)
  87. :m_sit(s)
  88. ,m_num_ticks(num_ticks)
  89. ,m_loc_time(timestamp)
  90. ,m_time_tmp(time_tmp)
  91. ,m_card_id(cardid)
  92. ,m_card_ct(ct)
  93. ,m_card_type(type)
  94. ,m_ant_id(antid)
  95. ,m_rav(rav)
  96. ,m_acc(acc)
  97. ,m_sync_ct(sync_ct)
  98. ,m_rssi(rssi)
  99. ,m_batstatus(batstatus)
  100. ,m_loc_type(_loc_type)
  101. ,m_loc_dimension(_dim)
  102. {
  103. m_poa[0] = _poa0;
  104. m_poa[1] = _poa1;
  105. m_poa[2] = _poa2;
  106. }
  107. loc_message& operator=(const loc_message& lhs)
  108. {
  109. if(this != &lhs){
  110. this->m_sit = lhs.m_sit;
  111. this->m_num_ticks = lhs.m_num_ticks;
  112. this->m_loc_time = lhs.m_loc_time;
  113. this->m_card_id = lhs.m_card_id;
  114. this->m_card_ct = lhs.m_card_ct;
  115. this->m_card_type = lhs.m_card_type;
  116. this->m_ant_id = lhs.m_ant_id;
  117. this->m_rav = lhs.m_rav;
  118. this->m_acc = lhs.m_acc;
  119. this->m_sync_ct = lhs.m_sync_ct;
  120. this->m_rssi = lhs.m_rssi;
  121. this->m_batstatus = lhs.m_batstatus;
  122. this->m_loc_type = lhs.m_loc_type;
  123. this->m_loc_dimension = lhs.m_loc_dimension;
  124. this->m_poa[0] = lhs.m_poa[0];
  125. this->m_poa[1] = lhs.m_poa[1];
  126. this->m_poa[2] = lhs.m_poa[2];
  127. this->m_interpolation = lhs.m_interpolation;
  128. this->m_freq = lhs.m_freq;
  129. }
  130. return *this;
  131. }
  132. float get_pdoa(const int i)
  133. {
  134. if(i>1){
  135. return 10.0;
  136. }
  137. float poa1 = m_poa[i];
  138. float poa2 = m_poa[i+1];
  139. float pdoa = poa2 - poa1 - m_sit->m_pdoa_offset;
  140. while(pdoa >= TPI){
  141. pdoa -= TPI;
  142. }
  143. while(pdoa < 0){
  144. pdoa += TPI;
  145. }
  146. pdoa -= PI;
  147. /*pdoa -= m_sit->m_pdoa_offset;
  148. if(pdoa < -1.0*PI){
  149. pdoa += TPI;
  150. }
  151. if(pdoa > PI){
  152. pdoa -= TPI;
  153. }*/
  154. return pdoa;
  155. }
  156. };
  157. struct pdoa_message: public point{
  158. double angle;
  159. double distance;
  160. double x_ant;
  161. double y_ant;
  162. double pdoa;
  163. double relative_angle;
  164. pdoa_message(const double& _x, const double& _y, const double& _angle, const double& _distance, const double& _ax, const double& _ay, const double& _pdoa, const double& _relative_angle):point(_x, _y), angle(_angle), distance(_distance), x_ant(_ax), y_ant(_ay), pdoa(_pdoa), relative_angle(_relative_angle)
  165. {}
  166. pdoa_message():point(0.0, 0.0),angle(0.0), distance(0.0), x_ant(0.0), y_ant(0.0), pdoa(0.0), relative_angle(0.0)
  167. {}
  168. };
  169. using pdoa_msg_ptr = std::shared_ptr<pdoa_message>;
  170. struct pdoa_param{
  171. double pdoa;
  172. double r;
  173. double a;
  174. double ax;
  175. double ay;
  176. pdoa_param(const double& _pdoa, const double& _r, const double& _a, const double& _ax, double& _ay):pdoa(_pdoa), r(_r), a(_a), ax(_ax), ay(_ay)
  177. {}
  178. pdoa_param():pdoa(0.0), r(0.0), a(0.0), ax(0.0), ay(0.0)
  179. {}
  180. };
  181. #endif