فهرست منبع

添加交通标志牌识别决策逻辑,待验证

chenxiaowei 1 سال پیش
والد
کامیت
bd6e5288c2

+ 9 - 0
src/decition/common/common/car_status.h

@@ -27,6 +27,8 @@
 #include "common/tracepointstation.h"
 
 #include "groupmsg.pb.h"
+#include "cameraobject.pb.h"
+#include "cameraobjectarray.pb.h"
 #include <QMutex>
 
 #define RADAR_OBJ_NUM 64
@@ -273,6 +275,13 @@ namespace iv {
 
         double mfbasepitch = 0.0;
         bool mbUseRampAssit = false;
+
+        //20230814,交通标志牌识别数据更新计时
+        QTime mTrafficSignUpdateTimer;
+        //std::vector<iv::vision::cameraobjectarray> xtrafficsign;
+        double iTrafficsignSpeed = 200;//5,10 ,0
+        int itrafficsignTurn = 200; //0,左转,1 右转
+
     };
     typedef boost::serialization::singleton<iv::CarStatus> CarStatusSingleton;//非线程安全,注意多线程加锁,单例模式
 }

+ 92 - 1
src/decition/decition_brain_sf_changan_shenlan/decition/brain.cpp

@@ -68,7 +68,11 @@ namespace decition {
         {
             gbrain->GetFusion(strdata,nSize);
         }
-    }
+        void ListenTrafficSign(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname) //20230814,交通标志牌识别数据更新
+        {
+            gbrain->GetTrafficSign(strdata,nSize);
+        }
+}
 
 }
 
@@ -115,6 +119,9 @@ iv::decition::BrainDecition::BrainDecition()
 
     mpv2r            = iv::modulecomm::RegisterRecv("v2r_send",iv::decition::ListenV2r); //20211009,cxw
 
