chenxiaowei 3 жил өмнө
parent
commit
74a7bac941

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

@@ -208,10 +208,12 @@ namespace iv {
         //hapo station 2021/02/05
         //hapo station 2021/02/05
         iv::StationCmd   stationCmd;
         iv::StationCmd   stationCmd;
 
 
+
         //对于1+x车辆V2X信息,cxw
         //对于1+x车辆V2X信息,cxw
         unsigned char rsu_traffic_type=0;//路况信息
         unsigned char rsu_traffic_type=0;//路况信息
         unsigned char rsu_warning_type=0;//碰撞预警信息
         unsigned char rsu_warning_type=0;//碰撞预警信息
         float rsu_radiation_distance=0;//事件辐射范围
         float rsu_radiation_distance=0;//事件辐射范围
+
         float rsu_trafficelimit_spd=200;  //200代表没有限速
         float rsu_trafficelimit_spd=200;  //200代表没有限速
         float rsu_warnlimit_spd=200;  //200代表没有限速
         float rsu_warnlimit_spd=200;  //200代表没有限速
         double rsu_gps_lat=0.0;
         double rsu_gps_lat=0.0;
@@ -221,6 +223,12 @@ namespace iv {
         //0x2: 绿色
         //0x2: 绿色
         int vehicle_state_1x=0; //0正常行驶,1减速,2 停车
         int vehicle_state_1x=0; //0正常行驶,1减速,2 停车
         float target_spd_1x=0;//减速时的目标速度
         float target_spd_1x=0;//减速时的目标速度
+
+        float rsu_limit_spd=200;  //200代表没有限速
+        int iTrafficeLightColor = 2;    //0x0: 红色
+        //0x1: 黄色
+        //0x2: 绿色
+
         int iTrafficeLightTime = 0;     //红绿灯剩余时间
         int iTrafficeLightTime = 0;     //红绿灯剩余时间
         double iTrafficeLightLat = 0;
         double iTrafficeLightLat = 0;
         double iTrafficeLightLon = 0;
         double iTrafficeLightLon = 0;

+ 2 - 0
src/decition/decition_brain_sf_1x/decition/adc_adapter/hunter_adapter.cpp

@@ -107,6 +107,8 @@ iv::decition::Decition iv::decition::HunterAdapter::getAdapterDeciton(GPS_INS no
 //             controlSpeed = min(realSpeed+1,dSpeed);
 //             controlSpeed = min(realSpeed+1,dSpeed);
 //        }
 //        }
 
 
+         controlSpeed= dSpeed;
+
 
 
 //        controlSpeed= dSpeed;
 //        controlSpeed= dSpeed;
 
 

+ 8 - 0
src/decition/decition_brain_sf_1x/decition/decide_gps_00.cpp

@@ -2050,6 +2050,7 @@ if((traffic_type==0x01)||(traffic_type==0x02)||(traffic_type==0x03)||(traffic_ty
          ServiceCarStatus.vehicle_state_1x = 2;
          ServiceCarStatus.vehicle_state_1x = 2;
          ServiceCarStatus.target_spd_1x = 0;
          ServiceCarStatus.target_spd_1x = 0;
     }
     }
+<<<<<<< Updated upstream
     else
     else
     {}
     {}
 }
 }
@@ -2059,6 +2060,9 @@ else
 }
 }
     //红绿灯信息处理,computeTrafficSpeedLimt由于车子最高5所以要对速度做调整
     //红绿灯信息处理,computeTrafficSpeedLimt由于车子最高5所以要对速度做调整
 
 
+=======
+//红绿灯信息处理,computeTrafficSpeedLimt由于车子最高5所以要对速度做调整
+>>>>>>> Stashed changes
     //-----------------------------------------1+X采集车车路协同,end---------------------------------------------
     //-----------------------------------------1+X采集车车路协同,end---------------------------------------------
     //-------------------------------traffic light----------------------------------------------------------------------------------------
     //-------------------------------traffic light----------------------------------------------------------------------------------------
 
 
