Pārlūkot izejas kodu

change driver_lidar_leishen_chx. test ch128x1 ok.

yuchuli 1 gadu atpakaļ
vecāks
revīzija
99960be390

+ 9 - 2
src/driver/driver_lidar_leishen_chx/leishenchx.cpp

@@ -2,7 +2,7 @@
 
 leishenchx::leishenchx(char * strmemname,double froll,double finclinationang_xaxis ,
                        double finclinationang_yaxis , int nDevMode ,
-                       unsigned short nDataPort,unsigned short nDevPort ):
+                       unsigned short nDataPort,unsigned short nDevPort,std::string strtype):
     socket_id(-1),
     point_cloud_xyzi_(new pcl::PointCloud<pcl::PointXYZI>),
     point_cloud_xyzi_bak_(new pcl::PointCloud<pcl::PointXYZI>),
@@ -38,7 +38,7 @@ leishenchx::leishenchx(char * strmemname,double froll,double finclinationang_xax
     lidar_ip_string = std::string("192.168.1.200");
     add_multicast = false;
     pcl_type = true;
-    lidar_type = std::string("ch128x1");
+    lidar_type = strtype;//std::string("ch128x1");
     group_ip_string = std::string("224.1.1.2");
     msop_udp_port = nDataPort;
     difop_udp_port = nDevPort;
@@ -958,7 +958,13 @@ int leishenchx::convertCoordinate(struct Firing &lidardata) {
     //add point
     if (pcl_type) {
         static int g_seq = 0;
+        static int nround = 0;
         if((lidardata.azimuth - noldaz)<-9000)
+        {
+            nround++;
+        }
+
+        if(nround >= 4)
         {
             std::cout<< std::chrono::system_clock::now().time_since_epoch().count()/1000000 <<" share point cloud."<<std::endl;
             ProduceCloud(point_cloud_xyzi_);
@@ -975,6 +981,7 @@ int leishenchx::convertCoordinate(struct Firing &lidardata) {
             point_cloud->header.seq =g_seq;
             g_seq++;
             point_cloud_xyzi_ = point_cloud;
+            nround = 0;
         }
 
         noldaz =  lidardata.azimuth;

+ 1 - 1
src/driver/driver_lidar_leishen_chx/leishenchx.h

@@ -70,7 +70,7 @@ class leishenchx : public lidardecode
 public:
     leishenchx(char * strmemname, double froll = 0.0,double finclinationang_xaxis = 0.0,
                double finclinationang_yaxis = 0.0, int nDevMode = 0,
-               unsigned short nDataPort = 2368,unsigned short nDevPort = 2369);
+               unsigned short nDataPort = 2368,unsigned short nDevPort = 2369,std::string strtype = "ch128x1");
 
     ~leishenchx();
 

+ 9 - 2
src/driver/driver_lidar_leishen_chx/main.cpp

@@ -19,6 +19,7 @@ static char gstr_devport[256];
 static char gstr_yaml[256];
 static char gstr_modulename[256];
 static char gstr_devmode[256];
+static char gstr_devtype[256];
 
 /**
  * @brief print_useage
@@ -35,6 +36,7 @@ void print_useage()
     std::cout<<" -d --devport $port : port . eq.  -d 2369"<<std::endl;
     std::cout<<" -f --devport $port : port . eq.  -f 0"<<std::endl;
     std::cout<<" -s --setyaml $yaml : port . eq.  -s rs1.yaml"<<std::endl;
+    std::cout<<" -t --settype $type : type . eq.  -t ch128x1"<<std::endl;
     std::cout<<" -h --help print help"<<std::endl;
 }
 
@@ -48,7 +50,7 @@ int  GetOptLong(int argc, char *argv[]) {
     // 第几个元素的描述,即是long_opts的下标值
     int option_index = 0;
     // 设置短参数类型及是否需要参数
-    const char *optstring = "n:m:r:x:y:p:d:f:s:h";
+    const char *optstring = "n:m:r:x:y:p:d:f:s:t:h";
 
     // 设置长参数类型及其简写,比如 --reqarg <==>-r
     /*
@@ -74,6 +76,7 @@ int  GetOptLong(int argc, char *argv[]) {
         {"devport", required_argument, NULL, 'd'},
         {"devmode", required_argument, NULL, 'f'},
         {"setyaml", required_argument, NULL, 's'},
+        {"settype", required_argument, NULL, 't'},
         {"help",  no_argument,       NULL, 'h'},
         //       {"optarg", optional_argument, NULL, 'o'},
         {0, 0, 0, 0}  // 添加 {0, 0, 0, 0} 是为了防止输入空值
@@ -122,6 +125,9 @@ int  GetOptLong(int argc, char *argv[]) {
         case 's':
             strncpy(gstr_yaml,optarg,255);
             break;
+        case 't':
+            strncpy(gstr_devtype,optarg,255);
+            break;
         case 'h':
             print_useage();
             nRtn = 1; //because use -h
@@ -212,6 +218,7 @@ int main(int argc, char *argv[])
     snprintf(gstr_devmode,255,"0");//默认端口号
     snprintf(gstr_yaml,255," ");
     snprintf(gstr_modulename,255,"driver_lidar_leishenc16");
+    snprintf(gstr_devtype,255,"ch128x1");
 
     int nRtn = GetOptLong(argc,argv);
     if(nRtn == 1)  //show help,so exit.
@@ -226,7 +233,7 @@ int main(int argc, char *argv[])
 
     leishenchx * pleishenchx = new leishenchx(gstr_memname,atof(gstr_rollang),atof(gstr_inclinationang_xaxis),
                                              atof(gstr_inclinationang_yaxis),atoi(gstr_devmode),static_cast<unsigned short>(atoi(gstr_port)),
-                                             static_cast<unsigned short>(atoi(gstr_devport)));
+                                             static_cast<unsigned short>(atoi(gstr_devport)),std::string(gstr_devtype));
     (void)pleishenchx;
 
     return a.exec();