+    mpaTrafficSign   = iv::modulecomm::RegisterRecv("signarray",iv::decition::ListenTrafficSign); //20230814,交通标志牌识别数据更新
+
+
     ModuleFun funchassis =std::bind(&iv::decition::BrainDecition::UpdateChassis,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
     mpaChassis = iv::modulecomm::RegisterRecvPlus(gstrmemchassis.data(),funchassis);
 
@@ -150,6 +157,8 @@ iv::decition::BrainDecition::~BrainDecition()
     iv::modulecomm::Unregister(mpaVechicleState);
     iv::modulecomm::Unregister(mpvbox);
     iv::modulecomm::Unregister(mpa);
+    iv::modulecomm::Unregister(mpaTrafficSign);
+    iv::modulecomm::Unregister(mpv2r);
 
     delete eyes;
     std::cout<<"Brain Unialize."<<std::endl;
@@ -1172,6 +1181,88 @@ void iv::decition::BrainDecition::UpdateFusion(std::shared_ptr<iv::fusion::fusio
 
 }
 
+//20230814,交通标志识别
+void iv::decition::BrainDecition::GetTrafficSign(const char *pdata, const int ndatasize)
+{
+    std::shared_ptr<iv::vision::cameraobjectarray> xtrafficsign (new iv::vision::cameraobjectarray);
+
+    if(ndatasize<1)return;
+
+    if(false == xtrafficsign->ParseFromArray(pdata,ndatasize))
+    {
+        std::cout<<" Listen traffic sign fail."<<std::endl;
+        return;
+    }
+    else{
+        //std::cout<<"srfront byte size:  "<<radarobjvec.ByteSize()<<std::endl;
+    }
+
+    ServiceCarStatus.mTrafficSignUpdateTimer.start();
+    ServiceCarStatus.iTrafficsignSpeed=200.0;
+    ServiceCarStatus.itrafficsignTurn=200.0;
+
+    iv::decition::BrainDecition::UpdateTrafficSign(xtrafficsign);
+}
+
+void iv::decition::BrainDecition::UpdateTrafficSign(std::shared_ptr<iv::vision::cameraobjectarray> xtrafficsign)
+{
+    mMutexVison_.lock();
+
+    xtrafficsign.swap(mvision_obs_);
+    int flag;
+    for(int i =0; i<mvision_obs_->obj_size();i++)//{"Speed10","Speed5","Left","Right","Nopassing","Park"}共六类
+    {
+        if(mvision_obs_->obj(i).type()=="Speed10")
+            flag=0;
+        else if(mvision_obs_->obj(i).type()=="Speed5")
+            flag=1;
+        else if(mvision_obs_->obj(i).type()=="Left")
+            flag=2;
+        else if(mvision_obs_->obj(i).type()=="Right")
+            flag=3;
+        else if(mvision_obs_->obj(i).type()=="Nopassing")
+            flag=4;
+        else if(mvision_obs_->obj(i).type()=="Park")
+            flag=5;
+        else
+            flag =200;
+
+      if((flag==0) ||(flag==1)||(flag==4)|(flag==5))
+      {
+          switch(flag)
+          {
+              case 0:
+                    ServiceCarStatus.iTrafficsignSpeed=min(10.0 , ServiceCarStatus.iTrafficsignSpeed);
+              case 1:
+                    ServiceCarStatus.iTrafficsignSpeed=min(5.0,ServiceCarStatus.iTrafficsignSpeed);
+              case 4:
+                    ServiceCarStatus.iTrafficsignSpeed=min(0.0,ServiceCarStatus.iTrafficsignSpeed);
+              case 5:
+                    ServiceCarStatus.iTrafficsignSpeed=min(0.0,ServiceCarStatus.iTrafficsignSpeed);
+              default:
+                    ServiceCarStatus.iTrafficsignSpeed=200.0;
+          }
+      }
+      else if((flag==2) ||(flag==3))
+      {
+          switch(flag)
+          {
+              case 2:
+                    ServiceCarStatus.itrafficsignTurn=2;
+              case 3:
+                    ServiceCarStatus.itrafficsignTurn=3;
+              default:
+                    ServiceCarStatus.itrafficsignTurn=200.0;
+          }
+      }
+
+    }
+    givlog->debug("decition_brain","flag is : %d",flag);
+    givlog->debug("decition_brain","itrafficsignTurn is : %d",ServiceCarStatus.itrafficsignTurn);
+    givlog->debug("decition_brain","iTrafficsignSpeed is : %f",ServiceCarStatus.iTrafficsignSpeed);
+
+    mMutexVison_.unlock();
+}
 
 void iv::decition::BrainDecition::UpdateGroupInfo(const char *pdata, const int ndatasize){
 

+ 8 - 1
src/decition/decition_brain_sf_changan_shenlan/decition/brain.h

@@ -48,6 +48,8 @@
 #include "v2r.pb.h"
 #include "carstate.pb.h"
 #include "groupmsg.pb.h"
+#include "cameraobject.pb.h"
+#include "cameraobjectarray.pb.h"
 
 #include "fanyaapi.h"
 
@@ -132,7 +134,8 @@ namespace iv {
             void * mpaObsTraceLeft;
             void * mpaObsTraceRight;
             void * mpaCarstate;
-             void * mpv2r;//20211009,cxw
+            void * mpv2r;//20211009,cxw
+            void * mpaTrafficSign;//20230814,交通标志牌识别数据更新计时
 
 
             void ShareDecition(iv::decition::Decition decition);
@@ -162,10 +165,14 @@ namespace iv {
             void GetFusion(const char* pdata, const int ndatasize);
             void UpdateFusion(std::shared_ptr<iv::fusion::fusionobjectarray> fusion_obs);
             void UpdateV2r(const char *pdata, const int ndatasize);
+            void GetTrafficSign(const char* pdata, const int ndatasize);//20230814,交通标志牌识别
+            void UpdateTrafficSign(std::shared_ptr<iv::vision::cameraobjectarray> xtrafficsign);//20230814,交通标志牌识别数据更新计时
 
         private:
             std::shared_ptr<iv::fusion::fusionobjectarray>  mfusion_obs_;
             iv::LidarGridPtr fusion_ptr_ = NULL;
+            std::shared_ptr<iv::vision::cameraobjectarray>  mvision_obs_;//20230814,交通标志牌识别数据更新计时
+            QMutex mMutexVison_;//20230814,交通标志牌识别数据更新计时
             QMutex mMutex_;
 
 

+ 25 - 0
src/decition/decition_brain_sf_changan_shenlan/decition/decide_gps_00.cpp

@@ -2797,6 +2797,31 @@ else
     }
 
     if(obsDistance == 0)obsDistance = -1;
+
+    //20230814,交通标志识别添加 start
+    if(ServiceCarStatus.mTrafficSignUpdateTimer.elapsed()>10*1000)
+     {
+        ServiceCarStatus.iTrafficsignSpeed=200;
+        ServiceCarStatus.itrafficsignTurn=200;
+     }
+
+    if (ServiceCarStatus.itrafficsignTurn==2)
+    {
+        gps_decition->leftlamp = true;
+        gps_decition->rightlamp = false;
+    }
+    else if (ServiceCarStatus.itrafficsignTurn==3)
+    {
+        gps_decition->leftlamp = false;
+        gps_decition->rightlamp = true;
+    }
+    else
+    {
+        ;
+    }
+    dSpeed=min(dSpeed,ServiceCarStatus.iTrafficsignSpeed);
+    //20230814,交通标志识别添加 end
+
     phaseSpeedDecition(gps_decition, secSpeed, obsDistance, obsSpeed,now_gps_ins);
 
     Point2D now_s_d=iv::decition::cartesian_to_frenet1D(gpsMapLine,now_gps_ins.gps_x,now_gps_ins.gps_y);

+ 5 - 2
src/decition/decition_brain_sf_changan_shenlan/decition_brain_sf_changan_shenlan.pro

@@ -34,6 +34,8 @@ SOURCES += $$PWD/../common/main.cpp \
     ../../include/msgtype/fusionobject.pb.cc \
     ../../include/msgtype/carstate.pb.cc \
     ../../include/msgtype/v2r.pb.cc \
+    ../../include/msgtype/cameraobjectarray.pb.cc\
+    ../../include/msgtype/cameraobject.pb.cc\
     ../../include/msgtype/groupmsg.pb.cc
 
 include($$PWD/../common/common/common.pri)
@@ -96,9 +98,10 @@ HEADERS += \
     ../common/perception_sf/sensor_lidar.h \
     ../common/perception_sf/sensor_radar.h \
     ../common/common/sysparam_type.h \
-    ../../include/msgtype/carstate.pb.h
+    ../../include/msgtype/carstate.pb.h \
     ../../include/msgtype/v2r.pb.h \
-
+    ../../include/msgtype/cameraobjectarray.pb.h\
+    ../../include/msgtype/cameraobject.pb.h\
     ../../include/msgtype/groupmsg.pb.h