system_executor.cpp 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310
  1. //
  2. // Created by huli on 2020/7/2.
  3. //
  4. #include "system_executor.h"
  5. // std::ofstream g_debug_file; // 用于测试滤波功能
  6. System_executor::System_executor()
  7. {
  8. }
  9. System_executor::~System_executor()
  10. {
  11. system_executor_uninit();
  12. }
  13. //初始化
  14. Error_manager System_executor::system_executor_init(int threads_size, int terminal_id)
  15. {
  16. m_thread_pool.thread_pool_init(threads_size);
  17. m_system_executor_status = SYSTEM_EXECUTOR_READY;
  18. m_terminal_id = terminal_id;
  19. PathCreator pc;
  20. pc.Mkdir("./log/");
  21. return Error_code::SUCCESS;
  22. }
  23. //反初始化
  24. Error_manager System_executor::system_executor_uninit()
  25. {
  26. // if(g_debug_file.is_open())
  27. // g_debug_file.close();
  28. m_thread_pool.thread_pool_uninit();
  29. m_system_executor_status = SYSTEM_EXECUTOR_UNKNOW;
  30. return Error_code::SUCCESS;
  31. }
  32. //检查消息是否有效, 主要检查消息类型和接受者, 判断这条消息是不是给我的.
  33. Error_manager System_executor::check_msg(Communication_message* p_msg)
  34. {
  35. if ( p_msg == NULL )
  36. {
  37. return Error_manager(Error_code::POINTER_IS_NULL, Error_level::MINOR_ERROR,
  38. " POINTER IS NULL ");
  39. }
  40. //检查消息类型
  41. switch ( p_msg->get_message_type() )
  42. {
  43. case Communication_message::Message_type::eGround_detect_request_msg:
  44. {
  45. //检查接受人
  46. if ( p_msg->get_receiver() == Communication_message::Communicator::eGround_measurer)
  47. {
  48. message::Ground_detect_request_msg t_ground_detect_request_msg;
  49. //针对消息类型, 对消息进行二次解析
  50. if (t_ground_detect_request_msg.ParseFromString(p_msg->get_message_buf()))
  51. {
  52. // //检查终端id
  53. // 普爱不检查终端id
  54. // 楚天检查终端id
  55. // if ( t_ground_detect_request_msg.terminal_id() == m_terminal_id )
  56. // {
  57. return Error_code::SUCCESS;
  58. // }
  59. }
  60. }
  61. break;
  62. }
  63. default :
  64. ;
  65. break;
  66. }
  67. //无效的消息,
  68. return Error_manager(Error_code::INVALID_MESSAGE, Error_level::NEGLIGIBLE_ERROR,
  69. " INVALID_MESSAGE error ");
  70. }
  71. //检查执行者的状态, 判断能否处理这条消息,
  72. Error_manager System_executor::check_executer(Communication_message* p_msg)
  73. {
  74. //huli DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 记得删除
  75. return Error_code::SUCCESS;
  76. if ( p_msg == NULL )
  77. {
  78. return Error_manager(Error_code::POINTER_IS_NULL, Error_level::MINOR_ERROR,
  79. " POINTER IS NULL ");
  80. }
  81. Error_manager t_error;
  82. //通过 p_msg->get_message_type() 和 p_msg->get_receiver() 找到处理模块的实例对象, 查询执行人是否可以处理这条消息
  83. switch ( p_msg->get_message_type() )
  84. {
  85. case Communication_message::Message_type::eGround_detect_request_msg:
  86. {
  87. Error_manager t_executor_result = System_executor::get_instance_references().check_status();
  88. if (t_executor_result == SUCCESS)
  89. {
  90. return Error_code::SUCCESS;
  91. }
  92. else
  93. {
  94. //整合所有的错误码
  95. t_error.compare_and_cover_error(t_executor_result);
  96. if (t_error.get_error_level() == NEGLIGIBLE_ERROR)//一级故障,轻微故障,
  97. {
  98. LOG(INFO) << "executer_is_busy , ";
  99. //返回繁忙之后, 通信模块1秒后再次调用check
  100. return Error_code::COMMUNICATION_EXCUTER_IS_BUSY;
  101. }
  102. else//返回二级故障,可以封装一条答复信息, 返回错误码
  103. {
  104. message::Ground_detect_request_msg t_ground_detect_request_msg;
  105. //针对消息类型, 对消息进行二次解析
  106. if (t_ground_detect_request_msg.ParseFromString(p_msg->get_message_buf()))
  107. {
  108. //创建一条答复消息
  109. message::Ground_detect_response_msg t_ground_detect_response_msg;
  110. t_ground_detect_response_msg.mutable_base_info()->set_msg_type(message::Message_type::eGround_detect_response_msg);
  111. t_ground_detect_response_msg.mutable_base_info()->set_timeout_ms(5000);
  112. t_ground_detect_response_msg.mutable_base_info()->set_sender(message::Communicator::eGround_measurer);
  113. t_ground_detect_response_msg.mutable_base_info()->set_receiver(message::Communicator::eMain);
  114. t_ground_detect_response_msg.set_command_key(t_ground_detect_request_msg.command_key());
  115. t_ground_detect_response_msg.mutable_id_struct()->set_terminal_id(t_ground_detect_request_msg.id_struct().terminal_id());
  116. t_ground_detect_response_msg.mutable_error_manager()->set_error_code(t_error.get_error_code());
  117. t_ground_detect_response_msg.mutable_error_manager()->set_error_level((message::Error_level)t_error.get_error_level());
  118. t_ground_detect_response_msg.mutable_error_manager()->set_error_description(t_error.get_error_description());
  119. std::string t_msg = t_ground_detect_response_msg.SerializeAsString();
  120. System_communication::get_instance_references().encapsulate_msg(t_msg);
  121. LOG(INFO) << " System_executor::check_executer executer status error "<< this;
  122. return t_error;
  123. }
  124. else
  125. {
  126. LOG(INFO) << " System_executor::check_executer second PARSE_ERROR "<< this;
  127. return Error_manager(Error_code::SYSTEM_EXECUTOR_PARSE_ERROR, Error_level::MINOR_ERROR,
  128. " message::Measure_request_msg ParseFromString error ");
  129. }
  130. }
  131. }
  132. break;
  133. }
  134. default :
  135. ;
  136. break;
  137. }
  138. return t_error;
  139. }
  140. //处理消息的执行函数
  141. Error_manager System_executor::execute_msg(Communication_message* p_msg)
  142. {
  143. if ( p_msg == NULL )
  144. {
  145. return Error_manager(Error_code::POINTER_IS_NULL, Error_level::MINOR_ERROR,
  146. " POINTER IS NULL ");
  147. }
  148. // std::cout << " huli test ::333333333333333333333333333333:: " << " p_msg->get_message_type() = " << p_msg->get_message_type() << std::endl;
  149. switch ( p_msg->get_message_type() )
  150. {
  151. case Communication_message::eGround_detect_request_msg:
  152. {
  153. message::Ground_detect_request_msg t_ground_detect_request_msg;
  154. //针对消息类型, 对消息进行二次解析
  155. if (t_ground_detect_request_msg.ParseFromString(p_msg->get_message_buf()) && t_ground_detect_request_msg.id_struct().has_terminal_id())
  156. {
  157. //往线程池添加执行任务, 之后会唤醒一个线程去执行他.
  158. m_thread_pool.enqueue(&System_executor::execute_for_measure, this,
  159. t_ground_detect_request_msg.command_key(), t_ground_detect_request_msg.id_struct().terminal_id(),
  160. p_msg->get_receive_time());
  161. }
  162. else
  163. {
  164. return Error_manager(Error_code::SYSTEM_EXECUTOR_PARSE_ERROR, Error_level::MINOR_ERROR,
  165. " message::Measure_request_msg ParseFromString error ");
  166. }
  167. break;
  168. }
  169. default:
  170. {
  171. }
  172. }
  173. return Error_code::SUCCESS;
  174. }
  175. //检查状态
  176. Error_manager System_executor::check_status()
  177. {
  178. if ( m_system_executor_status == SYSTEM_EXECUTOR_READY )
  179. {
  180. if ( m_thread_pool.thread_is_full_load() == false )
  181. {
  182. return Error_code::SUCCESS;
  183. }
  184. else
  185. {
  186. return Error_manager(Error_code::SYSTEM_EXECUTOR_STATUS_BUSY, Error_level::NEGLIGIBLE_ERROR,
  187. " System_executor::check_status error ");
  188. }
  189. }
  190. else
  191. {
  192. return Error_manager(Error_code::SYSTEM_EXECUTOR_STATUS_ERROR, Error_level::MINOR_ERROR,
  193. " System_executor::check_status error ");
  194. }
  195. }
  196. int System_executor::transMeasureStatus(const int &measure_status) {
  197. switch (measure_status) {
  198. case message::Ground_statu::Car_correct:
  199. return 0;
  200. case message::Ground_statu::Nothing:
  201. return 1;
  202. case message::Ground_statu::Noise:
  203. return 2;
  204. case message::Ground_statu::Car_border_reached:
  205. return 3;
  206. default:
  207. return 2;
  208. }
  209. }
  210. // 更新消息中关于定位结果与超界信息的内容
  211. bool System_executor::update_measure_info(message::Ground_status_msg &msg, Common_data::Car_wheel_information &measure_info, int cloud_size)
  212. {
  213. Error_manager t_error;
  214. //无论定位结果如何, 都要填充数据, 即使全部写0, 必须保证通信格式正确.
  215. message::Locate_information t_locate_information;
  216. //= t_multi_status_msg.add_locate_information_realtime();
  217. t_locate_information.set_locate_x(measure_info.car_center_x);
  218. t_locate_information.set_locate_y(measure_info.car_center_y);
  219. t_locate_information.set_locate_angle(measure_info.car_angle);
  220. t_locate_information.set_locate_length(0);
  221. t_locate_information.set_locate_width(0);
  222. t_locate_information.set_locate_height(0);
  223. t_locate_information.set_locate_wheel_base(measure_info.car_wheel_base);
  224. t_locate_information.set_locate_wheel_width(measure_info.car_wheel_width);
  225. t_locate_information.set_locate_front_theta(measure_info.car_front_theta);
  226. t_locate_information.set_locate_correct(measure_info.correctness);
  227. t_locate_information.set_uniformed_car_x(measure_info.uniform_car_x);
  228. t_locate_information.set_uniformed_car_y(measure_info.uniform_car_y);
  229. msg.mutable_locate_information_realtime()->CopyFrom(t_locate_information);
  230. // 当前超界提示仅保留一项
  231. // 20211026已修改,分离为电子围栏状态与超界状态,只有测量正确时超界状态才有意义
  232. msg.set_border_status(measure_info.range_status);
  233. if (!measure_info.correctness)
  234. {
  235. if (cloud_size > 0)
  236. msg.set_ground_status(message::Ground_statu::Noise);
  237. else
  238. msg.set_ground_status(message::Ground_statu::Nothing);
  239. }
  240. else if (measure_info.range_status == int(Ground_region::Range_status::Range_correct))
  241. {
  242. msg.set_ground_status(message::Ground_statu::Car_correct);
  243. }
  244. else
  245. {
  246. msg.set_ground_status(message::Ground_statu::Car_border_reached);
  247. // 更新待提示错误信息
  248. std::string t_error_str;
  249. if (measure_info.range_status & Ground_region::Range_status::Range_front != 0)
  250. {
  251. t_error_str.append("前超界 ");
  252. }
  253. if (measure_info.range_status & Ground_region::Range_status::Range_back != 0)
  254. {
  255. t_error_str.append("后超界 ");
  256. }
  257. if (measure_info.range_status & Ground_region::Range_status::Range_left != 0)
  258. {
  259. t_error_str.append("左超界 ");
  260. }
  261. if (measure_info.range_status & Ground_region::Range_status::Range_right != 0)
  262. {
  263. t_error_str.append("右超界 ");
  264. }
  265. if (measure_info.range_status & Ground_region::Range_status::Range_bottom != 0)
  266. {
  267. t_error_str.append("底盘超界 ");
  268. }
  269. if (measure_info.range_status & Ground_region::Range_status::Range_top != 0)
  270. {
  271. t_error_str.append("顶超界 ");
  272. }
  273. if (measure_info.range_status & Ground_region::Range_status::Range_car_width != 0)
  274. {
  275. t_error_str.append("车宽超界 ");
  276. }
  277. if (measure_info.range_status & Ground_region::Range_status::Range_car_wheelbase != 0)
  278. {
  279. t_error_str.append("轴距超界 ");
  280. }
  281. if (measure_info.range_status & Ground_region::Range_status::Range_angle_anti_clock != 0)
  282. {
  283. t_error_str.append("车辆角度左超界 ");
  284. }
  285. if (measure_info.range_status & Ground_region::Range_status::Range_angle_clock != 0)
  286. {
  287. t_error_str.append("车辆角度右超界 ");
  288. }
  289. if (measure_info.range_status & Ground_region::Range_status::Range_steering_wheel_nozero != 0)
  290. {
  291. t_error_str.append("车辆前轮角超界 ");
  292. }
  293. t_error.set_error_description(t_error_str);
  294. }
  295. msg.mutable_error_manager()->set_error_code(t_error.get_error_code());
  296. msg.mutable_error_manager()->set_error_level((message::Error_level)t_error.get_error_level());
  297. msg.mutable_error_manager()->set_error_description(t_error.get_error_description());
  298. return true;
  299. }
  300. // 更新消息中关于定位结果与超界信息的内容
  301. bool System_executor::update_terminal_measure_info(message::Ground_status_msg &msg, Common_data::Car_wheel_information &measure_info, int cloud_size)
  302. {
  303. Error_manager t_error;
  304. //无论定位结果如何, 都要填充数据, 即使全部写0, 必须保证通信格式正确.
  305. message::Locate_information t_locate_information;
  306. //= t_multi_status_msg.add_locate_information_realtime();
  307. t_locate_information.set_locate_x(measure_info.car_center_x);
  308. t_locate_information.set_locate_y(measure_info.car_center_y);
  309. t_locate_information.set_locate_angle(measure_info.car_angle);
  310. t_locate_information.set_locate_length(0);
  311. t_locate_information.set_locate_width(0);
  312. t_locate_information.set_locate_height(0);
  313. t_locate_information.set_locate_wheel_base(measure_info.car_wheel_base);
  314. t_locate_information.set_locate_wheel_width(measure_info.car_wheel_width);
  315. t_locate_information.set_locate_front_theta(measure_info.car_front_theta);
  316. t_locate_information.set_locate_correct(measure_info.correctness);
  317. t_locate_information.set_uniformed_car_x(measure_info.uniform_car_x);
  318. t_locate_information.set_uniformed_car_y(measure_info.uniform_car_y);
  319. msg.mutable_locate_information_realtime()->CopyFrom(t_locate_information);
  320. // 当前超界提示仅保留一项
  321. // 20211026已修改,分离为电子围栏状态与超界状态,只有测量正确时超界状态才有意义
  322. msg.set_border_status(measure_info.terminal_range_status);
  323. if (!measure_info.correctness)
  324. {
  325. if (cloud_size > 0)
  326. msg.set_ground_status(message::Ground_statu::Noise);
  327. else
  328. msg.set_ground_status(message::Ground_statu::Nothing);
  329. }
  330. else if (measure_info.terminal_range_status == int(Ground_region::Range_status::Range_correct))
  331. {
  332. msg.set_ground_status(message::Ground_statu::Car_correct);
  333. }
  334. else
  335. {
  336. msg.set_ground_status(message::Ground_statu::Car_border_reached);
  337. // 更新待提示错误信息
  338. std::string t_error_str;
  339. if (measure_info.terminal_range_status & Ground_region::Range_status::Range_front != 0)
  340. {
  341. t_error_str.append("前超界 ");
  342. }
  343. if (measure_info.terminal_range_status & Ground_region::Range_status::Range_back != 0)
  344. {
  345. t_error_str.append("后超界 ");
  346. }
  347. if (measure_info.terminal_range_status & Ground_region::Range_status::Range_left != 0)
  348. {
  349. t_error_str.append("左超界 ");
  350. }
  351. if (measure_info.terminal_range_status & Ground_region::Range_status::Range_right != 0)
  352. {
  353. t_error_str.append("右超界 ");
  354. }
  355. if (measure_info.terminal_range_status & Ground_region::Range_status::Range_bottom != 0)
  356. {
  357. t_error_str.append("底盘超界 ");
  358. }
  359. if (measure_info.terminal_range_status & Ground_region::Range_status::Range_top != 0)
  360. {
  361. t_error_str.append("顶超界 ");
  362. }
  363. if (measure_info.terminal_range_status & Ground_region::Range_status::Range_car_width != 0)
  364. {
  365. t_error_str.append("车宽超界 ");
  366. }
  367. if (measure_info.terminal_range_status & Ground_region::Range_status::Range_car_wheelbase != 0)
  368. {
  369. t_error_str.append("轴距超界 ");
  370. }
  371. if (measure_info.terminal_range_status & Ground_region::Range_status::Range_angle_anti_clock != 0)
  372. {
  373. t_error_str.append("车辆角度左超界 ");
  374. }
  375. if (measure_info.terminal_range_status & Ground_region::Range_status::Range_angle_clock != 0)
  376. {
  377. t_error_str.append("车辆角度右超界 ");
  378. }
  379. if (measure_info.terminal_range_status & Ground_region::Range_status::Range_steering_wheel_nozero != 0)
  380. {
  381. t_error_str.append("车辆前轮角超界 ");
  382. }
  383. t_error.set_error_description(t_error_str);
  384. }
  385. msg.mutable_error_manager()->set_error_code(t_error.get_error_code());
  386. msg.mutable_error_manager()->set_error_level((message::Error_level)t_error.get_error_level());
  387. msg.mutable_error_manager()->set_error_description(t_error.get_error_description());
  388. return true;
  389. }
  390. // ***************************** rabbitmq *********************************
  391. Error_manager System_executor::encapsulate_send_mq_status()
  392. {
  393. static int cloud_count=-1;
  394. cloud_count++;
  395. // if(!g_debug_file.is_open())
  396. // {
  397. // g_debug_file.open("./filter_debug_result.txt", std::ios::app);
  398. // }
  399. Error_manager t_error;
  400. //创建一条状态消息
  401. message::Ground_status_msg t_ground_status_msg;
  402. t_ground_status_msg.mutable_base_info()->set_msg_type(message::Message_type::eGround_status_msg);
  403. t_ground_status_msg.mutable_base_info()->set_timeout_ms(5000);
  404. t_ground_status_msg.mutable_base_info()->set_sender(message::Communicator::eGround_measurer);
  405. t_ground_status_msg.mutable_base_info()->set_receiver(message::Communicator::eEmpty);
  406. // t_ground_status_msg.set_terminal_id(m_terminal_id);
  407. t_ground_status_msg.mutable_id_struct()->set_terminal_id(m_terminal_id);
  408. // 创建各区域状态消息,
  409. // 注意!!!目前公共消息名字依旧使用wj,不做修改
  410. // manager
  411. #if WJ_VELO == 1
  412. {
  413. Velodyne_manager::Velodyne_manager_status t_velodyne_manager_status = Velodyne_manager::get_instance_references().get_status();
  414. t_ground_status_msg.set_wanji_manager_status((message::Wanji_manager_status)t_velodyne_manager_status);
  415. // lidar
  416. std::map<int, Velodyne_lidar_device *> t_velodyne_lidar_device_map = Velodyne_manager::get_instance_references().get_velodyne_lidar_device_map();
  417. std::map<int, Velodyne_lidar_device::Velodyne_lidar_device_status> t_velodyne_lidar_status_map;
  418. for (auto iter = t_velodyne_lidar_device_map.begin(); iter != t_velodyne_lidar_device_map.end(); ++iter)
  419. {
  420. t_velodyne_lidar_status_map.emplace(std::pair<int, Velodyne_lidar_device::Velodyne_lidar_device_status>(iter->second->get_lidar_id(), iter->second->get_status()));
  421. }
  422. // region
  423. std::map<int, Ground_region *> t_ground_region_map = Velodyne_manager::get_instance_references().get_ground_region_map();
  424. int region_index = 0;
  425. for (auto iter = t_ground_region_map.begin(); iter != t_ground_region_map.end(); ++iter)
  426. {
  427. // 以t_ground_status_msg为模板创建各区域心跳消息
  428. message::Ground_status_msg t_multi_status_msg;
  429. t_multi_status_msg.CopyFrom(t_ground_status_msg);
  430. t_multi_status_msg.mutable_id_struct()->set_terminal_id(iter->second->get_terminal_id());
  431. t_multi_status_msg.set_region_worker_status((message::Region_worker_status)(iter->second->get_status()));
  432. velodyne::Region t_param = iter->second->get_param();
  433. for (size_t j = 0; j < t_param.lidar_exts_size(); j++)
  434. {
  435. std::map<int, Velodyne_lidar_device::Velodyne_lidar_device_status>::iterator t_status_iter = t_velodyne_lidar_status_map.find(t_param.lidar_exts(j).lidar_id());
  436. if (t_status_iter == t_velodyne_lidar_status_map.end())
  437. {
  438. LOG(WARNING) << "lidar status " << t_param.lidar_exts(j).lidar_id() << " cannot be found, param error";
  439. }
  440. else
  441. {
  442. t_multi_status_msg.add_wanji_lidar_device_status((message::Wanji_lidar_device_status)t_status_iter->second);
  443. }
  444. }
  445. //velodyne雷达的自动定位信息
  446. Common_data::Car_wheel_information t_car_wheel_information;
  447. t_error = (*iter).second->get_last_wheel_information(&t_car_wheel_information, std::chrono::system_clock::now());
  448. // 获取区域点云填入信息
  449. pcl::PointCloud<pcl::PointXYZ>::Ptr t_region_cloud = pcl::PointCloud<pcl::PointXYZ>::Ptr(new pcl::PointCloud<pcl::PointXYZ>);
  450. iter->second->get_region_cloud(t_region_cloud, Ground_region::Region_cloud_type::filtered);
  451. if (cloud_count == 5)
  452. {
  453. std::string t_filename = std::string("region_") + std::to_string(iter->first) + "_cloud.txt";
  454. save_cloud_txt(t_region_cloud, t_filename);
  455. LOG(INFO) << "region " << iter->first << " cloud has been saved in " + t_filename;
  456. }
  457. // for (size_t j = 0; j < t_region_cloud->size(); j++)
  458. // {
  459. // message::Cloud_coordinate *tp_cloud = t_multi_status_msg.add_cloud();
  460. // tp_cloud->set_x(t_region_cloud->points[j].x);
  461. // tp_cloud->set_y(t_region_cloud->points[j].y);
  462. // tp_cloud->set_z(t_region_cloud->points[j].z);
  463. // }
  464. update_measure_info(t_multi_status_msg, t_car_wheel_information, t_region_cloud->size());
  465. std::string t_msg = t_multi_status_msg.SerializeAsString();
  466. System_communication::get_instance_references().encapsulate_msg(t_msg);
  467. if (t_multi_status_msg.id_struct().terminal_id() == DISP_TERM_ID)
  468. std::cout << t_multi_status_msg.DebugString() << std::endl
  469. << std::endl;
  470. }
  471. }
  472. #elif WJ_VELO == 0
  473. {
  474. // wj_support 20220718
  475. Wanji_manager::Wanji_manager_status t_wj_manager_status = Wanji_manager::get_instance_references().get_status();
  476. t_ground_status_msg.set_wanji_manager_status((message::Wanji_manager_status)t_wj_manager_status);
  477. // lidar
  478. std::map<int, Wanji_lidar_device *> t_wj_lidar_device_map = Wanji_manager::get_instance_references().get_wanji_lidar_device_map();
  479. std::map<int, Wanji_lidar_device::Wanji_lidar_device_status> t_wj_lidar_status_map;
  480. for (auto iter = t_wj_lidar_device_map.begin(); iter != t_wj_lidar_device_map.end(); ++iter)
  481. {
  482. t_wj_lidar_status_map.emplace(std::pair<int, Wanji_lidar_device::Wanji_lidar_device_status>(iter->second->get_lidar_id(), iter->second->get_status()));
  483. }
  484. // region
  485. std::map<int, Region_worker *> t_region_worker_map = Wanji_manager::get_instance_references().get_region_worker_map();
  486. int region_index = 0;
  487. for (auto iter = t_region_worker_map.begin(); iter != t_region_worker_map.end(); ++iter)
  488. {
  489. // 以t_ground_status_msg为模板创建各区域心跳消息
  490. message::Ground_status_msg t_multi_status_msg;
  491. t_multi_status_msg.CopyFrom(t_ground_status_msg);
  492. t_multi_status_msg.mutable_id_struct()->set_terminal_id(iter->second->get_terminal_id());
  493. t_multi_status_msg.set_region_worker_status((message::Region_worker_status)(iter->second->get_status()));
  494. wj::Region t_param = iter->second->get_param();
  495. for (size_t j = 0; j < t_param.lidar_exts_size(); j++)
  496. {
  497. std::map<int, Wanji_lidar_device::Wanji_lidar_device_status>::iterator t_status_iter = t_wj_lidar_status_map.find(t_param.lidar_exts(j).lidar_id());
  498. if (t_status_iter == t_wj_lidar_status_map.end())
  499. {
  500. LOG(WARNING) << "lidar status " << t_param.lidar_exts(j).lidar_id() << " cannot be found, param error";
  501. }
  502. else
  503. {
  504. t_multi_status_msg.add_wanji_lidar_device_status((message::Wanji_lidar_device_status)t_status_iter->second);
  505. }
  506. }
  507. //velodyne雷达的自动定位信息
  508. Common_data::Car_wheel_information t_car_wheel_information;
  509. t_error = (*iter).second->get_last_wheel_information(&t_car_wheel_information, std::chrono::system_clock::now());
  510. // 获取区域点云填入信息
  511. pcl::PointCloud<pcl::PointXYZ>::Ptr t_region_cloud = pcl::PointCloud<pcl::PointXYZ>::Ptr(new pcl::PointCloud<pcl::PointXYZ>);
  512. iter->second->get_region_cloud(t_region_cloud);
  513. if (cloud_count == 5)
  514. {
  515. std::string t_filename = std::string("region_") + std::to_string(iter->first) + "_cloud.txt";
  516. save_cloud_txt(t_region_cloud, t_filename);
  517. LOG(INFO) << "region " << iter->first << " cloud has been saved in " + t_filename;
  518. }
  519. // for (size_t j = 0; j < t_region_cloud->size(); j++)
  520. // {
  521. // message::Cloud_coordinate *tp_cloud = t_multi_status_msg.add_cloud();
  522. // tp_cloud->set_x(t_region_cloud->points[j].x);
  523. // tp_cloud->set_y(t_region_cloud->points[j].y);
  524. // tp_cloud->set_z(t_region_cloud->points[j].z);
  525. // }
  526. update_measure_info(t_multi_status_msg, t_car_wheel_information, t_region_cloud->size());
  527. std::string t_msg = t_multi_status_msg.SerializeAsString();
  528. System_communication::get_instance_references().encapsulate_msg(t_msg);
  529. if (t_multi_status_msg.id_struct().terminal_id() == DISP_TERM_ID)
  530. LOG(INFO) << t_multi_status_msg.DebugString();
  531. }
  532. }
  533. // std::cout << " huli test :::: " << " t_ground_status_msg.DebugString() = " << std::endl;
  534. // std::cout << t_ground_status_msg.DebugString() << std::endl;
  535. // std::cout << " huli test :::: " << " t_ground_status_msg.DebugString() = " << t_ground_status_msg.DebugString() << std::endl;
  536. #else
  537. {
  538. // mix vlp16 and wj716
  539. // 以多线雷达为主
  540. Velodyne_manager::Velodyne_manager_status t_velodyne_manager_status = Velodyne_manager::get_instance_references().get_status();
  541. t_ground_status_msg.set_wanji_manager_status((message::Wanji_manager_status)t_velodyne_manager_status);
  542. // vlp16 lidar
  543. std::map<int, Velodyne_lidar_device *> t_velodyne_lidar_device_map = Velodyne_manager::get_instance_references().get_velodyne_lidar_device_map();
  544. std::map<int, Velodyne_lidar_device::Velodyne_lidar_device_status> t_velodyne_lidar_status_map;
  545. for (auto iter = t_velodyne_lidar_device_map.begin(); iter != t_velodyne_lidar_device_map.end(); ++iter)
  546. {
  547. t_velodyne_lidar_status_map.emplace(std::pair<int, Velodyne_lidar_device::Velodyne_lidar_device_status>(iter->second->get_lidar_id(), iter->second->get_status()));
  548. }
  549. // wj lidar
  550. #if LIDAR_TYPE == 1
  551. std::map<int, Wanji_lidar_device *> t_wj_lidar_device_map = Wanji_manager::get_instance_references().get_wanji_lidar_device_map();
  552. std::map<int, Wanji_lidar_device::Wanji_lidar_device_status> t_wj_lidar_status_map;
  553. for (auto iter = t_wj_lidar_device_map.begin(); iter != t_wj_lidar_device_map.end(); ++iter)
  554. {
  555. t_wj_lidar_status_map.emplace(std::pair<int, Wanji_lidar_device::Wanji_lidar_device_status>(iter->second->get_lidar_id(), iter->second->get_status()));
  556. }
  557. #else
  558. std::map<int, Wanji_716N_lidar_device *> t_wj_lidar_device_map = Wanji_manager::get_instance_references().get_wanji_lidar_device_map();
  559. std::map<int, Wanji_716N_lidar_device::Wanji_716N_device_status> t_wj_lidar_status_map;
  560. for (auto iter = t_wj_lidar_device_map.begin(); iter != t_wj_lidar_device_map.end(); ++iter)
  561. {
  562. t_wj_lidar_status_map.emplace(std::pair<int, Wanji_716N_lidar_device::Wanji_716N_device_status>(iter->second->get_lidar_id(), iter->second->get_status()));
  563. }
  564. #endif
  565. // wj region
  566. std::map<int, Region_worker *> t_region_worker_map = Wanji_manager::get_instance_references().get_region_worker_map();
  567. // vlp16 region
  568. std::map<int, Ground_region *> t_ground_region_map = Velodyne_manager::get_instance_references().get_ground_region_map();
  569. int region_index = 0;
  570. for (auto iter = t_ground_region_map.begin(); iter != t_ground_region_map.end(); ++iter)
  571. {
  572. // 以t_ground_status_msg为模板创建各区域心跳消息
  573. message::Ground_status_msg t_multi_status_msg;
  574. t_multi_status_msg.CopyFrom(t_ground_status_msg);
  575. t_multi_status_msg.mutable_id_struct()->set_terminal_id(iter->second->get_terminal_id());
  576. t_multi_status_msg.set_region_worker_status((message::Region_worker_status)(iter->second->get_status()));
  577. // 查找多线区域内对应多线激光雷达
  578. velodyne::Region t_param = iter->second->get_param();
  579. for (size_t j = 0; j < t_param.lidar_exts_size(); j++)
  580. {
  581. std::map<int, Velodyne_lidar_device::Velodyne_lidar_device_status>::iterator t_status_iter = t_velodyne_lidar_status_map.find(t_param.lidar_exts(j).lidar_id());
  582. if (t_status_iter == t_velodyne_lidar_status_map.end())
  583. {
  584. LOG(WARNING) << "vlp16 lidar status " << t_param.lidar_exts(j).lidar_id() << " cannot be found, param error";
  585. }
  586. else
  587. {
  588. t_multi_status_msg.add_wanji_lidar_device_status((message::Wanji_lidar_device_status)t_status_iter->second);
  589. }
  590. }
  591. //velodyne雷达的自动定位信息
  592. Common_data::Car_wheel_information t_car_wheel_information;
  593. t_error = (*iter).second->get_last_wheel_information(&t_car_wheel_information, std::chrono::system_clock::now());
  594. // 获取区域点云填入信息
  595. pcl::PointCloud<pcl::PointXYZ>::Ptr t_region_cloud = pcl::PointCloud<pcl::PointXYZ>::Ptr(new pcl::PointCloud<pcl::PointXYZ>);
  596. iter->second->get_region_cloud(t_region_cloud, Ground_region::Region_cloud_type::filtered);
  597. if (cloud_count == 10)
  598. {
  599. std::string t_filename = std::string("vlp16_region_") + std::to_string(iter->first) + "_cloud.txt";
  600. save_cloud_txt(t_region_cloud, t_filename);
  601. LOG(INFO) << " vlp16 region " << iter->first << " cloud has been saved in " + t_filename;
  602. }
  603. // for (size_t j = 0; j < t_region_cloud->size(); j++)
  604. // {
  605. // message::Cloud_coordinate *tp_cloud = t_multi_status_msg.add_cloud();
  606. // tp_cloud->set_x(t_region_cloud->points[j].x);
  607. // tp_cloud->set_y(t_region_cloud->points[j].y);
  608. // tp_cloud->set_z(t_region_cloud->points[j].z);
  609. // }
  610. // 检查vlp16区域与wj区域对应关系,wj存在对应区域则填充设备状态,并融合测量结果
  611. auto t_wj_region_iter = t_region_worker_map.find(iter->first);
  612. if(t_wj_region_iter != t_region_worker_map.end())
  613. {
  614. wj::Region t_param = t_wj_region_iter->second->get_param();
  615. //
  616. for (size_t j = 0; j < t_param.lidar_exts_size(); j++)
  617. {
  618. #if LIDAR_TYPE == 1
  619. std::map<int, Wanji_lidar_device::Wanji_lidar_device_status>::iterator t_status_iter = t_wj_lidar_status_map.find(t_param.lidar_exts(j).lidar_id());
  620. #else
  621. std::map<int, Wanji_716N_lidar_device::Wanji_716N_device_status>::iterator t_status_iter = t_wj_lidar_status_map.find(t_param.lidar_exts(j).lidar_id());
  622. #endif
  623. if (t_status_iter == t_wj_lidar_status_map.end())
  624. {
  625. LOG(WARNING) << "wj lidar status " << t_param.lidar_exts(j).lidar_id() << " cannot be found, param error";
  626. }
  627. else
  628. {
  629. t_multi_status_msg.add_wanji_lidar_device_status((message::Wanji_lidar_device_status)t_status_iter->second);
  630. }
  631. }
  632. //wj雷达的自动定位信息
  633. Common_data::Car_wheel_information t_wj_car_wheel_information;
  634. t_error = t_wj_region_iter->second->get_last_wheel_information(&t_wj_car_wheel_information, std::chrono::system_clock::now());
  635. // 获取区域点云填入信息
  636. pcl::PointCloud<pcl::PointXYZ>::Ptr t_wj_region_cloud = pcl::PointCloud<pcl::PointXYZ>::Ptr(new pcl::PointCloud<pcl::PointXYZ>);
  637. t_wj_region_iter->second->get_region_cloud(t_wj_region_cloud);
  638. if (cloud_count == 8)
  639. {
  640. std::string t_filename = std::string("wj_region_") + std::to_string(t_wj_region_iter->first) + "_cloud.txt";
  641. save_cloud_txt(t_wj_region_cloud, t_filename);
  642. LOG(INFO) << "wj region " << t_wj_region_iter->first << " cloud has been saved in " + t_filename;
  643. }
  644. // for (size_t j = 0; j < t_wj_region_cloud->size(); j++)
  645. // {
  646. // message::Cloud_coordinate *tp_cloud = t_multi_status_msg.add_cloud();
  647. // tp_cloud->set_x(t_wj_region_cloud->points[j].x);
  648. // tp_cloud->set_y(t_wj_region_cloud->points[j].y);
  649. // tp_cloud->set_z(t_wj_region_cloud->points[j].z);
  650. // }
  651. // LOG_IF(WARNING, iter->second->get_terminal_id() == DISP_TERM_ID)<<"\n"<<t_car_wheel_information.to_string()<<"\n"
  652. // <<t_wj_car_wheel_information.to_string()<<"\n"
  653. // <<t_car_wheel_information.range_status<<", "<<t_wj_car_wheel_information.range_status;
  654. // 融合测量结果,验证中心点差异x<0.03, y<0.06, 角度差异ang<0.6, 轴距差异wb<0.055
  655. double dx = t_car_wheel_information.car_center_x - t_wj_car_wheel_information.car_center_x;
  656. double dy = t_car_wheel_information.car_center_y - t_wj_car_wheel_information.car_center_y;
  657. double dang = t_car_wheel_information.car_angle - t_wj_car_wheel_information.car_angle;
  658. double dwb = t_car_wheel_information.car_wheel_base - t_wj_car_wheel_information.car_wheel_base;
  659. if(fabs(dx) < 0.03 && fabs(dy) < 0.06 && fabs(dang) < 0.6 && fabs(dwb) < 0.055)
  660. {
  661. t_car_wheel_information.car_wheel_base = t_car_wheel_information.car_wheel_base*0.3 + t_car_wheel_information.car_wheel_base*0.7;
  662. }else
  663. {
  664. LOG_IF(WARNING, iter->second->get_terminal_id() == DISP_TERM_ID)<<
  665. "detect mismatch, region "<<iter->first<<", dx dy dang dwb: "<<dx<<", "<<dy<<", "<<dang<<", "<< dwb << std::endl
  666. << t_car_wheel_information.to_string() << std::endl
  667. << t_wj_car_wheel_information.to_string() << std::endl;
  668. }
  669. }else{
  670. LOG_IF(WARNING, iter->second->get_terminal_id() == DISP_TERM_ID)<<"region mismatch, vlp16 "<<iter->first<<", wj doesn't have corresponding region id";
  671. }
  672. int rabbit_send_status_msg_id = t_multi_status_msg.id_struct().terminal_id();
  673. int rabbit_send_terminal_status_msg_id = t_multi_status_msg.id_struct().terminal_id() + 6; // 6是因为目前楚天plc有六个队列
  674. message::Ground_status_msg t_multi_terminal_status_msg = t_multi_status_msg;
  675. update_measure_info(t_multi_status_msg, t_car_wheel_information, t_region_cloud->size());
  676. update_terminal_measure_info(t_multi_terminal_status_msg, t_car_wheel_information, t_region_cloud->size());
  677. if(t_multi_status_msg.id_struct().terminal_id() == 4 ||
  678. t_multi_status_msg.id_struct().terminal_id() == 0||
  679. t_multi_status_msg.id_struct().terminal_id() == 5||
  680. t_multi_status_msg.id_struct().terminal_id() == 1||
  681. t_multi_status_msg.id_struct().terminal_id() == 3||
  682. t_multi_status_msg.id_struct().terminal_id() == 2)
  683. {
  684. // plc测量结果转换
  685. measure_info t_multi_measure_info_msg;
  686. t_multi_measure_info_msg.set_cx(t_car_wheel_information.uniform_car_x);
  687. t_multi_measure_info_msg.set_cy(t_car_wheel_information.uniform_car_y);
  688. t_multi_measure_info_msg.set_theta(t_car_wheel_information.car_angle);
  689. t_multi_measure_info_msg.set_length(0.0f);
  690. t_multi_measure_info_msg.set_width(t_car_wheel_information.car_wheel_width);
  691. t_multi_measure_info_msg.set_height(0.0f);
  692. t_multi_measure_info_msg.set_wheelbase(t_car_wheel_information.car_wheel_base);
  693. t_multi_measure_info_msg.set_front_theta(t_car_wheel_information.car_front_theta);
  694. t_multi_measure_info_msg.set_border_statu(t_car_wheel_information.range_status);
  695. // 终端测量结果copy,只改变超界状态
  696. measure_info t_multi_terminal_measure_info_msg;
  697. t_multi_terminal_measure_info_msg = t_multi_measure_info_msg;
  698. t_multi_terminal_measure_info_msg.set_border_statu(t_car_wheel_information.terminal_range_status);
  699. // 变更超界状态,因为发出去的和旧的状态不太一样
  700. t_multi_measure_info_msg.set_ground_status(transMeasureStatus(t_multi_status_msg.ground_status()));
  701. t_multi_terminal_measure_info_msg.set_ground_status(transMeasureStatus(t_multi_terminal_status_msg.ground_status()));
  702. // 分别发送到两个队列
  703. System_communication_mq::get_instance_references().encapsulate_status_msg(t_multi_measure_info_msg.DebugString(), rabbit_send_status_msg_id);
  704. System_communication_mq::get_instance_references().encapsulate_status_msg(t_multi_terminal_measure_info_msg.DebugString(), rabbit_send_terminal_status_msg_id);
  705. // if (t_multi_status_msg.id_struct().terminal_id() == 1)
  706. // {
  707. // LOG(WARNING) << "-------------------------------------------------------" <<std::endl;
  708. // LOG(WARNING) << "t_msg = " << t_msg <<std::endl;
  709. // LOG(WARNING) << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++" <<std::endl;
  710. // LOG(WARNING) << "t_multi_status_msg.ground_status() = " << t_ground_status <<std::endl;
  711. // LOG(WARNING) << "t_multi_measure_info_msg.set_ground_status(0) = " << t_multi_measure_info_msg.ground_status() <<std::endl;
  712. // }
  713. }
  714. if (t_multi_status_msg.id_struct().terminal_id() == DISP_TERM_ID)
  715. {
  716. // LOG(WARNING) << t_car_wheel_information.range_status<<std::endl;
  717. LOG(INFO) << t_multi_status_msg.DebugString() << std::endl
  718. << std::endl;
  719. }
  720. }
  721. }
  722. #endif
  723. return Error_code::SUCCESS;
  724. }
  725. // ***************************** nanomsg *********************************
  726. //定时发送状态信息
  727. Error_manager System_executor::encapsulate_send_status()
  728. {
  729. static int cloud_count=-1;
  730. cloud_count++;
  731. // if(!g_debug_file.is_open())
  732. // {
  733. // g_debug_file.open("./filter_debug_result.txt", std::ios::app);
  734. // }
  735. Error_manager t_error;
  736. //创建一条状态消息
  737. message::Ground_status_msg t_ground_status_msg;
  738. t_ground_status_msg.mutable_base_info()->set_msg_type(message::Message_type::eGround_status_msg);
  739. t_ground_status_msg.mutable_base_info()->set_timeout_ms(5000);
  740. t_ground_status_msg.mutable_base_info()->set_sender(message::Communicator::eGround_measurer);
  741. t_ground_status_msg.mutable_base_info()->set_receiver(message::Communicator::eEmpty);
  742. // t_ground_status_msg.set_terminal_id(m_terminal_id);
  743. t_ground_status_msg.mutable_id_struct()->set_terminal_id(m_terminal_id);
  744. // 创建各区域状态消息,
  745. // 注意!!!目前公共消息名字依旧使用wj,不做修改
  746. // manager
  747. #if WJ_VELO == 1
  748. {
  749. Velodyne_manager::Velodyne_manager_status t_velodyne_manager_status = Velodyne_manager::get_instance_references().get_status();
  750. t_ground_status_msg.set_wanji_manager_status((message::Wanji_manager_status)t_velodyne_manager_status);
  751. // lidar
  752. std::map<int, Velodyne_lidar_device *> t_velodyne_lidar_device_map = Velodyne_manager::get_instance_references().get_velodyne_lidar_device_map();
  753. std::map<int, Velodyne_lidar_device::Velodyne_lidar_device_status> t_velodyne_lidar_status_map;
  754. for (auto iter = t_velodyne_lidar_device_map.begin(); iter != t_velodyne_lidar_device_map.end(); ++iter)
  755. {
  756. t_velodyne_lidar_status_map.emplace(std::pair<int, Velodyne_lidar_device::Velodyne_lidar_device_status>(iter->second->get_lidar_id(), iter->second->get_status()));
  757. }
  758. // region
  759. std::map<int, Ground_region *> t_ground_region_map = Velodyne_manager::get_instance_references().get_ground_region_map();
  760. int region_index = 0;
  761. for (auto iter = t_ground_region_map.begin(); iter != t_ground_region_map.end(); ++iter)
  762. {
  763. // 以t_ground_status_msg为模板创建各区域心跳消息
  764. message::Ground_status_msg t_multi_status_msg;
  765. t_multi_status_msg.CopyFrom(t_ground_status_msg);
  766. t_multi_status_msg.mutable_id_struct()->set_terminal_id(iter->second->get_terminal_id());
  767. t_multi_status_msg.set_region_worker_status((message::Region_worker_status)(iter->second->get_status()));
  768. velodyne::Region t_param = iter->second->get_param();
  769. for (size_t j = 0; j < t_param.lidar_exts_size(); j++)
  770. {
  771. std::map<int, Velodyne_lidar_device::Velodyne_lidar_device_status>::iterator t_status_iter = t_velodyne_lidar_status_map.find(t_param.lidar_exts(j).lidar_id());
  772. if (t_status_iter == t_velodyne_lidar_status_map.end())
  773. {
  774. LOG(WARNING) << "lidar status " << t_param.lidar_exts(j).lidar_id() << " cannot be found, param error";
  775. }
  776. else
  777. {
  778. t_multi_status_msg.add_wanji_lidar_device_status((message::Wanji_lidar_device_status)t_status_iter->second);
  779. }
  780. }
  781. //velodyne雷达的自动定位信息
  782. Common_data::Car_wheel_information t_car_wheel_information;
  783. t_error = (*iter).second->get_last_wheel_information(&t_car_wheel_information, std::chrono::system_clock::now());
  784. // 获取区域点云填入信息
  785. pcl::PointCloud<pcl::PointXYZ>::Ptr t_region_cloud = pcl::PointCloud<pcl::PointXYZ>::Ptr(new pcl::PointCloud<pcl::PointXYZ>);
  786. iter->second->get_region_cloud(t_region_cloud, Ground_region::Region_cloud_type::filtered);
  787. // if (cloud_count == 5)
  788. // {
  789. // std::string t_filename = std::string("region_") + std::to_string(iter->first) + "_cloud.txt";
  790. // save_cloud_txt(t_region_cloud, t_filename);
  791. // LOG(INFO) << "region " << iter->first << " cloud has been saved in " + t_filename;
  792. // }
  793. // for (size_t j = 0; j < t_region_cloud->size(); j++)
  794. // {
  795. // message::Cloud_coordinate *tp_cloud = t_multi_status_msg.add_cloud();
  796. // tp_cloud->set_x(t_region_cloud->points[j].x);
  797. // tp_cloud->set_y(t_region_cloud->points[j].y);
  798. // tp_cloud->set_z(t_region_cloud->points[j].z);
  799. // }
  800. update_measure_info(t_multi_status_msg, t_car_wheel_information, t_region_cloud->size());
  801. std::string t_msg = t_multi_status_msg.SerializeAsString();
  802. System_communication::get_instance_references().encapsulate_msg(t_msg);
  803. if (t_multi_status_msg.id_struct().terminal_id() == DISP_TERM_ID)
  804. std::cout << t_multi_status_msg.DebugString() << std::endl
  805. << std::endl;
  806. }
  807. }
  808. #elif WJ_VELO == 0
  809. {
  810. // wj_support 20220718
  811. Wanji_manager::Wanji_manager_status t_wj_manager_status = Wanji_manager::get_instance_references().get_status();
  812. t_ground_status_msg.set_wanji_manager_status((message::Wanji_manager_status)t_wj_manager_status);
  813. // lidar
  814. std::map<int, Wanji_lidar_device *> t_wj_lidar_device_map = Wanji_manager::get_instance_references().get_wanji_lidar_device_map();
  815. std::map<int, Wanji_lidar_device::Wanji_lidar_device_status> t_wj_lidar_status_map;
  816. for (auto iter = t_wj_lidar_device_map.begin(); iter != t_wj_lidar_device_map.end(); ++iter)
  817. {
  818. t_wj_lidar_status_map.emplace(std::pair<int, Wanji_lidar_device::Wanji_lidar_device_status>(iter->second->get_lidar_id(), iter->second->get_status()));
  819. }
  820. // region
  821. std::map<int, Region_worker *> t_region_worker_map = Wanji_manager::get_instance_references().get_region_worker_map();
  822. int region_index = 0;
  823. for (auto iter = t_region_worker_map.begin(); iter != t_region_worker_map.end(); ++iter)
  824. {
  825. // 以t_ground_status_msg为模板创建各区域心跳消息
  826. message::Ground_status_msg t_multi_status_msg;
  827. t_multi_status_msg.CopyFrom(t_ground_status_msg);
  828. t_multi_status_msg.mutable_id_struct()->set_terminal_id(iter->second->get_terminal_id());
  829. t_multi_status_msg.set_region_worker_status((message::Region_worker_status)(iter->second->get_status()));
  830. wj::Region t_param = iter->second->get_param();
  831. for (size_t j = 0; j < t_param.lidar_exts_size(); j++)
  832. {
  833. std::map<int, Wanji_lidar_device::Wanji_lidar_device_status>::iterator t_status_iter = t_wj_lidar_status_map.find(t_param.lidar_exts(j).lidar_id());
  834. if (t_status_iter == t_wj_lidar_status_map.end())
  835. {
  836. LOG(WARNING) << "lidar status " << t_param.lidar_exts(j).lidar_id() << " cannot be found, param error";
  837. }
  838. else
  839. {
  840. t_multi_status_msg.add_wanji_lidar_device_status((message::Wanji_lidar_device_status)t_status_iter->second);
  841. }
  842. }
  843. //velodyne雷达的自动定位信息
  844. Common_data::Car_wheel_information t_car_wheel_information;
  845. t_error = (*iter).second->get_last_wheel_information(&t_car_wheel_information, std::chrono::system_clock::now());
  846. // 获取区域点云填入信息
  847. pcl::PointCloud<pcl::PointXYZ>::Ptr t_region_cloud = pcl::PointCloud<pcl::PointXYZ>::Ptr(new pcl::PointCloud<pcl::PointXYZ>);
  848. iter->second->get_region_cloud(t_region_cloud);
  849. // if (cloud_count == 5)
  850. // {
  851. // std::string t_filename = std::string("region_") + std::to_string(iter->first) + "_cloud.txt";
  852. // save_cloud_txt(t_region_cloud, t_filename);
  853. // LOG(INFO) << "region " << iter->first << " cloud has been saved in " + t_filename;
  854. // }
  855. // for (size_t j = 0; j < t_region_cloud->size(); j++)
  856. // {
  857. // message::Cloud_coordinate *tp_cloud = t_multi_status_msg.add_cloud();
  858. // tp_cloud->set_x(t_region_cloud->points[j].x);
  859. // tp_cloud->set_y(t_region_cloud->points[j].y);
  860. // tp_cloud->set_z(t_region_cloud->points[j].z);
  861. // }
  862. update_measure_info(t_multi_status_msg, t_car_wheel_information, t_region_cloud->size());
  863. std::string t_msg = t_multi_status_msg.SerializeAsString();
  864. System_communication::get_instance_references().encapsulate_msg(t_msg);
  865. if (t_multi_status_msg.id_struct().terminal_id() == DISP_TERM_ID)
  866. LOG(INFO) << t_multi_status_msg.DebugString();
  867. }
  868. }
  869. // std::cout << " huli test :::: " << " t_ground_status_msg.DebugString() = " << std::endl;
  870. // std::cout << t_ground_status_msg.DebugString() << std::endl;
  871. // std::cout << " huli test :::: " << " t_ground_status_msg.DebugString() = " << t_ground_status_msg.DebugString() << std::endl;
  872. #else
  873. {
  874. // mix vlp16 and wj716
  875. // 以多线雷达为主
  876. Velodyne_manager::Velodyne_manager_status t_velodyne_manager_status = Velodyne_manager::get_instance_references().get_status();
  877. t_ground_status_msg.set_wanji_manager_status((message::Wanji_manager_status)t_velodyne_manager_status);
  878. // vlp16 lidar
  879. std::map<int, Velodyne_lidar_device *> t_velodyne_lidar_device_map = Velodyne_manager::get_instance_references().get_velodyne_lidar_device_map();
  880. std::map<int, Velodyne_lidar_device::Velodyne_lidar_device_status> t_velodyne_lidar_status_map;
  881. for (auto iter = t_velodyne_lidar_device_map.begin(); iter != t_velodyne_lidar_device_map.end(); ++iter)
  882. {
  883. t_velodyne_lidar_status_map.emplace(std::pair<int, Velodyne_lidar_device::Velodyne_lidar_device_status>(iter->second->get_lidar_id(), iter->second->get_status()));
  884. }
  885. // wj lidar
  886. #if LIDAR_TYPE == 1
  887. std::map<int, Wanji_lidar_device *> t_wj_lidar_device_map = Wanji_manager::get_instance_references().get_wanji_lidar_device_map();
  888. std::map<int, Wanji_lidar_device::Wanji_lidar_device_status> t_wj_lidar_status_map;
  889. for (auto iter = t_wj_lidar_device_map.begin(); iter != t_wj_lidar_device_map.end(); ++iter)
  890. {
  891. t_wj_lidar_status_map.emplace(std::pair<int, Wanji_lidar_device::Wanji_lidar_device_status>(iter->second->get_lidar_id(), iter->second->get_status()));
  892. }
  893. #else
  894. std::map<int, Wanji_716N_lidar_device *> t_wj_lidar_device_map = Wanji_manager::get_instance_references().get_wanji_lidar_device_map();
  895. std::map<int, Wanji_716N_lidar_device::Wanji_716N_device_status> t_wj_lidar_status_map;
  896. for (auto iter = t_wj_lidar_device_map.begin(); iter != t_wj_lidar_device_map.end(); ++iter)
  897. {
  898. t_wj_lidar_status_map.emplace(std::pair<int, Wanji_716N_lidar_device::Wanji_716N_device_status>(iter->second->get_lidar_id(), iter->second->get_status()));
  899. }
  900. #endif
  901. // wj region
  902. std::map<int, Region_worker *> t_region_worker_map = Wanji_manager::get_instance_references().get_region_worker_map();
  903. // vlp16 region
  904. std::map<int, Ground_region *> t_ground_region_map = Velodyne_manager::get_instance_references().get_ground_region_map();
  905. int region_index = 0;
  906. for (auto iter = t_ground_region_map.begin(); iter != t_ground_region_map.end(); ++iter)
  907. {
  908. // 以t_ground_status_msg为模板创建各区域心跳消息
  909. message::Ground_status_msg t_multi_status_msg;
  910. t_multi_status_msg.CopyFrom(t_ground_status_msg);
  911. t_multi_status_msg.mutable_id_struct()->set_terminal_id(iter->second->get_terminal_id());
  912. t_multi_status_msg.set_region_worker_status((message::Region_worker_status)(iter->second->get_status()));
  913. // 查找多线区域内对应多线激光雷达
  914. velodyne::Region t_param = iter->second->get_param();
  915. for (size_t j = 0; j < t_param.lidar_exts_size(); j++)
  916. {
  917. std::map<int, Velodyne_lidar_device::Velodyne_lidar_device_status>::iterator t_status_iter = t_velodyne_lidar_status_map.find(t_param.lidar_exts(j).lidar_id());
  918. if (t_status_iter == t_velodyne_lidar_status_map.end())
  919. {
  920. LOG(WARNING) << "vlp16 lidar status " << t_param.lidar_exts(j).lidar_id() << " cannot be found, param error";
  921. }
  922. else
  923. {
  924. t_multi_status_msg.add_wanji_lidar_device_status((message::Wanji_lidar_device_status)t_status_iter->second);
  925. }
  926. }
  927. //velodyne雷达的自动定位信息
  928. Common_data::Car_wheel_information t_car_wheel_information;
  929. t_error = (*iter).second->get_last_wheel_information(&t_car_wheel_information, std::chrono::system_clock::now());
  930. // 获取区域点云填入信息
  931. // 20221211 changed by yct, nanomsg dont save cloud
  932. pcl::PointCloud<pcl::PointXYZ>::Ptr t_region_cloud = pcl::PointCloud<pcl::PointXYZ>::Ptr(new pcl::PointCloud<pcl::PointXYZ>);
  933. iter->second->get_region_cloud(t_region_cloud, Ground_region::Region_cloud_type::filtered);
  934. // if (cloud_count == 5)
  935. // {
  936. // std::string t_filename = std::string("vlp16_region_") + std::to_string(iter->first) + "_cloud.txt";
  937. // save_cloud_txt(t_region_cloud, t_filename);
  938. // LOG(INFO) << "vlp16 region " << iter->first << " cloud has been saved in " + t_filename;
  939. // }
  940. // for (size_t j = 0; j < t_region_cloud->size(); j++)
  941. // {
  942. // message::Cloud_coordinate *tp_cloud = t_multi_status_msg.add_cloud();
  943. // tp_cloud->set_x(t_region_cloud->points[j].x);
  944. // tp_cloud->set_y(t_region_cloud->points[j].y);
  945. // tp_cloud->set_z(t_region_cloud->points[j].z);
  946. // }
  947. // 检查vlp16区域与wj区域对应关系,wj存在对应区域则填充设备状态,并融合测量结果
  948. auto t_wj_region_iter = t_region_worker_map.find(iter->first);
  949. if(t_wj_region_iter != t_region_worker_map.end())
  950. {
  951. wj::Region t_param = t_wj_region_iter->second->get_param();
  952. //
  953. for (size_t j = 0; j < t_param.lidar_exts_size(); j++)
  954. {
  955. #if LIDAR_TYPE == 1
  956. std::map<int, Wanji_lidar_device::Wanji_lidar_device_status>::iterator t_status_iter = t_wj_lidar_status_map.find(t_param.lidar_exts(j).lidar_id());
  957. #else
  958. std::map<int, Wanji_716N_lidar_device::Wanji_716N_device_status>::iterator t_status_iter = t_wj_lidar_status_map.find(t_param.lidar_exts(j).lidar_id());
  959. #endif
  960. if (t_status_iter == t_wj_lidar_status_map.end())
  961. {
  962. LOG(WARNING) << "wj lidar status " << t_param.lidar_exts(j).lidar_id() << " cannot be found, param error";
  963. }
  964. else
  965. {
  966. t_multi_status_msg.add_wanji_lidar_device_status((message::Wanji_lidar_device_status)t_status_iter->second);
  967. }
  968. }
  969. //wj雷达的自动定位信息
  970. Common_data::Car_wheel_information t_wj_car_wheel_information;
  971. t_error = t_wj_region_iter->second->get_last_wheel_information(&t_wj_car_wheel_information, std::chrono::system_clock::now());
  972. // 获取区域点云填入信息
  973. pcl::PointCloud<pcl::PointXYZ>::Ptr t_wj_region_cloud = pcl::PointCloud<pcl::PointXYZ>::Ptr(new pcl::PointCloud<pcl::PointXYZ>);
  974. t_wj_region_iter->second->get_region_cloud(t_wj_region_cloud);
  975. // if (cloud_count == 8)
  976. // {
  977. // std::string t_filename = std::string("wj_region_") + std::to_string(t_wj_region_iter->first) + "_cloud.txt";
  978. // save_cloud_txt(t_wj_region_cloud, t_filename);
  979. // LOG(INFO) << "wj region " << t_wj_region_iter->first << " cloud has been saved in " + t_filename;
  980. // }
  981. // for (size_t j = 0; j < t_wj_region_cloud->size(); j++)
  982. // {
  983. // message::Cloud_coordinate *tp_cloud = t_multi_status_msg.add_cloud();
  984. // tp_cloud->set_x(t_wj_region_cloud->points[j].x);
  985. // tp_cloud->set_y(t_wj_region_cloud->points[j].y);
  986. // tp_cloud->set_z(t_wj_region_cloud->points[j].z);
  987. // }
  988. // LOG_IF(WARNING, iter->second->get_terminal_id() == DISP_TERM_ID)<<"\n"<<t_car_wheel_information.to_string()<<"\n"
  989. // <<t_wj_car_wheel_information.to_string()<<"\n"
  990. // <<t_car_wheel_information.range_status<<", "<<t_wj_car_wheel_information.range_status;
  991. // 融合测量结果,验证中心点差异x<0.03, y<0.06, 角度差异ang<0.6, 轴距差异wb<0.055
  992. double dx = t_car_wheel_information.car_center_x - t_wj_car_wheel_information.car_center_x;
  993. double dy = t_car_wheel_information.car_center_y - t_wj_car_wheel_information.car_center_y;
  994. double dang = t_car_wheel_information.car_angle - t_wj_car_wheel_information.car_angle;
  995. double dwb = t_car_wheel_information.car_wheel_base - t_wj_car_wheel_information.car_wheel_base;
  996. // 使用rabbit mq 中函数计算偏差与提示,此处不处理!!
  997. if(fabs(dx) < 0.03 && fabs(dy) < 0.06 && fabs(dang) < 0.6 && fabs(dwb) < 0.055)
  998. {
  999. // t_car_wheel_information.car_wheel_base = t_car_wheel_information.car_wheel_base*0.3 + t_car_wheel_information.car_wheel_base*0.7;
  1000. }else
  1001. {
  1002. // LOG_IF(WARNING, iter->second->get_terminal_id() == DISP_TERM_ID)<<
  1003. // "detect mismatch, region "<<iter->first<<", dx dy dang dwb: "<<dx<<", "<<dy<<", "<<dang<<", "<< dwb << std::endl
  1004. // << t_car_wheel_information.to_string() << std::endl
  1005. // << t_wj_car_wheel_information.to_string() << std::endl;
  1006. }
  1007. }else{
  1008. LOG_IF(WARNING, iter->second->get_terminal_id() == DISP_TERM_ID)<<"region mismatch, vlp16 "<<iter->first<<", wj doesn't have corresponding region id";
  1009. }
  1010. update_measure_info(t_multi_status_msg, t_car_wheel_information, t_region_cloud->size());
  1011. std::string t_msg = t_multi_status_msg.SerializeAsString();
  1012. System_communication::get_instance_references().encapsulate_msg(t_msg);
  1013. // if (t_multi_status_msg.id_struct().terminal_id() == DISP_TERM_ID)
  1014. // std::cout << t_multi_status_msg.DebugString() << std::endl
  1015. // << std::endl;
  1016. }
  1017. }
  1018. #endif
  1019. return Error_code::SUCCESS;
  1020. }
  1021. //判断是否为待机,如果已经准备好,则可以执行任务。
  1022. bool System_executor::is_ready()
  1023. {
  1024. if (m_system_executor_status == SYSTEM_EXECUTOR_READY && m_thread_pool.thread_is_full_load() == false)
  1025. {
  1026. return true;
  1027. }
  1028. else
  1029. {
  1030. return false;
  1031. }
  1032. }
  1033. System_executor::System_executor_status System_executor::get_system_executor_status()
  1034. {
  1035. return m_system_executor_status;
  1036. }
  1037. int System_executor::get_terminal_id()
  1038. {
  1039. return m_terminal_id;
  1040. }
  1041. //雷达感测定位 的处理函数
  1042. //input::command_id, 消息指令id, 由主控制系统生成的唯一码
  1043. //input::command_id, 终端id, 对应具体的某个车位
  1044. //return::void, 没有返回, 执行结果直接生成一条答复消息, 然后通过通信返回
  1045. void System_executor::execute_for_measure(std::string command_info, int terminal_id, std::chrono::system_clock::time_point receive_time)
  1046. {
  1047. Error_manager t_error;
  1048. Error_manager t_result;
  1049. LOG(INFO) << " System_executor::execute_for_measure run " << this;
  1050. //第1步, 按照时间生成中间文件的保存路径
  1051. time_t nowTime;
  1052. nowTime = time(NULL);
  1053. struct tm *sysTime = localtime(&nowTime);
  1054. char t_save_path[256] = {0};
  1055. sprintf(t_save_path, "../data/%04d%02d%02d_%02d%02d%02d",
  1056. sysTime->tm_year + 1900, sysTime->tm_mon + 1, sysTime->tm_mday, sysTime->tm_hour, sysTime->tm_min, sysTime->tm_sec);
  1057. //第2步, 创建万集管理模块的任务单, 并发送到 wanji_manager
  1058. // Wanji_manager_task t_wanji_manager_task ;
  1059. // Common_data::Car_wheel_information t_car_information_by_wanji;
  1060. // t_wanji_manager_task.task_init(TASK_CREATED,"",NULL,std::chrono::milliseconds(3000),
  1061. // terminal_id, receive_time);
  1062. // t_error = Task_command_manager::get_instance_references().execute_task(&t_wanji_manager_task);
  1063. // 或者创建velodyne管理模块任务单,并发送到velodyne_manager
  1064. Velodyne_manager_task t_velodyne_manager_task;
  1065. Common_data::Car_wheel_information t_car_information_by_velodyne;
  1066. t_velodyne_manager_task.task_init(TASK_CREATED, "", NULL, std::chrono::milliseconds(3000),
  1067. terminal_id, receive_time);
  1068. t_error = Task_command_manager::get_instance_references().execute_task(&t_velodyne_manager_task);
  1069. //第3步, 等待任务单完成
  1070. if (t_error != Error_code::SUCCESS)
  1071. {
  1072. LOG(INFO) << " Velodyne_manager/Velodyne_manager execute_task error " << this;
  1073. }
  1074. else
  1075. {
  1076. // //判断任务是否结束, 阻塞 等待, 直到任务完成或者超时
  1077. // while ( t_wanji_manager_task.is_task_end() == false)
  1078. // {
  1079. // if ( t_wanji_manager_task.is_over_time() )
  1080. // {
  1081. // //超时处理。取消任务。
  1082. // Wanji_manager::get_instance_pointer()->cancel_task(&t_wanji_manager_task);
  1083. // t_error.error_manager_reset(Error_code::WJ_MANAGER_TASK_OVER_TIME, Error_level::MINOR_ERROR,
  1084. // " t_wanjestaui_manager_task is_over_time ");
  1085. // t_wanji_manager_task.set_task_error_manager(t_error);
  1086. // }
  1087. // else
  1088. // {
  1089. // //继续等待
  1090. // std::this_thread::sleep_for(std::chrono::microseconds(1));
  1091. // std::this_thread::yield();
  1092. // }
  1093. // }
  1094. // //提取任务单 的错误码
  1095. // t_error = t_wanji_manager_task.get_task_error_manager();
  1096. // if ( t_error == Error_code::SUCCESS )
  1097. // {
  1098. // t_car_information_by_wanji = t_wanji_manager_task.get_car_wheel_information();
  1099. // }
  1100. // else
  1101. // {
  1102. // LOG(INFO) << " wanji_manager_task error :::::::" << t_wanji_manager_task.get_task_error_manager().to_string() << this;
  1103. // }
  1104. // ------------------- 切换为velodyne ------------------
  1105. //判断任务是否结束, 阻塞 等待, 直到任务完成或者超时
  1106. while (t_velodyne_manager_task.is_task_end() == false)
  1107. {
  1108. if (t_velodyne_manager_task.is_over_time())
  1109. {
  1110. //超时处理。取消任务。
  1111. Velodyne_manager::get_instance_pointer()->cancel_task(&t_velodyne_manager_task);
  1112. t_error.error_manager_reset(Error_code::VELODYNE_MANAGER_TASK_OVER_TIME, Error_level::MINOR_ERROR,
  1113. " t_velodyne_manager_task is_over_time ");
  1114. t_velodyne_manager_task.set_task_error_manager(t_error);
  1115. }
  1116. else
  1117. {
  1118. //继续等待
  1119. std::this_thread::sleep_for(std::chrono::microseconds(1));
  1120. std::this_thread::yield();
  1121. }
  1122. }
  1123. //提取任务单 的错误码
  1124. t_error = t_velodyne_manager_task.get_task_error_manager();
  1125. if (t_error == Error_code::SUCCESS)
  1126. {
  1127. t_car_information_by_velodyne = t_velodyne_manager_task.get_car_wheel_information();
  1128. }
  1129. else
  1130. {
  1131. LOG(INFO) << " velodyne_manager_task error :::::::" << t_velodyne_manager_task.get_task_error_manager().to_string() << this;
  1132. }
  1133. }
  1134. t_result.compare_and_cover_error(t_error);
  1135. //measure 测量模块的最终结果
  1136. Common_data::Car_measure_information t_car_information_result;
  1137. //第4步, 生成反馈消息
  1138. // if(t_car_information_by_wanji.correctness == true )
  1139. // {
  1140. // t_car_information_result.center_x = t_car_information_by_wanji.center_x;
  1141. // t_car_information_result.center_y = t_car_information_by_wanji.center_y;
  1142. // t_car_information_result.car_angle = t_car_information_by_wanji.car_angle;
  1143. // t_car_information_result.wheel_base = t_car_information_by_wanji.wheel_base;
  1144. // t_car_information_result.wheel_width = t_car_information_by_wanji.wheel_width;
  1145. // t_car_information_result.correctness = true;
  1146. // }else{
  1147. // t_result.set_error_level_down(NEGLIGIBLE_ERROR);
  1148. // }
  1149. // ------------------- 切换为velodyne ------------------
  1150. if (t_car_information_by_velodyne.correctness == true)
  1151. {
  1152. t_car_information_result.car_center_x = t_car_information_by_velodyne.car_center_x;
  1153. t_car_information_result.car_center_y = t_car_information_by_velodyne.car_center_y;
  1154. t_car_information_result.car_angle = t_car_information_by_velodyne.car_angle;
  1155. t_car_information_result.car_wheel_base = t_car_information_by_velodyne.car_wheel_base;
  1156. t_car_information_result.car_wheel_width = t_car_information_by_velodyne.car_wheel_width;
  1157. t_car_information_result.correctness = true;
  1158. }
  1159. else
  1160. {
  1161. t_result.set_error_level_down(NEGLIGIBLE_ERROR);
  1162. }
  1163. //第七步, 创建一条答复消息
  1164. message::Ground_detect_response_msg t_ground_detect_response_msg;
  1165. t_ground_detect_response_msg.mutable_base_info()->set_msg_type(message::Message_type::eGround_detect_response_msg);
  1166. t_ground_detect_response_msg.mutable_base_info()->set_timeout_ms(5000);
  1167. t_ground_detect_response_msg.mutable_base_info()->set_sender(message::Communicator::eGround_measurer);
  1168. t_ground_detect_response_msg.mutable_base_info()->set_receiver(message::Communicator::eMain);
  1169. t_ground_detect_response_msg.set_command_key(command_info);
  1170. t_ground_detect_response_msg.mutable_id_struct()->set_terminal_id(terminal_id);
  1171. t_ground_detect_response_msg.mutable_error_manager()->set_error_code(t_result.get_error_code());
  1172. t_ground_detect_response_msg.mutable_error_manager()->set_error_level((message::Error_level)t_result.get_error_level());
  1173. t_ground_detect_response_msg.mutable_error_manager()->set_error_description(t_result.get_error_description());
  1174. t_ground_detect_response_msg.mutable_locate_information()->set_locate_x(t_car_information_result.car_center_x);
  1175. t_ground_detect_response_msg.mutable_locate_information()->set_locate_y(t_car_information_result.car_center_y);
  1176. t_ground_detect_response_msg.mutable_locate_information()->set_locate_angle(t_car_information_result.car_angle);
  1177. t_ground_detect_response_msg.mutable_locate_information()->set_locate_length(t_car_information_result.car_length);
  1178. t_ground_detect_response_msg.mutable_locate_information()->set_locate_width(t_car_information_result.car_width);
  1179. t_ground_detect_response_msg.mutable_locate_information()->set_locate_height(t_car_information_result.car_height);
  1180. t_ground_detect_response_msg.mutable_locate_information()->set_locate_wheel_base(t_car_information_result.car_wheel_base);
  1181. t_ground_detect_response_msg.mutable_locate_information()->set_locate_wheel_width(t_car_information_result.car_wheel_width);
  1182. t_ground_detect_response_msg.mutable_locate_information()->set_locate_front_theta(t_car_information_result.car_front_theta);
  1183. t_ground_detect_response_msg.mutable_locate_information()->set_locate_correct(t_car_information_result.correctness);
  1184. std::string t_msg = t_ground_detect_response_msg.SerializeAsString();
  1185. System_communication::get_instance_references().encapsulate_msg(t_msg);
  1186. std::cout << "huli t_measure_response_msg = " << t_ground_detect_response_msg.DebugString() << std::endl;
  1187. return;
  1188. }