Przeglądaj źródła

change detection_lidar_grid for add fusion.

yuchuli 1 rok temu
rodzic
commit
c280f48e6b

+ 1 - 1
src/decition/decition_brain_sf_changan_shenlan/decition/decide_gps_00.h

@@ -300,7 +300,7 @@ extern double avoidX;
 //extern int avoidXNew;
 extern double avoidXNew; //20230213
 extern bool parkBesideRoad;
-extern double steerSpeed;
+extern double steerSpeed;·
 extern bool transferPieriod;
 extern bool transferPieriod2;
 extern double traceDevi;

+ 8 - 3
src/detection/detection_lidar_grid/detection_lidar_grid.pro

@@ -6,13 +6,14 @@
 
 QT       -= gui
 
-CONFIG += c++11 console
+CONFIG += c++14 console
 CONFIG -= app_bundle
 
 DEFINES += PERCEPTION_LIDAR_VV7_LIBRARY
 
 #CONFIG += plugin
 
+
 # The following define makes your compiler emit warnings if you use
 # any feature of Qt which has been marked as deprecated (the exact warnings
 # depend on your compiler). Please consult the documentation of the
@@ -58,11 +59,15 @@ DEFINES += QT_DEPRECATED_WARNINGS
 
 SOURCES += \
         perception_lidar_vv7.cpp \
-    perceptionoutput.cpp
+    perceptionoutput.cpp \
+    ../../include/msgtype/fusionobject.pb.cc \
+    ../../include/msgtype/fusionobjectarray.pb.cc
 
 HEADERS += \
         perception_lidar_vv7.h \
-    perceptionoutput.h
+    perceptionoutput.h \
+    ../../include/msgtype/fusionobject.pb.h \
+    ../../include/msgtype/fusionobjectarray.pb.h
 
 unix {
     target.path = /usr/lib

+ 57 - 1
src/detection/detection_lidar_grid/perception_lidar_vv7.cpp

@@ -35,6 +35,8 @@ static void * g_lidar_pc_nofloor;
 static void * glidar_pc_p;
 static void * glidar_per;
 
+static void * gpafusion;
+
 iv::Ivfault *gfault = nullptr;
 iv::Ivlog *givlog = nullptr;
 
@@ -101,7 +103,9 @@ static void writepctosm(pcl::PointCloud<pcl::PointXYZI>::Ptr & point_cloud,void
     int * pHeadSize = (int *)strOut;
     *pHeadSize = 4 + point_cloud->header.frame_id.size()+4+8;
     memcpy(strOut+4,point_cloud->header.frame_id.c_str(),point_cloud->header.frame_id.size());
-    pcl::uint32_t * pu32 = (pcl::uint32_t *)(strOut+4+sizeof(point_cloud->header.frame_id.size()));
+//    pcl::uint32_t * pu32 = (pcl::uint32_t *)(strOut+4+sizeof(point_cloud->header.frame_id.size()));
+
+    unsigned int * pu32 = (unsigned int *)(strOut+4+sizeof(point_cloud->header.frame_id.size()));
     *pu32 = point_cloud->header.seq;
     memcpy(strOut+4+sizeof(point_cloud->header.frame_id.size()) + 4,&point_cloud->header.stamp,8);
     pcl::PointXYZI * p;
@@ -400,6 +404,54 @@ static void GridGetObs(pcl::PointCloud<pcl::PointXYZI>::Ptr & point_cloud,std::s
 
 #include <QTime>
 
+#include "fusionobjectarray.pb.h"
+
+void ShareFusionObject(void * pa ,std::shared_ptr<std::vector<iv::ObstacleBasic>> & lidar_obs)
+{
+    iv::fusion::fusionobjectarray xfusion;
+    double timestamp = std::chrono::system_clock::now().time_since_epoch().count();
+    timestamp = timestamp/1000000.0;
+
+    xfusion.set_timestamp(timestamp);
+
+    iv::fusion::fusionobject * pobj =  xfusion.add_obj();
+
+    pobj->set_id(0);
+    pobj->set_type(0);
+    iv::fusion::VelXY xvel;
+    xvel.set_x(0);
+    xvel.set_y(0);
+    pobj->set_allocated_vel_abs(&xvel);
+    iv::fusion::Dimension xdim;
+    xdim.set_x(0.2);
+    xdim.set_y(0.2);
+    xdim.set_z(2.0);
+    pobj->set_allocated_dimensions(&xdim);
+
+    int i;
+    int nsize = lidar_obs->size();
+    for(i=0;i<nsize;i++)
+    {
+        iv::fusion::NomalXYZ * pcen = pobj->add_nomal_centroid();
+        pcen->set_nomal_x(lidar_obs->at(i).nomal_x);
+        pcen->set_nomal_y(lidar_obs->at(i).nomal_y);
+        pcen->set_nomal_z(lidar_obs->at(i).nomal_z);
+    }
+
+    int nbytesize = xfusion.ByteSize();
+    std::shared_ptr<char> pstr_ptr = std::shared_ptr<char>(new char[nbytesize]);
+
+    if(xfusion.SerializeToArray(pstr_ptr.get(),nbytesize))
+    {
+        iv::modulecomm::ModuleSendMsg(pa,pstr_ptr.get(),nbytesize);
+    }
+    else
+    {
+        std::cout<<" serialzie fusion fail."<<std::endl;
+    }
+
+
+}
 
 
 static void ListenPointCloud(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
@@ -446,6 +498,8 @@ static void ListenPointCloud(const char * strdata,const unsigned int nSize,const
 
 //   std::cout<<"prc."<<std::endl;
 
+    ShareFusionObject(gpafusion,lidar_obs);
+
     if(g_robosys == 0)
     {
         if(lidar_obs->size() == 0)
@@ -484,6 +538,8 @@ void  PERCEPTION_LIDAR_VV7SHARED_EXPORT StartPerception_lidar_vv7()
 
     glidar_obs = iv::modulecomm::RegisterSend(gstr_outputmemname,20000000,3);
 
+    gpafusion = iv::modulecomm::RegisterSend("li_ra_fusion",10000000,1);
+
 #ifdef OUT_GROUND
     g_lidar_pc_floor = iv::modulecomm::RegisterSend("lidar_pc_floor",20000000,3);
     g_lidar_pc_nofloor = iv::modulecomm::RegisterSend("lidar_pc_nofloor",20000000,3);

+ 1 - 1
src/driver/driver_lidar_rs16/driver_lidar_rs16.pro

@@ -2,7 +2,7 @@ QT -= gui
 
 QT += network
 
-CONFIG += c++11 console
+CONFIG += c++14 console
 CONFIG -= app_bundle
 
 # The following define makes your compiler emit warnings if you use