@@ -2212,7 +2216,11 @@ else
                   <<"OBS_Speed"<< ","<<obsSpeed<< ","
                   <<"OBS_Speed"<< ","<<obsSpeed<< ","
                   <<"Traffic_Type"<< ","<<traffic_type<< ","
                   <<"Traffic_Type"<< ","<<traffic_type<< ","
                   <<"Warn_Type"<< ","<<warning_type<< ","
                   <<"Warn_Type"<< ","<<warning_type<< ","
+<<<<<<< Updated upstream
                   <<"Limit_Speed"<< ","<<trafficlimit_spd<< ","
                   <<"Limit_Speed"<< ","<<trafficlimit_spd<< ","
+=======
+                  <<"Limit_Speed"<< ","<<limit_spd<< ","
+>>>>>>> Stashed changes
                   <<endl;
                   <<endl;
            outfile.close();
            outfile.close();
        }
        }

+ 1 - 1
src/v2x/CommunicatePlatform/common.h

@@ -12,7 +12,7 @@
 //std::string strHostPort = xp.GetParam("hostPort","12123");
 //std::string strHostPort = xp.GetParam("hostPort","12123");
 extern std::string strHostIP = "127.0.0.1";
 extern std::string strHostIP = "127.0.0.1";
 extern int iHostPort = 6666;
 extern int iHostPort = 6666;
-extern std::string VIN = "LMWHP1S27J1005905";
+extern std::string VIN = "A1000000CATARCS02";
 //////////////////////////////
 //////////////////////////////
 //         应答标识 TBOX         //
 //         应答标识 TBOX         //
 /////////////////////////////
 /////////////////////////////

+ 98 - 2
src/v2x/CommunicatePlatform/mainwindow.cpp

