loc_message.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. #ifndef __LOC_MESSAGE__HPP
  2. #define __LOC_MESSAGE__HPP
  3. #include "ant.h"
  4. #include "message.h"
  5. struct loc_message
  6. {
  7. std::shared_ptr<site> m_sit;
  8. uint64_t m_num_ticks; //tof时间片m_tof或tdoa相对root时间
  9. uint64_t m_loc_time;
  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. int16_t 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. ins_data m_ins_data;
  28. loc_message()
  29. :m_num_ticks(0)
  30. {
  31. }
  32. int tool_index()const
  33. {
  34. return m_sit->index();
  35. }
  36. loc_message(std::shared_ptr<site> s,uint64_t num_ticks,uint64_t timestamp,
  37. uint32_t cardid,int32_t ct,int8_t type,int8_t antid,
  38. int16_t rav,int16_t acc,uint16_t sync_ct,uint16_t rssi,uint16_t batstatus)
  39. :m_sit(s)
  40. ,m_num_ticks(num_ticks)
  41. ,m_loc_time(timestamp)
  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,int16_t 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, ins_data val)
  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. m_ins_data = val;
  82. }
  83. // pdoa定位数据,17
  84. loc_message(std::shared_ptr<site> s,uint64_t num_ticks,uint64_t timestamp,
  85. uint32_t cardid,int32_t ct,int8_t type,int8_t antid,
  86. int16_t rav,int16_t acc,uint16_t sync_ct,uint16_t rssi,uint16_t batstatus
  87. ,uint8_t _loc_type, uint8_t _dim, double _poa0, double _poa1, double _poa2)
  88. :m_sit(s)
  89. ,m_num_ticks(num_ticks)
  90. ,m_loc_time(timestamp)
  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. // ins tof
  108. loc_message(std::shared_ptr<site> s, uint64_t num_ticks, uint64_t timestamp,
  109. uint32_t card_id, int32_t ct, int8_t type, int8_t ant_id,
  110. int16_t rav, int16_t acc, uint16_t sync_ct, uint16_t rssi, uint16_t bat_status,
  111. uint8_t loc_type, uint8_t dim, double poa0, double poa1, double poa2, ins_data val)
  112. :m_sit(s)
  113. ,m_num_ticks(num_ticks)
  114. ,m_loc_time(timestamp)
  115. ,m_card_id(card_id)
  116. ,m_card_ct(ct)
  117. ,m_card_type(type)
  118. ,m_ant_id(ant_id)
  119. ,m_rav(rav)
  120. ,m_acc(acc)
  121. ,m_sync_ct(sync_ct)
  122. ,m_rssi(rssi)
  123. ,m_batstatus(bat_status)
  124. ,m_loc_type(loc_type)
  125. ,m_loc_dimension(dim)
  126. {
  127. m_poa[0] = poa0;
  128. m_poa[1] = poa1;
  129. m_poa[2] = poa2;
  130. m_ins_data = val;
  131. }
  132. loc_message& operator=(const loc_message& lhs)
  133. {
  134. if(this != &lhs){
  135. this->m_sit = lhs.m_sit;
  136. this->m_num_ticks = lhs.m_num_ticks;
  137. this->m_loc_time = lhs.m_loc_time;
  138. this->m_card_id = lhs.m_card_id;
  139. this->m_card_ct = lhs.m_card_ct;
  140. this->m_card_type = lhs.m_card_type;
  141. this->m_ant_id = lhs.m_ant_id;
  142. this->m_rav = lhs.m_rav;
  143. this->m_acc = lhs.m_acc;
  144. this->m_sync_ct = lhs.m_sync_ct;
  145. this->m_rssi = lhs.m_rssi;
  146. this->m_batstatus = lhs.m_batstatus;
  147. this->m_loc_type = lhs.m_loc_type;
  148. this->m_loc_dimension = lhs.m_loc_dimension;
  149. this->m_poa[0] = lhs.m_poa[0];
  150. this->m_poa[1] = lhs.m_poa[1];
  151. this->m_poa[2] = lhs.m_poa[2];
  152. this->m_interpolation = lhs.m_interpolation;
  153. this->m_freq = lhs.m_freq;
  154. }
  155. return *this;
  156. }
  157. float get_pdoa(const int i)
  158. {
  159. if(i>1){
  160. return 10.0;
  161. }
  162. float poa1 = m_poa[i];
  163. float poa2 = m_poa[i+1];
  164. float pdoa = poa2 - poa1 - m_sit->m_pdoa_offset;
  165. while(pdoa >= TPI){
  166. pdoa -= TPI;
  167. }
  168. while(pdoa < 0){
  169. pdoa += TPI;
  170. }
  171. pdoa -= PI;
  172. /*pdoa -= m_sit->m_pdoa_offset;
  173. if(pdoa < -1.0*PI){
  174. pdoa += TPI;
  175. }
  176. if(pdoa > PI){
  177. pdoa -= TPI;
  178. }*/
  179. return pdoa;
  180. }
  181. };
  182. struct pdoa_message: public point{
  183. double angle;
  184. double distance;
  185. double x_ant;
  186. double y_ant;
  187. double pdoa;
  188. double relative_angle;
  189. 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)
  190. {}
  191. 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)
  192. {}
  193. };
  194. using pdoa_msg_ptr = std::shared_ptr<pdoa_message>;
  195. struct pdoa_param{
  196. double pdoa;
  197. double r;
  198. double a;
  199. double ax;
  200. double ay;
  201. 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)
  202. {}
  203. pdoa_param():pdoa(0.0), r(0.0), a(0.0), ax(0.0), ay(0.0)
  204. {}
  205. };
  206. #endif