loc_message.h 5.8 KB

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