@@ -5,8 +5,8 @@ MainWindow::MainWindow(QWidget *parent) :
     QMainWindow(parent),
     QMainWindow(parent),
     ui(new Ui::MainWindow)
     ui(new Ui::MainWindow)
 {
 {
-    //m_tbox=new Tbox();
-    //initTboxMemory();
+    m_tbox=new Tbox();
+    initTboxMemory();
     m_radio=new Radio();
     m_radio=new Radio();
     ui->setupUi(this);
     ui->setupUi(this);
     initUi();
     initUi();
@@ -18,6 +18,10 @@ MainWindow::MainWindow(QWidget *parent) :
     ModuleFun fungpsimu =std::bind(&MainWindow::UpdateGPSIMU,this,std::placeholders::_1, \
     ModuleFun fungpsimu =std::bind(&MainWindow::UpdateGPSIMU,this,std::placeholders::_1, \
                                    std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
                                    std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
     mpMemGps = iv::modulecomm::RegisterRecvPlus("hcp2_gpsimu",fungpsimu);
     mpMemGps = iv::modulecomm::RegisterRecvPlus("hcp2_gpsimu",fungpsimu);
+    //ShareMem: ui
+    ModuleFun funUI =std::bind(&MainWindow::UpdateUI,this,std::placeholders::_1, \
+                                   std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
+    mpMemUI = iv::modulecomm::RegisterRecvPlus("hcp2_gpsimu",funUI);
 }
 }
 
 
 MainWindow::~MainWindow()
 MainWindow::~MainWindow()
@@ -244,3 +248,95 @@ void MainWindow::UpdateGPSIMU(const char * strdata,const unsigned int nSize,cons
  //   mfspeed = sqrt(pow(data->vel_E,2)+pow(data->vel_N,2)) * 3.6;  //double pow(double x, double y) 返回 x 的 y 次幂,即 xy。
  //   mfspeed = sqrt(pow(data->vel_E,2)+pow(data->vel_N,2)) * 3.6;  //double pow(double x, double y) 返回 x 的 y 次幂,即 xy。
     //mistGPS = 0;
     //mistGPS = 0;
 }
 }
+//UI DATA
+void MainWindow::UpdateUI(const char * strdata,const unsigned int nSize,const unsigned int index,\
+                              const QDateTime * dt,const char * strmemname)
+{
+    double accX,accY,lat,lon,heading,rtk,ins,vd,ve,vn;
+    iv::hmi::hmimsg  xhmi;
+    if(!xhmi.ParseFromArray(strdata,nSize))
+    {
+        mivlog->warn("ADCIntelligentVehicle::UpdateGPSIMU parse error. nSize is %d",nSize);
+        return;
+    }
+
+
+    if(xhmi.has_obuen()) {
+        bool enRadio=xhmi.obuen();
+        setEnRadio(enRadio);
+    }
+    if(xhmi.has_platformen()) {
+        bool enTbox=xhmi.platformen();
+        if(enTbox) {
+            enableTbox();
+        } else {
+            disableTbox();
+        }
+    }
+    if(xhmi.has_vin()) {
+        std::string str=xhmi.vin();
+        ui->lineEdit_VIN->setText(QString::fromStdString(str));
+        m_tbox->setTboxNewVin(str);
+    }
+    if(xhmi.has_rodeinfoen()) {
+        bool enRadioBroadcast = xhmi.rodeinfoen();
+        m_radio->getTrafficBroadcast(enRadioBroadcast);
+        ui->checkBox_trafficBroadcast->setChecked(enRadioBroadcast);
+    }
+    if(xhmi.has_rodefcwen()) {
+        bool enRadioWarning = xhmi.rodefcwen();
+        m_radio->getCollisonWarning(enRadioWarning);
+        ui->checkBox_collisionWarning->setChecked(enRadioWarning);
+    }
+    if(xhmi.has_roadjamsen()) {
+        bool enRadioIdenti = xhmi.roadjamsen();
+        m_radio->getBusyRoad(enRadioIdenti);
+        ui->checkBox_busyRoad->setChecked(enRadioIdenti);
+    }
+    if(xhmi.has_roaddricrimsen()) {
+        bool enRadioDanger =xhmi.roaddricrimsen();
+        m_radio->getDangerDrive(enRadioDanger);
+        ui->checkBox_dangerousDrive->setChecked(enRadioDanger);
+    }
+    if((xhmi.has_carcount())&&(xhmi.has_latup())&&(xhmi.has_latlow())
+            &&(xhmi.has_lonup())&&(xhmi.has_lonlow())
+            &&(xhmi.has_headingup())&&(xhmi.has_headinglow())
+            &&(xhmi.has_speedlow())&&(xhmi.has_speedup())) {
+        int virtualVehicleNum= int(xhmi.carcount());
+        ui->lineEdit_virtualVehicleNum->setText(QString::number(virtualVehicleNum));
+        double latMax = xhmi.latup();
+        ui->lineEdit_latMax->setText(QString("%1").arg(latMax));
+        double latMin= xhmi.latlow();
+        ui->lineEdit_latMin->setText(QString("%1").arg(latMin));
+        double lngMax= xhmi.lonup();
+        ui->lineEdit_lngMax->setText(QString("%1").arg(lngMax));
+        double lngMin= xhmi.lonlow();
+        ui->lineEdit_lngMin->setText(QString("%1").arg(lngMin));
+        float speedMax= xhmi.speedup();
+        ui->lineEdit_speedMax->setText(QString("%1").arg(speedMax));
+        float speedMin= xhmi.speedlow();
+        ui->lineEdit_speedMin->setText(QString("%1").arg(speedMin));
+        float yawMax=xhmi.headingup();
+        ui->lineEdit_yawMax->setText(QString("%1").arg(yawMax));
+        float yawMin=xhmi.headinglow();
+        ui->lineEdit_yawMin->setText(QString("%1").arg(yawMin));
+        int randId=qrand()%10000;
+        m_vectorRandom.push_back(randId);
+        virtualVehicleM structVirtualVehicle;
+        for(int i=1;i<virtualVehicleNum;i++) {
+            getRandomNum();
+        }
+        for(int i=0;i<virtualVehicleNum;i++) {
+            structVirtualVehicle.vin = m_vectorVin[i];
+            structVirtualVehicle.gps_lat=latMin+((double(m_vectorRandom[i]))/10000.0)*(latMax-latMin);
+            structVirtualVehicle.gps_lng=lngMin+((double(m_vectorRandom[i]))/10000.0)*(lngMax-lngMin);
+            structVirtualVehicle.speed=speedMin+((float(m_vectorRandom[i]))/10000.0)*(speedMax-speedMin);
+            structVirtualVehicle.yaw=yawMin+((float(m_vectorRandom[i]))/10000.0)*(yawMax-yawMin);
+            m_radio->upVirtualVehicle(structVirtualVehicle);
+        }
+
+    }
+
+
+
+}

+ 3 - 0
src/v2x/CommunicatePlatform/mainwindow.h

@@ -24,6 +24,7 @@ private:
     std::vector<std::string> m_vectorVin;
     std::vector<std::string> m_vectorVin;
     //20211009,jiaolili
     //20211009,jiaolili
     void * mpMemGps;
     void * mpMemGps;
+    void * mpMemUI;
     iv::Ivlog *mivlog;
     iv::Ivlog *mivlog;
     ///////////////////////////////
     ///////////////////////////////
 public:
 public:
@@ -36,6 +37,8 @@ public:
     void setEnRadio(bool en);
     void setEnRadio(bool en);
     void UpdateGPSIMU(const char * strdata,const unsigned int nSize,const unsigned int index,\
     void UpdateGPSIMU(const char * strdata,const unsigned int nSize,const unsigned int index,\
                                   const QDateTime * dt,const char * strmemname);
                                   const QDateTime * dt,const char * strmemname);
+    void UpdateUI(const char * strdata,const unsigned int nSize,const unsigned int index,\
+                                  const QDateTime * dt,const char * strmemname);
 private slots:
 private slots:
     void on_pushButton_connect_clicked();
     void on_pushButton_connect_clicked();
     void on_pushButton_vinChange_clicked(); 
     void on_pushButton_vinChange_clicked(); 

+ 3 - 3
src/v2x/CommunicatePlatform/radio.cpp

@@ -85,8 +85,8 @@ void Radio::outRealtimeTraffic(realtimeTrafficMessage realtimeTraffic)
 {
 {
     if(m_bEnTrafficBroadcast) {
     if(m_bEnTrafficBroadcast) {
         iv::v2r::v2r_send protobuf;
         iv::v2r::v2r_send protobuf;
-        float lat=((float)realtimeTraffic.lat)/1000000.0;
-        float lon=((float)realtimeTraffic.lng)/1000000.0;
+        double lat=((double)realtimeTraffic.lat)/1000000.0;
+        double lon=((double)realtimeTraffic.lng)/1000000.0;
         protobuf.set_radiobroadcastgpslat(lat);
         protobuf.set_radiobroadcastgpslat(lat);
         protobuf.set_radiobroadcastgpslat(lon);
         protobuf.set_radiobroadcastgpslat(lon);
         protobuf.set_radiobroadcastrange(realtimeTraffic.scope);
         protobuf.set_radiobroadcastrange(realtimeTraffic.scope);
@@ -226,7 +226,7 @@ void Radio::upDataStream()
     carFormationInfo.yaw[1] = (yaw>>16)&0xff;
     carFormationInfo.yaw[1] = (yaw>>16)&0xff;
     carFormationInfo.yaw[2] = (yaw>>8)&0xff;
     carFormationInfo.yaw[2] = (yaw>>8)&0xff;
     carFormationInfo.yaw[3] = (yaw)&0xff;
     carFormationInfo.yaw[3] = (yaw)&0xff;
-    float fele=m_structMControl.eleVoltage*100.0;
+    float fele=m_structMControl.eleVoltage;
     int iele = int(fele);
     int iele = int(fele);
     unsigned char electrical=(iele)&0xff;
     unsigned char electrical=(iele)&0xff;
     carFormationInfo.electricalVoltage=electrical;
     carFormationInfo.electricalVoltage=electrical;

+ 2 - 1
src/v2x/CommunicatePlatform/tbox.cpp

@@ -180,6 +180,7 @@ void Tbox::upDataStream()
     carFormationInfo.time[5]=(timestamp>>16)&0xff;
     carFormationInfo.time[5]=(timestamp>>16)&0xff;
     carFormationInfo.time[6]=(timestamp>>8)&0xff;
     carFormationInfo.time[6]=(timestamp>>8)&0xff;
     carFormationInfo.time[7]=(timestamp)&0xff;
     carFormationInfo.time[7]=(timestamp)&0xff;
+    carFormationInfo.type=0x0A;
     float flng,flat;
     float flng,flat;
     flng = (m_structM.gps_lng*1000000);
     flng = (m_structM.gps_lng*1000000);
     flat = m_structM.gps_lat*1000000;
     flat = m_structM.gps_lat*1000000;
@@ -204,7 +205,7 @@ void Tbox::upDataStream()
     carFormationInfo.car_yaw[1] = (yaw>>16)&0xff;
     carFormationInfo.car_yaw[1] = (yaw>>16)&0xff;
     carFormationInfo.car_yaw[2] = (yaw>>8)&0xff;
     carFormationInfo.car_yaw[2] = (yaw>>8)&0xff;
     carFormationInfo.car_yaw[3] = (yaw)&0xff;
     carFormationInfo.car_yaw[3] = (yaw)&0xff;
-    float fele=m_structM.ele_voltage*100.0;
+    float fele=m_structM.ele_voltage;
     int iele = int(fele);
     int iele = int(fele);
     unsigned char electrical=(iele)&0xff;
     unsigned char electrical=(iele)&0xff;
     carFormationInfo.electrical_voltage=electrical;
     carFormationInfo.electrical_voltage=electrical;

+ 1 - 0
src/v2x/CommunicatePlatform/tbox.h

@@ -20,6 +20,7 @@ struct DataPackageHead//数据包结构
 struct CarFormationInfoData  //车况数据
 struct CarFormationInfoData  //车况数据
 {
 {
     unsigned char time[8];//本报文时间戳。格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总秒数。
     unsigned char time[8];//本报文时间戳。格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总秒数。
+    unsigned char type;//0A
     unsigned char gps_lng[4];//经度 有效值范围:0~180;精确到小数点后6位;“0xFF,0xFF,0xFF,0xFE”表示异常,“0xFF,0xFF,0xFF,0xFF”表示无效
     unsigned char gps_lng[4];//经度 有效值范围:0~180;精确到小数点后6位;“0xFF,0xFF,0xFF,0xFE”表示异常,“0xFF,0xFF,0xFF,0xFF”表示无效
     unsigned char gps_lat[4];//维度 有效值范围:0~180;精确到小数点后6位;“0xFF,0xFF,0xFF,0xFE”表示异常,“0xFF,0xFF,0xFF,0xFF”表示无效
     unsigned char gps_lat[4];//维度 有效值范围:0~180;精确到小数点后6位;“0xFF,0xFF,0xFF,0xFE”表示异常,“0xFF,0xFF,0xFF,0xFF”表示无效
     unsigned char car_speed;//车速 有效值范围:0~200(表示0km/h~200km/h),最小计量单元:1km/h;“0xFE”表示异常,“0xFF”表示无效
     unsigned char car_speed;//车速 有效值范围:0~200(表示0km/h~200km/h),最小计量单元:1km/h;“0xFE”表示异常,“0xFF”表示无效