lidar_driver_hesaipandarqt64.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. #include <thread>
  2. #include <iostream>
  3. #include <QUdpSocket>
  4. //#include <QNetworkDatagram>
  5. #include <iostream>
  6. #include <QMutex>
  7. #include <QDateTime>
  8. #include <QFile>
  9. //#include <pcl/conversions.h>
  10. #include <pcl/point_cloud.h>
  11. #include <pcl/point_types.h>
  12. #include "modulecomm.h"
  13. #include "lidar_driver_hesaipandarqt64.h"
  14. #include "lidar_hesaipandarqt64_rawdata.h"
  15. #include "ivexit.h"
  16. #include "ivfault.h"
  17. #include "ivlog.h"
  18. #ifdef VV7_1
  19. int vv7;
  20. #endif
  21. #define Lidar_Pi 3.1415926535897932384626433832795
  22. #define Lidar32 (unsigned long)3405883584//192.168.1.203
  23. #define Lidar_roll_ang 90*Lidar_Pi/180.0
  24. static std::thread * g_phesaipandar64Thread;
  25. static std::thread * g_phesaipandar64ProcThread;
  26. //float gV_theta[16] = {-15,1,-13,3,-11,5,-9,7,-7,9,-5,11,-3,13,-1,15}; //16 Angles
  27. //static float gV_theta[64] = {14.7,10.85,7.877,4.875,2.858,1.846,1.678,1.506,1.34,1.169,1.002,0.831,0.664,0.493,0.326,0.155,-0.013,-0.182,-0.351,-0.519,-0.69,-0.857,-1.027,-1.195,-1.366,-1.533,-1.704,-1.87,-2.042,-2.21,-2.38,-2.547,-2.718,-2.882,-3.055,-3.222,-3.392,-3.557,-3.73,-3.894,-4.066,-4.232,-4.403,-4.567,-4.74,-4.902,-5.074,-5.239,-5.411,-5.573,-5.747,-5.908,-6.08,-6.243,-7.245,-8.241,-9.242,-10.227,-11.214,-12.188,-13.156,-14.112,-19.071,-25.079}; //64 Angles
  28. static float gV_theta[64] = {-52.121,-49.785,-47.577,-45.477,-43.465,-41.528,-39.653,-37.831,
  29. -36.055,-34.32,-32.619,-30.95,-29.308,-27.69,-26.094,-24.517,
  30. -22.964,-21.42,-19.889,-18.372,-16.865,-15.368,-13.88,-12.399,
  31. -10.925,-9.457,-7.994,-6.535,-5.079,-3.626,-2.175,-0.725,
  32. 0.725,2.175,3.626,5.079,6.534,7.993,9.456,10.923,
  33. 12.397,13.877,15.365,16.861,18.368,19.885,21.415,22.959,
  34. 24.524,26.101,27.697,29.315,30.957,32.627,34.328,36.064,
  35. 37.84,39.662,41.537,43.475,45.487,47.587,49.795,52.133};
  36. static float gH_theta[64] = {8.736,8.314,7.964,7.669,7.417,7.198,7.007,6.838,
  37. 6.688,6.554,6.434,6.326,6.228,6.14,6.059,5.987,
  38. -5.27,-5.216,-5.167,-5.123,-5.083,-5.047,-5.016,-4.988,
  39. -4.963,-4.942,-4.924,-4.91,-4.898,-4.889,-4.884,-4.881,
  40. 5.493,5.496,5.502,5.512,5.525,5.541,5.561,5.584,
  41. 5.611,5.642,5.676,5.716,5.759,5.808,5.862,5.921,
  42. -5.33,-5.396,-5.469,-5.55,-5.64,-5.74,-5.85,-5.974,
  43. -6.113,-6.269,-6.447,-6.651,-6.887,-7.163,-7.493,-7.892};
  44. //static float gH_theta[64] = {-1.042,-1.042,-1.042,-1.042,-1.042,-1.042,1.042,3.125,5.208,-5.208,-3.125,-1.042,1.042,3.125,5.208,-5.208,-3.125,-1.042,1.042,3.125,5.208,-5.208,-3.125,-1.042,1.042,3.125,5.208,-5.208,-3.125,-1.042,1.042,3.125,5.208,-5.208,-3.125,-1.042,1.042,3.125,5.208,-5.208,-3.125,-1.042,1.042,3.125,5.208,-5.208,-3.125,-1.042,1.042,3.125,5.208,-5.208,-3.125,-1.042,-1.042,-1.042,-1.042,-1.042,-1.042,-1.042,-1.042,-1.042,-1.042,-1.042};
  45. static float gV_theta_cos[64],gV_theta_sin[64];
  46. //static void * g_hesaipandar64_raw;
  47. static void * g_lidar_pc;
  48. static bool g_bhesaipandar64_run = false;
  49. static bool g_bhesaipandar64_running = false;
  50. static bool g_bhesaipandar64_Proc_running = false;
  51. static int g_seq = 0;
  52. static unsigned short glidar_port=2368;
  53. extern char gstr_memname[256];
  54. extern char gstr_rollang[256];
  55. extern char gstr_inclinationang_yaxis[256]; //from y axis
  56. extern char gstr_inclinationang_xaxis[256]; //from x axis
  57. //char gstr_hostip[256];
  58. extern char gstr_port[256];
  59. extern char gstr_yaml[256];
  60. extern char gstr_calibfile[256];
  61. extern iv::Ivfault * gIvfault;
  62. extern iv::Ivlog * gIvlog;
  63. /**
  64. * @brief The hesaipandar64_Buf class
  65. * Use for Lidar UDP DATA Save
  66. */
  67. class hesaipandar64_Buf
  68. {
  69. private:
  70. char * mstrdata;
  71. int mnSize; //Data SizeUse
  72. QMutex mMutex;
  73. int mIndex;
  74. public:
  75. hesaipandar64_Buf()
  76. {
  77. mstrdata = new char[BK32_DATA_BUFSIZE];
  78. mIndex = 0;
  79. mnSize = 0;
  80. }
  81. ~hesaipandar64_Buf()
  82. {
  83. delete mstrdata;
  84. }
  85. void WriteData(const char * strdata,const int nSize)
  86. {
  87. mMutex.lock();
  88. memcpy(mstrdata,strdata,nSize);
  89. mnSize = nSize;
  90. mIndex++;
  91. mMutex.unlock();
  92. }
  93. int ReadData(char * strdata,const int nRead,int * pnIndex)
  94. {
  95. int nRtn = 0;
  96. if(mnSize <= 0)return 0;
  97. mMutex.lock();
  98. nRtn = mnSize;
  99. if(nRtn >nRead)
  100. {
  101. nRtn = nRead;
  102. std::cout<<"lidar_hesaipandarQT64 hesaipandarQT64_Buf ReadData data nRead = "<<nRead<<" is small"<<std::endl;
  103. }
  104. memcpy(strdata,mstrdata,nRtn);
  105. mnSize = 0;
  106. if(pnIndex != 0)*pnIndex = mIndex;
  107. mMutex.unlock();
  108. return nRtn;
  109. }
  110. };
  111. static hesaipandar64_Buf * g_hesaipandar64_Buf;
  112. static char * g_RawData_Buf; //Buffer UDP Data
  113. static int gnRawPos = 0;
  114. static float gAngle_Old = 0;
  115. static float gAngle_Total = 0;
  116. static unsigned short gold = 0;
  117. static int gnPac = 0;
  118. #include <QTime>
  119. static QTime gTime;
  120. /**
  121. * @brief processhesaipandar64_Data
  122. * @param ba UDP Buffer
  123. * 1.UDP ByteArray Length is npacsize.
  124. * 2.if Angle is More than 360. Tell Another thread process.
  125. */
  126. static void processhesaipandar64_Data(QByteArray ba)
  127. {
  128. gnPac++;
  129. unsigned short * pAng;
  130. float fAng;
  131. char * pdata;
  132. pdata = ba.data();
  133. // const int npacsize = 1194;
  134. const int npacsize = 1072;
  135. if(ba.length() >= npacsize)
  136. {
  137. // pAng = (unsigned short *)(pdata+8);
  138. pAng = (unsigned short *)(pdata+6+6);
  139. fAng = *pAng;fAng = fAng*0.01;
  140. if(fabs(fAng-gAngle_Old)>300)
  141. {
  142. gAngle_Total = gAngle_Total + fabs(fabs(fAng-gAngle_Old)-360);
  143. }
  144. else
  145. {
  146. gAngle_Total = gAngle_Total + fabs(fabs(fAng-gAngle_Old));
  147. }
  148. gAngle_Old = fAng;
  149. if(gAngle_Total > 360)
  150. {
  151. g_hesaipandar64_Buf->WriteData(g_RawData_Buf,gnRawPos);
  152. lidar_hesaipandar64_raw * p = new lidar_hesaipandar64_raw();
  153. p->mnLen = gnRawPos;
  154. memcpy(p->mstrdata,g_RawData_Buf,gnRawPos);
  155. // iv::modulecomm::ModuleSendMsg(g_hesaipandar64_raw,(char *)p,sizeof(lidar_hesaipandar64_raw));
  156. delete p;
  157. memcpy(g_RawData_Buf,pdata,npacsize);
  158. gnRawPos = npacsize;
  159. // std::cout<<"index = "<<gnPac<<" time ="<<gTime.elapsed()<<" a cycle"<<std::endl;
  160. gAngle_Total = 0;
  161. }
  162. else
  163. {
  164. if((gnRawPos+npacsize)<= BK32_DATA_BUFSIZE)
  165. {
  166. memcpy(g_RawData_Buf+gnRawPos,pdata,npacsize);
  167. gnRawPos= gnRawPos+npacsize;
  168. }
  169. else
  170. {
  171. std::cout<<"lidar_hesaipandar64 processhesaipandar64_Data data is very big gnRawPos = "<<gnRawPos<<std::endl;
  172. }
  173. }
  174. // std::cout<<*pAng<<std::endl;
  175. // gold = *pAng;
  176. if(gnRawPos == 0)
  177. {
  178. gAngle_Total = 0;
  179. gAngle_Old = *pAng;
  180. gAngle_Old = gAngle_Old*0.01;
  181. memcpy(g_RawData_Buf,pdata,npacsize);
  182. gnRawPos = gnRawPos+npacsize;
  183. }
  184. }
  185. else
  186. {
  187. std::cout<<"lidar_hesaipandar64 processhesaipandar64_Data receive data packet len is not npacsize "<<std::endl;
  188. }
  189. }
  190. /**
  191. * @brief hesaipandar64_Func thread for receive udp socket
  192. * @param n
  193. */
  194. static void hesaipandar64_Func(int n)
  195. {
  196. gTime.start();
  197. std::cout<<"Enter hesaipandar64_Func."<<std::endl;
  198. QUdpSocket * udpSocket = new QUdpSocket( );
  199. udpSocket->bind(QHostAddress::Any, glidar_port);
  200. unsigned int ndatamisstime = 0;
  201. int nstate = 0;
  202. int nlaststate = 0;
  203. while(g_bhesaipandar64_run)
  204. {
  205. if(udpSocket->hasPendingDatagrams())
  206. {
  207. ndatamisstime = 0;
  208. // std::cout<<"have data."<<std::endl;
  209. QByteArray datagram;
  210. datagram.resize(udpSocket->pendingDatagramSize());
  211. QHostAddress sender;
  212. quint16 senderPort;
  213. udpSocket->readDatagram(datagram.data(), datagram.size(),
  214. &sender, &senderPort);
  215. // processTheDatagram(datagram);
  216. // std::cout<<"have data."<<std::endl;
  217. // QNetworkDatagram datagram = udpSocket->receiveDatagram();
  218. processhesaipandar64_Data(datagram);
  219. datagram.clear();
  220. }
  221. else
  222. {
  223. // std::cout<<"running."<<std::endl;
  224. std::this_thread::sleep_for(std::chrono::milliseconds(1));
  225. if(ndatamisstime < 1000000) ndatamisstime++;
  226. }
  227. if(ndatamisstime > 1000)
  228. {
  229. nstate = 1;
  230. }
  231. if(ndatamisstime > 60000)
  232. {
  233. nstate = 2;
  234. }
  235. if(ndatamisstime < 100)
  236. {
  237. nstate = 0;
  238. }
  239. if(nlaststate != nstate)
  240. {
  241. nlaststate = nstate;
  242. switch (nstate) {
  243. case 0:
  244. gIvfault->SetFaultState(0,0,"OK");
  245. gIvlog->info("received udp data.device is ok.");
  246. break;
  247. case 1:
  248. gIvfault->SetFaultState(1,1,"No data");
  249. gIvlog->warn("more than 1 second no data. warning.");
  250. break;
  251. case 2:
  252. gIvfault->SetFaultState(2,2,"No data,Please Check Device or setting.");
  253. gIvlog->error("more than 60 seconds no data. error. Please check device or setting.");
  254. break;
  255. default:
  256. break;
  257. }
  258. }
  259. }
  260. udpSocket->close();
  261. delete udpSocket;
  262. g_bhesaipandar64_running = false;
  263. std::cout<<"hesaipandar64_Func Exit."<<std::endl;
  264. }
  265. /**
  266. * @brief process_hesaipandar64obs Make PointCloud And Share
  267. * @param strdata pointer to data
  268. * @param nLen data length
  269. */
  270. static void process_hesaipandar64obs(char * strdata,int nLen)
  271. {
  272. double frollang = atof(gstr_rollang) *M_PI/180.0; //Roll Angle
  273. double finclinationang_xaxis = atof(gstr_inclinationang_xaxis)*M_PI/180.0; //Inclination from x axis
  274. double finclinationang_yaxis = atof(gstr_inclinationang_yaxis)*M_PI/180.0; //Inclination from y axis
  275. bool binclix = false;
  276. bool bincliy = false;
  277. if(finclinationang_xaxis != 0.0)binclix = true;
  278. if(finclinationang_yaxis != 0.0)bincliy = true;
  279. double cos_finclinationang_xaxis = cos(finclinationang_xaxis);
  280. double sin_finclinationang_xaxis = sin(finclinationang_xaxis);
  281. double cos_finclinationang_yaxis = cos(finclinationang_yaxis);
  282. double sin_finclinationang_yaxis = sin(finclinationang_yaxis);
  283. QDateTime dt = QDateTime::currentDateTime();
  284. pcl::PointCloud<pcl::PointXYZI>::Ptr point_cloud(
  285. new pcl::PointCloud<pcl::PointXYZI>());
  286. point_cloud->header.frame_id = "velodyne";
  287. point_cloud->height = 1;
  288. point_cloud->header.stamp = dt.currentMSecsSinceEpoch();
  289. point_cloud->width = 0;
  290. point_cloud->header.seq =g_seq;
  291. g_seq++;
  292. unsigned char * pstr = (unsigned char *)strdata;
  293. // std::cout<<"enter obs."<<std::endl;
  294. // float w = 0.0036;
  295. float Ang = 0;
  296. float Range = 0;
  297. int bag = 0;
  298. int Group = 0;
  299. int pointi = 0;
  300. float wt = 0;
  301. int wt1 = 0;
  302. // const int npacsize = 1194;
  303. const int npacsize = 1072;
  304. int buf1len = nLen/npacsize;
  305. // unsigned short * pAng;
  306. // double ang1,ang2;
  307. // pAng = (unsigned short *)(strdata+2+0*100);
  308. // ang1 = *pAng;ang1 = ang1/100.0;
  309. // pAng = (unsigned short *)(strdata+2+1*100);
  310. // ang2 = *pAng;ang2 = ang2/100.0;
  311. // double angdiff = ang2 - ang1;
  312. // if(angdiff<0)angdiff = angdiff + 360.0;
  313. // angdiff = angdiff/2.0;
  314. for (bag = 0; bag < buf1len; bag++)
  315. {
  316. // for (Group = 0; Group < 6; Group++)
  317. for (Group = 0; Group < 4; Group++)
  318. {
  319. // wt1 = ((pstr[bag*npacsize +9 + Group * 194] *256) + pstr[bag*npacsize + 8 + Group * 194]) ;
  320. wt1 = ((pstr[bag*npacsize +13 + Group * 258] *256) + pstr[bag*npacsize + 12 + Group * 258]) ;
  321. wt = wt1/ 100.0;
  322. for (pointi = 0; pointi <64; pointi++)
  323. {
  324. Ang = (0 - wt-gH_theta[pointi]) / 180.0 * Lidar_Pi;
  325. // Range = ((pstr[bag*npacsize + Group * 194 + 11 + 3 * pointi] << 8) + pstr[bag*npacsize+Group * 194 + 10 + 3 * pointi]);
  326. Range = ((pstr[bag*npacsize + Group * 258 + 15 + 4 * pointi] << 8) + pstr[bag*npacsize+Group * 258 + 14 + 4 * pointi]);
  327. // unsigned char intensity = pstr[bag*npacsize + Group * 194 + 12 + 3 * pointi];
  328. unsigned char intensity = pstr[bag*npacsize + Group * 258 + 16 + 4 * pointi];
  329. Range=Range* 0.004;
  330. pcl::PointXYZI point;
  331. point.x = Range* gV_theta_cos[pointi]*cos(Ang + frollang);
  332. point.y = Range* gV_theta_cos[pointi] *sin(Ang + frollang);
  333. point.z = Range* gV_theta_sin[pointi];
  334. point.intensity = intensity;
  335. if(binclix)
  336. {
  337. double y,z;
  338. y = point.y;z = point.z;
  339. point.y = y*cos_finclinationang_xaxis +z*sin_finclinationang_xaxis;
  340. point.z = z*cos_finclinationang_xaxis - y*sin_finclinationang_xaxis;
  341. }
  342. if(bincliy)
  343. {
  344. double z,x;
  345. z = point.z;x = point.x;
  346. point.z = z*cos_finclinationang_yaxis + x*sin_finclinationang_yaxis;
  347. point.x = x*cos_finclinationang_yaxis - z*sin_finclinationang_yaxis;
  348. }
  349. point_cloud->points.push_back(point);
  350. ++point_cloud->width;
  351. }
  352. }
  353. }
  354. char * strOut = new char[4+sizeof(point_cloud->header.frame_id.size()) + 4+8+point_cloud->width * sizeof(pcl::PointXYZI)];
  355. int * pHeadSize = (int *)strOut;
  356. *pHeadSize = 4 + point_cloud->header.frame_id.size()+4+8;
  357. memcpy(strOut+4,point_cloud->header.frame_id.c_str(),point_cloud->header.frame_id.size());
  358. pcl::uint32_t * pu32 = (pcl::uint32_t *)(strOut+4+sizeof(point_cloud->header.frame_id.size()));
  359. *pu32 = point_cloud->header.seq;
  360. memcpy(strOut+4+sizeof(point_cloud->header.frame_id.size()) + 4,&point_cloud->header.stamp,8);
  361. pcl::PointXYZI * p;
  362. p = (pcl::PointXYZI *)(strOut +4+sizeof(point_cloud->header.frame_id.size()) + 4+8 );
  363. memcpy(p,point_cloud->points.data(),point_cloud->width * sizeof(pcl::PointXYZI));
  364. iv::modulecomm::ModuleSendMsg(g_lidar_pc,strOut,4+sizeof(point_cloud->header.frame_id.size()) + 4+8+point_cloud->width * sizeof(pcl::PointXYZI));
  365. delete strOut;
  366. // std::cout<<"point cloud width = "<<point_cloud->width<<" size = "<<point_cloud->size()<<std::endl;
  367. }
  368. /**
  369. * @brief hesaipandar64_Proc_Func
  370. * thread for process data to PointCloud
  371. * @param n
  372. */
  373. static void hesaipandar64_Proc_Func(int n)
  374. {
  375. std::cout<<"Enter hesaipandar64_Proc_Func"<<std::endl;
  376. char * strdata = new char[BK32_DATA_BUFSIZE];
  377. int nIndex;
  378. int nRead;
  379. while(g_bhesaipandar64_run)
  380. {
  381. if((nRead = g_hesaipandar64_Buf->ReadData(strdata,BK32_DATA_BUFSIZE,&nIndex))>0)
  382. {
  383. //process data.
  384. process_hesaipandar64obs(strdata,nRead);
  385. }
  386. else
  387. {
  388. // std::cout<<"running."<<std::endl;
  389. std::this_thread::sleep_for(std::chrono::milliseconds(1));
  390. }
  391. }
  392. g_bhesaipandar64_Proc_running = false;
  393. std::cout<<"Exit hesaipandar64_Proc_Func"<<std::endl;
  394. }
  395. void exitfunc()
  396. {
  397. StopLidar_hesaipandar64();
  398. }
  399. static void decodecsv(char * strpath)
  400. {
  401. QFile xFile;
  402. xFile.setFileName(strpath);
  403. if(!xFile.open(QIODevice::ReadOnly))
  404. {
  405. std::cout<<"open csv file "<<strpath<<" fail."<<std::endl;
  406. return;
  407. }
  408. QByteArray ba = xFile.readAll();
  409. QString strdata = ba;
  410. QStringList strline = strdata.split("\n");
  411. const int nline= 64;
  412. if(strline.size()<(nline+1))
  413. {
  414. std::cout<<"File not complete. line size is "<<strline.size()<<std::endl;
  415. xFile.close();
  416. return;
  417. }
  418. int i;
  419. int nlinesize = strline.size();
  420. float * pxV,*pxH;
  421. pxV = new float[nline];
  422. pxH = new float[nline];
  423. bool bAllOK = true;
  424. for(i=1;i<(nline +1);i++)
  425. {
  426. QString strx = strline.at(i);
  427. QStringList strlistvalue = strx.split(",");
  428. if(strlistvalue.size()>=3)
  429. {
  430. pxV[i-1] = QString(strlistvalue.at(1)).toDouble();
  431. pxH[i-1] = QString(strlistvalue.at(2)).toDouble();
  432. }
  433. else
  434. {
  435. bAllOK = false;
  436. }
  437. }
  438. std::cout<<"Elevation:"<<std::endl;
  439. for(i=0;i<nline;i++)
  440. {
  441. std::cout<<pxV[i]<<",";
  442. }
  443. std::cout<<std::endl;
  444. std::cout<<"Azimuth:"<<std::endl;
  445. for(i=0;i<nline;i++)
  446. {
  447. std::cout<<pxH[i]<<",";
  448. }
  449. std::cout<<std::endl;
  450. if(bAllOK)
  451. {
  452. memcpy(gV_theta,pxV,64*sizeof(float));
  453. memcpy(gH_theta,pxH,64*sizeof(float));
  454. }
  455. else
  456. {
  457. std::cout<<"Not All Data OK. Please check."<<std::endl;
  458. }
  459. delete pxV;
  460. delete pxH;
  461. xFile.close();
  462. }
  463. /**
  464. * @brief StartLidar_hesaipandar64x Start
  465. * @return
  466. */
  467. int LIDAR_DRIVER_HESAIPANDARQT64SHARED_EXPORT StartLidar_hesaipandar64()
  468. {
  469. iv::ivexit::RegIVExitCall(exitfunc);
  470. std::cout<<"Now Start hesaipandar64 Listen."<<std::endl;
  471. g_RawData_Buf = new char[BK32_DATA_BUFSIZE];
  472. decodecsv(gstr_calibfile);
  473. int i;
  474. for(i=0;i<64;i++)
  475. {
  476. gV_theta[i] = gV_theta[i]*M_PI/180.0;
  477. gV_theta_cos[i] = cos(gV_theta[i]);
  478. gV_theta_sin[i] = sin(gV_theta[i]);
  479. }
  480. g_hesaipandar64_Buf = new hesaipandar64_Buf();
  481. g_bhesaipandar64_run = true;
  482. g_bhesaipandar64_running = true;
  483. g_bhesaipandar64_Proc_running = true;
  484. glidar_port = atoi(gstr_port);
  485. // g_hesaipandar64_raw = iv::modulecomm::RegisterSend(strmemnameraw,10*sizeof(lidar_hesaipandar64_raw),10);
  486. g_lidar_pc = iv::modulecomm::RegisterSend(gstr_memname,20000000,1);
  487. g_phesaipandar64Thread = new std::thread(hesaipandar64_Func,0);
  488. g_phesaipandar64ProcThread = new std::thread(hesaipandar64_Proc_Func,0);
  489. return 0;
  490. }
  491. /**
  492. * @brief StopLidar_hesaipandar64 Stop
  493. */
  494. void LIDAR_DRIVER_HESAIPANDARQT64SHARED_EXPORT StopLidar_hesaipandar64()
  495. {
  496. std::cout<<"Now Close hesaipandar64. "<<std::endl;
  497. g_bhesaipandar64_run = false;
  498. g_phesaipandar64Thread->join();
  499. g_phesaipandar64ProcThread->join();
  500. iv::modulecomm::Unregister(g_lidar_pc);
  501. delete g_phesaipandar64ProcThread;
  502. delete g_phesaipandar64Thread;
  503. delete g_hesaipandar64_Buf;
  504. delete g_RawData_Buf;
  505. }