Browse Source

change decition_brain for hapo

liusunan 4 years ago
parent
commit
5483ad07c8
31 changed files with 12381 additions and 12372 deletions
  1. 21 19
      src/decition/decition_brain/decition/adc_adapter/base_adapter.cpp
  2. 8 2
      src/decition/decition_brain/decition/adc_adapter/qingyuan_adapter.h
  3. 2063 2063
      src/decition/decition_brain/decition/adc_controller/pid_controller.h
  4. 101 101
      src/decition/decition_brain/decition/adc_tools/compute_00.h
  5. 154 154
      src/decition/decition_brain/decition/adc_tools/dubins.cpp
  6. 26 26
      src/decition/decition_brain/decition/adc_tools/gnss_coordinate_convert.h
  7. 45 45
      src/decition/decition_brain/decition/adc_tools/gps_distance.cpp
  8. 26 26
      src/decition/decition_brain/decition/adc_tools/gps_distance.h
  9. 138 138
      src/decition/decition_brain/decition/adc_tools/parameter_status.h
  10. 27 27
      src/decition/decition_brain/decition/adc_tools/transfer.h
  11. 1282 1281
      src/decition/decition_brain/decition/brain.cpp
  12. 166 166
      src/decition/decition_brain/decition/brain.h
  13. 1843 1843
      src/decition/decition_brain/decition/compute_00.cpp
  14. 96 96
      src/decition/decition_brain/decition/compute_00.h
  15. 605 605
      src/decition/decition_brain/decition/decide_from_gps.cpp
  16. 3616 3616
      src/decition/decition_brain/decition/decide_gps_00.cpp
  17. 249 249
      src/decition/decition_brain/decition/decide_gps_00.h
  18. 252 252
      src/decition/decition_brain/decition/decide_line_00.h
  19. 979 979
      src/decition/decition_brain/decition/decide_line_00_.cpp
  20. 62 62
      src/decition/decition_brain/decition/decition_maker.h
  21. 61 61
      src/decition/decition_brain/decition/decition_type.h
  22. 22 22
      src/decition/decition_brain/decition/decition_voter.cpp
  23. 28 28
      src/decition/decition_brain/decition/decition_voter.h
  24. 58 58
      src/decition/decition_brain/decition/fanyaapi.cpp
  25. 38 38
      src/decition/decition_brain/decition/fanyaapi.h
  26. 153 153
      src/decition/decition_brain/decition/gnss_coordinate_convert.cpp
  27. 26 26
      src/decition/decition_brain/decition/gnss_coordinate_convert.h
  28. 45 45
      src/decition/decition_brain/decition/gps_distance.cpp
  29. 26 26
      src/decition/decition_brain/decition/gps_distance.h
  30. 138 138
      src/decition/decition_brain/decition/obs_predict.cpp
  31. 27 27
      src/decition/decition_brain/decition/transfer.h

+ 21 - 19
src/decition/decition_brain/decition/adc_adapter/base_adapter.cpp

@@ -87,6 +87,7 @@ iv::decition::Decition iv::decition::HapoAdapter::getAdapterDeciton(GPS_INS now_
         if(ServiceCarStatus.torque_st==0){
             controlSpeed = (u*(-16)+((0-u)-ServiceCarStatus.mfCalAcc)*10)*0.7; //*1.0
             controlSpeed =min( controlSpeed,2.0f);
+             controlSpeed =max( controlSpeed,1.0f);
 
         }else{
             controlSpeed= ServiceCarStatus.torque_st+((0-u)-ServiceCarStatus.mfCalAcc)*20;//1115    *10
@@ -116,9 +117,9 @@ iv::decition::Decition iv::decition::HapoAdapter::getAdapterDeciton(GPS_INS now_
 
 
         if(controlSpeed>ServiceCarStatus.torque_st){
-            controlSpeed = min(ServiceCarStatus.torque_st+1.0f,controlSpeed);
+            controlSpeed = min(ServiceCarStatus.torque_st+2.0f,controlSpeed);
         }else if(controlSpeed<ServiceCarStatus.torque_st){
-            controlSpeed = ServiceCarStatus.torque_st-1.0;
+            controlSpeed = ServiceCarStatus.torque_st-1.0f;
         }
 
 
@@ -134,9 +135,9 @@ iv::decition::Decition iv::decition::HapoAdapter::getAdapterDeciton(GPS_INS now_
             controlSpeed=ServiceCarStatus.torque_st+2;
         }
 
-//        if(controlSpeed==2.0 && ServiceCarStatus.torque_st<2){
-//          controlSpeed=2.4;
-//        }
+       if(controlSpeed==2.0 && ServiceCarStatus.torque_st<2){
+          controlSpeed=2.4;
+        }
         //seizing end
 
 
@@ -146,23 +147,23 @@ iv::decition::Decition iv::decition::HapoAdapter::getAdapterDeciton(GPS_INS now_
 
         // 斜坡加大油门   0217 lsn
 
-        if(((now_gps_ins.ins_pitch_angle<-2.5 && ServiceCarStatus.daocheMode)||
-            (now_gps_ins.ins_pitch_angle>2.5 && !ServiceCarStatus.daocheMode))
-                && abs(realSpeed)<1.0){
-            controlSpeed=max((float)20.0,controlSpeed);
-            controlSpeed=min((float)40.0,controlSpeed);
-        }
+//        if(((now_gps_ins.ins_pitch_angle<-2.5 && ServiceCarStatus.daocheMode)||
+//            (now_gps_ins.ins_pitch_angle>2.5 && !ServiceCarStatus.daocheMode))
+//                && abs(realSpeed)<1.0){
+//            controlSpeed=max((float)20.0,controlSpeed);
+//            controlSpeed=min((float)40.0,controlSpeed);
+//        }
         // 斜坡加大油门  end
 
 
-        else if(((now_gps_ins.ins_pitch_angle<-2.5 && ServiceCarStatus.daocheMode)||
-                 (now_gps_ins.ins_pitch_angle>2.5 && !ServiceCarStatus.daocheMode))
-                && abs(realSpeed)<10.0){
-            controlSpeed=min((float)25.0,controlSpeed); //youmenxianxiao  30
-        }
+//        else if(((now_gps_ins.ins_pitch_angle<-2.5 && ServiceCarStatus.daocheMode)||
+//                 (now_gps_ins.ins_pitch_angle>2.5 && !ServiceCarStatus.daocheMode))
+//                && abs(realSpeed)<10.0){
+//            controlSpeed=min((float)25.0,controlSpeed); //youmenxianxiao  30
+//        }
 
     }
-
+//0125
     if(controlSpeed>0){
         controlSpeed=max(controlSpeed,2.4f);
     }
@@ -184,7 +185,7 @@ iv::decition::Decition iv::decition::HapoAdapter::getAdapterDeciton(GPS_INS now_
     controlSpeed = limitSpeed(realSpeed, controlBrake, dSpeed, controlSpeed);
 
    // (*decition)->brake = controlBrake*10;
-      (*decition)->brake = controlBrake*9;
+      (*decition)->brake = controlBrake*7;
 
     (*decition)->torque=controlSpeed;
       lastBrake= (*decition)->brake;
@@ -209,7 +210,7 @@ iv::decition::Decition iv::decition::HapoAdapter::getAdapterDeciton(GPS_INS now_
     (*decition)->angleEnable=true;
     (*decition)->speedEnable=true;
     (*decition)-> brakeEnable=true;
-    (*decition)->air_enable=true;
+    (*decition)->air_enable=false;
     (*decition)->driveMode=1;
     (*decition)->brakeType=0;
     (*decition)->angSpeed=60;
@@ -276,6 +277,7 @@ std::cout<<"========================================="<<std::endl;
 
    (*decition)->accelerator=  (*decition)->torque ;
 
+
     return *decition;
 }
 

+ 8 - 2
src/decition/decition_brain/decition/adc_adapter/qingyuan_adapter.h

@@ -66,7 +66,13 @@ float iv::decition::PIDController::getPidAngle(float realSpeed, std::vector<Poin
 
     if(ServiceCarStatus.msysparam.mvehtype=="ge3"){
         realSpeed > 40 ? PreviewDistance = max(6.0, realSpeed *0.6) : PreviewDistance = max(4.0, realSpeed *0.3);
-    }else{
+    }else if(ServiceCarStatus.msysparam.mvehtype=="hapo"){
+        if(turning){
+           realSpeed > 40 ? PreviewDistance = max(6.0, realSpeed *0.6) : PreviewDistance = max(4.0, realSpeed *0.3);
+        }else{
+          realSpeed > 40 ? PreviewDistance = max(6.0, realSpeed *0.6) : PreviewDistance = max(6.0, realSpeed *0.5);
+        }
+    } else{
         realSpeed > 40 ? PreviewDistance = max(6.0, realSpeed *0.6) : PreviewDistance = max(6.0, realSpeed *0.5);
     }
 
@@ -243,7 +249,7 @@ float iv::decition::PIDController::computeU(float obsDistance, float ds,float vs
     if (ttc>10)
     {
         double kp = 0.5;        //double kp = 0.5;
-        double kd = 0.5;       //kd = 0.03
+        double kd = 0.5;       //kd = 0.5
         //      double k11 = 0.025;
         //      double k12 = 0.000125;
         double dev = (ev - lastEv) / 0.1;

+ 2063 - 2063
src/decition/decition_brain/decition/adc_controller/pid_controller.h

@@ -1,2063 +1,2063 @@
-#include <decition/adc_tools/compute_00.h>
-#include <decition/decide_gps_00.h>
-#include <decition/adc_tools/gps_distance.h>
-#include <decition/decition_type.h>
-#include <decition/adc_tools/transfer.h>
-#include <common/constants.h>
-#include <math.h>
-#include <iostream>
-#include <fstream>
-#include <control/can.h>
-using namespace std;
-
-#define PI (3.1415926535897932384626433832795)
-
-iv::decition::Compute00::Compute00() {
-
-}
-iv::decition::Compute00::~Compute00() {
-
-}
-
-
-double iv::decition::Compute00::angleLimit = 700;
-double iv::decition::Compute00::lastEA = 0;
-double iv::decition::Compute00::lastEP = 0;
-double iv::decition::Compute00::decision_Angle = 0;
-double iv::decition::Compute00::lastAng = 0;
-int iv::decition::Compute00::lastEsrID = -1;
-int  iv::decition::Compute00::lastEsrCount = 0;
-int iv::decition::Compute00::lastEsrIDAvoid = -1;
-int  iv::decition::Compute00::lastEsrCountAvoid = 0;
-
-iv::GPS_INS  iv::decition::Compute00::nearTpoint;
-iv::GPS_INS  iv::decition::Compute00::farTpoint;
-double  iv::decition::Compute00::bocheAngle;
-
-
-
-iv::GPS_INS  iv::decition::Compute00::dTpoint0;
-iv::GPS_INS  iv::decition::Compute00::dTpoint1;
-iv::GPS_INS  iv::decition::Compute00::dTpoint2;
-iv::GPS_INS  iv::decition::Compute00::dTpoint3;
-double  iv::decition::Compute00::dBocheAngle;
-
-
-std::vector<int> lastEsrIdVector;
-std::vector<int> lastEsrCountVector;
-
-
-
-int iv::decition::Compute00::getDesiredSpeed(std::vector<GPSData> gpsMap)
-{
-    int startIndex = 0;     // startIndex = 0 则每一次都是遍历整条地图路线
-    int endIndex = gpsMap.size() - 1;
-    static double FrontTotalFive=0,FrontAveFive=0,BackAveFive=0,BackTotalFive=0;
-    static int FrontCount=0,BackCount=0;
-    static int CurrentIndex=0,MarkingIndex=0,MarkingCount=0;
-    int MarkedIndex=0,CurveContinue=0;
-
-    for (int j = startIndex; j < endIndex; j++)
-    {
-        int i = (j + gpsMap.size()) % gpsMap.size();
-        (*gpsMap[i]).roadMode=5;
-    }
-    for (int j = startIndex; j < (endIndex-10); j+=10)
-    {
-        int i = (j + gpsMap.size()) % gpsMap.size();
-        for(int front_k=i;front_k<i+5;front_k++)
-        {
-            if(fabs(((*gpsMap[front_k]).ins_heading_angle)-((*gpsMap[i]).ins_heading_angle))<10)
-            {
-                   FrontTotalFive+=(*gpsMap[front_k]).ins_heading_angle;
-                   FrontCount++;
-            }
-
-        }
-        i+=5;
-        FrontAveFive=FrontTotalFive/FrontCount;
-        FrontTotalFive=0;
-        FrontCount=0;
-        for(int back_k=i;back_k<i+5;back_k++)
-        {
-            if(fabs((*gpsMap[back_k]).ins_heading_angle-(*gpsMap[i]).ins_heading_angle)<10)
-            {
-                   BackTotalFive+=(*gpsMap[back_k]).ins_heading_angle;
-                   BackCount++;
-            }
-
-        }
-        i+=5;
-        CurrentIndex=i-1;
-        BackAveFive=BackTotalFive/BackCount;
-        BackTotalFive=0;
-        BackCount=0;
-        if(fabs(FrontAveFive-BackAveFive)<50)
-        {
-                   if(fabs(FrontAveFive-BackAveFive)>3)
-                   {
-                        CurveContinue+=1;
-                        if(CurveContinue>=2)
-                        {
-                            MarkingCount=0;
-                            for(MarkingIndex=CurrentIndex;MarkingIndex>=MarkedIndex;MarkingIndex--)
-                            {
-
-                                if(MarkingCount<100)
-                                {
-                                     if((BackAveFive-FrontAveFive)<3)
-                                     {
-                                           (*gpsMap[MarkingIndex]).roadMode=14;   //弯道,2米,14
-                                     }
-                                     else if((BackAveFive-FrontAveFive)>3)
-                                     {
-                                           (*gpsMap[MarkingIndex]).roadMode=15;
-                                     }
-
-                                }
-                                else if((MarkingCount>=100)&&(MarkingCount<150))
-                                {
-                                     (*gpsMap[MarkingIndex]).roadMode=18;   //超低速,10米,1
-                                }
-                                else if((MarkingCount>=150)&&(MarkingCount<320))
-                                {
-                                     (*gpsMap[MarkingIndex]).roadMode=5;   //低速,20米,5
-                                }
-                                else if((MarkingCount>=320)&&(MarkingCount<620))
-                                {
-                                     (*gpsMap[MarkingIndex]).roadMode=0;   //常速,60米
-                                }
-                                else if(MarkingCount>=620)
-                                {
-                                     (*gpsMap[MarkingIndex]).roadMode=11;   //高速/疯狂加速,大于60米
-                                }
-
-                                MarkingCount++;
-                            }
-                            MarkedIndex=CurrentIndex;
-                        }
-                   }
-                   else if(fabs(FrontAveFive-BackAveFive)<=3)
-                   {
-                        CurveContinue=0;
-                   }
-        }
-        FrontAveFive=0;
-        BackAveFive=0;
-    }
-
-    if(MarkedIndex<endIndex)
-    {
-        MarkingCount=0;
-        for(MarkingIndex=endIndex;MarkingIndex>=MarkedIndex;MarkingIndex--)
-        {
-
-            if(MarkingCount<100)
-            {
-                if((BackAveFive-FrontAveFive)<3)
-                {
-                      (*gpsMap[MarkingIndex]).roadMode=14;   //弯道,2米,14
-                }
-                else if((BackAveFive-FrontAveFive)>3)
-                {
-                      (*gpsMap[MarkingIndex]).roadMode=15;
-                }
-            }
-            else if((MarkingCount>=100)&&(MarkingCount<150))
-            {
-                 (*gpsMap[MarkingIndex]).roadMode=18;   //超低速,10米
-            }
-            else if((MarkingCount>=150)&&(MarkingCount<320))
-            {
-                 (*gpsMap[MarkingIndex]).roadMode=5;   //低速,30米
-            }
-            else if((MarkingCount>=320)&&(MarkingCount<620))
-            {
-                 (*gpsMap[MarkingIndex]).roadMode=0;   //常速,60米
-            }
-            else if(MarkingCount>=620)
-            {
-                 (*gpsMap[MarkingIndex]).roadMode=11;   //高速/疯狂加速,大于60米
-            }
-
-            MarkingCount++;
-        }
-    }
-
-
-    return 1;
-}
-
-
-
-//首次找点
-
-int iv::decition::Compute00::getFirstNearestPointIndex(GPS_INS rp, std::vector<GPSData> gpsMap, int lastIndex, double mindis, double maxAngle)
-{
-    int index = -1;
-    //	DecideGps00().minDis = iv::MaxValue;
-    float minDis = 10;
-    double maxAng = iv::MaxValue;
-
-    int startIndex = 0;     // startIndex = 0 则每一次都是遍历整条地图路线
-    int endIndex = gpsMap.size() - 1;
-
-    for (int j = startIndex; j < endIndex; j++)
-    {
-        int i = (j + gpsMap.size()) % gpsMap.size();
-        double tmpdis = GetDistance(rp, (*gpsMap[i]));
-
-        if (tmpdis < minDis && (abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle) < 80
-                                              || abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle - 360) < 80
-                                              || abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle + 360) < 80)
-                )
-        {
-            index = i;
-            minDis = tmpdis;
-            maxAng = min(abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle), abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle - 360));
-            maxAng = min(maxAng, abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle + 360));
-        }
-    }
-
-    DecideGps00().maxAngle=maxAng;
-    DecideGps00().minDis=minDis;
-    return index;
-}
-
-//search pathpoint
-int iv::decition::Compute00::getNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap, int lastIndex, double mindis, double maxAngle)
-{
-    int index = -1;
-    float minDis = 10;
-    double maxAng = iv::MaxValue;
-    int map_size=gpsMap.size();
-    int preDistance=max(100,(int)(rp.speed*10));
-        preDistance=min(500,preDistance);
-
-    int startIndex = max((int)(lastIndex - 100),(int)(lastIndex-map_size));     // startIndex = 0 则每一次都是遍历整条地图路线
-    int endIndex = min((int)(lastIndex + preDistance ),(int)(lastIndex+map_size));
-
-
-    for (int j = startIndex; j < endIndex; j++)
-    {
-        int i = (j + map_size) % map_size;
-        double tmpdis = GetDistance(rp, (*gpsMap[i]));
-
-        if (tmpdis < minDis && (abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle) < 80
-            || abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle - 360) < 80
-            || abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle + 360) < 80)
-            )
-        {
-            index = i;
-            minDis = tmpdis;
-            maxAng = min(abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle), abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle - 360));
-            maxAng = min(maxAngle, abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle + 360));
-        }
-    }
-
-
-    DecideGps00().maxAngle=maxAng;
-    DecideGps00().minDis=minDis;
-    return index;
-}
-
-
-double iv::decition::Compute00::getAveDef(std::vector<Point2D> farTrace)
-{
-    double sum_x = 0;
-    double sum_y = 0;
-
-    for (int i = 0; i < min(5, (int)farTrace.size()); i++)
-    {
-        sum_x += farTrace[i].x;
-        sum_y += abs(farTrace[i].y);
-    }
-    double average_y = sum_y / min(5, (int)farTrace.size());
-    double average_x = sum_x / min(5, (int)farTrace.size());
-
-
-    return atan(average_x / average_y) / PI * 180;
-}
-
-
-
-double iv::decition::Compute00::getAvoidAveDef(std::vector<Point2D> farTrace, double avoidX)
-{
-    double sum_x = 0;
-    double sum_y = 0;
-
-    for (int i = 0; i < min(5, (int)farTrace.size()); i++)
-    {
-        sum_x += farTrace[i].x;
-        sum_y += abs(farTrace[i].y);
-    }
-    double average_y = sum_y / min(5, (int)farTrace.size());
-    double average_x = sum_x / min(5, (int)farTrace.size());
-
-
-    return atan(average_x + avoidX / average_y) / PI * 180;
-}
-
-
-
-
-
-
-double iv::decition::Compute00::getDecideAngle(std::vector<Point2D>  gpsTrace, double realSpeed) {
-
-    double ang = 0;
-    double EPos = 0, EAng = 0;
-
-    //   double KEang = 14, KEPos = 10, DEang = 3, DEPos = 1;  // double KEang = 14, KEPos = 10, DEang = 10, DEPos = 10;
-    double KEang = 14, KEPos = 10, DEang = 0, DEPos = 0;
-
-    if(transferPieriod&& !transferPieriod2){
-        DEang = 200;
-        DEPos = 150;
-    }
-
-    //   double PreviewDistance = max(6.0, realSpeed / 3.6 * 1.8);//预瞄距离
-
-    double PreviewDistance;//预瞄距离
-    realSpeed > 40 ? PreviewDistance = max(6.0, realSpeed *0.6) : PreviewDistance = max(6.0, realSpeed *0.5);
-    if(changeRoad ||transferPieriod){
-        PreviewDistance=PreviewDistance+avoidX;
-    }
-    if(realSpeed <15){
-        PreviewDistance = max(4.0, realSpeed *0.4) ;
-    }
-
-    if (gpsTrace[0].v1 == 1)
-    {
-        KEang = 14; KEPos = 10;
-    }
-    else if (gpsTrace[0].v1 == 2 || gpsTrace[0].v1 == 3)
-    {
-        KEang = 14; KEPos = 10;
-    }
-    else if (gpsTrace[0].v1 == 4 || gpsTrace[0].v1 == 5)
-    {
-        KEang = 14; KEPos = 10;
-    }
-    else if (gpsTrace[0].v1 == 7 && (gpsTrace[0].v2 == 23 || gpsTrace[0].v2 == 24))
-    {
-        KEang = 18; KEPos = 50; PreviewDistance = 3;
-    }
-    else if (gpsTrace[0].v1 == 7)
-    {
-        KEang = 20; KEPos = 50; PreviewDistance = 4;
-    }
-
-
-    if (realSpeed > 40)	KEang = 10; KEPos = 8;
-    if (realSpeed > 50) KEang = 5;
-
-    double sumdis = 0;
-    int gpsIndex = 0;
-    std::vector<Point2D> farTrace;
-
-
-
-
-
-
-    for (int i = 1; i < gpsTrace.size() - 1; i++)
-    {
-        sumdis += GetDistance(gpsTrace[i - 1], gpsTrace[i]);
-        if (sumdis > PreviewDistance)
-        {
-            gpsIndex = i;
-            break;
-        }
-    }
-
-
-
-
-    EPos = gpsTrace[gpsIndex].x;
-
-    for (unsigned int i = max(0, gpsIndex - 3); i < min((size_t)(gpsIndex + 3), gpsTrace.size()); i++) {
-        farTrace.push_back(gpsTrace[gpsIndex]);
-    }
-    if (farTrace.size() == 0) {
-        EAng = 0;
-    }
-    else {
-        EAng = getAveDef(farTrace);
-    }
-
-    ang = KEang * EAng + KEPos * EPos + DEang * (EAng - lastEA) + DEPos * (EPos - lastEP);
-
-    lastEA = EAng;
-    lastEP = EPos;
-
-    if (ang > angleLimit) {
-        ang = angleLimit;
-    }
-    else if (ang < -angleLimit) {
-        ang = -angleLimit;
-    }
-    if (lastAng != iv::MaxValue) {
-        ang = 0.2 * lastAng + 0.8 * ang;
-        //ODS("lastAng:%d\n", lastAng);
-    }
-    lastAng = ang;
-    return ang;
-}
-
-
-
-
-int  iv::decition::Compute00::getSpeedPointIndex(std::vector<Point2D> gpsTrace, double realSpeed)
-{
-    int index = 1;
-    double sumdis = 0;
-    while (index < gpsTrace.size() && sumdis < realSpeed)
-        sumdis += GetDistance(gpsTrace[index - 1], gpsTrace[index++]);
-
-    if (index == gpsTrace.size())
-        return index - 1;
-
-    if (abs(sumdis - realSpeed) > abs(sumdis - GetDistance(gpsTrace[index - 1], gpsTrace[index]) - realSpeed))
-        index--;
-    return index;
-}
-
-iv::Point2D iv::decition::Compute00::getLidarObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
-
-    iv::Point2D obsPoint(-1, -1);
-    vector<Point2D> gpsTraceLeft;
-    vector<Point2D> gpsTraceRight;
-    float xiuzheng=0;
-    if(!ServiceCarStatus.useMobileEye){
-        xiuzheng=0-ServiceCarStatus.msysparam.lidarGpsXiuzheng;
-    }
-
-
-    for (int j = 0; j < gpsTrace.size(); j++)
-    {
-        double sumx1 = 0, sumy1 = 0, count1 = 0;
-        double sumx2 = 0, sumy2 = 0, count2 = 0;
-        for (int k = max(0, j - 4); k <= j; k++)
-        {
-            count1 = count1 + 1;
-            sumx1 += gpsTrace[k].x;
-            sumy1 += gpsTrace[k].y;
-        }
-        for (unsigned int k = j; k <= min(gpsTrace.size() - 1, (size_t)(j + 4)); k++)
-        {
-            count2 = count2 + 1;
-            sumx2 += gpsTrace[k].x;
-            sumy2 += gpsTrace[k].y;
-        }
-        sumx1 /= count1; sumy1 /= count1;
-        sumx2 /= count2; sumy2 /= count2;
-
-        double anglevalue = atan2(sumy2 - sumy1, sumx2 - sumx1);
-
-        double carFrontx = gpsTrace[j].x;// -Form1.CarRear * Math.Cos(anglevalue);
-        double carFronty = gpsTrace[j].y;// -Form1.CarRear * Math.Sin(anglevalue);
-
-        Point2D ptLeft(carFrontx + Veh_Width / 2 * cos(anglevalue + PI / 2),
-                       carFronty + Veh_Width / 2 * sin(anglevalue + PI / 2));
-
-        Point2D ptRight(carFrontx + Veh_Width / 2 * cos(anglevalue - PI / 2),
-                        carFronty + Veh_Width / 2 * sin(anglevalue - PI / 2));
-
-        gpsTraceLeft.push_back(ptLeft);
-        gpsTraceRight.push_back(ptRight);
-
-    }
-
-
-    bool isRemove = false;
-
-    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
-    {
-
-        if (!isRemove && gpsTrace[j].y>ServiceCarStatus.msysparam.lidarGpsXiuzheng)
-        {
-            int count = 0;
-
-            for (double length = 0; length <= Veh_Width; length += 0.4)
-            {
-                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
-                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
-
-                //				int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;  //+(ptx / abs(ptx))) / 2左右多出一半的车宽(1米)
-                //				int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
-                int dx = (ptx + gridwide*(double)centerx)/gridwide;
-                int dy = (pty + gridwide*(double)centery+xiuzheng)/gridwide;
-
-                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
-                {
-                    //					if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
-                    if (lidarGridPtr[dx * (iv::gry) + dy].ob != 0)
-                    {
-                        count++; obsPoint.x = ptx; obsPoint.y = pty;
-                    }
-                }
-            }
-
-            j++;
-
-            for (double length = 0; length <= Veh_Width; length += 0.4)
-            {
-                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
-                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
-
-                //				int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;
-                //				int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
-                int dx = (ptx + gridwide*(double)centerx)/gridwide;
-                int dy = (pty + gridwide*(double)centery+xiuzheng)/gridwide;
-
-                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
-                {
-                    //					if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
-                    if (lidarGridPtr[dx * (iv::gry) + dy].ob != 0)
-                    {
-                        count++; obsPoint.x = ptx; obsPoint.y = pty;
-                    }
-                }
-            }
-
-            if (count >= 2)
-            {
-                obsPoint.x = gpsTrace[j].x;
-                obsPoint.y = gpsTrace[j].y;
-
-                isRemove = true;
-                //		DecideGps00().lidarDistance = obsPoint.y;
-                return obsPoint;
-            }
-        }
-    }
-    //	DecideGps00().lidarDistance = obsPoint.y;
-    return obsPoint;
-}
-
-//1220
-iv::Point2D iv::decition::Compute00::getLidarRearObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
-
-    iv::Point2D obsPoint(-1, -1);
-    vector<Point2D> gpsTraceLeft;
-    vector<Point2D> gpsTraceRight;
-    float xiuzheng=0;
-    if(!ServiceCarStatus.useMobileEye){
-        xiuzheng=0-ServiceCarStatus.msysparam.rearLidarGpsXiuzheng;
-    }
-    for (int j = 0; j < gpsTrace.size(); j++)
-    {
-        double sumx1 = 0, sumy1 = 0, count1 = 0;
-        double sumx2 = 0, sumy2 = 0, count2 = 0;
-        for (int k = max(0, j - 4); k <= j; k++)
-        {
-            count1 = count1 + 1;
-            sumx1 += gpsTrace[k].x;
-            sumy1 += gpsTrace[k].y;
-        }
-        for (unsigned int k = j; k <= min(gpsTrace.size() - 1, (size_t)(j + 4)); k++)
-        {
-            count2 = count2 + 1;
-            sumx2 += gpsTrace[k].x;
-            sumy2 += gpsTrace[k].y;
-        }
-        sumx1 /= count1; sumy1 /= count1;
-        sumx2 /= count2; sumy2 /= count2;
-
-        double anglevalue = atan2(sumy2 - sumy1, sumx2 - sumx1);
-
-        double carFrontx = gpsTrace[j].x;// -Form1.CarRear * Math.Cos(anglevalue);
-        double carFronty = gpsTrace[j].y;// -Form1.CarRear * Math.Sin(anglevalue);
-
-        Point2D ptLeft(carFrontx + (Veh_Width-0.3) / 2 * cos(anglevalue + PI / 2),
-                       carFronty + (Veh_Width-0.3) / 2 * sin(anglevalue + PI / 2));
-
-        Point2D ptRight(carFrontx + (Veh_Width-0.3) / 2 * cos(anglevalue - PI / 2),
-                        carFronty + (Veh_Width-0.3) / 2 * sin(anglevalue - PI / 2));
-
-        gpsTraceLeft.push_back(ptLeft);
-        gpsTraceRight.push_back(ptRight);
-
-    }
-
-
-    bool isRemove = false;
-
-    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
-    {
-
-        if (!isRemove && gpsTrace[j].y<(0-ServiceCarStatus.msysparam.rearGpsXiuzheng) )
-        {
-            int count = 0;
-
-            for (double length = 0; length <= Veh_Width; length += 0.4)
-            {
-                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
-                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
-
-                //				int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;  //+(ptx / abs(ptx))) / 2左右多出一半的车宽(1米)
-                //				int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
-                int dx = (ptx + gridwide*(double)centerx)/gridwide;
-
-                dx=grx-dx;//1227
-
-                int dy = (pty + gridwide*(double)centery+xiuzheng)/gridwide;
-
-                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
-                {
-                    //					if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
-                    if (lidarGridPtr[dx * (iv::gry) + dy].ob != 0)
-                    {
-                        count++; obsPoint.x = ptx; obsPoint.y = pty;
-                    }
-                }
-            }
-
-            j++;
-
-            for (double length = 0; length <= Veh_Width; length += 0.4)
-            {
-                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
-                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
-
-                //				int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;
-                //				int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
-                int dx = (ptx + gridwide*(double)centerx)/gridwide;
-
-                dx=grx-dx;//1227
-                int dy = (pty + gridwide*(double)centery+xiuzheng)/gridwide;
-
-                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
-                {
-                    //					if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
-                    if (lidarGridPtr[dx * (iv::gry) + dy].ob != 0)
-                    {
-                        count++; obsPoint.x = ptx; obsPoint.y = pty;
-                    }
-                }
-            }
-
-            if (count >= 2)
-            {
-                obsPoint.x = gpsTrace[j].x;
-                obsPoint.y = gpsTrace[j].y;
-
-                isRemove = true;
-                //		DecideGps00().lidarDistance = obsPoint.y;
-                return obsPoint;
-            }
-        }
-    }
-    //	DecideGps00().lidarDistance = obsPoint.y;
-    return obsPoint;
-}
-
-
-iv::Point2D iv::decition::Compute00::getLidarObsPointAvoid(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
-
-    iv::Point2D obsPoint(-1, -1);
-    vector<Point2D> gpsTraceLeft;
-    vector<Point2D> gpsTraceRight;
-    for (int j = 0; j < gpsTrace.size(); j++)
-    {
-        double sumx1 = 0, sumy1 = 0, count1 = 0;
-        double sumx2 = 0, sumy2 = 0, count2 = 0;
-        for (int k = max(0, j - 4); k <= j; k++)
-        {
-            count1 = count1 + 1;
-            sumx1 += gpsTrace[k].x;
-            sumy1 += gpsTrace[k].y;
-        }
-        for (unsigned int k = j; k <= min(gpsTrace.size() - 1, (size_t)(j + 4)); k++)
-        {
-            count2 = count2 + 1;
-            sumx2 += gpsTrace[k].x;
-            sumy2 += gpsTrace[k].y;
-        }
-        sumx1 /= count1; sumy1 /= count1;
-        sumx2 /= count2; sumy2 /= count2;
-
-        double anglevalue = atan2(sumy2 - sumy1, sumx2 - sumx1);
-
-        double carFrontx = gpsTrace[j].x;// -Form1.CarRear * Math.Cos(anglevalue);
-        double carFronty = gpsTrace[j].y;// -Form1.CarRear * Math.Sin(anglevalue);
-
-        //1127 fanwei xiuzheng
-        float buchang=0;
-        Point2D ptLeft(carFrontx + (Veh_Width+(buchang)*2) / 2 * cos(anglevalue + PI / 2),
-                       carFronty +  (Veh_Width+(buchang)*2) / 2 * sin(anglevalue + PI / 2));
-
-        Point2D ptRight(carFrontx +  (Veh_Width+(buchang)*2) / 2 * cos(anglevalue - PI / 2),
-                        carFronty +  (Veh_Width+(buchang)*2) / 2 * sin(anglevalue - PI / 2));
-
-        gpsTraceLeft.push_back(ptLeft);
-        gpsTraceRight.push_back(ptRight);
-
-    }
-
-
-    bool isRemove = false;
-
-    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
-    {
-
-        if (!isRemove && gpsTrace[j].y>2.5 && gpsTraceLeft[j].y>2.5 && gpsTraceRight[j].y>2.5)
-        {
-            int count = 0;
-
-            for (double length = 0; length <= Veh_Width; length += 0.4)
-            {
-                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
-                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
-
-                int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;  //*2左右多出一半的车宽(1米)
-                int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
-
-                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
-                {
-                    if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
-                    {
-                        count++; obsPoint.x = ptx; obsPoint.y = pty;
-                    }
-                }
-            }
-
-            j++;
-
-            for (double length = 0; length <= Veh_Width; length += 0.4)
-            {
-                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
-                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
-
-                int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;
-                int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
-
-                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
-                {
-                    if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
-                    {
-                        count++; obsPoint.x = ptx; obsPoint.y = pty;
-                    }
-                }
-            }
-
-            if (count >= 2)
-            {
-                obsPoint.x = gpsTrace[j].x;
-                obsPoint.y = gpsTrace[j].y;
-
-                isRemove = true;
-                DecideGps00().lidarDistanceAvoid = obsPoint.y;
-                return obsPoint;
-            }
-        }
-    }
-    //	DecideGps00().lidarDistanceAvoid = obsPoint.y;
-
-    return obsPoint;
-}
-
-
-
-
-//int  iv::decition::Compute00::getEsrIndex(std::vector<Point2D> gpsTrace, std::vector<ObstacleBasic> esrRadars) {
-//	bool isRemove = false;
-//
-//	for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
-//	{
-//
-//		for (int i = 0; i < esrRadars.size(); i++)
-//			if ((esrRadars[i].nomal_y) != 0)
-//			{
-//				double xxx = esrRadars[i].nomal_x + Esr_Offset;
-//				double yyy = esrRadars[i].nomal_y;
-//
-//				if (abs(xxx - gpsTrace[j].x) <= 3.0*Veh_Width / 4.0 && abs(yyy - (gpsTrace[j].y)) <= 1)
-//				{
-//
-//					if (lastEsrID == (esrRadars[i]).esr_ID)
-//					{
-//						lastEsrCount++;
-//					}
-//					else
-//					{
-//						lastEsrCount = 0;
-//					}
-//
-//					if (lastEsrCount >= 3)
-//					{
-//						return i;
-//					}
-//
-//					lastEsrID = (esrRadars[i]).esr_ID;
-//				}
-//			}
-//	}
-//	return -1;
-//}
-
-
-
-
-int  iv::decition::Compute00::getEsrIndex(std::vector<Point2D> gpsTrace,int roadNum,int *esrPathpoint) {
-    bool isRemove = false;
-
-    float xiuzheng=0;
-    if(!ServiceCarStatus.useMobileEye){
-        xiuzheng=ServiceCarStatus.msysparam.radarGpsXiuzheng;
-    }
-
-    float fxiuzhengCs = DecideGps00().xiuzhengCs;
-    int nsize = gpsTrace.size();
-    for (int j = 1; j < nsize - 1 && !isRemove; j++)
-    {
-
-        for (int i = 0; i < 64; i++)
-            if ((ServiceCarStatus.obs_radar[i].nomal_y) != 0 && (ServiceCarStatus.obs_radar[i].valid))
-            {
-                double xxx = ServiceCarStatus.obs_radar[i].nomal_x + Esr_Offset;
-                double yyy = ServiceCarStatus.obs_radar[i].nomal_y+ xiuzheng;
-
-                /*ODS("\nESR毫米波检测物体X距离:%f\n", xxx);
-                ODS("\nESR毫米波检测物体Y距离:%f\n", yyy);*/
-
-//优化
-//                if(sqrt((xxx - gpsTrace[j].x)*(xxx - gpsTrace[j].x) + (yyy - gpsTrace[j].y)*(yyy - gpsTrace[j].y)) < (1.0*Veh_Width / 2.0+DecideGps00().xiuzhengCs)){
-//                    *esrPathpoint = j;
-//                    return i;
-//                }
-
-
-                if (abs(xxx - gpsTrace[j].x) <= (3.0*Veh_Width / 4.0+fxiuzhengCs) && abs(yyy - (gpsTrace[j].y)) <= 1)
-                {
-
-                    if (lastEsrID == i)
-                    {
-                        lastEsrCount++;
-                    }
-                    else
-                    {
-                        lastEsrCount = 0;
-                    }
-
-                    if(yyy>50 ){
-                        if (lastEsrCount >=200)
-                        {
-                            return i;
-                        }
-                    }
-                    else if (lastEsrCount >= 1)
-                    {
-                        return i;
-                    }
-
-                    lastEsrID = i;
-                }
-            }
-    }
-    return -1;
-}
-
-
-
-
-int  iv::decition::Compute00::getRearEsrIndex(std::vector<Point2D> gpsTrace,int roadNum) {
-    bool isRemove = false;
-
-    float xiuzheng = ServiceCarStatus.msysparam.rearRadarGpsXiuzheng;
-    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
-    {
-
-        for (int i = 0; i < 64; i++)
-            if ((ServiceCarStatus.obs_rear_radar[i].nomal_y) != 0 && (ServiceCarStatus.obs_rear_radar[i].valid))
-            {
-                double xxx = 0-(ServiceCarStatus.obs_rear_radar[i].nomal_x + Esr_Offset);
-                double yyy = 0-(ServiceCarStatus.obs_rear_radar[i].nomal_y+ xiuzheng);
-
-                if(ServiceCarStatus.msysparam.mvehtype=="qingyuan"){
-                    xxx=0-xxx;
-                }
-
-                /*ODS("\nESR毫米波检测物体X距离:%f\n", xxx);
-                ODS("\nESR毫米波检测物体Y距离:%f\n", yyy);*/
-
-
-                if (abs(xxx - gpsTrace[j].x) <= (3.0*Veh_Width / 4.0+DecideGps00().xiuzhengCs) && abs(yyy - (gpsTrace[j].y)) <= 1)
-                {
-
-                    if (lastEsrID == i)
-                    {
-                        lastEsrCount++;
-                    }
-                    else
-                    {
-                        lastEsrCount = 0;
-                    }
-
-                    if(yyy>50 ){
-                        if (lastEsrCount >=200)
-                        {
-                            return i;
-                        }
-                    }
-                    else if (lastEsrCount >= 1)
-                    {
-                        return i;
-                    }
-
-                    lastEsrID = i;
-                }
-            }
-    }
-    return -1;
-}
-
-
-
-
-
-//int  iv::decition::Compute00::getEsrIndex(std::vector<Point2D> gpsTrace,int roadNum) {
-//    bool isRemove = false;
-
-//    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
-//    {
-
-//        for (int i = 0; i < 64; i++)
-//            if ((examed_obs_radar[i].nomal_y) != 0 && (examed_obs_radar[i].valid))
-//            {
-//                double xxx = examed_obs_radar[i].nomal_x + Esr_Offset;
-//                double yyy = examed_obs_radar[i].nomal_y+ Esr_Y_Offset;
-
-//                /*ODS("\nESR毫米波检测物体X距离:%f\n", xxx);
-//                ODS("\nESR毫米波检测物体Y距离:%f\n", yyy);*/
-
-
-//                if (abs(xxx - gpsTrace[j].x) <= 3.0*Veh_Width / 4.0 && abs(yyy - (gpsTrace[j].y)) <= 1)
-//                {
-
-//                    if (lastEsrID == i)
-//                    {
-//                        lastEsrCount++;
-//                    }
-//                    else
-//                    {
-//                        lastEsrCount = 0;
-//                    }
-
-//                    if(yyy>50 ){
-//                        if (lastEsrCount >=200)
-//                        {
-//                            return i;
-//                        }
-//                    }
-//                    else if (lastEsrCount >= 3)
-//                    {
-//                        return i;
-//                    }
-
-//                    lastEsrID = i;
-//                }
-//            }
-//    }
-//    return -1;
-//}
-
-
-
-int  iv::decition::Compute00::getEsrIndexAvoid(std::vector<Point2D> gpsTrace) {
-    bool isRemove = false;
-
-    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
-    {
-
-        for (int i = 0; i < 64; i++)
-            if ((ServiceCarStatus.obs_radar[i].nomal_y) != 0 && (ServiceCarStatus.obs_radar[i].valid))
-            {
-                double xxx = ServiceCarStatus.obs_radar[i].nomal_x + Esr_Offset;
-                double yyy = ServiceCarStatus.obs_radar[i].nomal_y;
-
-                if (abs(xxx - gpsTrace[j].x) <= 3.0*Veh_Width / 4.0 && abs(yyy - (gpsTrace[j].y)) <= 1)
-                {
-
-                    if (lastEsrIDAvoid == i)
-                    {
-                        lastEsrCountAvoid++;
-                    }
-                    else
-                    {
-                        lastEsrCountAvoid = 0;
-                    }
-
-                    if (lastEsrCountAvoid >= 6)
-                    {
-                        return i;
-                    }
-
-                    lastEsrIDAvoid = i;
-                }
-            }
-    }
-    return -1;
-}
-
-
-
-
-
-
-
-//double iv::decition::Compute00::getObsSpeed(Point2D obsPoint, std::vector<ObstacleBasic> esrRadars,double realSecSpeed) {
-//	double obsSpeed = 0 - realSecSpeed;
-//	double minDis = iv::MaxValue;
-//	for (int i = 0; i < esrRadars.size(); i++)
-//		if ((esrRadars[i].nomal_y) != 0)
-//		{
-//			double xxx = esrRadars[i].nomal_x + Esr_Offset;
-//			double yyy = esrRadars[i].nomal_y;
-//
-//			if (abs(xxx - obsPoint.x) < 4 && abs(yyy - obsPoint.y) < 2)
-//			{
-//				double tmpDis =sqrt((xxx - obsPoint.x) * (xxx - obsPoint.x) + (yyy - obsPoint.y) * (yyy - obsPoint.y));
-//				if (tmpDis < minDis)
-//				{
-//					minDis = tmpDis;
-//					obsSpeed = esrRadars[i].speed_y;
-//				}
-//			}
-//		}
-//
-//	return obsSpeed;
-//
-//
-//}
-
-
-
-
-double iv::decition::Compute00::getObsSpeed(Point2D obsPoint, double realSecSpeed) {
-    double obsSpeed = 0 - realSecSpeed;
-    double minDis = iv::MaxValue;
-    for (int i = 0; i < 64; i++)
-        if ((ServiceCarStatus.obs_radar[i].nomal_y) != 0 && ServiceCarStatus.obs_radar[i].valid)
-        {
-            double xxx = ServiceCarStatus.obs_radar[i].nomal_x + Esr_Offset;
-            double yyy = ServiceCarStatus.obs_radar[i].nomal_y + Esr_Y_Offset;
-
-            if (abs(xxx - obsPoint.x) < 4 && abs(yyy - obsPoint.y) < 2)
-            {
-                double tmpDis = sqrt((xxx - obsPoint.x) * (xxx - obsPoint.x) + (yyy - obsPoint.y) * (yyy - obsPoint.y));
-                if (tmpDis < minDis)
-                {
-                    minDis = tmpDis;
-                    obsSpeed = ServiceCarStatus.obs_radar[i].speed_y;
-                }
-            }
-        }
-
-    return obsSpeed;
-}
-
-
-
-
-double iv::decition::Compute00::getDecideAvoidAngle(std::vector<Point2D>  gpsTrace, double realSpeed, float avoidX) {
-
-    double ang = 0;
-    double EPos = 0, EAng = 0;
-
-    double KEang = 14, KEPos = 10, DEang = 0, DEPos = 0;
-
-    double PreviewDistance = max(6.0, realSpeed / 3.6 * 1.8);//预瞄距离
-
-
-    if (gpsTrace[0].v1 == 1)
-    {
-        KEang = 10; KEPos = 8;
-        if (realSpeed > 60) KEang = 5;
-    }
-    else if (gpsTrace[0].v1 == 2 || gpsTrace[0].v1 == 3)
-    {
-        KEang = 14; KEPos = 10;
-    }
-    else if (gpsTrace[0].v1 == 4 || gpsTrace[0].v1 == 5)
-    {
-        KEang = 14; KEPos = 10;
-    }
-    else if (gpsTrace[0].v1 == 7 && (gpsTrace[0].v2 == 23 || gpsTrace[0].v2 == 24))
-    {
-        KEang = 18; KEPos = 50; PreviewDistance = 3;
-    }
-    else if (gpsTrace[0].v1 == 7)
-    {
-        KEang = 20; KEPos = 50; PreviewDistance = 4;
-    }
-
-
-    double sumdis = 0;
-    int gpsIndex = 0;
-    std::vector<Point2D> farTrace;
-
-
-
-
-
-
-    for (int i = 1; i < gpsTrace.size() - 1; i++)
-    {
-        sumdis += GetDistance(gpsTrace[i - 1], gpsTrace[i]);
-        if (sumdis > PreviewDistance)
-        {
-            gpsIndex = i;
-            break;
-        }
-    }
-
-    if ((DecideGps00().readyParkMode) && (gpsIndex + 10>DecideGps00().gpsLineParkIndex))
-    {
-        gpsIndex = DecideGps00().gpsLineParkIndex;
-    }
-
-
-
-    EPos = gpsTrace[gpsIndex].x + avoidX;
-
-    for (unsigned int i = max(0, gpsIndex - 3); i < min((size_t)(gpsIndex + 3), gpsTrace.size()); i++) {
-        farTrace.push_back(gpsTrace[gpsIndex]);
-    }
-    if (farTrace.size() == 0) {
-        EAng = 0;
-    }
-    else {
-        EAng = getAvoidAveDef(farTrace, avoidX);
-    }
-
-    ang = KEang * EAng + KEPos * EPos + DEang * (EAng - lastEA) + DEPos * (EPos - lastEP);
-
-    lastEA = EAng;
-    lastEP = EPos;
-
-    if (ang > angleLimit) {
-        ang = angleLimit;
-    }
-    else if (ang < -angleLimit) {
-        ang = -angleLimit;
-    }
-    if (lastAng != iv::MaxValue) {
-        ang = 0.2 * lastAng + 0.8 * ang;
-        //ODS("lastAng:%d\n", lastAng);
-    }
-    lastAng = ang;
-
-    return ang;
-}
-
-
-std::vector<iv::GPSData>   iv::decition::Compute00::getBesideGpsMapLine(iv::GPS_INS now_gps_ins, vector<iv::GPSData>gpsMapLine, float avoidX) {
-
-    vector<vector<iv::GPSData>> maps;
-    vector<iv::GPSData> gpsMapLineBeside;
-    int sizeN = gpsMapLine.size();
-    for (int i = 1; i < sizeN; i++)
-    {
-        iv::GPSData gpsData(new GPS_INS);
-        double xx = gpsMapLine[i]->gps_x - now_gps_ins.gps_x;
-        double yy = gpsMapLine[i]->gps_y - now_gps_ins.gps_y;
-        double lng = ServiceCarStatus.location->ins_heading_angle;
-
-
-        double x0 = xx * cos(lng * PI / 180) - yy * sin(lng * PI / 180);
-        double y0 = xx * sin(lng * PI / 180) + yy * cos(lng * PI / 180);
-        double k1 = sin((90 + (gpsMapLine[i]->ins_heading_angle - lng)) * PI / 180);
-        double k2 = cos((90 + (gpsMapLine[i]->ins_heading_angle - lng)) * PI / 180);
-
-        //	memcpy(&gpsData, &gpsMapLine[i], sizeof(gpsData));
-
-        gpsData->speed_mode = gpsMapLine[i]->speed_mode;
-        gpsData->gps_x = x0 + k1 * avoidX;
-        gpsData->gps_y = y0 + k2 * avoidX;
-        gpsMapLineBeside.push_back(gpsData);
-
-    }
-    return gpsMapLineBeside;
-
-}
-
-
-
-//double iv::decition::Compute00::getDecideAngleByLane(double realSpeed) {
-
-//    double ang = 0;
-//    double EPos = 0, EAng = 0;
-
-// //   double KEang = 14, KEpos = 10, DEang = 0, DEpos = 0;
-//       double KEang = 5, KEPos = 30, DEang = 0, DEPos = 0;
-
-// //   double PreviewDistance = max(6.0, realSpeed / 3.6 * 1.8);//预瞄距离
-
-//    double PreviewDistance;//预瞄距离
-//    realSpeed > 40 ? PreviewDistance = max(6.0, realSpeed *0.6) : PreviewDistance = max(6.0, realSpeed *0.5);
-
-
-
-
-
-////    if (realSpeed > 40)	KEang = 10; KEpos = 8;
-////        if (realSpeed > 50) KEang = 5;
-
-
-
-
-
-//double c1 = ServiceCarStatus.aftermarketLane.dist_to_lane_l;
-//double c2 = ServiceCarStatus.aftermarketLane.dist_to_lane_r;
-//double a = ServiceCarStatus.Lane.curvature;
-//double b = ServiceCarStatus.Lane.heading;
-//double c = (c1+c2)*0.5;
-//double x= PreviewDistance;
-//double y;
-
-
-//y=a*x*x+b*x+c;
-
-//   // EPos = y;
-//EPos=c;
-
-
-//  //  EAng=atan(2*a*x+b) / PI * 180;
-//    EAng=ServiceCarStatus.Lane.yaw;
-//        ang = KEang * EAng + KEPos * EPos + DEang * (EAng - lastEA) + DEPos * (EPos - lastEP);
-
-//        lastEA = EAng;
-//        lastEP = EPos;
-
-
-//           std::cout << "\nEPos:%f\n" << EPos << std::endl;
-//            std::cout << "\nEAng:%f\n" << EAng << std::endl;
-
-
-//        if (ang > angleLimit) {
-//            ang = angleLimit;
-//        }
-//        else if (ang < -angleLimit) {
-//            ang = -angleLimit;
-//        }
-//        if (lastAng != iv::MaxValue) {
-//            ang = 0.2 * lastAng + 0.8 * ang;
-//            //ODS("lastAng:%d\n", lastAng);
-//        }
-//        lastAng = ang;
-//        return ang;
-//    }
-
-
-
-double IEPos = 0, IEang = 0;
-
-
-double iv::decition::Compute00::getDecideAngleByLanePID(double realSpeed) {
-
-    double ang = 0;
-    double EPos = 0, EAng = 0;
-    double Curve=0;
-    double KEang = 14, KEPos = 10, DEang = 0, DEPos = 0;
-    double KCurve=120;
-    double KIEPos = 0, KIEang = 0;
-    //   double PreviewDistance = max(6.0, realSpeed / 3.6 * 1.8);//预瞄距离
-
-    double PreviewDistance;//预瞄距离
-
-    int confL=ServiceCarStatus.aftermarketLane.lane_conf_left;
-    int confR=ServiceCarStatus.aftermarketLane.lane_conf_right;
-    int conf =min(confL,confR);
-
-    realSpeed > 40 ? PreviewDistance = max(6.0, realSpeed *0.6) : PreviewDistance = max(6.0, realSpeed *0.5);
-
-
-
-
-
-    if (realSpeed > 40)	KEang = 10; KEPos = 8;
-    if (realSpeed > 50) KEang = 5;
-
-    KEPos = 20;
-    KEang = 200;
-    //KEang = 15;
-
-    double c1 = ServiceCarStatus.aftermarketLane.dist_to_lane_l;
-    double c2 = ServiceCarStatus.aftermarketLane.dist_to_lane_r;
-    double a = ServiceCarStatus.Lane.curvature;
-    double b = ServiceCarStatus.Lane.heading;
-    double c = (c1+c2)*0.5;
-    double yaw= ServiceCarStatus.Lane.yaw;
-
-    double x= PreviewDistance;
-    double y;
-
-
-    y=c-(a*x*x+b*x);
-    double difa=0-(atan(2*a*x+b) / PI * 180);
-    Curve=0-a;
-
-    //EAng=difa;
-    //EPos=y;
-    EAng= 0-b;
-    EPos = c;
-    DEang = 10;
-    DEPos = 20;
-    //DEang = 20;
-    //DEPos = 10;
-
-    IEang = EAng+0.7*IEang;
-    IEPos = EPos+0.7*IEPos;
-    KIEang = 0;
-    //KIEang = 0.5;
-    KIEPos =2;
-
-
-
-    if(abs(confL)>=2&&abs(confR)>=2){
-        //ang = KEang * EAng + KEPos * EPos + DEang * (EAng - lastEA) + DEPos * (EPos - lastEP)+ KIEang * IEang + KIEPos * IEPos;
-        ang = KEang * EAng + KEPos * EPos +KCurve*Curve+ DEang * (EAng - lastEA) + DEPos * (EPos - lastEP)+ KIEang * IEang + KIEPos * IEPos;
-    }else{
-        ang=lastAng;
-    }
-    //if(lastAng!=0&&abs(ang-lastAng)>20)ang=lastAng;
-
-    lastEA = EAng;
-    lastEP = EPos;
-
-    if (ang > angleLimit) {
-        ang = angleLimit;
-    }
-    else if (ang < -angleLimit) {
-        ang = -angleLimit;
-    }
-    if (lastAng != iv::MaxValue) {
-        ang = 0.2 * lastAng + 0.8 * ang;
-        //ODS("lastAng:%d\n", lastAng);
-    }
-    lastAng = ang;
-    return ang;
-}
-
-
-
-double iv::decition::Compute00::bocheCompute(GPS_INS nowGps, GPS_INS aimGps) {
-
-    GaussProjCal(aimGps.gps_lng, aimGps.gps_lat, &aimGps.gps_x, &aimGps.gps_y);
-    Point2D pt = Coordinate_Transfer(nowGps.gps_x, nowGps.gps_y, aimGps);
-
-
-
-    double x_1 = pt.x;
-    double y_1 = pt.y;
-    double angle_1 = getQieXianAngle(nowGps,aimGps);
-    double x_2 = 0.0, y_2 = 0.0;
-    double steering_angle;
-    double l = 2.950;
-    double r =6;
-    double x_o, y_o, x_o_1, y_o_1, x_o_2, y_o_2, x_3, y_3;
-    double x_t_n, y_t_n, x_t_f, y_t_f;//近切点和远切点
-    double x_t_1, y_t_1, x_t_2, y_t_2;//圆形1的切点
-    double x_t_3, y_t_3, x_t_4, y_t_4;//圆形2的切点
-    double g_1 = tan(angle_1);
-    double car_pos[3] = { x_1,y_1,g_1 };
-    double parking_pos[2] = { x_2,y_2 };
-    double g_3;
-    double t[4][2];
-    double p[4];
-    double  s1, s2; //切点与车起始位置的距离
-    double  min;
-    int  min_i;
-
-    //g_3 = 0 - 0.5775;
-    g_3 = pingfenxian_xielv(x_1, y_1, x_2, y_2, angle_1);
-    //交点
-    x_3 = 0.0;//(y_1 - y_2 + g_2*x_2 - g_1*x_1) / (g_2 - g_1);
-    y_3 = y_1 - g_1 * x_1;
-    //圆心1
-    x_o_1 = r;
-    y_o_1 = g_3 * r + y_3;
-    //圆形1的切点1
-    x_t_1 = 0.0;
-    y_t_1 = g_3 * r + y_3;
-    //圆形1的切点2
-    if (g_1 == 0)
-    {
-        x_t_2 = r;
-        y_t_2 = y_1 - g_1 * x_1;
-    }
-    else
-    {
-        y_t_2 = (y_1 + g_1 * x_o_1 + y_o_1 * g_1*g_1 - g_1 * x_1) / (1 + g_1 * g_1);
-        x_t_2 = (y_t_2 + g_1 * x_1 - y_1) / g_1;
-
-    }
-    //圆心2
-    x_o_2 = 0 - r;
-    y_o_2 = y_3 - g_3 * r;
-    //圆形2的切点1
-    x_t_3 = 0;
-    y_t_3 = y_3 - g_3 * r;
-    //圆形2的切点2
-    if (g_1 == 0)
-    {
-        x_t_4 = 0 - r;
-        y_t_4 = y_1 - g_1 * x_1;
-    }
-    else
-    {
-        y_t_4 = (y_1 + g_1 * x_o_2 + y_o_2 * g_1*g_1 - g_1 * x_1) / (1 + g_1 * g_1);
-        x_t_4 = (y_t_4 + g_1 * x_1 - y_1) / g_1;
-
-    }
-    t[0][0] = x_t_1;
-    t[0][1] = y_t_1;
-    t[1][0] = x_t_2;
-    t[1][1] = y_t_2;
-    t[2][0] = x_t_3;
-    t[2][1] = y_t_3;
-    t[3][0] = x_t_4;
-    t[3][1] = y_t_4;
-    for (int i = 0; i < 4; i++)
-    {
-
-        p[i] = (t[i][0] - parking_pos[0])*(t[i][0] - parking_pos[0]) + (t[i][1] - parking_pos[1])*(t[i][1] - parking_pos[1]);
-
-    }
-    min = p[0];
-    min_i = 0;
-    for (int i = 1; i < 4; i++)
-    {
-
-        if (p[i] < min)
-        {
-            min = p[i]; min_i = i;
-        }
-    }
-    if (min_i < 2)
-    {
-        x_o = x_o_1;
-        y_o = y_o_1;
-        s1 = (x_t_1 - x_1)*(x_t_1 - x_1) + (y_t_1 - y_1)*(y_t_1 - y_1);
-        s2 = (x_t_2 - x_1)*(x_t_2 - x_1) + (y_t_2 - y_1)*(y_t_2 - y_1);
-        if (s1 < s2)
-        {
-            x_t_n = x_t_1;
-            y_t_n = y_t_1;
-            x_t_f = x_t_2;
-            y_t_f = y_t_2;
-        }
-        else
-        {
-            x_t_n = x_t_2;
-            y_t_n = y_t_2;
-            x_t_f = x_t_1;
-            y_t_f = y_t_1;
-
-        }
-    }
-    else
-    {
-        x_o = x_o_2;
-        y_o = y_o_2;
-        s1 = (x_t_3 - x_1)*(x_t_3 - x_1) + (y_t_3 - y_1)*(y_t_3 - y_1);
-        s2 = (x_t_4 - x_1)*(x_t_4 - x_1) + (y_t_4 - y_1)*(y_t_4 - y_1);
-
-        if (s1 < s2)
-        {
-
-            x_t_n = x_t_3;
-            y_t_n = y_t_3;
-            x_t_f = x_t_4;
-            y_t_f = y_t_4;
-        }
-        else
-        {
-            x_t_n = x_t_4;
-            y_t_n = y_t_4;
-            x_t_f = x_t_3;
-            y_t_f = y_t_3;
-        }
-
-
-
-
-    }
-    steering_angle = atan2(l, r);
-
-    if (x_t_n < 0)
-    {
-        steering_angle = 0 - steering_angle;
-    }
-
-    nearTpoint=Coordinate_UnTransfer(x_t_n, y_t_n, aimGps);
-    farTpoint = Coordinate_UnTransfer(x_t_f, y_t_f, aimGps);
-    bocheAngle = steering_angle*180/PI;
-
-    cout << "近切点:x_t_n=" << x_t_n << endl;
-    cout << "近切点:y_t_n=" << y_t_n << endl;
-    cout << "远切点:x_t_f=" << x_t_f << endl;
-    cout << "远切点:y_t_f=" << y_t_f << endl;
-    cout << "航向角:" << steering_angle << endl;
-
-
-    //    if (x_1 < 0 && y_1 > 0 && x_1 < x_t_n &&y_t_f > 0.1) {
-    //        return 1;
-    //    }
-    Point2D ptN = Coordinate_Transfer(nearTpoint.gps_x, nearTpoint.gps_y, nowGps);
-    double disA = GetDistance(aimGps,nowGps);
-    if(y_t_n>0 && ptN.y<0 && y_t_f>0.1 && disA<40){
-        return 1;
-    }
-
-    return 0;
-
-}
-
-
-
-//返回垂直平分线的斜率
-double iv::decition::Compute00::pingfenxian_xielv(double x_1, double y_1, double x_2, double y_2, double angle_1) {
-    double angl, x_3, angle_3;
-    if (tan(angle_1 == 0))
-    {
-        if ((x_1 - x_2) > 0 && ((y_1 - y_2) > 0))
-        {
-            angle_3 = 0 - 1;
-        }
-        else
-        {
-            angle_3 = 1;
-        }
-    }
-    else
-    {
-        x_3 = (tan(angle_1)*x_1 - y_1) / tan(angle_1);//车所在直线与x轴交点
-        angl = tan(angle_1);//车所在直线的斜率
-        if ((x_1 - x_2)>0 && ((y_1 - y_2)>0))//第一象限
-        {
-            if ((angl *x_3)<0)//车斜率与车直线的x轴交点异号
-            {
-                if (angl < 0)
-                {
-                    angle_3 = tan(PI*0.5 + (PI*0.5 - atan(fabs(angl))) *0.5);//垂直平分线斜率
-                }
-                else
-                {
-                    angle_3 = tan(PI*0.5 + (PI*0.5 + atan(fabs(angl))) *0.5);//垂直平分线斜率
-                }
-
-
-
-            }
-
-        }
-        else//第二象限
-        {
-            if ((angl*x_3)<0)//车斜率与车直线的x轴交点异号
-            {
-                if (angl < 0)
-                {
-                    angle_3 = tan(PI*0.5 - (PI*0.5 + atan(fabs(angl))) *0.5);//垂直平分线斜率
-                }
-                else
-                {
-                    angle_3 = tan(atan(fabs(angl)) + (PI*0.5 - atan(fabs(angl))) *0.5);//垂直平分线斜率
-                }
-
-            }
-        }
-    }
-
-    return angle_3;
-
-}
-
-
-
-double iv::decition::Compute00::getQieXianAngle(GPS_INS nowGps, GPS_INS aimGps) {
-    double heading = nowGps.ins_heading_angle *PI/180;
-    double x1 = nowGps.gps_x;
-    double y1 = nowGps.gps_y;
-    if (heading<=PI*0.5)
-    {
-        heading = 0.5*PI - heading;
-    }
-    else if (heading>PI*0.5 && heading<=PI*1.5) {
-        heading = 1.5*PI - heading;
-    }
-    else if (heading>PI*1.5) {
-        heading = 2.5*PI - heading;
-    }
-    double k1 = tan(heading);
-    double x = x1+10;
-    double y = k1 * x + y1 - (k1 * x1);
-    Point2D pt1 = Coordinate_Transfer(nowGps.gps_x, nowGps.gps_y, aimGps);
-    Point2D pt2 = Coordinate_Transfer(x, y, aimGps);
-    double xielv = (pt1.y - pt2.y) / (pt1.x - pt2.x);
-    double angle = atan(abs(xielv));
-    if (xielv<0)
-    {
-        angle = PI - angle;
-    }
-    return angle;
-
-}
-
-
-/*
-  chuizhicheweiboche
-  */
-
-
-int iv::decition::Compute00::bocheDirectCompute(GPS_INS nowGps, GPS_INS aimGps)
-{
-
-
-
-    double l=2.95;//轴距
-    double x_0 = 0, y_0 = 0.5;
-    double x_1, y_1;//车起点坐标
-    double ange1;//车航向角弧度
-    double x_2, y_2;//另一条与车直线在angle2和R_M 固定情况下过坐标点,第二个近切点
-    double real_rad;;//另一条直线的航向角弧度
-    double angle_3;//垂直平分线弧度
-    double x_3, y_3;//垂直平分线交点
-    double x_4, y_4;//另一条直线的远切点坐标,第二个远切点,已知
-    double x_o_1, y_o_1;//圆形1坐标
-    double x_o_2, y_o_2;//圆形2坐标
-    double x_t_n, y_t_n, x_t_f, y_t_f;//近切点和远切点
-    double min_rad;
-    double R_M; //后轴中点的转弯半径
-    double steering_angle;
-
-
-
-
-    GaussProjCal(aimGps.gps_lng, aimGps.gps_lat, &aimGps.gps_x, &aimGps.gps_y);
-    Point2D pt = Coordinate_Transfer(nowGps.gps_x, nowGps.gps_y, aimGps);
-    x_1=pt.x;
-    y_1=pt.y;
-    ange1=getQieXianAngle(nowGps,aimGps);
-
-    min_rad_zhuanxiang(&R_M , &min_rad);
-    qiedian_n(x_1,y_1,R_M,min_rad,&x_2 , &y_2, &real_rad);//计算另一条与车直线在angle2和R_M 固定情况下近切点:x_2, y_2
-    liangzhixian_jiaodian( x_1, y_1,  x_2, y_2,ange1,real_rad,&x_3 , &y_3);
-    chuizhipingfenxian_xielv( x_1, y_1, ange1, real_rad, min_rad,&angle_3);
-    yuanxin( x_2, y_2, x_3, y_3, real_rad, angle_3, R_M,&x_o_1,&y_o_1,&x_o_2,&y_o_2);
-    yuanxin_qiedian( ange1, x_o_1, y_o_1,  x_o_2, y_o_2,
-                     x_1, y_1, x_2, y_2, x_3, y_3, real_rad, angle_3, R_M,&x_t_n,&y_t_n,&x_t_f, &y_t_f);
-    steering_angle = atan2(l, R_M);
-    x_4 = 0.5;
-    y_4 = 0;
-    //for (int i = 0; i < 4; i++)
-    //{
-    //for (int j = 0; j < 2; j++)
-    //{
-    //	cout << t[i][j] << endl;
-    //}
-    //}
-    //cout << "min_rad:" << min_rad<< endl;
-    //cout << "jiaodian:x=" << x_3 << endl;
-    //cout << "jiaodian:y=" << y_3 << endl;
-    // cout << "R-M:" << R_M << endl;
-    cout << "x_0:" << x_0 << endl;
-    cout << "y_0:" << y_0 << endl;
-    cout << "x_2:" << x_2 << endl;
-    cout << "y_2:" << y_2 << endl;
-    cout << "近切点:x_t_n="<< x_t_n << endl;
-    cout << "近切点:y_t_n=" << y_t_n << endl;
-    cout << "远切点:x_t_f=" << x_t_f << endl;
-    cout << "远切点:y_t_f=" << y_t_f << endl;
-    //cout << "航向角:" << steering_angle << endl;
-    //cout << "圆心1横坐标=" << x_o_1 << endl;
-    //cout << "圆心1纵坐标=" << y_o_1 << endl;
-    //cout << "圆心2横坐标=" << x_o_2 << endl;
-    //cout << "圆心2纵坐标=" << y_o_2 << endl;
-    //cout << "平分线弧度=" << angle_3 << endl;
-    //cout << " min_rad=" << min_rad << endl;
-    //cout << " real_rad=" << real_rad << endl;
-    //   system("PAUSE");
-
-
-
-    dTpoint0=Coordinate_UnTransfer(x_t_n, y_t_n, aimGps);
-    dTpoint1 = Coordinate_UnTransfer(x_t_f, y_t_f, aimGps);
-    dTpoint2 = Coordinate_UnTransfer(x_2, y_2, aimGps);
-    dTpoint3 = Coordinate_UnTransfer(x_0, y_0, aimGps);
-    dBocheAngle = steering_angle*180/PI;
-
-    double disA = GetDistance(aimGps,nowGps);
-
-    if(pt.y>y_t_n && x_t_f<x_2 && y_t_f>y_2&&disA<40){
-        return 1;
-    }
-    return 0;
-
-}
-
-
-double iv::decition::Compute00::min_rad_zhuanxiang(double *R_M, double *min_rad) {
-    double L_c = 4.749;//车长
-    double rad_1;
-    double rad_2;
-    double L_k = 1.931;//车宽
-    double L = 2.95;//轴距
-    double L_f =1.2 ;//前悬
-    double L_r =0.7 ;//后悬
-    double R_min =6.5 ;//最小转弯半径
-    *R_M = fabs(sqrt(R_min*R_min - (L + L_f)*(L + L_f))) - L_k*0.5;//double	R_M  ;//后轴中点的转弯半径
-    //rad_1 = atan2(sqrt(R_min*R_min - (R_M - L_k*0.5)*(R_M - L_k*0.5)), R_M - L_k*0.5);
-    //rad_2 = atan2(L + L_f, R_M + L_k*0.5);
-    *min_rad = 45 * PI / 180;// rad_1 - rad_2;
-    return 0;
-}
-
-
-double iv::decition::Compute00::qiedian_n(double x_1, double y_1, double R_M,double min_rad, double *x_2, double *y_2, double *real_rad ) {
-
-    if (x_1 > 0 && y_1 > 0)
-    {
-        *real_rad = PI*0.5 - min_rad;
-        *x_2 = R_M - R_M*cos(min_rad);
-        *y_2 = R_M*sin(min_rad) + 0.5;
-    }
-    else
-    {
-        *real_rad = PI*0.5 + min_rad;
-        *x_2 = R_M*cos(min_rad) - R_M;
-        *y_2 = R_M*sin(min_rad) + 0.5;
-    }
-    return 0;
-
-}
-
-
-double iv::decition::Compute00::liangzhixian_jiaodian(double x_1,double y_1,double x_2,double y_2,double ange1,double real_rad,double *x_3,double *y_3) {
-    double b1, b2;
-    double k1, k2;
-    if (ange1!=(PI*0.5))
-    {
-        k1 = tan(ange1);
-        b1 = y_1 - k1*x_1;
-        k2 = tan(real_rad);
-        b2 = y_2 - k2*x_2;
-        *x_3 = (b2 - b1) / (k1 - k2);
-        *y_3 = k2*(*x_3) + b2;
-    }
-    else
-    {
-        k2 = tan(real_rad);
-        b2 = y_2 - k2*x_2;
-        *x_3 = x_1;
-        *y_3 = k2*(*x_3) + b2;
-    }
-    return 0;
-}
-
-
-double iv::decition::Compute00::chuizhipingfenxian_xielv(double x_1,double y_1,double ange1,double real_rad,double min_rad,double *angle_3) {
-    double k1, k2;
-    double  angle_j;
-    k2 = tan(real_rad);
-    if (ange1 != (PI*0.5))
-    {
-        k1 = tan(ange1);
-        angle_j = atan(fabs((k2 - k1) / (1 + k2*k1)));//两直线夹角
-
-        if (x_1 > 0 && y_1 > 0)
-        {
-            *angle_3 = angle_j*0.5 - min_rad + PI;
-        }
-        else
-        {
-            *angle_3 = min_rad - angle_j*0.5;
-        }
-    }
-    else
-    {
-        angle_j = min_rad;//两直线夹角
-        if (x_1 > 0 && y_1 > 0)
-        {
-            *angle_3 = angle_j*0.5 - min_rad + PI;
-        }
-        else
-        {
-            *angle_3 = min_rad - angle_j*0.5;
-        }
-    }
-    return 0;
-}
-
-
-double iv::decition::Compute00::yuanxin(double x_2,double y_2,double x_3,double y_3,double real_rad,double angle_3,double R_M,
-                                        double *x_o_1,double *y_o_1,double *x_o_2,double *y_o_2) {
-    double b2, b3, k2, k3;
-    b2 = y_2 - tan(real_rad)*x_2;
-    b3 = y_3 - tan(angle_3)*x_3;
-    k2 = tan(real_rad);
-    k3 = tan(angle_3);
-    *x_o_1 = (sqrt(k2*k2 + 1)*R_M + b3 - b2) / (k2 - k3);
-    *y_o_1 = k3*(*x_o_1) + b3;
-
-    *x_o_2 = (b3 - b2 - (sqrt(k2*k2 + 1)*R_M)) / (k2 - k3);
-    *y_o_2 = k3*(*x_o_2) + b3;
-    return 0;
-}
-
-
-double iv::decition::Compute00::yuanxin_qiedian(double ange1,double x_o_1,double y_o_1, double x_o_2,double y_o_2,
-                                                double x_1,double y_1,double x_2,double y_2,double x_3,double y_3,double real_rad,double angle_3,double R_M,
-                                                double *x_t_n, double *y_t_n, double *x_t_f, double *y_t_f)
-{
-    double x_o, y_o;
-    double b2, b3, k1, k2, k3;
-
-    //double car_pos[3] = { x_1,y_1,k1 };
-    double parking_pos[2] = { x_2,y_2 };
-    //double t[4][2];
-    double p[4];
-    double  s1, s2; //切点与车起始位置的距离
-    double  min;
-    int  min_i;
-    double x_t_1, y_t_1, x_t_2, y_t_2;//圆形1的切点
-    double x_t_3, y_t_3, x_t_4, y_t_4;//圆形2的切点
-    double t[4][2];
-    k1 = tan(ange1);
-    b2 = y_2 - tan(real_rad)*x_2;
-    b3 = y_3 - tan(real_rad)*x_3;
-    k2 = tan(real_rad);//另一条直线斜率
-    k3 = tan(angle_3);//垂直平分线斜率
-    //圆心1和2切点*********************************************
-    if (x_1 > 0 && y_1 > 0)//第一象限
-    {
-        if (ange1 == (PI*0.5))
-        {
-            x_t_1 = x_1;
-            y_t_1 = y_o_1;
-            y_t_2 = (y_2 + k2 *x_o_1 + y_o_1*k2*k2 - k2*x_2) / (1 + k2*k2);
-            x_t_2 = (y_t_2 + k2*x_2 - y_2) / k2;
-
-            x_t_3 = x_1;
-            y_t_3 = y_o_2;
-            y_t_4 = (y_2 + k2 *x_o_2 + y_o_2*k2*k2 - k2*x_2) / (1 + k2*k2);
-            x_t_4 = (y_t_4 + k2*x_2 - y_2) / k2;
-
-
-        }
-        else
-        {
-            y_t_1 = (y_1 + k1 *x_o_1 + y_o_1*k1*k1 - k1*x_1) / (1 + k1*k1);
-            x_t_1 = (y_t_1 + k1*x_1 - y_1) / k1;
-            y_t_2 = (y_2 + k2 *x_o_1 + y_o_1*k2*k2 - k2*x_2) / (1 + k2*k2);
-            x_t_2 = (y_t_2 + k2*x_2 - y_2) / k2;
-
-            y_t_3 = (y_1 + k1 *x_o_2 + y_o_2*k1*k1 - k1*x_1) / (1 + k1*k1);
-            x_t_3 = (y_t_3 + k1*x_1 - y_1) / k1;
-            y_t_4 = (y_2 + k2 *x_o_2 + y_o_2*k2*k2 - k2*x_2) / (1 + k2*k2);
-            x_t_4 = (y_t_4 + k2*x_2 - y_2) / k2;
-
-        }
-    }
-    else
-    {
-        if (ange1 == 0)
-        {
-            x_t_1 = 0 - x_1;
-            y_t_1 = y_o_1;
-            y_t_2 = (y_2 + k2 *x_o_1 + y_o_1*k2*k2 - k2*x_2) / (1 + k2*k2);
-            x_t_2 = (y_t_2 + k2*x_2 - y_2) / k2;
-
-            x_t_3 = 0 - x_1;
-            y_t_3 = y_o_2;
-            y_t_4 = (y_2 + k2 *x_o_2 + y_o_2*k2*k2 - k2*x_2) / (1 + k2*k2);
-            x_t_4 = (y_t_4 + k2*x_2 - y_2) / k2;
-        }
-        else
-        {
-            y_t_1 = (y_1 + k1 *x_o_1 + y_o_1*k1*k1 - k1*x_1) / (1 + k1*k1);
-            x_t_1 = (y_t_1 + k1*x_1 - y_1) / k1;
-            y_t_2 = (y_2 + k2 *x_o_1 + y_o_1*k2*k2 - k2*x_2) / (1 + k2*k2);
-            x_t_2 = (y_t_2 + k2*x_2 - y_2) / k2;
-
-            y_t_3 = (y_1 + k1 *x_o_2 + y_o_2*k1*k1 - k1*x_1) / (1 + k1*k1);
-            x_t_3 = (y_t_3 + k1*x_1 - y_1) / k1;
-            y_t_4 = (y_2 + k2 *x_o_2 + y_o_2*k2*k2 - k2*x_2) / (1 + k2*k2);
-            x_t_4 = (y_t_4 + k2*x_2 - y_2) / k2;
-
-        }
-
-    }
-
-    //圆心1和2切点*********************************************
-
-    t[0][0] = x_t_1;
-    t[0][1] = y_t_1;
-    t[1][0] = x_t_2;
-    t[1][1] = y_t_2;
-    t[2][0] = x_t_3;
-    t[2][1] = y_t_3;
-    t[3][0] = x_t_4;
-    t[3][1] = y_t_4;
-    for (int i = 0; i < 4; i++)
-    {
-
-        p[i] = (t[i][0] - parking_pos[0])*(t[i][0] - parking_pos[0]) + (t[i][1] - parking_pos[1])*(t[i][1] - parking_pos[1]);
-
-    }
-    min = p[0];
-    min_i = 0;
-    for (int i = 1; i < 4; i++)
-    {
-
-        if (p[i] < min)
-        {
-            min = p[i]; min_i = i;
-        }
-    }
-    if (min_i < 2)
-    {
-        x_o = x_o_1;
-        y_o = y_o_1;
-        s1 = (x_t_1 - x_1)*(x_t_1 - x_1) + (y_t_1 - y_1)*(y_t_1 - y_1);
-        s2 = (x_t_2 - x_1)*(x_t_2 - x_1) + (y_t_2 - y_1)*(y_t_2 - y_1);
-        if (s1 < s2)
-        {
-            *x_t_n = x_t_1;
-            *y_t_n = y_t_1;
-            *x_t_f = x_t_2;
-            *y_t_f = y_t_2;
-        }
-        else
-        {
-            *x_t_n = x_t_2;
-            *y_t_n = y_t_2;
-            *x_t_f = x_t_1;
-            *y_t_f = y_t_1;
-
-        }
-    }
-    else
-    {
-        x_o = x_o_2;
-        y_o = y_o_2;
-        s1 = (x_t_3 - x_1)*(x_t_3 - x_1) + (y_t_3 - y_1)*(y_t_3 - y_1);
-        s2 = (x_t_4 - x_1)*(x_t_4 - x_1) + (y_t_4 - y_1)*(y_t_4 - y_1);
-
-        if (s1 < s2)
-        {
-
-            *x_t_n = x_t_3;
-            *y_t_n = y_t_3;
-            *x_t_f = x_t_4;
-            *y_t_f = y_t_4;
-        }
-        else
-        {
-            *x_t_n = x_t_4;
-            *y_t_n = y_t_4;
-            *x_t_f = x_t_3;
-            *y_t_f = y_t_3;
-        }
-
-
-
-    }
-
-    return 0;
-
-}
-
-
-int iv::decition::Compute00::getNoAngleNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap)
-{
-    int index = -1;
-    int startIndex = 0;     // startIndex = 0 则每一次都是遍历整条地图路线
-    int endIndex = gpsMap.size() - 1;
-    float minDis=20;
-
-    for (int j = startIndex; j < endIndex; j++)
-    {
-        int i = (j + gpsMap.size()) % gpsMap.size();
-        double tmpdis = GetDistance(rp, (*gpsMap[i]));
-
-        if (tmpdis < minDis)
-        {
-            index = i;
-            minDis=tmpdis;
-        }
-    }
-    return index;
-}
-
-
-double iv::decition::Compute00::getObsSpeedByFrenet(Point2D obsPoint, double realSecSpeed,const vector<Point2D> gpsTrace, std::vector<iv::GPSData> gpsMap,int pathpoint,GPS_INS nowGps) {
-    double obsSpeed = 0 - realSecSpeed;
-    double minDis = iv::MaxValue;
-    FrenetPoint esr_obs_F_point;
-    for (int i = 0; i < 64; i++)
-        if ((ServiceCarStatus.obs_radar[i].nomal_y) != 0 && ServiceCarStatus.obs_radar[i].valid)
-        {
-            double xxx = ServiceCarStatus.obs_radar[i].nomal_x + Esr_Offset;
-            double yyy = ServiceCarStatus.obs_radar[i].nomal_y + Esr_Y_Offset;
-
-            if (abs(xxx - obsPoint.x) < 4 && abs(yyy - obsPoint.y) < 2)
-            {
-                double tmpDis = sqrt((xxx - obsPoint.x) * (xxx - obsPoint.x) + (yyy - obsPoint.y) * (yyy - obsPoint.y));
-                if (tmpDis < minDis)
-                {
-                    minDis = tmpDis;
-//                    esr_obs_F_point = iv::decition::FrenetPlanner::XY2Frenet(xxx, yyy, gpsTrace);
-                    esr_obs_F_point = iv::decition::FrenetPlanner::getFrenetfromXY(xxx, yyy, gpsTrace,gpsMap,pathpoint,nowGps);
-//                    obsSpeed = ServiceCarStatus.obs_radar[i].speed_y;
-                    double speedx=ServiceCarStatus.obs_radar[i].speed_x;  //障碍物相对于车辆x轴的速度
-                    double speedy=ServiceCarStatus.obs_radar[i].speed_y;  //障碍物相对于车辆y轴的速度
-                    double speed_combine = sqrt(speedx*speedx+speedy*speedy);    //将x、y轴两个方向的速度求矢量和
-                    //障碍物的速度方向与道路方向的夹角。用于将速度分解到s方向和d方向。
-                    //所谓道路方向是指,道路上离障碍物的最近的点沿道路弧线的切线方向。
-                    double Etheta = esr_obs_F_point.tangent_Ang - atan2(speedy,speedx);
-
-                    obsSpeed = speed_combine*cos(Etheta);  //由speed_combine分解的s轴方向上的速度
-                }
-            }
-        }
-
-    return obsSpeed;
-}
-
-
-int iv::decition::Compute00::getEsrIndexByFrenet(std::vector<Point2D> gpsTrace, FrenetPoint &esrObsPoint, std::vector<iv::GPSData> gpsMap,int pathpoint,GPS_INS nowGps){
-    double minDistance = numeric_limits<double>::max();
-    int minDis_index=-1;
-
-    for(int i=0; i<64; ++i){
-        if ((ServiceCarStatus.obs_radar[i].nomal_y) != 0 && (ServiceCarStatus.obs_radar[i].valid)){
-            //毫米波在车头,故要加上毫米波与惯导的相对距离。(xxx,yyy)才是障碍物在 车辆坐标系下的坐标。
-            double xxx = ServiceCarStatus.obs_radar[i].nomal_x + Esr_Offset;
-            double yyy = ServiceCarStatus.obs_radar[i].nomal_y+ Esr_Y_Offset;
-
-            //将毫米波障碍物位置转换到frenet坐标系下
-//            esrObsPoint = iv::decition::FrenetPlanner::XY2Frenet(xxx,yyy,gpsTrace);
-            esrObsPoint = iv::decition::FrenetPlanner::getFrenetfromXY(xxx,yyy,gpsTrace,gpsMap,pathpoint,nowGps);
-
-            //如果障碍物与道路的横向距离d<=3.0*Veh_Width / 4.0,则认为道路上有障碍物。
-            //s则可理解为障碍物距离。为障碍物与车辆沿着道路方向的距离,而不是空间上的x或y坐标或者直线距离。
-            //minDistance、minDis_index用来统计最近的障碍物信息。
-            if(abs(esrObsPoint.d)<=(3.0*Veh_Width / 4.0+DecideGps00().xiuzhengCs)){
-                if(esrObsPoint.s<minDistance){
-                    minDistance = esrObsPoint.s;
-                    minDis_index = i;
-                }
-            }
-        }
-    }
-    return minDis_index;
-}
-
-
-
-
-std::vector<std::vector<iv::GPSData>> gmapsL;
-std::vector<std::vector<iv::GPSData>> gmapsR;
+#include <decition/adc_tools/compute_00.h>
+#include <decition/decide_gps_00.h>
+#include <decition/adc_tools/gps_distance.h>
+#include <decition/decition_type.h>
+#include <decition/adc_tools/transfer.h>
+#include <common/constants.h>
+#include <math.h>
+#include <iostream>
+#include <fstream>
+#include <control/can.h>
+using namespace std;
+
+#define PI (3.1415926535897932384626433832795)
+
+iv::decition::Compute00::Compute00() {
+
+}
+iv::decition::Compute00::~Compute00() {
+
+}
+
+
+double iv::decition::Compute00::angleLimit = 700;
+double iv::decition::Compute00::lastEA = 0;
+double iv::decition::Compute00::lastEP = 0;
+double iv::decition::Compute00::decision_Angle = 0;
+double iv::decition::Compute00::lastAng = 0;
+int iv::decition::Compute00::lastEsrID = -1;
+int  iv::decition::Compute00::lastEsrCount = 0;
+int iv::decition::Compute00::lastEsrIDAvoid = -1;
+int  iv::decition::Compute00::lastEsrCountAvoid = 0;
+
+iv::GPS_INS  iv::decition::Compute00::nearTpoint;
+iv::GPS_INS  iv::decition::Compute00::farTpoint;
+double  iv::decition::Compute00::bocheAngle;
+
+
+
+iv::GPS_INS  iv::decition::Compute00::dTpoint0;
+iv::GPS_INS  iv::decition::Compute00::dTpoint1;
+iv::GPS_INS  iv::decition::Compute00::dTpoint2;
+iv::GPS_INS  iv::decition::Compute00::dTpoint3;
+double  iv::decition::Compute00::dBocheAngle;
+
+
+std::vector<int> lastEsrIdVector;
+std::vector<int> lastEsrCountVector;
+
+
+
+int iv::decition::Compute00::getDesiredSpeed(std::vector<GPSData> gpsMap)
+{
+    int startIndex = 0;     // startIndex = 0 则每一次都是遍历整条地图路线
+    int endIndex = gpsMap.size() - 1;
+    static double FrontTotalFive=0,FrontAveFive=0,BackAveFive=0,BackTotalFive=0;
+    static int FrontCount=0,BackCount=0;
+    static int CurrentIndex=0,MarkingIndex=0,MarkingCount=0;
+    int MarkedIndex=0,CurveContinue=0;
+
+    for (int j = startIndex; j < endIndex; j++)
+    {
+        int i = (j + gpsMap.size()) % gpsMap.size();
+        (*gpsMap[i]).roadMode=5;
+    }
+    for (int j = startIndex; j < (endIndex-10); j+=10)
+    {
+        int i = (j + gpsMap.size()) % gpsMap.size();
+        for(int front_k=i;front_k<i+5;front_k++)
+        {
+            if(fabs(((*gpsMap[front_k]).ins_heading_angle)-((*gpsMap[i]).ins_heading_angle))<10)
+            {
+                   FrontTotalFive+=(*gpsMap[front_k]).ins_heading_angle;
+                   FrontCount++;
+            }
+
+        }
+        i+=5;
+        FrontAveFive=FrontTotalFive/FrontCount;
+        FrontTotalFive=0;
+        FrontCount=0;
+        for(int back_k=i;back_k<i+5;back_k++)
+        {
+            if(fabs((*gpsMap[back_k]).ins_heading_angle-(*gpsMap[i]).ins_heading_angle)<10)
+            {
+                   BackTotalFive+=(*gpsMap[back_k]).ins_heading_angle;
+                   BackCount++;
+            }
+
+        }
+        i+=5;
+        CurrentIndex=i-1;
+        BackAveFive=BackTotalFive/BackCount;
+        BackTotalFive=0;
+        BackCount=0;
+        if(fabs(FrontAveFive-BackAveFive)<50)
+        {
+                   if(fabs(FrontAveFive-BackAveFive)>3)
+                   {
+                        CurveContinue+=1;
+                        if(CurveContinue>=2)
+                        {
+                            MarkingCount=0;
+                            for(MarkingIndex=CurrentIndex;MarkingIndex>=MarkedIndex;MarkingIndex--)
+                            {
+
+                                if(MarkingCount<100)
+                                {
+                                     if((BackAveFive-FrontAveFive)<3)
+                                     {
+                                           (*gpsMap[MarkingIndex]).roadMode=14;   //弯道,2米,14
+                                     }
+                                     else if((BackAveFive-FrontAveFive)>3)
+                                     {
+                                           (*gpsMap[MarkingIndex]).roadMode=15;
+                                     }
+
+                                }
+                                else if((MarkingCount>=100)&&(MarkingCount<150))
+                                {
+                                     (*gpsMap[MarkingIndex]).roadMode=18;   //超低速,10米,1
+                                }
+                                else if((MarkingCount>=150)&&(MarkingCount<320))
+                                {
+                                     (*gpsMap[MarkingIndex]).roadMode=5;   //低速,20米,5
+                                }
+                                else if((MarkingCount>=320)&&(MarkingCount<620))
+                                {
+                                     (*gpsMap[MarkingIndex]).roadMode=0;   //常速,60米
+                                }
+                                else if(MarkingCount>=620)
+                                {
+                                     (*gpsMap[MarkingIndex]).roadMode=11;   //高速/疯狂加速,大于60米
+                                }
+
+                                MarkingCount++;
+                            }
+                            MarkedIndex=CurrentIndex;
+                        }
+                   }
+                   else if(fabs(FrontAveFive-BackAveFive)<=3)
+                   {
+                        CurveContinue=0;
+                   }
+        }
+        FrontAveFive=0;
+        BackAveFive=0;
+    }
+
+    if(MarkedIndex<endIndex)
+    {
+        MarkingCount=0;
+        for(MarkingIndex=endIndex;MarkingIndex>=MarkedIndex;MarkingIndex--)
+        {
+
+            if(MarkingCount<100)
+            {
+                if((BackAveFive-FrontAveFive)<3)
+                {
+                      (*gpsMap[MarkingIndex]).roadMode=14;   //弯道,2米,14
+                }
+                else if((BackAveFive-FrontAveFive)>3)
+                {
+                      (*gpsMap[MarkingIndex]).roadMode=15;
+                }
+            }
+            else if((MarkingCount>=100)&&(MarkingCount<150))
+            {
+                 (*gpsMap[MarkingIndex]).roadMode=18;   //超低速,10米
+            }
+            else if((MarkingCount>=150)&&(MarkingCount<320))
+            {
+                 (*gpsMap[MarkingIndex]).roadMode=5;   //低速,30米
+            }
+            else if((MarkingCount>=320)&&(MarkingCount<620))
+            {
+                 (*gpsMap[MarkingIndex]).roadMode=0;   //常速,60米
+            }
+            else if(MarkingCount>=620)
+            {
+                 (*gpsMap[MarkingIndex]).roadMode=11;   //高速/疯狂加速,大于60米
+            }
+
+            MarkingCount++;
+        }
+    }
+
+
+    return 1;
+}
+
+
+
+//首次找点
+
+int iv::decition::Compute00::getFirstNearestPointIndex(GPS_INS rp, std::vector<GPSData> gpsMap, int lastIndex, double mindis, double maxAngle)
+{
+    int index = -1;
+    //	DecideGps00().minDis = iv::MaxValue;
+    float minDis = 10;
+    double maxAng = iv::MaxValue;
+
+    int startIndex = 0;     // startIndex = 0 则每一次都是遍历整条地图路线
+    int endIndex = gpsMap.size() - 1;
+
+    for (int j = startIndex; j < endIndex; j++)
+    {
+        int i = (j + gpsMap.size()) % gpsMap.size();
+        double tmpdis = GetDistance(rp, (*gpsMap[i]));
+
+        if (tmpdis < minDis && (abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle) < 80
+                                              || abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle - 360) < 80
+                                              || abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle + 360) < 80)
+                )
+        {
+            index = i;
+            minDis = tmpdis;
+            maxAng = min(abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle), abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle - 360));
+            maxAng = min(maxAng, abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle + 360));
+        }
+    }
+
+    DecideGps00().maxAngle=maxAng;
+    DecideGps00().minDis=minDis;
+    return index;
+}
+
+//search pathpoint
+int iv::decition::Compute00::getNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap, int lastIndex, double mindis, double maxAngle)
+{
+    int index = -1;
+    float minDis = 10;
+    double maxAng = iv::MaxValue;
+    int map_size=gpsMap.size();
+    int preDistance=max(100,(int)(rp.speed*10));
+        preDistance=min(500,preDistance);
+
+    int startIndex = max((int)(lastIndex - 100),(int)(lastIndex-map_size));     // startIndex = 0 则每一次都是遍历整条地图路线
+    int endIndex = min((int)(lastIndex + preDistance ),(int)(lastIndex+map_size));
+
+
+    for (int j = startIndex; j < endIndex; j++)
+    {
+        int i = (j + map_size) % map_size;
+        double tmpdis = GetDistance(rp, (*gpsMap[i]));
+
+        if (tmpdis < minDis && (abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle) < 80
+            || abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle - 360) < 80
+            || abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle + 360) < 80)
+            )
+        {
+            index = i;
+            minDis = tmpdis;
+            maxAng = min(abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle), abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle - 360));
+            maxAng = min(maxAngle, abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle + 360));
+        }
+    }
+
+
+    DecideGps00().maxAngle=maxAng;
+    DecideGps00().minDis=minDis;
+    return index;
+}
+
+
+double iv::decition::Compute00::getAveDef(std::vector<Point2D> farTrace)
+{
+    double sum_x = 0;
+    double sum_y = 0;
+
+    for (int i = 0; i < min(5, (int)farTrace.size()); i++)
+    {
+        sum_x += farTrace[i].x;
+        sum_y += abs(farTrace[i].y);
+    }
+    double average_y = sum_y / min(5, (int)farTrace.size());
+    double average_x = sum_x / min(5, (int)farTrace.size());
+
+
+    return atan(average_x / average_y) / PI * 180;
+}
+
+
+
+double iv::decition::Compute00::getAvoidAveDef(std::vector<Point2D> farTrace, double avoidX)
+{
+    double sum_x = 0;
+    double sum_y = 0;
+
+    for (int i = 0; i < min(5, (int)farTrace.size()); i++)
+    {
+        sum_x += farTrace[i].x;
+        sum_y += abs(farTrace[i].y);
+    }
+    double average_y = sum_y / min(5, (int)farTrace.size());
+    double average_x = sum_x / min(5, (int)farTrace.size());
+
+
+    return atan(average_x + avoidX / average_y) / PI * 180;
+}
+
+
+
+
+
+
+double iv::decition::Compute00::getDecideAngle(std::vector<Point2D>  gpsTrace, double realSpeed) {
+
+    double ang = 0;
+    double EPos = 0, EAng = 0;
+
+    //   double KEang = 14, KEPos = 10, DEang = 3, DEPos = 1;  // double KEang = 14, KEPos = 10, DEang = 10, DEPos = 10;
+    double KEang = 14, KEPos = 10, DEang = 0, DEPos = 0;
+
+    if(transferPieriod&& !transferPieriod2){
+        DEang = 200;
+        DEPos = 150;
+    }
+
+    //   double PreviewDistance = max(6.0, realSpeed / 3.6 * 1.8);//预瞄距离
+
+    double PreviewDistance;//预瞄距离
+    realSpeed > 40 ? PreviewDistance = max(6.0, realSpeed *0.6) : PreviewDistance = max(6.0, realSpeed *0.5);
+    if(changeRoad ||transferPieriod){
+        PreviewDistance=PreviewDistance+avoidX;
+    }
+    if(realSpeed <15){
+        PreviewDistance = max(4.0, realSpeed *0.4) ;
+    }
+
+    if (gpsTrace[0].v1 == 1)
+    {
+        KEang = 14; KEPos = 10;
+    }
+    else if (gpsTrace[0].v1 == 2 || gpsTrace[0].v1 == 3)
+    {
+        KEang = 14; KEPos = 10;
+    }
+    else if (gpsTrace[0].v1 == 4 || gpsTrace[0].v1 == 5)
+    {
+        KEang = 14; KEPos = 10;
+    }
+    else if (gpsTrace[0].v1 == 7 && (gpsTrace[0].v2 == 23 || gpsTrace[0].v2 == 24))
+    {
+        KEang = 18; KEPos = 50; PreviewDistance = 3;
+    }
+    else if (gpsTrace[0].v1 == 7)
+    {
+        KEang = 20; KEPos = 50; PreviewDistance = 4;
+    }
+
+
+    if (realSpeed > 40)	KEang = 10; KEPos = 8;
+    if (realSpeed > 50) KEang = 5;
+
+    double sumdis = 0;
+    int gpsIndex = 0;
+    std::vector<Point2D> farTrace;
+
+
+
+
+
+
+    for (int i = 1; i < gpsTrace.size() - 1; i++)
+    {
+        sumdis += GetDistance(gpsTrace[i - 1], gpsTrace[i]);
+        if (sumdis > PreviewDistance)
+        {
+            gpsIndex = i;
+            break;
+        }
+    }
+
+
+
+
+    EPos = gpsTrace[gpsIndex].x;
+
+    for (unsigned int i = max(0, gpsIndex - 3); i < min((size_t)(gpsIndex + 3), gpsTrace.size()); i++) {
+        farTrace.push_back(gpsTrace[gpsIndex]);
+    }
+    if (farTrace.size() == 0) {
+        EAng = 0;
+    }
+    else {
+        EAng = getAveDef(farTrace);
+    }
+
+    ang = KEang * EAng + KEPos * EPos + DEang * (EAng - lastEA) + DEPos * (EPos - lastEP);
+
+    lastEA = EAng;
+    lastEP = EPos;
+
+    if (ang > angleLimit) {
+        ang = angleLimit;
+    }
+    else if (ang < -angleLimit) {
+        ang = -angleLimit;
+    }
+    if (lastAng != iv::MaxValue) {
+        ang = 0.2 * lastAng + 0.8 * ang;
+        //ODS("lastAng:%d\n", lastAng);
+    }
+    lastAng = ang;
+    return ang;
+}
+
+
+
+
+int  iv::decition::Compute00::getSpeedPointIndex(std::vector<Point2D> gpsTrace, double realSpeed)
+{
+    int index = 1;
+    double sumdis = 0;
+    while (index < gpsTrace.size() && sumdis < realSpeed)
+        sumdis += GetDistance(gpsTrace[index - 1], gpsTrace[index++]);
+
+    if (index == gpsTrace.size())
+        return index - 1;
+
+    if (abs(sumdis - realSpeed) > abs(sumdis - GetDistance(gpsTrace[index - 1], gpsTrace[index]) - realSpeed))
+        index--;
+    return index;
+}
+
+iv::Point2D iv::decition::Compute00::getLidarObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
+
+    iv::Point2D obsPoint(-1, -1);
+    vector<Point2D> gpsTraceLeft;
+    vector<Point2D> gpsTraceRight;
+    float xiuzheng=0;
+    if(!ServiceCarStatus.useMobileEye){
+        xiuzheng=0-ServiceCarStatus.msysparam.lidarGpsXiuzheng;
+    }
+
+
+    for (int j = 0; j < gpsTrace.size(); j++)
+    {
+        double sumx1 = 0, sumy1 = 0, count1 = 0;
+        double sumx2 = 0, sumy2 = 0, count2 = 0;
+        for (int k = max(0, j - 4); k <= j; k++)
+        {
+            count1 = count1 + 1;
+            sumx1 += gpsTrace[k].x;
+            sumy1 += gpsTrace[k].y;
+        }
+        for (unsigned int k = j; k <= min(gpsTrace.size() - 1, (size_t)(j + 4)); k++)
+        {
+            count2 = count2 + 1;
+            sumx2 += gpsTrace[k].x;
+            sumy2 += gpsTrace[k].y;
+        }
+        sumx1 /= count1; sumy1 /= count1;
+        sumx2 /= count2; sumy2 /= count2;
+
+        double anglevalue = atan2(sumy2 - sumy1, sumx2 - sumx1);
+
+        double carFrontx = gpsTrace[j].x;// -Form1.CarRear * Math.Cos(anglevalue);
+        double carFronty = gpsTrace[j].y;// -Form1.CarRear * Math.Sin(anglevalue);
+
+        Point2D ptLeft(carFrontx + Veh_Width / 2 * cos(anglevalue + PI / 2),
+                       carFronty + Veh_Width / 2 * sin(anglevalue + PI / 2));
+
+        Point2D ptRight(carFrontx + Veh_Width / 2 * cos(anglevalue - PI / 2),
+                        carFronty + Veh_Width / 2 * sin(anglevalue - PI / 2));
+
+        gpsTraceLeft.push_back(ptLeft);
+        gpsTraceRight.push_back(ptRight);
+
+    }
+
+
+    bool isRemove = false;
+
+    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
+    {
+
+        if (!isRemove && gpsTrace[j].y>ServiceCarStatus.msysparam.lidarGpsXiuzheng)
+        {
+            int count = 0;
+
+            for (double length = 0; length <= Veh_Width; length += 0.4)
+            {
+                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
+                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
+
+                //				int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;  //+(ptx / abs(ptx))) / 2左右多出一半的车宽(1米)
+                //				int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
+                int dx = (ptx + gridwide*(double)centerx)/gridwide;
+                int dy = (pty + gridwide*(double)centery+xiuzheng)/gridwide;
+
+                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
+                {
+                    //					if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
+                    if (lidarGridPtr[dx * (iv::gry) + dy].ob != 0)
+                    {
+                        count++; obsPoint.x = ptx; obsPoint.y = pty;
+                    }
+                }
+            }
+
+            j++;
+
+            for (double length = 0; length <= Veh_Width; length += 0.4)
+            {
+                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
+                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
+
+                //				int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;
+                //				int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
+                int dx = (ptx + gridwide*(double)centerx)/gridwide;
+                int dy = (pty + gridwide*(double)centery+xiuzheng)/gridwide;
+
+                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
+                {
+                    //					if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
+                    if (lidarGridPtr[dx * (iv::gry) + dy].ob != 0)
+                    {
+                        count++; obsPoint.x = ptx; obsPoint.y = pty;
+                    }
+                }
+            }
+
+            if (count >= 2)
+            {
+                obsPoint.x = gpsTrace[j].x;
+                obsPoint.y = gpsTrace[j].y;
+
+                isRemove = true;
+                //		DecideGps00().lidarDistance = obsPoint.y;
+                return obsPoint;
+            }
+        }
+    }
+    //	DecideGps00().lidarDistance = obsPoint.y;
+    return obsPoint;
+}
+
+//1220
+iv::Point2D iv::decition::Compute00::getLidarRearObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
+
+    iv::Point2D obsPoint(-1, -1);
+    vector<Point2D> gpsTraceLeft;
+    vector<Point2D> gpsTraceRight;
+    float xiuzheng=0;
+    if(!ServiceCarStatus.useMobileEye){
+        xiuzheng=0-ServiceCarStatus.msysparam.rearLidarGpsXiuzheng;
+    }
+    for (int j = 0; j < gpsTrace.size(); j++)
+    {
+        double sumx1 = 0, sumy1 = 0, count1 = 0;
+        double sumx2 = 0, sumy2 = 0, count2 = 0;
+        for (int k = max(0, j - 4); k <= j; k++)
+        {
+            count1 = count1 + 1;
+            sumx1 += gpsTrace[k].x;
+            sumy1 += gpsTrace[k].y;
+        }
+        for (unsigned int k = j; k <= min(gpsTrace.size() - 1, (size_t)(j + 4)); k++)
+        {
+            count2 = count2 + 1;
+            sumx2 += gpsTrace[k].x;
+            sumy2 += gpsTrace[k].y;
+        }
+        sumx1 /= count1; sumy1 /= count1;
+        sumx2 /= count2; sumy2 /= count2;
+
+        double anglevalue = atan2(sumy2 - sumy1, sumx2 - sumx1);
+
+        double carFrontx = gpsTrace[j].x;// -Form1.CarRear * Math.Cos(anglevalue);
+        double carFronty = gpsTrace[j].y;// -Form1.CarRear * Math.Sin(anglevalue);
+
+        Point2D ptLeft(carFrontx + (Veh_Width-0.3) / 2 * cos(anglevalue + PI / 2),
+                       carFronty + (Veh_Width-0.3) / 2 * sin(anglevalue + PI / 2));
+
+        Point2D ptRight(carFrontx + (Veh_Width-0.3) / 2 * cos(anglevalue - PI / 2),
+                        carFronty + (Veh_Width-0.3) / 2 * sin(anglevalue - PI / 2));
+
+        gpsTraceLeft.push_back(ptLeft);
+        gpsTraceRight.push_back(ptRight);
+
+    }
+
+
+    bool isRemove = false;
+
+    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
+    {
+
+        if (!isRemove && gpsTrace[j].y<(0-ServiceCarStatus.msysparam.rearGpsXiuzheng) )
+        {
+            int count = 0;
+
+            for (double length = 0; length <= Veh_Width; length += 0.4)
+            {
+                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
+                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
+
+                //				int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;  //+(ptx / abs(ptx))) / 2左右多出一半的车宽(1米)
+                //				int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
+                int dx = (ptx + gridwide*(double)centerx)/gridwide;
+
+                dx=grx-dx;//1227
+
+                int dy = (pty + gridwide*(double)centery+xiuzheng)/gridwide;
+
+                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
+                {
+                    //					if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
+                    if (lidarGridPtr[dx * (iv::gry) + dy].ob != 0)
+                    {
+                        count++; obsPoint.x = ptx; obsPoint.y = pty;
+                    }
+                }
+            }
+
+            j++;
+
+            for (double length = 0; length <= Veh_Width; length += 0.4)
+            {
+                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
+                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
+
+                //				int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;
+                //				int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
+                int dx = (ptx + gridwide*(double)centerx)/gridwide;
+
+                dx=grx-dx;//1227
+                int dy = (pty + gridwide*(double)centery+xiuzheng)/gridwide;
+
+                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
+                {
+                    //					if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
+                    if (lidarGridPtr[dx * (iv::gry) + dy].ob != 0)
+                    {
+                        count++; obsPoint.x = ptx; obsPoint.y = pty;
+                    }
+                }
+            }
+
+            if (count >= 2)
+            {
+                obsPoint.x = gpsTrace[j].x;
+                obsPoint.y = gpsTrace[j].y;
+
+                isRemove = true;
+                //		DecideGps00().lidarDistance = obsPoint.y;
+                return obsPoint;
+            }
+        }
+    }
+    //	DecideGps00().lidarDistance = obsPoint.y;
+    return obsPoint;
+}
+
+
+iv::Point2D iv::decition::Compute00::getLidarObsPointAvoid(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
+
+    iv::Point2D obsPoint(-1, -1);
+    vector<Point2D> gpsTraceLeft;
+    vector<Point2D> gpsTraceRight;
+    for (int j = 0; j < gpsTrace.size(); j++)
+    {
+        double sumx1 = 0, sumy1 = 0, count1 = 0;
+        double sumx2 = 0, sumy2 = 0, count2 = 0;
+        for (int k = max(0, j - 4); k <= j; k++)
+        {
+            count1 = count1 + 1;
+            sumx1 += gpsTrace[k].x;
+            sumy1 += gpsTrace[k].y;
+        }
+        for (unsigned int k = j; k <= min(gpsTrace.size() - 1, (size_t)(j + 4)); k++)
+        {
+            count2 = count2 + 1;
+            sumx2 += gpsTrace[k].x;
+            sumy2 += gpsTrace[k].y;
+        }
+        sumx1 /= count1; sumy1 /= count1;
+        sumx2 /= count2; sumy2 /= count2;
+
+        double anglevalue = atan2(sumy2 - sumy1, sumx2 - sumx1);
+
+        double carFrontx = gpsTrace[j].x;// -Form1.CarRear * Math.Cos(anglevalue);
+        double carFronty = gpsTrace[j].y;// -Form1.CarRear * Math.Sin(anglevalue);
+
+        //1127 fanwei xiuzheng
+        float buchang=0;
+        Point2D ptLeft(carFrontx + (Veh_Width+(buchang)*2) / 2 * cos(anglevalue + PI / 2),
+                       carFronty +  (Veh_Width+(buchang)*2) / 2 * sin(anglevalue + PI / 2));
+
+        Point2D ptRight(carFrontx +  (Veh_Width+(buchang)*2) / 2 * cos(anglevalue - PI / 2),
+                        carFronty +  (Veh_Width+(buchang)*2) / 2 * sin(anglevalue - PI / 2));
+
+        gpsTraceLeft.push_back(ptLeft);
+        gpsTraceRight.push_back(ptRight);
+
+    }
+
+
+    bool isRemove = false;
+
+    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
+    {
+
+        if (!isRemove && gpsTrace[j].y>2.5 && gpsTraceLeft[j].y>2.5 && gpsTraceRight[j].y>2.5)
+        {
+            int count = 0;
+
+            for (double length = 0; length <= Veh_Width; length += 0.4)
+            {
+                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
+                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
+
+                int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;  //*2左右多出一半的车宽(1米)
+                int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
+
+                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
+                {
+                    if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
+                    {
+                        count++; obsPoint.x = ptx; obsPoint.y = pty;
+                    }
+                }
+            }
+
+            j++;
+
+            for (double length = 0; length <= Veh_Width; length += 0.4)
+            {
+                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
+                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
+
+                int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;
+                int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
+
+                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
+                {
+                    if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
+                    {
+                        count++; obsPoint.x = ptx; obsPoint.y = pty;
+                    }
+                }
+            }
+
+            if (count >= 2)
+            {
+                obsPoint.x = gpsTrace[j].x;
+                obsPoint.y = gpsTrace[j].y;
+
+                isRemove = true;
+                DecideGps00().lidarDistanceAvoid = obsPoint.y;
+                return obsPoint;
+            }
+        }
+    }
+    //	DecideGps00().lidarDistanceAvoid = obsPoint.y;
+
+    return obsPoint;
+}
+
+
+
+
+//int  iv::decition::Compute00::getEsrIndex(std::vector<Point2D> gpsTrace, std::vector<ObstacleBasic> esrRadars) {
+//	bool isRemove = false;
+//
+//	for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
+//	{
+//
+//		for (int i = 0; i < esrRadars.size(); i++)
+//			if ((esrRadars[i].nomal_y) != 0)
+//			{
+//				double xxx = esrRadars[i].nomal_x + Esr_Offset;
+//				double yyy = esrRadars[i].nomal_y;
+//
+//				if (abs(xxx - gpsTrace[j].x) <= 3.0*Veh_Width / 4.0 && abs(yyy - (gpsTrace[j].y)) <= 1)
+//				{
+//
+//					if (lastEsrID == (esrRadars[i]).esr_ID)
+//					{
+//						lastEsrCount++;
+//					}
+//					else
+//					{
+//						lastEsrCount = 0;
+//					}
+//
+//					if (lastEsrCount >= 3)
+//					{
+//						return i;
+//					}
+//
+//					lastEsrID = (esrRadars[i]).esr_ID;
+//				}
+//			}
+//	}
+//	return -1;
+//}
+
+
+
+
+int  iv::decition::Compute00::getEsrIndex(std::vector<Point2D> gpsTrace,int roadNum,int *esrPathpoint) {
+    bool isRemove = false;
+
+    float xiuzheng=0;
+    if(!ServiceCarStatus.useMobileEye){
+        xiuzheng=ServiceCarStatus.msysparam.radarGpsXiuzheng;
+    }
+
+    float fxiuzhengCs = DecideGps00().xiuzhengCs;
+    int nsize = gpsTrace.size();
+    for (int j = 1; j < nsize - 1 && !isRemove; j++)
+    {
+
+        for (int i = 0; i < 64; i++)
+            if ((ServiceCarStatus.obs_radar[i].nomal_y) != 0 && (ServiceCarStatus.obs_radar[i].valid))
+            {
+                double xxx = ServiceCarStatus.obs_radar[i].nomal_x + Esr_Offset;
+                double yyy = ServiceCarStatus.obs_radar[i].nomal_y+ xiuzheng;
+
+                /*ODS("\nESR毫米波检测物体X距离:%f\n", xxx);
+                ODS("\nESR毫米波检测物体Y距离:%f\n", yyy);*/
+
+//优化
+//                if(sqrt((xxx - gpsTrace[j].x)*(xxx - gpsTrace[j].x) + (yyy - gpsTrace[j].y)*(yyy - gpsTrace[j].y)) < (1.0*Veh_Width / 2.0+DecideGps00().xiuzhengCs)){
+//                    *esrPathpoint = j;
+//                    return i;
+//                }
+
+
+                if (abs(xxx - gpsTrace[j].x) <= (3.0*Veh_Width / 4.0+fxiuzhengCs) && abs(yyy - (gpsTrace[j].y)) <= 1)
+                {
+
+                    if (lastEsrID == i)
+                    {
+                        lastEsrCount++;
+                    }
+                    else
+                    {
+                        lastEsrCount = 0;
+                    }
+
+                    if(yyy>50 ){
+                        if (lastEsrCount >=200)
+                        {
+                            return i;
+                        }
+                    }
+                    else if (lastEsrCount >= 1)
+                    {
+                        return i;
+                    }
+
+                    lastEsrID = i;
+                }
+            }
+    }
+    return -1;
+}
+
+
+
+
+int  iv::decition::Compute00::getRearEsrIndex(std::vector<Point2D> gpsTrace,int roadNum) {
+    bool isRemove = false;
+
+    float xiuzheng = ServiceCarStatus.msysparam.rearRadarGpsXiuzheng;
+    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
+    {
+
+        for (int i = 0; i < 64; i++)
+            if ((ServiceCarStatus.obs_rear_radar[i].nomal_y) != 0 && (ServiceCarStatus.obs_rear_radar[i].valid))
+            {
+                double xxx = 0-(ServiceCarStatus.obs_rear_radar[i].nomal_x + Esr_Offset);
+                double yyy = 0-(ServiceCarStatus.obs_rear_radar[i].nomal_y+ xiuzheng);
+
+                if(ServiceCarStatus.msysparam.mvehtype=="qingyuan"){
+                    xxx=0-xxx;
+                }
+
+                /*ODS("\nESR毫米波检测物体X距离:%f\n", xxx);
+                ODS("\nESR毫米波检测物体Y距离:%f\n", yyy);*/
+
+
+                if (abs(xxx - gpsTrace[j].x) <= (3.0*Veh_Width / 4.0+DecideGps00().xiuzhengCs) && abs(yyy - (gpsTrace[j].y)) <= 1)
+                {
+
+                    if (lastEsrID == i)
+                    {
+                        lastEsrCount++;
+                    }
+                    else
+                    {
+                        lastEsrCount = 0;
+                    }
+
+                    if(yyy>50 ){
+                        if (lastEsrCount >=200)
+                        {
+                            return i;
+                        }
+                    }
+                    else if (lastEsrCount >= 1)
+                    {
+                        return i;
+                    }
+
+                    lastEsrID = i;
+                }
+            }
+    }
+    return -1;
+}
+
+
+
+
+
+//int  iv::decition::Compute00::getEsrIndex(std::vector<Point2D> gpsTrace,int roadNum) {
+//    bool isRemove = false;
+
+//    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
+//    {
+
+//        for (int i = 0; i < 64; i++)
+//            if ((examed_obs_radar[i].nomal_y) != 0 && (examed_obs_radar[i].valid))
+//            {
+//                double xxx = examed_obs_radar[i].nomal_x + Esr_Offset;
+//                double yyy = examed_obs_radar[i].nomal_y+ Esr_Y_Offset;
+
+//                /*ODS("\nESR毫米波检测物体X距离:%f\n", xxx);
+//                ODS("\nESR毫米波检测物体Y距离:%f\n", yyy);*/
+
+
+//                if (abs(xxx - gpsTrace[j].x) <= 3.0*Veh_Width / 4.0 && abs(yyy - (gpsTrace[j].y)) <= 1)
+//                {
+
+//                    if (lastEsrID == i)
+//                    {
+//                        lastEsrCount++;
+//                    }
+//                    else
+//                    {
+//                        lastEsrCount = 0;
+//                    }
+
+//                    if(yyy>50 ){
+//                        if (lastEsrCount >=200)
+//                        {
+//                            return i;
+//                        }
+//                    }
+//                    else if (lastEsrCount >= 3)
+//                    {
+//                        return i;
+//                    }
+
+//                    lastEsrID = i;
+//                }
+//            }
+//    }
+//    return -1;
+//}
+
+
+
+int  iv::decition::Compute00::getEsrIndexAvoid(std::vector<Point2D> gpsTrace) {
+    bool isRemove = false;
+
+    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
+    {
+
+        for (int i = 0; i < 64; i++)
+            if ((ServiceCarStatus.obs_radar[i].nomal_y) != 0 && (ServiceCarStatus.obs_radar[i].valid))
+            {
+                double xxx = ServiceCarStatus.obs_radar[i].nomal_x + Esr_Offset;
+                double yyy = ServiceCarStatus.obs_radar[i].nomal_y;
+
+                if (abs(xxx - gpsTrace[j].x) <= 3.0*Veh_Width / 4.0 && abs(yyy - (gpsTrace[j].y)) <= 1)
+                {
+
+                    if (lastEsrIDAvoid == i)
+                    {
+                        lastEsrCountAvoid++;
+                    }
+                    else
+                    {
+                        lastEsrCountAvoid = 0;
+                    }
+
+                    if (lastEsrCountAvoid >= 6)
+                    {
+                        return i;
+                    }
+
+                    lastEsrIDAvoid = i;
+                }
+            }
+    }
+    return -1;
+}
+
+
+
+
+
+
+
+//double iv::decition::Compute00::getObsSpeed(Point2D obsPoint, std::vector<ObstacleBasic> esrRadars,double realSecSpeed) {
+//	double obsSpeed = 0 - realSecSpeed;
+//	double minDis = iv::MaxValue;
+//	for (int i = 0; i < esrRadars.size(); i++)
+//		if ((esrRadars[i].nomal_y) != 0)
+//		{
+//			double xxx = esrRadars[i].nomal_x + Esr_Offset;
+//			double yyy = esrRadars[i].nomal_y;
+//
+//			if (abs(xxx - obsPoint.x) < 4 && abs(yyy - obsPoint.y) < 2)
+//			{
+//				double tmpDis =sqrt((xxx - obsPoint.x) * (xxx - obsPoint.x) + (yyy - obsPoint.y) * (yyy - obsPoint.y));
+//				if (tmpDis < minDis)
+//				{
+//					minDis = tmpDis;
+//					obsSpeed = esrRadars[i].speed_y;
+//				}
+//			}
+//		}
+//
+//	return obsSpeed;
+//
+//
+//}
+
+
+
+
+double iv::decition::Compute00::getObsSpeed(Point2D obsPoint, double realSecSpeed) {
+    double obsSpeed = 0 - realSecSpeed;
+    double minDis = iv::MaxValue;
+    for (int i = 0; i < 64; i++)
+        if ((ServiceCarStatus.obs_radar[i].nomal_y) != 0 && ServiceCarStatus.obs_radar[i].valid)
+        {
+            double xxx = ServiceCarStatus.obs_radar[i].nomal_x + Esr_Offset;
+            double yyy = ServiceCarStatus.obs_radar[i].nomal_y + Esr_Y_Offset;
+
+            if (abs(xxx - obsPoint.x) < 4 && abs(yyy - obsPoint.y) < 2)
+            {
+                double tmpDis = sqrt((xxx - obsPoint.x) * (xxx - obsPoint.x) + (yyy - obsPoint.y) * (yyy - obsPoint.y));
+                if (tmpDis < minDis)
+                {
+                    minDis = tmpDis;
+                    obsSpeed = ServiceCarStatus.obs_radar[i].speed_y;
+                }
+            }
+        }
+
+    return obsSpeed;
+}
+
+
+
+
+double iv::decition::Compute00::getDecideAvoidAngle(std::vector<Point2D>  gpsTrace, double realSpeed, float avoidX) {
+
+    double ang = 0;
+    double EPos = 0, EAng = 0;
+
+    double KEang = 14, KEPos = 10, DEang = 0, DEPos = 0;
+
+    double PreviewDistance = max(6.0, realSpeed / 3.6 * 1.8);//预瞄距离
+
+
+    if (gpsTrace[0].v1 == 1)
+    {
+        KEang = 10; KEPos = 8;
+        if (realSpeed > 60) KEang = 5;
+    }
+    else if (gpsTrace[0].v1 == 2 || gpsTrace[0].v1 == 3)
+    {
+        KEang = 14; KEPos = 10;
+    }
+    else if (gpsTrace[0].v1 == 4 || gpsTrace[0].v1 == 5)
+    {
+        KEang = 14; KEPos = 10;
+    }
+    else if (gpsTrace[0].v1 == 7 && (gpsTrace[0].v2 == 23 || gpsTrace[0].v2 == 24))
+    {
+        KEang = 18; KEPos = 50; PreviewDistance = 3;
+    }
+    else if (gpsTrace[0].v1 == 7)
+    {
+        KEang = 20; KEPos = 50; PreviewDistance = 4;
+    }
+
+
+    double sumdis = 0;
+    int gpsIndex = 0;
+    std::vector<Point2D> farTrace;
+
+
+
+
+
+
+    for (int i = 1; i < gpsTrace.size() - 1; i++)
+    {
+        sumdis += GetDistance(gpsTrace[i - 1], gpsTrace[i]);
+        if (sumdis > PreviewDistance)
+        {
+            gpsIndex = i;
+            break;
+        }
+    }
+
+    if ((DecideGps00().readyParkMode) && (gpsIndex + 10>DecideGps00().gpsLineParkIndex))
+    {
+        gpsIndex = DecideGps00().gpsLineParkIndex;
+    }
+
+
+
+    EPos = gpsTrace[gpsIndex].x + avoidX;
+
+    for (unsigned int i = max(0, gpsIndex - 3); i < min((size_t)(gpsIndex + 3), gpsTrace.size()); i++) {
+        farTrace.push_back(gpsTrace[gpsIndex]);
+    }
+    if (farTrace.size() == 0) {
+        EAng = 0;
+    }
+    else {
+        EAng = getAvoidAveDef(farTrace, avoidX);
+    }
+
+    ang = KEang * EAng + KEPos * EPos + DEang * (EAng - lastEA) + DEPos * (EPos - lastEP);
+
+    lastEA = EAng;
+    lastEP = EPos;
+
+    if (ang > angleLimit) {
+        ang = angleLimit;
+    }
+    else if (ang < -angleLimit) {
+        ang = -angleLimit;
+    }
+    if (lastAng != iv::MaxValue) {
+        ang = 0.2 * lastAng + 0.8 * ang;
+        //ODS("lastAng:%d\n", lastAng);
+    }
+    lastAng = ang;
+
+    return ang;
+}
+
+
+std::vector<iv::GPSData>   iv::decition::Compute00::getBesideGpsMapLine(iv::GPS_INS now_gps_ins, vector<iv::GPSData>gpsMapLine, float avoidX) {
+
+    vector<vector<iv::GPSData>> maps;
+    vector<iv::GPSData> gpsMapLineBeside;
+    int sizeN = gpsMapLine.size();
+    for (int i = 1; i < sizeN; i++)
+    {
+        iv::GPSData gpsData(new GPS_INS);
+        double xx = gpsMapLine[i]->gps_x - now_gps_ins.gps_x;
+        double yy = gpsMapLine[i]->gps_y - now_gps_ins.gps_y;
+        double lng = ServiceCarStatus.location->ins_heading_angle;
+
+
+        double x0 = xx * cos(lng * PI / 180) - yy * sin(lng * PI / 180);
+        double y0 = xx * sin(lng * PI / 180) + yy * cos(lng * PI / 180);
+        double k1 = sin((90 + (gpsMapLine[i]->ins_heading_angle - lng)) * PI / 180);
+        double k2 = cos((90 + (gpsMapLine[i]->ins_heading_angle - lng)) * PI / 180);
+
+        //	memcpy(&gpsData, &gpsMapLine[i], sizeof(gpsData));
+
+        gpsData->speed_mode = gpsMapLine[i]->speed_mode;
+        gpsData->gps_x = x0 + k1 * avoidX;
+        gpsData->gps_y = y0 + k2 * avoidX;
+        gpsMapLineBeside.push_back(gpsData);
+
+    }
+    return gpsMapLineBeside;
+
+}
+
+
+
+//double iv::decition::Compute00::getDecideAngleByLane(double realSpeed) {
+
+//    double ang = 0;
+//    double EPos = 0, EAng = 0;
+
+// //   double KEang = 14, KEpos = 10, DEang = 0, DEpos = 0;
+//       double KEang = 5, KEPos = 30, DEang = 0, DEPos = 0;
+
+// //   double PreviewDistance = max(6.0, realSpeed / 3.6 * 1.8);//预瞄距离
+
+//    double PreviewDistance;//预瞄距离
+//    realSpeed > 40 ? PreviewDistance = max(6.0, realSpeed *0.6) : PreviewDistance = max(6.0, realSpeed *0.5);
+
+
+
+
+
+////    if (realSpeed > 40)	KEang = 10; KEpos = 8;
+////        if (realSpeed > 50) KEang = 5;
+
+
+
+
+
+//double c1 = ServiceCarStatus.aftermarketLane.dist_to_lane_l;
+//double c2 = ServiceCarStatus.aftermarketLane.dist_to_lane_r;
+//double a = ServiceCarStatus.Lane.curvature;
+//double b = ServiceCarStatus.Lane.heading;
+//double c = (c1+c2)*0.5;
+//double x= PreviewDistance;
+//double y;
+
+
+//y=a*x*x+b*x+c;
+
+//   // EPos = y;
+//EPos=c;
+
+
+//  //  EAng=atan(2*a*x+b) / PI * 180;
+//    EAng=ServiceCarStatus.Lane.yaw;
+//        ang = KEang * EAng + KEPos * EPos + DEang * (EAng - lastEA) + DEPos * (EPos - lastEP);
+
+//        lastEA = EAng;
+//        lastEP = EPos;
+
+
+//           std::cout << "\nEPos:%f\n" << EPos << std::endl;
+//            std::cout << "\nEAng:%f\n" << EAng << std::endl;
+
+
+//        if (ang > angleLimit) {
+//            ang = angleLimit;
+//        }
+//        else if (ang < -angleLimit) {
+//            ang = -angleLimit;
+//        }
+//        if (lastAng != iv::MaxValue) {
+//            ang = 0.2 * lastAng + 0.8 * ang;
+//            //ODS("lastAng:%d\n", lastAng);
+//        }
+//        lastAng = ang;
+//        return ang;
+//    }
+
+
+
+double IEPos = 0, IEang = 0;
+
+
+double iv::decition::Compute00::getDecideAngleByLanePID(double realSpeed) {
+
+    double ang = 0;
+    double EPos = 0, EAng = 0;
+    double Curve=0;
+    double KEang = 14, KEPos = 10, DEang = 0, DEPos = 0;
+    double KCurve=120;
+    double KIEPos = 0, KIEang = 0;
+    //   double PreviewDistance = max(6.0, realSpeed / 3.6 * 1.8);//预瞄距离
+
+    double PreviewDistance;//预瞄距离
+
+    int confL=ServiceCarStatus.aftermarketLane.lane_conf_left;
+    int confR=ServiceCarStatus.aftermarketLane.lane_conf_right;
+    int conf =min(confL,confR);
+
+    realSpeed > 40 ? PreviewDistance = max(6.0, realSpeed *0.6) : PreviewDistance = max(6.0, realSpeed *0.5);
+
+
+
+
+
+    if (realSpeed > 40)	KEang = 10; KEPos = 8;
+    if (realSpeed > 50) KEang = 5;
+
+    KEPos = 20;
+    KEang = 200;
+    //KEang = 15;
+
+    double c1 = ServiceCarStatus.aftermarketLane.dist_to_lane_l;
+    double c2 = ServiceCarStatus.aftermarketLane.dist_to_lane_r;
+    double a = ServiceCarStatus.Lane.curvature;
+    double b = ServiceCarStatus.Lane.heading;
+    double c = (c1+c2)*0.5;
+    double yaw= ServiceCarStatus.Lane.yaw;
+
+    double x= PreviewDistance;
+    double y;
+
+
+    y=c-(a*x*x+b*x);
+    double difa=0-(atan(2*a*x+b) / PI * 180);
+    Curve=0-a;
+
+    //EAng=difa;
+    //EPos=y;
+    EAng= 0-b;
+    EPos = c;
+    DEang = 10;
+    DEPos = 20;
+    //DEang = 20;
+    //DEPos = 10;
+
+    IEang = EAng+0.7*IEang;
+    IEPos = EPos+0.7*IEPos;
+    KIEang = 0;
+    //KIEang = 0.5;
+    KIEPos =2;
+
+
+
+    if(abs(confL)>=2&&abs(confR)>=2){
+        //ang = KEang * EAng + KEPos * EPos + DEang * (EAng - lastEA) + DEPos * (EPos - lastEP)+ KIEang * IEang + KIEPos * IEPos;
+        ang = KEang * EAng + KEPos * EPos +KCurve*Curve+ DEang * (EAng - lastEA) + DEPos * (EPos - lastEP)+ KIEang * IEang + KIEPos * IEPos;
+    }else{
+        ang=lastAng;
+    }
+    //if(lastAng!=0&&abs(ang-lastAng)>20)ang=lastAng;
+
+    lastEA = EAng;
+    lastEP = EPos;
+
+    if (ang > angleLimit) {
+        ang = angleLimit;
+    }
+    else if (ang < -angleLimit) {
+        ang = -angleLimit;
+    }
+    if (lastAng != iv::MaxValue) {
+        ang = 0.2 * lastAng + 0.8 * ang;
+        //ODS("lastAng:%d\n", lastAng);
+    }
+    lastAng = ang;
+    return ang;
+}
+
+
+
+double iv::decition::Compute00::bocheCompute(GPS_INS nowGps, GPS_INS aimGps) {
+
+    GaussProjCal(aimGps.gps_lng, aimGps.gps_lat, &aimGps.gps_x, &aimGps.gps_y);
+    Point2D pt = Coordinate_Transfer(nowGps.gps_x, nowGps.gps_y, aimGps);
+
+
+
+    double x_1 = pt.x;
+    double y_1 = pt.y;
+    double angle_1 = getQieXianAngle(nowGps,aimGps);
+    double x_2 = 0.0, y_2 = 0.0;
+    double steering_angle;
+    double l = 2.950;
+    double r =6;
+    double x_o, y_o, x_o_1, y_o_1, x_o_2, y_o_2, x_3, y_3;
+    double x_t_n, y_t_n, x_t_f, y_t_f;//近切点和远切点
+    double x_t_1, y_t_1, x_t_2, y_t_2;//圆形1的切点
+    double x_t_3, y_t_3, x_t_4, y_t_4;//圆形2的切点
+    double g_1 = tan(angle_1);
+    double car_pos[3] = { x_1,y_1,g_1 };
+    double parking_pos[2] = { x_2,y_2 };
+    double g_3;
+    double t[4][2];
+    double p[4];
+    double  s1, s2; //切点与车起始位置的距离
+    double  min;
+    int  min_i;
+
+    //g_3 = 0 - 0.5775;
+    g_3 = pingfenxian_xielv(x_1, y_1, x_2, y_2, angle_1);
+    //交点
+    x_3 = 0.0;//(y_1 - y_2 + g_2*x_2 - g_1*x_1) / (g_2 - g_1);
+    y_3 = y_1 - g_1 * x_1;
+    //圆心1
+    x_o_1 = r;
+    y_o_1 = g_3 * r + y_3;
+    //圆形1的切点1
+    x_t_1 = 0.0;
+    y_t_1 = g_3 * r + y_3;
+    //圆形1的切点2
+    if (g_1 == 0)
+    {
+        x_t_2 = r;
+        y_t_2 = y_1 - g_1 * x_1;
+    }
+    else
+    {
+        y_t_2 = (y_1 + g_1 * x_o_1 + y_o_1 * g_1*g_1 - g_1 * x_1) / (1 + g_1 * g_1);
+        x_t_2 = (y_t_2 + g_1 * x_1 - y_1) / g_1;
+
+    }
+    //圆心2
+    x_o_2 = 0 - r;
+    y_o_2 = y_3 - g_3 * r;
+    //圆形2的切点1
+    x_t_3 = 0;
+    y_t_3 = y_3 - g_3 * r;
+    //圆形2的切点2
+    if (g_1 == 0)
+    {
+        x_t_4 = 0 - r;
+        y_t_4 = y_1 - g_1 * x_1;
+    }
+    else
+    {
+        y_t_4 = (y_1 + g_1 * x_o_2 + y_o_2 * g_1*g_1 - g_1 * x_1) / (1 + g_1 * g_1);
+        x_t_4 = (y_t_4 + g_1 * x_1 - y_1) / g_1;
+
+    }
+    t[0][0] = x_t_1;
+    t[0][1] = y_t_1;
+    t[1][0] = x_t_2;
+    t[1][1] = y_t_2;
+    t[2][0] = x_t_3;
+    t[2][1] = y_t_3;
+    t[3][0] = x_t_4;
+    t[3][1] = y_t_4;
+    for (int i = 0; i < 4; i++)
+    {
+
+        p[i] = (t[i][0] - parking_pos[0])*(t[i][0] - parking_pos[0]) + (t[i][1] - parking_pos[1])*(t[i][1] - parking_pos[1]);
+
+    }
+    min = p[0];
+    min_i = 0;
+    for (int i = 1; i < 4; i++)
+    {
+
+        if (p[i] < min)
+        {
+            min = p[i]; min_i = i;
+        }
+    }
+    if (min_i < 2)
+    {
+        x_o = x_o_1;
+        y_o = y_o_1;
+        s1 = (x_t_1 - x_1)*(x_t_1 - x_1) + (y_t_1 - y_1)*(y_t_1 - y_1);
+        s2 = (x_t_2 - x_1)*(x_t_2 - x_1) + (y_t_2 - y_1)*(y_t_2 - y_1);
+        if (s1 < s2)
+        {
+            x_t_n = x_t_1;
+            y_t_n = y_t_1;
+            x_t_f = x_t_2;
+            y_t_f = y_t_2;
+        }
+        else
+        {
+            x_t_n = x_t_2;
+            y_t_n = y_t_2;
+            x_t_f = x_t_1;
+            y_t_f = y_t_1;
+
+        }
+    }
+    else
+    {
+        x_o = x_o_2;
+        y_o = y_o_2;
+        s1 = (x_t_3 - x_1)*(x_t_3 - x_1) + (y_t_3 - y_1)*(y_t_3 - y_1);
+        s2 = (x_t_4 - x_1)*(x_t_4 - x_1) + (y_t_4 - y_1)*(y_t_4 - y_1);
+
+        if (s1 < s2)
+        {
+
+            x_t_n = x_t_3;
+            y_t_n = y_t_3;
+            x_t_f = x_t_4;
+            y_t_f = y_t_4;
+        }
+        else
+        {
+            x_t_n = x_t_4;
+            y_t_n = y_t_4;
+            x_t_f = x_t_3;
+            y_t_f = y_t_3;
+        }
+
+
+
+
+    }
+    steering_angle = atan2(l, r);
+
+    if (x_t_n < 0)
+    {
+        steering_angle = 0 - steering_angle;
+    }
+
+    nearTpoint=Coordinate_UnTransfer(x_t_n, y_t_n, aimGps);
+    farTpoint = Coordinate_UnTransfer(x_t_f, y_t_f, aimGps);
+    bocheAngle = steering_angle*180/PI;
+
+    cout << "近切点:x_t_n=" << x_t_n << endl;
+    cout << "近切点:y_t_n=" << y_t_n << endl;
+    cout << "远切点:x_t_f=" << x_t_f << endl;
+    cout << "远切点:y_t_f=" << y_t_f << endl;
+    cout << "航向角:" << steering_angle << endl;
+
+
+    //    if (x_1 < 0 && y_1 > 0 && x_1 < x_t_n &&y_t_f > 0.1) {
+    //        return 1;
+    //    }
+    Point2D ptN = Coordinate_Transfer(nearTpoint.gps_x, nearTpoint.gps_y, nowGps);
+    double disA = GetDistance(aimGps,nowGps);
+    if(y_t_n>0 && ptN.y<0 && y_t_f>0.1 && disA<40){
+        return 1;
+    }
+
+    return 0;
+
+}
+
+
+
+//返回垂直平分线的斜率
+double iv::decition::Compute00::pingfenxian_xielv(double x_1, double y_1, double x_2, double y_2, double angle_1) {
+    double angl, x_3, angle_3;
+    if (tan(angle_1 == 0))
+    {
+        if ((x_1 - x_2) > 0 && ((y_1 - y_2) > 0))
+        {
+            angle_3 = 0 - 1;
+        }
+        else
+        {
+            angle_3 = 1;
+        }
+    }
+    else
+    {
+        x_3 = (tan(angle_1)*x_1 - y_1) / tan(angle_1);//车所在直线与x轴交点
+        angl = tan(angle_1);//车所在直线的斜率
+        if ((x_1 - x_2)>0 && ((y_1 - y_2)>0))//第一象限
+        {
+            if ((angl *x_3)<0)//车斜率与车直线的x轴交点异号
+            {
+                if (angl < 0)
+                {
+                    angle_3 = tan(PI*0.5 + (PI*0.5 - atan(fabs(angl))) *0.5);//垂直平分线斜率
+                }
+                else
+                {
+                    angle_3 = tan(PI*0.5 + (PI*0.5 + atan(fabs(angl))) *0.5);//垂直平分线斜率
+                }
+
+
+
+            }
+
+        }
+        else//第二象限
+        {
+            if ((angl*x_3)<0)//车斜率与车直线的x轴交点异号
+            {
+                if (angl < 0)
+                {
+                    angle_3 = tan(PI*0.5 - (PI*0.5 + atan(fabs(angl))) *0.5);//垂直平分线斜率
+                }
+                else
+                {
+                    angle_3 = tan(atan(fabs(angl)) + (PI*0.5 - atan(fabs(angl))) *0.5);//垂直平分线斜率
+                }
+
+            }
+        }
+    }
+
+    return angle_3;
+
+}
+
+
+
+double iv::decition::Compute00::getQieXianAngle(GPS_INS nowGps, GPS_INS aimGps) {
+    double heading = nowGps.ins_heading_angle *PI/180;
+    double x1 = nowGps.gps_x;
+    double y1 = nowGps.gps_y;
+    if (heading<=PI*0.5)
+    {
+        heading = 0.5*PI - heading;
+    }
+    else if (heading>PI*0.5 && heading<=PI*1.5) {
+        heading = 1.5*PI - heading;
+    }
+    else if (heading>PI*1.5) {
+        heading = 2.5*PI - heading;
+    }
+    double k1 = tan(heading);
+    double x = x1+10;
+    double y = k1 * x + y1 - (k1 * x1);
+    Point2D pt1 = Coordinate_Transfer(nowGps.gps_x, nowGps.gps_y, aimGps);
+    Point2D pt2 = Coordinate_Transfer(x, y, aimGps);
+    double xielv = (pt1.y - pt2.y) / (pt1.x - pt2.x);
+    double angle = atan(abs(xielv));
+    if (xielv<0)
+    {
+        angle = PI - angle;
+    }
+    return angle;
+
+}
+
+
+/*
+  chuizhicheweiboche
+  */
+
+
+int iv::decition::Compute00::bocheDirectCompute(GPS_INS nowGps, GPS_INS aimGps)
+{
+
+
+
+    double l=2.95;//轴距
+    double x_0 = 0, y_0 = 0.5;
+    double x_1, y_1;//车起点坐标
+    double ange1;//车航向角弧度
+    double x_2, y_2;//另一条与车直线在angle2和R_M 固定情况下过坐标点,第二个近切点
+    double real_rad;;//另一条直线的航向角弧度
+    double angle_3;//垂直平分线弧度
+    double x_3, y_3;//垂直平分线交点
+    double x_4, y_4;//另一条直线的远切点坐标,第二个远切点,已知
+    double x_o_1, y_o_1;//圆形1坐标
+    double x_o_2, y_o_2;//圆形2坐标
+    double x_t_n, y_t_n, x_t_f, y_t_f;//近切点和远切点
+    double min_rad;
+    double R_M; //后轴中点的转弯半径
+    double steering_angle;
+
+
+
+
+    GaussProjCal(aimGps.gps_lng, aimGps.gps_lat, &aimGps.gps_x, &aimGps.gps_y);
+    Point2D pt = Coordinate_Transfer(nowGps.gps_x, nowGps.gps_y, aimGps);
+    x_1=pt.x;
+    y_1=pt.y;
+    ange1=getQieXianAngle(nowGps,aimGps);
+
+    min_rad_zhuanxiang(&R_M , &min_rad);
+    qiedian_n(x_1,y_1,R_M,min_rad,&x_2 , &y_2, &real_rad);//计算另一条与车直线在angle2和R_M 固定情况下近切点:x_2, y_2
+    liangzhixian_jiaodian( x_1, y_1,  x_2, y_2,ange1,real_rad,&x_3 , &y_3);
+    chuizhipingfenxian_xielv( x_1, y_1, ange1, real_rad, min_rad,&angle_3);
+    yuanxin( x_2, y_2, x_3, y_3, real_rad, angle_3, R_M,&x_o_1,&y_o_1,&x_o_2,&y_o_2);
+    yuanxin_qiedian( ange1, x_o_1, y_o_1,  x_o_2, y_o_2,
+                     x_1, y_1, x_2, y_2, x_3, y_3, real_rad, angle_3, R_M,&x_t_n,&y_t_n,&x_t_f, &y_t_f);
+    steering_angle = atan2(l, R_M);
+    x_4 = 0.5;
+    y_4 = 0;
+    //for (int i = 0; i < 4; i++)
+    //{
+    //for (int j = 0; j < 2; j++)
+    //{
+    //	cout << t[i][j] << endl;
+    //}
+    //}
+    //cout << "min_rad:" << min_rad<< endl;
+    //cout << "jiaodian:x=" << x_3 << endl;
+    //cout << "jiaodian:y=" << y_3 << endl;
+    // cout << "R-M:" << R_M << endl;
+    cout << "x_0:" << x_0 << endl;
+    cout << "y_0:" << y_0 << endl;
+    cout << "x_2:" << x_2 << endl;
+    cout << "y_2:" << y_2 << endl;
+    cout << "近切点:x_t_n="<< x_t_n << endl;
+    cout << "近切点:y_t_n=" << y_t_n << endl;
+    cout << "远切点:x_t_f=" << x_t_f << endl;
+    cout << "远切点:y_t_f=" << y_t_f << endl;
+    //cout << "航向角:" << steering_angle << endl;
+    //cout << "圆心1横坐标=" << x_o_1 << endl;
+    //cout << "圆心1纵坐标=" << y_o_1 << endl;
+    //cout << "圆心2横坐标=" << x_o_2 << endl;
+    //cout << "圆心2纵坐标=" << y_o_2 << endl;
+    //cout << "平分线弧度=" << angle_3 << endl;
+    //cout << " min_rad=" << min_rad << endl;
+    //cout << " real_rad=" << real_rad << endl;
+    //   system("PAUSE");
+
+
+
+    dTpoint0=Coordinate_UnTransfer(x_t_n, y_t_n, aimGps);
+    dTpoint1 = Coordinate_UnTransfer(x_t_f, y_t_f, aimGps);
+    dTpoint2 = Coordinate_UnTransfer(x_2, y_2, aimGps);
+    dTpoint3 = Coordinate_UnTransfer(x_0, y_0, aimGps);
+    dBocheAngle = steering_angle*180/PI;
+
+    double disA = GetDistance(aimGps,nowGps);
+
+    if(pt.y>y_t_n && x_t_f<x_2 && y_t_f>y_2&&disA<40){
+        return 1;
+    }
+    return 0;
+
+}
+
+
+double iv::decition::Compute00::min_rad_zhuanxiang(double *R_M, double *min_rad) {
+    double L_c = 4.749;//车长
+    double rad_1;
+    double rad_2;
+    double L_k = 1.931;//车宽
+    double L = 2.95;//轴距
+    double L_f =1.2 ;//前悬
+    double L_r =0.7 ;//后悬
+    double R_min =6.5 ;//最小转弯半径
+    *R_M = fabs(sqrt(R_min*R_min - (L + L_f)*(L + L_f))) - L_k*0.5;//double	R_M  ;//后轴中点的转弯半径
+    //rad_1 = atan2(sqrt(R_min*R_min - (R_M - L_k*0.5)*(R_M - L_k*0.5)), R_M - L_k*0.5);
+    //rad_2 = atan2(L + L_f, R_M + L_k*0.5);
+    *min_rad = 45 * PI / 180;// rad_1 - rad_2;
+    return 0;
+}
+
+
+double iv::decition::Compute00::qiedian_n(double x_1, double y_1, double R_M,double min_rad, double *x_2, double *y_2, double *real_rad ) {
+
+    if (x_1 > 0 && y_1 > 0)
+    {
+        *real_rad = PI*0.5 - min_rad;
+        *x_2 = R_M - R_M*cos(min_rad);
+        *y_2 = R_M*sin(min_rad) + 0.5;
+    }
+    else
+    {
+        *real_rad = PI*0.5 + min_rad;
+        *x_2 = R_M*cos(min_rad) - R_M;
+        *y_2 = R_M*sin(min_rad) + 0.5;
+    }
+    return 0;
+
+}
+
+
+double iv::decition::Compute00::liangzhixian_jiaodian(double x_1,double y_1,double x_2,double y_2,double ange1,double real_rad,double *x_3,double *y_3) {
+    double b1, b2;
+    double k1, k2;
+    if (ange1!=(PI*0.5))
+    {
+        k1 = tan(ange1);
+        b1 = y_1 - k1*x_1;
+        k2 = tan(real_rad);
+        b2 = y_2 - k2*x_2;
+        *x_3 = (b2 - b1) / (k1 - k2);
+        *y_3 = k2*(*x_3) + b2;
+    }
+    else
+    {
+        k2 = tan(real_rad);
+        b2 = y_2 - k2*x_2;
+        *x_3 = x_1;
+        *y_3 = k2*(*x_3) + b2;
+    }
+    return 0;
+}
+
+
+double iv::decition::Compute00::chuizhipingfenxian_xielv(double x_1,double y_1,double ange1,double real_rad,double min_rad,double *angle_3) {
+    double k1, k2;
+    double  angle_j;
+    k2 = tan(real_rad);
+    if (ange1 != (PI*0.5))
+    {
+        k1 = tan(ange1);
+        angle_j = atan(fabs((k2 - k1) / (1 + k2*k1)));//两直线夹角
+
+        if (x_1 > 0 && y_1 > 0)
+        {
+            *angle_3 = angle_j*0.5 - min_rad + PI;
+        }
+        else
+        {
+            *angle_3 = min_rad - angle_j*0.5;
+        }
+    }
+    else
+    {
+        angle_j = min_rad;//两直线夹角
+        if (x_1 > 0 && y_1 > 0)
+        {
+            *angle_3 = angle_j*0.5 - min_rad + PI;
+        }
+        else
+        {
+            *angle_3 = min_rad - angle_j*0.5;
+        }
+    }
+    return 0;
+}
+
+
+double iv::decition::Compute00::yuanxin(double x_2,double y_2,double x_3,double y_3,double real_rad,double angle_3,double R_M,
+                                        double *x_o_1,double *y_o_1,double *x_o_2,double *y_o_2) {
+    double b2, b3, k2, k3;
+    b2 = y_2 - tan(real_rad)*x_2;
+    b3 = y_3 - tan(angle_3)*x_3;
+    k2 = tan(real_rad);
+    k3 = tan(angle_3);
+    *x_o_1 = (sqrt(k2*k2 + 1)*R_M + b3 - b2) / (k2 - k3);
+    *y_o_1 = k3*(*x_o_1) + b3;
+
+    *x_o_2 = (b3 - b2 - (sqrt(k2*k2 + 1)*R_M)) / (k2 - k3);
+    *y_o_2 = k3*(*x_o_2) + b3;
+    return 0;
+}
+
+
+double iv::decition::Compute00::yuanxin_qiedian(double ange1,double x_o_1,double y_o_1, double x_o_2,double y_o_2,
+                                                double x_1,double y_1,double x_2,double y_2,double x_3,double y_3,double real_rad,double angle_3,double R_M,
+                                                double *x_t_n, double *y_t_n, double *x_t_f, double *y_t_f)
+{
+    double x_o, y_o;
+    double b2, b3, k1, k2, k3;
+
+    //double car_pos[3] = { x_1,y_1,k1 };
+    double parking_pos[2] = { x_2,y_2 };
+    //double t[4][2];
+    double p[4];
+    double  s1, s2; //切点与车起始位置的距离
+    double  min;
+    int  min_i;
+    double x_t_1, y_t_1, x_t_2, y_t_2;//圆形1的切点
+    double x_t_3, y_t_3, x_t_4, y_t_4;//圆形2的切点
+    double t[4][2];
+    k1 = tan(ange1);
+    b2 = y_2 - tan(real_rad)*x_2;
+    b3 = y_3 - tan(real_rad)*x_3;
+    k2 = tan(real_rad);//另一条直线斜率
+    k3 = tan(angle_3);//垂直平分线斜率
+    //圆心1和2切点*********************************************
+    if (x_1 > 0 && y_1 > 0)//第一象限
+    {
+        if (ange1 == (PI*0.5))
+        {
+            x_t_1 = x_1;
+            y_t_1 = y_o_1;
+            y_t_2 = (y_2 + k2 *x_o_1 + y_o_1*k2*k2 - k2*x_2) / (1 + k2*k2);
+            x_t_2 = (y_t_2 + k2*x_2 - y_2) / k2;
+
+            x_t_3 = x_1;
+            y_t_3 = y_o_2;
+            y_t_4 = (y_2 + k2 *x_o_2 + y_o_2*k2*k2 - k2*x_2) / (1 + k2*k2);
+            x_t_4 = (y_t_4 + k2*x_2 - y_2) / k2;
+
+
+        }
+        else
+        {
+            y_t_1 = (y_1 + k1 *x_o_1 + y_o_1*k1*k1 - k1*x_1) / (1 + k1*k1);
+            x_t_1 = (y_t_1 + k1*x_1 - y_1) / k1;
+            y_t_2 = (y_2 + k2 *x_o_1 + y_o_1*k2*k2 - k2*x_2) / (1 + k2*k2);
+            x_t_2 = (y_t_2 + k2*x_2 - y_2) / k2;
+
+            y_t_3 = (y_1 + k1 *x_o_2 + y_o_2*k1*k1 - k1*x_1) / (1 + k1*k1);
+            x_t_3 = (y_t_3 + k1*x_1 - y_1) / k1;
+            y_t_4 = (y_2 + k2 *x_o_2 + y_o_2*k2*k2 - k2*x_2) / (1 + k2*k2);
+            x_t_4 = (y_t_4 + k2*x_2 - y_2) / k2;
+
+        }
+    }
+    else
+    {
+        if (ange1 == 0)
+        {
+            x_t_1 = 0 - x_1;
+            y_t_1 = y_o_1;
+            y_t_2 = (y_2 + k2 *x_o_1 + y_o_1*k2*k2 - k2*x_2) / (1 + k2*k2);
+            x_t_2 = (y_t_2 + k2*x_2 - y_2) / k2;
+
+            x_t_3 = 0 - x_1;
+            y_t_3 = y_o_2;
+            y_t_4 = (y_2 + k2 *x_o_2 + y_o_2*k2*k2 - k2*x_2) / (1 + k2*k2);
+            x_t_4 = (y_t_4 + k2*x_2 - y_2) / k2;
+        }
+        else
+        {
+            y_t_1 = (y_1 + k1 *x_o_1 + y_o_1*k1*k1 - k1*x_1) / (1 + k1*k1);
+            x_t_1 = (y_t_1 + k1*x_1 - y_1) / k1;
+            y_t_2 = (y_2 + k2 *x_o_1 + y_o_1*k2*k2 - k2*x_2) / (1 + k2*k2);
+            x_t_2 = (y_t_2 + k2*x_2 - y_2) / k2;
+
+            y_t_3 = (y_1 + k1 *x_o_2 + y_o_2*k1*k1 - k1*x_1) / (1 + k1*k1);
+            x_t_3 = (y_t_3 + k1*x_1 - y_1) / k1;
+            y_t_4 = (y_2 + k2 *x_o_2 + y_o_2*k2*k2 - k2*x_2) / (1 + k2*k2);
+            x_t_4 = (y_t_4 + k2*x_2 - y_2) / k2;
+
+        }
+
+    }
+
+    //圆心1和2切点*********************************************
+
+    t[0][0] = x_t_1;
+    t[0][1] = y_t_1;
+    t[1][0] = x_t_2;
+    t[1][1] = y_t_2;
+    t[2][0] = x_t_3;
+    t[2][1] = y_t_3;
+    t[3][0] = x_t_4;
+    t[3][1] = y_t_4;
+    for (int i = 0; i < 4; i++)
+    {
+
+        p[i] = (t[i][0] - parking_pos[0])*(t[i][0] - parking_pos[0]) + (t[i][1] - parking_pos[1])*(t[i][1] - parking_pos[1]);
+
+    }
+    min = p[0];
+    min_i = 0;
+    for (int i = 1; i < 4; i++)
+    {
+
+        if (p[i] < min)
+        {
+            min = p[i]; min_i = i;
+        }
+    }
+    if (min_i < 2)
+    {
+        x_o = x_o_1;
+        y_o = y_o_1;
+        s1 = (x_t_1 - x_1)*(x_t_1 - x_1) + (y_t_1 - y_1)*(y_t_1 - y_1);
+        s2 = (x_t_2 - x_1)*(x_t_2 - x_1) + (y_t_2 - y_1)*(y_t_2 - y_1);
+        if (s1 < s2)
+        {
+            *x_t_n = x_t_1;
+            *y_t_n = y_t_1;
+            *x_t_f = x_t_2;
+            *y_t_f = y_t_2;
+        }
+        else
+        {
+            *x_t_n = x_t_2;
+            *y_t_n = y_t_2;
+            *x_t_f = x_t_1;
+            *y_t_f = y_t_1;
+
+        }
+    }
+    else
+    {
+        x_o = x_o_2;
+        y_o = y_o_2;
+        s1 = (x_t_3 - x_1)*(x_t_3 - x_1) + (y_t_3 - y_1)*(y_t_3 - y_1);
+        s2 = (x_t_4 - x_1)*(x_t_4 - x_1) + (y_t_4 - y_1)*(y_t_4 - y_1);
+
+        if (s1 < s2)
+        {
+
+            *x_t_n = x_t_3;
+            *y_t_n = y_t_3;
+            *x_t_f = x_t_4;
+            *y_t_f = y_t_4;
+        }
+        else
+        {
+            *x_t_n = x_t_4;
+            *y_t_n = y_t_4;
+            *x_t_f = x_t_3;
+            *y_t_f = y_t_3;
+        }
+
+
+
+    }
+
+    return 0;
+
+}
+
+
+int iv::decition::Compute00::getNoAngleNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap)
+{
+    int index = -1;
+    int startIndex = 0;     // startIndex = 0 则每一次都是遍历整条地图路线
+    int endIndex = gpsMap.size() - 1;
+    float minDis=20;
+
+    for (int j = startIndex; j < endIndex; j++)
+    {
+        int i = (j + gpsMap.size()) % gpsMap.size();
+        double tmpdis = GetDistance(rp, (*gpsMap[i]));
+
+        if (tmpdis < minDis)
+        {
+            index = i;
+            minDis=tmpdis;
+        }
+    }
+    return index;
+}
+
+
+double iv::decition::Compute00::getObsSpeedByFrenet(Point2D obsPoint, double realSecSpeed,const vector<Point2D> gpsTrace, std::vector<iv::GPSData> gpsMap,int pathpoint,GPS_INS nowGps) {
+    double obsSpeed = 0 - realSecSpeed;
+    double minDis = iv::MaxValue;
+    FrenetPoint esr_obs_F_point;
+    for (int i = 0; i < 64; i++)
+        if ((ServiceCarStatus.obs_radar[i].nomal_y) != 0 && ServiceCarStatus.obs_radar[i].valid)
+        {
+            double xxx = ServiceCarStatus.obs_radar[i].nomal_x + Esr_Offset;
+            double yyy = ServiceCarStatus.obs_radar[i].nomal_y + Esr_Y_Offset;
+
+            if (abs(xxx - obsPoint.x) < 4 && abs(yyy - obsPoint.y) < 2)
+            {
+                double tmpDis = sqrt((xxx - obsPoint.x) * (xxx - obsPoint.x) + (yyy - obsPoint.y) * (yyy - obsPoint.y));
+                if (tmpDis < minDis)
+                {
+                    minDis = tmpDis;
+//                    esr_obs_F_point = iv::decition::FrenetPlanner::XY2Frenet(xxx, yyy, gpsTrace);
+                    esr_obs_F_point = iv::decition::FrenetPlanner::getFrenetfromXY(xxx, yyy, gpsTrace,gpsMap,pathpoint,nowGps);
+//                    obsSpeed = ServiceCarStatus.obs_radar[i].speed_y;
+                    double speedx=ServiceCarStatus.obs_radar[i].speed_x;  //障碍物相对于车辆x轴的速度
+                    double speedy=ServiceCarStatus.obs_radar[i].speed_y;  //障碍物相对于车辆y轴的速度
+                    double speed_combine = sqrt(speedx*speedx+speedy*speedy);    //将x、y轴两个方向的速度求矢量和
+                    //障碍物的速度方向与道路方向的夹角。用于将速度分解到s方向和d方向。
+                    //所谓道路方向是指,道路上离障碍物的最近的点沿道路弧线的切线方向。
+                    double Etheta = esr_obs_F_point.tangent_Ang - atan2(speedy,speedx);
+
+                    obsSpeed = speed_combine*cos(Etheta);  //由speed_combine分解的s轴方向上的速度
+                }
+            }
+        }
+
+    return obsSpeed;
+}
+
+
+int iv::decition::Compute00::getEsrIndexByFrenet(std::vector<Point2D> gpsTrace, FrenetPoint &esrObsPoint, std::vector<iv::GPSData> gpsMap,int pathpoint,GPS_INS nowGps){
+    double minDistance = numeric_limits<double>::max();
+    int minDis_index=-1;
+
+    for(int i=0; i<64; ++i){
+        if ((ServiceCarStatus.obs_radar[i].nomal_y) != 0 && (ServiceCarStatus.obs_radar[i].valid)){
+            //毫米波在车头,故要加上毫米波与惯导的相对距离。(xxx,yyy)才是障碍物在 车辆坐标系下的坐标。
+            double xxx = ServiceCarStatus.obs_radar[i].nomal_x + Esr_Offset;
+            double yyy = ServiceCarStatus.obs_radar[i].nomal_y+ Esr_Y_Offset;
+
+            //将毫米波障碍物位置转换到frenet坐标系下
+//            esrObsPoint = iv::decition::FrenetPlanner::XY2Frenet(xxx,yyy,gpsTrace);
+            esrObsPoint = iv::decition::FrenetPlanner::getFrenetfromXY(xxx,yyy,gpsTrace,gpsMap,pathpoint,nowGps);
+
+            //如果障碍物与道路的横向距离d<=3.0*Veh_Width / 4.0,则认为道路上有障碍物。
+            //s则可理解为障碍物距离。为障碍物与车辆沿着道路方向的距离,而不是空间上的x或y坐标或者直线距离。
+            //minDistance、minDis_index用来统计最近的障碍物信息。
+            if(abs(esrObsPoint.d)<=(3.0*Veh_Width / 4.0+DecideGps00().xiuzhengCs)){
+                if(esrObsPoint.s<minDistance){
+                    minDistance = esrObsPoint.s;
+                    minDis_index = i;
+                }
+            }
+        }
+    }
+    return minDis_index;
+}
+
+
+
+
+std::vector<std::vector<iv::GPSData>> gmapsL;
+std::vector<std::vector<iv::GPSData>> gmapsR;

+ 101 - 101
src/decition/decition_brain/decition/adc_tools/compute_00.h

@@ -1,101 +1,101 @@
-#pragma once
-#ifndef _IV_DECITION_COMPUTE_00_
-#define _IV_DECITION_COMPUTE_00_
-
-#include <common/gps_type.h>
-#include <common/obstacle_type.h>
-#include <decition/decition_type.h>
-#include<vector> 
-#include <decition/decide_gps_00.h>
-
-namespace iv {
-    namespace decition {
-    //根据传感器传输来的信息作出决策
-        class Compute00 {
-        public:
-            Compute00();
-            ~Compute00();
-
-            static   double maxAngle;
-            static	 double angleLimit;  //角度限制
-            static	 double lastEA;      //上一次角度误差
-            static	 double lastEP;      //上一次位置误差
-            static	 double decision_Angle;  //决策角度
-            static	 double lastAng;         //上次角度
-            static   int lastEsrID;          //上次毫米波障碍物ID
-            static   int  lastEsrCount;      //毫米波障碍物累计次数
-
-            static   int lastEsrIDAvoid;          //上次毫米波障碍物ID Avoid
-            static   int  lastEsrCountAvoid;      //毫米波障碍物累计次数 Avoid
-
-            static iv::GPS_INS nearTpoint, farTpoint,dTpoint0,dTpoint1,dTpoint2,dTpoint3;
-            static double bocheAngle,dBocheAngle;
-
-            static	int getNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap, int lastIndex, double mindis, double maxAngle);
-            static	int getFirstNearestPointIndex(GPS_INS rp, std::vector<GPSData> gpsMap, int lastIndex, double mindis, double maxAngle);
-
-            static int getDesiredSpeed(std::vector<GPSData> gpsMap);
-
-            static double getDecideAngle(std::vector<Point2D>  gpsTrace, double realSpeed);
-            static double getAveDef(std::vector<Point2D> farTrace);
-            static int getSpeedPointIndex(std::vector<Point2D> gpsTrace, double realSpeed);
-            static Point2D getLidarObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr);
-            static Point2D getLidarRearObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr);
-
-
-            static Point2D getLidarObsPointAvoid(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr);
-            static int getEsrIndex(std::vector<Point2D> gpsTrace , int roadNum, int *esrPathpoint);
-            static int getRearEsrIndex(std::vector<Point2D> gpsTrace , int roadNum);
-            static int getEsrIndexAvoid(std::vector<Point2D> gpsTrace);
-
-            static double getObsSpeed(Point2D obsPoint, double realSecSpeed);
-
-            static double getAvoidAveDef(std::vector<Point2D> farTrace, double avoidX);
-            static double getDecideAvoidAngle(std::vector<Point2D>  gpsTrace, double realSpeed, float avoidX);
-
-            static std::vector<GPSData>  getBesideGpsMapLine(iv::GPS_INS now_gps_ins, std::vector<iv::GPSData>gpsMapLine, float avoidX);
-
-            static double getDecideAngleByLane(double realSpeed);
-
-            static double getDecideAngleByLanePID(double realSpeed);
-
-            static double bocheCompute(GPS_INS nowGps, GPS_INS aimGps);
-
-            static	double pingfenxian_xielv(double x_1, double y_1, double x_2, double y_2, double angle_1);
-
-            static double getQieXianAngle(GPS_INS nowGps, GPS_INS aimGps);
-
-            static int bocheDirectCompute(GPS_INS nowGps, GPS_INS aimGps);
-
-            static double min_rad_zhuanxiang(double *R_M, double *min_rad);
-            static double qiedian_n(double x_1,double y_1,double R_M,double min_rad,
-                                    double *x_2, double *y_2, double *real_rad);
-            static double liangzhixian_jiaodian(double x_1,double y_1,double x_2,double y_2,
-                                                double ange1,double real_rad,double *x_3, double *y_3);
-            static double chuizhipingfenxian_xielv(double x_1,double y_1,double ange1,double real_rad,
-                                                   double min_rad,double *angle_3);
-            static double yuanxin(double x_2,double y_2,double x_3,double y_3,double real_rad,
-                                  double angle_3,double R_M,double *x_o_1, double *y_o_1, double *x_o_2, double *y_0_2);
-            static double yuanxin_qiedian(double angel,double x_o_1,double y_o_1, double x_o_2,double y_o_2,
-                                          double x_1,double y_1,double x_2,double y_2,double x_3,double y_3,
-                                          double real_rad,double angle_3,double R_M,
-                                          double *x_t_n, double *y_t_n, double *x_t_f, double *y_t_f);
-
-            static int getNoAngleNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap);
-
-            static int getEsrIndexByFrenet(std::vector<Point2D> gpsTrace,FrenetPoint &esrObsPoint, std::vector<iv::GPSData> gpsMap,int pathpoint,GPS_INS nowGps);
-            double getObsSpeedByFrenet(Point2D obsPoint, double realSecSpeed,const std::vector<Point2D> gpsTrace, std::vector<iv::GPSData> gpsMap,int pathpoint,GPS_INS nowGps);
-
-        private:
-
-        };
-    }
-}
-extern std::vector<std::vector<iv::GPSData>> gmapsL;
-extern std::vector<std::vector<iv::GPSData>> gmapsR;
-
-extern std::vector<int> lastEsrIdVector;
-extern std::vector<int> lastEsrCountVector;
-
-#endif // !_IV_DECITION_COMPUTE_00_
-
+#pragma once
+#ifndef _IV_DECITION_COMPUTE_00_
+#define _IV_DECITION_COMPUTE_00_
+
+#include <common/gps_type.h>
+#include <common/obstacle_type.h>
+#include <decition/decition_type.h>
+#include<vector> 
+#include <decition/decide_gps_00.h>
+
+namespace iv {
+    namespace decition {
+    //根据传感器传输来的信息作出决策
+        class Compute00 {
+        public:
+            Compute00();
+            ~Compute00();
+
+            static   double maxAngle;
+            static	 double angleLimit;  //角度限制
+            static	 double lastEA;      //上一次角度误差
+            static	 double lastEP;      //上一次位置误差
+            static	 double decision_Angle;  //决策角度
+            static	 double lastAng;         //上次角度
+            static   int lastEsrID;          //上次毫米波障碍物ID
+            static   int  lastEsrCount;      //毫米波障碍物累计次数
+
+            static   int lastEsrIDAvoid;          //上次毫米波障碍物ID Avoid
+            static   int  lastEsrCountAvoid;      //毫米波障碍物累计次数 Avoid
+
+            static iv::GPS_INS nearTpoint, farTpoint,dTpoint0,dTpoint1,dTpoint2,dTpoint3;
+            static double bocheAngle,dBocheAngle;
+
+            static	int getNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap, int lastIndex, double mindis, double maxAngle);
+            static	int getFirstNearestPointIndex(GPS_INS rp, std::vector<GPSData> gpsMap, int lastIndex, double mindis, double maxAngle);
+
+            static int getDesiredSpeed(std::vector<GPSData> gpsMap);
+
+            static double getDecideAngle(std::vector<Point2D>  gpsTrace, double realSpeed);
+            static double getAveDef(std::vector<Point2D> farTrace);
+            static int getSpeedPointIndex(std::vector<Point2D> gpsTrace, double realSpeed);
+            static Point2D getLidarObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr);
+            static Point2D getLidarRearObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr);
+
+
+            static Point2D getLidarObsPointAvoid(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr);
+            static int getEsrIndex(std::vector<Point2D> gpsTrace , int roadNum, int *esrPathpoint);
+            static int getRearEsrIndex(std::vector<Point2D> gpsTrace , int roadNum);
+            static int getEsrIndexAvoid(std::vector<Point2D> gpsTrace);
+
+            static double getObsSpeed(Point2D obsPoint, double realSecSpeed);
+
+            static double getAvoidAveDef(std::vector<Point2D> farTrace, double avoidX);
+            static double getDecideAvoidAngle(std::vector<Point2D>  gpsTrace, double realSpeed, float avoidX);
+
+            static std::vector<GPSData>  getBesideGpsMapLine(iv::GPS_INS now_gps_ins, std::vector<iv::GPSData>gpsMapLine, float avoidX);
+
+            static double getDecideAngleByLane(double realSpeed);
+
+            static double getDecideAngleByLanePID(double realSpeed);
+
+            static double bocheCompute(GPS_INS nowGps, GPS_INS aimGps);
+
+            static	double pingfenxian_xielv(double x_1, double y_1, double x_2, double y_2, double angle_1);
+
+            static double getQieXianAngle(GPS_INS nowGps, GPS_INS aimGps);
+
+            static int bocheDirectCompute(GPS_INS nowGps, GPS_INS aimGps);
+
+            static double min_rad_zhuanxiang(double *R_M, double *min_rad);
+            static double qiedian_n(double x_1,double y_1,double R_M,double min_rad,
+                                    double *x_2, double *y_2, double *real_rad);
+            static double liangzhixian_jiaodian(double x_1,double y_1,double x_2,double y_2,
+                                                double ange1,double real_rad,double *x_3, double *y_3);
+            static double chuizhipingfenxian_xielv(double x_1,double y_1,double ange1,double real_rad,
+                                                   double min_rad,double *angle_3);
+            static double yuanxin(double x_2,double y_2,double x_3,double y_3,double real_rad,
+                                  double angle_3,double R_M,double *x_o_1, double *y_o_1, double *x_o_2, double *y_0_2);
+            static double yuanxin_qiedian(double angel,double x_o_1,double y_o_1, double x_o_2,double y_o_2,
+                                          double x_1,double y_1,double x_2,double y_2,double x_3,double y_3,
+                                          double real_rad,double angle_3,double R_M,
+                                          double *x_t_n, double *y_t_n, double *x_t_f, double *y_t_f);
+
+            static int getNoAngleNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap);
+
+            static int getEsrIndexByFrenet(std::vector<Point2D> gpsTrace,FrenetPoint &esrObsPoint, std::vector<iv::GPSData> gpsMap,int pathpoint,GPS_INS nowGps);
+            double getObsSpeedByFrenet(Point2D obsPoint, double realSecSpeed,const std::vector<Point2D> gpsTrace, std::vector<iv::GPSData> gpsMap,int pathpoint,GPS_INS nowGps);
+
+        private:
+
+        };
+    }
+}
+extern std::vector<std::vector<iv::GPSData>> gmapsL;
+extern std::vector<std::vector<iv::GPSData>> gmapsR;
+
+extern std::vector<int> lastEsrIdVector;
+extern std::vector<int> lastEsrCountVector;
+
+#endif // !_IV_DECITION_COMPUTE_00_
+

+ 154 - 154
src/decition/decition_brain/decition/adc_tools/dubins.cpp

@@ -1,154 +1,154 @@
-#include <decition/adc_tools/gnss_coordinate_convert.h>
-
-void gps2xy(double J4, double K4, double *x, double *y)
-{
-    int L4 = (int)((K4 - 1.5) / 3) + 1;
-    double M4 = K4 - (L4 * 3);
-    double N4 = sin(J4 * 3.1415926536 / 180);
-    double O4 = cos(J4 * 3.1415926536 / 180);
-    double P4 = tan(J4 * 3.1415926536 / 180);
-    double Q4 = 111134.8611 * J4 - N4 * O4 * (32005.7799 + 133.9238 * N4 * N4 + 0.6973 * N4 * N4 * N4 * N4 + 0.0039 * N4 * N4 * N4 * N4 * N4 * N4);
-    double R4 = sqrt(0.006738525414683) * O4;
-    double S4 = sqrt(1 + R4 * R4);
-    double T4 = 6399698.901783 / S4;
-    double U4 = (T4 / S4) / S4;
-    double V4 = O4 * M4 * 3.1415926536 / 180;
-    double W4 = 0.5 + (5 - P4 * P4 + 9 * R4 * R4 + 4 * R4 * R4 * R4 * R4) * V4 * V4 / 24;
-    double X4 = V4 * V4 * V4 * V4 / 720 * (61 + (P4 * P4 - 58) * P4 * P4);
-    double Y4 = 1 + V4 * V4 * (1 - P4 * P4 + R4 * R4) / 6;
-    double Z4 = V4 * V4 * V4 * V4 * (5 - 18 * P4 * P4 * P4 * P4 * P4 * P4 + 14 * R4 * R4 - 58 * R4 * R4 * P4 * P4) / 120;
-
-    *y = Q4 + T4 * P4 * V4 * V4 * (W4 + X4);
-    *x = 500000 + T4 * V4 * (Y4 + Z4);
-}
-
-
-
-//高斯投影由经纬度(Unit:DD)反算大地坐标(含带号,Unit:Metres)
-void GaussProjCal(double longitude, double latitude, double *X, double *Y)
-{
-    int ProjNo = 0; int ZoneWide; ////带宽
-    double longitude1, latitude1, longitude0, latitude0, X0, Y0, xval, yval;
-    double a, f, e2, ee, NN, T, C, A, M, iPI;
-    iPI = 0.0174532925199433; ////3.1415926535898/180.0;
-    ZoneWide = 6; ////6度带宽
-    a = 6378245.0; f = 1.0 / 298.3; //54年北京坐标系参数
-                                    ////a=6378140.0; f=1/298.257; //80年西安坐标系参数
-    ProjNo = (int)(longitude / ZoneWide);
-    longitude0 = ProjNo * ZoneWide + ZoneWide / 2;
-    longitude0 = longitude0 * iPI;
-    latitude0 = 0;
-    longitude1 = longitude * iPI; //经度转换为弧度
-    latitude1 = latitude * iPI; //纬度转换为弧度
-    e2 = 2 * f - f * f;
-    ee = e2 * (1.0 - e2);
-    NN = a / sqrt(1.0 - e2 * sin(latitude1)*sin(latitude1));
-    T = tan(latitude1)*tan(latitude1);
-    C = ee * cos(latitude1)*cos(latitude1);
-    A = (longitude1 - longitude0)*cos(latitude1);
-    M = a * ((1 - e2 / 4 - 3 * e2*e2 / 64 - 5 * e2*e2*e2 / 256)*latitude1 - (3 * e2 / 8 + 3 * e2*e2 / 32 + 45 * e2*e2
-        *e2 / 1024)*sin(2 * latitude1)
-        + (15 * e2*e2 / 256 + 45 * e2*e2*e2 / 1024)*sin(4 * latitude1) - (35 * e2*e2*e2 / 3072)*sin(6 * latitude1));
-    xval = NN * (A + (1 - T + C)*A*A*A / 6 + (5 - 18 * T + T * T + 72 * C - 58 * ee)*A*A*A*A*A / 120);
-    yval = M + NN * tan(latitude1)*(A*A / 2 + (5 - T + 9 * C + 4 * C*C)*A*A*A*A / 24
-        + (61 - 58 * T + T * T + 600 * C - 330 * ee)*A*A*A*A*A*A / 720);
-    X0 = 1000000L * (ProjNo + 1) + 500000L;
-    Y0 = 0;
-    xval = xval + X0; yval = yval + Y0;
-    *X = xval;
-    *Y = yval;
-}
-
-
-/*
-//=======================zhaobo0904
-#define PI  3.14159265358979
-void GaussProjCal(double lon, double lat, double *X, double *Y)
-{
-    // 1975 年国际椭球体长半轴 a, 第一离心率 e2, 第二离心率 ep2
-    double a = 6378140.0;
-    double e2 = 0.006694384999588;
-    double ep2 = e2/(1-e2);
-
-    // 原点所在经度
-    double lon_origin = 6.0*int(lon/6) + 3.0;
-    lon_origin *= PI / 180.0;
-
-    double k0 = 0.9996;
-
-    // 角度转弧度
-    double lat1 = lat * PI / 180.0;
-    double lon1 = lon * PI / 180.0;
-
-
-    // 经线在该点处的曲率半径,
-    double N = a / sqrt(1 - e2*sin(lat1)*sin(lat1));
-
-
-    // 赤道到该点的经线长度近似值 M, 使用泰勒展开逐项积分然后取前四项.
-    // 这个近似值是将 N 作为纬度 \phi 的函数展开为泰勒计数, 然后在区间 [0, lat1] 上积分得到的.
-    // 首先计算前四项的系数 a1~a4.
-    double a1 = 1 - e2/4 - (3*e2*e2)/64 - (5*e2*e2*e2)/256;
-    double a2 = (3*e2)/8 + (3*e2*e2)/32 + (45*e2*e2*e2)/1024;
-    double a3 = (15*e2*e2)/256 + (45*e2*e2*e2)/1024;
-    double a4 = (35*e2*e2*e2)/3072;
-    double M = a * (a1*lat1 - a2*sin(2*lat1) + a3*sin(4*lat1) - a4*sin(6*lat1));
-
-    // 辅助量
-    double T = tan(lat1)*tan(lat1);
-    double C = ep2*cos(lat1)*cos(lat1);
-    double A = (lon1 - lon_origin)*cos(lat1);
-
-    *X = 500000.0 + k0 * N * (A + (1 - T + C)*(A*A*A)/6 + (5 - 18*T + T*T + 72*C - 58*ep2)*(A*A*A*A*A)/120);
-    *Y = M + N * tan(lat1) * ((A*A)/2 +
-                              (5 - T + 9*C + 4*C*C)*(A*A*A*A)/24 +
-                              (61 - 58*T + T*T + 600*C - 330*ep2)*(A*A*A*A*A*A)/720);
-
-
-    *Y *= k0;
-    return;
-}
-//==========================================================
-
-*/
-
-
-//高斯投影由大地坐标(Unit:Metres)反算经纬度(Unit:DD)
-void GaussProjInvCal(double X, double Y, double *longitude, double *latitude)
-{
-    int ProjNo; int ZoneWide; ////带宽
-    double longitude1, latitude1, longitude0, latitude0, X0, Y0, xval, yval;
-    double e1, e2, f, a, ee, NN, T, C, M, D, R, u, fai, iPI;
-    iPI = 0.0174532925199433; ////3.1415926535898/180.0;
-    a = 6378245.0; f = 1.0 / 298.3; //54年北京坐标系参数
-    ////a=6378140.0; f=1/298.257; //80年西安坐标系参数
-    ZoneWide = 6; ////6度带宽
-    ProjNo = (int)(X / 1000000L); //查找带号
-    longitude0 = (ProjNo - 1) * ZoneWide + ZoneWide / 2;
-    longitude0 = longitude0 * iPI; //中央经线
-    X0 = ProjNo * 1000000L + 500000L;
-    Y0 = 0;
-    xval = X - X0; yval = Y - Y0; //带内大地坐标
-    e2 = 2 * f - f * f;
-    e1 = (1.0 - sqrt(1 - e2)) / (1.0 + sqrt(1 - e2));
-    ee = e2 / (1 - e2);
-    M = yval;
-    u = M / (a*(1 - e2 / 4 - 3 * e2*e2 / 64 - 5 * e2*e2*e2 / 256));
-    fai = u + (3 * e1 / 2 - 27 * e1*e1*e1 / 32)*sin(2 * u) + (21 * e1*e1 / 16 - 55 * e1*e1*e1*e1 / 32)*sin(
-                4 * u)
-            + (151 * e1*e1*e1 / 96)*sin(6 * u) + (1097 * e1*e1*e1*e1 / 512)*sin(8 * u);
-    C = ee * cos(fai)*cos(fai);
-    T = tan(fai)*tan(fai);
-    NN = a / sqrt(1.0 - e2 * sin(fai)*sin(fai));
-    R = a * (1 - e2) / sqrt((1 - e2 * sin(fai)*sin(fai))*(1 - e2 * sin(fai)*sin(fai))*(1 - e2 * sin
-                                                                                       (fai)*sin(fai)));
-    D = xval / NN;
-    //计算经度(Longitude) 纬度(Latitude)
-    longitude1 = longitude0 + (D - (1 + 2 * T + C)*D*D*D / 6 + (5 - 2 * C + 28 * T - 3 * C*C + 8 * ee + 24 * T*T)*D
-                               *D*D*D*D / 120) / cos(fai);
-    latitude1 = fai - (NN*tan(fai) / R)*(D*D / 2 - (5 + 3 * T + 10 * C - 4 * C*C - 9 * ee)*D*D*D*D / 24
-                                         + (61 + 90 * T + 298 * C + 45 * T*T - 256 * ee - 3 * C*C)*D*D*D*D*D*D / 720);
-    //转换为度 DD
-    *longitude = longitude1 / iPI;
-    *latitude = latitude1 / iPI;
-}
+#include <decition/adc_tools/gnss_coordinate_convert.h>
+
+void gps2xy(double J4, double K4, double *x, double *y)
+{
+    int L4 = (int)((K4 - 1.5) / 3) + 1;
+    double M4 = K4 - (L4 * 3);
+    double N4 = sin(J4 * 3.1415926536 / 180);
+    double O4 = cos(J4 * 3.1415926536 / 180);
+    double P4 = tan(J4 * 3.1415926536 / 180);
+    double Q4 = 111134.8611 * J4 - N4 * O4 * (32005.7799 + 133.9238 * N4 * N4 + 0.6973 * N4 * N4 * N4 * N4 + 0.0039 * N4 * N4 * N4 * N4 * N4 * N4);
+    double R4 = sqrt(0.006738525414683) * O4;
+    double S4 = sqrt(1 + R4 * R4);
+    double T4 = 6399698.901783 / S4;
+    double U4 = (T4 / S4) / S4;
+    double V4 = O4 * M4 * 3.1415926536 / 180;
+    double W4 = 0.5 + (5 - P4 * P4 + 9 * R4 * R4 + 4 * R4 * R4 * R4 * R4) * V4 * V4 / 24;
+    double X4 = V4 * V4 * V4 * V4 / 720 * (61 + (P4 * P4 - 58) * P4 * P4);
+    double Y4 = 1 + V4 * V4 * (1 - P4 * P4 + R4 * R4) / 6;
+    double Z4 = V4 * V4 * V4 * V4 * (5 - 18 * P4 * P4 * P4 * P4 * P4 * P4 + 14 * R4 * R4 - 58 * R4 * R4 * P4 * P4) / 120;
+
+    *y = Q4 + T4 * P4 * V4 * V4 * (W4 + X4);
+    *x = 500000 + T4 * V4 * (Y4 + Z4);
+}
+
+
+
+//高斯投影由经纬度(Unit:DD)反算大地坐标(含带号,Unit:Metres)
+void GaussProjCal(double longitude, double latitude, double *X, double *Y)
+{
+    int ProjNo = 0; int ZoneWide; ////带宽
+    double longitude1, latitude1, longitude0, latitude0, X0, Y0, xval, yval;
+    double a, f, e2, ee, NN, T, C, A, M, iPI;
+    iPI = 0.0174532925199433; ////3.1415926535898/180.0;
+    ZoneWide = 6; ////6度带宽
+    a = 6378245.0; f = 1.0 / 298.3; //54年北京坐标系参数
+                                    ////a=6378140.0; f=1/298.257; //80年西安坐标系参数
+    ProjNo = (int)(longitude / ZoneWide);
+    longitude0 = ProjNo * ZoneWide + ZoneWide / 2;
+    longitude0 = longitude0 * iPI;
+    latitude0 = 0;
+    longitude1 = longitude * iPI; //经度转换为弧度
+    latitude1 = latitude * iPI; //纬度转换为弧度
+    e2 = 2 * f - f * f;
+    ee = e2 * (1.0 - e2);
+    NN = a / sqrt(1.0 - e2 * sin(latitude1)*sin(latitude1));
+    T = tan(latitude1)*tan(latitude1);
+    C = ee * cos(latitude1)*cos(latitude1);
+    A = (longitude1 - longitude0)*cos(latitude1);
+    M = a * ((1 - e2 / 4 - 3 * e2*e2 / 64 - 5 * e2*e2*e2 / 256)*latitude1 - (3 * e2 / 8 + 3 * e2*e2 / 32 + 45 * e2*e2
+        *e2 / 1024)*sin(2 * latitude1)
+        + (15 * e2*e2 / 256 + 45 * e2*e2*e2 / 1024)*sin(4 * latitude1) - (35 * e2*e2*e2 / 3072)*sin(6 * latitude1));
+    xval = NN * (A + (1 - T + C)*A*A*A / 6 + (5 - 18 * T + T * T + 72 * C - 58 * ee)*A*A*A*A*A / 120);
+    yval = M + NN * tan(latitude1)*(A*A / 2 + (5 - T + 9 * C + 4 * C*C)*A*A*A*A / 24
+        + (61 - 58 * T + T * T + 600 * C - 330 * ee)*A*A*A*A*A*A / 720);
+    X0 = 1000000L * (ProjNo + 1) + 500000L;
+    Y0 = 0;
+    xval = xval + X0; yval = yval + Y0;
+    *X = xval;
+    *Y = yval;
+}
+
+
+/*
+//=======================zhaobo0904
+#define PI  3.14159265358979
+void GaussProjCal(double lon, double lat, double *X, double *Y)
+{
+    // 1975 年国际椭球体长半轴 a, 第一离心率 e2, 第二离心率 ep2
+    double a = 6378140.0;
+    double e2 = 0.006694384999588;
+    double ep2 = e2/(1-e2);
+
+    // 原点所在经度
+    double lon_origin = 6.0*int(lon/6) + 3.0;
+    lon_origin *= PI / 180.0;
+
+    double k0 = 0.9996;
+
+    // 角度转弧度
+    double lat1 = lat * PI / 180.0;
+    double lon1 = lon * PI / 180.0;
+
+
+    // 经线在该点处的曲率半径,
+    double N = a / sqrt(1 - e2*sin(lat1)*sin(lat1));
+
+
+    // 赤道到该点的经线长度近似值 M, 使用泰勒展开逐项积分然后取前四项.
+    // 这个近似值是将 N 作为纬度 \phi 的函数展开为泰勒计数, 然后在区间 [0, lat1] 上积分得到的.
+    // 首先计算前四项的系数 a1~a4.
+    double a1 = 1 - e2/4 - (3*e2*e2)/64 - (5*e2*e2*e2)/256;
+    double a2 = (3*e2)/8 + (3*e2*e2)/32 + (45*e2*e2*e2)/1024;
+    double a3 = (15*e2*e2)/256 + (45*e2*e2*e2)/1024;
+    double a4 = (35*e2*e2*e2)/3072;
+    double M = a * (a1*lat1 - a2*sin(2*lat1) + a3*sin(4*lat1) - a4*sin(6*lat1));
+
+    // 辅助量
+    double T = tan(lat1)*tan(lat1);
+    double C = ep2*cos(lat1)*cos(lat1);
+    double A = (lon1 - lon_origin)*cos(lat1);
+
+    *X = 500000.0 + k0 * N * (A + (1 - T + C)*(A*A*A)/6 + (5 - 18*T + T*T + 72*C - 58*ep2)*(A*A*A*A*A)/120);
+    *Y = M + N * tan(lat1) * ((A*A)/2 +
+                              (5 - T + 9*C + 4*C*C)*(A*A*A*A)/24 +
+                              (61 - 58*T + T*T + 600*C - 330*ep2)*(A*A*A*A*A*A)/720);
+
+
+    *Y *= k0;
+    return;
+}
+//==========================================================
+
+*/
+
+
+//高斯投影由大地坐标(Unit:Metres)反算经纬度(Unit:DD)
+void GaussProjInvCal(double X, double Y, double *longitude, double *latitude)
+{
+    int ProjNo; int ZoneWide; ////带宽
+    double longitude1, latitude1, longitude0, latitude0, X0, Y0, xval, yval;
+    double e1, e2, f, a, ee, NN, T, C, M, D, R, u, fai, iPI;
+    iPI = 0.0174532925199433; ////3.1415926535898/180.0;
+    a = 6378245.0; f = 1.0 / 298.3; //54年北京坐标系参数
+    ////a=6378140.0; f=1/298.257; //80年西安坐标系参数
+    ZoneWide = 6; ////6度带宽
+    ProjNo = (int)(X / 1000000L); //查找带号
+    longitude0 = (ProjNo - 1) * ZoneWide + ZoneWide / 2;
+    longitude0 = longitude0 * iPI; //中央经线
+    X0 = ProjNo * 1000000L + 500000L;
+    Y0 = 0;
+    xval = X - X0; yval = Y - Y0; //带内大地坐标
+    e2 = 2 * f - f * f;
+    e1 = (1.0 - sqrt(1 - e2)) / (1.0 + sqrt(1 - e2));
+    ee = e2 / (1 - e2);
+    M = yval;
+    u = M / (a*(1 - e2 / 4 - 3 * e2*e2 / 64 - 5 * e2*e2*e2 / 256));
+    fai = u + (3 * e1 / 2 - 27 * e1*e1*e1 / 32)*sin(2 * u) + (21 * e1*e1 / 16 - 55 * e1*e1*e1*e1 / 32)*sin(
+                4 * u)
+            + (151 * e1*e1*e1 / 96)*sin(6 * u) + (1097 * e1*e1*e1*e1 / 512)*sin(8 * u);
+    C = ee * cos(fai)*cos(fai);
+    T = tan(fai)*tan(fai);
+    NN = a / sqrt(1.0 - e2 * sin(fai)*sin(fai));
+    R = a * (1 - e2) / sqrt((1 - e2 * sin(fai)*sin(fai))*(1 - e2 * sin(fai)*sin(fai))*(1 - e2 * sin
+                                                                                       (fai)*sin(fai)));
+    D = xval / NN;
+    //计算经度(Longitude) 纬度(Latitude)
+    longitude1 = longitude0 + (D - (1 + 2 * T + C)*D*D*D / 6 + (5 - 2 * C + 28 * T - 3 * C*C + 8 * ee + 24 * T*T)*D
+                               *D*D*D*D / 120) / cos(fai);
+    latitude1 = fai - (NN*tan(fai) / R)*(D*D / 2 - (5 + 3 * T + 10 * C - 4 * C*C - 9 * ee)*D*D*D*D / 24
+                                         + (61 + 90 * T + 298 * C + 45 * T*T - 256 * ee - 3 * C*C)*D*D*D*D*D*D / 720);
+    //转换为度 DD
+    *longitude = longitude1 / iPI;
+    *latitude = latitude1 / iPI;
+}

+ 26 - 26
src/decition/decition_brain/decition/adc_tools/gnss_coordinate_convert.h

@@ -1,26 +1,26 @@
-#pragma once
-#ifndef _IV_PERCEPTION_GNSS_CONVERT_
-#define _IV_PERCEPTION_GNSS_CONVERT_
-
-#include <math.h>
-//double nmeaConvert2Lat(string lat)
-//{
-//	Console.WriteLine(lat);
-//	double nmea_d = double.Parse(lat.Substring(0, 2));
-//	double nmea_m = double.Parse(lat.Substring(2, 6));
-//	return nmea_d + nmea_m / 60;
-//}
-//
-//double nmeaConvert2Lon(string lon)
-//{
-//	Console.WriteLine(lon);
-//	double nmea_d = double.Parse(lon.Substring(0, 3));
-//	double nmea_m = double.Parse(lon.Substring(3, 7));
-//	return nmea_d + nmea_m / 60;
-//}
-
-void gps2xy(double , double , double *, double *);
-void GaussProjCal(double longitude, double latitude, double *X, double *Y);
-void GaussProjInvCal(double X, double Y, double *longitude, double *latitude);
-
-#endif // !_IV_PERCEPTION_GNSS_CONVERT_
+#pragma once
+#ifndef _IV_PERCEPTION_GNSS_CONVERT_
+#define _IV_PERCEPTION_GNSS_CONVERT_
+
+#include <math.h>
+//double nmeaConvert2Lat(string lat)
+//{
+//	Console.WriteLine(lat);
+//	double nmea_d = double.Parse(lat.Substring(0, 2));
+//	double nmea_m = double.Parse(lat.Substring(2, 6));
+//	return nmea_d + nmea_m / 60;
+//}
+//
+//double nmeaConvert2Lon(string lon)
+//{
+//	Console.WriteLine(lon);
+//	double nmea_d = double.Parse(lon.Substring(0, 3));
+//	double nmea_m = double.Parse(lon.Substring(3, 7));
+//	return nmea_d + nmea_m / 60;
+//}
+
+void gps2xy(double , double , double *, double *);
+void GaussProjCal(double longitude, double latitude, double *X, double *Y);
+void GaussProjInvCal(double X, double Y, double *longitude, double *latitude);
+
+#endif // !_IV_PERCEPTION_GNSS_CONVERT_

+ 45 - 45
src/decition/decition_brain/decition/adc_tools/gps_distance.cpp

@@ -1,45 +1,45 @@
-#include <decition/adc_tools/gps_distance.h>
-#include <math.h>
-#define M_PI (3.1415926535897932384626433832795)
-
-// 计算弧度
-double iv::decition::rad(double d)
-{
-    const double PI = 3.1415926535898;
-    return d * PI / 180.0;
-}
-
-// 从两个gps坐标点(经纬度)获得两点的直线距离,单位是米
-double iv::decition::CalcDistance(double fLati1, double fLong1, double fLati2, double fLong2)
-{
-    const float EARTH_RADIUS = 6378.137;
-    double radLat1 = rad(fLati1);
-    double radLat2 = rad(fLati2);
-    double a = radLat1 - radLat2;
-
-    double b = rad(fLong1) - rad(fLong2);
-    double s = 2 * asin(sqrt(pow(sin(a / 2), 2) + cos(radLat1)*cos(radLat2)*pow(sin(b / 2), 2)));
-    s = s * EARTH_RADIUS;
-    //	s = (int)(s * 10000000) / 10000;
-    return s;
-}
-
-
-// 从直角坐标两点的直线距离,单位是米
-double iv::decition::DirectDistance(double x1, double y1, double x2, double y2)
-{
-    double s = sqrt(pow((x1-x2), 2) +pow((y1-y2), 2));
-    return s;
-}
-
-
-// 从直角坐标计算两点的夹角
-double iv::decition::DirectAngle(double x1, double y1, double x2, double y2)
-{
-    double angle = atan((y2 - y1) / (x2 - x1)) * 180 / M_PI;
-    return angle;
-}
-
-
-
-
+#include <decition/adc_tools/gps_distance.h>
+#include <math.h>
+#define M_PI (3.1415926535897932384626433832795)
+
+// 计算弧度
+double iv::decition::rad(double d)
+{
+    const double PI = 3.1415926535898;
+    return d * PI / 180.0;
+}
+
+// 从两个gps坐标点(经纬度)获得两点的直线距离,单位是米
+double iv::decition::CalcDistance(double fLati1, double fLong1, double fLati2, double fLong2)
+{
+    const float EARTH_RADIUS = 6378.137;
+    double radLat1 = rad(fLati1);
+    double radLat2 = rad(fLati2);
+    double a = radLat1 - radLat2;
+
+    double b = rad(fLong1) - rad(fLong2);
+    double s = 2 * asin(sqrt(pow(sin(a / 2), 2) + cos(radLat1)*cos(radLat2)*pow(sin(b / 2), 2)));
+    s = s * EARTH_RADIUS;
+    //	s = (int)(s * 10000000) / 10000;
+    return s;
+}
+
+
+// 从直角坐标两点的直线距离,单位是米
+double iv::decition::DirectDistance(double x1, double y1, double x2, double y2)
+{
+    double s = sqrt(pow((x1-x2), 2) +pow((y1-y2), 2));
+    return s;
+}
+
+
+// 从直角坐标计算两点的夹角
+double iv::decition::DirectAngle(double x1, double y1, double x2, double y2)
+{
+    double angle = atan((y2 - y1) / (x2 - x1)) * 180 / M_PI;
+    return angle;
+}
+
+
+
+

+ 26 - 26
src/decition/decition_brain/decition/adc_tools/gps_distance.h

@@ -1,26 +1,26 @@
-#pragma once
-#ifndef _IV_DECITION_GPS_DISTANCE_
-#define _IV_DECITION_GPS_DISTANCE_
-
-namespace iv {
-	namespace decition {
-        // 计算弧度
-		double rad(double d);
-
-		// 从两个gps坐标点(经纬度)获得两点的直线距离,单位是米
-		double CalcDistance(double , double , double , double );
-
-		//计算直角坐标距离
-		double DirectDistance(double, double, double, double);
-
-		//计算直角坐标角度
-		double DirectAngle(double, double, double, double);
-
-
-	}
-}
-
-
-
-
-#endif // !_IV_DECITION_GPS_DISTANCE_
+#pragma once
+#ifndef _IV_DECITION_GPS_DISTANCE_
+#define _IV_DECITION_GPS_DISTANCE_
+
+namespace iv {
+	namespace decition {
+        // 计算弧度
+		double rad(double d);
+
+		// 从两个gps坐标点(经纬度)获得两点的直线距离,单位是米
+		double CalcDistance(double , double , double , double );
+
+		//计算直角坐标距离
+		double DirectDistance(double, double, double, double);
+
+		//计算直角坐标角度
+		double DirectAngle(double, double, double, double);
+
+
+	}
+}
+
+
+
+
+#endif // !_IV_DECITION_GPS_DISTANCE_

+ 138 - 138
src/decition/decition_brain/decition/adc_tools/parameter_status.h

@@ -1,138 +1,138 @@
-#include <decition/adc_tools/transfer.h>
-#include <decition/decition_type.h>
-#include <math.h>
-#include <iostream>
-#include <fstream>
-using namespace std;
-#define PI (3.1415926535897932384626433832795)
-
-
-
-///大地转车体
-iv::Point2D iv::decition::Coordinate_Transfer(double x_path, double y_path, iv::GPS_INS pos)
-{
-    double x_vehicle, y_vehicle;
-    double theta = atan2(x_path - pos.gps_x, y_path - pos.gps_y);
-
-    double distance = sqrt((x_path - pos.gps_x) * (x_path - pos.gps_x) + (y_path - pos.gps_y) * (y_path - pos.gps_y));
-    double angle = theta - (-90 + pos.ins_heading_angle) / 180 * PI;
-
-    x_vehicle = -cos(angle) * distance;
-    y_vehicle = sin(angle) * distance;
-    return  iv::Point2D(x_vehicle, y_vehicle);
-}
-
-///车体转大地
-iv::GPS_INS iv::decition::Coordinate_UnTransfer(double x_path, double y_path, iv::GPS_INS pos)
-{
-    iv::GPS_INS gps_ins;
-    double x_vehicle, y_vehicle;
-    double theta = atan2(x_path, y_path);
-
-    double distance = sqrt(x_path * x_path + y_path * y_path);
-    double angle = (pos.ins_heading_angle / 180 * PI + theta);
-
-    x_vehicle = pos.gps_x + distance * sin(angle);
-    y_vehicle = pos.gps_y + distance * cos(angle);
-    gps_ins.gps_x = x_vehicle;
-    gps_ins.gps_y = y_vehicle;
-
-    return  gps_ins;
-}
-
-double iv::decition::GetDistance(iv::Point2D x1, iv::Point2D x2)
-{
-    return sqrt((x1.x - x2.x) * (x1.x - x2.x) + (x1.y - x2.y) * (x1.y - x2.y));
-}
-
-double iv::decition::GetDistance(iv::GPS_INS p1, iv::GPS_INS p2)
-{
-    return sqrt((p1.gps_x - p2.gps_x) * (p1.gps_x - p2.gps_x) + (p1.gps_y - p2.gps_y) * (p1.gps_y - p2.gps_y));
-}
-
-
-
-
-//GPS转大地坐标
-void iv::decition::BLH2XYZ(iv::GPS_INS gp)
-{
-    int nFlag = 2;
-
-    double B = gp.gps_lat;
-
-    double L = gp.gps_lng;
-
-
-
-    double N, E, h;
-    double L0 = GetL0InDegree(L);//根据经度求中央子午线经度
-
-    double a = 6378245.0;            //地球半径  北京6378245
-    double F = 298.257223563;        //地球扁率
-    double iPI = 0.0174532925199433; //2pi除以360,用于角度转换
-
-    double f = 1 / F;
-    double b = a * (1 - f);
-    double ee = (a * a - b * b) / (a * a);
-    double e2 = (a * a - b * b) / (b * b);
-    double n = (a - b) / (a + b), n2 = (n * n), n3 = (n2 * n), n4 = (n2 * n2), n5 = (n4 * n);
-    double al = (a + b) * (1 + n2 / 4 + n4 / 64) / 2;
-    double bt = -3 * n / 2 + 9 * n3 / 16 - 3 * n5 / 32;
-    double gm = 15 * n2 / 16 - 15 * n4 / 32;
-    double dt = -35 * n3 / 48 + 105 * n5 / 256;
-    double ep = 315 * n4 / 512;
-
-    B = B * iPI;
-    L = L * iPI;
-    L0 = L0 * iPI;
-
-    double l = L - L0, cl = (cos(B) * l), cl2 = (cl * cl), cl3 = (cl2 * cl), cl4 = (cl2 * cl2), cl5 = (cl4 * cl), cl6 = (cl5 * cl), cl7 = (cl6 * cl), cl8 = (cl4 * cl4);
-    double lB = al * (B + bt * sin(2 * B) + gm * sin(4 * B) + dt * sin(6 * B) + ep * sin(8 * B));
-    double t = tan(B), t2 = (t * t), t4 = (t2 * t2), t6 = (t4 * t2);
-    double Nn = a / sqrt(1 - ee * sin(B) * sin(B));
-    double yt = e2 * cos(B) * cos(B);
-    N = lB;
-    N += t * Nn * cl2 / 2;
-    N += t * Nn * cl4 * (5 - t2 + 9 * yt + 4 * yt * yt) / 24;
-    N += t * Nn * cl6 * (61 - 58 * t2 + t4 + 270 * yt - 330 * t2 * yt) / 720;
-    N += t * Nn * cl8 * (1385 - 3111 * t2 + 543 * t4 - t6) / 40320;
-
-    E = Nn * cl;
-    E += Nn * cl3 * (1 - t2 + yt) / 6;
-    E += Nn * cl5 * (5 - 18 * t2 + t4 + 14 * yt - 58 * t2 * yt) / 120;
-    E += Nn * cl7 * (61 - 479 * t2 + 179 * t4 - t6) / 5040;
-
-    E += 500000;
-    if (nFlag == 1)
-    {
-        //UTM投影
-        N = 0.9996 * N;
-        E = 0.9996 * (E - 500000.0) + 500000.0;//Get y
-    }
-    if (nFlag == 2)
-    {
-        //UTM投影
-        N = 0.9999 * N;
-        E = 0.9999 * (E - 500000.0) + 250000.0;//Get y
-    }
-
-    //原
-    //pt2d.x = N;
-    //pt2d.y = E;
-    //
-    gp.gps_x = E - 280000;
-    gp.gps_y = N - 4325000;
-
-}
-
-
-double iv::decition::GetL0InDegree(double dLIn)
-{
-    //3°带求带号及中央子午线经度(d的形式)
-    //具体公式请参阅《常用大地坐标系及其变换》朱华统,解放军出版社138页
-    double L = dLIn;//d.d
-    double L_ddd_Style = L;
-    double ZoneNumber = (int)((L_ddd_Style - 1.5) / 3.0) + 1;
-    double L0 = ZoneNumber * 3.0;//degree
-    return L0;
-}
+#include <decition/adc_tools/transfer.h>
+#include <decition/decition_type.h>
+#include <math.h>
+#include <iostream>
+#include <fstream>
+using namespace std;
+#define PI (3.1415926535897932384626433832795)
+
+
+
+///大地转车体
+iv::Point2D iv::decition::Coordinate_Transfer(double x_path, double y_path, iv::GPS_INS pos)
+{
+    double x_vehicle, y_vehicle;
+    double theta = atan2(x_path - pos.gps_x, y_path - pos.gps_y);
+
+    double distance = sqrt((x_path - pos.gps_x) * (x_path - pos.gps_x) + (y_path - pos.gps_y) * (y_path - pos.gps_y));
+    double angle = theta - (-90 + pos.ins_heading_angle) / 180 * PI;
+
+    x_vehicle = -cos(angle) * distance;
+    y_vehicle = sin(angle) * distance;
+    return  iv::Point2D(x_vehicle, y_vehicle);
+}
+
+///车体转大地
+iv::GPS_INS iv::decition::Coordinate_UnTransfer(double x_path, double y_path, iv::GPS_INS pos)
+{
+    iv::GPS_INS gps_ins;
+    double x_vehicle, y_vehicle;
+    double theta = atan2(x_path, y_path);
+
+    double distance = sqrt(x_path * x_path + y_path * y_path);
+    double angle = (pos.ins_heading_angle / 180 * PI + theta);
+
+    x_vehicle = pos.gps_x + distance * sin(angle);
+    y_vehicle = pos.gps_y + distance * cos(angle);
+    gps_ins.gps_x = x_vehicle;
+    gps_ins.gps_y = y_vehicle;
+
+    return  gps_ins;
+}
+
+double iv::decition::GetDistance(iv::Point2D x1, iv::Point2D x2)
+{
+    return sqrt((x1.x - x2.x) * (x1.x - x2.x) + (x1.y - x2.y) * (x1.y - x2.y));
+}
+
+double iv::decition::GetDistance(iv::GPS_INS p1, iv::GPS_INS p2)
+{
+    return sqrt((p1.gps_x - p2.gps_x) * (p1.gps_x - p2.gps_x) + (p1.gps_y - p2.gps_y) * (p1.gps_y - p2.gps_y));
+}
+
+
+
+
+//GPS转大地坐标
+void iv::decition::BLH2XYZ(iv::GPS_INS gp)
+{
+    int nFlag = 2;
+
+    double B = gp.gps_lat;
+
+    double L = gp.gps_lng;
+
+
+
+    double N, E, h;
+    double L0 = GetL0InDegree(L);//根据经度求中央子午线经度
+
+    double a = 6378245.0;            //地球半径  北京6378245
+    double F = 298.257223563;        //地球扁率
+    double iPI = 0.0174532925199433; //2pi除以360,用于角度转换
+
+    double f = 1 / F;
+    double b = a * (1 - f);
+    double ee = (a * a - b * b) / (a * a);
+    double e2 = (a * a - b * b) / (b * b);
+    double n = (a - b) / (a + b), n2 = (n * n), n3 = (n2 * n), n4 = (n2 * n2), n5 = (n4 * n);
+    double al = (a + b) * (1 + n2 / 4 + n4 / 64) / 2;
+    double bt = -3 * n / 2 + 9 * n3 / 16 - 3 * n5 / 32;
+    double gm = 15 * n2 / 16 - 15 * n4 / 32;
+    double dt = -35 * n3 / 48 + 105 * n5 / 256;
+    double ep = 315 * n4 / 512;
+
+    B = B * iPI;
+    L = L * iPI;
+    L0 = L0 * iPI;
+
+    double l = L - L0, cl = (cos(B) * l), cl2 = (cl * cl), cl3 = (cl2 * cl), cl4 = (cl2 * cl2), cl5 = (cl4 * cl), cl6 = (cl5 * cl), cl7 = (cl6 * cl), cl8 = (cl4 * cl4);
+    double lB = al * (B + bt * sin(2 * B) + gm * sin(4 * B) + dt * sin(6 * B) + ep * sin(8 * B));
+    double t = tan(B), t2 = (t * t), t4 = (t2 * t2), t6 = (t4 * t2);
+    double Nn = a / sqrt(1 - ee * sin(B) * sin(B));
+    double yt = e2 * cos(B) * cos(B);
+    N = lB;
+    N += t * Nn * cl2 / 2;
+    N += t * Nn * cl4 * (5 - t2 + 9 * yt + 4 * yt * yt) / 24;
+    N += t * Nn * cl6 * (61 - 58 * t2 + t4 + 270 * yt - 330 * t2 * yt) / 720;
+    N += t * Nn * cl8 * (1385 - 3111 * t2 + 543 * t4 - t6) / 40320;
+
+    E = Nn * cl;
+    E += Nn * cl3 * (1 - t2 + yt) / 6;
+    E += Nn * cl5 * (5 - 18 * t2 + t4 + 14 * yt - 58 * t2 * yt) / 120;
+    E += Nn * cl7 * (61 - 479 * t2 + 179 * t4 - t6) / 5040;
+
+    E += 500000;
+    if (nFlag == 1)
+    {
+        //UTM投影
+        N = 0.9996 * N;
+        E = 0.9996 * (E - 500000.0) + 500000.0;//Get y
+    }
+    if (nFlag == 2)
+    {
+        //UTM投影
+        N = 0.9999 * N;
+        E = 0.9999 * (E - 500000.0) + 250000.0;//Get y
+    }
+
+    //原
+    //pt2d.x = N;
+    //pt2d.y = E;
+    //
+    gp.gps_x = E - 280000;
+    gp.gps_y = N - 4325000;
+
+}
+
+
+double iv::decition::GetL0InDegree(double dLIn)
+{
+    //3°带求带号及中央子午线经度(d的形式)
+    //具体公式请参阅《常用大地坐标系及其变换》朱华统,解放军出版社138页
+    double L = dLIn;//d.d
+    double L_ddd_Style = L;
+    double ZoneNumber = (int)((L_ddd_Style - 1.5) / 3.0) + 1;
+    double L0 = ZoneNumber * 3.0;//degree
+    return L0;
+}

+ 27 - 27
src/decition/decition_brain/decition/adc_tools/transfer.h

@@ -1,27 +1,27 @@
-#pragma once
-#ifndef _IV_DECITION_TRANSFER_
-#define _IV_DECITION_TRANSFER_
-
-#include <common/gps_type.h>
-#include <decition/decition_type.h>
-#include<vector> 
-
-namespace iv {
-    namespace decition {
-        //根据传感器传输来的信息作出决策
-
-        double GetL0InDegree(double dLIn);
-
-        void BLH2XYZ(GPS_INS gps_ins);
-
-        ///大地转车体
-        Point2D Coordinate_Transfer(double x_path, double y_path, GPS_INS pos);
-
-        ///车体转大地
-        GPS_INS Coordinate_UnTransfer(double x_path, double y_path, GPS_INS pos);
-        double GetDistance(Point2D x1, Point2D x2);
-        double GetDistance(GPS_INS p1, GPS_INS p2);
-    }
-}
-
-#endif // ! _IV_DECITION_TRANSFER_
+#pragma once
+#ifndef _IV_DECITION_TRANSFER_
+#define _IV_DECITION_TRANSFER_
+
+#include <common/gps_type.h>
+#include <decition/decition_type.h>
+#include<vector> 
+
+namespace iv {
+    namespace decition {
+        //根据传感器传输来的信息作出决策
+
+        double GetL0InDegree(double dLIn);
+
+        void BLH2XYZ(GPS_INS gps_ins);
+
+        ///大地转车体
+        Point2D Coordinate_Transfer(double x_path, double y_path, GPS_INS pos);
+
+        ///车体转大地
+        GPS_INS Coordinate_UnTransfer(double x_path, double y_path, GPS_INS pos);
+        double GetDistance(Point2D x1, Point2D x2);
+        double GetDistance(GPS_INS p1, GPS_INS p2);
+    }
+}
+
+#endif // ! _IV_DECITION_TRANSFER_

+ 1282 - 1281
src/decition/decition_brain/decition/brain.cpp

@@ -1,1281 +1,1282 @@
-#include <decition/brain.h>
-#include <fstream>
-#include <time.h>
-#include <exception>
-#include <decition/adc_tools/gnss_coordinate_convert.h>
-#include <common/logout.h>
-#include <decition/adc_tools/transfer.h>
-
-#include <iostream>
-#include "xmlparam.h"
-#include "qcoreapplication.h"
-
-
-extern std::string gstrmemdecition;
-extern std::string gstrmembrainstate;
-extern iv::Ivlog * givlog;
-extern std::string gstrmemchassis;
-
-#define LOG_ENABLE
-
-namespace iv {
-namespace decition {
-iv::decition::BrainDecition * gbrain;
-
-
-        void ListenTraceMap(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
-        {
-            (void)&index;
-            (void)dt;
-            (void)strmemname;
-            gbrain->UpdateMap(strdata,nSize);
-            gbrain->UpdateSate();
-        }
-
-        void ListenVbox(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
-        {
-            (void)&index;
-            (void)dt;
-            (void)strmemname;
-            gbrain->UpdateVbox(strdata,nSize);
-            gbrain->UpdateSate();
-        }
-
-        void ListenHMI(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
-        {
-            (void)&index;
-            (void)dt;
-            (void)strmemname;
-            gbrain->UpdateHMI(strdata,nSize);
-        }
-
-        void ListenPAD(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
-        {
-            (void)&index;
-            (void)dt;
-            (void)strmemname;
-            gbrain->UpdatePAD(strdata,nSize);
-        }
-
-        void ListenPlatform(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
-        {
-            (void)&index;
-            (void)dt;
-            (void)strmemname;
-            gbrain->UpdatePlatform(strdata,nSize);
-        }
-
-        void ListenGroup(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
-        {
-            (void)&index;
-            (void)dt;
-            (void)strmemname;
-            gbrain->UpdateGroupInfo(strdata,nSize);
-        }
-
-    /*    void ListenMap_change_req(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
-        {
-            iv::formation_map_index::map map;
-            if(false == map.ParseFromArray(strdata,nSize))
-            {
-                givlog->error("GPS","[%s] Listencansend Parse fail.",__func__);
-                return;
-            }else{
-               gbrain->UpdateSate();
-            }
-        //    map.index()-1  map index num.
-        }*/
-
-    }
-
-}
-
-
-
-iv::decition::BrainDecition::BrainDecition()
-{
-    //    mpasd = new Adcivstatedb();
-    look1 = 0.0;
-    look2 = 0.0;
-    look3 = 0.0;
-    look4 = 0.0;
-    look5 = 0.0;
-    look6 = 0.0;
-    look7 = 0.0;
-    obs_lidar_grid_ = NULL;
-    old_obs_lidar_grid_ = NULL;
-    obs_camera_ = NULL;
-    //    controller = boost::shared_ptr<iv::control::Controller>(new iv::control::Controller());
-
-    //    carcall = new iv::carcalling::carcalling();
-    eyes = new iv::perception::Eyes();
-    //	decitionMaker = new iv::decition::DecitionMaker();
-
-    decitionGps00 = new iv::decition::DecideGps00();
-    decitionLine00=new iv::decition::DecideLine00();
-
-    //	decitionGpsUnit = new iv::decition::DecideGpsUnit();
-
-    //	decitionExecuter = new iv::decition::DecitionExecuter(controller);
-
-    iv::decition::gbrain = this;
-
-
-    mpa = iv::modulecomm::RegisterRecv("tracemap",iv::decition::ListenTraceMap);
-
-    mpvbox = iv::modulecomm::RegisterRecv("vbox",iv::decition::ListenVbox);
-
-    mpaVechicleState = iv::modulecomm::RegisterSend(gstrmembrainstate.data(),10000,10);
-
-
-    mpaToPlatform = iv::modulecomm::RegisterSend("toplatform",10*sizeof(iv::platform::PlatFormMsg),10);
-    mpaDecition = iv::modulecomm::RegisterSend(gstrmemdecition.data(),10*sizeof(iv::decition::DecitionBasic),1);
-
-    mpaPAD = iv::modulecomm::RegisterRecv("pad",iv::decition::ListenPAD);
-    mpaHMI = iv::modulecomm::RegisterRecv("hmi",iv::decition::ListenHMI);
-
-    mpaPlatform = iv::modulecomm::RegisterRecv("platformfrom",iv::decition::ListenPlatform);
-
-    mpaGroup = iv::modulecomm::RegisterRecv("p900_send",iv::decition::ListenGroup);
- //   iv::modulecomm::RegisterRecv("map_index",ListenMap_change_req);
-
-
-
-
-    mpamapreq = iv::modulecomm::RegisterSend("mapreq",1000,1);
-
-    ModuleFun funchassis =std::bind(&iv::decition::BrainDecition::UpdateChassis,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
-    void * pa = iv::modulecomm::RegisterRecvPlus(gstrmemchassis.data(),funchassis);
-
-    mpaPlanTrace = iv::modulecomm::RegisterSend("plantrace",100000,1);
-
-    mTime.start();
-    mnOldTime = mTime.elapsed();
-
-}
-
-iv::decition::BrainDecition::~BrainDecition()
-{
-}
-
-
-void iv::decition::BrainDecition::inialize() {
-    //	controller->inialize();
-    eyes->inialize();
-    //    carcall->start();
-}
-
-
-void iv::decition::BrainDecition::run() {
-
-    double last = 0;
-
-    iv::decition::Decition decition_gps = NULL;
-    iv::decition::Decition decition_lidar = NULL;
-    iv::decition::Decition decition_radar = NULL;
-    iv::decition::Decition decition_camera = NULL;
-    iv::decition::Decition decition_localmap = NULL;
-
-    iv::decition::Decition dgtemp(new iv::decition::DecitionBasic);
-    decition_gps = dgtemp;
-    decition_gps->brake = 0;
-    decition_gps->accelerator = 0;
-    decition_gps->wheel_angle = 0;
-
-    //controller->auto_drive_mode_enable(true);
-
-    /*Decition test(new DecitionBasic);
-    while (true)
-    {
-        test->accelerator = 1.2;
-        test->wheel_angle = 0;
-        decitionExecuter->executeDecition(test);
-        Sleep(5000);
-
-        test->accelerator = 0;
-        test->wheel_angle = 0;
-        decitionExecuter->executeDecition(test);
-        Sleep(5000);
-
-        test->accelerator = -1.2;
-        test->wheel_angle = 0;
-        decitionExecuter->executeDecition(test);
-        Sleep(5000);
-
-        test->accelerator = 0;
-        test->wheel_angle = 45;
-        decitionExecuter->executeDecition(test);
-        Sleep(5000);
-
-        test->accelerator = 0;
-        test->wheel_angle = 0;
-        decitionExecuter->executeDecition(test);
-        Sleep(5000);
-
-        test->accelerator = 0;
-        test->wheel_angle = -60;
-        decitionExecuter->executeDecition(test);
-        Sleep(5000);
-
-    }*/
-
-    //   std::cout<<"start run."<<std::endl;
-
-    //   ServiceCarStatus.mbRunPause = false;
-
-    bool bRun;
-    int nValueSize;
-
-    //    if(mpasd->LoadState("runstate",(char *)&bRun,sizeof(bool),&nValueSize) == true)
-    //    {
-    //        if(bRun)
-    //        {
-    //            ServiceCarStatus.mbRunPause = false;
-    //        }
-    //        else
-    //        {
-    //            ServiceCarStatus.mbRunPause = true;
-    //        }
-    //    }
-
-    char * strmap = new char[10000000];
-    int nMapSize;
-
-    //    if(mpasd->LoadState("map",strmap,10000000,&nMapSize) == true)
-    //    {
-    //        UpdateMap(strmap,nMapSize);
-    //    }
-
-    QString strpath = QCoreApplication::applicationDirPath();
-    strpath = strpath + "/ADS_decision.xml";
-    iv::xmlparam::Xmlparam xp(strpath.toStdString());
-    ServiceCarStatus.msysparam.mstrvin = xp.GetParam("vin","10000000000000001");
-    ServiceCarStatus.msysparam.mstrid = xp.GetParam("id","1");
-    ServiceCarStatus.msysparam.mstriccid = xp.GetParam("iccid","11111111111111111111");
-    ServiceCarStatus.msysparam.mvehtype= xp.GetParam("vehType","ge3");
-
-
-
-    /*=============     20200113 apollo_fu  add ===========*/
-    std::string str_zhuchetime = xp.GetParam("zhuchetime","16");
-    ServiceCarStatus.msysparam.mzhuchetime =atoi(str_zhuchetime.data());
-    /*============= end ================================== */
-
-    std::string strepsoff = xp.GetParam("epsoff","0.0");
-    ServiceCarStatus.mfEPSOff = atof(strepsoff.data());
-
-    std::string strroadmode_vel = xp.GetParam("roadmode0","10");
-    ServiceCarStatus.mroadmode_vel.mfmode0 = atof(strroadmode_vel.data());
-
-    strroadmode_vel = xp.GetParam("roadmode11","30");
-    ServiceCarStatus.mroadmode_vel.mfmode11 = atof(strroadmode_vel.data());
-
-
-    strroadmode_vel = xp.GetParam("roadmode14","15");
-    ServiceCarStatus.mroadmode_vel.mfmode14 = atof(strroadmode_vel.data());
-
-    //float a = ServiceCarStatus.mroadmode_vel.mfmode14;
-    //cout<<"........"<<a<<endl;
-
-    strroadmode_vel = xp.GetParam("roadmode15","15");
-    ServiceCarStatus.mroadmode_vel.mfmode15 = atof(strroadmode_vel.data());
-
-    /*==================== 20200113    apollo_fu add =================*/
-    strroadmode_vel = xp.GetParam("roadmode5","10");
-    ServiceCarStatus.mroadmode_vel.mfmode5 = atof(strroadmode_vel.data());
-
-    strroadmode_vel = xp.GetParam("roadmode13","5");
-    ServiceCarStatus.mroadmode_vel.mfmode13 = atof(strroadmode_vel.data());
-
-    strroadmode_vel = xp.GetParam("roadmode16","8");
-    ServiceCarStatus.mroadmode_vel.mfmode16 = atof(strroadmode_vel.data());
-
-    strroadmode_vel = xp.GetParam("roadmode17","8");
-    ServiceCarStatus.mroadmode_vel.mfmode17 = atof(strroadmode_vel.data());
-
-    strroadmode_vel = xp.GetParam("roadmode18","5");
-    ServiceCarStatus.mroadmode_vel.mfmode18 = atof(strroadmode_vel.data());
-
-
-
-    /*=========================    end   =============================*/
-
-    std::string group_cotrol = xp.GetParam("group","false");
-    if(group_cotrol=="true"){
-        ServiceCarStatus.group_control=true;
-    }else{
-        ServiceCarStatus.group_control=false;
-    }
-
-    std::string speed_control = xp.GetParam("speed","false");
-    if(speed_control=="true"){
-        ServiceCarStatus.speed_control=true;
-    }else{
-        ServiceCarStatus.speed_control=false;
-    }
-
-
-
-    std::string strparklat = xp.GetParam("parklat","39.0624557");
-    std::string strparklng = xp.GetParam("parklng","117.3575493");
-    std::string strparkheading = xp.GetParam("parkheading","112.5");
-    std::string strparktype = xp.GetParam("parktype","1");
-
-    ServiceCarStatus.mfParkLat = atof(strparklat.data());
-    ServiceCarStatus.mfParkLng = atof(strparklng.data());
-    ServiceCarStatus.mfParkHeading = atof(strparkheading.data());
-    ServiceCarStatus.mnParkType = atoi(strparktype.data());
-
-    ServiceCarStatus.mLidarRotation = atof(xp.GetParam("LidarRotation","90.0").data());
-    ServiceCarStatus.mLidarRangeUnit = atof(xp.GetParam("LidarRangeUnit","5.0").data());
-
-
-
-    std::string lightlon = xp.GetParam("lightlon","0");
-    std::string lightlat = xp.GetParam("lightlat","0");
-    ServiceCarStatus.iTrafficeLightLat=atof(lightlat.data());
-    ServiceCarStatus.iTrafficeLightLon=atof(lightlon.data());
-
-
-
-    //mobileEye
-    std::string   timeWidth =xp.GetParam("waitGpsTimeWidth","5000");
-    std::string   garageLong =xp.GetParam("outGarageLong","10");
-    ServiceCarStatus.waitGpsTimeWidth=atof(timeWidth.data());
-    ServiceCarStatus.outGarageLong=atof(garageLong.data());
-    //mobileEye end
-
-
-    //lidar start
-    std::string lidarGpsXiuzheng = xp.GetParam("lidarGpsXiuzheng","1.0");
-    std::string radarGpsXiuzheng = xp.GetParam("radarGpsXiuzheng","3.0");
-    std::string rearRadarGpsXiuzheng = xp.GetParam("rearRadarGpsXiuzheng","0.5");
-    std::string rearLidarGpsXiuzheng = xp.GetParam("rearLidarGpsXiuzheng","1.0");
-    std::string frontGpsXiuzheng = xp.GetParam("frontGpsXiuzheng","3.0");
-    std::string rearGpsXiuzheng = xp.GetParam("rearGpsXiuzheng","1.0");
-    std::string gpsOffset_x = xp.GetParam("gpsOffset_X","0");
-    std::string gpsOffset_y = xp.GetParam("gpsOffset_Y","0");
-    std::string strexternmpc = xp.GetParam("ExternMPC","false");  //If Use MPC set true
-    if(strexternmpc == "true")
-    {
-        mbUseExternMPC = true;
-    }
-
-    ServiceCarStatus.msysparam.lidarGpsXiuzheng = atof(lidarGpsXiuzheng.data());
-    ServiceCarStatus.msysparam.radarGpsXiuzheng = atof(radarGpsXiuzheng.data());
-    ServiceCarStatus.msysparam.rearRadarGpsXiuzheng = atof(rearRadarGpsXiuzheng.data());
-    ServiceCarStatus.msysparam.rearLidarGpsXiuzheng = atof(rearLidarGpsXiuzheng.data());
-    ServiceCarStatus.msysparam.frontGpsXiuzheng = atof(frontGpsXiuzheng.data());
-    ServiceCarStatus.msysparam.rearGpsXiuzheng = atof(rearGpsXiuzheng.data());
-    ServiceCarStatus.msysparam.gpsOffset_x = atof(gpsOffset_x.data());
-    ServiceCarStatus.msysparam.gpsOffset_y = atof(gpsOffset_y.data());
-    // lidar end
-
-    std::string strObsPredict = xp.GetParam("obsPredict","false");  //If Use MPC set true
-    if(strObsPredict == "true")
-    {
-        ServiceCarStatus.useObsPredict = true;
-    }
-    //map
-
-    mstrmemmap_index = xp.GetParam("msg_mapindex","map_index");
-
-
-    while (eyes->isAllSensorRunning())
-    {
-        if(navigation_data.size() <1)
-        {
-            iv::map::mapreq x;
-            x.set_maptype(1);
-            int nsize = x.ByteSize();
-            char * str = new char[nsize];
-            if(x.SerializeToArray(str,nsize))
-            {
-                iv::modulecomm::ModuleSendMsg(mpamapreq,str,nsize);
-            }
-            else
-            {
-                std::cout<<"iv::map::mapreq serialize error."<<std::endl;
-            }
-            delete str;
-        }
-
-
-        iv::GPSData gps_data_;			//gps 惯导数据
-
-        //       qDebug("size = %d",navigation_data.size());
-
-
-
-        std::shared_ptr<std::vector<iv::Perception::PerceptionOutput>> lidar_per(new std::vector<iv::Perception::PerceptionOutput>);
-
-        bool brun =ServiceCarStatus.mbRunPause;
-        if(ServiceCarStatus.mnBocheComplete > 0)
-        {
-            ServiceCarStatus.mbBrainCtring = false;
-            ServiceCarStatus.mbRunPause = true;
-            ServiceCarStatus.mnBocheComplete--;
-        }
-        if((ServiceCarStatus.mbRunPause)||(navigation_data.size()<1)||(ServiceCarStatus.mnBocheComplete>0))
-        {
-            ServiceCarStatus.mbBrainCtring = false;
-            decition_gps->brake = 6;
-            decition_gps->accelerator = -0.5;
-            decition_gps->wheel_angle = 0;
-            decition_gps->torque = 0;
-            decition_gps->mode = 0;
-            //decitionExecuter->executeDecition(decition_gps);
-                   ShareDecition(decition_gps);  //apollo_fu 20200413 qudiaozhushi
-            ServiceCarStatus.mfAcc = decition_gps->accelerator;
-            ServiceCarStatus.mfWheel = decition_gps->wheel_angle;
-            ServiceCarStatus.mfBrake = decition_gps->brake;
-
-            iv::brain::brainstate xbs;
-            xbs.set_mbbocheenable(ServiceCarStatus.bocheEnable);
-            xbs.set_mbbrainrunning(false);
-            xbs.set_mflidarobs(ServiceCarStatus.mLidarObs);
-            xbs.set_mfradarobs(ServiceCarStatus.mRadarObs);
-            xbs.set_mfobs(ServiceCarStatus.mObs);
-            xbs.set_decision_period(decision_period);
-            ShareBrainstate(xbs);    //apollo_fu 20200413 qudiaozhushi
-            //            iv::decition::VehicleStateBasic vsb;
-            //            vsb.mbBocheEnable = ServiceCarStatus.bocheEnable;
-            //            vsb.mfLidarObs = ServiceCarStatus.mLidarObs;
-            //            vsb.mfRadarObs = ServiceCarStatus.mRadarObs;
-            //            vsb.mfObs = ServiceCarStatus.mRadarObs;
-            //            vsb.decision_period = decision_period;
-            //            vsb.mbBrainRunning = false;
-            ////             mpaVechicleState->writemsg((char *)&vsb,sizeof(iv::decition::VehicleStateBasic));
-            //            iv::modulecomm::ModuleSendMsg(mpaVechicleState,(char *)&vsb,sizeof(iv::decition::VehicleStateBasic));
-
-#ifdef Q_OS_LINUX
-            usleep(10000);
-#endif
-#ifdef Q_OS_WIN32
-            boost::this_thread::sleep(boost::posix_time::milliseconds(10));
-#endif
-             std::cout<<"enter mbRunPause"<<std::endl;
-            continue;
-
-        }
-
-
-
-        ServiceCarStatus.mbBrainCtring = true;
-        obs_lidar_ = obs_radar_ = NULL;
-
-        int j;
-        //      gps_data_ = NULL;
-
-        //        if(obs_lidar_grid_ != NULL)free(obs_lidar_grid_);
-        if(obs_lidar_grid_ != NULL)
-        {
-            if(old_obs_lidar_grid_ != NULL) free(old_obs_lidar_grid_);
-            old_obs_lidar_grid_ = obs_lidar_grid_;
-        }
-
-        obs_lidar_grid_ = NULL;
-
-        if(obs_camera_ != NULL)free(obs_camera_);
-
-        obs_camera_ = NULL;
-
-
-
-        eyes->getSensorObstacle(obs_radar_, obs_camera_,gps_data_, obs_lidar_grid_);	//从传感器线程临界区交换数据
-
-
-
-
-
-        ServiceLidar.copylidarperto(lidar_per);
-
-        //        if(lidar_per->size() >0)
-        //        {
-        //            int i;
-        //            for(i=0;i<lidar_per->size();i++)
-        //            {
-        //                if(lidar_per->at(i).label>0)
-        //                {
-        //                    std::cout<<"label is"<<lidar_per->at(i).label<<" vy = "<<lidar_per->at(i).velocity.y<<std::endl;
-        //                }
-        //            }
-        //            //if size > 0, have perception result;
-        //        }
-
-        iv::ObsLiDAR obs_lidar_tmp(new std::vector<iv::ObstacleBasic>);
-        iv::ObsRadar obs_radar_tmp(new std::vector<iv::ObstacleBasic>);
-        iv::decition::Decition decition_final(new iv::decition::DecitionBasic);
-
-        //		if ((ServiceCarStatus.status[0] == true && ServiceCarStatus.status[1] == false && ServiceCarStatus.status[2] == false && ServiceCarStatus.status[3] == false && ServiceCarStatus.status[4] == true) ||
-        //			(ServiceCarStatus.status[0] == true && ServiceCarStatus.status[1] == false && ServiceCarStatus.status[2] == false && ServiceCarStatus.status[3] == true && ServiceCarStatus.status[4] == true) ||
-        //			(ServiceCarStatus.status[0] == true && ServiceCarStatus.status[1] == true && ServiceCarStatus.status[2] == true && ServiceCarStatus.status[3] == true && ServiceCarStatus.status[4] == true))
-        //		{
-        //			//停车
-        //			ServiceCarStatus.carState = 0;
-        //		}
-        //		else if ((ServiceCarStatus.status[0] == false && ServiceCarStatus.status[1] == false && ServiceCarStatus.status[2] == false && ServiceCarStatus.status[3] == false && ServiceCarStatus.status[4] == true) ||
-        //				 (ServiceCarStatus.status[0] == false && ServiceCarStatus.status[1] == true && ServiceCarStatus.status[2] == false && ServiceCarStatus.status[3] == true && ServiceCarStatus.status[4] == true))
-        //		{
-        //			//正常循迹
-        //			ServiceCarStatus.carState = 1;
-        //		}
-        //		else if ((ServiceCarStatus.status[0] == false && ServiceCarStatus.status[1] == false && ServiceCarStatus.status[2] == false && ServiceCarStatus.status[3] == true && ServiceCarStatus.status[4] == true) ||
-        //				 (ServiceCarStatus.status[0] == false && ServiceCarStatus.status[1] == true && ServiceCarStatus.status[2] == true && ServiceCarStatus.status[3] == true && ServiceCarStatus.status[4] == true))
-        //		{
-        //			//前往站点
-        //			ServiceCarStatus.carState = 2;
-        //		}
-
-        if (obs_lidar_) {	//激光雷达有障碍物
-            //          std::cout<<"obs lidar size = "<<obs_lidar_->size()<<std::endl;
-            //std::cout << "大脑处理激光雷达:" << obs_lidar_->at(0).nomal_x << " " << obs_lidar_->at(0).nomal_y << " " << obs_lidar_->at(0).nomal_z << std::endl;
-            obs_lidar_tmp = NULL;
-            obs_lidar_tmp.swap(obs_lidar_);
-        }
-        else
-        {
-            //           std::cout<<"no lidar obs"<<std::endl;
-        }
-        //ServiceCarStatus.obs_radar;
-        //毫米波雷达障碍物信息
-
-        if (obs_radar_) {
-            //std::cout << "大脑处理毫米波雷达:" << obs_radar_->at(0).nomal_x << " " << obs_radar_->at(0).nomal_y << " " << obs_radar_->at(0).nomal_z << std::endl;
-            obs_radar_tmp = NULL;
-            obs_radar_tmp.swap(obs_radar_);
-        }
-        if (obs_camera_) {
-            //std::cout << "大脑处理摄像头雷达:" << obs_camera_->at(0).nomal_x << " " << obs_camera_->at(0).nomal_y << " " << obs_camera_->at(0).nomal_z << std::endl;
-        }
-
-
-        //useMobileEye chuku
-        if(ServiceCarStatus.m_bOutGarage){
-            GPS_INS gps ;
-            if(gps_data_){
-                gps=*gps_data_;
-            }
-            decition_gps = decitionLine00->getDecideFromGPS(gps, navigation_data, obs_lidar_grid_,*lidar_per);  //chedaoxian
-
-            std::cout << "使用mobileEye决策"<< std::endl;
-        }
-        //useMobileEye chuku end;
-
-        if (gps_data_  &&!handPark && !ServiceCarStatus.m_bOutGarage){// && obs_lidar_grid_) {	//处理GPS数据
-            //todo gps_data_为当前读到的gps位置信息
-            //decition_gps = iv::decition::Decition(new iv::decition::DecitionBasic);
-            //ODS("接收GPS数据:%f\t\t%f\n", gps_data_->gps_x, gps_data_->gps_y);
-            //	decition_gps = decitionMaker->getDecideForGPS(*gps_data_,navigation_data);
-
-            //ODS("\n接收到的实时GPS数据:%f\t%f\t%f\n", gps_data_->gps_x, gps_data_->gps_y, gps_data_->ins_heading_angle);
-
-            //以下为正常用
-            //         if (gps_data_->valid == RTK_IMU_OK)
-            //        {
-            double start = GetTickCount();
-
-            //				decitionGps00->aim_gps_ins.gps_lat = carcall->lat;
-            //				decitionGps00->aim_gps_ins.gps_lng = carcall->lon;
-            /*iv::ObsRadar obs_radar_tmp(new std::vector<iv::ObstacleBasic>);
-                if(obs_radar_){
-                    obs_radar_tmp = NULL;
-                    obs_radar_tmp.swap(obs_radar_);
-                }*/
-            //decition_gps = decitionGpsUnit->getDecideFromGPS(*gps_data_, navigation_data, *obs_radar_tmp, obs_lidar_grid_);
-            //		decition_gps = decitionGpsUnit->getDecideFromGPS(*gps_data_, navigation_data, obs_lidar_grid_);     // 新的
-
-
-            if ( ServiceCarStatus.epsMode==0 && ServiceCarStatus.receiveEps) {
-                ServiceCarStatus.mbRunPause=true;
-
-            }
-            ServiceCarStatus.receiveEps=false;
-
-            lastMode=ServiceCarStatus.epsMode;
-            lastPause=ServiceCarStatus.mbRunPause;
-
-            if((fabs(mTime.elapsed() - mnOldTime)>40))
-            {
-                if((fabs(mTime.elapsed() - mnOldTime)<10000))
-                {
-                    ServiceCarStatus.mfCalAcc = (ServiceCarStatus.speed - mfSpeedLast)*1000/(fabs(mTime.elapsed() - mnOldTime))/3.6;
-                    ServiceCarStatus.mfVehAcc = (ServiceCarStatus.vehSpeed_st - mfVehSpeedLast)*1000/(fabs(mTime.elapsed() - mnOldTime))/3.6;
-                }else
-                {
-                    ServiceCarStatus.mfCalAcc = 0;
-                    ServiceCarStatus.mfVehAcc = 0;
-                }
-                mnOldTime = mTime.elapsed();
-                mfSpeedLast = ServiceCarStatus.speed;
-                mfVehSpeedLast=ServiceCarStatus.vehSpeed_st;
-            }
-
-            iv::LidarGridPtr templidar= obs_lidar_grid_;
-            if(templidar == NULL)templidar = old_obs_lidar_grid_;
-        //    GaussProjCal(gps_data_->gps_lng,gps_data_->gps_lat,&gps_data_->gps_x,&gps_data_->gps_y);
-
-            mMutexMap.lock();
-            decition_gps = decitionGps00->getDecideFromGPS(*gps_data_, navigation_data, templidar,*lidar_per,trafficLight);  // my dicition=============================
-            mMutexMap.unlock();
-
-            if(mbUseExternMPC)
-            {
-                fanya::GPS_INS xgpsins;
-                xgpsins.speed_y = gps_data_->speed/3.6;
-                xgpsins.gps_lat = gps_data_->gps_lat;
-                xgpsins.gps_lng = gps_data_->gps_lng;
-                xgpsins.ins_heading = gps_data_->ins_heading_angle;
-                mmpcapi.SetGPS(xgpsins);
-                mmpcapi.SetDesiredspeed(decition_gps->speed/3.6);
-                double mpc_speed,mpc_decision,mpc_wheel;
-                if(mmpcapi.GetDecision(mpc_speed,mpc_decision,mpc_wheel) == 0)
-                {
-                    decition_gps->wheel_angle = mpc_wheel;
-                }
-            }
-            iv::modulecomm::ModuleSendMsg(mpaPlanTrace,(char *)decitionGps00->planTrace.data(),decitionGps00->planTrace.size()*sizeof(iv::Point2D));
-
-
-
-            //      decition_gps = decitionLine00->getDecideFromGPS(*gps_data_, navigation_data, obs_lidar_grid_);
-            //ODS("\n决策:%f\t%f\t\t", decition_gps->speed, decition_gps->wheel_angle);
-            //ODS("\n接收到的实时GPS数据:%f\t%f\t%f\n", gps_data_->gps_x, gps_data_->gps_y,gps_data_->ins_heading_angle);
-
-            //carcall->is_arrived = decitionGps00->is_arrivaled;
-            //double end = GetTickCount();
-            decision_period = start - last;
-            std::cout<<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "\n周期时长:%f\n" << decision_period << std::endl;
-            //                iv::decition::VehicleStateBasic vsb;
-            //                vsb.mbBocheEnable = ServiceCarStatus.bocheEnable;
-            //                vsb.mfLidarObs = ServiceCarStatus.mLidarObs;
-            //                vsb.mfRadarObs = ServiceCarStatus.mRadarObs;
-            //                vsb.mfObs = ServiceCarStatus.mRadarObs;
-            //                vsb.decision_period = decision_period;
-            //                vsb.mbBrainRunning = ServiceCarStatus.mbBrainCtring;
-            ////                mpaVechicleState->writemsg((char *)&vsb,sizeof(iv::decition::VehicleStateBasic));
-
-            //                iv::modulecomm::ModuleSendMsg(mpaVechicleState,(char *)&vsb,sizeof(iv::decition::VehicleStateBasic));
-
-            iv::brain::brainstate xbs;
-            xbs.set_mbbocheenable(ServiceCarStatus.bocheEnable);
-            xbs.set_mbbrainrunning(true);  //apollo_fu debug ui 20200417
-            xbs.set_mflidarobs(ServiceCarStatus.mLidarObs);
-            xbs.set_mfradarobs(ServiceCarStatus.mRadarObs);
-            xbs.set_mfobs(ServiceCarStatus.mObs);
-            xbs.set_decision_period(decision_period);
-            ShareBrainstate(xbs);
-
-
-            //                decitionExecuter->executeDecition(decition_gps);
-            ShareDecition(decition_gps);
-
-            givlog->debug("acc is %f brake is %f wheel is %f",
-                          decition_gps->accelerator,decition_gps->brake,
-                          decition_gps->wheel_angle);
-            givlog->debug("period id %f",decision_period);
-
-            //	ODS("\n周期时长:%f\n", start - last);
-            //	ODS("\n决策时长:%f\n", end - start);
-            //	ODS("\n接收到的实时GPS车速:%f\n", gps_data_->speed);
-            //	ODS("\n接收到的实时GPS车y轴加速:%f\n", gps_data_->accel_y);
-            //	ODS("\n接收到的实时GPS车x轴加速:%f\n", gps_data_->accel_x);
-            std::cout<<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "\n决策加速度:%f\n" << decition_gps->accelerator << std::endl;
-            //		ODS("\n决策刹车:%f\n", decition_gps->brake);
-            std::cout<<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "\n决策方向:%f\n" << decition_gps->wheel_angle << std::endl;
-            std::cout<<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "\n决策速度:%f\n" << decition_gps->speed << std::endl;
-            last = start;
-            //decitionMaker->decideFromGPS(decition_gps, gps_data_, navigation_data);		//gps_data_为当前读到的gps位置信息  navigation_data为导航数据  decition_gps为根据前两者得出的决策速度与决策角度
-            //            }
-
-        }
-
-        if (handPark && decition_gps != NULL)
-        {
-            decition_gps->brake = 20;
-            decition_gps->accelerator = 0;
-            //			decitionExecuter->executeDecition(decition_gps);
-            ShareDecition(decition_gps);
-            //boost::this_thread::sleep(boost::posix_time::milliseconds(2000));
-
-#ifdef linux
-            usleep(2000000);
-#endif
-#ifdef WIN32
-            boost::this_thread::sleep(boost::posix_time::milliseconds(2000));
-            //           Sleep(2000);
-#endif
-            decition_gps->brake = 0;
-            decition_gps->accelerator = 0;
-            //			decitionExecuter->executeDecition(decition_gps);
-            //			ServiceCanUtil.set_handbrake_on();
-            //boost::this_thread::sleep(boost::posix_time::milliseconds(handParkTime));
-            ShareDecition(decition_gps);
-
-#ifdef linux
-            usleep(handParkTime*1000);
-#endif
-#ifdef WIN32
-            Sleep(handParkTime);
-#endif
-            handPark = false;
-        }
-
-
-        else
-        {
-            //boost::this_thread::sleep(boost::posix_time::milliseconds(1));
-
-#ifdef linux
-            usleep(1000);
-#endif
-#ifdef WIN32
-            Sleep(1);
-#endif
-            //			ODS("no gps data .sleep.\r\n");
-        }
-
-
-
-
-        //        if (decition_lidar || decition_radar || decition_camera || decition_gps || decition_lidar) {
-        //            //	decitionVoter->decideFromAll(decition_final, decition_lidar, decition_radar, decition_camera, decition_gps, decition_localmap);
-        //            //	decitionExecuter->executeDecition(decition_final);	//执行最终的决策
-        //            /*	decition_gps->brake = 0;
-        //            decition_gps->accelerator = 0;*/
-        //            look1 = decition_gps->accelerator;
-        //            look2 = decition_gps->brake;
-        //            look3 = decition_gps->wheel_angle;
-        //            look4 = decition_gps->speed;
-        //            look5 = decitionGps00->lidarDistance;
-        //            look6 = decitionGps00->myesrDistance;
-        //            look7 = decitionGps00->obsDistance;
-
-        //            decition_gps->grade=1;
-        //            decition_gps->mode=1;
-        //            decition_gps->speak=0;
-        //            decition_gps->handBrake=0;
-        //            decition_gps->bright=false;
-        //            decition_gps->engine=0;
-
-        //            if(ServiceCarStatus.bocheMode){
-        //                decition_gps->dangWei=2;
-        //            }else{
-        //                decition_gps->dangWei=1;
-        //            }
-
-
-        //            decition_gps->wheel_angle=max((float)-500.0,float(decition_gps->wheel_angle+ServiceCarStatus.mfEPSOff));
-        //            decition_gps->wheel_angle=min((float)500.0,decition_gps->wheel_angle);
-
-        //            //			decitionExecuter->executeDecition(decition_gps);
-        //            //           ShareDecition(decition_gps);
-        //        }
-
-        ServiceCarStatus.mfAcc = decition_gps->accelerator;
-        ServiceCarStatus.mfWheel = decition_gps->wheel_angle;
-        ServiceCarStatus.mfBrake = decition_gps->brake;
-
-        iv::platform::PlatFormMsg toplat;
-        toplat.carState = ServiceCarStatus.carState;	// 0:停车	1:正常循迹	2:前往站点
-        toplat.istostation = ServiceCarStatus.istostation;
-        toplat.currentstation = ServiceCarStatus.currentstation;
-        toplat.clientto = ServiceCarStatus.clientto;
-        toplat.amilng = ServiceCarStatus.amilng;
-        toplat.amilat = ServiceCarStatus.amilat;
-        //       mpaToPlatform->writemsg((char*)&toplat,sizeof(iv::platform::PlatFormMsg));
-
-        iv::modulecomm::ModuleSendMsg(mpaToPlatform,(char*)&toplat,sizeof(iv::platform::PlatFormMsg));
-        //ODS("\ngetSensor时长:%f\n", end1 - start1);
-    }
-    std::cout << "\n\n\n\n\n\n\n\n\n\n\nbrain线程退出\n" << std::endl;
-}
-
-bool iv::decition::BrainDecition::loadMapFromFile(std::string fileName) {
-    std::ifstream fis(fileName);//获取文件
-    std::string line;
-    std::vector<std::string> des;
-
-    if (fis.is_open() == false)
-        return false;
-    try {
-        while (std::getline(fis, line)) {//开始一行一行的读数据
-            boost::split(des, line, boost::is_any_of("\t"));
-            if (des.size() != 10)
-                throw "error";
-            iv::GPSData data(new iv::GPS_INS);
-            data->index = atoi(des[0].c_str());
-            data->gps_lng = atof(des[1].c_str());
-            data->gps_lat = atof(des[2].c_str());
-            data->speed_mode = atoi(des[3].c_str());
-            data->mode2 = atoi(des[4].c_str());
-            data->ins_heading_angle = atof(des[5].c_str());
-            data->runMode = atoi(des[6].c_str());
-            data->roadMode = atoi(des[7].c_str());
-            data->roadSum = atoi(des[8].c_str());
-            data->roadOri = atoi(des[9].c_str());
-            //      gps2xy(data->gps_lat, data->gps_lng, &data->gps_x, &data->gps_y);
-            GaussProjCal(data->gps_lng, data->gps_lat, &data->gps_x, &data->gps_y);
-            //data->speed = 5;	//调试用  所有点速度都设为5km/h
-            //LOG2(data->gps_x, data->gps_y);
-            //ODS("x %.20lf   y %.20lf\n", data->gps_x, data->gps_y);
-
-            //	iv::decition::BLH2XYZ(*data);   //重新转下大地坐标
-
-            if(data->roadMode==4){
-                data->ins_heading_angle=data->ins_heading_angle+180;
-                if(data->ins_heading_angle>=360)
-                    data->ins_heading_angle=data->ins_heading_angle-360;
-            }
-
-            navigation_data.push_back(data);
-        }
-
-    }
-    catch (...) {
-        fis.close();
-        return false;
-    }
-
-    fis.close();
-    return true;
-}
-
-bool iv::decition::BrainDecition::loadMapFromFile2(std::string fileName) {
-    std::ifstream fis(fileName);//获取文件
-    std::string line;
-    std::vector<std::string> des;
-
-    if (fis.is_open() == false)
-        return false;
-    try {
-        while (std::getline(fis, line)) {//开始一行一行的读数据
-            boost::split(des, line, boost::is_any_of("\t"));
-            if (des.size() != 10)
-                throw "error";
-            iv::GPSData data(new iv::GPS_INS);
-            data->index = atoi(des[0].c_str());
-            data->gps_lng = atof(des[1].c_str());
-            data->gps_lat = atof(des[2].c_str());
-            data->speed_mode = atoi(des[3].c_str());
-            data->mode2 = atoi(des[4].c_str());
-            data->ins_heading_angle = atof(des[5].c_str());
-            data->runMode = atoi(des[6].c_str());
-            data->roadMode = atoi(des[7].c_str());
-            data->roadSum = atoi(des[8].c_str());
-            data->roadOri = atoi(des[9].c_str());
-            GaussProjCal(data->gps_lng, data->gps_lat, &data->gps_x, &data->gps_y);
-            navigation_data2.push_back(data);
-        }
-    }
-    catch (...) {
-        fis.close();
-        return false;
-    }
-
-    fis.close();
-    return true;
-}
-
-bool iv::decition::BrainDecition::loadMapFromFile3(std::string fileName) {
-    std::ifstream fis(fileName);//获取文件
-    std::string line;
-    std::vector<std::string> des;
-
-    if (fis.is_open() == false)
-        return false;
-    try {
-        while (std::getline(fis, line)) {//开始一行一行的读数据
-            boost::split(des, line, boost::is_any_of("\t"));
-            if (des.size() != 10)
-                throw "error";
-            iv::GPSData data(new iv::GPS_INS);
-            data->index = atoi(des[0].c_str());
-            data->gps_lng = atof(des[1].c_str());
-            data->gps_lat = atof(des[2].c_str());
-            data->speed_mode = atoi(des[3].c_str());
-            data->mode2 = atoi(des[4].c_str());
-            data->ins_heading_angle = atof(des[5].c_str());
-            data->runMode = atoi(des[6].c_str());
-            data->roadMode = atoi(des[7].c_str());
-            data->roadSum = atoi(des[8].c_str());
-            data->roadOri = atoi(des[9].c_str());
-            GaussProjCal(data->gps_lng, data->gps_lat, &data->gps_x, &data->gps_y);
-            navigation_data3.push_back(data);
-        }
-    }
-    catch (...) {
-        fis.close();
-        return false;
-    }
-
-    fis.close();
-    return true;
-}
-
-bool iv::decition::BrainDecition::loadMapFromFile4(std::string fileName) {
-    std::ifstream fis(fileName);//获取文件
-    std::string line;
-    std::vector<std::string> des;
-
-    if (fis.is_open() == false)
-        return false;
-    try {
-        while (std::getline(fis, line)) {//开始一行一行的读数据
-            boost::split(des, line, boost::is_any_of("\t"));
-            if (des.size() != 10)
-                throw "error";
-            iv::GPSData data(new iv::GPS_INS);
-            data->index = atoi(des[0].c_str());
-            data->gps_lng = atof(des[1].c_str());
-            data->gps_lat = atof(des[2].c_str());
-            data->speed_mode = atoi(des[3].c_str());
-            data->mode2 = atoi(des[4].c_str());
-            data->ins_heading_angle = atof(des[5].c_str());
-            data->runMode = atoi(des[6].c_str());
-            data->roadMode = atoi(des[7].c_str());
-            data->roadSum = atoi(des[8].c_str());
-            data->roadOri = atoi(des[9].c_str());
-            GaussProjCal(data->gps_lng, data->gps_lat, &data->gps_x, &data->gps_y);
-            navigation_data4.push_back(data);
-        }
-    }
-    catch (...) {
-        fis.close();
-        return false;
-    }
-
-    fis.close();
-    return true;
-}
-
-void iv::decition::BrainDecition::start() {
-    thread_run = new boost::thread(boost::bind(&iv::decition::BrainDecition::run, this));
-}
-
-void iv::decition::BrainDecition::stop() {
-    //    carcall->stop();
-    thread_run->interrupt();
-    thread_run->join();
-}
-
-void iv::decition::BrainDecition::UpdateMap(const char *mapdata, const int mapdatasize)
-{
-    //    std::cout<<"update map "<<std::endl;
-    int gpsunitsize = sizeof(iv::GPS_INS);
-    int nMapSize = mapdatasize/gpsunitsize;
-    //    std::cout<<"map size is "<<nMapSize<<std::endl;
-
-    if(nMapSize < 1)return;
-
-    bool bUpdate = false;
-    if(nMapSize != navigation_data.size())
-    {
-        bUpdate = true;
-    }
-    else
-    {
-        iv::GPS_INS * p = (iv::GPS_INS *)mapdata;
-        if((p->gps_lat == navigation_data.at(0)->gps_lat)&&(p->ins_heading_angle == navigation_data.at(0)->ins_heading_angle))
-        {
-            //           qDebug("same map");
-            bUpdate = false;
-        }
-        else
-        {
-            bUpdate = true;
-        }
-    }
-
-    if(bUpdate)
-    {
-        std::vector<fanya::MAP_DATA> xvectorMAP;
-        int i;
-        mMutexMap.lock();
-        navigation_data.clear();
-        for(i=0;i<nMapSize;i++)
-        {
-            iv::GPS_INS x;
-            memcpy(&x,mapdata + i*gpsunitsize,gpsunitsize);
-            iv::GPSData data(new iv::GPS_INS);
-            *data = x;
-            navigation_data.push_back(data);
-
-            fanya::MAP_DATA xmapdata;
-            xmapdata.gps_lat = x.gps_lat;
-            xmapdata.gps_lng = x.gps_lng;
-            xmapdata.ins_heading = x.ins_heading_angle;
-            xvectorMAP.push_back(xmapdata);
-        }
-
-        mmpcapi.SetMAP(xvectorMAP);
-
-        if(ServiceCarStatus.speed_control==true){
-        Compute00().getDesiredSpeed(navigation_data);}
-        mMutexMap.unlock();
-        //        mpasd->SaveState("map",mapdata,mapdatasize);
-    }
-    else
-    {
-        //       qDebug("not need update");
-    }
-}
-
-void iv::decition::BrainDecition::ShareDecition(iv::decition::Decition decition)
-{
-    iv::brain::decition xdecition;
-    xdecition.set_accelerator(decition->accelerator);
-    xdecition.set_brake(decition->brake);
-    xdecition.set_leftlamp(decition->leftlamp);
-    xdecition.set_rightlamp(decition->rightlamp);
-    xdecition.set_speed(decition->speed);
-    xdecition.set_wheelangle(decition->wheel_angle);
-    xdecition.set_wheelspeed(decition->angSpeed);
-    xdecition.set_torque(decition->torque);
-    xdecition.set_mode(decition->mode);
-    xdecition.set_gear(decition->dangWei);
-    xdecition.set_handbrake(decition->handBrake);
-    xdecition.set_grade(decition->grade);
-    xdecition.set_engine(decition->engine);
-    xdecition.set_brakelamp(decition->brakeLight);
-    xdecition.set_ttc(ServiceCarStatus.mfttc);
-    xdecition.set_air_enable(decition->air_enable);
-    xdecition.set_air_temp(decition->air_temp);
-    xdecition.set_air_mode(decition->air_mode);
-    xdecition.set_wind_level(decition->wind_level);
-    xdecition.set_roof_light(decition->roof_light);
-    xdecition.set_home_light(decition->home_light);
-    xdecition.set_air_worktime(decition->air_worktime);
-    xdecition.set_air_offtime(decition->air_offtime);
-    xdecition.set_air_on(decition->air_on);
-
-
-
-    std::cout<<"===================shareDecition========================"<<std::endl;
-         std::cout<<"  torque_st:"<<ServiceCarStatus.torque_st
-                 <<"  decideTorque:"<<decition->torque <<"  decideBrake:"<<decition->brake
-                <<"  decition mode:"<<decition->mode
-        <<std::endl;
-    std::cout<<"========================================="<<std::endl;
-
-    givlog->verbose("torque_st: %ld",ServiceCarStatus.torque_st);
-     givlog->verbose("decideTorque: %ld",decition->torque);
-     givlog->verbose("decideBrake: %ld", decition->brake);
-     givlog->debug("wheelAng: %f",decition->wheel_angle);
-
-   //  xdecition.set_wheelangle(100);
-    static qint64 oldtime;
-
-    if((QDateTime::currentMSecsSinceEpoch() - oldtime)>100)
-    {
-        givlog->warn("brain interval is more than 100ms.  value is %ld",QDateTime::currentMSecsSinceEpoch() - oldtime);
-    }
-
-    givlog->verbose("decition time is %ld",QDateTime::currentMSecsSinceEpoch());
-    oldtime = QDateTime::currentMSecsSinceEpoch();
-
-
-    givlog->verbose("torque %f wheel %f dangwei %d ",decition->torque,
-                    decition->wheel_angle,decition->dangWei);
-    int nsize = xdecition.ByteSize();
-    char * str = new char[nsize];
-    std::shared_ptr<char> pstr;
-    pstr.reset(str);
-    if(xdecition.SerializeToArray(str,nsize))
-    {
-        if(ServiceCarStatus.mbRunPause == false)
-        {
-
-            iv::modulecomm::ModuleSendMsg(mpaDecition,str,nsize);
-        }
-    }
-    else
-    {
-        std::cout<<"iv::decition::BrainDecition::ShareDecition serialize error."<<std::endl;
-    }
-}
-
-void iv::decition::BrainDecition::ShareBrainstate(iv::brain::brainstate xbs)
-{
-    int nsize = xbs.ByteSize();
-    char * str = new char[nsize];
-    std::shared_ptr<char> pstr;
-    pstr.reset(str);
-    if(xbs.SerializeToArray(str,nsize))
-    {
-        iv::modulecomm::ModuleSendMsg(mpaVechicleState,str,nsize);
-    }
-    else
-    {
-        std::cout<<"iv::decition::BrainDecition::ShareBrainstate serialize error."<<std::endl;
-    }
-}
-
-void iv::decition::BrainDecition::UpdateHMI(const char *pdata, const int ndatasize)
-{
-    if(ndatasize < sizeof(iv::hmi::HMIBasic))return;
-
-    iv::hmi::hmimsg xhmimsg;
-    if(!xhmimsg.ParseFromArray(pdata,ndatasize))
-    {
-        givlog->error("iv::decition::BrainDecition::UpdateHMI parse error");
-        return;
-    }
-
-    ServiceCarStatus.mbRunPause = xhmimsg.mbpause();
-
-    if(xhmimsg.mbbochemode()){
-         ServiceCarStatus.bocheMode = true;
-    }
-    ServiceCarStatus.busmode = xhmimsg.mbbusmode();
-
-    if( ServiceCarStatus.bocheMode ){
-        int a=0;
-    }
-
-    bool bRun;
-    bRun = !ServiceCarStatus.mbRunPause;
-
-    //    mpasd->SaveState("runstate",(char *)&bRun,sizeof(bool));
-
-}
-
-void iv::decition::BrainDecition::UpdatePAD(const char *pdata, const int ndatasize)
-{
-//    if(ndatasize < sizeof(iv::hmi::HMIBasic))return;
-
-    iv::hmi::hmimsg xhmimsg;
-    if(!xhmimsg.ParseFromArray(pdata,ndatasize))
-    {
-        givlog->error("iv::decition::BrainDecition::UpdateHMI parse error");
-        return;
-    }
-
-    ServiceCarStatus.mbRunPause = xhmimsg.mbpause();
-
-    if(xhmimsg.mbbochemode()){
-         ServiceCarStatus.bocheMode = true;
-    }
-    ServiceCarStatus.busmode = xhmimsg.mbbusmode();
-
-    if( ServiceCarStatus.bocheMode ){
-        int a=0;
-    }
-
-    bool bRun;
-    bRun = !ServiceCarStatus.mbRunPause;
-
-    //    mpasd->SaveState("runstate",(char *)&bRun,sizeof(bool));
-
-}
-
-void iv::decition::BrainDecition::UpdatePlatform(const char *pdata, const int ndatasize)
-{
-    if(ndatasize < sizeof(iv::platform::PlatFormMsg))return;
-
-    iv::platform::PlatFormMsg x;
-    memcpy(&x,pdata,sizeof(iv::platform::PlatFormMsg));
-    ServiceCarStatus.carState = x.carState;	// 0:停车	1:正常循迹	2:前往站点
-    std::cout<<"car state "<<ServiceCarStatus.carState<<std::endl;
-    ServiceCarStatus.istostation = x.istostation;
-    ServiceCarStatus.currentstation = x.currentstation;
-    ServiceCarStatus.clientto = x.clientto;
-    ServiceCarStatus.amilng = x.amilng;
-    ServiceCarStatus.amilat = x.amilat;
-
-}
-
-void iv::decition::BrainDecition::UpdateChassis(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
-{
-    iv::chassis xchassis;
-    static int ncount = 0;
-    if(!xchassis.ParseFromArray(strdata,nSize))
-    {
-        std::cout<<"iv::decition::BrainDecition::UpdateChassis ParseFrom Array Error."<<std::endl;
-        return;
-    }
-
-    ServiceCarStatus.epb = xchassis.epbfault();
-    ServiceCarStatus.grade = xchassis.shift();
-    ServiceCarStatus.driverMode = xchassis.drivemode();
-    if(xchassis.has_epsmode()){
-        ServiceCarStatus.epsMode = xchassis.epsmode();
-        ServiceCarStatus.receiveEps=true;
-        if(ServiceCarStatus.epsMode == 0)
-        {
-            ServiceCarStatus.mbRunPause = true;
-        }
-    }
-    if(xchassis.has_torque())
-    {
-         ServiceCarStatus.torque_st = xchassis.torque();
-        if(ServiceCarStatus.msysparam.mvehtype=="bus"){
-            ServiceCarStatus.torque_st = xchassis.torque()*0.4;
-        }
-        std::cout<<"******* ServiceCarStatus.torque_st:"<< ServiceCarStatus.torque_st<<std::endl;
-        givlog->warn(" ServiceCarStatus.torque_st: is %f",ServiceCarStatus.torque_st);
-
-    }
-    //    if(xchassis.epsmode() == 1)
-    //    {
-    //        ncount++;
-    ////        if(ncount > 10)ServiceCarStatus.mbRunPause = true;
-    //    }
-    //    else
-    //    {
-    //        ncount = 0;
-    //    }
-}
-
-void iv::decition::BrainDecition::UpdateGroupInfo(const char *pdata, const int ndatasize){
-
-    iv::radio::radio_send group_message;
-    if(false == group_message.ParseFromArray(pdata,ndatasize))
-    {
-        std::cout<<"Listencansend Parse fail."<<std::endl;
-        return;
-    }
-    ServiceCarStatus.group_server_status = group_message.server_status();
-    ServiceCarStatus.group_comm_speed= (float)group_message.car_control_speed();
-    ServiceCarStatus.group_state= group_message.cmd_mode();
-
-    qDebug("updateGroupInfo %ld",QDateTime::currentMSecsSinceEpoch());
-    if(ServiceCarStatus.group_state!=2){
-        ServiceCarStatus.group_comm_speed=0;
-    }
-    qDebug("serverSt: %d, speed: %f, state: %d", ServiceCarStatus.group_server_status, ServiceCarStatus.group_comm_speed, ServiceCarStatus.group_state);
-
-
-}
-
-void iv::decition::BrainDecition::UpdateVbox(const char *pdata, const int ndatasize){
-
-    iv::vbox::vbox group_message;
-    if(false == group_message.ParseFromArray(pdata,ndatasize))
-    {
-        std::cout<<"Listencansend Parse fail."<<std::endl;
-        return;
-    }
-
-//  解析box信息
-//    ServiceCarStatus.group_server_status = group_message.server_status();
-//    ServiceCarStatus.group_comm_speed= (float)group_message.car_control_speed();
-//    ServiceCarStatus.group_state= group_message.cmd_mode();
-
-
-    trafficLight.leftColor=group_message.st_left();
-    trafficLight.rightColor=group_message.st_right();
-    trafficLight.straightColor=group_message.st_straight();
-    trafficLight.uturnColor=group_message.st_turn();
-    trafficLight.leftTime=group_message.time_left();
-    trafficLight.rightTime=group_message.time_right();
-    trafficLight.straightTime=group_message.time_straight();
-    trafficLight.uturnTime=group_message.time_turn();
-
-
-
-}
-
-void iv::decition::BrainDecition::UpdateSate(){
-     decitionGps00->isFirstRun=true;
-}
+#include <decition/brain.h>
+#include <fstream>
+#include <time.h>
+#include <exception>
+#include <decition/adc_tools/gnss_coordinate_convert.h>
+#include <common/logout.h>
+#include <decition/adc_tools/transfer.h>
+
+#include <iostream>
+#include "xmlparam.h"
+#include "qcoreapplication.h"
+
+
+extern std::string gstrmemdecition;
+extern std::string gstrmembrainstate;
+extern iv::Ivlog * givlog;
+extern std::string gstrmemchassis;
+
+#define LOG_ENABLE
+
+namespace iv {
+namespace decition {
+iv::decition::BrainDecition * gbrain;
+
+
+        void ListenTraceMap(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
+        {
+            (void)&index;
+            (void)dt;
+            (void)strmemname;
+            gbrain->UpdateMap(strdata,nSize);
+            gbrain->UpdateSate();
+        }
+
+        void ListenVbox(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
+        {
+            (void)&index;
+            (void)dt;
+            (void)strmemname;
+            gbrain->UpdateVbox(strdata,nSize);
+            gbrain->UpdateSate();
+        }
+
+        void ListenHMI(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
+        {
+            (void)&index;
+            (void)dt;
+            (void)strmemname;
+            gbrain->UpdateHMI(strdata,nSize);
+        }
+
+        void ListenPAD(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
+        {
+            (void)&index;
+            (void)dt;
+            (void)strmemname;
+            gbrain->UpdatePAD(strdata,nSize);
+        }
+
+        void ListenPlatform(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
+        {
+            (void)&index;
+            (void)dt;
+            (void)strmemname;
+            gbrain->UpdatePlatform(strdata,nSize);
+        }
+
+        void ListenGroup(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
+        {
+            (void)&index;
+            (void)dt;
+            (void)strmemname;
+            gbrain->UpdateGroupInfo(strdata,nSize);
+        }
+
+    /*    void ListenMap_change_req(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
+        {
+            iv::formation_map_index::map map;
+            if(false == map.ParseFromArray(strdata,nSize))
+            {
+                givlog->error("GPS","[%s] Listencansend Parse fail.",__func__);
+                return;
+            }else{
+               gbrain->UpdateSate();
+            }
+        //    map.index()-1  map index num.
+        }*/
+
+    }
+
+}
+
+
+
+iv::decition::BrainDecition::BrainDecition()
+{
+    //    mpasd = new Adcivstatedb();
+    look1 = 0.0;
+    look2 = 0.0;
+    look3 = 0.0;
+    look4 = 0.0;
+    look5 = 0.0;
+    look6 = 0.0;
+    look7 = 0.0;
+    obs_lidar_grid_ = NULL;
+    old_obs_lidar_grid_ = NULL;
+    obs_camera_ = NULL;
+    //    controller = boost::shared_ptr<iv::control::Controller>(new iv::control::Controller());
+
+    //    carcall = new iv::carcalling::carcalling();
+    eyes = new iv::perception::Eyes();
+    //	decitionMaker = new iv::decition::DecitionMaker();
+
+    decitionGps00 = new iv::decition::DecideGps00();
+    decitionLine00=new iv::decition::DecideLine00();
+
+    //	decitionGpsUnit = new iv::decition::DecideGpsUnit();
+
+    //	decitionExecuter = new iv::decition::DecitionExecuter(controller);
+
+    iv::decition::gbrain = this;
+
+
+    mpa = iv::modulecomm::RegisterRecv("tracemap",iv::decition::ListenTraceMap);
+
+    mpvbox = iv::modulecomm::RegisterRecv("vbox",iv::decition::ListenVbox);
+
+    mpaVechicleState = iv::modulecomm::RegisterSend(gstrmembrainstate.data(),10000,10);
+
+
+    mpaToPlatform = iv::modulecomm::RegisterSend("toplatform",10*sizeof(iv::platform::PlatFormMsg),10);
+    mpaDecition = iv::modulecomm::RegisterSend(gstrmemdecition.data(),10*sizeof(iv::decition::DecitionBasic),1);
+
+    mpaPAD = iv::modulecomm::RegisterRecv("pad",iv::decition::ListenPAD);
+    mpaHMI = iv::modulecomm::RegisterRecv("hmi",iv::decition::ListenHMI);
+
+    mpaPlatform = iv::modulecomm::RegisterRecv("platformfrom",iv::decition::ListenPlatform);
+
+    mpaGroup = iv::modulecomm::RegisterRecv("p900_send",iv::decition::ListenGroup);
+ //   iv::modulecomm::RegisterRecv("map_index",ListenMap_change_req);
+
+
+
+
+    mpamapreq = iv::modulecomm::RegisterSend("mapreq",1000,1);
+
+    ModuleFun funchassis =std::bind(&iv::decition::BrainDecition::UpdateChassis,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
+    void * pa = iv::modulecomm::RegisterRecvPlus(gstrmemchassis.data(),funchassis);
+
+    mpaPlanTrace = iv::modulecomm::RegisterSend("plantrace",100000,1);
+
+    mTime.start();
+    mnOldTime = mTime.elapsed();
+
+}
+
+iv::decition::BrainDecition::~BrainDecition()
+{
+}
+
+
+void iv::decition::BrainDecition::inialize() {
+    //	controller->inialize();
+    eyes->inialize();
+    //    carcall->start();
+}
+
+
+void iv::decition::BrainDecition::run() {
+
+    double last = 0;
+
+    iv::decition::Decition decition_gps = NULL;
+    iv::decition::Decition decition_lidar = NULL;
+    iv::decition::Decition decition_radar = NULL;
+    iv::decition::Decition decition_camera = NULL;
+    iv::decition::Decition decition_localmap = NULL;
+
+    iv::decition::Decition dgtemp(new iv::decition::DecitionBasic);
+    decition_gps = dgtemp;
+    decition_gps->brake = 0;
+    decition_gps->accelerator = 0;
+    decition_gps->wheel_angle = 0;
+
+    //controller->auto_drive_mode_enable(true);
+
+    /*Decition test(new DecitionBasic);
+    while (true)
+    {
+        test->accelerator = 1.2;
+        test->wheel_angle = 0;
+        decitionExecuter->executeDecition(test);
+        Sleep(5000);
+
+        test->accelerator = 0;
+        test->wheel_angle = 0;
+        decitionExecuter->executeDecition(test);
+        Sleep(5000);
+
+        test->accelerator = -1.2;
+        test->wheel_angle = 0;
+        decitionExecuter->executeDecition(test);
+        Sleep(5000);
+
+        test->accelerator = 0;
+        test->wheel_angle = 45;
+        decitionExecuter->executeDecition(test);
+        Sleep(5000);
+
+        test->accelerator = 0;
+        test->wheel_angle = 0;
+        decitionExecuter->executeDecition(test);
+        Sleep(5000);
+
+        test->accelerator = 0;
+        test->wheel_angle = -60;
+        decitionExecuter->executeDecition(test);
+        Sleep(5000);
+
+    }*/
+
+    //   std::cout<<"start run."<<std::endl;
+
+    //   ServiceCarStatus.mbRunPause = false;
+
+    bool bRun;
+    int nValueSize;
+
+    //    if(mpasd->LoadState("runstate",(char *)&bRun,sizeof(bool),&nValueSize) == true)
+    //    {
+    //        if(bRun)
+    //        {
+    //            ServiceCarStatus.mbRunPause = false;
+    //        }
+    //        else
+    //        {
+    //            ServiceCarStatus.mbRunPause = true;
+    //        }
+    //    }
+
+    char * strmap = new char[10000000];
+    int nMapSize;
+
+    //    if(mpasd->LoadState("map",strmap,10000000,&nMapSize) == true)
+    //    {
+    //        UpdateMap(strmap,nMapSize);
+    //    }
+
+    QString strpath = QCoreApplication::applicationDirPath();
+    strpath = strpath + "/ADS_decision.xml";
+    iv::xmlparam::Xmlparam xp(strpath.toStdString());
+    ServiceCarStatus.msysparam.mstrvin = xp.GetParam("vin","10000000000000001");
+    ServiceCarStatus.msysparam.mstrid = xp.GetParam("id","1");
+    ServiceCarStatus.msysparam.mstriccid = xp.GetParam("iccid","11111111111111111111");
+    ServiceCarStatus.msysparam.mvehtype= xp.GetParam("vehType","ge3");
+
+
+
+    /*=============     20200113 apollo_fu  add ===========*/
+    std::string str_zhuchetime = xp.GetParam("zhuchetime","16");
+    ServiceCarStatus.msysparam.mzhuchetime =atoi(str_zhuchetime.data());
+    /*============= end ================================== */
+
+    std::string strepsoff = xp.GetParam("epsoff","0.0");
+    ServiceCarStatus.mfEPSOff = atof(strepsoff.data());
+
+    std::string strroadmode_vel = xp.GetParam("roadmode0","10");
+    ServiceCarStatus.mroadmode_vel.mfmode0 = atof(strroadmode_vel.data());
+
+    strroadmode_vel = xp.GetParam("roadmode11","30");
+    ServiceCarStatus.mroadmode_vel.mfmode11 = atof(strroadmode_vel.data());
+
+
+    strroadmode_vel = xp.GetParam("roadmode14","15");
+    ServiceCarStatus.mroadmode_vel.mfmode14 = atof(strroadmode_vel.data());
+
+    //float a = ServiceCarStatus.mroadmode_vel.mfmode14;
+    //cout<<"........"<<a<<endl;
+
+    strroadmode_vel = xp.GetParam("roadmode15","15");
+    ServiceCarStatus.mroadmode_vel.mfmode15 = atof(strroadmode_vel.data());
+
+    /*==================== 20200113    apollo_fu add =================*/
+    strroadmode_vel = xp.GetParam("roadmode5","10");
+    ServiceCarStatus.mroadmode_vel.mfmode5 = atof(strroadmode_vel.data());
+
+    strroadmode_vel = xp.GetParam("roadmode13","5");
+    ServiceCarStatus.mroadmode_vel.mfmode13 = atof(strroadmode_vel.data());
+
+    strroadmode_vel = xp.GetParam("roadmode16","8");
+    ServiceCarStatus.mroadmode_vel.mfmode16 = atof(strroadmode_vel.data());
+
+    strroadmode_vel = xp.GetParam("roadmode17","8");
+    ServiceCarStatus.mroadmode_vel.mfmode17 = atof(strroadmode_vel.data());
+
+    strroadmode_vel = xp.GetParam("roadmode18","5");
+    ServiceCarStatus.mroadmode_vel.mfmode18 = atof(strroadmode_vel.data());
+
+
+
+    /*=========================    end   =============================*/
+
+    std::string group_cotrol = xp.GetParam("group","false");
+    if(group_cotrol=="true"){
+        ServiceCarStatus.group_control=true;
+    }else{
+        ServiceCarStatus.group_control=false;
+    }
+
+    std::string speed_control = xp.GetParam("speed","false");
+    if(speed_control=="true"){
+        ServiceCarStatus.speed_control=true;
+    }else{
+        ServiceCarStatus.speed_control=false;
+    }
+
+
+
+    std::string strparklat = xp.GetParam("parklat","39.0624557");
+    std::string strparklng = xp.GetParam("parklng","117.3575493");
+    std::string strparkheading = xp.GetParam("parkheading","112.5");
+    std::string strparktype = xp.GetParam("parktype","1");
+
+    ServiceCarStatus.mfParkLat = atof(strparklat.data());
+    ServiceCarStatus.mfParkLng = atof(strparklng.data());
+    ServiceCarStatus.mfParkHeading = atof(strparkheading.data());
+    ServiceCarStatus.mnParkType = atoi(strparktype.data());
+
+    ServiceCarStatus.mLidarRotation = atof(xp.GetParam("LidarRotation","90.0").data());
+    ServiceCarStatus.mLidarRangeUnit = atof(xp.GetParam("LidarRangeUnit","5.0").data());
+
+
+
+    std::string lightlon = xp.GetParam("lightlon","0");
+    std::string lightlat = xp.GetParam("lightlat","0");
+    ServiceCarStatus.iTrafficeLightLat=atof(lightlat.data());
+    ServiceCarStatus.iTrafficeLightLon=atof(lightlon.data());
+
+
+
+    //mobileEye
+    std::string   timeWidth =xp.GetParam("waitGpsTimeWidth","5000");
+    std::string   garageLong =xp.GetParam("outGarageLong","10");
+    ServiceCarStatus.waitGpsTimeWidth=atof(timeWidth.data());
+    ServiceCarStatus.outGarageLong=atof(garageLong.data());
+    //mobileEye end
+
+
+    //lidar start
+    std::string lidarGpsXiuzheng = xp.GetParam("lidarGpsXiuzheng","1.0");
+    std::string radarGpsXiuzheng = xp.GetParam("radarGpsXiuzheng","3.0");
+    std::string rearRadarGpsXiuzheng = xp.GetParam("rearRadarGpsXiuzheng","0.5");
+    std::string rearLidarGpsXiuzheng = xp.GetParam("rearLidarGpsXiuzheng","1.0");
+    std::string frontGpsXiuzheng = xp.GetParam("frontGpsXiuzheng","3.0");
+    std::string rearGpsXiuzheng = xp.GetParam("rearGpsXiuzheng","1.0");
+    std::string gpsOffset_x = xp.GetParam("gpsOffset_X","0");
+    std::string gpsOffset_y = xp.GetParam("gpsOffset_Y","0");
+    std::string strexternmpc = xp.GetParam("ExternMPC","false");  //If Use MPC set true
+    if(strexternmpc == "true")
+    {
+        mbUseExternMPC = true;
+    }
+
+    ServiceCarStatus.msysparam.lidarGpsXiuzheng = atof(lidarGpsXiuzheng.data());
+    ServiceCarStatus.msysparam.radarGpsXiuzheng = atof(radarGpsXiuzheng.data());
+    ServiceCarStatus.msysparam.rearRadarGpsXiuzheng = atof(rearRadarGpsXiuzheng.data());
+    ServiceCarStatus.msysparam.rearLidarGpsXiuzheng = atof(rearLidarGpsXiuzheng.data());
+    ServiceCarStatus.msysparam.frontGpsXiuzheng = atof(frontGpsXiuzheng.data());
+    ServiceCarStatus.msysparam.rearGpsXiuzheng = atof(rearGpsXiuzheng.data());
+    ServiceCarStatus.msysparam.gpsOffset_x = atof(gpsOffset_x.data());
+    ServiceCarStatus.msysparam.gpsOffset_y = atof(gpsOffset_y.data());
+    // lidar end
+
+    std::string strObsPredict = xp.GetParam("obsPredict","false");  //If Use MPC set true
+    if(strObsPredict == "true")
+    {
+        ServiceCarStatus.useObsPredict = true;
+    }
+    //map
+
+    mstrmemmap_index = xp.GetParam("msg_mapindex","map_index");
+
+
+    while (eyes->isAllSensorRunning())
+    {
+        if(navigation_data.size() <1)
+        {
+            iv::map::mapreq x;
+            x.set_maptype(1);
+            int nsize = x.ByteSize();
+            char * str = new char[nsize];
+            if(x.SerializeToArray(str,nsize))
+            {
+                iv::modulecomm::ModuleSendMsg(mpamapreq,str,nsize);
+            }
+            else
+            {
+                std::cout<<"iv::map::mapreq serialize error."<<std::endl;
+            }
+            delete str;
+        }
+
+
+        iv::GPSData gps_data_;			//gps 惯导数据
+
+        //       qDebug("size = %d",navigation_data.size());
+
+
+
+        std::shared_ptr<std::vector<iv::Perception::PerceptionOutput>> lidar_per(new std::vector<iv::Perception::PerceptionOutput>);
+
+        bool brun =ServiceCarStatus.mbRunPause;
+        if(ServiceCarStatus.mnBocheComplete > 0)
+        {
+            ServiceCarStatus.mbBrainCtring = false;
+            ServiceCarStatus.mbRunPause = true;
+            ServiceCarStatus.mnBocheComplete--;
+        }
+        if((ServiceCarStatus.mbRunPause)||(navigation_data.size()<1)||(ServiceCarStatus.mnBocheComplete>0))
+        {
+            ServiceCarStatus.mbBrainCtring = false;
+            decition_gps->brake = 6;
+            decition_gps->accelerator = -0.5;
+            decition_gps->wheel_angle = 0;
+            decition_gps->torque = 0;
+            decition_gps->mode = 0;
+            //decitionExecuter->executeDecition(decition_gps);
+                   ShareDecition(decition_gps);  //apollo_fu 20200413 qudiaozhushi
+            ServiceCarStatus.mfAcc = decition_gps->accelerator;
+            ServiceCarStatus.mfWheel = decition_gps->wheel_angle;
+            ServiceCarStatus.mfBrake = decition_gps->brake;
+
+            iv::brain::brainstate xbs;
+            xbs.set_mbbocheenable(ServiceCarStatus.bocheEnable);
+            xbs.set_mbbrainrunning(false);
+            xbs.set_mflidarobs(ServiceCarStatus.mLidarObs);
+            xbs.set_mfradarobs(ServiceCarStatus.mRadarObs);
+            xbs.set_mfobs(ServiceCarStatus.mObs);
+            xbs.set_decision_period(decision_period);
+            ShareBrainstate(xbs);    //apollo_fu 20200413 qudiaozhushi
+            //            iv::decition::VehicleStateBasic vsb;
+            //            vsb.mbBocheEnable = ServiceCarStatus.bocheEnable;
+            //            vsb.mfLidarObs = ServiceCarStatus.mLidarObs;
+            //            vsb.mfRadarObs = ServiceCarStatus.mRadarObs;
+            //            vsb.mfObs = ServiceCarStatus.mRadarObs;
+            //            vsb.decision_period = decision_period;
+            //            vsb.mbBrainRunning = false;
+            ////             mpaVechicleState->writemsg((char *)&vsb,sizeof(iv::decition::VehicleStateBasic));
+            //            iv::modulecomm::ModuleSendMsg(mpaVechicleState,(char *)&vsb,sizeof(iv::decition::VehicleStateBasic));
+
+#ifdef Q_OS_LINUX
+            usleep(10000);
+#endif
+#ifdef Q_OS_WIN32
+            boost::this_thread::sleep(boost::posix_time::milliseconds(10));
+#endif
+             std::cout<<"enter mbRunPause"<<std::endl;
+            continue;
+
+        }
+
+
+
+        ServiceCarStatus.mbBrainCtring = true;
+        obs_lidar_ = obs_radar_ = NULL;
+
+        int j;
+        //      gps_data_ = NULL;
+
+        //        if(obs_lidar_grid_ != NULL)free(obs_lidar_grid_);
+        if(obs_lidar_grid_ != NULL)
+        {
+            if(old_obs_lidar_grid_ != NULL) free(old_obs_lidar_grid_);
+            old_obs_lidar_grid_ = obs_lidar_grid_;
+        }
+
+        obs_lidar_grid_ = NULL;
+
+        if(obs_camera_ != NULL)free(obs_camera_);
+
+        obs_camera_ = NULL;
+
+
+
+        eyes->getSensorObstacle(obs_radar_, obs_camera_,gps_data_, obs_lidar_grid_);	//从传感器线程临界区交换数据
+
+
+
+
+
+        ServiceLidar.copylidarperto(lidar_per);
+
+        //        if(lidar_per->size() >0)
+        //        {
+        //            int i;
+        //            for(i=0;i<lidar_per->size();i++)
+        //            {
+        //                if(lidar_per->at(i).label>0)
+        //                {
+        //                    std::cout<<"label is"<<lidar_per->at(i).label<<" vy = "<<lidar_per->at(i).velocity.y<<std::endl;
+        //                }
+        //            }
+        //            //if size > 0, have perception result;
+        //        }
+
+        iv::ObsLiDAR obs_lidar_tmp(new std::vector<iv::ObstacleBasic>);
+        iv::ObsRadar obs_radar_tmp(new std::vector<iv::ObstacleBasic>);
+        iv::decition::Decition decition_final(new iv::decition::DecitionBasic);
+
+        //		if ((ServiceCarStatus.status[0] == true && ServiceCarStatus.status[1] == false && ServiceCarStatus.status[2] == false && ServiceCarStatus.status[3] == false && ServiceCarStatus.status[4] == true) ||
+        //			(ServiceCarStatus.status[0] == true && ServiceCarStatus.status[1] == false && ServiceCarStatus.status[2] == false && ServiceCarStatus.status[3] == true && ServiceCarStatus.status[4] == true) ||
+        //			(ServiceCarStatus.status[0] == true && ServiceCarStatus.status[1] == true && ServiceCarStatus.status[2] == true && ServiceCarStatus.status[3] == true && ServiceCarStatus.status[4] == true))
+        //		{
+        //			//停车
+        //			ServiceCarStatus.carState = 0;
+        //		}
+        //		else if ((ServiceCarStatus.status[0] == false && ServiceCarStatus.status[1] == false && ServiceCarStatus.status[2] == false && ServiceCarStatus.status[3] == false && ServiceCarStatus.status[4] == true) ||
+        //				 (ServiceCarStatus.status[0] == false && ServiceCarStatus.status[1] == true && ServiceCarStatus.status[2] == false && ServiceCarStatus.status[3] == true && ServiceCarStatus.status[4] == true))
+        //		{
+        //			//正常循迹
+        //			ServiceCarStatus.carState = 1;
+        //		}
+        //		else if ((ServiceCarStatus.status[0] == false && ServiceCarStatus.status[1] == false && ServiceCarStatus.status[2] == false && ServiceCarStatus.status[3] == true && ServiceCarStatus.status[4] == true) ||
+        //				 (ServiceCarStatus.status[0] == false && ServiceCarStatus.status[1] == true && ServiceCarStatus.status[2] == true && ServiceCarStatus.status[3] == true && ServiceCarStatus.status[4] == true))
+        //		{
+        //			//前往站点
+        //			ServiceCarStatus.carState = 2;
+        //		}
+
+        if (obs_lidar_) {	//激光雷达有障碍物
+            //          std::cout<<"obs lidar size = "<<obs_lidar_->size()<<std::endl;
+            //std::cout << "大脑处理激光雷达:" << obs_lidar_->at(0).nomal_x << " " << obs_lidar_->at(0).nomal_y << " " << obs_lidar_->at(0).nomal_z << std::endl;
+            obs_lidar_tmp = NULL;
+            obs_lidar_tmp.swap(obs_lidar_);
+        }
+        else
+        {
+            //           std::cout<<"no lidar obs"<<std::endl;
+        }
+        //ServiceCarStatus.obs_radar;
+        //毫米波雷达障碍物信息
+
+        if (obs_radar_) {
+            //std::cout << "大脑处理毫米波雷达:" << obs_radar_->at(0).nomal_x << " " << obs_radar_->at(0).nomal_y << " " << obs_radar_->at(0).nomal_z << std::endl;
+            obs_radar_tmp = NULL;
+            obs_radar_tmp.swap(obs_radar_);
+        }
+        if (obs_camera_) {
+            //std::cout << "大脑处理摄像头雷达:" << obs_camera_->at(0).nomal_x << " " << obs_camera_->at(0).nomal_y << " " << obs_camera_->at(0).nomal_z << std::endl;
+        }
+
+
+        //useMobileEye chuku
+        if(ServiceCarStatus.m_bOutGarage){
+            GPS_INS gps ;
+            if(gps_data_){
+                gps=*gps_data_;
+            }
+            decition_gps = decitionLine00->getDecideFromGPS(gps, navigation_data, obs_lidar_grid_,*lidar_per);  //chedaoxian
+
+            std::cout << "使用mobileEye决策"<< std::endl;
+        }
+        //useMobileEye chuku end;
+
+        if (gps_data_  &&!handPark && !ServiceCarStatus.m_bOutGarage){// && obs_lidar_grid_) {	//处理GPS数据
+            //todo gps_data_为当前读到的gps位置信息
+            //decition_gps = iv::decition::Decition(new iv::decition::DecitionBasic);
+            //ODS("接收GPS数据:%f\t\t%f\n", gps_data_->gps_x, gps_data_->gps_y);
+            //	decition_gps = decitionMaker->getDecideForGPS(*gps_data_,navigation_data);
+
+            //ODS("\n接收到的实时GPS数据:%f\t%f\t%f\n", gps_data_->gps_x, gps_data_->gps_y, gps_data_->ins_heading_angle);
+
+            //以下为正常用
+            //         if (gps_data_->valid == RTK_IMU_OK)
+            //        {
+            double start = GetTickCount();
+
+            //				decitionGps00->aim_gps_ins.gps_lat = carcall->lat;
+            //				decitionGps00->aim_gps_ins.gps_lng = carcall->lon;
+            /*iv::ObsRadar obs_radar_tmp(new std::vector<iv::ObstacleBasic>);
+                if(obs_radar_){
+                    obs_radar_tmp = NULL;
+                    obs_radar_tmp.swap(obs_radar_);
+                }*/
+            //decition_gps = decitionGpsUnit->getDecideFromGPS(*gps_data_, navigation_data, *obs_radar_tmp, obs_lidar_grid_);
+            //		decition_gps = decitionGpsUnit->getDecideFromGPS(*gps_data_, navigation_data, obs_lidar_grid_);     // 新的
+
+
+            if ( ServiceCarStatus.epsMode==0 && ServiceCarStatus.receiveEps) {
+                ServiceCarStatus.mbRunPause=true;
+
+            }
+            ServiceCarStatus.receiveEps=false;
+
+            lastMode=ServiceCarStatus.epsMode;
+            lastPause=ServiceCarStatus.mbRunPause;
+
+            if((fabs(mTime.elapsed() - mnOldTime)>40))
+            {
+                if((fabs(mTime.elapsed() - mnOldTime)<10000))
+                {
+                    ServiceCarStatus.mfCalAcc = (ServiceCarStatus.speed - mfSpeedLast)*1000/(fabs(mTime.elapsed() - mnOldTime))/3.6;
+                    ServiceCarStatus.mfVehAcc = (ServiceCarStatus.vehSpeed_st - mfVehSpeedLast)*1000/(fabs(mTime.elapsed() - mnOldTime))/3.6;
+                }else
+                {
+                    ServiceCarStatus.mfCalAcc = 0;
+                    ServiceCarStatus.mfVehAcc = 0;
+                }
+                mnOldTime = mTime.elapsed();
+                mfSpeedLast = ServiceCarStatus.speed;
+                mfVehSpeedLast=ServiceCarStatus.vehSpeed_st;
+            }
+
+            iv::LidarGridPtr templidar= obs_lidar_grid_;
+            if(templidar == NULL)templidar = old_obs_lidar_grid_;
+        //    GaussProjCal(gps_data_->gps_lng,gps_data_->gps_lat,&gps_data_->gps_x,&gps_data_->gps_y);
+
+            mMutexMap.lock();
+            decition_gps = decitionGps00->getDecideFromGPS(*gps_data_, navigation_data, templidar,*lidar_per,trafficLight);  // my dicition=============================
+            mMutexMap.unlock();
+
+            if(mbUseExternMPC)
+            {
+                fanya::GPS_INS xgpsins;
+                xgpsins.speed_y = gps_data_->speed/3.6;
+                xgpsins.gps_lat = gps_data_->gps_lat;
+                xgpsins.gps_lng = gps_data_->gps_lng;
+                xgpsins.ins_heading = gps_data_->ins_heading_angle;
+                mmpcapi.SetGPS(xgpsins);
+                mmpcapi.SetDesiredspeed(decition_gps->speed/3.6);
+                double mpc_speed,mpc_decision,mpc_wheel;
+                if(mmpcapi.GetDecision(mpc_speed,mpc_decision,mpc_wheel) == 0)
+                {
+                    decition_gps->wheel_angle = mpc_wheel;
+                }
+            }
+            iv::modulecomm::ModuleSendMsg(mpaPlanTrace,(char *)decitionGps00->planTrace.data(),decitionGps00->planTrace.size()*sizeof(iv::Point2D));
+
+
+
+            //      decition_gps = decitionLine00->getDecideFromGPS(*gps_data_, navigation_data, obs_lidar_grid_);
+            //ODS("\n决策:%f\t%f\t\t", decition_gps->speed, decition_gps->wheel_angle);
+            //ODS("\n接收到的实时GPS数据:%f\t%f\t%f\n", gps_data_->gps_x, gps_data_->gps_y,gps_data_->ins_heading_angle);
+
+            //carcall->is_arrived = decitionGps00->is_arrivaled;
+            //double end = GetTickCount();
+            decision_period = start - last;
+            std::cout<<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "\n周期时长:%f\n" << decision_period << std::endl;
+            //                iv::decition::VehicleStateBasic vsb;
+            //                vsb.mbBocheEnable = ServiceCarStatus.bocheEnable;
+            //                vsb.mfLidarObs = ServiceCarStatus.mLidarObs;
+            //                vsb.mfRadarObs = ServiceCarStatus.mRadarObs;
+            //                vsb.mfObs = ServiceCarStatus.mRadarObs;
+            //                vsb.decision_period = decision_period;
+            //                vsb.mbBrainRunning = ServiceCarStatus.mbBrainCtring;
+            ////                mpaVechicleState->writemsg((char *)&vsb,sizeof(iv::decition::VehicleStateBasic));
+
+            //                iv::modulecomm::ModuleSendMsg(mpaVechicleState,(char *)&vsb,sizeof(iv::decition::VehicleStateBasic));
+
+            iv::brain::brainstate xbs;
+            xbs.set_mbbocheenable(ServiceCarStatus.bocheEnable);
+            xbs.set_mbbrainrunning(true);  //apollo_fu debug ui 20200417
+            xbs.set_mflidarobs(ServiceCarStatus.mLidarObs);
+            xbs.set_mfradarobs(ServiceCarStatus.mRadarObs);
+            xbs.set_mfobs(ServiceCarStatus.mObs);
+            xbs.set_decision_period(decision_period);
+            ShareBrainstate(xbs);
+
+
+            //                decitionExecuter->executeDecition(decition_gps);
+            ShareDecition(decition_gps);
+
+            givlog->debug("acc is %f brake is %f wheel is %f",
+                          decition_gps->accelerator,decition_gps->brake,
+                          decition_gps->wheel_angle);
+            givlog->debug("period id %f",decision_period);
+
+            //	ODS("\n周期时长:%f\n", start - last);
+            //	ODS("\n决策时长:%f\n", end - start);
+            //	ODS("\n接收到的实时GPS车速:%f\n", gps_data_->speed);
+            //	ODS("\n接收到的实时GPS车y轴加速:%f\n", gps_data_->accel_y);
+            //	ODS("\n接收到的实时GPS车x轴加速:%f\n", gps_data_->accel_x);
+            std::cout<<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "\n决策加速度:%f\n" << decition_gps->accelerator << std::endl;
+            //		ODS("\n决策刹车:%f\n", decition_gps->brake);
+            std::cout<<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "\n决策方向:%f\n" << decition_gps->wheel_angle << std::endl;
+            std::cout<<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "\n决策速度:%f\n" << decition_gps->speed << std::endl;
+            last = start;
+            //decitionMaker->decideFromGPS(decition_gps, gps_data_, navigation_data);		//gps_data_为当前读到的gps位置信息  navigation_data为导航数据  decition_gps为根据前两者得出的决策速度与决策角度
+            //            }
+
+        }
+
+        if (handPark && decition_gps != NULL)
+        {
+            decition_gps->brake = 20;
+            decition_gps->accelerator = 0;
+            //			decitionExecuter->executeDecition(decition_gps);
+            ShareDecition(decition_gps);
+            //boost::this_thread::sleep(boost::posix_time::milliseconds(2000));
+
+#ifdef linux
+            usleep(2000000);
+#endif
+#ifdef WIN32
+            boost::this_thread::sleep(boost::posix_time::milliseconds(2000));
+            //           Sleep(2000);
+#endif
+            decition_gps->brake = 0;
+            decition_gps->accelerator = 0;
+            //			decitionExecuter->executeDecition(decition_gps);
+            //			ServiceCanUtil.set_handbrake_on();
+            //boost::this_thread::sleep(boost::posix_time::milliseconds(handParkTime));
+            ShareDecition(decition_gps);
+
+#ifdef linux
+            usleep(handParkTime*1000);
+#endif
+#ifdef WIN32
+            Sleep(handParkTime);
+#endif
+            handPark = false;
+        }
+
+
+        else
+        {
+            //boost::this_thread::sleep(boost::posix_time::milliseconds(1));
+
+#ifdef linux
+            usleep(1000);
+#endif
+#ifdef WIN32
+            Sleep(1);
+#endif
+            //			ODS("no gps data .sleep.\r\n");
+        }
+
+
+
+
+        //        if (decition_lidar || decition_radar || decition_camera || decition_gps || decition_lidar) {
+        //            //	decitionVoter->decideFromAll(decition_final, decition_lidar, decition_radar, decition_camera, decition_gps, decition_localmap);
+        //            //	decitionExecuter->executeDecition(decition_final);	//执行最终的决策
+        //            /*	decition_gps->brake = 0;
+        //            decition_gps->accelerator = 0;*/
+        //            look1 = decition_gps->accelerator;
+        //            look2 = decition_gps->brake;
+        //            look3 = decition_gps->wheel_angle;
+        //            look4 = decition_gps->speed;
+        //            look5 = decitionGps00->lidarDistance;
+        //            look6 = decitionGps00->myesrDistance;
+        //            look7 = decitionGps00->obsDistance;
+
+        //            decition_gps->grade=1;
+        //            decition_gps->mode=1;
+        //            decition_gps->speak=0;
+        //            decition_gps->handBrake=0;
+        //            decition_gps->bright=false;
+        //            decition_gps->engine=0;
+
+        //            if(ServiceCarStatus.bocheMode){
+        //                decition_gps->dangWei=2;
+        //            }else{
+        //                decition_gps->dangWei=1;
+        //            }
+
+
+        //            decition_gps->wheel_angle=max((float)-500.0,float(decition_gps->wheel_angle+ServiceCarStatus.mfEPSOff));
+        //            decition_gps->wheel_angle=min((float)500.0,decition_gps->wheel_angle);
+
+        //            //			decitionExecuter->executeDecition(decition_gps);
+        //            //           ShareDecition(decition_gps);
+        //        }
+
+        ServiceCarStatus.mfAcc = decition_gps->accelerator;
+        ServiceCarStatus.mfWheel = decition_gps->wheel_angle;
+        ServiceCarStatus.mfBrake = decition_gps->brake;
+
+        iv::platform::PlatFormMsg toplat;
+        toplat.carState = ServiceCarStatus.carState;	// 0:停车	1:正常循迹	2:前往站点
+        toplat.istostation = ServiceCarStatus.istostation;
+        toplat.currentstation = ServiceCarStatus.currentstation;
+        toplat.clientto = ServiceCarStatus.clientto;
+        toplat.amilng = ServiceCarStatus.amilng;
+        toplat.amilat = ServiceCarStatus.amilat;
+        //       mpaToPlatform->writemsg((char*)&toplat,sizeof(iv::platform::PlatFormMsg));
+
+        iv::modulecomm::ModuleSendMsg(mpaToPlatform,(char*)&toplat,sizeof(iv::platform::PlatFormMsg));
+        //ODS("\ngetSensor时长:%f\n", end1 - start1);
+    }
+    std::cout << "\n\n\n\n\n\n\n\n\n\n\nbrain线程退出\n" << std::endl;
+}
+
+bool iv::decition::BrainDecition::loadMapFromFile(std::string fileName) {
+    std::ifstream fis(fileName);//获取文件
+    std::string line;
+    std::vector<std::string> des;
+
+    if (fis.is_open() == false)
+        return false;
+    try {
+        while (std::getline(fis, line)) {//开始一行一行的读数据
+            boost::split(des, line, boost::is_any_of("\t"));
+            if (des.size() != 10)
+                throw "error";
+            iv::GPSData data(new iv::GPS_INS);
+            data->index = atoi(des[0].c_str());
+            data->gps_lng = atof(des[1].c_str());
+            data->gps_lat = atof(des[2].c_str());
+            data->speed_mode = atoi(des[3].c_str());
+            data->mode2 = atoi(des[4].c_str());
+            data->ins_heading_angle = atof(des[5].c_str());
+            data->runMode = atoi(des[6].c_str());
+            data->roadMode = atoi(des[7].c_str());
+            data->roadSum = atoi(des[8].c_str());
+            data->roadOri = atoi(des[9].c_str());
+            //      gps2xy(data->gps_lat, data->gps_lng, &data->gps_x, &data->gps_y);
+            GaussProjCal(data->gps_lng, data->gps_lat, &data->gps_x, &data->gps_y);
+            //data->speed = 5;	//调试用  所有点速度都设为5km/h
+            //LOG2(data->gps_x, data->gps_y);
+            //ODS("x %.20lf   y %.20lf\n", data->gps_x, data->gps_y);
+
+            //	iv::decition::BLH2XYZ(*data);   //重新转下大地坐标
+
+            if(data->roadMode==4){
+                data->ins_heading_angle=data->ins_heading_angle+180;
+                if(data->ins_heading_angle>=360)
+                    data->ins_heading_angle=data->ins_heading_angle-360;
+            }
+
+            navigation_data.push_back(data);
+        }
+
+    }
+    catch (...) {
+        fis.close();
+        return false;
+    }
+
+    fis.close();
+    return true;
+}
+
+bool iv::decition::BrainDecition::loadMapFromFile2(std::string fileName) {
+    std::ifstream fis(fileName);//获取文件
+    std::string line;
+    std::vector<std::string> des;
+
+    if (fis.is_open() == false)
+        return false;
+    try {
+        while (std::getline(fis, line)) {//开始一行一行的读数据
+            boost::split(des, line, boost::is_any_of("\t"));
+            if (des.size() != 10)
+                throw "error";
+            iv::GPSData data(new iv::GPS_INS);
+            data->index = atoi(des[0].c_str());
+            data->gps_lng = atof(des[1].c_str());
+            data->gps_lat = atof(des[2].c_str());
+            data->speed_mode = atoi(des[3].c_str());
+            data->mode2 = atoi(des[4].c_str());
+            data->ins_heading_angle = atof(des[5].c_str());
+            data->runMode = atoi(des[6].c_str());
+            data->roadMode = atoi(des[7].c_str());
+            data->roadSum = atoi(des[8].c_str());
+            data->roadOri = atoi(des[9].c_str());
+            GaussProjCal(data->gps_lng, data->gps_lat, &data->gps_x, &data->gps_y);
+            navigation_data2.push_back(data);
+        }
+    }
+    catch (...) {
+        fis.close();
+        return false;
+    }
+
+    fis.close();
+    return true;
+}
+
+bool iv::decition::BrainDecition::loadMapFromFile3(std::string fileName) {
+    std::ifstream fis(fileName);//获取文件
+    std::string line;
+    std::vector<std::string> des;
+
+    if (fis.is_open() == false)
+        return false;
+    try {
+        while (std::getline(fis, line)) {//开始一行一行的读数据
+            boost::split(des, line, boost::is_any_of("\t"));
+            if (des.size() != 10)
+                throw "error";
+            iv::GPSData data(new iv::GPS_INS);
+            data->index = atoi(des[0].c_str());
+            data->gps_lng = atof(des[1].c_str());
+            data->gps_lat = atof(des[2].c_str());
+            data->speed_mode = atoi(des[3].c_str());
+            data->mode2 = atoi(des[4].c_str());
+            data->ins_heading_angle = atof(des[5].c_str());
+            data->runMode = atoi(des[6].c_str());
+            data->roadMode = atoi(des[7].c_str());
+            data->roadSum = atoi(des[8].c_str());
+            data->roadOri = atoi(des[9].c_str());
+            GaussProjCal(data->gps_lng, data->gps_lat, &data->gps_x, &data->gps_y);
+            navigation_data3.push_back(data);
+        }
+    }
+    catch (...) {
+        fis.close();
+        return false;
+    }
+
+    fis.close();
+    return true;
+}
+
+bool iv::decition::BrainDecition::loadMapFromFile4(std::string fileName) {
+    std::ifstream fis(fileName);//获取文件
+    std::string line;
+    std::vector<std::string> des;
+
+    if (fis.is_open() == false)
+        return false;
+    try {
+        while (std::getline(fis, line)) {//开始一行一行的读数据
+            boost::split(des, line, boost::is_any_of("\t"));
+            if (des.size() != 10)
+                throw "error";
+            iv::GPSData data(new iv::GPS_INS);
+            data->index = atoi(des[0].c_str());
+            data->gps_lng = atof(des[1].c_str());
+            data->gps_lat = atof(des[2].c_str());
+            data->speed_mode = atoi(des[3].c_str());
+            data->mode2 = atoi(des[4].c_str());
+            data->ins_heading_angle = atof(des[5].c_str());
+            data->runMode = atoi(des[6].c_str());
+            data->roadMode = atoi(des[7].c_str());
+            data->roadSum = atoi(des[8].c_str());
+            data->roadOri = atoi(des[9].c_str());
+            GaussProjCal(data->gps_lng, data->gps_lat, &data->gps_x, &data->gps_y);
+            navigation_data4.push_back(data);
+        }
+    }
+    catch (...) {
+        fis.close();
+        return false;
+    }
+
+    fis.close();
+    return true;
+}
+
+void iv::decition::BrainDecition::start() {
+    thread_run = new boost::thread(boost::bind(&iv::decition::BrainDecition::run, this));
+}
+
+void iv::decition::BrainDecition::stop() {
+    //    carcall->stop();
+    thread_run->interrupt();
+    thread_run->join();
+}
+
+void iv::decition::BrainDecition::UpdateMap(const char *mapdata, const int mapdatasize)
+{
+    //    std::cout<<"update map "<<std::endl;
+    int gpsunitsize = sizeof(iv::GPS_INS);
+    int nMapSize = mapdatasize/gpsunitsize;
+    //    std::cout<<"map size is "<<nMapSize<<std::endl;
+
+    if(nMapSize < 1)return;
+
+    bool bUpdate = false;
+    if(nMapSize != navigation_data.size())
+    {
+        bUpdate = true;
+    }
+    else
+    {
+        iv::GPS_INS * p = (iv::GPS_INS *)mapdata;
+        if((p->gps_lat == navigation_data.at(0)->gps_lat)&&(p->ins_heading_angle == navigation_data.at(0)->ins_heading_angle))
+        {
+            //           qDebug("same map");
+            bUpdate = false;
+        }
+        else
+        {
+            bUpdate = true;
+        }
+    }
+
+    if(bUpdate)
+    {
+        std::vector<fanya::MAP_DATA> xvectorMAP;
+        int i;
+        mMutexMap.lock();
+        navigation_data.clear();
+        for(i=0;i<nMapSize;i++)
+        {
+            iv::GPS_INS x;
+            memcpy(&x,mapdata + i*gpsunitsize,gpsunitsize);
+            iv::GPSData data(new iv::GPS_INS);
+            *data = x;
+            navigation_data.push_back(data);
+
+            fanya::MAP_DATA xmapdata;
+            xmapdata.gps_lat = x.gps_lat;
+            xmapdata.gps_lng = x.gps_lng;
+            xmapdata.ins_heading = x.ins_heading_angle;
+            xvectorMAP.push_back(xmapdata);
+        }
+
+        mmpcapi.SetMAP(xvectorMAP);
+
+        if(ServiceCarStatus.speed_control==true){
+        Compute00().getDesiredSpeed(navigation_data);}
+        mMutexMap.unlock();
+        //        mpasd->SaveState("map",mapdata,mapdatasize);
+    }
+    else
+    {
+        //       qDebug("not need update");
+    }
+}
+
+void iv::decition::BrainDecition::ShareDecition(iv::decition::Decition decition)
+{
+    iv::brain::decition xdecition;
+    xdecition.set_accelerator(decition->accelerator);
+    xdecition.set_brake(decition->brake);
+    xdecition.set_leftlamp(decition->leftlamp);
+    xdecition.set_rightlamp(decition->rightlamp);
+    xdecition.set_speed(decition->speed);
+    xdecition.set_wheelangle(decition->wheel_angle);
+    xdecition.set_wheelspeed(decition->angSpeed);
+    xdecition.set_torque(decition->torque);
+    xdecition.set_mode(decition->mode);
+    xdecition.set_gear(decition->dangWei);
+    xdecition.set_handbrake(decition->handBrake);
+    xdecition.set_grade(decition->grade);
+    xdecition.set_engine(decition->engine);
+    xdecition.set_brakelamp(decition->brakeLight);
+    xdecition.set_ttc(ServiceCarStatus.mfttc);
+    xdecition.set_air_enable(decition->air_enable);
+    xdecition.set_air_temp(decition->air_temp);
+    xdecition.set_air_mode(decition->air_mode);
+    xdecition.set_wind_level(decition->wind_level);
+    xdecition.set_roof_light(decition->roof_light);
+    xdecition.set_home_light(decition->home_light);
+    xdecition.set_air_worktime(decition->air_worktime);
+    xdecition.set_air_offtime(decition->air_offtime);
+    xdecition.set_air_on(decition->air_on);
+
+
+
+    std::cout<<"===================shareDecition========================"<<std::endl;
+         std::cout<<"  torque_st:"<<ServiceCarStatus.torque_st
+                 <<"  decideTorque:"<<decition->torque <<"  decideBrake:"<<decition->brake
+                <<"  decition mode:"<<decition->mode
+        <<std::endl;
+    std::cout<<"========================================="<<std::endl;
+
+    givlog->verbose("torque_st: %ld",ServiceCarStatus.torque_st);
+     givlog->verbose("decideTorque: %ld",decition->torque);
+     givlog->verbose("decideBrake: %ld", decition->brake);
+     givlog->debug("wheelAng: %f",decition->wheel_angle);
+
+   //  xdecition.set_wheelangle(100);
+    static qint64 oldtime;
+
+    if((QDateTime::currentMSecsSinceEpoch() - oldtime)>100)
+    {
+        givlog->warn("brain interval is more than 100ms.  value is %ld",QDateTime::currentMSecsSinceEpoch() - oldtime);
+    }
+
+    givlog->verbose("decition time is %ld",QDateTime::currentMSecsSinceEpoch());
+    oldtime = QDateTime::currentMSecsSinceEpoch();
+
+
+    givlog->verbose("torque %f wheel %f dangwei %d ",decition->torque,
+                    decition->wheel_angle,decition->dangWei);
+    int nsize = xdecition.ByteSize();
+    char * str = new char[nsize];
+    std::shared_ptr<char> pstr;
+    pstr.reset(str);
+    if(xdecition.SerializeToArray(str,nsize))
+    {
+        if(ServiceCarStatus.mbRunPause == false)
+        {
+
+            iv::modulecomm::ModuleSendMsg(mpaDecition,str,nsize);
+        }
+    }
+    else
+    {
+        std::cout<<"iv::decition::BrainDecition::ShareDecition serialize error."<<std::endl;
+    }
+}
+
+void iv::decition::BrainDecition::ShareBrainstate(iv::brain::brainstate xbs)
+{
+    int nsize = xbs.ByteSize();
+    char * str = new char[nsize];
+    std::shared_ptr<char> pstr;
+    pstr.reset(str);
+    if(xbs.SerializeToArray(str,nsize))
+    {
+        iv::modulecomm::ModuleSendMsg(mpaVechicleState,str,nsize);
+    }
+    else
+    {
+        std::cout<<"iv::decition::BrainDecition::ShareBrainstate serialize error."<<std::endl;
+    }
+}
+
+void iv::decition::BrainDecition::UpdateHMI(const char *pdata, const int ndatasize)
+{
+    if(ndatasize < sizeof(iv::hmi::HMIBasic))return;
+
+    iv::hmi::hmimsg xhmimsg;
+    if(!xhmimsg.ParseFromArray(pdata,ndatasize))
+    {
+        givlog->error("iv::decition::BrainDecition::UpdateHMI parse error");
+        return;
+    }
+
+    ServiceCarStatus.mbRunPause = xhmimsg.mbpause();
+
+    if(xhmimsg.mbbochemode()){
+         ServiceCarStatus.bocheMode = true;
+    }
+    ServiceCarStatus.busmode = xhmimsg.mbbusmode();
+
+    if( ServiceCarStatus.bocheMode ){
+        int a=0;
+    }
+
+    bool bRun;
+    bRun = !ServiceCarStatus.mbRunPause;
+
+    //    mpasd->SaveState("runstate",(char *)&bRun,sizeof(bool));
+
+}
+
+void iv::decition::BrainDecition::UpdatePAD(const char *pdata, const int ndatasize)
+{
+//    if(ndatasize < sizeof(iv::hmi::HMIBasic))return;
+
+    iv::hmi::hmimsg xhmimsg;
+    if(!xhmimsg.ParseFromArray(pdata,ndatasize))
+    {
+        givlog->error("iv::decition::BrainDecition::UpdateHMI parse error");
+        return;
+    }
+
+    ServiceCarStatus.mbRunPause = xhmimsg.mbpause();
+
+    if(xhmimsg.mbbochemode()){
+         ServiceCarStatus.bocheMode = true;
+    }
+    ServiceCarStatus.busmode = xhmimsg.mbbusmode();
+
+    if( ServiceCarStatus.bocheMode ){
+        int a=0;
+    }
+
+    bool bRun;
+    bRun = !ServiceCarStatus.mbRunPause;
+
+    //    mpasd->SaveState("runstate",(char *)&bRun,sizeof(bool));
+
+}
+
+void iv::decition::BrainDecition::UpdatePlatform(const char *pdata, const int ndatasize)
+{
+    if(ndatasize < sizeof(iv::platform::PlatFormMsg))return;
+
+    iv::platform::PlatFormMsg x;
+    memcpy(&x,pdata,sizeof(iv::platform::PlatFormMsg));
+    ServiceCarStatus.carState = x.carState;	// 0:停车	1:正常循迹	2:前往站点
+    std::cout<<"car state "<<ServiceCarStatus.carState<<std::endl;
+    ServiceCarStatus.istostation = x.istostation;
+    ServiceCarStatus.currentstation = x.currentstation;
+    ServiceCarStatus.clientto = x.clientto;
+    ServiceCarStatus.amilng = x.amilng;
+    ServiceCarStatus.amilat = x.amilat;
+
+}
+
+void iv::decition::BrainDecition::UpdateChassis(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
+{
+    iv::chassis xchassis;
+    static int ncount = 0;
+    if(!xchassis.ParseFromArray(strdata,nSize))
+    {
+        std::cout<<"iv::decition::BrainDecition::UpdateChassis ParseFrom Array Error."<<std::endl;
+        return;
+    }
+
+    ServiceCarStatus.epb = xchassis.epbfault();
+    ServiceCarStatus.grade = xchassis.shift();
+    ServiceCarStatus.driverMode = xchassis.drivemode();
+    if(xchassis.has_epsmode()){
+        ServiceCarStatus.epsMode = xchassis.epsmode();
+        ServiceCarStatus.receiveEps=true;
+        if(ServiceCarStatus.epsMode == 0)
+        {
+            ServiceCarStatus.mbRunPause = true;
+        }
+    }
+    if(xchassis.has_torque())
+    {
+         ServiceCarStatus.torque_st = xchassis.torque();
+        if(ServiceCarStatus.msysparam.mvehtype=="bus"){
+            ServiceCarStatus.torque_st = xchassis.torque()*0.4;
+        }
+         std::cout<<"******* xchassis.torque:"<< xchassis.torque()<<std::endl;
+        std::cout<<"******* ServiceCarStatus.torque_st:"<< ServiceCarStatus.torque_st<<std::endl;
+        givlog->warn(" ServiceCarStatus.torque_st: is %f",ServiceCarStatus.torque_st);
+
+    }
+    //    if(xchassis.epsmode() == 1)
+    //    {
+    //        ncount++;
+    ////        if(ncount > 10)ServiceCarStatus.mbRunPause = true;
+    //    }
+    //    else
+    //    {
+    //        ncount = 0;
+    //    }
+}
+
+void iv::decition::BrainDecition::UpdateGroupInfo(const char *pdata, const int ndatasize){
+
+    iv::radio::radio_send group_message;
+    if(false == group_message.ParseFromArray(pdata,ndatasize))
+    {
+        std::cout<<"Listencansend Parse fail."<<std::endl;
+        return;
+    }
+    ServiceCarStatus.group_server_status = group_message.server_status();
+    ServiceCarStatus.group_comm_speed= (float)group_message.car_control_speed();
+    ServiceCarStatus.group_state= group_message.cmd_mode();
+
+    qDebug("updateGroupInfo %ld",QDateTime::currentMSecsSinceEpoch());
+    if(ServiceCarStatus.group_state!=2){
+        ServiceCarStatus.group_comm_speed=0;
+    }
+    qDebug("serverSt: %d, speed: %f, state: %d", ServiceCarStatus.group_server_status, ServiceCarStatus.group_comm_speed, ServiceCarStatus.group_state);
+
+
+}
+
+void iv::decition::BrainDecition::UpdateVbox(const char *pdata, const int ndatasize){
+
+    iv::vbox::vbox group_message;
+    if(false == group_message.ParseFromArray(pdata,ndatasize))
+    {
+        std::cout<<"Listencansend Parse fail."<<std::endl;
+        return;
+    }
+
+//  解析box信息
+//    ServiceCarStatus.group_server_status = group_message.server_status();
+//    ServiceCarStatus.group_comm_speed= (float)group_message.car_control_speed();
+//    ServiceCarStatus.group_state= group_message.cmd_mode();
+
+
+    trafficLight.leftColor=group_message.st_left();
+    trafficLight.rightColor=group_message.st_right();
+    trafficLight.straightColor=group_message.st_straight();
+    trafficLight.uturnColor=group_message.st_turn();
+    trafficLight.leftTime=group_message.time_left();
+    trafficLight.rightTime=group_message.time_right();
+    trafficLight.straightTime=group_message.time_straight();
+    trafficLight.uturnTime=group_message.time_turn();
+
+
+
+}
+
+void iv::decition::BrainDecition::UpdateSate(){
+     decitionGps00->isFirstRun=true;
+}

+ 166 - 166
src/decition/decition_brain/decition/brain.h

@@ -1,166 +1,166 @@
-#pragma once
-/*
-* 中央决策大脑
-*/
-
-#ifndef _IV_DECITION_BRAIN_
-#define _IV_DECITION_BRAIN_
-
-#include <common/boost.h>
-#include <common/gps_type.h>
-//#include <control/controller.h>
-//#include <control/can.h>
-#include <perception/eyes.h>
-#include <decition/decition_maker.h>
-//#include <decition/decition_executer.h>
-#include <decition/decition_voter.h>
-#include <decition/decide_gps_00.h>
-#include <decition/decide_line_00.h>
-#include <decition/adc_tools/compute_00.h>
-#include <perception/sensor.h>
-#include <perception/sensor_camera.h>
-#include <perception/sensor_gps.h>
-#include<perception/sensor_lidar.h>
-#include<perception/sensor_radar.h>
-//#include <server/carcalling.h>
-//#include "adcivstatedb.h"
-
-//#include "decition/vehiclestate_type.h"
-#include "common/hmi_type.h"
-#include "common/platform_type.h"
-#include"common/gps_type.h"
-
-#include <QMutex>
-#include <QTime>
-#include <memory>
-
-#include "brainstate.pb.h"
-#include "decition.pb.h"
-#include "mapreq.pb.h"
-#include "chassis.pb.h"
-#include "hmi.pb.h"
-#include "radio_send.pb.h"
-#include "ivlog.h"
-#include "formation_map.pb.h"
-#include "vbox.pb.h"
-
-#include "fanyaapi.h"
-
-namespace iv {
-	namespace decition {
-		class BrainDecition
-		{
-		public:
-			BrainDecition();
-			~BrainDecition();
-
-
-            void inialize();/* 初始化*/
-
-
-            bool loadMapFromFile(std::string fileName);/* 加载地图*/
-			bool loadMapFromFile2(std::string fileName);
-			bool loadMapFromFile3(std::string fileName);
-			bool loadMapFromFile4(std::string fileName);
-
-
-            void start();/* 启动大脑*/
-			void stop();	//关闭
-
-			std::vector<iv::GPSData> navigation_data;	//导航数据,GPS结构体数组
-			std::vector<iv::GPSData> navigation_data2;	//导航数据,GPS结构体数组2
-			std::vector<iv::GPSData> navigation_data3;	//导航数据,GPS结构体数组3
-			std::vector<iv::GPSData> navigation_data4;	//导航数据,GPS结构体数组4
-			std::vector<iv::ObsRadar> radar_data;
-			std::vector<iv::ObsRadar> lidar_data;
-			std::vector<iv::ObsRadar> camera_data;
-		/*	std::vector<std::vector<iv::GPSData>> mapsL;
-			std::vector<std::vector<iv::GPSData>> mapsR;*/
-
-            double decision_period = 0.0;
-            double look1 = 0.0;
-            double look2 = 0.0;
-            double look3 = 0.0;
-            double look4 = 0.0;
-            double look5 = 0.0;
-            double look6 = 0.0;
-            double look7 = 0.0;
-
-            void UpdateMap(const char * mapdata,const int mapdatasize);
-		private:
-		//	iv::perception::Eyes* eyes;							//眼睛
- //           iv::carcalling::carcalling* carcall;
-			iv::perception::Eyes* eyes;
-			iv::decition::DecitionMaker* decitionMaker;			//决策器
-			iv::decition::DecitionVoter* decitionVoter;			//决策仲裁 判断器
-//			iv::decition::DecitionExecuter* decitionExecuter;	//决策执行器
-
-            iv::decition::DecideGps00* decitionGps00;			//决策器
-              iv::decition::DecideLine00* decitionLine00;
-
-//			boost::shared_ptr<iv::control::Controller> controller;	//实际车辆控制器
-
-			boost::thread* thread_run;
-			
-			iv::ObsLiDAR obs_lidar_;		//激光雷达障碍物
-			iv::ObsRadar obs_radar_;		//毫米波雷达障碍物
-			//iv::ObsCamera obs_camera_;		//摄像头障碍物
-			iv::CameraInfoPtr obs_camera_;
-//			iv::GPSData gps_data_;			//gps 惯导数据
-			iv::LidarGridPtr obs_lidar_grid_;//激光雷达网格化
-            iv::LidarGridPtr old_obs_lidar_grid_;//激光雷达网格化
-            iv::TrafficLight trafficLight;
-            int lastMode;
-            bool lastPause;
-
-			void run();	//实际执行逻辑
-
-            void * mpamapreq;
-            void * mpa;
-            void * mpvbox;
-            QMutex mMutexMap;
-
-            void * mpaDecition;
-            void * mpaVechicleState;
-            void * mpaToPlatform;
-            void * mpaPlanTrace;
-
-
-            void ShareDecition(iv::decition::Decition decition);
-            void ShareBrainstate(iv::brain::brainstate xbs);
-
-        private:
-            void * mpaPAD;
-            void * mpaHMI;
-            void * mpaPlatform;
-            void *mpaGroup;
-            void * mpmapChangeSig;
-            std::string mstrmemmap_index;
-
-            int mnOldTime;
-            QTime mTime;
-            double mfSpeedLast;
-            double mfVehSpeedLast;
-
-
-        public:
-            void UpdatePAD(const char *pdata, const int ndatasize);
-            void UpdateHMI(const char * pdata,const int ndatasize);
-            void UpdatePlatform(const char * pdata,const int ndatasize);
-            void UpdateGroupInfo(const char * pdata,const int ndatasize);
-            void UpdateSate();
-            void UpdateVbox(const char * pdata,const int ndatasize);
-
-        private:
-//            Adcivstatedb * mpasd;
-            void UpdateChassis(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname);
-
-            fanyaapi mmpcapi;
-
-            bool mbUseExternMPC = false;
-        };
-
-    }
-}
-
-#endif // !_IV_DECITION_BRAIN_
+#pragma once
+/*
+* 中央决策大脑
+*/
+
+#ifndef _IV_DECITION_BRAIN_
+#define _IV_DECITION_BRAIN_
+
+#include <common/boost.h>
+#include <common/gps_type.h>
+//#include <control/controller.h>
+//#include <control/can.h>
+#include <perception/eyes.h>
+#include <decition/decition_maker.h>
+//#include <decition/decition_executer.h>
+#include <decition/decition_voter.h>
+#include <decition/decide_gps_00.h>
+#include <decition/decide_line_00.h>
+#include <decition/adc_tools/compute_00.h>
+#include <perception/sensor.h>
+#include <perception/sensor_camera.h>
+#include <perception/sensor_gps.h>
+#include<perception/sensor_lidar.h>
+#include<perception/sensor_radar.h>
+//#include <server/carcalling.h>
+//#include "adcivstatedb.h"
+
+//#include "decition/vehiclestate_type.h"
+#include "common/hmi_type.h"
+#include "common/platform_type.h"
+#include"common/gps_type.h"
+
+#include <QMutex>
+#include <QTime>
+#include <memory>
+
+#include "brainstate.pb.h"
+#include "decition.pb.h"
+#include "mapreq.pb.h"
+#include "chassis.pb.h"
+#include "hmi.pb.h"
+#include "radio_send.pb.h"
+#include "ivlog.h"
+#include "formation_map.pb.h"
+#include "vbox.pb.h"
+
+#include "fanyaapi.h"
+
+namespace iv {
+	namespace decition {
+		class BrainDecition
+		{
+		public:
+			BrainDecition();
+			~BrainDecition();
+
+
+            void inialize();/* 初始化*/
+
+
+            bool loadMapFromFile(std::string fileName);/* 加载地图*/
+			bool loadMapFromFile2(std::string fileName);
+			bool loadMapFromFile3(std::string fileName);
+			bool loadMapFromFile4(std::string fileName);
+
+
+            void start();/* 启动大脑*/
+			void stop();	//关闭
+
+			std::vector<iv::GPSData> navigation_data;	//导航数据,GPS结构体数组
+			std::vector<iv::GPSData> navigation_data2;	//导航数据,GPS结构体数组2
+			std::vector<iv::GPSData> navigation_data3;	//导航数据,GPS结构体数组3
+			std::vector<iv::GPSData> navigation_data4;	//导航数据,GPS结构体数组4
+			std::vector<iv::ObsRadar> radar_data;
+			std::vector<iv::ObsRadar> lidar_data;
+			std::vector<iv::ObsRadar> camera_data;
+		/*	std::vector<std::vector<iv::GPSData>> mapsL;
+			std::vector<std::vector<iv::GPSData>> mapsR;*/
+
+            double decision_period = 0.0;
+            double look1 = 0.0;
+            double look2 = 0.0;
+            double look3 = 0.0;
+            double look4 = 0.0;
+            double look5 = 0.0;
+            double look6 = 0.0;
+            double look7 = 0.0;
+
+            void UpdateMap(const char * mapdata,const int mapdatasize);
+		private:
+		//	iv::perception::Eyes* eyes;							//眼睛
+ //           iv::carcalling::carcalling* carcall;
+			iv::perception::Eyes* eyes;
+			iv::decition::DecitionMaker* decitionMaker;			//决策器
+			iv::decition::DecitionVoter* decitionVoter;			//决策仲裁 判断器
+//			iv::decition::DecitionExecuter* decitionExecuter;	//决策执行器
+
+            iv::decition::DecideGps00* decitionGps00;			//决策器
+              iv::decition::DecideLine00* decitionLine00;
+
+//			boost::shared_ptr<iv::control::Controller> controller;	//实际车辆控制器
+
+			boost::thread* thread_run;
+			
+			iv::ObsLiDAR obs_lidar_;		//激光雷达障碍物
+			iv::ObsRadar obs_radar_;		//毫米波雷达障碍物
+			//iv::ObsCamera obs_camera_;		//摄像头障碍物
+			iv::CameraInfoPtr obs_camera_;
+//			iv::GPSData gps_data_;			//gps 惯导数据
+			iv::LidarGridPtr obs_lidar_grid_;//激光雷达网格化
+            iv::LidarGridPtr old_obs_lidar_grid_;//激光雷达网格化
+            iv::TrafficLight trafficLight;
+            int lastMode;
+            bool lastPause;
+
+			void run();	//实际执行逻辑
+
+            void * mpamapreq;
+            void * mpa;
+            void * mpvbox;
+            QMutex mMutexMap;
+
+            void * mpaDecition;
+            void * mpaVechicleState;
+            void * mpaToPlatform;
+            void * mpaPlanTrace;
+
+
+            void ShareDecition(iv::decition::Decition decition);
+            void ShareBrainstate(iv::brain::brainstate xbs);
+
+        private:
+            void * mpaPAD;
+            void * mpaHMI;
+            void * mpaPlatform;
+            void *mpaGroup;
+            void * mpmapChangeSig;
+            std::string mstrmemmap_index;
+
+            int mnOldTime;
+            QTime mTime;
+            double mfSpeedLast;
+            double mfVehSpeedLast;
+
+
+        public:
+            void UpdatePAD(const char *pdata, const int ndatasize);
+            void UpdateHMI(const char * pdata,const int ndatasize);
+            void UpdatePlatform(const char * pdata,const int ndatasize);
+            void UpdateGroupInfo(const char * pdata,const int ndatasize);
+            void UpdateSate();
+            void UpdateVbox(const char * pdata,const int ndatasize);
+
+        private:
+//            Adcivstatedb * mpasd;
+            void UpdateChassis(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname);
+
+            fanyaapi mmpcapi;
+
+            bool mbUseExternMPC = false;
+        };
+
+    }
+}
+
+#endif // !_IV_DECITION_BRAIN_

+ 1843 - 1843
src/decition/decition_brain/decition/compute_00.cpp

@@ -1,1843 +1,1843 @@
-#include <decition/compute_00.h>
-#include <decition/decide_gps_00.h>
-#include <decition/gps_distance.h>
-#include <decition/decition_type.h>
-#include <decition/transfer.h>
-#include <common/constants.h>
-#include <math.h>
-#include <iostream>
-#include <fstream>
-//#include <control/radar_exam.h>
-#include <control/can.h>
-using namespace std;
-
-#define PI (3.1415926535897932384626433832795)
-
-iv::decition::Compute00::Compute00() {
-
-}
-iv::decition::Compute00::~Compute00() {
-
-}
-
-
-double iv::decition::Compute00::angleLimit = 700;
-double iv::decition::Compute00::lastEA = 0;
-double iv::decition::Compute00::lastEP = 0;
-double iv::decition::Compute00::decision_Angle = 0;
-double iv::decition::Compute00::lastAng = 0;
-int iv::decition::Compute00::lastEsrID = -1;
-int  iv::decition::Compute00::lastEsrCount = 0;
-int iv::decition::Compute00::lastEsrIDAvoid = -1;
-int  iv::decition::Compute00::lastEsrCountAvoid = 0;
-
-iv::GPS_INS  iv::decition::Compute00::nearTpoint;
-iv::GPS_INS  iv::decition::Compute00::farTpoint;
-double  iv::decition::Compute00::bocheAngle;
-
-
-
-iv::GPS_INS  iv::decition::Compute00::dTpoint0;
-iv::GPS_INS  iv::decition::Compute00::dTpoint1;
-iv::GPS_INS  iv::decition::Compute00::dTpoint2;
-iv::GPS_INS  iv::decition::Compute00::dTpoint3;
-double  iv::decition::Compute00::dBocheAngle;
-
-
-std::vector<int> lastEsrIdVector;
-std::vector<int> lastEsrCountVector;
-
-int iv::decition::Compute00::getNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap, int lastIndex, double mindis, double maxAngle)
-{
-    int index = -1;
-    //	DecideGps00().minDis = iv::MaxValue;
-    DecideGps00().minDis = 20;
-    DecideGps00().maxAngle = iv::MaxValue;
-
-    int startIndex = max((lastIndex - 500), 0);     // startIndex = 0 则每一次都是遍历整条地图路线
-    int endIndex = min((gpsMap.size() - 1), (size_t)(lastIndex + 2000 + 100 * (gpsMissCount + 1)));
-
-    for (int j = startIndex; j < endIndex; j++)
-    {
-        int i = (j + gpsMap.size()) % gpsMap.size();
-        double tmpdis = GetDistance(rp, (*gpsMap[i]));
-
-        if (tmpdis < DecideGps00().minDis && (abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle) < 80
-                                              || abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle - 360) < 80
-                                              || abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle + 360) < 80)
-                )
-        {
-            index = i;
-            DecideGps00().minDis = tmpdis;
-            DecideGps00().maxAngle = min(abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle), abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle - 360));
-            DecideGps00().maxAngle = min(DecideGps00().maxAngle, abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle + 360));
-        }
-    }
-    /*if (index == -1) {
-        index = 0;
-    }*/
-    return index;
-}
-
-
-//首次找点
-
-int iv::decition::Compute00::getFirstNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap, int lastIndex, double mindis, double maxAngle)
-{
-    int index = -1;
-    //	DecideGps00().minDis = iv::MaxValue;
-    DecideGps00().minDis = 40;
-    DecideGps00().maxAngle = iv::MaxValue;
-
-    int startIndex = 0;     // startIndex = 0 则每一次都是遍历整条地图路线
-    int endIndex = gpsMap.size() - 1;
-
-    for (int j = startIndex; j < endIndex; j++)
-    {
-        int i = (j + gpsMap.size()) % gpsMap.size();
-        double tmpdis = GetDistance(rp, (*gpsMap[i]));
-
-        if (tmpdis < DecideGps00().minDis && (abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle) < 80
-                                              || abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle - 360) < 80
-                                              || abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle + 360) < 80)
-                )
-        {
-            index = i;
-            DecideGps00().minDis = tmpdis;
-            DecideGps00().maxAngle = min(abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle), abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle - 360));
-            DecideGps00().maxAngle = min(DecideGps00().maxAngle, abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle + 360));
-        }
-    }
-    /*if (index == -1) {
-        index = 0;
-    }*/
-    return index;
-}
-
-
-
-
-
-double iv::decition::Compute00::getAveDef(std::vector<Point2D> farTrace)
-{
-    double sum_x = 0;
-    double sum_y = 0;
-
-    for (int i = 0; i < min(5, (int)farTrace.size()); i++)
-    {
-        sum_x += farTrace[i].x;
-        sum_y += abs(farTrace[i].y);
-    }
-    double average_y = sum_y / min(5, (int)farTrace.size());
-    double average_x = sum_x / min(5, (int)farTrace.size());
-
-
-    return atan(average_x / average_y) / PI * 180;
-}
-
-
-
-double iv::decition::Compute00::getAvoidAveDef(std::vector<Point2D> farTrace, double avoidX)
-{
-    double sum_x = 0;
-    double sum_y = 0;
-
-    for (int i = 0; i < min(5, (int)farTrace.size()); i++)
-    {
-        sum_x += farTrace[i].x;
-        sum_y += abs(farTrace[i].y);
-    }
-    double average_y = sum_y / min(5, (int)farTrace.size());
-    double average_x = sum_x / min(5, (int)farTrace.size());
-
-
-    return atan(average_x + avoidX / average_y) / PI * 180;
-}
-
-
-
-
-
-
-double iv::decition::Compute00::getDecideAngle(std::vector<Point2D>  gpsTrace, double realSpeed) {
-
-    double ang = 0;
-    double EPos = 0, EAng = 0;
-
-    //   double KEang = 14, KEPos = 10, DEang = 3, DEPos = 1;  // double KEang = 14, KEPos = 10, DEang = 10, DEPos = 10;
-    double KEang = 14, KEPos = 10, DEang = 0, DEPos = 0;
-
-    if(transferPieriod&& !transferPieriod2){
-        DEang = 200;
-        DEPos = 150;
-    }
-
-    //   double PreviewDistance = max(6.0, realSpeed / 3.6 * 1.8);//预瞄距离
-
-    double PreviewDistance;//预瞄距离
-    realSpeed > 40 ? PreviewDistance = max(6.0, realSpeed *0.6) : PreviewDistance = max(6.0, realSpeed *0.5);
-    if(changeRoad ||transferPieriod){
-        PreviewDistance=PreviewDistance+avoidX;
-    }
-    if(realSpeed <15){
-        PreviewDistance = max(4.0, realSpeed *0.4) ;
-    }
-
-    if (gpsTrace[0].v1 == 1)
-    {
-        KEang = 14; KEPos = 10;
-    }
-    else if (gpsTrace[0].v1 == 2 || gpsTrace[0].v1 == 3)
-    {
-        KEang = 14; KEPos = 10;
-    }
-    else if (gpsTrace[0].v1 == 4 || gpsTrace[0].v1 == 5)
-    {
-        KEang = 14; KEPos = 10;
-    }
-    else if (gpsTrace[0].v1 == 7 && (gpsTrace[0].v2 == 23 || gpsTrace[0].v2 == 24))
-    {
-        KEang = 18; KEPos = 50; PreviewDistance = 3;
-    }
-    else if (gpsTrace[0].v1 == 7)
-    {
-        KEang = 20; KEPos = 50; PreviewDistance = 4;
-    }
-
-
-    if (realSpeed > 40)	KEang = 10; KEPos = 8;
-    if (realSpeed > 50) KEang = 5;
-
-    double sumdis = 0;
-    int gpsIndex = 0;
-    std::vector<Point2D> farTrace;
-
-
-
-
-
-
-    for (int i = 1; i < gpsTrace.size() - 1; i++)
-    {
-        sumdis += GetDistance(gpsTrace[i - 1], gpsTrace[i]);
-        if (sumdis > PreviewDistance)
-        {
-            gpsIndex = i;
-            break;
-        }
-    }
-
-
-
-
-    EPos = gpsTrace[gpsIndex].x;
-
-    for (unsigned int i = max(0, gpsIndex - 3); i < min((size_t)(gpsIndex + 3), gpsTrace.size()); i++) {
-        farTrace.push_back(gpsTrace[gpsIndex]);
-    }
-    if (farTrace.size() == 0) {
-        EAng = 0;
-    }
-    else {
-        EAng = getAveDef(farTrace);
-    }
-
-    ang = KEang * EAng + KEPos * EPos + DEang * (EAng - lastEA) + DEPos * (EPos - lastEP);
-
-    lastEA = EAng;
-    lastEP = EPos;
-
-    if (ang > angleLimit) {
-        ang = angleLimit;
-    }
-    else if (ang < -angleLimit) {
-        ang = -angleLimit;
-    }
-    if (lastAng != iv::MaxValue) {
-        ang = 0.2 * lastAng + 0.8 * ang;
-        //ODS("lastAng:%d\n", lastAng);
-    }
-    lastAng = ang;
-    return ang;
-}
-
-
-
-
-int  iv::decition::Compute00::getSpeedPointIndex(std::vector<Point2D> gpsTrace, double realSpeed)
-{
-    int index = 1;
-    double sumdis = 0;
-    while (index < gpsTrace.size() && sumdis < realSpeed)
-        sumdis += GetDistance(gpsTrace[index - 1], gpsTrace[index++]);
-
-    if (index == gpsTrace.size())
-        return index - 1;
-
-    if (abs(sumdis - realSpeed) > abs(sumdis - GetDistance(gpsTrace[index - 1], gpsTrace[index]) - realSpeed))
-        index--;
-    return index;
-}
-
-iv::Point2D iv::decition::Compute00::getLidarObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
-
-    iv::Point2D obsPoint(-1, -1);
-    vector<Point2D> gpsTraceLeft;
-    vector<Point2D> gpsTraceRight;
-    for (int j = 0; j < gpsTrace.size(); j++)
-    {
-        double sumx1 = 0, sumy1 = 0, count1 = 0;
-        double sumx2 = 0, sumy2 = 0, count2 = 0;
-        for (int k = max(0, j - 4); k <= j; k++)
-        {
-            count1 = count1 + 1;
-            sumx1 += gpsTrace[k].x;
-            sumy1 += gpsTrace[k].y;
-        }
-        for (unsigned int k = j; k <= min(gpsTrace.size() - 1, (size_t)(j + 4)); k++)
-        {
-            count2 = count2 + 1;
-            sumx2 += gpsTrace[k].x;
-            sumy2 += gpsTrace[k].y;
-        }
-        sumx1 /= count1; sumy1 /= count1;
-        sumx2 /= count2; sumy2 /= count2;
-
-        double anglevalue = atan2(sumy2 - sumy1, sumx2 - sumx1);
-
-        double carFrontx = gpsTrace[j].x;// -Form1.CarRear * Math.Cos(anglevalue);
-        double carFronty = gpsTrace[j].y;// -Form1.CarRear * Math.Sin(anglevalue);
-
-        Point2D ptLeft(carFrontx + Veh_Width / 2 * cos(anglevalue + PI / 2),
-                       carFronty + Veh_Width / 2 * sin(anglevalue + PI / 2));
-
-        Point2D ptRight(carFrontx + Veh_Width / 2 * cos(anglevalue - PI / 2),
-                        carFronty + Veh_Width / 2 * sin(anglevalue - PI / 2));
-
-        gpsTraceLeft.push_back(ptLeft);
-        gpsTraceRight.push_back(ptRight);
-
-    }
-
-
-    bool isRemove = false;
-
-    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
-    {
-
-        if (!isRemove && gpsTrace[j].y>2.5 )
-        {
-            int count = 0;
-
-            for (double length = 0; length <= Veh_Width; length += 0.4)
-            {
-                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
-                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
-
-                //				int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;  //+(ptx / abs(ptx))) / 2左右多出一半的车宽(1米)
-                //				int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
-                int dx = (ptx + gridwide*(double)centerx)/gridwide;
-                int dy = (pty + gridwide*(double)centery)/gridwide;
-
-                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
-                {
-                    //					if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
-                    if (lidarGridPtr[dx * (iv::gry) + dy].ob != 0)
-                    {
-                        count++; obsPoint.x = ptx; obsPoint.y = pty;
-                    }
-                }
-            }
-
-            j++;
-
-            for (double length = 0; length <= Veh_Width; length += 0.4)
-            {
-                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
-                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
-
-                //				int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;
-                //				int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
-                int dx = (ptx + gridwide*(double)centerx)/gridwide;
-                int dy = (pty + gridwide*(double)centery)/gridwide;
-
-                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
-                {
-                    //					if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
-                    if (lidarGridPtr[dx * (iv::gry) + dy].ob != 0)
-                    {
-                        count++; obsPoint.x = ptx; obsPoint.y = pty;
-                    }
-                }
-            }
-
-            if (count >= 2)
-            {
-                obsPoint.x = gpsTrace[j].x;
-                obsPoint.y = gpsTrace[j].y;
-
-                isRemove = true;
-                //		DecideGps00().lidarDistance = obsPoint.y;
-                return obsPoint;
-            }
-        }
-    }
-    //	DecideGps00().lidarDistance = obsPoint.y;
-    return obsPoint;
-}
-
-//1220
-iv::Point2D iv::decition::Compute00::getLidarRearObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
-
-    iv::Point2D obsPoint(-1, -1);
-    vector<Point2D> gpsTraceLeft;
-    vector<Point2D> gpsTraceRight;
-    for (int j = 0; j < gpsTrace.size(); j++)
-    {
-        double sumx1 = 0, sumy1 = 0, count1 = 0;
-        double sumx2 = 0, sumy2 = 0, count2 = 0;
-        for (int k = max(0, j - 4); k <= j; k++)
-        {
-            count1 = count1 + 1;
-            sumx1 += gpsTrace[k].x;
-            sumy1 += gpsTrace[k].y;
-        }
-        for (unsigned int k = j; k <= min(gpsTrace.size() - 1, (size_t)(j + 4)); k++)
-        {
-            count2 = count2 + 1;
-            sumx2 += gpsTrace[k].x;
-            sumy2 += gpsTrace[k].y;
-        }
-        sumx1 /= count1; sumy1 /= count1;
-        sumx2 /= count2; sumy2 /= count2;
-
-        double anglevalue = atan2(sumy2 - sumy1, sumx2 - sumx1);
-
-        double carFrontx = gpsTrace[j].x;// -Form1.CarRear * Math.Cos(anglevalue);
-        double carFronty = gpsTrace[j].y;// -Form1.CarRear * Math.Sin(anglevalue);
-
-        Point2D ptLeft(carFrontx + (Veh_Width-0.3) / 2 * cos(anglevalue + PI / 2),
-                       carFronty + (Veh_Width-0.3) / 2 * sin(anglevalue + PI / 2));
-
-        Point2D ptRight(carFrontx + (Veh_Width-0.3) / 2 * cos(anglevalue - PI / 2),
-                        carFronty + (Veh_Width-0.3) / 2 * sin(anglevalue - PI / 2));
-
-        gpsTraceLeft.push_back(ptLeft);
-        gpsTraceRight.push_back(ptRight);
-
-    }
-
-
-    bool isRemove = false;
-
-    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
-    {
-
-        if (!isRemove && gpsTrace[j].y<-1.0 )
-        {
-            int count = 0;
-
-            for (double length = 0; length <= Veh_Width; length += 0.4)
-            {
-                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
-                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
-
-                //				int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;  //+(ptx / abs(ptx))) / 2左右多出一半的车宽(1米)
-                //				int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
-                int dx = (ptx + gridwide*(double)centerx)/gridwide;
-
-                dx=grx-dx;//1227
-
-                int dy = (pty + gridwide*(double)centery)/gridwide;
-
-                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
-                {
-                    //					if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
-                    if (lidarGridPtr[dx * (iv::gry) + dy].ob != 0)
-                    {
-                        count++; obsPoint.x = ptx; obsPoint.y = pty;
-                    }
-                }
-            }
-
-            j++;
-
-            for (double length = 0; length <= Veh_Width; length += 0.4)
-            {
-                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
-                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
-
-                //				int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;
-                //				int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
-                int dx = (ptx + gridwide*(double)centerx)/gridwide;
-
-                dx=grx-dx;//1227
-                int dy = (pty + gridwide*(double)centery)/gridwide;
-
-                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
-                {
-                    //					if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
-                    if (lidarGridPtr[dx * (iv::gry) + dy].ob != 0)
-                    {
-                        count++; obsPoint.x = ptx; obsPoint.y = pty;
-                    }
-                }
-            }
-
-            if (count >= 2)
-            {
-                obsPoint.x = gpsTrace[j].x;
-                obsPoint.y = gpsTrace[j].y;
-
-                isRemove = true;
-                //		DecideGps00().lidarDistance = obsPoint.y;
-                return obsPoint;
-            }
-        }
-    }
-    //	DecideGps00().lidarDistance = obsPoint.y;
-    return obsPoint;
-}
-
-
-iv::Point2D iv::decition::Compute00::getLidarObsPointAvoid(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
-
-    iv::Point2D obsPoint(-1, -1);
-    vector<Point2D> gpsTraceLeft;
-    vector<Point2D> gpsTraceRight;
-    for (int j = 0; j < gpsTrace.size(); j++)
-    {
-        double sumx1 = 0, sumy1 = 0, count1 = 0;
-        double sumx2 = 0, sumy2 = 0, count2 = 0;
-        for (int k = max(0, j - 4); k <= j; k++)
-        {
-            count1 = count1 + 1;
-            sumx1 += gpsTrace[k].x;
-            sumy1 += gpsTrace[k].y;
-        }
-        for (unsigned int k = j; k <= min(gpsTrace.size() - 1, (size_t)(j + 4)); k++)
-        {
-            count2 = count2 + 1;
-            sumx2 += gpsTrace[k].x;
-            sumy2 += gpsTrace[k].y;
-        }
-        sumx1 /= count1; sumy1 /= count1;
-        sumx2 /= count2; sumy2 /= count2;
-
-        double anglevalue = atan2(sumy2 - sumy1, sumx2 - sumx1);
-
-        double carFrontx = gpsTrace[j].x;// -Form1.CarRear * Math.Cos(anglevalue);
-        double carFronty = gpsTrace[j].y;// -Form1.CarRear * Math.Sin(anglevalue);
-
-        //1127 fanwei xiuzheng
-        float buchang=0;
-        Point2D ptLeft(carFrontx + (Veh_Width+(buchang)*2) / 2 * cos(anglevalue + PI / 2),
-                       carFronty +  (Veh_Width+(buchang)*2) / 2 * sin(anglevalue + PI / 2));
-
-        Point2D ptRight(carFrontx +  (Veh_Width+(buchang)*2) / 2 * cos(anglevalue - PI / 2),
-                        carFronty +  (Veh_Width+(buchang)*2) / 2 * sin(anglevalue - PI / 2));
-
-        gpsTraceLeft.push_back(ptLeft);
-        gpsTraceRight.push_back(ptRight);
-
-    }
-
-
-    bool isRemove = false;
-
-    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
-    {
-
-        if (!isRemove && gpsTrace[j].y>2.5 && gpsTraceLeft[j].y>2.5 && gpsTraceRight[j].y>2.5)
-        {
-            int count = 0;
-
-            for (double length = 0; length <= Veh_Width; length += 0.4)
-            {
-                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
-                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
-
-                int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;  //*2左右多出一半的车宽(1米)
-                int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
-
-                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
-                {
-                    if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
-                    {
-                        count++; obsPoint.x = ptx; obsPoint.y = pty;
-                    }
-                }
-            }
-
-            j++;
-
-            for (double length = 0; length <= Veh_Width; length += 0.4)
-            {
-                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
-                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
-
-                int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;
-                int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
-
-                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
-                {
-                    if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
-                    {
-                        count++; obsPoint.x = ptx; obsPoint.y = pty;
-                    }
-                }
-            }
-
-            if (count >= 2)
-            {
-                obsPoint.x = gpsTrace[j].x;
-                obsPoint.y = gpsTrace[j].y;
-
-                isRemove = true;
-                DecideGps00().lidarDistanceAvoid = obsPoint.y;
-                return obsPoint;
-            }
-        }
-    }
-    //	DecideGps00().lidarDistanceAvoid = obsPoint.y;
-
-    return obsPoint;
-}
-
-
-
-
-//int  iv::decition::Compute00::getEsrIndex(std::vector<Point2D> gpsTrace, std::vector<ObstacleBasic> esrRadars) {
-//	bool isRemove = false;
-//
-//	for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
-//	{
-//
-//		for (int i = 0; i < esrRadars.size(); i++)
-//			if ((esrRadars[i].nomal_y) != 0)
-//			{
-//				double xxx = esrRadars[i].nomal_x + Esr_Offset;
-//				double yyy = esrRadars[i].nomal_y;
-//
-//				if (abs(xxx - gpsTrace[j].x) <= 3.0*Veh_Width / 4.0 && abs(yyy - (gpsTrace[j].y)) <= 1)
-//				{
-//
-//					if (lastEsrID == (esrRadars[i]).esr_ID)
-//					{
-//						lastEsrCount++;
-//					}
-//					else
-//					{
-//						lastEsrCount = 0;
-//					}
-//
-//					if (lastEsrCount >= 3)
-//					{
-//						return i;
-//					}
-//
-//					lastEsrID = (esrRadars[i]).esr_ID;
-//				}
-//			}
-//	}
-//	return -1;
-//}
-
-
-
-
-int  iv::decition::Compute00::getEsrIndex(std::vector<Point2D> gpsTrace,int roadNum,int *esrPathpoint) {
-    bool isRemove = false;
-
-    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
-    {
-
-        for (int i = 0; i < 64; i++)
-            if ((ServiceCarStatus.obs_radar[i].nomal_y) != 0 && (ServiceCarStatus.obs_radar[i].valid))
-            {
-                double xxx = ServiceCarStatus.obs_radar[i].nomal_x + Esr_Offset;
-                double yyy = ServiceCarStatus.obs_radar[i].nomal_y+ Esr_Y_Offset;
-
-                /*ODS("\nESR毫米波检测物体X距离:%f\n", xxx);
-                ODS("\nESR毫米波检测物体Y距离:%f\n", yyy);*/
-
-//优化
-//                if(sqrt((xxx - gpsTrace[j].x)*(xxx - gpsTrace[j].x) + (yyy - gpsTrace[j].y)*(yyy - gpsTrace[j].y)) < (1.0*Veh_Width / 2.0+DecideGps00().xiuzhengCs)){
-//                    *esrPathpoint = j;
-//                    return i;
-//                }
-
-
-                if (abs(xxx - gpsTrace[j].x) <= (3.0*Veh_Width / 4.0+DecideGps00().xiuzhengCs) && abs(yyy - (gpsTrace[j].y)) <= 1)
-                {
-
-                    if (lastEsrID == i)
-                    {
-                        lastEsrCount++;
-                    }
-                    else
-                    {
-                        lastEsrCount = 0;
-                    }
-
-                    if(yyy>50 ){
-                        if (lastEsrCount >=200)
-                        {
-                            return i;
-                        }
-                    }
-                    else if (lastEsrCount >= 1)
-                    {
-                        return i;
-                    }
-
-                    lastEsrID = i;
-                }
-            }
-    }
-    return -1;
-}
-
-//int  iv::decition::Compute00::getEsrIndex(std::vector<Point2D> gpsTrace,int roadNum) {
-//    bool isRemove = false;
-
-//    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
-//    {
-
-//        for (int i = 0; i < 64; i++)
-//            if ((examed_obs_radar[i].nomal_y) != 0 && (examed_obs_radar[i].valid))
-//            {
-//                double xxx = examed_obs_radar[i].nomal_x + Esr_Offset;
-//                double yyy = examed_obs_radar[i].nomal_y+ Esr_Y_Offset;
-
-//                /*ODS("\nESR毫米波检测物体X距离:%f\n", xxx);
-//                ODS("\nESR毫米波检测物体Y距离:%f\n", yyy);*/
-
-
-//                if (abs(xxx - gpsTrace[j].x) <= 3.0*Veh_Width / 4.0 && abs(yyy - (gpsTrace[j].y)) <= 1)
-//                {
-
-//                    if (lastEsrID == i)
-//                    {
-//                        lastEsrCount++;
-//                    }
-//                    else
-//                    {
-//                        lastEsrCount = 0;
-//                    }
-
-//                    if(yyy>50 ){
-//                        if (lastEsrCount >=200)
-//                        {
-//                            return i;
-//                        }
-//                    }
-//                    else if (lastEsrCount >= 3)
-//                    {
-//                        return i;
-//                    }
-
-//                    lastEsrID = i;
-//                }
-//            }
-//    }
-//    return -1;
-//}
-
-
-
-int  iv::decition::Compute00::getEsrIndexAvoid(std::vector<Point2D> gpsTrace) {
-    bool isRemove = false;
-
-    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
-    {
-
-        for (int i = 0; i < 64; i++)
-            if ((ServiceCarStatus.obs_radar[i].nomal_y) != 0 && (ServiceCarStatus.obs_radar[i].valid))
-            {
-                double xxx = ServiceCarStatus.obs_radar[i].nomal_x + Esr_Offset;
-                double yyy = ServiceCarStatus.obs_radar[i].nomal_y;
-
-                if (abs(xxx - gpsTrace[j].x) <= 3.0*Veh_Width / 4.0 && abs(yyy - (gpsTrace[j].y)) <= 1)
-                {
-
-                    if (lastEsrIDAvoid == i)
-                    {
-                        lastEsrCountAvoid++;
-                    }
-                    else
-                    {
-                        lastEsrCountAvoid = 0;
-                    }
-
-                    if (lastEsrCountAvoid >= 6)
-                    {
-                        return i;
-                    }
-
-                    lastEsrIDAvoid = i;
-                }
-            }
-    }
-    return -1;
-}
-
-
-
-
-
-
-
-//double iv::decition::Compute00::getObsSpeed(Point2D obsPoint, std::vector<ObstacleBasic> esrRadars,double realSecSpeed) {
-//	double obsSpeed = 0 - realSecSpeed;
-//	double minDis = iv::MaxValue;
-//	for (int i = 0; i < esrRadars.size(); i++)
-//		if ((esrRadars[i].nomal_y) != 0)
-//		{
-//			double xxx = esrRadars[i].nomal_x + Esr_Offset;
-//			double yyy = esrRadars[i].nomal_y;
-//
-//			if (abs(xxx - obsPoint.x) < 4 && abs(yyy - obsPoint.y) < 2)
-//			{
-//				double tmpDis =sqrt((xxx - obsPoint.x) * (xxx - obsPoint.x) + (yyy - obsPoint.y) * (yyy - obsPoint.y));
-//				if (tmpDis < minDis)
-//				{
-//					minDis = tmpDis;
-//					obsSpeed = esrRadars[i].speed_y;
-//				}
-//			}
-//		}
-//
-//	return obsSpeed;
-//
-//
-//}
-
-
-
-
-double iv::decition::Compute00::getObsSpeed(Point2D obsPoint, double realSecSpeed) {
-    double obsSpeed = 0 - realSecSpeed;
-    double minDis = iv::MaxValue;
-    for (int i = 0; i < 64; i++)
-        if ((ServiceCarStatus.obs_radar[i].nomal_y) != 0 && ServiceCarStatus.obs_radar[i].valid)
-        {
-            double xxx = ServiceCarStatus.obs_radar[i].nomal_x + Esr_Offset;
-            double yyy = ServiceCarStatus.obs_radar[i].nomal_y + Esr_Y_Offset;
-
-            if (abs(xxx - obsPoint.x) < 4 && abs(yyy - obsPoint.y) < 2)
-            {
-                double tmpDis = sqrt((xxx - obsPoint.x) * (xxx - obsPoint.x) + (yyy - obsPoint.y) * (yyy - obsPoint.y));
-                if (tmpDis < minDis)
-                {
-                    minDis = tmpDis;
-                    obsSpeed = ServiceCarStatus.obs_radar[i].speed_y;
-                }
-            }
-        }
-
-    return obsSpeed;
-}
-
-
-
-
-double iv::decition::Compute00::getDecideAvoidAngle(std::vector<Point2D>  gpsTrace, double realSpeed, float avoidX) {
-
-    double ang = 0;
-    double EPos = 0, EAng = 0;
-
-    double KEang = 14, KEPos = 10, DEang = 0, DEPos = 0;
-
-    double PreviewDistance = max(6.0, realSpeed / 3.6 * 1.8);//预瞄距离
-
-
-    if (gpsTrace[0].v1 == 1)
-    {
-        KEang = 10; KEPos = 8;
-        if (realSpeed > 60) KEang = 5;
-    }
-    else if (gpsTrace[0].v1 == 2 || gpsTrace[0].v1 == 3)
-    {
-        KEang = 14; KEPos = 10;
-    }
-    else if (gpsTrace[0].v1 == 4 || gpsTrace[0].v1 == 5)
-    {
-        KEang = 14; KEPos = 10;
-    }
-    else if (gpsTrace[0].v1 == 7 && (gpsTrace[0].v2 == 23 || gpsTrace[0].v2 == 24))
-    {
-        KEang = 18; KEPos = 50; PreviewDistance = 3;
-    }
-    else if (gpsTrace[0].v1 == 7)
-    {
-        KEang = 20; KEPos = 50; PreviewDistance = 4;
-    }
-
-
-    double sumdis = 0;
-    int gpsIndex = 0;
-    std::vector<Point2D> farTrace;
-
-
-
-
-
-
-    for (int i = 1; i < gpsTrace.size() - 1; i++)
-    {
-        sumdis += GetDistance(gpsTrace[i - 1], gpsTrace[i]);
-        if (sumdis > PreviewDistance)
-        {
-            gpsIndex = i;
-            break;
-        }
-    }
-
-    if ((DecideGps00().readyParkMode) && (gpsIndex + 10>DecideGps00().gpsLineParkIndex))
-    {
-        gpsIndex = DecideGps00().gpsLineParkIndex;
-    }
-
-
-
-    EPos = gpsTrace[gpsIndex].x + avoidX;
-
-    for (unsigned int i = max(0, gpsIndex - 3); i < min((size_t)(gpsIndex + 3), gpsTrace.size()); i++) {
-        farTrace.push_back(gpsTrace[gpsIndex]);
-    }
-    if (farTrace.size() == 0) {
-        EAng = 0;
-    }
-    else {
-        EAng = getAvoidAveDef(farTrace, avoidX);
-    }
-
-    ang = KEang * EAng + KEPos * EPos + DEang * (EAng - lastEA) + DEPos * (EPos - lastEP);
-
-    lastEA = EAng;
-    lastEP = EPos;
-
-    if (ang > angleLimit) {
-        ang = angleLimit;
-    }
-    else if (ang < -angleLimit) {
-        ang = -angleLimit;
-    }
-    if (lastAng != iv::MaxValue) {
-        ang = 0.2 * lastAng + 0.8 * ang;
-        //ODS("lastAng:%d\n", lastAng);
-    }
-    lastAng = ang;
-
-    return ang;
-}
-
-
-std::vector<iv::GPSData>   iv::decition::Compute00::getBesideGpsMapLine(iv::GPS_INS now_gps_ins, vector<iv::GPSData>gpsMapLine, float avoidX) {
-
-    vector<vector<iv::GPSData>> maps;
-    vector<iv::GPSData> gpsMapLineBeside;
-    int sizeN = gpsMapLine.size();
-    for (int i = 1; i < sizeN; i++)
-    {
-        iv::GPSData gpsData(new GPS_INS);
-        double xx = gpsMapLine[i]->gps_x - now_gps_ins.gps_x;
-        double yy = gpsMapLine[i]->gps_y - now_gps_ins.gps_y;
-        double lng = ServiceCarStatus.location->ins_heading_angle;
-
-
-        double x0 = xx * cos(lng * PI / 180) - yy * sin(lng * PI / 180);
-        double y0 = xx * sin(lng * PI / 180) + yy * cos(lng * PI / 180);
-        double k1 = sin((90 + (gpsMapLine[i]->ins_heading_angle - lng)) * PI / 180);
-        double k2 = cos((90 + (gpsMapLine[i]->ins_heading_angle - lng)) * PI / 180);
-
-        //	memcpy(&gpsData, &gpsMapLine[i], sizeof(gpsData));
-
-        gpsData->speed_mode = gpsMapLine[i]->speed_mode;
-        gpsData->gps_x = x0 + k1 * avoidX;
-        gpsData->gps_y = y0 + k2 * avoidX;
-        gpsMapLineBeside.push_back(gpsData);
-
-    }
-    return gpsMapLineBeside;
-
-}
-
-
-
-//double iv::decition::Compute00::getDecideAngleByLane(double realSpeed) {
-
-//    double ang = 0;
-//    double EPos = 0, EAng = 0;
-
-// //   double KEang = 14, KEpos = 10, DEang = 0, DEpos = 0;
-//       double KEang = 5, KEPos = 30, DEang = 0, DEPos = 0;
-
-// //   double PreviewDistance = max(6.0, realSpeed / 3.6 * 1.8);//预瞄距离
-
-//    double PreviewDistance;//预瞄距离
-//    realSpeed > 40 ? PreviewDistance = max(6.0, realSpeed *0.6) : PreviewDistance = max(6.0, realSpeed *0.5);
-
-
-
-
-
-////    if (realSpeed > 40)	KEang = 10; KEpos = 8;
-////        if (realSpeed > 50) KEang = 5;
-
-
-
-
-
-//double c1 = ServiceCarStatus.aftermarketLane.dist_to_lane_l;
-//double c2 = ServiceCarStatus.aftermarketLane.dist_to_lane_r;
-//double a = ServiceCarStatus.Lane.curvature;
-//double b = ServiceCarStatus.Lane.heading;
-//double c = (c1+c2)*0.5;
-//double x= PreviewDistance;
-//double y;
-
-
-//y=a*x*x+b*x+c;
-
-//   // EPos = y;
-//EPos=c;
-
-
-//  //  EAng=atan(2*a*x+b) / PI * 180;
-//    EAng=ServiceCarStatus.Lane.yaw;
-//        ang = KEang * EAng + KEPos * EPos + DEang * (EAng - lastEA) + DEPos * (EPos - lastEP);
-
-//        lastEA = EAng;
-//        lastEP = EPos;
-
-
-//           std::cout << "\nEPos:%f\n" << EPos << std::endl;
-//            std::cout << "\nEAng:%f\n" << EAng << std::endl;
-
-
-//        if (ang > angleLimit) {
-//            ang = angleLimit;
-//        }
-//        else if (ang < -angleLimit) {
-//            ang = -angleLimit;
-//        }
-//        if (lastAng != iv::MaxValue) {
-//            ang = 0.2 * lastAng + 0.8 * ang;
-//            //ODS("lastAng:%d\n", lastAng);
-//        }
-//        lastAng = ang;
-//        return ang;
-//    }
-
-
-
-double IEPos = 0, IEang = 0;
-
-
-double iv::decition::Compute00::getDecideAngleByLanePID(double realSpeed) {
-
-    double ang = 0;
-    double EPos = 0, EAng = 0;
-    double Curve=0;
-    double KEang = 14, KEPos = 10, DEang = 0, DEPos = 0;
-    double KCurve=120;
-    double KIEPos = 0, KIEang = 0;
-    //   double PreviewDistance = max(6.0, realSpeed / 3.6 * 1.8);//预瞄距离
-
-    double PreviewDistance;//预瞄距离
-
-    int confL=ServiceCarStatus.aftermarketLane.lane_conf_left;
-    int confR=ServiceCarStatus.aftermarketLane.lane_conf_right;
-    int conf =min(confL,confR);
-
-    realSpeed > 40 ? PreviewDistance = max(6.0, realSpeed *0.6) : PreviewDistance = max(6.0, realSpeed *0.5);
-
-
-
-
-
-    if (realSpeed > 40)	KEang = 10; KEPos = 8;
-    if (realSpeed > 50) KEang = 5;
-
-    KEPos = 20;
-    KEang = 200;
-    //KEang = 15;
-
-    double c1 = ServiceCarStatus.aftermarketLane.dist_to_lane_l;
-    double c2 = ServiceCarStatus.aftermarketLane.dist_to_lane_r;
-    double a = ServiceCarStatus.Lane.curvature;
-    double b = ServiceCarStatus.Lane.heading;
-    double c = (c1+c2)*0.5;
-    double yaw= ServiceCarStatus.Lane.yaw;
-
-    double x= PreviewDistance;
-    double y;
-
-
-    y=c-(a*x*x+b*x);
-    double difa=0-(atan(2*a*x+b) / PI * 180);
-    Curve=0-a;
-
-    //EAng=difa;
-    //EPos=y;
-    EAng= 0-b;
-    EPos = c;
-    DEang = 10;
-    DEPos = 20;
-    //DEang = 20;
-    //DEPos = 10;
-
-    IEang = EAng+0.7*IEang;
-    IEPos = EPos+0.7*IEPos;
-    KIEang = 0;
-    //KIEang = 0.5;
-    KIEPos =2;
-
-
-
-    if(abs(confL)>=2&&abs(confR)>=2){
-        //ang = KEang * EAng + KEPos * EPos + DEang * (EAng - lastEA) + DEPos * (EPos - lastEP)+ KIEang * IEang + KIEPos * IEPos;
-        ang = KEang * EAng + KEPos * EPos +KCurve*Curve+ DEang * (EAng - lastEA) + DEPos * (EPos - lastEP)+ KIEang * IEang + KIEPos * IEPos;
-    }else{
-        ang=lastAng;
-    }
-    //if(lastAng!=0&&abs(ang-lastAng)>20)ang=lastAng;
-
-    lastEA = EAng;
-    lastEP = EPos;
-
-    if (ang > angleLimit) {
-        ang = angleLimit;
-    }
-    else if (ang < -angleLimit) {
-        ang = -angleLimit;
-    }
-    if (lastAng != iv::MaxValue) {
-        ang = 0.2 * lastAng + 0.8 * ang;
-        //ODS("lastAng:%d\n", lastAng);
-    }
-    lastAng = ang;
-    return ang;
-}
-
-
-
-double iv::decition::Compute00::bocheCompute(GPS_INS nowGps, GPS_INS aimGps) {
-
-    GaussProjCal(aimGps.gps_lng, aimGps.gps_lat, &aimGps.gps_x, &aimGps.gps_y);
-    Point2D pt = Coordinate_Transfer(nowGps.gps_x, nowGps.gps_y, aimGps);
-
-
-
-    double x_1 = pt.x;
-    double y_1 = pt.y;
-    double angle_1 = getQieXianAngle(nowGps,aimGps);
-    double x_2 = 0.0, y_2 = 0.0;
-    double steering_angle;
-    double l = 2.950;
-    double r =6;
-    double x_o, y_o, x_o_1, y_o_1, x_o_2, y_o_2, x_3, y_3;
-    double x_t_n, y_t_n, x_t_f, y_t_f;//近切点和远切点
-    double x_t_1, y_t_1, x_t_2, y_t_2;//圆形1的切点
-    double x_t_3, y_t_3, x_t_4, y_t_4;//圆形2的切点
-    double g_1 = tan(angle_1);
-    double car_pos[3] = { x_1,y_1,g_1 };
-    double parking_pos[2] = { x_2,y_2 };
-    double g_3;
-    double t[4][2];
-    double p[4];
-    double  s1, s2; //切点与车起始位置的距离
-    double  min;
-    int  min_i;
-
-    //g_3 = 0 - 0.5775;
-    g_3 = pingfenxian_xielv(x_1, y_1, x_2, y_2, angle_1);
-    //交点
-    x_3 = 0.0;//(y_1 - y_2 + g_2*x_2 - g_1*x_1) / (g_2 - g_1);
-    y_3 = y_1 - g_1 * x_1;
-    //圆心1
-    x_o_1 = r;
-    y_o_1 = g_3 * r + y_3;
-    //圆形1的切点1
-    x_t_1 = 0.0;
-    y_t_1 = g_3 * r + y_3;
-    //圆形1的切点2
-    if (g_1 == 0)
-    {
-        x_t_2 = r;
-        y_t_2 = y_1 - g_1 * x_1;
-    }
-    else
-    {
-        y_t_2 = (y_1 + g_1 * x_o_1 + y_o_1 * g_1*g_1 - g_1 * x_1) / (1 + g_1 * g_1);
-        x_t_2 = (y_t_2 + g_1 * x_1 - y_1) / g_1;
-
-    }
-    //圆心2
-    x_o_2 = 0 - r;
-    y_o_2 = y_3 - g_3 * r;
-    //圆形2的切点1
-    x_t_3 = 0;
-    y_t_3 = y_3 - g_3 * r;
-    //圆形2的切点2
-    if (g_1 == 0)
-    {
-        x_t_4 = 0 - r;
-        y_t_4 = y_1 - g_1 * x_1;
-    }
-    else
-    {
-        y_t_4 = (y_1 + g_1 * x_o_2 + y_o_2 * g_1*g_1 - g_1 * x_1) / (1 + g_1 * g_1);
-        x_t_4 = (y_t_4 + g_1 * x_1 - y_1) / g_1;
-
-    }
-    t[0][0] = x_t_1;
-    t[0][1] = y_t_1;
-    t[1][0] = x_t_2;
-    t[1][1] = y_t_2;
-    t[2][0] = x_t_3;
-    t[2][1] = y_t_3;
-    t[3][0] = x_t_4;
-    t[3][1] = y_t_4;
-    for (int i = 0; i < 4; i++)
-    {
-
-        p[i] = (t[i][0] - parking_pos[0])*(t[i][0] - parking_pos[0]) + (t[i][1] - parking_pos[1])*(t[i][1] - parking_pos[1]);
-
-    }
-    min = p[0];
-    min_i = 0;
-    for (int i = 1; i < 4; i++)
-    {
-
-        if (p[i] < min)
-        {
-            min = p[i]; min_i = i;
-        }
-    }
-    if (min_i < 2)
-    {
-        x_o = x_o_1;
-        y_o = y_o_1;
-        s1 = (x_t_1 - x_1)*(x_t_1 - x_1) + (y_t_1 - y_1)*(y_t_1 - y_1);
-        s2 = (x_t_2 - x_1)*(x_t_2 - x_1) + (y_t_2 - y_1)*(y_t_2 - y_1);
-        if (s1 < s2)
-        {
-            x_t_n = x_t_1;
-            y_t_n = y_t_1;
-            x_t_f = x_t_2;
-            y_t_f = y_t_2;
-        }
-        else
-        {
-            x_t_n = x_t_2;
-            y_t_n = y_t_2;
-            x_t_f = x_t_1;
-            y_t_f = y_t_1;
-
-        }
-    }
-    else
-    {
-        x_o = x_o_2;
-        y_o = y_o_2;
-        s1 = (x_t_3 - x_1)*(x_t_3 - x_1) + (y_t_3 - y_1)*(y_t_3 - y_1);
-        s2 = (x_t_4 - x_1)*(x_t_4 - x_1) + (y_t_4 - y_1)*(y_t_4 - y_1);
-
-        if (s1 < s2)
-        {
-
-            x_t_n = x_t_3;
-            y_t_n = y_t_3;
-            x_t_f = x_t_4;
-            y_t_f = y_t_4;
-        }
-        else
-        {
-            x_t_n = x_t_4;
-            y_t_n = y_t_4;
-            x_t_f = x_t_3;
-            y_t_f = y_t_3;
-        }
-
-
-
-
-    }
-    steering_angle = atan2(l, r);
-
-    if (x_t_n < 0)
-    {
-        steering_angle = 0 - steering_angle;
-    }
-
-    nearTpoint=Coordinate_UnTransfer(x_t_n, y_t_n, aimGps);
-    farTpoint = Coordinate_UnTransfer(x_t_f, y_t_f, aimGps);
-    bocheAngle = steering_angle*180/PI;
-
-    cout << "近切点:x_t_n=" << x_t_n << endl;
-    cout << "近切点:y_t_n=" << y_t_n << endl;
-    cout << "远切点:x_t_f=" << x_t_f << endl;
-    cout << "远切点:y_t_f=" << y_t_f << endl;
-    cout << "航向角:" << steering_angle << endl;
-
-
-    //    if (x_1 < 0 && y_1 > 0 && x_1 < x_t_n &&y_t_f > 0.1) {
-    //        return 1;
-    //    }
-    Point2D ptN = Coordinate_Transfer(nearTpoint.gps_x, nearTpoint.gps_y, nowGps);
-    double disA = GetDistance(aimGps,nowGps);
-    if(y_t_n>0 && ptN.y<0 && y_t_f>0.1 && disA<40){
-        return 1;
-    }
-
-    return 0;
-
-}
-
-
-
-//返回垂直平分线的斜率
-double iv::decition::Compute00::pingfenxian_xielv(double x_1, double y_1, double x_2, double y_2, double angle_1) {
-    double angl, x_3, angle_3;
-    if (tan(angle_1 == 0))
-    {
-        if ((x_1 - x_2) > 0 && ((y_1 - y_2) > 0))
-        {
-            angle_3 = 0 - 1;
-        }
-        else
-        {
-            angle_3 = 1;
-        }
-    }
-    else
-    {
-        x_3 = (tan(angle_1)*x_1 - y_1) / tan(angle_1);//车所在直线与x轴交点
-        angl = tan(angle_1);//车所在直线的斜率
-        if ((x_1 - x_2)>0 && ((y_1 - y_2)>0))//第一象限
-        {
-            if ((angl *x_3)<0)//车斜率与车直线的x轴交点异号
-            {
-                if (angl < 0)
-                {
-                    angle_3 = tan(PI*0.5 + (PI*0.5 - atan(fabs(angl))) *0.5);//垂直平分线斜率
-                }
-                else
-                {
-                    angle_3 = tan(PI*0.5 + (PI*0.5 + atan(fabs(angl))) *0.5);//垂直平分线斜率
-                }
-
-
-
-            }
-
-        }
-        else//第二象限
-        {
-            if ((angl*x_3)<0)//车斜率与车直线的x轴交点异号
-            {
-                if (angl < 0)
-                {
-                    angle_3 = tan(PI*0.5 - (PI*0.5 + atan(fabs(angl))) *0.5);//垂直平分线斜率
-                }
-                else
-                {
-                    angle_3 = tan(atan(fabs(angl)) + (PI*0.5 - atan(fabs(angl))) *0.5);//垂直平分线斜率
-                }
-
-            }
-        }
-    }
-
-    return angle_3;
-
-}
-
-
-
-double iv::decition::Compute00::getQieXianAngle(GPS_INS nowGps, GPS_INS aimGps) {
-    double heading = nowGps.ins_heading_angle *PI/180;
-    double x1 = nowGps.gps_x;
-    double y1 = nowGps.gps_y;
-    if (heading<=PI*0.5)
-    {
-        heading = 0.5*PI - heading;
-    }
-    else if (heading>PI*0.5 && heading<=PI*1.5) {
-        heading = 1.5*PI - heading;
-    }
-    else if (heading>PI*1.5) {
-        heading = 2.5*PI - heading;
-    }
-    double k1 = tan(heading);
-    double x = x1+10;
-    double y = k1 * x + y1 - (k1 * x1);
-    Point2D pt1 = Coordinate_Transfer(nowGps.gps_x, nowGps.gps_y, aimGps);
-    Point2D pt2 = Coordinate_Transfer(x, y, aimGps);
-    double xielv = (pt1.y - pt2.y) / (pt1.x - pt2.x);
-    double angle = atan(abs(xielv));
-    if (xielv<0)
-    {
-        angle = PI - angle;
-    }
-    return angle;
-
-}
-
-
-/*
-  chuizhicheweiboche
-  */
-
-
-int iv::decition::Compute00::bocheDirectCompute(GPS_INS nowGps, GPS_INS aimGps)
-{
-
-
-
-    double l=2.95;//轴距
-    double x_0 = 0, y_0 = 0.5;
-    double x_1, y_1;//车起点坐标
-    double ange1;//车航向角弧度
-    double x_2, y_2;//另一条与车直线在angle2和R_M 固定情况下过坐标点,第二个近切点
-    double real_rad;;//另一条直线的航向角弧度
-    double angle_3;//垂直平分线弧度
-    double x_3, y_3;//垂直平分线交点
-    double x_4, y_4;//另一条直线的远切点坐标,第二个远切点,已知
-    double x_o_1, y_o_1;//圆形1坐标
-    double x_o_2, y_o_2;//圆形2坐标
-    double x_t_n, y_t_n, x_t_f, y_t_f;//近切点和远切点
-    double min_rad;
-    double R_M; //后轴中点的转弯半径
-    double steering_angle;
-
-
-
-
-    GaussProjCal(aimGps.gps_lng, aimGps.gps_lat, &aimGps.gps_x, &aimGps.gps_y);
-    Point2D pt = Coordinate_Transfer(nowGps.gps_x, nowGps.gps_y, aimGps);
-    x_1=pt.x;
-    y_1=pt.y;
-    ange1=getQieXianAngle(nowGps,aimGps);
-
-    min_rad_zhuanxiang(&R_M , &min_rad);
-    qiedian_n(x_1,y_1,R_M,min_rad,&x_2 , &y_2, &real_rad);//计算另一条与车直线在angle2和R_M 固定情况下近切点:x_2, y_2
-    liangzhixian_jiaodian( x_1, y_1,  x_2, y_2,ange1,real_rad,&x_3 , &y_3);
-    chuizhipingfenxian_xielv( x_1, y_1, ange1, real_rad, min_rad,&angle_3);
-    yuanxin( x_2, y_2, x_3, y_3, real_rad, angle_3, R_M,&x_o_1,&y_o_1,&x_o_2,&y_o_2);
-    yuanxin_qiedian( ange1, x_o_1, y_o_1,  x_o_2, y_o_2,
-                     x_1, y_1, x_2, y_2, x_3, y_3, real_rad, angle_3, R_M,&x_t_n,&y_t_n,&x_t_f, &y_t_f);
-    steering_angle = atan2(l, R_M);
-    x_4 = 0.5;
-    y_4 = 0;
-    //for (int i = 0; i < 4; i++)
-    //{
-    //for (int j = 0; j < 2; j++)
-    //{
-    //	cout << t[i][j] << endl;
-    //}
-    //}
-    //cout << "min_rad:" << min_rad<< endl;
-    //cout << "jiaodian:x=" << x_3 << endl;
-    //cout << "jiaodian:y=" << y_3 << endl;
-    // cout << "R-M:" << R_M << endl;
-    cout << "x_0:" << x_0 << endl;
-    cout << "y_0:" << y_0 << endl;
-    cout << "x_2:" << x_2 << endl;
-    cout << "y_2:" << y_2 << endl;
-    cout << "近切点:x_t_n="<< x_t_n << endl;
-    cout << "近切点:y_t_n=" << y_t_n << endl;
-    cout << "远切点:x_t_f=" << x_t_f << endl;
-    cout << "远切点:y_t_f=" << y_t_f << endl;
-    //cout << "航向角:" << steering_angle << endl;
-    //cout << "圆心1横坐标=" << x_o_1 << endl;
-    //cout << "圆心1纵坐标=" << y_o_1 << endl;
-    //cout << "圆心2横坐标=" << x_o_2 << endl;
-    //cout << "圆心2纵坐标=" << y_o_2 << endl;
-    //cout << "平分线弧度=" << angle_3 << endl;
-    //cout << " min_rad=" << min_rad << endl;
-    //cout << " real_rad=" << real_rad << endl;
-    //   system("PAUSE");
-
-
-
-    dTpoint0=Coordinate_UnTransfer(x_t_n, y_t_n, aimGps);
-    dTpoint1 = Coordinate_UnTransfer(x_t_f, y_t_f, aimGps);
-    dTpoint2 = Coordinate_UnTransfer(x_2, y_2, aimGps);
-    dTpoint3 = Coordinate_UnTransfer(x_0, y_0, aimGps);
-    dBocheAngle = steering_angle*180/PI;
-
-    double disA = GetDistance(aimGps,nowGps);
-
-    if(pt.y>y_t_n && x_t_f<x_2 && y_t_f>y_2&&disA<40){
-        return 1;
-    }
-    return 0;
-
-}
-
-
-double iv::decition::Compute00::min_rad_zhuanxiang(double *R_M, double *min_rad) {
-    double L_c = 4.749;//车长
-    double rad_1;
-    double rad_2;
-    double L_k = 1.931;//车宽
-    double L = 2.95;//轴距
-    double L_f =1.2 ;//前悬
-    double L_r =0.7 ;//后悬
-    double R_min =6.5 ;//最小转弯半径
-    *R_M = fabs(sqrt(R_min*R_min - (L + L_f)*(L + L_f))) - L_k*0.5;//double	R_M  ;//后轴中点的转弯半径
-    //rad_1 = atan2(sqrt(R_min*R_min - (R_M - L_k*0.5)*(R_M - L_k*0.5)), R_M - L_k*0.5);
-    //rad_2 = atan2(L + L_f, R_M + L_k*0.5);
-    *min_rad = 45 * PI / 180;// rad_1 - rad_2;
-    return 0;
-}
-
-
-double iv::decition::Compute00::qiedian_n(double x_1, double y_1, double R_M,double min_rad, double *x_2, double *y_2, double *real_rad ) {
-
-    if (x_1 > 0 && y_1 > 0)
-    {
-        *real_rad = PI*0.5 - min_rad;
-        *x_2 = R_M - R_M*cos(min_rad);
-        *y_2 = R_M*sin(min_rad) + 0.5;
-    }
-    else
-    {
-        *real_rad = PI*0.5 + min_rad;
-        *x_2 = R_M*cos(min_rad) - R_M;
-        *y_2 = R_M*sin(min_rad) + 0.5;
-    }
-    return 0;
-
-}
-
-
-double iv::decition::Compute00::liangzhixian_jiaodian(double x_1,double y_1,double x_2,double y_2,double ange1,double real_rad,double *x_3,double *y_3) {
-    double b1, b2;
-    double k1, k2;
-    if (ange1!=(PI*0.5))
-    {
-        k1 = tan(ange1);
-        b1 = y_1 - k1*x_1;
-        k2 = tan(real_rad);
-        b2 = y_2 - k2*x_2;
-        *x_3 = (b2 - b1) / (k1 - k2);
-        *y_3 = k2*(*x_3) + b2;
-    }
-    else
-    {
-        k2 = tan(real_rad);
-        b2 = y_2 - k2*x_2;
-        *x_3 = x_1;
-        *y_3 = k2*(*x_3) + b2;
-    }
-    return 0;
-}
-
-
-double iv::decition::Compute00::chuizhipingfenxian_xielv(double x_1,double y_1,double ange1,double real_rad,double min_rad,double *angle_3) {
-    double k1, k2;
-    double  angle_j;
-    k2 = tan(real_rad);
-    if (ange1 != (PI*0.5))
-    {
-        k1 = tan(ange1);
-        angle_j = atan(fabs((k2 - k1) / (1 + k2*k1)));//两直线夹角
-
-        if (x_1 > 0 && y_1 > 0)
-        {
-            *angle_3 = angle_j*0.5 - min_rad + PI;
-        }
-        else
-        {
-            *angle_3 = min_rad - angle_j*0.5;
-        }
-    }
-    else
-    {
-        angle_j = min_rad;//两直线夹角
-        if (x_1 > 0 && y_1 > 0)
-        {
-            *angle_3 = angle_j*0.5 - min_rad + PI;
-        }
-        else
-        {
-            *angle_3 = min_rad - angle_j*0.5;
-        }
-    }
-    return 0;
-}
-
-
-double iv::decition::Compute00::yuanxin(double x_2,double y_2,double x_3,double y_3,double real_rad,double angle_3,double R_M,
-                                        double *x_o_1,double *y_o_1,double *x_o_2,double *y_o_2) {
-    double b2, b3, k2, k3;
-    b2 = y_2 - tan(real_rad)*x_2;
-    b3 = y_3 - tan(angle_3)*x_3;
-    k2 = tan(real_rad);
-    k3 = tan(angle_3);
-    *x_o_1 = (sqrt(k2*k2 + 1)*R_M + b3 - b2) / (k2 - k3);
-    *y_o_1 = k3*(*x_o_1) + b3;
-
-    *x_o_2 = (b3 - b2 - (sqrt(k2*k2 + 1)*R_M)) / (k2 - k3);
-    *y_o_2 = k3*(*x_o_2) + b3;
-    return 0;
-}
-
-
-double iv::decition::Compute00::yuanxin_qiedian(double ange1,double x_o_1,double y_o_1, double x_o_2,double y_o_2,
-                                                double x_1,double y_1,double x_2,double y_2,double x_3,double y_3,double real_rad,double angle_3,double R_M,
-                                                double *x_t_n, double *y_t_n, double *x_t_f, double *y_t_f)
-{
-    double x_o, y_o;
-    double b2, b3, k1, k2, k3;
-    //double car_pos[3] = { x_1,y_1,k1 };
-    double parking_pos[2] = { x_2,y_2 };
-    //double t[4][2];
-    double p[4];
-    double  s1, s2; //切点与车起始位置的距离
-    double  min;
-    int  min_i;
-    double x_t_1, y_t_1, x_t_2, y_t_2;//圆形1的切点
-    double x_t_3, y_t_3, x_t_4, y_t_4;//圆形2的切点
-    double t[4][2];
-    k1 = tan(ange1);
-    b2 = y_2 - tan(real_rad)*x_2;
-    b3 = y_3 - tan(real_rad)*x_3;
-    k2 = tan(real_rad);//另一条直线斜率
-    k3 = tan(angle_3);//垂直平分线斜率
-    //圆心1和2切点*********************************************
-    if (x_1 > 0 && y_1 > 0)//第一象限
-    {
-        if (ange1 == (PI*0.5))
-        {
-            x_t_1 = x_1;
-            y_t_1 = y_o_1;
-            y_t_2 = (y_2 + k2 *x_o_1 + y_o_1*k2*k2 - k2*x_2) / (1 + k2*k2);
-            x_t_2 = (y_t_2 + k2*x_2 - y_2) / k2;
-
-            x_t_3 = x_1;
-            y_t_3 = y_o_2;
-            y_t_4 = (y_2 + k2 *x_o_2 + y_o_2*k2*k2 - k2*x_2) / (1 + k2*k2);
-            x_t_4 = (y_t_4 + k2*x_2 - y_2) / k2;
-
-
-        }
-        else
-        {
-            y_t_1 = (y_1 + k1 *x_o_1 + y_o_1*k1*k1 - k1*x_1) / (1 + k1*k1);
-            x_t_1 = (y_t_1 + k1*x_1 - y_1) / k1;
-            y_t_2 = (y_2 + k2 *x_o_1 + y_o_1*k2*k2 - k2*x_2) / (1 + k2*k2);
-            x_t_2 = (y_t_2 + k2*x_2 - y_2) / k2;
-
-            y_t_3 = (y_1 + k1 *x_o_2 + y_o_2*k1*k1 - k1*x_1) / (1 + k1*k1);
-            x_t_3 = (y_t_3 + k1*x_1 - y_1) / k1;
-            y_t_4 = (y_2 + k2 *x_o_2 + y_o_2*k2*k2 - k2*x_2) / (1 + k2*k2);
-            x_t_4 = (y_t_4 + k2*x_2 - y_2) / k2;
-
-        }
-    }
-    else
-    {
-        if (ange1 == 0)
-        {
-            x_t_1 = 0 - x_1;
-            y_t_1 = y_o_1;
-            y_t_2 = (y_2 + k2 *x_o_1 + y_o_1*k2*k2 - k2*x_2) / (1 + k2*k2);
-            x_t_2 = (y_t_2 + k2*x_2 - y_2) / k2;
-
-            x_t_3 = 0 - x_1;
-            y_t_3 = y_o_2;
-            y_t_4 = (y_2 + k2 *x_o_2 + y_o_2*k2*k2 - k2*x_2) / (1 + k2*k2);
-            x_t_4 = (y_t_4 + k2*x_2 - y_2) / k2;
-        }
-        else
-        {
-            y_t_1 = (y_1 + k1 *x_o_1 + y_o_1*k1*k1 - k1*x_1) / (1 + k1*k1);
-            x_t_1 = (y_t_1 + k1*x_1 - y_1) / k1;
-            y_t_2 = (y_2 + k2 *x_o_1 + y_o_1*k2*k2 - k2*x_2) / (1 + k2*k2);
-            x_t_2 = (y_t_2 + k2*x_2 - y_2) / k2;
-
-            y_t_3 = (y_1 + k1 *x_o_2 + y_o_2*k1*k1 - k1*x_1) / (1 + k1*k1);
-            x_t_3 = (y_t_3 + k1*x_1 - y_1) / k1;
-            y_t_4 = (y_2 + k2 *x_o_2 + y_o_2*k2*k2 - k2*x_2) / (1 + k2*k2);
-            x_t_4 = (y_t_4 + k2*x_2 - y_2) / k2;
-
-        }
-
-    }
-
-    //圆心1和2切点*********************************************
-
-    t[0][0] = x_t_1;
-    t[0][1] = y_t_1;
-    t[1][0] = x_t_2;
-    t[1][1] = y_t_2;
-    t[2][0] = x_t_3;
-    t[2][1] = y_t_3;
-    t[3][0] = x_t_4;
-    t[3][1] = y_t_4;
-    for (int i = 0; i < 4; i++)
-    {
-
-        p[i] = (t[i][0] - parking_pos[0])*(t[i][0] - parking_pos[0]) + (t[i][1] - parking_pos[1])*(t[i][1] - parking_pos[1]);
-
-    }
-    min = p[0];
-    min_i = 0;
-    for (int i = 1; i < 4; i++)
-    {
-
-        if (p[i] < min)
-        {
-            min = p[i]; min_i = i;
-        }
-    }
-    if (min_i < 2)
-    {
-        x_o = x_o_1;
-        y_o = y_o_1;
-        s1 = (x_t_1 - x_1)*(x_t_1 - x_1) + (y_t_1 - y_1)*(y_t_1 - y_1);
-        s2 = (x_t_2 - x_1)*(x_t_2 - x_1) + (y_t_2 - y_1)*(y_t_2 - y_1);
-        if (s1 < s2)
-        {
-            *x_t_n = x_t_1;
-            *y_t_n = y_t_1;
-            *x_t_f = x_t_2;
-            *y_t_f = y_t_2;
-        }
-        else
-        {
-            *x_t_n = x_t_2;
-            *y_t_n = y_t_2;
-            *x_t_f = x_t_1;
-            *y_t_f = y_t_1;
-
-        }
-    }
-    else
-    {
-        x_o = x_o_2;
-        y_o = y_o_2;
-        s1 = (x_t_3 - x_1)*(x_t_3 - x_1) + (y_t_3 - y_1)*(y_t_3 - y_1);
-        s2 = (x_t_4 - x_1)*(x_t_4 - x_1) + (y_t_4 - y_1)*(y_t_4 - y_1);
-
-        if (s1 < s2)
-        {
-
-            *x_t_n = x_t_3;
-            *y_t_n = y_t_3;
-            *x_t_f = x_t_4;
-            *y_t_f = y_t_4;
-        }
-        else
-        {
-            *x_t_n = x_t_4;
-            *y_t_n = y_t_4;
-            *x_t_f = x_t_3;
-            *y_t_f = y_t_3;
-        }
-
-
-
-    }
-
-    return 0;
-
-}
-
-
-int iv::decition::Compute00::getNoAngleNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap)
-{
-    int index = -1;
-    int startIndex = 0;     // startIndex = 0 则每一次都是遍历整条地图路线
-    int endIndex = gpsMap.size() - 1;
-    float minDis=20;
-
-    for (int j = startIndex; j < endIndex; j++)
-    {
-        int i = (j + gpsMap.size()) % gpsMap.size();
-        double tmpdis = GetDistance(rp, (*gpsMap[i]));
-
-        if (tmpdis < minDis)
-        {
-            index = i;
-            minDis=tmpdis;
-        }
-    }
-    return index;
-}
-
-
-double iv::decition::Compute00::getObsSpeedByFrenet(Point2D obsPoint, double realSecSpeed,const vector<Point2D>& gpsTrace, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps) {
-    double obsSpeed = 0 - realSecSpeed;
-    double minDis = iv::MaxValue;
-    FrenetPoint esr_obs_F_point;
-    for (int i = 0; i < 64; i++)
-        if ((ServiceCarStatus.obs_radar[i].nomal_y) != 0 && ServiceCarStatus.obs_radar[i].valid)
-        {
-            double xxx = ServiceCarStatus.obs_radar[i].nomal_x + Esr_Offset;
-            double yyy = ServiceCarStatus.obs_radar[i].nomal_y + Esr_Y_Offset;
-
-            if (abs(xxx - obsPoint.x) < 4 && abs(yyy - obsPoint.y) < 2)
-            {
-                double tmpDis = sqrt((xxx - obsPoint.x) * (xxx - obsPoint.x) + (yyy - obsPoint.y) * (yyy - obsPoint.y));
-                if (tmpDis < minDis)
-                {
-                    minDis = tmpDis;
-//                    esr_obs_F_point = iv::decition::FrenetPlanner::XY2Frenet(xxx, yyy, gpsTrace);
-                    esr_obs_F_point = iv::decition::FrenetPlanner::getFrenetfromXY(xxx, yyy, gpsTrace,gpsMap,pathpoint,nowGps);
-//                    obsSpeed = ServiceCarStatus.obs_radar[i].speed_y;
-                    double speedx=ServiceCarStatus.obs_radar[i].speed_x;  //障碍物相对于车辆x轴的速度
-                    double speedy=ServiceCarStatus.obs_radar[i].speed_y;  //障碍物相对于车辆y轴的速度
-                    double speed_combine = sqrt(speedx*speedx+speedy*speedy);    //将x、y轴两个方向的速度求矢量和
-                    //障碍物的速度方向与道路方向的夹角。用于将速度分解到s方向和d方向。
-                    //所谓道路方向是指,道路上离障碍物的最近的点沿道路弧线的切线方向。
-                    double Etheta = esr_obs_F_point.tangent_Ang - atan2(speedy,speedx);
-
-                    obsSpeed = speed_combine*cos(Etheta);  //由speed_combine分解的s轴方向上的速度
-                }
-            }
-        }
-
-    return obsSpeed;
-}
-
-
-int iv::decition::Compute00::getEsrIndexByFrenet(const std::vector<Point2D>& gpsTrace, FrenetPoint &esrObsPoint, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps){
-    double minDistance = numeric_limits<double>::max();
-    int minDis_index=-1;
-
-    for(int i=0; i<64; ++i){
-        if ((ServiceCarStatus.obs_radar[i].nomal_y) != 0 && (ServiceCarStatus.obs_radar[i].valid)){
-            //毫米波在车头,故要加上毫米波与惯导的相对距离。(xxx,yyy)才是障碍物在 车辆坐标系下的坐标。
-            double xxx = ServiceCarStatus.obs_radar[i].nomal_x + Esr_Offset;
-            double yyy = ServiceCarStatus.obs_radar[i].nomal_y+ Esr_Y_Offset;
-
-            //将毫米波障碍物位置转换到frenet坐标系下
-//            esrObsPoint = iv::decition::FrenetPlanner::XY2Frenet(xxx,yyy,gpsTrace);
-            esrObsPoint = iv::decition::FrenetPlanner::getFrenetfromXY(xxx,yyy,gpsTrace,gpsMap,pathpoint,nowGps);
-
-            //如果障碍物与道路的横向距离d<=3.0*Veh_Width / 4.0,则认为道路上有障碍物。
-            //s则可理解为障碍物距离。为障碍物与车辆沿着道路方向的距离,而不是空间上的x或y坐标或者直线距离。
-            //minDistance、minDis_index用来统计最近的障碍物信息。
-            if(abs(esrObsPoint.d)<=(3.0*Veh_Width / 4.0+DecideGps00().xiuzhengCs)){
-                if(esrObsPoint.s<minDistance){
-                    minDistance = esrObsPoint.s;
-                    minDis_index = i;
-                }
-            }
-        }
-    }
-    return minDis_index;
-}
-
-
-
-
-std::vector<std::vector<iv::GPSData>> gmapsL;
-std::vector<std::vector<iv::GPSData>> gmapsR;
+#include <decition/compute_00.h>
+#include <decition/decide_gps_00.h>
+#include <decition/gps_distance.h>
+#include <decition/decition_type.h>
+#include <decition/transfer.h>
+#include <common/constants.h>
+#include <math.h>
+#include <iostream>
+#include <fstream>
+//#include <control/radar_exam.h>
+#include <control/can.h>
+using namespace std;
+
+#define PI (3.1415926535897932384626433832795)
+
+iv::decition::Compute00::Compute00() {
+
+}
+iv::decition::Compute00::~Compute00() {
+
+}
+
+
+double iv::decition::Compute00::angleLimit = 700;
+double iv::decition::Compute00::lastEA = 0;
+double iv::decition::Compute00::lastEP = 0;
+double iv::decition::Compute00::decision_Angle = 0;
+double iv::decition::Compute00::lastAng = 0;
+int iv::decition::Compute00::lastEsrID = -1;
+int  iv::decition::Compute00::lastEsrCount = 0;
+int iv::decition::Compute00::lastEsrIDAvoid = -1;
+int  iv::decition::Compute00::lastEsrCountAvoid = 0;
+
+iv::GPS_INS  iv::decition::Compute00::nearTpoint;
+iv::GPS_INS  iv::decition::Compute00::farTpoint;
+double  iv::decition::Compute00::bocheAngle;
+
+
+
+iv::GPS_INS  iv::decition::Compute00::dTpoint0;
+iv::GPS_INS  iv::decition::Compute00::dTpoint1;
+iv::GPS_INS  iv::decition::Compute00::dTpoint2;
+iv::GPS_INS  iv::decition::Compute00::dTpoint3;
+double  iv::decition::Compute00::dBocheAngle;
+
+
+std::vector<int> lastEsrIdVector;
+std::vector<int> lastEsrCountVector;
+
+int iv::decition::Compute00::getNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap, int lastIndex, double mindis, double maxAngle)
+{
+    int index = -1;
+    //	DecideGps00().minDis = iv::MaxValue;
+    DecideGps00().minDis = 20;
+    DecideGps00().maxAngle = iv::MaxValue;
+
+    int startIndex = max((lastIndex - 500), 0);     // startIndex = 0 则每一次都是遍历整条地图路线
+    int endIndex = min((gpsMap.size() - 1), (size_t)(lastIndex + 2000 + 100 * (gpsMissCount + 1)));
+
+    for (int j = startIndex; j < endIndex; j++)
+    {
+        int i = (j + gpsMap.size()) % gpsMap.size();
+        double tmpdis = GetDistance(rp, (*gpsMap[i]));
+
+        if (tmpdis < DecideGps00().minDis && (abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle) < 80
+                                              || abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle - 360) < 80
+                                              || abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle + 360) < 80)
+                )
+        {
+            index = i;
+            DecideGps00().minDis = tmpdis;
+            DecideGps00().maxAngle = min(abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle), abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle - 360));
+            DecideGps00().maxAngle = min(DecideGps00().maxAngle, abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle + 360));
+        }
+    }
+    /*if (index == -1) {
+        index = 0;
+    }*/
+    return index;
+}
+
+
+//首次找点
+
+int iv::decition::Compute00::getFirstNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap, int lastIndex, double mindis, double maxAngle)
+{
+    int index = -1;
+    //	DecideGps00().minDis = iv::MaxValue;
+    DecideGps00().minDis = 40;
+    DecideGps00().maxAngle = iv::MaxValue;
+
+    int startIndex = 0;     // startIndex = 0 则每一次都是遍历整条地图路线
+    int endIndex = gpsMap.size() - 1;
+
+    for (int j = startIndex; j < endIndex; j++)
+    {
+        int i = (j + gpsMap.size()) % gpsMap.size();
+        double tmpdis = GetDistance(rp, (*gpsMap[i]));
+
+        if (tmpdis < DecideGps00().minDis && (abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle) < 80
+                                              || abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle - 360) < 80
+                                              || abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle + 360) < 80)
+                )
+        {
+            index = i;
+            DecideGps00().minDis = tmpdis;
+            DecideGps00().maxAngle = min(abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle), abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle - 360));
+            DecideGps00().maxAngle = min(DecideGps00().maxAngle, abs(rp.ins_heading_angle - (*gpsMap[i]).ins_heading_angle + 360));
+        }
+    }
+    /*if (index == -1) {
+        index = 0;
+    }*/
+    return index;
+}
+
+
+
+
+
+double iv::decition::Compute00::getAveDef(std::vector<Point2D> farTrace)
+{
+    double sum_x = 0;
+    double sum_y = 0;
+
+    for (int i = 0; i < min(5, (int)farTrace.size()); i++)
+    {
+        sum_x += farTrace[i].x;
+        sum_y += abs(farTrace[i].y);
+    }
+    double average_y = sum_y / min(5, (int)farTrace.size());
+    double average_x = sum_x / min(5, (int)farTrace.size());
+
+
+    return atan(average_x / average_y) / PI * 180;
+}
+
+
+
+double iv::decition::Compute00::getAvoidAveDef(std::vector<Point2D> farTrace, double avoidX)
+{
+    double sum_x = 0;
+    double sum_y = 0;
+
+    for (int i = 0; i < min(5, (int)farTrace.size()); i++)
+    {
+        sum_x += farTrace[i].x;
+        sum_y += abs(farTrace[i].y);
+    }
+    double average_y = sum_y / min(5, (int)farTrace.size());
+    double average_x = sum_x / min(5, (int)farTrace.size());
+
+
+    return atan(average_x + avoidX / average_y) / PI * 180;
+}
+
+
+
+
+
+
+double iv::decition::Compute00::getDecideAngle(std::vector<Point2D>  gpsTrace, double realSpeed) {
+
+    double ang = 0;
+    double EPos = 0, EAng = 0;
+
+    //   double KEang = 14, KEPos = 10, DEang = 3, DEPos = 1;  // double KEang = 14, KEPos = 10, DEang = 10, DEPos = 10;
+    double KEang = 14, KEPos = 10, DEang = 0, DEPos = 0;
+
+    if(transferPieriod&& !transferPieriod2){
+        DEang = 200;
+        DEPos = 150;
+    }
+
+    //   double PreviewDistance = max(6.0, realSpeed / 3.6 * 1.8);//预瞄距离
+
+    double PreviewDistance;//预瞄距离
+    realSpeed > 40 ? PreviewDistance = max(6.0, realSpeed *0.6) : PreviewDistance = max(6.0, realSpeed *0.5);
+    if(changeRoad ||transferPieriod){
+        PreviewDistance=PreviewDistance+avoidX;
+    }
+    if(realSpeed <15){
+        PreviewDistance = max(4.0, realSpeed *0.4) ;
+    }
+
+    if (gpsTrace[0].v1 == 1)
+    {
+        KEang = 14; KEPos = 10;
+    }
+    else if (gpsTrace[0].v1 == 2 || gpsTrace[0].v1 == 3)
+    {
+        KEang = 14; KEPos = 10;
+    }
+    else if (gpsTrace[0].v1 == 4 || gpsTrace[0].v1 == 5)
+    {
+        KEang = 14; KEPos = 10;
+    }
+    else if (gpsTrace[0].v1 == 7 && (gpsTrace[0].v2 == 23 || gpsTrace[0].v2 == 24))
+    {
+        KEang = 18; KEPos = 50; PreviewDistance = 3;
+    }
+    else if (gpsTrace[0].v1 == 7)
+    {
+        KEang = 20; KEPos = 50; PreviewDistance = 4;
+    }
+
+
+    if (realSpeed > 40)	KEang = 10; KEPos = 8;
+    if (realSpeed > 50) KEang = 5;
+
+    double sumdis = 0;
+    int gpsIndex = 0;
+    std::vector<Point2D> farTrace;
+
+
+
+
+
+
+    for (int i = 1; i < gpsTrace.size() - 1; i++)
+    {
+        sumdis += GetDistance(gpsTrace[i - 1], gpsTrace[i]);
+        if (sumdis > PreviewDistance)
+        {
+            gpsIndex = i;
+            break;
+        }
+    }
+
+
+
+
+    EPos = gpsTrace[gpsIndex].x;
+
+    for (unsigned int i = max(0, gpsIndex - 3); i < min((size_t)(gpsIndex + 3), gpsTrace.size()); i++) {
+        farTrace.push_back(gpsTrace[gpsIndex]);
+    }
+    if (farTrace.size() == 0) {
+        EAng = 0;
+    }
+    else {
+        EAng = getAveDef(farTrace);
+    }
+
+    ang = KEang * EAng + KEPos * EPos + DEang * (EAng - lastEA) + DEPos * (EPos - lastEP);
+
+    lastEA = EAng;
+    lastEP = EPos;
+
+    if (ang > angleLimit) {
+        ang = angleLimit;
+    }
+    else if (ang < -angleLimit) {
+        ang = -angleLimit;
+    }
+    if (lastAng != iv::MaxValue) {
+        ang = 0.2 * lastAng + 0.8 * ang;
+        //ODS("lastAng:%d\n", lastAng);
+    }
+    lastAng = ang;
+    return ang;
+}
+
+
+
+
+int  iv::decition::Compute00::getSpeedPointIndex(std::vector<Point2D> gpsTrace, double realSpeed)
+{
+    int index = 1;
+    double sumdis = 0;
+    while (index < gpsTrace.size() && sumdis < realSpeed)
+        sumdis += GetDistance(gpsTrace[index - 1], gpsTrace[index++]);
+
+    if (index == gpsTrace.size())
+        return index - 1;
+
+    if (abs(sumdis - realSpeed) > abs(sumdis - GetDistance(gpsTrace[index - 1], gpsTrace[index]) - realSpeed))
+        index--;
+    return index;
+}
+
+iv::Point2D iv::decition::Compute00::getLidarObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
+
+    iv::Point2D obsPoint(-1, -1);
+    vector<Point2D> gpsTraceLeft;
+    vector<Point2D> gpsTraceRight;
+    for (int j = 0; j < gpsTrace.size(); j++)
+    {
+        double sumx1 = 0, sumy1 = 0, count1 = 0;
+        double sumx2 = 0, sumy2 = 0, count2 = 0;
+        for (int k = max(0, j - 4); k <= j; k++)
+        {
+            count1 = count1 + 1;
+            sumx1 += gpsTrace[k].x;
+            sumy1 += gpsTrace[k].y;
+        }
+        for (unsigned int k = j; k <= min(gpsTrace.size() - 1, (size_t)(j + 4)); k++)
+        {
+            count2 = count2 + 1;
+            sumx2 += gpsTrace[k].x;
+            sumy2 += gpsTrace[k].y;
+        }
+        sumx1 /= count1; sumy1 /= count1;
+        sumx2 /= count2; sumy2 /= count2;
+
+        double anglevalue = atan2(sumy2 - sumy1, sumx2 - sumx1);
+
+        double carFrontx = gpsTrace[j].x;// -Form1.CarRear * Math.Cos(anglevalue);
+        double carFronty = gpsTrace[j].y;// -Form1.CarRear * Math.Sin(anglevalue);
+
+        Point2D ptLeft(carFrontx + Veh_Width / 2 * cos(anglevalue + PI / 2),
+                       carFronty + Veh_Width / 2 * sin(anglevalue + PI / 2));
+
+        Point2D ptRight(carFrontx + Veh_Width / 2 * cos(anglevalue - PI / 2),
+                        carFronty + Veh_Width / 2 * sin(anglevalue - PI / 2));
+
+        gpsTraceLeft.push_back(ptLeft);
+        gpsTraceRight.push_back(ptRight);
+
+    }
+
+
+    bool isRemove = false;
+
+    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
+    {
+
+        if (!isRemove && gpsTrace[j].y>2.5 )
+        {
+            int count = 0;
+
+            for (double length = 0; length <= Veh_Width; length += 0.4)
+            {
+                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
+                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
+
+                //				int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;  //+(ptx / abs(ptx))) / 2左右多出一半的车宽(1米)
+                //				int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
+                int dx = (ptx + gridwide*(double)centerx)/gridwide;
+                int dy = (pty + gridwide*(double)centery)/gridwide;
+
+                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
+                {
+                    //					if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
+                    if (lidarGridPtr[dx * (iv::gry) + dy].ob != 0)
+                    {
+                        count++; obsPoint.x = ptx; obsPoint.y = pty;
+                    }
+                }
+            }
+
+            j++;
+
+            for (double length = 0; length <= Veh_Width; length += 0.4)
+            {
+                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
+                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
+
+                //				int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;
+                //				int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
+                int dx = (ptx + gridwide*(double)centerx)/gridwide;
+                int dy = (pty + gridwide*(double)centery)/gridwide;
+
+                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
+                {
+                    //					if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
+                    if (lidarGridPtr[dx * (iv::gry) + dy].ob != 0)
+                    {
+                        count++; obsPoint.x = ptx; obsPoint.y = pty;
+                    }
+                }
+            }
+
+            if (count >= 2)
+            {
+                obsPoint.x = gpsTrace[j].x;
+                obsPoint.y = gpsTrace[j].y;
+
+                isRemove = true;
+                //		DecideGps00().lidarDistance = obsPoint.y;
+                return obsPoint;
+            }
+        }
+    }
+    //	DecideGps00().lidarDistance = obsPoint.y;
+    return obsPoint;
+}
+
+//1220
+iv::Point2D iv::decition::Compute00::getLidarRearObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
+
+    iv::Point2D obsPoint(-1, -1);
+    vector<Point2D> gpsTraceLeft;
+    vector<Point2D> gpsTraceRight;
+    for (int j = 0; j < gpsTrace.size(); j++)
+    {
+        double sumx1 = 0, sumy1 = 0, count1 = 0;
+        double sumx2 = 0, sumy2 = 0, count2 = 0;
+        for (int k = max(0, j - 4); k <= j; k++)
+        {
+            count1 = count1 + 1;
+            sumx1 += gpsTrace[k].x;
+            sumy1 += gpsTrace[k].y;
+        }
+        for (unsigned int k = j; k <= min(gpsTrace.size() - 1, (size_t)(j + 4)); k++)
+        {
+            count2 = count2 + 1;
+            sumx2 += gpsTrace[k].x;
+            sumy2 += gpsTrace[k].y;
+        }
+        sumx1 /= count1; sumy1 /= count1;
+        sumx2 /= count2; sumy2 /= count2;
+
+        double anglevalue = atan2(sumy2 - sumy1, sumx2 - sumx1);
+
+        double carFrontx = gpsTrace[j].x;// -Form1.CarRear * Math.Cos(anglevalue);
+        double carFronty = gpsTrace[j].y;// -Form1.CarRear * Math.Sin(anglevalue);
+
+        Point2D ptLeft(carFrontx + (Veh_Width-0.3) / 2 * cos(anglevalue + PI / 2),
+                       carFronty + (Veh_Width-0.3) / 2 * sin(anglevalue + PI / 2));
+
+        Point2D ptRight(carFrontx + (Veh_Width-0.3) / 2 * cos(anglevalue - PI / 2),
+                        carFronty + (Veh_Width-0.3) / 2 * sin(anglevalue - PI / 2));
+
+        gpsTraceLeft.push_back(ptLeft);
+        gpsTraceRight.push_back(ptRight);
+
+    }
+
+
+    bool isRemove = false;
+
+    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
+    {
+
+        if (!isRemove && gpsTrace[j].y<-1.0 )
+        {
+            int count = 0;
+
+            for (double length = 0; length <= Veh_Width; length += 0.4)
+            {
+                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
+                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
+
+                //				int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;  //+(ptx / abs(ptx))) / 2左右多出一半的车宽(1米)
+                //				int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
+                int dx = (ptx + gridwide*(double)centerx)/gridwide;
+
+                dx=grx-dx;//1227
+
+                int dy = (pty + gridwide*(double)centery)/gridwide;
+
+                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
+                {
+                    //					if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
+                    if (lidarGridPtr[dx * (iv::gry) + dy].ob != 0)
+                    {
+                        count++; obsPoint.x = ptx; obsPoint.y = pty;
+                    }
+                }
+            }
+
+            j++;
+
+            for (double length = 0; length <= Veh_Width; length += 0.4)
+            {
+                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
+                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
+
+                //				int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;
+                //				int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
+                int dx = (ptx + gridwide*(double)centerx)/gridwide;
+
+                dx=grx-dx;//1227
+                int dy = (pty + gridwide*(double)centery)/gridwide;
+
+                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
+                {
+                    //					if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
+                    if (lidarGridPtr[dx * (iv::gry) + dy].ob != 0)
+                    {
+                        count++; obsPoint.x = ptx; obsPoint.y = pty;
+                    }
+                }
+            }
+
+            if (count >= 2)
+            {
+                obsPoint.x = gpsTrace[j].x;
+                obsPoint.y = gpsTrace[j].y;
+
+                isRemove = true;
+                //		DecideGps00().lidarDistance = obsPoint.y;
+                return obsPoint;
+            }
+        }
+    }
+    //	DecideGps00().lidarDistance = obsPoint.y;
+    return obsPoint;
+}
+
+
+iv::Point2D iv::decition::Compute00::getLidarObsPointAvoid(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
+
+    iv::Point2D obsPoint(-1, -1);
+    vector<Point2D> gpsTraceLeft;
+    vector<Point2D> gpsTraceRight;
+    for (int j = 0; j < gpsTrace.size(); j++)
+    {
+        double sumx1 = 0, sumy1 = 0, count1 = 0;
+        double sumx2 = 0, sumy2 = 0, count2 = 0;
+        for (int k = max(0, j - 4); k <= j; k++)
+        {
+            count1 = count1 + 1;
+            sumx1 += gpsTrace[k].x;
+            sumy1 += gpsTrace[k].y;
+        }
+        for (unsigned int k = j; k <= min(gpsTrace.size() - 1, (size_t)(j + 4)); k++)
+        {
+            count2 = count2 + 1;
+            sumx2 += gpsTrace[k].x;
+            sumy2 += gpsTrace[k].y;
+        }
+        sumx1 /= count1; sumy1 /= count1;
+        sumx2 /= count2; sumy2 /= count2;
+
+        double anglevalue = atan2(sumy2 - sumy1, sumx2 - sumx1);
+
+        double carFrontx = gpsTrace[j].x;// -Form1.CarRear * Math.Cos(anglevalue);
+        double carFronty = gpsTrace[j].y;// -Form1.CarRear * Math.Sin(anglevalue);
+
+        //1127 fanwei xiuzheng
+        float buchang=0;
+        Point2D ptLeft(carFrontx + (Veh_Width+(buchang)*2) / 2 * cos(anglevalue + PI / 2),
+                       carFronty +  (Veh_Width+(buchang)*2) / 2 * sin(anglevalue + PI / 2));
+
+        Point2D ptRight(carFrontx +  (Veh_Width+(buchang)*2) / 2 * cos(anglevalue - PI / 2),
+                        carFronty +  (Veh_Width+(buchang)*2) / 2 * sin(anglevalue - PI / 2));
+
+        gpsTraceLeft.push_back(ptLeft);
+        gpsTraceRight.push_back(ptRight);
+
+    }
+
+
+    bool isRemove = false;
+
+    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
+    {
+
+        if (!isRemove && gpsTrace[j].y>2.5 && gpsTraceLeft[j].y>2.5 && gpsTraceRight[j].y>2.5)
+        {
+            int count = 0;
+
+            for (double length = 0; length <= Veh_Width; length += 0.4)
+            {
+                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
+                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
+
+                int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;  //*2左右多出一半的车宽(1米)
+                int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
+
+                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
+                {
+                    if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
+                    {
+                        count++; obsPoint.x = ptx; obsPoint.y = pty;
+                    }
+                }
+            }
+
+            j++;
+
+            for (double length = 0; length <= Veh_Width; length += 0.4)
+            {
+                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / Veh_Width * length;
+                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / Veh_Width * length;
+
+                int dx = (int)(ptx / gridwide * 2 + (ptx / abs(ptx))) / 2 + centerx;
+                int dy = (int)(pty / gridwide * 2 + (pty / abs(pty))) / 2 + centery;
+
+                if (dx >= 0 && dx <grx && dy >= 0 && dy < gry)
+                {
+                    if (lidarGridPtr[dx * (iv::gry + 1) + dy].ob != 0)
+                    {
+                        count++; obsPoint.x = ptx; obsPoint.y = pty;
+                    }
+                }
+            }
+
+            if (count >= 2)
+            {
+                obsPoint.x = gpsTrace[j].x;
+                obsPoint.y = gpsTrace[j].y;
+
+                isRemove = true;
+                DecideGps00().lidarDistanceAvoid = obsPoint.y;
+                return obsPoint;
+            }
+        }
+    }
+    //	DecideGps00().lidarDistanceAvoid = obsPoint.y;
+
+    return obsPoint;
+}
+
+
+
+
+//int  iv::decition::Compute00::getEsrIndex(std::vector<Point2D> gpsTrace, std::vector<ObstacleBasic> esrRadars) {
+//	bool isRemove = false;
+//
+//	for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
+//	{
+//
+//		for (int i = 0; i < esrRadars.size(); i++)
+//			if ((esrRadars[i].nomal_y) != 0)
+//			{
+//				double xxx = esrRadars[i].nomal_x + Esr_Offset;
+//				double yyy = esrRadars[i].nomal_y;
+//
+//				if (abs(xxx - gpsTrace[j].x) <= 3.0*Veh_Width / 4.0 && abs(yyy - (gpsTrace[j].y)) <= 1)
+//				{
+//
+//					if (lastEsrID == (esrRadars[i]).esr_ID)
+//					{
+//						lastEsrCount++;
+//					}
+//					else
+//					{
+//						lastEsrCount = 0;
+//					}
+//
+//					if (lastEsrCount >= 3)
+//					{
+//						return i;
+//					}
+//
+//					lastEsrID = (esrRadars[i]).esr_ID;
+//				}
+//			}
+//	}
+//	return -1;
+//}
+
+
+
+
+int  iv::decition::Compute00::getEsrIndex(std::vector<Point2D> gpsTrace,int roadNum,int *esrPathpoint) {
+    bool isRemove = false;
+
+    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
+    {
+
+        for (int i = 0; i < 64; i++)
+            if ((ServiceCarStatus.obs_radar[i].nomal_y) != 0 && (ServiceCarStatus.obs_radar[i].valid))
+            {
+                double xxx = ServiceCarStatus.obs_radar[i].nomal_x + Esr_Offset;
+                double yyy = ServiceCarStatus.obs_radar[i].nomal_y+ Esr_Y_Offset;
+
+                /*ODS("\nESR毫米波检测物体X距离:%f\n", xxx);
+                ODS("\nESR毫米波检测物体Y距离:%f\n", yyy);*/
+
+//优化
+//                if(sqrt((xxx - gpsTrace[j].x)*(xxx - gpsTrace[j].x) + (yyy - gpsTrace[j].y)*(yyy - gpsTrace[j].y)) < (1.0*Veh_Width / 2.0+DecideGps00().xiuzhengCs)){
+//                    *esrPathpoint = j;
+//                    return i;
+//                }
+
+
+                if (abs(xxx - gpsTrace[j].x) <= (3.0*Veh_Width / 4.0+DecideGps00().xiuzhengCs) && abs(yyy - (gpsTrace[j].y)) <= 1)
+                {
+
+                    if (lastEsrID == i)
+                    {
+                        lastEsrCount++;
+                    }
+                    else
+                    {
+                        lastEsrCount = 0;
+                    }
+
+                    if(yyy>50 ){
+                        if (lastEsrCount >=200)
+                        {
+                            return i;
+                        }
+                    }
+                    else if (lastEsrCount >= 1)
+                    {
+                        return i;
+                    }
+
+                    lastEsrID = i;
+                }
+            }
+    }
+    return -1;
+}
+
+//int  iv::decition::Compute00::getEsrIndex(std::vector<Point2D> gpsTrace,int roadNum) {
+//    bool isRemove = false;
+
+//    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
+//    {
+
+//        for (int i = 0; i < 64; i++)
+//            if ((examed_obs_radar[i].nomal_y) != 0 && (examed_obs_radar[i].valid))
+//            {
+//                double xxx = examed_obs_radar[i].nomal_x + Esr_Offset;
+//                double yyy = examed_obs_radar[i].nomal_y+ Esr_Y_Offset;
+
+//                /*ODS("\nESR毫米波检测物体X距离:%f\n", xxx);
+//                ODS("\nESR毫米波检测物体Y距离:%f\n", yyy);*/
+
+
+//                if (abs(xxx - gpsTrace[j].x) <= 3.0*Veh_Width / 4.0 && abs(yyy - (gpsTrace[j].y)) <= 1)
+//                {
+
+//                    if (lastEsrID == i)
+//                    {
+//                        lastEsrCount++;
+//                    }
+//                    else
+//                    {
+//                        lastEsrCount = 0;
+//                    }
+
+//                    if(yyy>50 ){
+//                        if (lastEsrCount >=200)
+//                        {
+//                            return i;
+//                        }
+//                    }
+//                    else if (lastEsrCount >= 3)
+//                    {
+//                        return i;
+//                    }
+
+//                    lastEsrID = i;
+//                }
+//            }
+//    }
+//    return -1;
+//}
+
+
+
+int  iv::decition::Compute00::getEsrIndexAvoid(std::vector<Point2D> gpsTrace) {
+    bool isRemove = false;
+
+    for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
+    {
+
+        for (int i = 0; i < 64; i++)
+            if ((ServiceCarStatus.obs_radar[i].nomal_y) != 0 && (ServiceCarStatus.obs_radar[i].valid))
+            {
+                double xxx = ServiceCarStatus.obs_radar[i].nomal_x + Esr_Offset;
+                double yyy = ServiceCarStatus.obs_radar[i].nomal_y;
+
+                if (abs(xxx - gpsTrace[j].x) <= 3.0*Veh_Width / 4.0 && abs(yyy - (gpsTrace[j].y)) <= 1)
+                {
+
+                    if (lastEsrIDAvoid == i)
+                    {
+                        lastEsrCountAvoid++;
+                    }
+                    else
+                    {
+                        lastEsrCountAvoid = 0;
+                    }
+
+                    if (lastEsrCountAvoid >= 6)
+                    {
+                        return i;
+                    }
+
+                    lastEsrIDAvoid = i;
+                }
+            }
+    }
+    return -1;
+}
+
+
+
+
+
+
+
+//double iv::decition::Compute00::getObsSpeed(Point2D obsPoint, std::vector<ObstacleBasic> esrRadars,double realSecSpeed) {
+//	double obsSpeed = 0 - realSecSpeed;
+//	double minDis = iv::MaxValue;
+//	for (int i = 0; i < esrRadars.size(); i++)
+//		if ((esrRadars[i].nomal_y) != 0)
+//		{
+//			double xxx = esrRadars[i].nomal_x + Esr_Offset;
+//			double yyy = esrRadars[i].nomal_y;
+//
+//			if (abs(xxx - obsPoint.x) < 4 && abs(yyy - obsPoint.y) < 2)
+//			{
+//				double tmpDis =sqrt((xxx - obsPoint.x) * (xxx - obsPoint.x) + (yyy - obsPoint.y) * (yyy - obsPoint.y));
+//				if (tmpDis < minDis)
+//				{
+//					minDis = tmpDis;
+//					obsSpeed = esrRadars[i].speed_y;
+//				}
+//			}
+//		}
+//
+//	return obsSpeed;
+//
+//
+//}
+
+
+
+
+double iv::decition::Compute00::getObsSpeed(Point2D obsPoint, double realSecSpeed) {
+    double obsSpeed = 0 - realSecSpeed;
+    double minDis = iv::MaxValue;
+    for (int i = 0; i < 64; i++)
+        if ((ServiceCarStatus.obs_radar[i].nomal_y) != 0 && ServiceCarStatus.obs_radar[i].valid)
+        {
+            double xxx = ServiceCarStatus.obs_radar[i].nomal_x + Esr_Offset;
+            double yyy = ServiceCarStatus.obs_radar[i].nomal_y + Esr_Y_Offset;
+
+            if (abs(xxx - obsPoint.x) < 4 && abs(yyy - obsPoint.y) < 2)
+            {
+                double tmpDis = sqrt((xxx - obsPoint.x) * (xxx - obsPoint.x) + (yyy - obsPoint.y) * (yyy - obsPoint.y));
+                if (tmpDis < minDis)
+                {
+                    minDis = tmpDis;
+                    obsSpeed = ServiceCarStatus.obs_radar[i].speed_y;
+                }
+            }
+        }
+
+    return obsSpeed;
+}
+
+
+
+
+double iv::decition::Compute00::getDecideAvoidAngle(std::vector<Point2D>  gpsTrace, double realSpeed, float avoidX) {
+
+    double ang = 0;
+    double EPos = 0, EAng = 0;
+
+    double KEang = 14, KEPos = 10, DEang = 0, DEPos = 0;
+
+    double PreviewDistance = max(6.0, realSpeed / 3.6 * 1.8);//预瞄距离
+
+
+    if (gpsTrace[0].v1 == 1)
+    {
+        KEang = 10; KEPos = 8;
+        if (realSpeed > 60) KEang = 5;
+    }
+    else if (gpsTrace[0].v1 == 2 || gpsTrace[0].v1 == 3)
+    {
+        KEang = 14; KEPos = 10;
+    }
+    else if (gpsTrace[0].v1 == 4 || gpsTrace[0].v1 == 5)
+    {
+        KEang = 14; KEPos = 10;
+    }
+    else if (gpsTrace[0].v1 == 7 && (gpsTrace[0].v2 == 23 || gpsTrace[0].v2 == 24))
+    {
+        KEang = 18; KEPos = 50; PreviewDistance = 3;
+    }
+    else if (gpsTrace[0].v1 == 7)
+    {
+        KEang = 20; KEPos = 50; PreviewDistance = 4;
+    }
+
+
+    double sumdis = 0;
+    int gpsIndex = 0;
+    std::vector<Point2D> farTrace;
+
+
+
+
+
+
+    for (int i = 1; i < gpsTrace.size() - 1; i++)
+    {
+        sumdis += GetDistance(gpsTrace[i - 1], gpsTrace[i]);
+        if (sumdis > PreviewDistance)
+        {
+            gpsIndex = i;
+            break;
+        }
+    }
+
+    if ((DecideGps00().readyParkMode) && (gpsIndex + 10>DecideGps00().gpsLineParkIndex))
+    {
+        gpsIndex = DecideGps00().gpsLineParkIndex;
+    }
+
+
+
+    EPos = gpsTrace[gpsIndex].x + avoidX;
+
+    for (unsigned int i = max(0, gpsIndex - 3); i < min((size_t)(gpsIndex + 3), gpsTrace.size()); i++) {
+        farTrace.push_back(gpsTrace[gpsIndex]);
+    }
+    if (farTrace.size() == 0) {
+        EAng = 0;
+    }
+    else {
+        EAng = getAvoidAveDef(farTrace, avoidX);
+    }
+
+    ang = KEang * EAng + KEPos * EPos + DEang * (EAng - lastEA) + DEPos * (EPos - lastEP);
+
+    lastEA = EAng;
+    lastEP = EPos;
+
+    if (ang > angleLimit) {
+        ang = angleLimit;
+    }
+    else if (ang < -angleLimit) {
+        ang = -angleLimit;
+    }
+    if (lastAng != iv::MaxValue) {
+        ang = 0.2 * lastAng + 0.8 * ang;
+        //ODS("lastAng:%d\n", lastAng);
+    }
+    lastAng = ang;
+
+    return ang;
+}
+
+
+std::vector<iv::GPSData>   iv::decition::Compute00::getBesideGpsMapLine(iv::GPS_INS now_gps_ins, vector<iv::GPSData>gpsMapLine, float avoidX) {
+
+    vector<vector<iv::GPSData>> maps;
+    vector<iv::GPSData> gpsMapLineBeside;
+    int sizeN = gpsMapLine.size();
+    for (int i = 1; i < sizeN; i++)
+    {
+        iv::GPSData gpsData(new GPS_INS);
+        double xx = gpsMapLine[i]->gps_x - now_gps_ins.gps_x;
+        double yy = gpsMapLine[i]->gps_y - now_gps_ins.gps_y;
+        double lng = ServiceCarStatus.location->ins_heading_angle;
+
+
+        double x0 = xx * cos(lng * PI / 180) - yy * sin(lng * PI / 180);
+        double y0 = xx * sin(lng * PI / 180) + yy * cos(lng * PI / 180);
+        double k1 = sin((90 + (gpsMapLine[i]->ins_heading_angle - lng)) * PI / 180);
+        double k2 = cos((90 + (gpsMapLine[i]->ins_heading_angle - lng)) * PI / 180);
+
+        //	memcpy(&gpsData, &gpsMapLine[i], sizeof(gpsData));
+
+        gpsData->speed_mode = gpsMapLine[i]->speed_mode;
+        gpsData->gps_x = x0 + k1 * avoidX;
+        gpsData->gps_y = y0 + k2 * avoidX;
+        gpsMapLineBeside.push_back(gpsData);
+
+    }
+    return gpsMapLineBeside;
+
+}
+
+
+
+//double iv::decition::Compute00::getDecideAngleByLane(double realSpeed) {
+
+//    double ang = 0;
+//    double EPos = 0, EAng = 0;
+
+// //   double KEang = 14, KEpos = 10, DEang = 0, DEpos = 0;
+//       double KEang = 5, KEPos = 30, DEang = 0, DEPos = 0;
+
+// //   double PreviewDistance = max(6.0, realSpeed / 3.6 * 1.8);//预瞄距离
+
+//    double PreviewDistance;//预瞄距离
+//    realSpeed > 40 ? PreviewDistance = max(6.0, realSpeed *0.6) : PreviewDistance = max(6.0, realSpeed *0.5);
+
+
+
+
+
+////    if (realSpeed > 40)	KEang = 10; KEpos = 8;
+////        if (realSpeed > 50) KEang = 5;
+
+
+
+
+
+//double c1 = ServiceCarStatus.aftermarketLane.dist_to_lane_l;
+//double c2 = ServiceCarStatus.aftermarketLane.dist_to_lane_r;
+//double a = ServiceCarStatus.Lane.curvature;
+//double b = ServiceCarStatus.Lane.heading;
+//double c = (c1+c2)*0.5;
+//double x= PreviewDistance;
+//double y;
+
+
+//y=a*x*x+b*x+c;
+
+//   // EPos = y;
+//EPos=c;
+
+
+//  //  EAng=atan(2*a*x+b) / PI * 180;
+//    EAng=ServiceCarStatus.Lane.yaw;
+//        ang = KEang * EAng + KEPos * EPos + DEang * (EAng - lastEA) + DEPos * (EPos - lastEP);
+
+//        lastEA = EAng;
+//        lastEP = EPos;
+
+
+//           std::cout << "\nEPos:%f\n" << EPos << std::endl;
+//            std::cout << "\nEAng:%f\n" << EAng << std::endl;
+
+
+//        if (ang > angleLimit) {
+//            ang = angleLimit;
+//        }
+//        else if (ang < -angleLimit) {
+//            ang = -angleLimit;
+//        }
+//        if (lastAng != iv::MaxValue) {
+//            ang = 0.2 * lastAng + 0.8 * ang;
+//            //ODS("lastAng:%d\n", lastAng);
+//        }
+//        lastAng = ang;
+//        return ang;
+//    }
+
+
+
+double IEPos = 0, IEang = 0;
+
+
+double iv::decition::Compute00::getDecideAngleByLanePID(double realSpeed) {
+
+    double ang = 0;
+    double EPos = 0, EAng = 0;
+    double Curve=0;
+    double KEang = 14, KEPos = 10, DEang = 0, DEPos = 0;
+    double KCurve=120;
+    double KIEPos = 0, KIEang = 0;
+    //   double PreviewDistance = max(6.0, realSpeed / 3.6 * 1.8);//预瞄距离
+
+    double PreviewDistance;//预瞄距离
+
+    int confL=ServiceCarStatus.aftermarketLane.lane_conf_left;
+    int confR=ServiceCarStatus.aftermarketLane.lane_conf_right;
+    int conf =min(confL,confR);
+
+    realSpeed > 40 ? PreviewDistance = max(6.0, realSpeed *0.6) : PreviewDistance = max(6.0, realSpeed *0.5);
+
+
+
+
+
+    if (realSpeed > 40)	KEang = 10; KEPos = 8;
+    if (realSpeed > 50) KEang = 5;
+
+    KEPos = 20;
+    KEang = 200;
+    //KEang = 15;
+
+    double c1 = ServiceCarStatus.aftermarketLane.dist_to_lane_l;
+    double c2 = ServiceCarStatus.aftermarketLane.dist_to_lane_r;
+    double a = ServiceCarStatus.Lane.curvature;
+    double b = ServiceCarStatus.Lane.heading;
+    double c = (c1+c2)*0.5;
+    double yaw= ServiceCarStatus.Lane.yaw;
+
+    double x= PreviewDistance;
+    double y;
+
+
+    y=c-(a*x*x+b*x);
+    double difa=0-(atan(2*a*x+b) / PI * 180);
+    Curve=0-a;
+
+    //EAng=difa;
+    //EPos=y;
+    EAng= 0-b;
+    EPos = c;
+    DEang = 10;
+    DEPos = 20;
+    //DEang = 20;
+    //DEPos = 10;
+
+    IEang = EAng+0.7*IEang;
+    IEPos = EPos+0.7*IEPos;
+    KIEang = 0;
+    //KIEang = 0.5;
+    KIEPos =2;
+
+
+
+    if(abs(confL)>=2&&abs(confR)>=2){
+        //ang = KEang * EAng + KEPos * EPos + DEang * (EAng - lastEA) + DEPos * (EPos - lastEP)+ KIEang * IEang + KIEPos * IEPos;
+        ang = KEang * EAng + KEPos * EPos +KCurve*Curve+ DEang * (EAng - lastEA) + DEPos * (EPos - lastEP)+ KIEang * IEang + KIEPos * IEPos;
+    }else{
+        ang=lastAng;
+    }
+    //if(lastAng!=0&&abs(ang-lastAng)>20)ang=lastAng;
+
+    lastEA = EAng;
+    lastEP = EPos;
+
+    if (ang > angleLimit) {
+        ang = angleLimit;
+    }
+    else if (ang < -angleLimit) {
+        ang = -angleLimit;
+    }
+    if (lastAng != iv::MaxValue) {
+        ang = 0.2 * lastAng + 0.8 * ang;
+        //ODS("lastAng:%d\n", lastAng);
+    }
+    lastAng = ang;
+    return ang;
+}
+
+
+
+double iv::decition::Compute00::bocheCompute(GPS_INS nowGps, GPS_INS aimGps) {
+
+    GaussProjCal(aimGps.gps_lng, aimGps.gps_lat, &aimGps.gps_x, &aimGps.gps_y);
+    Point2D pt = Coordinate_Transfer(nowGps.gps_x, nowGps.gps_y, aimGps);
+
+
+
+    double x_1 = pt.x;
+    double y_1 = pt.y;
+    double angle_1 = getQieXianAngle(nowGps,aimGps);
+    double x_2 = 0.0, y_2 = 0.0;
+    double steering_angle;
+    double l = 2.950;
+    double r =6;
+    double x_o, y_o, x_o_1, y_o_1, x_o_2, y_o_2, x_3, y_3;
+    double x_t_n, y_t_n, x_t_f, y_t_f;//近切点和远切点
+    double x_t_1, y_t_1, x_t_2, y_t_2;//圆形1的切点
+    double x_t_3, y_t_3, x_t_4, y_t_4;//圆形2的切点
+    double g_1 = tan(angle_1);
+    double car_pos[3] = { x_1,y_1,g_1 };
+    double parking_pos[2] = { x_2,y_2 };
+    double g_3;
+    double t[4][2];
+    double p[4];
+    double  s1, s2; //切点与车起始位置的距离
+    double  min;
+    int  min_i;
+
+    //g_3 = 0 - 0.5775;
+    g_3 = pingfenxian_xielv(x_1, y_1, x_2, y_2, angle_1);
+    //交点
+    x_3 = 0.0;//(y_1 - y_2 + g_2*x_2 - g_1*x_1) / (g_2 - g_1);
+    y_3 = y_1 - g_1 * x_1;
+    //圆心1
+    x_o_1 = r;
+    y_o_1 = g_3 * r + y_3;
+    //圆形1的切点1
+    x_t_1 = 0.0;
+    y_t_1 = g_3 * r + y_3;
+    //圆形1的切点2
+    if (g_1 == 0)
+    {
+        x_t_2 = r;
+        y_t_2 = y_1 - g_1 * x_1;
+    }
+    else
+    {
+        y_t_2 = (y_1 + g_1 * x_o_1 + y_o_1 * g_1*g_1 - g_1 * x_1) / (1 + g_1 * g_1);
+        x_t_2 = (y_t_2 + g_1 * x_1 - y_1) / g_1;
+
+    }
+    //圆心2
+    x_o_2 = 0 - r;
+    y_o_2 = y_3 - g_3 * r;
+    //圆形2的切点1
+    x_t_3 = 0;
+    y_t_3 = y_3 - g_3 * r;
+    //圆形2的切点2
+    if (g_1 == 0)
+    {
+        x_t_4 = 0 - r;
+        y_t_4 = y_1 - g_1 * x_1;
+    }
+    else
+    {
+        y_t_4 = (y_1 + g_1 * x_o_2 + y_o_2 * g_1*g_1 - g_1 * x_1) / (1 + g_1 * g_1);
+        x_t_4 = (y_t_4 + g_1 * x_1 - y_1) / g_1;
+
+    }
+    t[0][0] = x_t_1;
+    t[0][1] = y_t_1;
+    t[1][0] = x_t_2;
+    t[1][1] = y_t_2;
+    t[2][0] = x_t_3;
+    t[2][1] = y_t_3;
+    t[3][0] = x_t_4;
+    t[3][1] = y_t_4;
+    for (int i = 0; i < 4; i++)
+    {
+
+        p[i] = (t[i][0] - parking_pos[0])*(t[i][0] - parking_pos[0]) + (t[i][1] - parking_pos[1])*(t[i][1] - parking_pos[1]);
+
+    }
+    min = p[0];
+    min_i = 0;
+    for (int i = 1; i < 4; i++)
+    {
+
+        if (p[i] < min)
+        {
+            min = p[i]; min_i = i;
+        }
+    }
+    if (min_i < 2)
+    {
+        x_o = x_o_1;
+        y_o = y_o_1;
+        s1 = (x_t_1 - x_1)*(x_t_1 - x_1) + (y_t_1 - y_1)*(y_t_1 - y_1);
+        s2 = (x_t_2 - x_1)*(x_t_2 - x_1) + (y_t_2 - y_1)*(y_t_2 - y_1);
+        if (s1 < s2)
+        {
+            x_t_n = x_t_1;
+            y_t_n = y_t_1;
+            x_t_f = x_t_2;
+            y_t_f = y_t_2;
+        }
+        else
+        {
+            x_t_n = x_t_2;
+            y_t_n = y_t_2;
+            x_t_f = x_t_1;
+            y_t_f = y_t_1;
+
+        }
+    }
+    else
+    {
+        x_o = x_o_2;
+        y_o = y_o_2;
+        s1 = (x_t_3 - x_1)*(x_t_3 - x_1) + (y_t_3 - y_1)*(y_t_3 - y_1);
+        s2 = (x_t_4 - x_1)*(x_t_4 - x_1) + (y_t_4 - y_1)*(y_t_4 - y_1);
+
+        if (s1 < s2)
+        {
+
+            x_t_n = x_t_3;
+            y_t_n = y_t_3;
+            x_t_f = x_t_4;
+            y_t_f = y_t_4;
+        }
+        else
+        {
+            x_t_n = x_t_4;
+            y_t_n = y_t_4;
+            x_t_f = x_t_3;
+            y_t_f = y_t_3;
+        }
+
+
+
+
+    }
+    steering_angle = atan2(l, r);
+
+    if (x_t_n < 0)
+    {
+        steering_angle = 0 - steering_angle;
+    }
+
+    nearTpoint=Coordinate_UnTransfer(x_t_n, y_t_n, aimGps);
+    farTpoint = Coordinate_UnTransfer(x_t_f, y_t_f, aimGps);
+    bocheAngle = steering_angle*180/PI;
+
+    cout << "近切点:x_t_n=" << x_t_n << endl;
+    cout << "近切点:y_t_n=" << y_t_n << endl;
+    cout << "远切点:x_t_f=" << x_t_f << endl;
+    cout << "远切点:y_t_f=" << y_t_f << endl;
+    cout << "航向角:" << steering_angle << endl;
+
+
+    //    if (x_1 < 0 && y_1 > 0 && x_1 < x_t_n &&y_t_f > 0.1) {
+    //        return 1;
+    //    }
+    Point2D ptN = Coordinate_Transfer(nearTpoint.gps_x, nearTpoint.gps_y, nowGps);
+    double disA = GetDistance(aimGps,nowGps);
+    if(y_t_n>0 && ptN.y<0 && y_t_f>0.1 && disA<40){
+        return 1;
+    }
+
+    return 0;
+
+}
+
+
+
+//返回垂直平分线的斜率
+double iv::decition::Compute00::pingfenxian_xielv(double x_1, double y_1, double x_2, double y_2, double angle_1) {
+    double angl, x_3, angle_3;
+    if (tan(angle_1 == 0))
+    {
+        if ((x_1 - x_2) > 0 && ((y_1 - y_2) > 0))
+        {
+            angle_3 = 0 - 1;
+        }
+        else
+        {
+            angle_3 = 1;
+        }
+    }
+    else
+    {
+        x_3 = (tan(angle_1)*x_1 - y_1) / tan(angle_1);//车所在直线与x轴交点
+        angl = tan(angle_1);//车所在直线的斜率
+        if ((x_1 - x_2)>0 && ((y_1 - y_2)>0))//第一象限
+        {
+            if ((angl *x_3)<0)//车斜率与车直线的x轴交点异号
+            {
+                if (angl < 0)
+                {
+                    angle_3 = tan(PI*0.5 + (PI*0.5 - atan(fabs(angl))) *0.5);//垂直平分线斜率
+                }
+                else
+                {
+                    angle_3 = tan(PI*0.5 + (PI*0.5 + atan(fabs(angl))) *0.5);//垂直平分线斜率
+                }
+
+
+
+            }
+
+        }
+        else//第二象限
+        {
+            if ((angl*x_3)<0)//车斜率与车直线的x轴交点异号
+            {
+                if (angl < 0)
+                {
+                    angle_3 = tan(PI*0.5 - (PI*0.5 + atan(fabs(angl))) *0.5);//垂直平分线斜率
+                }
+                else
+                {
+                    angle_3 = tan(atan(fabs(angl)) + (PI*0.5 - atan(fabs(angl))) *0.5);//垂直平分线斜率
+                }
+
+            }
+        }
+    }
+
+    return angle_3;
+
+}
+
+
+
+double iv::decition::Compute00::getQieXianAngle(GPS_INS nowGps, GPS_INS aimGps) {
+    double heading = nowGps.ins_heading_angle *PI/180;
+    double x1 = nowGps.gps_x;
+    double y1 = nowGps.gps_y;
+    if (heading<=PI*0.5)
+    {
+        heading = 0.5*PI - heading;
+    }
+    else if (heading>PI*0.5 && heading<=PI*1.5) {
+        heading = 1.5*PI - heading;
+    }
+    else if (heading>PI*1.5) {
+        heading = 2.5*PI - heading;
+    }
+    double k1 = tan(heading);
+    double x = x1+10;
+    double y = k1 * x + y1 - (k1 * x1);
+    Point2D pt1 = Coordinate_Transfer(nowGps.gps_x, nowGps.gps_y, aimGps);
+    Point2D pt2 = Coordinate_Transfer(x, y, aimGps);
+    double xielv = (pt1.y - pt2.y) / (pt1.x - pt2.x);
+    double angle = atan(abs(xielv));
+    if (xielv<0)
+    {
+        angle = PI - angle;
+    }
+    return angle;
+
+}
+
+
+/*
+  chuizhicheweiboche
+  */
+
+
+int iv::decition::Compute00::bocheDirectCompute(GPS_INS nowGps, GPS_INS aimGps)
+{
+
+
+
+    double l=2.95;//轴距
+    double x_0 = 0, y_0 = 0.5;
+    double x_1, y_1;//车起点坐标
+    double ange1;//车航向角弧度
+    double x_2, y_2;//另一条与车直线在angle2和R_M 固定情况下过坐标点,第二个近切点
+    double real_rad;;//另一条直线的航向角弧度
+    double angle_3;//垂直平分线弧度
+    double x_3, y_3;//垂直平分线交点
+    double x_4, y_4;//另一条直线的远切点坐标,第二个远切点,已知
+    double x_o_1, y_o_1;//圆形1坐标
+    double x_o_2, y_o_2;//圆形2坐标
+    double x_t_n, y_t_n, x_t_f, y_t_f;//近切点和远切点
+    double min_rad;
+    double R_M; //后轴中点的转弯半径
+    double steering_angle;
+
+
+
+
+    GaussProjCal(aimGps.gps_lng, aimGps.gps_lat, &aimGps.gps_x, &aimGps.gps_y);
+    Point2D pt = Coordinate_Transfer(nowGps.gps_x, nowGps.gps_y, aimGps);
+    x_1=pt.x;
+    y_1=pt.y;
+    ange1=getQieXianAngle(nowGps,aimGps);
+
+    min_rad_zhuanxiang(&R_M , &min_rad);
+    qiedian_n(x_1,y_1,R_M,min_rad,&x_2 , &y_2, &real_rad);//计算另一条与车直线在angle2和R_M 固定情况下近切点:x_2, y_2
+    liangzhixian_jiaodian( x_1, y_1,  x_2, y_2,ange1,real_rad,&x_3 , &y_3);
+    chuizhipingfenxian_xielv( x_1, y_1, ange1, real_rad, min_rad,&angle_3);
+    yuanxin( x_2, y_2, x_3, y_3, real_rad, angle_3, R_M,&x_o_1,&y_o_1,&x_o_2,&y_o_2);
+    yuanxin_qiedian( ange1, x_o_1, y_o_1,  x_o_2, y_o_2,
+                     x_1, y_1, x_2, y_2, x_3, y_3, real_rad, angle_3, R_M,&x_t_n,&y_t_n,&x_t_f, &y_t_f);
+    steering_angle = atan2(l, R_M);
+    x_4 = 0.5;
+    y_4 = 0;
+    //for (int i = 0; i < 4; i++)
+    //{
+    //for (int j = 0; j < 2; j++)
+    //{
+    //	cout << t[i][j] << endl;
+    //}
+    //}
+    //cout << "min_rad:" << min_rad<< endl;
+    //cout << "jiaodian:x=" << x_3 << endl;
+    //cout << "jiaodian:y=" << y_3 << endl;
+    // cout << "R-M:" << R_M << endl;
+    cout << "x_0:" << x_0 << endl;
+    cout << "y_0:" << y_0 << endl;
+    cout << "x_2:" << x_2 << endl;
+    cout << "y_2:" << y_2 << endl;
+    cout << "近切点:x_t_n="<< x_t_n << endl;
+    cout << "近切点:y_t_n=" << y_t_n << endl;
+    cout << "远切点:x_t_f=" << x_t_f << endl;
+    cout << "远切点:y_t_f=" << y_t_f << endl;
+    //cout << "航向角:" << steering_angle << endl;
+    //cout << "圆心1横坐标=" << x_o_1 << endl;
+    //cout << "圆心1纵坐标=" << y_o_1 << endl;
+    //cout << "圆心2横坐标=" << x_o_2 << endl;
+    //cout << "圆心2纵坐标=" << y_o_2 << endl;
+    //cout << "平分线弧度=" << angle_3 << endl;
+    //cout << " min_rad=" << min_rad << endl;
+    //cout << " real_rad=" << real_rad << endl;
+    //   system("PAUSE");
+
+
+
+    dTpoint0=Coordinate_UnTransfer(x_t_n, y_t_n, aimGps);
+    dTpoint1 = Coordinate_UnTransfer(x_t_f, y_t_f, aimGps);
+    dTpoint2 = Coordinate_UnTransfer(x_2, y_2, aimGps);
+    dTpoint3 = Coordinate_UnTransfer(x_0, y_0, aimGps);
+    dBocheAngle = steering_angle*180/PI;
+
+    double disA = GetDistance(aimGps,nowGps);
+
+    if(pt.y>y_t_n && x_t_f<x_2 && y_t_f>y_2&&disA<40){
+        return 1;
+    }
+    return 0;
+
+}
+
+
+double iv::decition::Compute00::min_rad_zhuanxiang(double *R_M, double *min_rad) {
+    double L_c = 4.749;//车长
+    double rad_1;
+    double rad_2;
+    double L_k = 1.931;//车宽
+    double L = 2.95;//轴距
+    double L_f =1.2 ;//前悬
+    double L_r =0.7 ;//后悬
+    double R_min =6.5 ;//最小转弯半径
+    *R_M = fabs(sqrt(R_min*R_min - (L + L_f)*(L + L_f))) - L_k*0.5;//double	R_M  ;//后轴中点的转弯半径
+    //rad_1 = atan2(sqrt(R_min*R_min - (R_M - L_k*0.5)*(R_M - L_k*0.5)), R_M - L_k*0.5);
+    //rad_2 = atan2(L + L_f, R_M + L_k*0.5);
+    *min_rad = 45 * PI / 180;// rad_1 - rad_2;
+    return 0;
+}
+
+
+double iv::decition::Compute00::qiedian_n(double x_1, double y_1, double R_M,double min_rad, double *x_2, double *y_2, double *real_rad ) {
+
+    if (x_1 > 0 && y_1 > 0)
+    {
+        *real_rad = PI*0.5 - min_rad;
+        *x_2 = R_M - R_M*cos(min_rad);
+        *y_2 = R_M*sin(min_rad) + 0.5;
+    }
+    else
+    {
+        *real_rad = PI*0.5 + min_rad;
+        *x_2 = R_M*cos(min_rad) - R_M;
+        *y_2 = R_M*sin(min_rad) + 0.5;
+    }
+    return 0;
+
+}
+
+
+double iv::decition::Compute00::liangzhixian_jiaodian(double x_1,double y_1,double x_2,double y_2,double ange1,double real_rad,double *x_3,double *y_3) {
+    double b1, b2;
+    double k1, k2;
+    if (ange1!=(PI*0.5))
+    {
+        k1 = tan(ange1);
+        b1 = y_1 - k1*x_1;
+        k2 = tan(real_rad);
+        b2 = y_2 - k2*x_2;
+        *x_3 = (b2 - b1) / (k1 - k2);
+        *y_3 = k2*(*x_3) + b2;
+    }
+    else
+    {
+        k2 = tan(real_rad);
+        b2 = y_2 - k2*x_2;
+        *x_3 = x_1;
+        *y_3 = k2*(*x_3) + b2;
+    }
+    return 0;
+}
+
+
+double iv::decition::Compute00::chuizhipingfenxian_xielv(double x_1,double y_1,double ange1,double real_rad,double min_rad,double *angle_3) {
+    double k1, k2;
+    double  angle_j;
+    k2 = tan(real_rad);
+    if (ange1 != (PI*0.5))
+    {
+        k1 = tan(ange1);
+        angle_j = atan(fabs((k2 - k1) / (1 + k2*k1)));//两直线夹角
+
+        if (x_1 > 0 && y_1 > 0)
+        {
+            *angle_3 = angle_j*0.5 - min_rad + PI;
+        }
+        else
+        {
+            *angle_3 = min_rad - angle_j*0.5;
+        }
+    }
+    else
+    {
+        angle_j = min_rad;//两直线夹角
+        if (x_1 > 0 && y_1 > 0)
+        {
+            *angle_3 = angle_j*0.5 - min_rad + PI;
+        }
+        else
+        {
+            *angle_3 = min_rad - angle_j*0.5;
+        }
+    }
+    return 0;
+}
+
+
+double iv::decition::Compute00::yuanxin(double x_2,double y_2,double x_3,double y_3,double real_rad,double angle_3,double R_M,
+                                        double *x_o_1,double *y_o_1,double *x_o_2,double *y_o_2) {
+    double b2, b3, k2, k3;
+    b2 = y_2 - tan(real_rad)*x_2;
+    b3 = y_3 - tan(angle_3)*x_3;
+    k2 = tan(real_rad);
+    k3 = tan(angle_3);
+    *x_o_1 = (sqrt(k2*k2 + 1)*R_M + b3 - b2) / (k2 - k3);
+    *y_o_1 = k3*(*x_o_1) + b3;
+
+    *x_o_2 = (b3 - b2 - (sqrt(k2*k2 + 1)*R_M)) / (k2 - k3);
+    *y_o_2 = k3*(*x_o_2) + b3;
+    return 0;
+}
+
+
+double iv::decition::Compute00::yuanxin_qiedian(double ange1,double x_o_1,double y_o_1, double x_o_2,double y_o_2,
+                                                double x_1,double y_1,double x_2,double y_2,double x_3,double y_3,double real_rad,double angle_3,double R_M,
+                                                double *x_t_n, double *y_t_n, double *x_t_f, double *y_t_f)
+{
+    double x_o, y_o;
+    double b2, b3, k1, k2, k3;
+    //double car_pos[3] = { x_1,y_1,k1 };
+    double parking_pos[2] = { x_2,y_2 };
+    //double t[4][2];
+    double p[4];
+    double  s1, s2; //切点与车起始位置的距离
+    double  min;
+    int  min_i;
+    double x_t_1, y_t_1, x_t_2, y_t_2;//圆形1的切点
+    double x_t_3, y_t_3, x_t_4, y_t_4;//圆形2的切点
+    double t[4][2];
+    k1 = tan(ange1);
+    b2 = y_2 - tan(real_rad)*x_2;
+    b3 = y_3 - tan(real_rad)*x_3;
+    k2 = tan(real_rad);//另一条直线斜率
+    k3 = tan(angle_3);//垂直平分线斜率
+    //圆心1和2切点*********************************************
+    if (x_1 > 0 && y_1 > 0)//第一象限
+    {
+        if (ange1 == (PI*0.5))
+        {
+            x_t_1 = x_1;
+            y_t_1 = y_o_1;
+            y_t_2 = (y_2 + k2 *x_o_1 + y_o_1*k2*k2 - k2*x_2) / (1 + k2*k2);
+            x_t_2 = (y_t_2 + k2*x_2 - y_2) / k2;
+
+            x_t_3 = x_1;
+            y_t_3 = y_o_2;
+            y_t_4 = (y_2 + k2 *x_o_2 + y_o_2*k2*k2 - k2*x_2) / (1 + k2*k2);
+            x_t_4 = (y_t_4 + k2*x_2 - y_2) / k2;
+
+
+        }
+        else
+        {
+            y_t_1 = (y_1 + k1 *x_o_1 + y_o_1*k1*k1 - k1*x_1) / (1 + k1*k1);
+            x_t_1 = (y_t_1 + k1*x_1 - y_1) / k1;
+            y_t_2 = (y_2 + k2 *x_o_1 + y_o_1*k2*k2 - k2*x_2) / (1 + k2*k2);
+            x_t_2 = (y_t_2 + k2*x_2 - y_2) / k2;
+
+            y_t_3 = (y_1 + k1 *x_o_2 + y_o_2*k1*k1 - k1*x_1) / (1 + k1*k1);
+            x_t_3 = (y_t_3 + k1*x_1 - y_1) / k1;
+            y_t_4 = (y_2 + k2 *x_o_2 + y_o_2*k2*k2 - k2*x_2) / (1 + k2*k2);
+            x_t_4 = (y_t_4 + k2*x_2 - y_2) / k2;
+
+        }
+    }
+    else
+    {
+        if (ange1 == 0)
+        {
+            x_t_1 = 0 - x_1;
+            y_t_1 = y_o_1;
+            y_t_2 = (y_2 + k2 *x_o_1 + y_o_1*k2*k2 - k2*x_2) / (1 + k2*k2);
+            x_t_2 = (y_t_2 + k2*x_2 - y_2) / k2;
+
+            x_t_3 = 0 - x_1;
+            y_t_3 = y_o_2;
+            y_t_4 = (y_2 + k2 *x_o_2 + y_o_2*k2*k2 - k2*x_2) / (1 + k2*k2);
+            x_t_4 = (y_t_4 + k2*x_2 - y_2) / k2;
+        }
+        else
+        {
+            y_t_1 = (y_1 + k1 *x_o_1 + y_o_1*k1*k1 - k1*x_1) / (1 + k1*k1);
+            x_t_1 = (y_t_1 + k1*x_1 - y_1) / k1;
+            y_t_2 = (y_2 + k2 *x_o_1 + y_o_1*k2*k2 - k2*x_2) / (1 + k2*k2);
+            x_t_2 = (y_t_2 + k2*x_2 - y_2) / k2;
+
+            y_t_3 = (y_1 + k1 *x_o_2 + y_o_2*k1*k1 - k1*x_1) / (1 + k1*k1);
+            x_t_3 = (y_t_3 + k1*x_1 - y_1) / k1;
+            y_t_4 = (y_2 + k2 *x_o_2 + y_o_2*k2*k2 - k2*x_2) / (1 + k2*k2);
+            x_t_4 = (y_t_4 + k2*x_2 - y_2) / k2;
+
+        }
+
+    }
+
+    //圆心1和2切点*********************************************
+
+    t[0][0] = x_t_1;
+    t[0][1] = y_t_1;
+    t[1][0] = x_t_2;
+    t[1][1] = y_t_2;
+    t[2][0] = x_t_3;
+    t[2][1] = y_t_3;
+    t[3][0] = x_t_4;
+    t[3][1] = y_t_4;
+    for (int i = 0; i < 4; i++)
+    {
+
+        p[i] = (t[i][0] - parking_pos[0])*(t[i][0] - parking_pos[0]) + (t[i][1] - parking_pos[1])*(t[i][1] - parking_pos[1]);
+
+    }
+    min = p[0];
+    min_i = 0;
+    for (int i = 1; i < 4; i++)
+    {
+
+        if (p[i] < min)
+        {
+            min = p[i]; min_i = i;
+        }
+    }
+    if (min_i < 2)
+    {
+        x_o = x_o_1;
+        y_o = y_o_1;
+        s1 = (x_t_1 - x_1)*(x_t_1 - x_1) + (y_t_1 - y_1)*(y_t_1 - y_1);
+        s2 = (x_t_2 - x_1)*(x_t_2 - x_1) + (y_t_2 - y_1)*(y_t_2 - y_1);
+        if (s1 < s2)
+        {
+            *x_t_n = x_t_1;
+            *y_t_n = y_t_1;
+            *x_t_f = x_t_2;
+            *y_t_f = y_t_2;
+        }
+        else
+        {
+            *x_t_n = x_t_2;
+            *y_t_n = y_t_2;
+            *x_t_f = x_t_1;
+            *y_t_f = y_t_1;
+
+        }
+    }
+    else
+    {
+        x_o = x_o_2;
+        y_o = y_o_2;
+        s1 = (x_t_3 - x_1)*(x_t_3 - x_1) + (y_t_3 - y_1)*(y_t_3 - y_1);
+        s2 = (x_t_4 - x_1)*(x_t_4 - x_1) + (y_t_4 - y_1)*(y_t_4 - y_1);
+
+        if (s1 < s2)
+        {
+
+            *x_t_n = x_t_3;
+            *y_t_n = y_t_3;
+            *x_t_f = x_t_4;
+            *y_t_f = y_t_4;
+        }
+        else
+        {
+            *x_t_n = x_t_4;
+            *y_t_n = y_t_4;
+            *x_t_f = x_t_3;
+            *y_t_f = y_t_3;
+        }
+
+
+
+    }
+
+    return 0;
+
+}
+
+
+int iv::decition::Compute00::getNoAngleNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap)
+{
+    int index = -1;
+    int startIndex = 0;     // startIndex = 0 则每一次都是遍历整条地图路线
+    int endIndex = gpsMap.size() - 1;
+    float minDis=20;
+
+    for (int j = startIndex; j < endIndex; j++)
+    {
+        int i = (j + gpsMap.size()) % gpsMap.size();
+        double tmpdis = GetDistance(rp, (*gpsMap[i]));
+
+        if (tmpdis < minDis)
+        {
+            index = i;
+            minDis=tmpdis;
+        }
+    }
+    return index;
+}
+
+
+double iv::decition::Compute00::getObsSpeedByFrenet(Point2D obsPoint, double realSecSpeed,const vector<Point2D>& gpsTrace, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps) {
+    double obsSpeed = 0 - realSecSpeed;
+    double minDis = iv::MaxValue;
+    FrenetPoint esr_obs_F_point;
+    for (int i = 0; i < 64; i++)
+        if ((ServiceCarStatus.obs_radar[i].nomal_y) != 0 && ServiceCarStatus.obs_radar[i].valid)
+        {
+            double xxx = ServiceCarStatus.obs_radar[i].nomal_x + Esr_Offset;
+            double yyy = ServiceCarStatus.obs_radar[i].nomal_y + Esr_Y_Offset;
+
+            if (abs(xxx - obsPoint.x) < 4 && abs(yyy - obsPoint.y) < 2)
+            {
+                double tmpDis = sqrt((xxx - obsPoint.x) * (xxx - obsPoint.x) + (yyy - obsPoint.y) * (yyy - obsPoint.y));
+                if (tmpDis < minDis)
+                {
+                    minDis = tmpDis;
+//                    esr_obs_F_point = iv::decition::FrenetPlanner::XY2Frenet(xxx, yyy, gpsTrace);
+                    esr_obs_F_point = iv::decition::FrenetPlanner::getFrenetfromXY(xxx, yyy, gpsTrace,gpsMap,pathpoint,nowGps);
+//                    obsSpeed = ServiceCarStatus.obs_radar[i].speed_y;
+                    double speedx=ServiceCarStatus.obs_radar[i].speed_x;  //障碍物相对于车辆x轴的速度
+                    double speedy=ServiceCarStatus.obs_radar[i].speed_y;  //障碍物相对于车辆y轴的速度
+                    double speed_combine = sqrt(speedx*speedx+speedy*speedy);    //将x、y轴两个方向的速度求矢量和
+                    //障碍物的速度方向与道路方向的夹角。用于将速度分解到s方向和d方向。
+                    //所谓道路方向是指,道路上离障碍物的最近的点沿道路弧线的切线方向。
+                    double Etheta = esr_obs_F_point.tangent_Ang - atan2(speedy,speedx);
+
+                    obsSpeed = speed_combine*cos(Etheta);  //由speed_combine分解的s轴方向上的速度
+                }
+            }
+        }
+
+    return obsSpeed;
+}
+
+
+int iv::decition::Compute00::getEsrIndexByFrenet(const std::vector<Point2D>& gpsTrace, FrenetPoint &esrObsPoint, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps){
+    double minDistance = numeric_limits<double>::max();
+    int minDis_index=-1;
+
+    for(int i=0; i<64; ++i){
+        if ((ServiceCarStatus.obs_radar[i].nomal_y) != 0 && (ServiceCarStatus.obs_radar[i].valid)){
+            //毫米波在车头,故要加上毫米波与惯导的相对距离。(xxx,yyy)才是障碍物在 车辆坐标系下的坐标。
+            double xxx = ServiceCarStatus.obs_radar[i].nomal_x + Esr_Offset;
+            double yyy = ServiceCarStatus.obs_radar[i].nomal_y+ Esr_Y_Offset;
+
+            //将毫米波障碍物位置转换到frenet坐标系下
+//            esrObsPoint = iv::decition::FrenetPlanner::XY2Frenet(xxx,yyy,gpsTrace);
+            esrObsPoint = iv::decition::FrenetPlanner::getFrenetfromXY(xxx,yyy,gpsTrace,gpsMap,pathpoint,nowGps);
+
+            //如果障碍物与道路的横向距离d<=3.0*Veh_Width / 4.0,则认为道路上有障碍物。
+            //s则可理解为障碍物距离。为障碍物与车辆沿着道路方向的距离,而不是空间上的x或y坐标或者直线距离。
+            //minDistance、minDis_index用来统计最近的障碍物信息。
+            if(abs(esrObsPoint.d)<=(3.0*Veh_Width / 4.0+DecideGps00().xiuzhengCs)){
+                if(esrObsPoint.s<minDistance){
+                    minDistance = esrObsPoint.s;
+                    minDis_index = i;
+                }
+            }
+        }
+    }
+    return minDis_index;
+}
+
+
+
+
+std::vector<std::vector<iv::GPSData>> gmapsL;
+std::vector<std::vector<iv::GPSData>> gmapsR;

+ 96 - 96
src/decition/decition_brain/decition/compute_00.h

@@ -1,96 +1,96 @@
-#pragma once
-#ifndef _IV_DECITION_COMPUTE_00_
-#define _IV_DECITION_COMPUTE_00_
-
-#include <common/gps_type.h>
-#include <common/obstacle_type.h>
-#include <decition/decition_type.h>
-#include<vector> 
-#include <decition/decide_gps_00.h>
-
-namespace iv {
-    namespace decition {
-    //根据传感器传输来的信息作出决策
-        class Compute00 {
-        public:
-            Compute00();
-            ~Compute00();
-
-            static   double maxAngle;
-            static	 double angleLimit;  //角度限制
-            static	 double lastEA;      //上一次角度误差
-            static	 double lastEP;      //上一次位置误差
-            static	 double decision_Angle;  //决策角度
-            static	 double lastAng;         //上次角度
-            static   int lastEsrID;          //上次毫米波障碍物ID
-            static   int  lastEsrCount;      //毫米波障碍物累计次数
-
-            static   int lastEsrIDAvoid;          //上次毫米波障碍物ID Avoid
-            static   int  lastEsrCountAvoid;      //毫米波障碍物累计次数 Avoid
-
-            static iv::GPS_INS nearTpoint, farTpoint,dTpoint0,dTpoint1,dTpoint2,dTpoint3;
-            static double bocheAngle,dBocheAngle;
-
-            static	int getNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap, int lastIndex, double mindis, double maxAngle);
-            static	int getFirstNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap, int lastIndex, double mindis, double maxAngle);
-
-            static double getDecideAngle(std::vector<Point2D>  gpsTrace, double realSpeed);
-            static double getAveDef(std::vector<Point2D> farTrace);
-            static int getSpeedPointIndex(std::vector<Point2D> gpsTrace, double realSpeed);
-            static Point2D getLidarObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr);
-            static Point2D getLidarRearObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr);
-
-
-            static Point2D getLidarObsPointAvoid(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr);
-            static int getEsrIndex(std::vector<Point2D> gpsTrace , int roadNum, int *esrPathpoint);
-            static int getEsrIndexAvoid(std::vector<Point2D> gpsTrace);
-
-            static double getObsSpeed(Point2D obsPoint, double realSecSpeed);
-
-            static double getAvoidAveDef(std::vector<Point2D> farTrace, double avoidX);
-            static double getDecideAvoidAngle(std::vector<Point2D>  gpsTrace, double realSpeed, float avoidX);
-
-            static std::vector<GPSData>  getBesideGpsMapLine(iv::GPS_INS now_gps_ins, std::vector<iv::GPSData>gpsMapLine, float avoidX);
-
-            static double getDecideAngleByLane(double realSpeed);
-
-            static double getDecideAngleByLanePID(double realSpeed);
-
-            static double bocheCompute(GPS_INS nowGps, GPS_INS aimGps);
-
-            static	double pingfenxian_xielv(double x_1, double y_1, double x_2, double y_2, double angle_1);
-
-            static double getQieXianAngle(GPS_INS nowGps, GPS_INS aimGps);
-
-            static int bocheDirectCompute(GPS_INS nowGps, GPS_INS aimGps);
-
-            static double min_rad_zhuanxiang(double *R_M, double *min_rad);
-            static double qiedian_n(double x_1,double y_1,double R_M,double min_rad,
-                                    double *x_2, double *y_2, double *real_rad);
-            static double liangzhixian_jiaodian(double x_1,double y_1,double x_2,double y_2,
-                                                double ange1,double real_rad,double *x_3, double *y_3);
-            static double chuizhipingfenxian_xielv(double x_1,double y_1,double ange1,double real_rad,
-                                                   double min_rad,double *angle_3);
-            static double yuanxin(double x_2,double y_2,double x_3,double y_3,double real_rad,
-                                  double angle_3,double R_M,double *x_o_1, double *y_o_1, double *x_o_2, double *y_0_2);
-            static double yuanxin_qiedian(double angel,double x_o_1,double y_o_1, double x_o_2,double y_o_2,
-                                          double x_1,double y_1,double x_2,double y_2,double x_3,double y_3,
-                                          double real_rad,double angle_3,double R_M,
-                                          double *x_t_n, double *y_t_n, double *x_t_f, double *y_t_f);
-
-            static int getNoAngleNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap);
-    		static int getEsrIndexByFrenet(const std::vector<Point2D>& gpsTrace,FrenetPoint &esrObsPoint, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps);
-    		double getObsSpeedByFrenet(Point2D obsPoint, double realSecSpeed,const std::vector<Point2D>& gpsTrace, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps);
-        private:
-
-        };
-    }
-}
-extern std::vector<std::vector<iv::GPSData>> gmapsL;
-extern std::vector<std::vector<iv::GPSData>> gmapsR;
-
-extern std::vector<int> lastEsrIdVector;
-extern std::vector<int> lastEsrCountVector;
-
-#endif // !_IV_DECITION_COMPUTE_00_
-
+#pragma once
+#ifndef _IV_DECITION_COMPUTE_00_
+#define _IV_DECITION_COMPUTE_00_
+
+#include <common/gps_type.h>
+#include <common/obstacle_type.h>
+#include <decition/decition_type.h>
+#include<vector> 
+#include <decition/decide_gps_00.h>
+
+namespace iv {
+    namespace decition {
+    //根据传感器传输来的信息作出决策
+        class Compute00 {
+        public:
+            Compute00();
+            ~Compute00();
+
+            static   double maxAngle;
+            static	 double angleLimit;  //角度限制
+            static	 double lastEA;      //上一次角度误差
+            static	 double lastEP;      //上一次位置误差
+            static	 double decision_Angle;  //决策角度
+            static	 double lastAng;         //上次角度
+            static   int lastEsrID;          //上次毫米波障碍物ID
+            static   int  lastEsrCount;      //毫米波障碍物累计次数
+
+            static   int lastEsrIDAvoid;          //上次毫米波障碍物ID Avoid
+            static   int  lastEsrCountAvoid;      //毫米波障碍物累计次数 Avoid
+
+            static iv::GPS_INS nearTpoint, farTpoint,dTpoint0,dTpoint1,dTpoint2,dTpoint3;
+            static double bocheAngle,dBocheAngle;
+
+            static	int getNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap, int lastIndex, double mindis, double maxAngle);
+            static	int getFirstNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap, int lastIndex, double mindis, double maxAngle);
+
+            static double getDecideAngle(std::vector<Point2D>  gpsTrace, double realSpeed);
+            static double getAveDef(std::vector<Point2D> farTrace);
+            static int getSpeedPointIndex(std::vector<Point2D> gpsTrace, double realSpeed);
+            static Point2D getLidarObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr);
+            static Point2D getLidarRearObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr);
+
+
+            static Point2D getLidarObsPointAvoid(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr);
+            static int getEsrIndex(std::vector<Point2D> gpsTrace , int roadNum, int *esrPathpoint);
+            static int getEsrIndexAvoid(std::vector<Point2D> gpsTrace);
+
+            static double getObsSpeed(Point2D obsPoint, double realSecSpeed);
+
+            static double getAvoidAveDef(std::vector<Point2D> farTrace, double avoidX);
+            static double getDecideAvoidAngle(std::vector<Point2D>  gpsTrace, double realSpeed, float avoidX);
+
+            static std::vector<GPSData>  getBesideGpsMapLine(iv::GPS_INS now_gps_ins, std::vector<iv::GPSData>gpsMapLine, float avoidX);
+
+            static double getDecideAngleByLane(double realSpeed);
+
+            static double getDecideAngleByLanePID(double realSpeed);
+
+            static double bocheCompute(GPS_INS nowGps, GPS_INS aimGps);
+
+            static	double pingfenxian_xielv(double x_1, double y_1, double x_2, double y_2, double angle_1);
+
+            static double getQieXianAngle(GPS_INS nowGps, GPS_INS aimGps);
+
+            static int bocheDirectCompute(GPS_INS nowGps, GPS_INS aimGps);
+
+            static double min_rad_zhuanxiang(double *R_M, double *min_rad);
+            static double qiedian_n(double x_1,double y_1,double R_M,double min_rad,
+                                    double *x_2, double *y_2, double *real_rad);
+            static double liangzhixian_jiaodian(double x_1,double y_1,double x_2,double y_2,
+                                                double ange1,double real_rad,double *x_3, double *y_3);
+            static double chuizhipingfenxian_xielv(double x_1,double y_1,double ange1,double real_rad,
+                                                   double min_rad,double *angle_3);
+            static double yuanxin(double x_2,double y_2,double x_3,double y_3,double real_rad,
+                                  double angle_3,double R_M,double *x_o_1, double *y_o_1, double *x_o_2, double *y_0_2);
+            static double yuanxin_qiedian(double angel,double x_o_1,double y_o_1, double x_o_2,double y_o_2,
+                                          double x_1,double y_1,double x_2,double y_2,double x_3,double y_3,
+                                          double real_rad,double angle_3,double R_M,
+                                          double *x_t_n, double *y_t_n, double *x_t_f, double *y_t_f);
+
+            static int getNoAngleNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap);
+    		static int getEsrIndexByFrenet(const std::vector<Point2D>& gpsTrace,FrenetPoint &esrObsPoint, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps);
+    		double getObsSpeedByFrenet(Point2D obsPoint, double realSecSpeed,const std::vector<Point2D>& gpsTrace, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps);
+        private:
+
+        };
+    }
+}
+extern std::vector<std::vector<iv::GPSData>> gmapsL;
+extern std::vector<std::vector<iv::GPSData>> gmapsR;
+
+extern std::vector<int> lastEsrIdVector;
+extern std::vector<int> lastEsrCountVector;
+
+#endif // !_IV_DECITION_COMPUTE_00_
+

+ 605 - 605
src/decition/decition_brain/decition/decide_from_gps.cpp

@@ -1,605 +1,605 @@
-#include <decition/decition_maker.h>
-#include <decition/gps_distance.h>
-#include <decition/decition_type.h>
-#include <math.h>
-#include <iostream>
-#include <fstream>
-using namespace std;
-
-
-iv::decition::DecitionMaker::DecitionMaker() {
-
-}
-iv::decition::DecitionMaker::~DecitionMaker() {
-
-}
-
-
-
-
-
-
-/* void iv::decition::DecitionMaker::decideFromGPS(Decition & gps_decition, iv::GPSData gps_data, const std::vector<iv::GPSData> navigation_data)
-{
-	//可直接获取车速  方法咨询张庆余
-
-	//样例
-	//输入数据类型
-	gps_data->gps_x;
-	gps_data->gps_y;
-	gps_data->gps_z;
-	gps_data->ins_heading_angle;	//航向角
-	gps_data->ins_pitch_angle;		//俯仰角
-	gps_data->ins_roll_angle;		//横滚角
-
-									//导航数据
-	navigation_data[0]->gps_x;
-	navigation_data[1]->gps_y;
-	for (std::vector<iv::GPSData>::const_iterator it = navigation_data.cbegin(); it != navigation_data.cend(); it++) {
-		//std::cout << (*it)->gps_x << std::endl;
-	}
-
-	//输出
-	gps_decition->speed = 30;
-	gps_decition->wheel_angle = 10;
-
-}*/
-
-
-void iv::decition::DecitionMaker::adjustOriginPoint(iv::GPS_INS nowGPSIns) {
-	const double PI = 3.1415926535898;
-	if (nowGPSIns.ins_heading_angle >= 0 && nowGPSIns.ins_heading_angle <= 90) {
-		origin_x = nowGPSIns.gps_x + vehLenthAdj*sin(nowGPSIns.ins_heading_angle*PI / 180);
-		origin_y = nowGPSIns.gps_y + vehLenthAdj*cos(nowGPSIns.ins_heading_angle*PI / 180);
-	}
-	else if (nowGPSIns.ins_heading_angle >= 90 && nowGPSIns.ins_heading_angle <= 180)
-	{
-		origin_x = nowGPSIns.gps_x + vehLenthAdj*sin((180 - nowGPSIns.ins_heading_angle)*PI / 180);
-		origin_y = nowGPSIns.gps_y - vehLenthAdj*cos((180 - nowGPSIns.ins_heading_angle)*PI / 180);
-	}
-	else  if (nowGPSIns.ins_heading_angle >= 180 && nowGPSIns.ins_heading_angle <= 270)
-	{
-		origin_x = nowGPSIns.gps_x - vehLenthAdj*sin((nowGPSIns.ins_heading_angle - 180)*PI / 180);
-		origin_y = nowGPSIns.gps_y - vehLenthAdj*cos((nowGPSIns.ins_heading_angle - 180)*PI / 180);
-	}
-	else if (nowGPSIns.ins_heading_angle >= 270 && nowGPSIns.ins_heading_angle <= 360)
-	{
-		origin_x = nowGPSIns.gps_x - vehLenthAdj*sin((360 - nowGPSIns.ins_heading_angle)*PI / 180);
-		origin_y = nowGPSIns.gps_y + vehLenthAdj*cos((360 - nowGPSIns.ins_heading_angle)*PI / 180);
-	}
-
-}
-
-
-
-
-/*
-	开启自动驾驶模式时,先获取离汽车距离最近的路径点
-*/
-
- void iv::decition::DecitionMaker::getStartPoint(iv::GPS_INS nowGPSIns, const std::vector<iv::GPSData> navigation_data) {
-	 double minDistance,distance;
-	 for (int i = lastNearPointNum; i < navigation_data.size(); i++)
-	 {
-		 distance = DirectDistance(origin_x, origin_y,(navigation_data[i])->gps_x, (navigation_data[i])->gps_y);
-//		 distance = CalcDistance(gps_ins.gps_lat, gps_ins.gps_lng, (navigation_data[i])->gps_lat, (navigation_data[i])->gps_lng);
-		 if (i==0)
-		 {
-			 minDistance = distance;
-		 }
-		 else {
-			 if (distance<minDistance)
-			 {
-				 minDistance = distance;
-				 lastNearPointNum = i;
-                 std::cout << "lastnearestpoint: %d\n" << lastNearPointNum << std::endl;
-//				 ODS("minDistance: %d\n", minDistance);
-			 }
-		 }
-	 }
-
-}
-
-
-
- /*
-     根据GPS坐标计算两点距离
- */
-
-double iv::decition::DecitionMaker::getDistanceDeviation(iv::GPS_INS nowGPSIns, iv::GPS_INS nearestGPSIns) {
-	return	CalcDistance((nearestGPSIns).gps_lat, (nearestGPSIns).gps_lng, (nowGPSIns).gps_lat, (nowGPSIns).gps_lng);
-}
-
-
-/*
-    根据GPS坐标计算汽车与目标点之间的角度
-*/
-
-double iv::decition::DecitionMaker::getCrossAngle(iv::GPS_INS nowGPSIns, iv::GPS_INS nearestGPSIns) {
-	const double PI = 3.1415926535898;
-	double hypo = CalcDistance((nearestGPSIns).gps_lat, (nearestGPSIns).gps_lng, (nowGPSIns).gps_lat, (nowGPSIns).gps_lng);
-	double hor = CalcDistance((nearestGPSIns).gps_lat, (nearestGPSIns).gps_lng, (nearestGPSIns).gps_lat, (nowGPSIns).gps_lng);
-	double ang = asin(hor / hypo) / PI * 180;
-	double guideAng;
-	double crossAng; //顺时针是正直,逆时针是负值
-	if (((nearestGPSIns).gps_lat - (nowGPSIns).gps_lat >= 0) && ((nearestGPSIns).gps_lng - (nowGPSIns).gps_lng >= 0)) {
-		guideAng = ang;
-		//ang = 90 - ang;
-	}
-	else if (((nearestGPSIns).gps_lat - (nowGPSIns).gps_lat >= 0) && ((nearestGPSIns).gps_lng - (nowGPSIns).gps_lng <= 0))
-	{
-		guideAng = 360 - ang;
-		//ang = ang + 90;
-		
-	}
-	else if (((nearestGPSIns).gps_lat - (nowGPSIns).gps_lat <= 0) && ((nearestGPSIns).gps_lng - (nowGPSIns).gps_lng >= 0))
-	{
-		guideAng = 180 - ang;
-		//ang = ang - 90;
-	}
-	else  if (((nearestGPSIns).gps_lat - (nowGPSIns).gps_lat <= 0) && ((nearestGPSIns).gps_lng - (nowGPSIns).gps_lng <= 0))
-	{
-		guideAng = 180 + ang;
-		//ang = -90 - ang;
-	}
-
-	crossAng = guideAng - nowGPSIns.ins_heading_angle;
-	if (crossAng<-180)
-	{
-		crossAng = crossAng + 360;
-	}
-	else if (crossAng > 180) {
-		crossAng = crossAng - 360;
-	}
-	
-	
-	return crossAng;
-
-}
-
-/*
-	根据直角坐标计算汽车与目标点之间的角度
-*/
-
-double iv::decition::DecitionMaker::getDirectCrossAngle(iv::GPS_INS nowGPSIns, iv::GPS_INS objGPSIns) {
-
-	//double ang = DirectAngle(nowGPSIns.gps_x, nowGPSIns.gps_y,objGPSIns.gps_x,objGPSIns.gps_y);
-	double ang = DirectAngle(origin_x, origin_y, objGPSIns.gps_x, objGPSIns.gps_y);
-	double guideAng; //追随目标所需航向角
-	double crossAng; //顺时针是正直,逆时针是负值
-	if (((objGPSIns).gps_y - origin_y >= 0) && ((objGPSIns).gps_x - origin_x >= 0)) {
-		guideAng = 90 - ang;
-		//ang = 90 - ang;
-	}
-	else if (((objGPSIns).gps_y - origin_y >= 0) && ((objGPSIns).gps_x - origin_x <= 0))
-	{
-		guideAng = 270 - ang;
-		//ang = ang + 90;
-
-	}
-	else if (((objGPSIns).gps_y - origin_y <= 0) && ((objGPSIns).gps_x - origin_x >= 0))
-	{
-		guideAng = 90 - ang;
-		//ang = ang - 90;
-	}
-	else  if (((objGPSIns).gps_y - origin_y <= 0) && ((objGPSIns).gps_x - origin_x <= 0))
-	{
-		guideAng = 270 - ang;
-		//ang = -90 - ang;
-	}
-
-	crossAng = guideAng - nowGPSIns.ins_heading_angle;
-	if (crossAng<-180)
-	{
-		crossAng = crossAng + 360;
-	}
-	else if (crossAng > 180) {
-		crossAng = crossAng - 360;
-	}
-	return crossAng;
-}
-
-
-
-
-
-/*
-		根据GPS坐标搜索最近的车前路径点
-*/
-
-iv::GPS_INS iv::decition::DecitionMaker::getNearestGpsIns(iv::GPS_INS gps_ins, const std::vector<iv::GPSData> navigation_data) {
-	
-	GPS_INS lastNearPoint = *(navigation_data[lastNearPointNum]);
-
-	int count = navigation_data.size();
-
-	if ((lastNearPoint).ins_heading_angle <= 45 || (lastNearPoint).ins_heading_angle >= 315) {
-		for (int i = lastNearPointNum; i < count; i++) {
-			GPS_INS nearGNS = *(navigation_data[i]);
-
-			if ((nearGNS).gps_y>origin_y)
-			{
-				lastNearPointNum = i;
-				return nearGNS;
-			}
-		}
-	}
-	else if ((lastNearPoint).ins_heading_angle >= 45 && (lastNearPoint).ins_heading_angle <= 135) {
-
-		for (int i = lastNearPointNum; i < count; i++)
-		{
-			GPS_INS nearGNS = *(navigation_data[i]);
-
-			if ((nearGNS).gps_x>origin_x)
-			{
-				lastNearPointNum = i;
-				return nearGNS;
-			}
-		}
-
-	}
-	else if ((lastNearPoint).ins_heading_angle >= 135 && (lastNearPoint).ins_heading_angle <= 225) {
-
-		for (int i = lastNearPointNum; i < count; i++)
-		{
-			GPS_INS nearGNS = *(navigation_data[i]);
-
-			if ((nearGNS).gps_y<origin_y)
-			{
-				lastNearPointNum = i;
-				return nearGNS;
-			}
-		}
-
-	}
-	else if ((lastNearPoint).ins_heading_angle >= 225 && (lastNearPoint).ins_heading_angle <= 315) {
-
-		for (int i = lastNearPointNum; i < count; i++)
-		{
-			GPS_INS nearGNS = *(navigation_data[i]);
-
-			if ((nearGNS).gps_x<origin_x)
-			{
-				lastNearPointNum = i;
-				return nearGNS;
-			}
-		}
-
-	}
-
-	return lastNearPoint;
-}
-
-
-/*
-  判断是否到达终点
-*/
-
-bool iv::decition::DecitionMaker::checkComplete(GPS_INS nowGPSIns, const std::vector<iv::GPSData> navigation_data) {
-	if (lastNearPointNum < navigation_data.size() - 1) {
-		return false;
-	}
-	
-	GPS_INS lastNearPoint = *(navigation_data[lastNearPointNum]);
-
-	if ((lastNearPoint).ins_heading_angle <= 45 || (lastNearPoint).ins_heading_angle >= 315) {
-		if (origin_y>=lastNearPoint.gps_y)
-		{
-			return true;
-		}
-	}
-	else if ((lastNearPoint).ins_heading_angle >= 45 && (lastNearPoint).ins_heading_angle <= 135) {
-		if (origin_x >= lastNearPoint.gps_x)
-		{
-			return true;
-		}
-		
-
-	}
-	else if ((lastNearPoint).ins_heading_angle >= 135 && (lastNearPoint).ins_heading_angle <= 225) {
-
-		if (origin_y <= lastNearPoint.gps_y)
-		{
-			return true;
-		}
-
-	}
-	else if ((lastNearPoint).ins_heading_angle >= 225 && (lastNearPoint).ins_heading_angle <= 315) {
-
-		if (origin_x <= lastNearPoint.gps_x)
-		{
-			return true;
-		}
-
-	}
-
-	return false;
-
-}
-
-
-
-
-
-
-/*
-	计算输出车速
-*/
-
-float iv::decition::DecitionMaker::getSpeedObj(GPS_INS nowGPSIns, GPS_INS objGPSIns) {
-	float speed;
-	int speedMode = objGPSIns.speed_mode;
-	/*switch (speedMode)
-	{
-	case 0:
-		nearSpeed = 0;
-		break;
-	case 1:
-		nearSpeed = 0;
-		break;
-	case 2:
-		nearSpeed = 0;
-		break;
-	case 3:
-		nearSpeed = 0;
-		break;
-	case 4:
-		nearSpeed = 0;
-		break;
-	case 5:
-		nearSpeed = 0;
-		break;
-	case 6:
-		nearSpeed = 0;
-		break;
-	case 7:
-		nearSpeed = 0;
-		break;
-	case 8:
-		nearSpeed = 0;
-		break;
-	default:
-		break;
-	}*/
-
-	float objSpeed = objGPSIns.speed;
-	float nowSpeed = nowGPSIns.speed;
-	if (objSpeed >nowSpeed) {
-		speed = nowGPSIns.speed + 1;
-	}
-	else if (objSpeed<nowSpeed)
-	{
-		speed = nowGPSIns.speed - 1;
-	}
-	else
-	{
-		speed = objSpeed;
-	}
-	return speed;
-}
-
-/*
-   检验车与目标轨迹距离是否偏大
-*/
-
-void iv::decition::DecitionMaker::checkDistance(GPS_INS nowGPSIns, const std::vector<iv::GPSData> navigation_data,double maxDistance) {
-	  double distanceF = DirectDistance(nowGPSIns.gps_x, nowGPSIns.gps_y, (navigation_data[lastNearPointNum])->gps_x, (navigation_data[lastNearPointNum])->gps_y);	
-	  if (distanceF>maxDistance)
-	  {
-        std::cout << "您已远离目标路线\n" << std::endl;
-	  }
-}
-
-
-string getTime()
-{
-	time_t timep;
-	time(&timep);
-	char tmp[64];
-	strftime(tmp, sizeof(tmp), "%Y-%m-%d %H:%M:%S", localtime(&timep));
-	return tmp;
-}
-
-/*
-	给出GPS决策Decition
-*/
-iv::decition::Decition iv::decition::DecitionMaker::getDecideForGPS(iv::GPS_INS now_gps_ins, const std::vector<iv::GPSData> navigation_data) {
-	Decition gps_decition(new DecitionBasic);
-	//DecitionBasic decitionBasic;
-	int aheadNum;
-	if (now_gps_ins.speed_mode>2)
-	{
-		aheadNum = 48;
-	}
-	else {
-		aheadNum = 48;
-	}
-	origin_x = now_gps_ins.gps_x;
-	origin_y = now_gps_ins.gps_y;
-	adjustOriginPoint(now_gps_ins);
-	
-	if (isFirstRun)
-	{
-		getStartPoint(now_gps_ins, navigation_data);
-		isFirstRun = false;
-	}
-	nearestGpsIns = getNearestGpsIns(now_gps_ins, navigation_data);
-    std::cout << "\nlast :%d\t%f\t%f \n" << lastNearPointNum << now_gps_ins.gps_lat << now_gps_ins.gps_lng << std::endl;
-    std::cout << "nearest index: %d\t%f\t%f\n" << nearestGpsIns.index << nearestGpsIns.gps_lat << nearestGpsIns.gps_lng <<std::endl;
-	if (!checkComplete(now_gps_ins, navigation_data))
-	{
-		objPointNum = lastNearPointNum+aheadNum;
-		if (objPointNum > navigation_data.size()-1)
-			objPointNum = aheadNum -1;
-		objGpsIns = *(navigation_data[objPointNum]);
-		double angle = getDirectCrossAngle(now_gps_ins, objGpsIns);
-
-	//	checkDistance(now_gps_ins, navigation_data, 5000);
-
-		gps_decition->speed = getSpeedObj(now_gps_ins, nearestGpsIns);
-		if (angle>5||angle<-5)
-		{
-			gps_decition->wheel_angle = angle;
-		}
-		else
-		{
-			gps_decition->wheel_angle = 0;
-		}
-		//string time = getTime();
-		//ODS("当前时间: %s\n", lastNearPointNum);
-		gps_decition->wheel_angle = 0 - gps_decition->wheel_angle*40;
-		if (gps_decition->wheel_angle > 4000) {
-			gps_decition->wheel_angle = 4000;
-		}
-		if (gps_decition->wheel_angle < -4000) {
-			gps_decition->wheel_angle = -4000;
-		}
-	}
-	else {
-		gps_decition->wheel_angle = 0;
-		gps_decition->speed = 0;
-	}
-	
-	return gps_decition;
-
-}
-
-
-//string iv::decition::DecitionMaker::getTime()
-// {
-//	     time_t timep;
-//	     time(&timep);
-//	     char tmp[64];
-//	     strftime(tmp, sizeof(tmp), "%Y-%m-%d %H:%M:%S", localtime(&timep));
-//	    return tmp;
-//}
-
-
-/*iv::GPS_INS iv::decition::DecitionMaker::getNearestGpsIns(iv::GPS_INS gps_ins) {
-
-GPS_INS lastNearPoint = vec_Gps_Group[lastNearPointNum];
-
-int count = vec_Gps_Group.size();
-
-if ((lastNearPoint).ins_heading_angle <= 45 || (lastNearPoint).ins_heading_angle >= 315) {
-for (int i = lastNearPointNum; i < count;i++) {
-GPS_INS objGD = vec_Gps_Group[i];
-
-if ((objGD).gps_lat>(gps_ins).gps_lat)
-{
-lastNearPointNum = i;
-return objGD;
-}
-}
-}
-else if ((lastNearPoint).ins_heading_angle >= 45 && (lastNearPoint).ins_heading_angle <= 135) {
-
-for (int i = lastNearPointNum; i < count;i++)
-{
-GPS_INS objGD = vec_Gps_Group[i];
-
-if ((objGD).gps_lng>(gps_ins).gps_lng)
-{
-lastNearPointNum = i;
-return objGD;
-}
-}
-
-}
-else if ((lastNearPoint).ins_heading_angle >= 135 && (lastNearPoint).ins_heading_angle <= 225) {
-
-for (int i = lastNearPointNum; i < count;i++)
-{
-GPS_INS objGD = vec_Gps_Group[i];
-
-if ((objGD).gps_lat<(gps_ins).gps_lat)
-{
-lastNearPointNum = i;
-return objGD;
-}
-}
-
-}
-else if ((lastNearPoint).ins_heading_angle >= 225 && (lastNearPoint).ins_heading_angle <= 315) {
-
-for (int i = lastNearPointNum; i < count;i++)
-{
-GPS_INS objGD = vec_Gps_Group[i];
-
-if ((objGD).gps_lng<(gps_ins).gps_lng)
-{
-lastNearPointNum = i;
-return objGD;
-}
-}
-
-}
-
-return lastNearPoint;
-}*/
-
-
-
-/*iv::decition::Decition iv::decition::DecitionMaker::getDecideForGPS(iv::GPS_INS now_gps_ins) {
-	Decition gps_decition(new DecitionBasic);
-	//DecitionBasic decitionBasic;
-	nearestGpsIns = getNearestGpsIns(now_gps_ins);
-	double angle = getCrossAngle(now_gps_ins, nearestGpsIns);
-
-	gps_decition->speed = getSpeedObj(now_gps_ins, nearestGpsIns);
-	gps_decition->wheel_angle = angle;
-	return gps_decition;
-
-}*/
-
-
-/*void iv::decition::DecitionMaker::readFromText() {
-
-	ifstream infile;
-	infile.open("D:\\auto_car\\gps_trace.txt");
-	if (!infile) cout << "error" << endl;
-	string str;
-	int t1 = 0;
-	
-	
-	while (getline(infile, str))   //按行读取,遇到换行符结束
-	{
-
-		
-		cout << str << endl;
-		GPS_INS gps_Ins;
-
-		while (infile >> str)
-		{
-			// ODS("%s\n", str);
-			
-			cout << str << endl;
-			t1++;
-			if (t1 == 2)
-			{
-				gps_Ins.gps_lng = stod(str);
-			}
-			else if (t1 == 3)
-			{
-				gps_Ins.gps_lat = stod(str);
-			}
-			else if (t1 == 4)
-			{
-				gps_Ins.speed = stod(str);
-			}
-			else if (t1 == 6)
-			{
-				gps_Ins.ins_heading_angle = stod(str);
-				vec_Gps_Group.push_back(gps_Ins);
-				t1 = 0;
-			}
-		}
-		
-		
-	}
-	infile.close();
-}*/
-
-
-
-
+#include <decition/decition_maker.h>
+#include <decition/gps_distance.h>
+#include <decition/decition_type.h>
+#include <math.h>
+#include <iostream>
+#include <fstream>
+using namespace std;
+
+
+iv::decition::DecitionMaker::DecitionMaker() {
+
+}
+iv::decition::DecitionMaker::~DecitionMaker() {
+
+}
+
+
+
+
+
+
+/* void iv::decition::DecitionMaker::decideFromGPS(Decition & gps_decition, iv::GPSData gps_data, const std::vector<iv::GPSData> navigation_data)
+{
+	//可直接获取车速  方法咨询张庆余
+
+	//样例
+	//输入数据类型
+	gps_data->gps_x;
+	gps_data->gps_y;
+	gps_data->gps_z;
+	gps_data->ins_heading_angle;	//航向角
+	gps_data->ins_pitch_angle;		//俯仰角
+	gps_data->ins_roll_angle;		//横滚角
+
+									//导航数据
+	navigation_data[0]->gps_x;
+	navigation_data[1]->gps_y;
+	for (std::vector<iv::GPSData>::const_iterator it = navigation_data.cbegin(); it != navigation_data.cend(); it++) {
+		//std::cout << (*it)->gps_x << std::endl;
+	}
+
+	//输出
+	gps_decition->speed = 30;
+	gps_decition->wheel_angle = 10;
+
+}*/
+
+
+void iv::decition::DecitionMaker::adjustOriginPoint(iv::GPS_INS nowGPSIns) {
+	const double PI = 3.1415926535898;
+	if (nowGPSIns.ins_heading_angle >= 0 && nowGPSIns.ins_heading_angle <= 90) {
+		origin_x = nowGPSIns.gps_x + vehLenthAdj*sin(nowGPSIns.ins_heading_angle*PI / 180);
+		origin_y = nowGPSIns.gps_y + vehLenthAdj*cos(nowGPSIns.ins_heading_angle*PI / 180);
+	}
+	else if (nowGPSIns.ins_heading_angle >= 90 && nowGPSIns.ins_heading_angle <= 180)
+	{
+		origin_x = nowGPSIns.gps_x + vehLenthAdj*sin((180 - nowGPSIns.ins_heading_angle)*PI / 180);
+		origin_y = nowGPSIns.gps_y - vehLenthAdj*cos((180 - nowGPSIns.ins_heading_angle)*PI / 180);
+	}
+	else  if (nowGPSIns.ins_heading_angle >= 180 && nowGPSIns.ins_heading_angle <= 270)
+	{
+		origin_x = nowGPSIns.gps_x - vehLenthAdj*sin((nowGPSIns.ins_heading_angle - 180)*PI / 180);
+		origin_y = nowGPSIns.gps_y - vehLenthAdj*cos((nowGPSIns.ins_heading_angle - 180)*PI / 180);
+	}
+	else if (nowGPSIns.ins_heading_angle >= 270 && nowGPSIns.ins_heading_angle <= 360)
+	{
+		origin_x = nowGPSIns.gps_x - vehLenthAdj*sin((360 - nowGPSIns.ins_heading_angle)*PI / 180);
+		origin_y = nowGPSIns.gps_y + vehLenthAdj*cos((360 - nowGPSIns.ins_heading_angle)*PI / 180);
+	}
+
+}
+
+
+
+
+/*
+	开启自动驾驶模式时,先获取离汽车距离最近的路径点
+*/
+
+ void iv::decition::DecitionMaker::getStartPoint(iv::GPS_INS nowGPSIns, const std::vector<iv::GPSData> navigation_data) {
+	 double minDistance,distance;
+	 for (int i = lastNearPointNum; i < navigation_data.size(); i++)
+	 {
+		 distance = DirectDistance(origin_x, origin_y,(navigation_data[i])->gps_x, (navigation_data[i])->gps_y);
+//		 distance = CalcDistance(gps_ins.gps_lat, gps_ins.gps_lng, (navigation_data[i])->gps_lat, (navigation_data[i])->gps_lng);
+		 if (i==0)
+		 {
+			 minDistance = distance;
+		 }
+		 else {
+			 if (distance<minDistance)
+			 {
+				 minDistance = distance;
+				 lastNearPointNum = i;
+                 std::cout << "lastnearestpoint: %d\n" << lastNearPointNum << std::endl;
+//				 ODS("minDistance: %d\n", minDistance);
+			 }
+		 }
+	 }
+
+}
+
+
+
+ /*
+     根据GPS坐标计算两点距离
+ */
+
+double iv::decition::DecitionMaker::getDistanceDeviation(iv::GPS_INS nowGPSIns, iv::GPS_INS nearestGPSIns) {
+	return	CalcDistance((nearestGPSIns).gps_lat, (nearestGPSIns).gps_lng, (nowGPSIns).gps_lat, (nowGPSIns).gps_lng);
+}
+
+
+/*
+    根据GPS坐标计算汽车与目标点之间的角度
+*/
+
+double iv::decition::DecitionMaker::getCrossAngle(iv::GPS_INS nowGPSIns, iv::GPS_INS nearestGPSIns) {
+	const double PI = 3.1415926535898;
+	double hypo = CalcDistance((nearestGPSIns).gps_lat, (nearestGPSIns).gps_lng, (nowGPSIns).gps_lat, (nowGPSIns).gps_lng);
+	double hor = CalcDistance((nearestGPSIns).gps_lat, (nearestGPSIns).gps_lng, (nearestGPSIns).gps_lat, (nowGPSIns).gps_lng);
+	double ang = asin(hor / hypo) / PI * 180;
+	double guideAng;
+	double crossAng; //顺时针是正直,逆时针是负值
+	if (((nearestGPSIns).gps_lat - (nowGPSIns).gps_lat >= 0) && ((nearestGPSIns).gps_lng - (nowGPSIns).gps_lng >= 0)) {
+		guideAng = ang;
+		//ang = 90 - ang;
+	}
+	else if (((nearestGPSIns).gps_lat - (nowGPSIns).gps_lat >= 0) && ((nearestGPSIns).gps_lng - (nowGPSIns).gps_lng <= 0))
+	{
+		guideAng = 360 - ang;
+		//ang = ang + 90;
+		
+	}
+	else if (((nearestGPSIns).gps_lat - (nowGPSIns).gps_lat <= 0) && ((nearestGPSIns).gps_lng - (nowGPSIns).gps_lng >= 0))
+	{
+		guideAng = 180 - ang;
+		//ang = ang - 90;
+	}
+	else  if (((nearestGPSIns).gps_lat - (nowGPSIns).gps_lat <= 0) && ((nearestGPSIns).gps_lng - (nowGPSIns).gps_lng <= 0))
+	{
+		guideAng = 180 + ang;
+		//ang = -90 - ang;
+	}
+
+	crossAng = guideAng - nowGPSIns.ins_heading_angle;
+	if (crossAng<-180)
+	{
+		crossAng = crossAng + 360;
+	}
+	else if (crossAng > 180) {
+		crossAng = crossAng - 360;
+	}
+	
+	
+	return crossAng;
+
+}
+
+/*
+	根据直角坐标计算汽车与目标点之间的角度
+*/
+
+double iv::decition::DecitionMaker::getDirectCrossAngle(iv::GPS_INS nowGPSIns, iv::GPS_INS objGPSIns) {
+
+	//double ang = DirectAngle(nowGPSIns.gps_x, nowGPSIns.gps_y,objGPSIns.gps_x,objGPSIns.gps_y);
+	double ang = DirectAngle(origin_x, origin_y, objGPSIns.gps_x, objGPSIns.gps_y);
+	double guideAng; //追随目标所需航向角
+	double crossAng; //顺时针是正直,逆时针是负值
+	if (((objGPSIns).gps_y - origin_y >= 0) && ((objGPSIns).gps_x - origin_x >= 0)) {
+		guideAng = 90 - ang;
+		//ang = 90 - ang;
+	}
+	else if (((objGPSIns).gps_y - origin_y >= 0) && ((objGPSIns).gps_x - origin_x <= 0))
+	{
+		guideAng = 270 - ang;
+		//ang = ang + 90;
+
+	}
+	else if (((objGPSIns).gps_y - origin_y <= 0) && ((objGPSIns).gps_x - origin_x >= 0))
+	{
+		guideAng = 90 - ang;
+		//ang = ang - 90;
+	}
+	else  if (((objGPSIns).gps_y - origin_y <= 0) && ((objGPSIns).gps_x - origin_x <= 0))
+	{
+		guideAng = 270 - ang;
+		//ang = -90 - ang;
+	}
+
+	crossAng = guideAng - nowGPSIns.ins_heading_angle;
+	if (crossAng<-180)
+	{
+		crossAng = crossAng + 360;
+	}
+	else if (crossAng > 180) {
+		crossAng = crossAng - 360;
+	}
+	return crossAng;
+}
+
+
+
+
+
+/*
+		根据GPS坐标搜索最近的车前路径点
+*/
+
+iv::GPS_INS iv::decition::DecitionMaker::getNearestGpsIns(iv::GPS_INS gps_ins, const std::vector<iv::GPSData> navigation_data) {
+	
+	GPS_INS lastNearPoint = *(navigation_data[lastNearPointNum]);
+
+	int count = navigation_data.size();
+
+	if ((lastNearPoint).ins_heading_angle <= 45 || (lastNearPoint).ins_heading_angle >= 315) {
+		for (int i = lastNearPointNum; i < count; i++) {
+			GPS_INS nearGNS = *(navigation_data[i]);
+
+			if ((nearGNS).gps_y>origin_y)
+			{
+				lastNearPointNum = i;
+				return nearGNS;
+			}
+		}
+	}
+	else if ((lastNearPoint).ins_heading_angle >= 45 && (lastNearPoint).ins_heading_angle <= 135) {
+
+		for (int i = lastNearPointNum; i < count; i++)
+		{
+			GPS_INS nearGNS = *(navigation_data[i]);
+
+			if ((nearGNS).gps_x>origin_x)
+			{
+				lastNearPointNum = i;
+				return nearGNS;
+			}
+		}
+
+	}
+	else if ((lastNearPoint).ins_heading_angle >= 135 && (lastNearPoint).ins_heading_angle <= 225) {
+
+		for (int i = lastNearPointNum; i < count; i++)
+		{
+			GPS_INS nearGNS = *(navigation_data[i]);
+
+			if ((nearGNS).gps_y<origin_y)
+			{
+				lastNearPointNum = i;
+				return nearGNS;
+			}
+		}
+
+	}
+	else if ((lastNearPoint).ins_heading_angle >= 225 && (lastNearPoint).ins_heading_angle <= 315) {
+
+		for (int i = lastNearPointNum; i < count; i++)
+		{
+			GPS_INS nearGNS = *(navigation_data[i]);
+
+			if ((nearGNS).gps_x<origin_x)
+			{
+				lastNearPointNum = i;
+				return nearGNS;
+			}
+		}
+
+	}
+
+	return lastNearPoint;
+}
+
+
+/*
+  判断是否到达终点
+*/
+
+bool iv::decition::DecitionMaker::checkComplete(GPS_INS nowGPSIns, const std::vector<iv::GPSData> navigation_data) {
+	if (lastNearPointNum < navigation_data.size() - 1) {
+		return false;
+	}
+	
+	GPS_INS lastNearPoint = *(navigation_data[lastNearPointNum]);
+
+	if ((lastNearPoint).ins_heading_angle <= 45 || (lastNearPoint).ins_heading_angle >= 315) {
+		if (origin_y>=lastNearPoint.gps_y)
+		{
+			return true;
+		}
+	}
+	else if ((lastNearPoint).ins_heading_angle >= 45 && (lastNearPoint).ins_heading_angle <= 135) {
+		if (origin_x >= lastNearPoint.gps_x)
+		{
+			return true;
+		}
+		
+
+	}
+	else if ((lastNearPoint).ins_heading_angle >= 135 && (lastNearPoint).ins_heading_angle <= 225) {
+
+		if (origin_y <= lastNearPoint.gps_y)
+		{
+			return true;
+		}
+
+	}
+	else if ((lastNearPoint).ins_heading_angle >= 225 && (lastNearPoint).ins_heading_angle <= 315) {
+
+		if (origin_x <= lastNearPoint.gps_x)
+		{
+			return true;
+		}
+
+	}
+
+	return false;
+
+}
+
+
+
+
+
+
+/*
+	计算输出车速
+*/
+
+float iv::decition::DecitionMaker::getSpeedObj(GPS_INS nowGPSIns, GPS_INS objGPSIns) {
+	float speed;
+	int speedMode = objGPSIns.speed_mode;
+	/*switch (speedMode)
+	{
+	case 0:
+		nearSpeed = 0;
+		break;
+	case 1:
+		nearSpeed = 0;
+		break;
+	case 2:
+		nearSpeed = 0;
+		break;
+	case 3:
+		nearSpeed = 0;
+		break;
+	case 4:
+		nearSpeed = 0;
+		break;
+	case 5:
+		nearSpeed = 0;
+		break;
+	case 6:
+		nearSpeed = 0;
+		break;
+	case 7:
+		nearSpeed = 0;
+		break;
+	case 8:
+		nearSpeed = 0;
+		break;
+	default:
+		break;
+	}*/
+
+	float objSpeed = objGPSIns.speed;
+	float nowSpeed = nowGPSIns.speed;
+	if (objSpeed >nowSpeed) {
+		speed = nowGPSIns.speed + 1;
+	}
+	else if (objSpeed<nowSpeed)
+	{
+		speed = nowGPSIns.speed - 1;
+	}
+	else
+	{
+		speed = objSpeed;
+	}
+	return speed;
+}
+
+/*
+   检验车与目标轨迹距离是否偏大
+*/
+
+void iv::decition::DecitionMaker::checkDistance(GPS_INS nowGPSIns, const std::vector<iv::GPSData> navigation_data,double maxDistance) {
+	  double distanceF = DirectDistance(nowGPSIns.gps_x, nowGPSIns.gps_y, (navigation_data[lastNearPointNum])->gps_x, (navigation_data[lastNearPointNum])->gps_y);	
+	  if (distanceF>maxDistance)
+	  {
+        std::cout << "您已远离目标路线\n" << std::endl;
+	  }
+}
+
+
+string getTime()
+{
+	time_t timep;
+	time(&timep);
+	char tmp[64];
+	strftime(tmp, sizeof(tmp), "%Y-%m-%d %H:%M:%S", localtime(&timep));
+	return tmp;
+}
+
+/*
+	给出GPS决策Decition
+*/
+iv::decition::Decition iv::decition::DecitionMaker::getDecideForGPS(iv::GPS_INS now_gps_ins, const std::vector<iv::GPSData> navigation_data) {
+	Decition gps_decition(new DecitionBasic);
+	//DecitionBasic decitionBasic;
+	int aheadNum;
+	if (now_gps_ins.speed_mode>2)
+	{
+		aheadNum = 48;
+	}
+	else {
+		aheadNum = 48;
+	}
+	origin_x = now_gps_ins.gps_x;
+	origin_y = now_gps_ins.gps_y;
+	adjustOriginPoint(now_gps_ins);
+	
+	if (isFirstRun)
+	{
+		getStartPoint(now_gps_ins, navigation_data);
+		isFirstRun = false;
+	}
+	nearestGpsIns = getNearestGpsIns(now_gps_ins, navigation_data);
+    std::cout << "\nlast :%d\t%f\t%f \n" << lastNearPointNum << now_gps_ins.gps_lat << now_gps_ins.gps_lng << std::endl;
+    std::cout << "nearest index: %d\t%f\t%f\n" << nearestGpsIns.index << nearestGpsIns.gps_lat << nearestGpsIns.gps_lng <<std::endl;
+	if (!checkComplete(now_gps_ins, navigation_data))
+	{
+		objPointNum = lastNearPointNum+aheadNum;
+		if (objPointNum > navigation_data.size()-1)
+			objPointNum = aheadNum -1;
+		objGpsIns = *(navigation_data[objPointNum]);
+		double angle = getDirectCrossAngle(now_gps_ins, objGpsIns);
+
+	//	checkDistance(now_gps_ins, navigation_data, 5000);
+
+		gps_decition->speed = getSpeedObj(now_gps_ins, nearestGpsIns);
+		if (angle>5||angle<-5)
+		{
+			gps_decition->wheel_angle = angle;
+		}
+		else
+		{
+			gps_decition->wheel_angle = 0;
+		}
+		//string time = getTime();
+		//ODS("当前时间: %s\n", lastNearPointNum);
+		gps_decition->wheel_angle = 0 - gps_decition->wheel_angle*40;
+		if (gps_decition->wheel_angle > 4000) {
+			gps_decition->wheel_angle = 4000;
+		}
+		if (gps_decition->wheel_angle < -4000) {
+			gps_decition->wheel_angle = -4000;
+		}
+	}
+	else {
+		gps_decition->wheel_angle = 0;
+		gps_decition->speed = 0;
+	}
+	
+	return gps_decition;
+
+}
+
+
+//string iv::decition::DecitionMaker::getTime()
+// {
+//	     time_t timep;
+//	     time(&timep);
+//	     char tmp[64];
+//	     strftime(tmp, sizeof(tmp), "%Y-%m-%d %H:%M:%S", localtime(&timep));
+//	    return tmp;
+//}
+
+
+/*iv::GPS_INS iv::decition::DecitionMaker::getNearestGpsIns(iv::GPS_INS gps_ins) {
+
+GPS_INS lastNearPoint = vec_Gps_Group[lastNearPointNum];
+
+int count = vec_Gps_Group.size();
+
+if ((lastNearPoint).ins_heading_angle <= 45 || (lastNearPoint).ins_heading_angle >= 315) {
+for (int i = lastNearPointNum; i < count;i++) {
+GPS_INS objGD = vec_Gps_Group[i];
+
+if ((objGD).gps_lat>(gps_ins).gps_lat)
+{
+lastNearPointNum = i;
+return objGD;
+}
+}
+}
+else if ((lastNearPoint).ins_heading_angle >= 45 && (lastNearPoint).ins_heading_angle <= 135) {
+
+for (int i = lastNearPointNum; i < count;i++)
+{
+GPS_INS objGD = vec_Gps_Group[i];
+
+if ((objGD).gps_lng>(gps_ins).gps_lng)
+{
+lastNearPointNum = i;
+return objGD;
+}
+}
+
+}
+else if ((lastNearPoint).ins_heading_angle >= 135 && (lastNearPoint).ins_heading_angle <= 225) {
+
+for (int i = lastNearPointNum; i < count;i++)
+{
+GPS_INS objGD = vec_Gps_Group[i];
+
+if ((objGD).gps_lat<(gps_ins).gps_lat)
+{
+lastNearPointNum = i;
+return objGD;
+}
+}
+
+}
+else if ((lastNearPoint).ins_heading_angle >= 225 && (lastNearPoint).ins_heading_angle <= 315) {
+
+for (int i = lastNearPointNum; i < count;i++)
+{
+GPS_INS objGD = vec_Gps_Group[i];
+
+if ((objGD).gps_lng<(gps_ins).gps_lng)
+{
+lastNearPointNum = i;
+return objGD;
+}
+}
+
+}
+
+return lastNearPoint;
+}*/
+
+
+
+/*iv::decition::Decition iv::decition::DecitionMaker::getDecideForGPS(iv::GPS_INS now_gps_ins) {
+	Decition gps_decition(new DecitionBasic);
+	//DecitionBasic decitionBasic;
+	nearestGpsIns = getNearestGpsIns(now_gps_ins);
+	double angle = getCrossAngle(now_gps_ins, nearestGpsIns);
+
+	gps_decition->speed = getSpeedObj(now_gps_ins, nearestGpsIns);
+	gps_decition->wheel_angle = angle;
+	return gps_decition;
+
+}*/
+
+
+/*void iv::decition::DecitionMaker::readFromText() {
+
+	ifstream infile;
+	infile.open("D:\\auto_car\\gps_trace.txt");
+	if (!infile) cout << "error" << endl;
+	string str;
+	int t1 = 0;
+	
+	
+	while (getline(infile, str))   //按行读取,遇到换行符结束
+	{
+
+		
+		cout << str << endl;
+		GPS_INS gps_Ins;
+
+		while (infile >> str)
+		{
+			// ODS("%s\n", str);
+			
+			cout << str << endl;
+			t1++;
+			if (t1 == 2)
+			{
+				gps_Ins.gps_lng = stod(str);
+			}
+			else if (t1 == 3)
+			{
+				gps_Ins.gps_lat = stod(str);
+			}
+			else if (t1 == 4)
+			{
+				gps_Ins.speed = stod(str);
+			}
+			else if (t1 == 6)
+			{
+				gps_Ins.ins_heading_angle = stod(str);
+				vec_Gps_Group.push_back(gps_Ins);
+				t1 = 0;
+			}
+		}
+		
+		
+	}
+	infile.close();
+}*/
+
+
+
+

+ 3616 - 3616
src/decition/decition_brain/decition/decide_gps_00.cpp

@@ -1,3616 +1,3616 @@
-#include <decition/decide_gps_00.h>
-#include <decition/adc_tools/compute_00.h>
-#include <decition/adc_tools/gps_distance.h>
-#include <decition/decition_type.h>
-#include <decition/adc_tools/transfer.h>
-#include <decition/obs_predict.h>
-#include <common/constants.h>
-#include <common/car_status.h>
-#include <math.h>
-#include <iostream>
-#include <fstream>
-#include <control/can.h>
-#include <time.h>
-#include <decition/adc_controller/base_controller.h>
-#include <decition/adc_controller/pid_controller.h>
-#include <decition/adc_planner/lane_change_planner.h>
-#include <decition/adc_planner/frenet_planner.h>
-#include <QTime>
-
-using namespace std;
-
-#include "ivlog.h"
-extern iv::Ivlog * givlog;
-
-#define PI (3.1415926535897932384626433832795)
-
-iv::decition::DecideGps00::DecideGps00() {
-
-}
-iv::decition::DecideGps00::~DecideGps00() {
-
-}
-
-float iv::decition::DecideGps00::xiuzhengCs=0;
-
-int iv::decition::DecideGps00::PathPoint = -1;
-double iv::decition::DecideGps00::minDis = iv::MaxValue;
-double iv::decition::DecideGps00::maxAngle = iv::MinValue;
-//int iv::decition::DecideGps00::lastGpsIndex = iv::MaxValue;
-int iv::decition::DecideGps00::lastGpsIndex = 0;
-double iv::decition::DecideGps00::controlSpeed = 0;
-double iv::decition::DecideGps00::controlBrake = 0;
-double iv::decition::DecideGps00::controlAng = 0;
-double iv::decition::DecideGps00::Iv = 0;
-double iv::decition::DecideGps00::lastU = 0;
-double iv::decition::DecideGps00::lastVt = 0;
-double iv::decition::DecideGps00::lastEv = 0;
-
-int iv::decition::DecideGps00::gpsLineParkIndex = 0;
-int iv::decition::DecideGps00::gpsMapParkIndex = 0;
-double iv::decition::DecideGps00::lastDistance = MaxValue;
-double iv::decition::DecideGps00::lastPreObsDistance = MaxValue;
-double iv::decition::DecideGps00::obsDistance = -1;
-double iv::decition::DecideGps00::obsSpeed=0;
-double iv::decition::DecideGps00::obsDistanceAvoid = -1;
-double iv::decition::DecideGps00::lastDistanceAvoid = -1;
-
-double iv::decition::DecideGps00::lidarDistance = -1;
-double iv::decition::DecideGps00::myesrDistance = -1;
-double iv::decition::DecideGps00::lastLidarDis = -1;
-
-bool iv::decition::DecideGps00::parkMode = false;
-bool iv::decition::DecideGps00::readyParkMode = false;
-
-bool iv::decition::DecideGps00::zhucheMode = false;
-bool iv::decition::DecideGps00::readyZhucheMode = false;
-bool iv::decition::DecideGps00::hasZhuched = false;
-
-double iv::decition::DecideGps00::lastLidarDisAvoid = -1;
-double iv::decition::DecideGps00::lidarDistanceAvoid = -1;
-
-int iv::decition::DecideGps00::finishPointNum = -1;
-int iv::decition::DecideGps00::zhuchePointNum = 0;
-
-///kkcai, 2020-01-03
-bool iv::decition::DecideGps00::isFirstRun = true;
-//////////////////////////////////////////////
-
-float iv::decition::DecideGps00::minDecelerate=0;
-//bool iv::decition::DecideGps00::startingFlag = true;//起步标志,在起步时需要进行frenet规划。
-
-double offset_real = 0;
-double realspeed;
-double dSpeed;
-double dSecSpeed;
-double secSpeed;
-double ac;
-
-
-iv::Point2D obsPoint(-1, -1);
-iv::Point2D obsPointAvoid(-1, -1);
-
-
-int esrIndex = -1;
-int esrIndexAvoid = -1;
-double obsSpeedAvoid = 0;
-
-double esrDistance = -1;
-double esrDistanceAvoid = -1;
-int obsLostTime = 0;
-int obsLostTimeAvoid = 0;
-
-// double avoidTime = 0;
-
-
-double avoidX =0;
-float roadWidth = 3.5;
-int roadSum =10;
-int roadNow = 0;
-int roadOri =0;
-int roadPre = -1;
-int lastRoadOri = 0;
-
-int lightTimes = 0;
-
-
-int lastRoadNum=1;
-
-int stopCount = 0;
-
-int gpsMissCount = 0;
-
-bool rapidStop = false;
-
-bool hasTrumpeted = false;
-
-
-bool changeRoad=false;
-//实验手刹
-bool handFirst = true;
-double handTimeSpan = 0;
-double handStartTime = 0;
-double handLastTime = 0;
-bool handPark = false;
-long handParkTime=10000;
-
-//喇叭
-bool trumpetFirstCount=true;
-double trumpetTimeSpan = 0;
-double trumpetStartTime = 0;
-double trumpetLastTime = 0;
-
-//过渡
-bool transferFirstCount=true;
-double transferTimeSpan = 0;
-double transferStartTime = 0;
-double transferLastTime = 0;
-
-bool busMode = false;
-bool parkBesideRoad=false;
-
-bool chaocheMode = false;
-bool specialSignle = false;
-
-double offsetX = 0;
-
-double steerSpeed=9000;
-
-bool transferPieriod;
-bool transferPieriod2;
-double traceDevi;
-
-bool startingFlag = true;  //起步标志,在起步时需要进行frenet规划。
-bool useFrenet = false;    //标志是否启用frenet算法避障
-bool useOldAvoid = true;   //标志是否用老方法避障
-
-enum VehState { normalRun, park, readyPark, stopObs, avoidObs, preAvoid, avoiding, backOri,preBack,
-                waitAvoid ,shoushaTest,justRun, changingRoad, chaoche, chaocheBack, reverseCar,reversing, reverseCircle, reverseDirect,reverseArr,
-                dRever,dRever0,dRever1,dRever2,dRever3,dRever4} vehState;
-
-
-std::vector<iv::Point2D>  gpsTraceAim; //记录变道后的目标路径,若车辆经frenet规划行驶至该路径上后,就关闭frenet规划
-std::vector<iv::Point2D>  gpsTraceAvoid,gpsTraceNow,gpsTraceBack,gpsTracePre,gpsTraceOri,gpsTraceRear;
-
-std::vector<double> esrDisVector(roadSum, -1);
-std::vector<double> lidarDisVector(roadSum, -1);
-std::vector<double> obsDisVector(roadSum,-1);
-std::vector<double> obsSpeedVector(roadSum, 0);
-
-std::vector<int> obsLostTimeVector(roadSum, 0);
-
-std::vector<double> lastLidarDisVector(roadSum, -1);
-std::vector<double> lastDistanceVector(roadSum, -1);
-
-bool qiedianCount = false;
-//日常展示
-
-iv::decition::Decition iv::decition::DecideGps00::getDecideFromGPS(GPS_INS now_gps_ins,
-                                                                   const std::vector<GPSData> gpsMapLine,
-                                                                   iv::LidarGridPtr lidarGridPtr,
-                                                                   std::vector<iv::Perception::PerceptionOutput> lidar_per,
-                                                                   iv::TrafficLight trafficLight)
-{
-    //   QTime xTime;
-    //    xTime.start();
-    //39.14034649083606 117.0863975920476 20507469.630314853  4334165.046101382 353
-    Decition gps_decition(new DecitionBasic);
-    //    vector<iv::Point2D> fpTraceTmp;
-
-
-    //如果useFrenet、useOldAvoid两者不互为相异,则采用原来的方法。“^”为异或运算符。
-    if(!(useFrenet^useOldAvoid)){
-        useFrenet = false;
-        useOldAvoid = true;
-    }
-
-    //    //如果useFrenet、useOldAvoid两者均为真或均为假,则采用原来的方法
-    //    if(useFrenet&&useOldAvoid || !useFrenet&&!useOldAvoid){
-    //        useFrenet = false;
-    //        useOldAvoid = true;
-    //    }
-
-    //  ServiceCarStatus.group_control=false;
-
-
-
-
-//    GPS_INS gps= Coordinate_UnTransfer(0,1.5,now_gps_ins);
-//    now_gps_ins.gps_x=gps.gps_x;
-//    now_gps_ins.gps_y=gps.gps_y;
-
-    //    GaussProjInvCal(now_gps_ins.gps_x, now_gps_ins.gps_y,&now_gps_ins.gps_lng, &now_gps_ins.gps_lat);
-
-
-    if (isFirstRun)
-    {
-        initMethods();
-        vehState = normalRun;
-        startAvoid_gps_ins = now_gps_ins;
-        init();
-        PathPoint = Compute00().getFirstNearestPointIndex(now_gps_ins, gpsMapLine,
-                                                          DecideGps00::lastGpsIndex,
-                                                          DecideGps00::minDis,
-                                                          DecideGps00::maxAngle);
-        DecideGps00::lastGpsIndex = PathPoint;
-
-        adjuseGpsLidarPosition();
-        if(ServiceCarStatus.speed_control==true){
-            Compute00().getDesiredSpeed(gpsMapLine);   //add by zj
-        }
-
-        //	ServiceCarStatus.carState = 1;
-        //        roadOri = gpsMapLine[PathPoint]->roadOri;
-        //        roadNow = roadOri;
-        //        roadSum = gpsMapLine[PathPoint]->roadSum;
-        //  busMode = false;
-        //  vehState = dRever;
-
-        double dis =  GetDistance(*gpsMapLine[0], *gpsMapLine[gpsMapLine.size()-1]);
-        if(dis<15){
-            circleMode=true;  //201200102
-        }else{
-            circleMode=false;
-        }
-        //     circleMode = true;
-
-
-        getV2XTrafficPositionVector(gpsMapLine);
-        //        group_ori_gps=*gpsMapLine[0];
-        ServiceCarStatus.bocheMode=false;
-        ServiceCarStatus.daocheMode=false;
-        parkMode=false;
-        readyParkMode=false;
-        finishPointNum=-1;
-        isFirstRun = false;
-    }
-
-
-    if(ServiceCarStatus.msysparam.gpsOffset_x!=0 || ServiceCarStatus.msysparam.gpsOffset_y!=0 ){
-        GPS_INS gpsOffset = Coordinate_UnTransfer(ServiceCarStatus.msysparam.gpsOffset_x, ServiceCarStatus.msysparam.gpsOffset_y, now_gps_ins);
-        now_gps_ins.gps_x=gpsOffset.gps_x;
-        now_gps_ins.gps_y=gpsOffset.gps_y;
-        GaussProjInvCal(now_gps_ins.gps_x,  now_gps_ins.gps_y, &now_gps_ins.gps_lng, &now_gps_ins.gps_lat);
-    }
-
-    //1227
-    //  ServiceCarStatus.daocheMode=true;
-
-    //1220
-    changingDangWei=false;
-
-    minDecelerate=0;
-    if(now_gps_ins.gps_lat<0||now_gps_ins.gps_lat>90){
-        //  int a=0;
-        gps_decition->wheel_angle = 0;
-        gps_decition->speed = dSpeed;
-
-        gps_decition->accelerator = -0.5;
-        gps_decition->brake=10;
-        return gps_decition;
-    }
-
-
-
-
-
-    //1220
-
-
-    if(ServiceCarStatus.daocheMode){
-
-        now_gps_ins.ins_heading_angle=now_gps_ins.ins_heading_angle+180;
-        if( now_gps_ins.ins_heading_angle>=360)
-            now_gps_ins.ins_heading_angle= now_gps_ins.ins_heading_angle-360;
-    }
-    //1220 end
-
-
-
-    //1125 traficc
-    traffic_light_gps.gps_lat=ServiceCarStatus.iTrafficeLightLat;
-    traffic_light_gps.gps_lng=ServiceCarStatus.iTrafficeLightLon;
-    GaussProjCal(traffic_light_gps.gps_lng,traffic_light_gps.gps_lat, &traffic_light_gps.gps_x, &traffic_light_gps.gps_y);
-
-
-    //xiesi
-    ///kkcai, 2020-01-03
-    //ServiceCarStatus.busmode=true;
-    //ServiceCarStatus.busmode=false;//20200102
-    ///////////////////////////////////////////////////
-
-
-    busMode = ServiceCarStatus.busmode;
-    nearStation=false;
-
-    gps_decition->leftlamp = false;
-    gps_decition->rightlamp = false;
-    //    qDebug("heading is %g",now_gps_ins.ins_heading_angle);
-
-
-    aim_gps_ins.gps_lat= ServiceCarStatus.mfParkLat;
-    aim_gps_ins.gps_lng= ServiceCarStatus.mfParkLng;
-
-    aim_gps_ins.ins_heading_angle= ServiceCarStatus.mfParkHeading;
-
-
-
-
-    GaussProjCal(aim_gps_ins.gps_lng,aim_gps_ins.gps_lat, &aim_gps_ins.gps_x, &aim_gps_ins.gps_y);
-    is_arrivaled = false;
-
-
-
-
-    //  xiuzhengCs=-0.8;  //1026
-
-    xiuzhengCs=0;
-    //    if (parkMode)
-    //    {
-
-
-    //        handBrakePark(gps_decition,10000,now_gps_ins);
-    //        return gps_decition;
-    //    }
-
-
-
-
-
-    realspeed = now_gps_ins.speed;
-
-    secSpeed = realspeed / 3.6;
-
-
-
-
-    //sidePark
-
-    if(ServiceCarStatus.mnParkType==1){
-
-        if( vehState!=dRever &&  vehState!=dRever0  &&  vehState!=dRever1 &&  vehState!=dRever2  &&  vehState!=dRever3 && vehState!=dRever4 && vehState!=reverseArr ){
-            int bocheEN=Compute00().bocheDirectCompute(now_gps_ins, aim_gps_ins);
-            if(bocheEN==1){
-                ServiceCarStatus.bocheEnable=1;
-            }else if(bocheEN==0){
-                ServiceCarStatus.bocheEnable=0;
-            }
-        }else{
-            ServiceCarStatus.bocheEnable=2;
-        }
-
-
-
-        if(ServiceCarStatus.bocheMode && vehState!=dRever &&  vehState!=dRever0  &&  vehState!=dRever1 &&
-                vehState!=dRever2  &&  vehState!=dRever3 && vehState!=dRever4&&  vehState!=reverseArr ){
-            if(abs(realspeed)>0.1){
-                dSpeed=0;
-                minDecelerate=min(minDecelerate,-0.5f);
-                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
-                gps_decition->wheel_angle=0;
-                return gps_decition;
-            }else{
-                if(trumpet()>3000){
-                    trumpetFirstCount=true;
-                    vehState=dRever;
-                }
-
-            }
-            //         ServiceCarStatus.bocheMode=false;
-        }
-
-    }
-
-
-    //chuizhiPark
-
-    if(ServiceCarStatus.mnParkType==0){
-        if( vehState!=reverseCar &&  vehState!=reversing  &&  vehState!=reverseCircle &&  vehState!=reverseDirect &&  vehState!=reverseArr ){
-            int bocheEN=Compute00().bocheCompute(now_gps_ins, aim_gps_ins);
-            if(bocheEN==1){
-                ServiceCarStatus.bocheEnable=1;
-            }else if(bocheEN==0){
-                ServiceCarStatus.bocheEnable=0;
-            }
-        }else{
-            ServiceCarStatus.bocheEnable=2;
-        }
-
-
-
-        if(ServiceCarStatus.bocheMode && vehState!=reverseCar &&  vehState!=reversing  &&  vehState!=reverseCircle &&  vehState!=reverseDirect&&  vehState!=reverseArr ){
-
-            if(abs(realspeed)>0.1){
-                dSpeed=0;
-                minDecelerate=min(minDecelerate,-0.5f);
-                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
-                gps_decition->wheel_angle=0;
-                return gps_decition;
-            }else{
-                if(trumpet()>3000){
-                    trumpetFirstCount=true;
-                    vehState=reverseCar;
-                }
-
-            }
-            //     ServiceCarStatus.bocheMode=false;
-
-        }
-    }
-    // ChuiZhiTingChe
-    if (vehState == reverseCar)
-    {
-        Compute00().bocheCompute(now_gps_ins, aim_gps_ins);
-
-        vehState = reversing;
-        qiedianCount=true;
-
-
-    }
-    if (vehState == reversing)
-    {
-        double dis = GetDistance(now_gps_ins, Compute00().nearTpoint);
-        if (dis<2.0)//0.5
-        {
-            vehState = reverseCircle;
-            qiedianCount = true;
-            cout<<"到达近切点+++++++++++++++++++++++++++++++++"<<endl;
-        }
-        else {
-            controlAng = 0;
-            dSpeed = 2;
-            dSecSpeed = dSpeed / 3.6;
-            gps_decition->wheel_angle = 0;
-            gps_decition->speed = dSpeed;
-            obsDistance=-1;
-            phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
-            //	gps_decition->accelerator = 0;
-            return gps_decition;
-        }
-    }
-
-    if (vehState == reverseCircle)
-    {
-        double dis = GetDistance(now_gps_ins, Compute00().farTpoint);
-        double angdis =abs(now_gps_ins.ins_heading_angle - aim_gps_ins.ins_heading_angle);
-        if((((angdis<5)||(angdis>355)))&&(dis<3.0))
-            //       if((((angdis<4)||(angdis>356)))&&(dis<2.0))
-        {
-            vehState = reverseDirect;
-            qiedianCount = true;
-            cout<<"到达远切点+++++++++++++++++++++++++++++++++"<<endl;
-
-        }
-        else {
-            if (qiedianCount && trumpet()<0)
-                //         if (qiedianCount && trumpet()<1500)
-            {
-
-                //                gps_decition->brake = 10;
-                //                gps_decition->torque = 0;
-                dSpeed=0;
-                minDecelerate=min(minDecelerate,-0.5f);
-                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
-            }
-            else
-            {
-                qiedianCount = false;
-                trumpetFirstCount = true;
-
-
-                dSpeed = 2;
-                dSecSpeed = dSpeed / 3.6;
-                gps_decition->speed = dSpeed;
-                obsDistance=-1;
-                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
-
-            }
-
-            controlAng = Compute00().bocheAngle*16.5;
-            gps_decition->wheel_angle = 0 - controlAng*1.05;
-
-            cout<<"farTpointDistance================"<<dis<<endl;
-
-            return gps_decition;
-        }
-    }
-
-    if (vehState == reverseDirect)
-    {
-        //	double dis = GetDistance(now_gps_ins, aim_gps_ins);
-        Point2D pt = Coordinate_Transfer(now_gps_ins.gps_x,now_gps_ins.gps_y, aim_gps_ins);
-
-        if ((pt.y)<0.5)
-        {
-
-            qiedianCount=true;
-            vehState=reverseArr;
-            cout<<"到达泊车点+++++++++++++++++++++++++++++++++"<<endl;
-            //            gps_decition->accelerator = -3;
-            //            gps_decition->brake = 10;
-            //            gps_decition->torque = 0;
-            gps_decition->wheel_angle=0;
-            dSpeed=0;
-            minDecelerate=min(minDecelerate,-0.5f);
-            phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
-            return gps_decition;
-
-
-
-
-        }
-        else {
-
-            //if (qiedianCount && trumpet()<0)
-            if (qiedianCount && trumpet()<1000)
-            {
-
-                //                gps_decition->brake = 10;
-                //                gps_decition->torque = 0;
-                dSpeed=0;
-                minDecelerate=min(minDecelerate,-0.5f);
-                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
-            }
-            else
-            {
-                qiedianCount = false;
-                trumpetFirstCount = true;
-                dSpeed = 1;
-                dSecSpeed = dSpeed / 3.6;
-                gps_decition->speed = dSpeed;
-                obsDistance=-1;
-                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
-            }
-
-
-
-            controlAng = 0;
-
-            gps_decition->wheel_angle = 0;
-
-            return gps_decition;
-        }
-    }
-
-
-
-    if (vehState == reverseArr)
-    {
-        //
-
-        ServiceCarStatus.bocheMode=false;
-        if (qiedianCount && trumpet()<1500)
-        {
-
-            //            gps_decition->brake = 10;
-            //            gps_decition->torque = 0;
-            dSpeed=0;
-            minDecelerate=min(minDecelerate,-0.5f);
-            phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
-            ServiceCarStatus.bocheMode=false;
-        }
-        else
-        {
-            qiedianCount = false;
-            trumpetFirstCount = true;
-            ServiceCarStatus.bocheEnable=0;
-            vehState=normalRun;
-            ServiceCarStatus.mbRunPause=true;
-            ServiceCarStatus.mnBocheComplete=100;
-            cout<<"泊车daowei mbRunPause+++++++++++++++++++++++++++++++++"<<endl;
-        }
-
-
-        gps_decition->wheel_angle = 0 ;
-
-
-
-        return gps_decition;
-
-    }
-
-
-
-    //ceFangWeiBoChe
-
-    if (vehState == dRever)
-    {
-        GaussProjCal(aim_gps_ins.gps_lng, aim_gps_ins.gps_lat, &aim_gps_ins.gps_x, &aim_gps_ins.gps_y);
-
-        Compute00().bocheDirectCompute(now_gps_ins, aim_gps_ins);
-
-        vehState = dRever0;
-        qiedianCount=true;
-
-
-        std::cout<<"enter side boche mode"<<std::endl;
-
-
-
-    }
-    if (vehState == dRever0)
-    {
-        double dis = GetDistance(now_gps_ins, Compute00().dTpoint0);
-        if (dis<2.0)
-        {
-            vehState = dRever1;
-            qiedianCount = true;
-            cout<<"到达近切点+++++++++++++++++++++++++++++++++"<<endl;
-        }
-        else {
-            controlAng = 0;
-            dSpeed = 2;
-            dSecSpeed = dSpeed / 3.6;
-            gps_decition->wheel_angle = 0;
-            gps_decition->speed = dSpeed;
-            obsDistance=-1;
-            phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
-            //	gps_decition->accelerator = 0;
-            return gps_decition;
-        }
-    }
-
-
-    if (vehState == dRever1)
-    {
-        double dis = GetDistance(now_gps_ins, Compute00().dTpoint1);
-
-        if(dis<2.0)
-        {
-            vehState = dRever2;
-            qiedianCount = true;
-            cout<<"到达远切点+++++++++++++++++++++++++++++++++"<<endl;
-
-        }
-        else {
-            if (qiedianCount && trumpet()<1000)
-
-            {
-
-                //                gps_decition->brake = 10;
-                //                gps_decition->torque = 0;
-                dSpeed=0;
-                minDecelerate=min(minDecelerate,-0.5f);
-                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
-            }
-            else
-            {
-                qiedianCount = false;
-                trumpetFirstCount = true;
-
-
-                dSpeed = 2;
-                dSecSpeed = dSpeed / 3.6;
-                gps_decition->speed = dSpeed;
-                obsDistance=-1;
-                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
-
-            }
-
-            controlAng = Compute00().dBocheAngle*16.5;
-            gps_decition->wheel_angle = 0 - controlAng;
-
-            cout<<"farTpointDistance================"<<dis<<endl;
-
-            return gps_decition;
-        }
-    }
-
-
-    if (vehState == dRever2)
-    {
-        double dis = GetDistance(now_gps_ins, Compute00().dTpoint2);
-        Point2D pt1 = Coordinate_Transfer(now_gps_ins.gps_x,now_gps_ins.gps_y, aim_gps_ins);
-        Point2D pt2 = Coordinate_Transfer(Compute00().dTpoint2.gps_x,Compute00().dTpoint2.gps_y, aim_gps_ins);
-        double xx= (pt1.x-pt2.x);
-        // if(xx>0)
-        if(xx>-0.5)
-        {
-            GaussProjCal(aim_gps_ins.gps_lng, aim_gps_ins.gps_lat, &aim_gps_ins.gps_x, &aim_gps_ins.gps_y);
-            Point2D ptt = Coordinate_Transfer(now_gps_ins.gps_x,now_gps_ins.gps_y, aim_gps_ins);
-            double xxx=ptt.x;
-            double yyy =ptt.y;
-//            if(xxx<-1.5||xx>1){
-//                int a=0;
-//            }
-            vehState = dRever3;
-            qiedianCount = true;
-            cout<<"到达远切点+++++++++++++++++++++++++++++++++"<<endl;
-            cout<<"xxx+++++++++++++++++++++++++++++++++"<<xxx<<endl;
-            cout<<"yyy+++++++++++++++++++++++++++++++++"<<yyy<<endl;
-
-
-        }
-        else {
-            if (qiedianCount && trumpet()<1000)
-
-            {
-
-                /*  gps_decition->brake = 10;
-                gps_decition->torque = 0;  */
-                dSpeed=0;
-                minDecelerate=min(minDecelerate,-0.5f);
-                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
-            }
-            else
-            {
-                qiedianCount = false;
-                trumpetFirstCount = true;
-
-
-                dSpeed = 2;
-                dSecSpeed = dSpeed / 3.6;
-                gps_decition->speed = dSpeed;
-                obsDistance=-1;
-                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
-
-            }
-
-
-            gps_decition->wheel_angle = 0 ;
-
-            cout<<"farTpointDistance================"<<dis<<endl;
-
-            return gps_decition;
-        }
-    }
-
-
-    if (vehState == dRever3)
-    {
-        double dis = GetDistance(now_gps_ins, Compute00().dTpoint3);
-        double angdis =abs(now_gps_ins.ins_heading_angle - aim_gps_ins.ins_heading_angle);
-        if((((angdis<5)||(angdis>355)))&&(dis<10.0))
-        {
-            vehState = dRever4;
-            qiedianCount = true;
-            cout<<"到达远切点+++++++++++++++++++++++++++++++++"<<endl;
-
-        }
-        else {
-            if (qiedianCount && trumpet()<1000)
-
-            {
-
-                //                gps_decition->brake = 10;
-                //                gps_decition->torque = 0;
-                dSpeed=0;
-                minDecelerate=min(minDecelerate,-0.5f);
-                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
-            }
-            else
-            {
-                qiedianCount = false;
-                trumpetFirstCount = true;
-
-
-                dSpeed = 2;
-                dSecSpeed = dSpeed / 3.6;
-                gps_decition->speed = dSpeed;
-                obsDistance=-1;
-                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
-
-            }
-
-            controlAng = 0-Compute00().dBocheAngle*16.5;
-            gps_decition->wheel_angle = 0 - controlAng*0.95;
-
-            cout<<"farTpointDistance================"<<dis<<endl;
-
-            return gps_decition;
-        }
-    }
-
-
-
-    if (vehState == dRever4)
-    {
-        //	double dis = GetDistance(now_gps_ins, aim_gps_ins);
-        Point2D pt = Coordinate_Transfer(now_gps_ins.gps_x,now_gps_ins.gps_y, aim_gps_ins);
-
-        if ((pt.y)<0.5)
-        {
-
-            qiedianCount=true;
-            vehState=reverseArr;
-            cout<<"到达泊车点+++++++++++++++++++++++++++++++++"<<endl;
-            //            gps_decition->accelerator = -3;
-            //            gps_decition->brake =10 ;
-            dSpeed=0;
-            minDecelerate=min(minDecelerate,-0.5f);
-            phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
-
-            gps_decition->wheel_angle=0;
-            return gps_decition;
-
-
-
-
-        }
-        else {
-
-            //if (qiedianCount && trumpet()<0)
-            if (qiedianCount && trumpet()<1000)
-            {
-
-                //                gps_decition->brake = 10;
-                //                gps_decition->torque = 0;
-                dSpeed=0;
-                minDecelerate=min(minDecelerate,-0.5f);
-                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
-            }
-            else
-            {
-                qiedianCount = false;
-                trumpetFirstCount = true;
-                dSpeed = 2;
-                dSecSpeed = dSpeed / 3.6;
-                gps_decition->speed = dSpeed;
-                obsDistance=-1;
-                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
-            }
-
-
-
-            controlAng = 0;
-
-            gps_decition->wheel_angle = 0;
-
-            return gps_decition;
-        }
-    }
-
-
-
-    if (vehState == reverseArr)
-    {
-        //
-        ServiceCarStatus.bocheMode=false;
-
-        if (qiedianCount && trumpet()<1500)
-        {
-
-            //            gps_decition->brake = 10;
-            //            gps_decition->torque = 0;
-            dSpeed=0;
-            minDecelerate=min(minDecelerate,-0.5f);
-            phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
-        }
-        else
-        {
-            qiedianCount = false;
-            trumpetFirstCount = true;
-            ServiceCarStatus.bocheEnable=0;
-            vehState=normalRun;
-            ServiceCarStatus.mbRunPause=true;
-            ServiceCarStatus.mnBocheComplete=100;
-            cout<<"泊车daowei mbRunPause+++++++++++++++++++++++++++++++++"<<endl;
-        }
-
-
-        gps_decition->wheel_angle = 0 ;
-
-
-
-        return gps_decition;
-
-    }
-
-
-
-
-
-
-
-
-
-
-
-    obsDistance = -1;
-    esrIndex = -1;
-    lidarDistance = -1;
-
-    obsDistanceAvoid = -1;
-    esrIndexAvoid = -1;
-    roadPre = -1;
-
-
-
-
-
-
-
-
-
-    avoidX = (roadOri-roadNow)*roadWidth;
-
-    gpsTraceOri.clear();
-    gpsTraceNow.clear();
-    gpsTraceAim.clear();
-    gpsTraceAvoid.clear();
-    gpsTraceBack.clear();
-
-
-
-
-
-
-
-    if (!isFirstRun)
-    {
-        //   PathPoint = Compute00().getNearestPointIndex(now_gps_ins, gpsMapLine, DecideGps00::lastGpsIndex, DecideGps00::minDis, DecideGps00::maxAngle);
-        //    if(PathPoint<0){
-        PathPoint = Compute00().getFirstNearestPointIndex(now_gps_ins, gpsMapLine, DecideGps00::lastGpsIndex, DecideGps00::minDis, DecideGps00::maxAngle);
-        //    }
-
-    }
-
-
-    if (PathPoint<0)
-    {
-
-        minDecelerate=-1.0;
-        phaseSpeedDecition(gps_decition, secSpeed, -1, 0,now_gps_ins);
-        return gps_decition;
-
-    }
-
-    DecideGps00::lastGpsIndex = PathPoint;
-    //2020-01-03, kkcai
-    //if(!circleMode && PathPoint>gpsMapLine.size()-200){
-    if(!circleMode && PathPoint>gpsMapLine.size()-100){
-        minDecelerate=-1.0;
-        std::cout<<"map finish brake"<<std::endl;
-    }
-
-
-
-
-    roadOri = gpsMapLine[PathPoint]->roadOri;
-
-    roadSum = gpsMapLine[PathPoint]->roadSum;
-
-
-    if ( gpsMapLine[PathPoint]->runMode == 0 &&(vehState == avoidObs||vehState ==stopObs||vehState == preAvoid
-                                                ||vehState == avoiding||vehState == backOri||vehState ==preBack||vehState ==waitAvoid ) )
-    {
-        vehState = normalRun;
-        roadNow = roadOri;
-    }
-
-
-
-    //    if (PathPoint!=-1&&((now_gps_ins.rtk_status==6)||(now_gps_ins.rtk_status==5))&&GetDistance(now_gps_ins,*gpsMapLine[PathPoint])<30)
-    //    {
-    //        DecideGps00::lastGpsIndex = PathPoint;
-    //        gpsMissCount = 0;
-
-    //    }
-    //    else
-    //    {
-    //        gpsMissCount++;
-    //    }
-
-    gpsTraceOri= getGpsTrace(now_gps_ins, gpsMapLine, lastGpsIndex,circleMode);
-    //    gpsTraceOri = laneChangePlanner->getPath(now_gps_ins,gpsMapLine,PathPoint,0,lidarGridPtr);
-    if(gpsTraceOri.empty()){
-        gps_decition->wheel_angle = 0;
-        gps_decition->speed = dSpeed;
-
-        gps_decition->accelerator = -0.5;
-        gps_decition->brake=10;
-        return gps_decition;
-    }
-
-
-
-    traceDevi=gpsTraceOri[0].x;
-
-    //起步进行frenet规划后,车辆行驶至地图路线上,起步操作完毕。
-    //如果车辆本身启动位置在地图路线上,可不用进行frenet规划。
-    //    if(GetDistance(now_gps_ins,*gpsMapLine[PathPoint]) < 1){
-    //        startingFlag = false;
-    //    }
-    startingFlag = false;
-    if(startingFlag){
-        //        gpsTraceAim = gpsTraceOri;
-        if(abs(gpsTraceOri[0].x)>1){
-            cout<<"frenetPlanner->getPath:pre"<<endl;
-            gpsTraceNow = frenetPlanner->getPath(now_gps_ins,gpsMapLine,PathPoint,0,lidarGridPtr);
-            cout<<"frenetPlanner->getPath,gpsTraceNow.size: "<<gpsTraceNow.size()<<endl;
-            if(gpsTraceNow.size()==0){
-                gps_decition->accelerator = 0;
-                gps_decition->brake=10;
-                gps_decition->wheel_angle = lastAngle;
-                gps_decition->speed = 0;
-                return gps_decition;
-            }
-        }else{
-            startingFlag = false;
-        }
-    }
-
-
-    if(useFrenet){
-        //如果车辆在变道中,启用frenet规划局部路径
-        if(vehState == avoiding || vehState == backOri){
-            avoidX = (roadOri - roadNow)*roadWidth;
-            gpsTraceNow = frenetPlanner->getPath(now_gps_ins,gpsMapLine,PathPoint,avoidX,lidarGridPtr);
-            //gpsTraceAim = laneChangePlanner->getPath(now_gps_ins,gpsMapLine,PathPoint,avoidX,lidarGridPtr);
-            gpsTraceAim = getGpsTraceOffset(gpsTraceOri, avoidX);
-            if(gpsTraceNow.size()==0){
-                gps_decition->accelerator = 0;
-                gps_decition->brake=10;
-                gps_decition->wheel_angle = lastAngle;
-                gps_decition->speed = 0;
-                return gps_decition;
-            }
-        }
-    }
-
-    if(gpsTraceNow.size()==0){
-        if (roadNow==roadOri)
-        {
-            gpsTraceNow.assign(gpsTraceOri.begin(), gpsTraceOri.end());
-            //gpsTraceNow = getGpsTrace(now_gps_ins, gpsMapLine, lastGpsIndex);
-        }else
-        {
-            //	gpsTraceNow = getGpsTrace(now_gps_ins, gmapsR[int(abs(roadWidth * 2)*(roadOri-roadNow))], lastGpsIndex);
-            gpsTraceNow = getGpsTraceOffset(gpsTraceOri, avoidX);
-            //gpsTraceNow = laneChangePlanner->getPath(now_gps_ins,gpsMapLine,PathPoint,avoidX,lidarGridPtr);
-        }
-    }
-
-
-    //  dSpeed = getSpeed(gpsTraceNow);
-    dSpeed = 80;
-
-    planTrace = gpsTraceNow; //Add By YuChuli, 2020.11.26
-
-    dSpeed = limitSpeed(controlAng, dSpeed);
-
-
-
-    controlAng= getAngle(gpsTraceNow,now_gps_ins,gps_decition);
-    if(!circleMode && PathPoint>(gpsMapLine.size()-100)){
-        controlAng=0;
-    }
-
-
-
-    //1220
-    if(ServiceCarStatus.daocheMode){
-        controlAng=0-controlAng;
-    }
-
-    //2020-0106
-    if(vehState==avoiding){
-        controlAng=max(-150.0,controlAng);
-        controlAng=min(150.0,controlAng);
-    }
-    if(vehState==backOri){
-        controlAng=max(-120.0,controlAng);
-        controlAng=min(120.0,controlAng);
-    }
-
-    //准备驻车
-
-    if (readyZhucheMode)
-    {
-
-        cout<<"ready ZHECHE STATE+++++++++++++++++++++++++++++++++"<<endl;
-        cout<<"zhuche point : "<<zhuchePointNum<<endl;
-
-        double dis = GetDistance(*gpsMapLine[zhuchePointNum], now_gps_ins);
-
-        if (dis<35)
-        {
-            Point2D pt = Coordinate_Transfer((*gpsMapLine[zhuchePointNum]).gps_x, (*gpsMapLine[zhuchePointNum]).gps_y, now_gps_ins);
-            double zhucheDistance = pt.y;
-#if 0
-
-            if (dSpeed > 15)
-            {
-                dSpeed = 15;
-            }
-
-
-
-            if (zhucheDistance < 20 && dis < 25)
-            {
-                dSpeed = min(dSpeed, 5.0);
-            }
-#else
-            if (dSpeed > 12)
-            {
-                dSpeed = 12;
-            }
-
-
-
-            if (zhucheDistance < 9 && dis < 9)
-            {
-                dSpeed = min(dSpeed, 5.0);
-            }
-#endif
-
-
-            if (zhucheDistance < 3.0 && dis < 3.5)
-            {
-                dSpeed = min(dSpeed, 5.0);
-                zhucheMode = true;
-                readyZhucheMode = false;
-                cout<<"jinru ZHECHE STATE+++++++++++++++++++++++++++++++++"<<endl;
-
-                //1125
-                //                 gps_decition->brake=20;
-                //                 gps_decition->accelerator = -3;
-                //                 gps_decition->wheel_angle = 0-controlAng;
-                //                 gps_decition->speed = 0;
-                //                 gps_decition->torque=0;
-                //                 return gps_decition;
-
-
-
-
-
-            }
-
-        }
-
-    }
-
-
-
-
-
-    if (readyParkMode)
-    {
-        double parkDis = GetDistance(now_gps_ins, *gpsMapLine[finishPointNum]);
-        hasZhuched = true;
-
-        if (parkDis < 25)
-        {
-            Point2D pt = Coordinate_Transfer((*gpsMapLine[finishPointNum]).gps_x, (*gpsMapLine[finishPointNum]).gps_y, now_gps_ins);
-            double parkDistance = pt.y;
-
-
-            if (dSpeed > 15)
-            {
-                dSpeed = 15;
-            }
-
-            //dSpeed = 15;//////////////////////////////
-
-            if (parkDistance < 15 && parkDistance >= 4.5 && parkDis<20)
-            {
-                dSpeed = min(dSpeed, 8.0);
-            }else if (parkDistance < 4.5 && parkDistance >= 3.5 && parkDis<5.0){
-                dSpeed = min(dSpeed, 5.0);
-            }else if(parkDistance < 3.5 && parkDis<4.0){
-                dSpeed = min(dSpeed, 3.0);
-            }
-
-
-            //            float stopDis=2;
-            //            if(ServiceCarStatus.msysparam.mvehtype=="ge3"){
-            //                stopDis=1.6;
-            //            } else if(ServiceCarStatus.msysparam.mvehtype=="vv7"){
-            //                stopDis=1.8;
-            //            }
-
-            if (parkDistance < 1.6  && parkDis<2.0)
-            {
-                // dSpeed = 0;
-                parkMode = true;
-                readyParkMode = false;
-            }
-
-
-        }
-    }
-
-
-
-    if (gpsMapLine[PathPoint]->roadMode ==0)
-    {
-        //dSpeed = min(10.0,dSpeed);
-
-        dSpeed = min(ServiceCarStatus.mroadmode_vel.mfmode0,dSpeed);
-        gps_decition->leftlamp = false;
-        gps_decition->rightlamp = false;
-
-    }else  if (gpsMapLine[PathPoint]->roadMode == 5)
-    {
-        //dSpeed = min(8.0,dSpeed);
-
-        dSpeed = min(ServiceCarStatus.mroadmode_vel.mfmode5,dSpeed);
-        gps_decition->leftlamp = false;
-        gps_decition->rightlamp = false;
-
-    }else if (gpsMapLine[PathPoint]->roadMode == 11)
-    {
-        dSpeed = min(ServiceCarStatus.mroadmode_vel.mfmode11,dSpeed);
-
-    }else if (gpsMapLine[PathPoint]->roadMode == 14)
-    {
-        //dSpeed = min(8.0,dSpeed);
-
-        dSpeed = min(ServiceCarStatus.mroadmode_vel.mfmode14,dSpeed);
-        gps_decition->leftlamp = true;
-        gps_decition->rightlamp = false;
-    }else if (gpsMapLine[PathPoint]->roadMode == 15)
-    {
-        //dSpeed = min(8.0,dSpeed);
-
-        dSpeed = min(ServiceCarStatus.mroadmode_vel.mfmode15,dSpeed);
-        gps_decition->leftlamp = false;
-        gps_decition->rightlamp = true;
-    }else if (gpsMapLine[PathPoint]->roadMode == 16)
-    {
-        // dSpeed = min(10.0,dSpeed);
-        dSpeed = min(ServiceCarStatus.mroadmode_vel.mfmode16,dSpeed);
-        gps_decition->leftlamp = true;
-        gps_decition->rightlamp = false;
-    }else if (gpsMapLine[PathPoint]->roadMode == 17)
-    {
-        //  dSpeed = min(10.0,dSpeed);
-        dSpeed = min(ServiceCarStatus.mroadmode_vel.mfmode17,dSpeed);
-        gps_decition->leftlamp = false;
-        gps_decition->rightlamp = true;
-    }else if (gpsMapLine[PathPoint]->roadMode == 18)
-    {
-        // dSpeed = min(10.0,dSpeed);
-        dSpeed = min(ServiceCarStatus.mroadmode_vel.mfmode18,dSpeed);
-        /*if(gpsMapLine[PathPoint]->light_left_or_right == 1)
-        {
-            gps_decition->leftlamp = true;
-            gps_decition->rightlamp = false;
-        }
-        else if(gpsMapLine[PathPoint]->light_left_or_right == 2)
-        {
-            gps_decition->leftlamp = false;
-            gps_decition->rightlamp = true;
-        }*/
-    }else if (gpsMapLine[PathPoint]->roadMode == 1)
-    {
-        dSpeed = min(10.0,dSpeed);
-    }else if (gpsMapLine[PathPoint]->roadMode == 2)
-    {
-        dSpeed = min(15.0,dSpeed);
-    }
-    else if (gpsMapLine[PathPoint]->roadMode == 7)
-    {
-        dSpeed = min(15.0,dSpeed);
-        xiuzhengCs=1.5;
-    }else if (gpsMapLine[PathPoint]->roadMode == 4) //1220
-    {
-        dSpeed = min(4.0,dSpeed);
-
-    }
-
-
-
-
-
-    if (gpsMapLine[PathPoint]->speed_mode == 2)
-    {
-        dSpeed = min(25.0,dSpeed);
-
-    }
-    dSecSpeed = dSpeed / 3.6;
-
-
-
-
-
-
-    std::cout<<"juecesudu2="<<dSpeed<<std::endl;
-
-
-
-
-
-
-
-    if(vehState==changingRoad){
-        if(gpsTraceNow[0].x>1.0){
-            gps_decition->leftlamp = false;
-            gps_decition->rightlamp = true;
-        }else if(gpsTraceNow[0].x<-1.0){
-            gps_decition->leftlamp = true;
-            gps_decition->rightlamp = false;
-        }else{
-            vehState==normalRun;
-        }
-    }
-
-    //    qDebug("decide0 time is %d",xTime.elapsed());
-
-    //1220
-    if(!ServiceCarStatus.daocheMode){
-        computeObsOnRoad(lidarGridPtr, gpsTraceNow, roadNow,gpsMapLine,lidar_per);
-    }else{
-        gpsTraceRear.clear();
-        for(int i=0;i<gpsTraceNow.size();i++){
-            Point2D pt;
-            pt.x=0-gpsTraceNow[i].x;
-            pt.y=0-gpsTraceNow[i].y;
-            gpsTraceRear.push_back(pt);
-        }
-        computeObsOnRoad(lidarGridPtr, gpsTraceNow, roadNow,gpsMapLine,lidar_per);
-        //  obsDistance=-1; //1227
-    }
-
-
-
-
-    //old_bz--------------------------------------------------------------------------------------------------
-
-    if (vehState == avoiding)
-    {
-        cout<<"\n==================avoiding=================\n"<<endl;
-        //  vehState=normalRun; //1025
-        if (dSpeed > 10) {
-            dSpeed = 10;
-        }
-        //若车辆到达变道后的路径,改变车辆状态,关闭frenet规划
-        if (useFrenet && abs(gpsTraceAim[0].x)<1.0) {
-            vehState = normalRun;
-            //            useFrenet = false;
-            //            useOldAvoid = true;
-        }
-        else if (useOldAvoid && abs(gpsTraceNow[0].x)<1.0) {
-            // vehState = avoidObs; 0929
-            vehState = normalRun;
-        }
-        else if (gpsTraceNow[0].x>0)
-        {
-            gps_decition->leftlamp = false;
-            gps_decition->rightlamp = true;
-        }
-        else if(gpsTraceNow[0].x<0)
-        {
-            gps_decition->leftlamp = true;
-            gps_decition->rightlamp = false;
-        }
-    }
-
-
-    if (vehState==preBack)
-    {
-        vehState = backOri;
-    }
-
-
-    if (vehState==backOri)
-    {
-        cout<<"\n================backOri===========\n"<<endl;
-        //  vehState=normalRun; //1025
-        if (dSpeed > 10) {
-            dSpeed = 10;
-        }
-
-        //若车辆到达变道后的路径,改变车辆状态,关闭frenet规划
-        if (useFrenet && abs(gpsTraceAim[0].x)<1.0) {
-            vehState = normalRun;
-            //            useFrenet = false;
-            //            useOldAvoid = true;
-        }
-        else if (useOldAvoid && abs(gpsTraceNow[0].x)<1.0) {
-            // vehState = avoidObs; 0929
-            vehState = normalRun;
-        }
-        else if (gpsTraceNow[0].x>0)
-        {
-            gps_decition->leftlamp = false;
-            gps_decition->rightlamp = true;
-        }
-        else if (gpsTraceNow[0].x<0)
-        {
-            gps_decition->leftlamp = true;
-            gps_decition->rightlamp = false;
-        }
-    }
-
-    std::cout<<"\n原始RoadOri:%d\n"<<roadOri<<endl;
-
-    cout<<"\n当前RoadNum:%d\n"<<roadNow<<endl;
-
-
-
-
-
-
-
-
-
-    //   计算回归原始路线
-
-    if (roadNow!=roadOri)
-    {
-        //        useFrenet = true;
-        //        useOldAvoid = false;
-
-        if(useFrenet){
-            if ((GetDistance(now_gps_ins, startAvoidGpsInsVector[roadOri])>max(avoidMinDistanceVector[roadOri],30.0)))
-            {
-                double offsetL = -(roadSum - 1)*roadWidth;
-                double offsetR = (roadOri - 0)*roadWidth;
-                roadPre = frenetPlanner->chooseRoadByFrenet(now_gps_ins,gpsMapLine,PathPoint,offsetL,offsetR,lidarGridPtr,roadNow);
-            }
-        }
-        else if(useOldAvoid){
-            roadPre = chooseBackRoad(lidarGridPtr, now_gps_ins, gpsMapLine,lidar_per);
-            avoidX = (roadOri - roadNow)*roadWidth; //1012
-        }
-    }
-    if (roadNow != roadOri && roadPre!=-1)
-    {
-
-        roadNow = roadPre;
-        avoidX = (roadOri - roadNow)*roadWidth;
-        gpsTraceNow.clear();
-        if(useOldAvoid){
-            gpsTraceNow = getGpsTraceOffset(gpsTraceOri, avoidX);
-        }
-        else if(useFrenet){
-            gpsTraceNow = frenetPlanner->getPath(now_gps_ins,gpsMapLine,PathPoint,avoidX,lidarGridPtr);
-        }
-
-        vehState = backOri;
-        hasCheckedBackLidar = false;
-        //  checkBackObsTimes = 0;
-
-        cout<<"\n回归RoadNum:%d\n"<< roadNow<<endl;
-
-    }
-
-    //shiyanbizhang 0929
-    if(obsDistance>0&& (obsDistance<ServiceCarStatus.socfDis+20.0) &&(abs(realspeed)<1.0) &&
-            (vehState==normalRun||vehState==backOri || vehState==avoiding) &&(ObsTimeStart==-1)
-            && (gpsMapLine[PathPoint]->runMode==1)){
-        ObsTimeStart=GetTickCount();
-        cout<<"\n====================preAvoid time count start==================\n"<<endl;
-    }
-    if(ObsTimeStart!=-1){
-        ObsTimeEnd=GetTickCount();
-    }
-    if(ObsTimeEnd!=-1){
-        ObsTimeSpan=ObsTimeEnd-ObsTimeStart;
-    }
-    if(ObsTimeSpan>ObsTimeWidth &&(obsDistance>1.5||obsDistance<0) && (gpsMapLine[PathPoint]->runMode==1)){ //1026
-        vehState=avoidObs;
-        ObsTimeStart=-1;
-        ObsTimeEnd=-1;
-        ObsTimeSpan=-1;
-        cout<<"\n====================preAvoid time count finish==================\n"<<endl;
-    }
-
-    if(obsDistance<0 ||obsDistance>ServiceCarStatus.socfDis){
-        ObsTimeStart=-1;
-        ObsTimeEnd=-1;
-        ObsTimeSpan=-1;
-
-    }
-
-
-    //避障模式
-
-
-    if (vehState == avoidObs   || vehState==waitAvoid ) {
-
-        //      if (obsDistance <20 && obsDistance >0)
-        if (obsDistance <ServiceCarStatus.aocfDis && obsDistance >0)
-        {
-            dSpeed = min(7.0,dSpeed);
-            avoidTimes++;
-            //          if (avoidTimes>=6)
-            if (avoidTimes>=ServiceCarStatus.aocfTimes)
-            {
-                vehState = preAvoid;
-                avoidTimes = 0;
-            }
-
-        }
-        //        else if (obsDistance < 35 && obsDistance >0 && dSpeed>10)
-        //        {
-        //            dSpeed = 10;
-        //            avoidTimes = 0;
-        //        }
-        else if (obsDistance < 40 && obsDistance >0 && dSpeed>15)
-        {
-            dSpeed =  min(15.0,dSpeed);
-            avoidTimes = 0;
-        }
-        else
-        {
-            avoidTimes = 0;
-        }
-
-    }
-
-
-    if (vehState == preAvoid)
-    {
-        cout<<"\n====================preAvoid==================\n"<<endl;
-        /* if (obsDisVector[roadNow]>30)*/  //if (obsDisVector[roadNow]>30||obsDisVector[roadNow]<0)
-        if (obsDisVector[roadNow]>ServiceCarStatus.aocfDis)
-        {
-            // vehState = avoidObs; 0929
-            vehState=normalRun;
-        }
-        else
-        {
-            //roadPre = chooseAvoidRoad(lidarGridPtr, now_gps_ins,gpsMapLine);
-            if(useOldAvoid){
-                roadPre = chooseAvoidRoad(lidarGridPtr, now_gps_ins,gpsMapLine,lidar_per);
-                avoidX = (roadOri - roadNow)*roadWidth;  //1012
-            }
-            else if(useFrenet){
-                double offsetL = -(roadSum - 1)*roadWidth;
-                double offsetR = (roadOri - 0)*roadWidth;
-                roadPre = frenetPlanner->chooseRoadByFrenet(now_gps_ins,gpsMapLine,PathPoint,offsetL,offsetR,lidarGridPtr,roadNow);
-            }
-
-            if (roadPre == -1 && obsDisVector[roadNow]<1.5 && obsDisVector[roadNow]>0)
-            {
-                //  vehState = waitAvoid; 0929
-                vehState = avoidObs;
-            }
-            else if (roadPre != -1)
-            {
-                if(useOldAvoid){
-                    roadNow = roadPre;
-                    avoidX = (roadOri - roadNow)*roadWidth;
-                    gpsTraceNow.clear();
-                    gpsTraceNow = getGpsTraceOffset(gpsTraceOri, avoidX);
-                }
-                else if(useFrenet){
-                    if(roadPre != roadNow){
-                        avoidMinDistanceVector[roadNow] = obsDisVector[roadNow] + Veh_Lenth;
-                        startAvoidGpsInsVector[roadNow] = now_gps_ins;
-                    }
-                    roadNow = roadPre;
-                    avoidX = (roadOri - roadNow)*roadWidth;
-                    gpsTraceNow = frenetPlanner->getPath(now_gps_ins,gpsMapLine,PathPoint,avoidX,lidarGridPtr);
-                }
-
-
-                vehState = avoiding;
-
-                hasCheckedAvoidLidar = false;
-
-                cout<<"\n避障到RoadNum:%d\n"<<roadNow<<endl;
-
-            }
-        }
-    }
-
-    //--------------------------------------------------------------------------------old_bz_end
-
-
-
-
-
-    //TOUCHEPINGBI
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-    if (parkMode)
-    {
-        minDecelerate=-1.0;
-
-        if(finishPointNum<0||finishPointNum>=gpsMapLine.size()){
-            parkMode=false;
-        }else if(GetDistance(now_gps_ins, *gpsMapLine[finishPointNum])>20){
-            parkMode=false;
-        }
-
-    }
-
-
-
-    //驻车
-
-    if (zhucheMode)
-    {
-        int mzcTime = ServiceCarStatus.msysparam.mzhuchetime * 1000;
-
-        //        if(trumpet()<16000)
-        if (trumpet()<mzcTime)
-        {
-            //            if (trumpet()<12000){
-            cout<<"ZHECHE ING STATE+++++++++++++++++++++++++++++++++"<<endl;
-            minDecelerate=-1.0;
-            if(abs(realspeed)<0.2){
-                controlAng=0;  //tju
-            }
-        }
-        else
-        {
-            hasZhuched = true; //1125
-            zhucheMode = false;
-            trumpetFirstCount = true;
-            cout<<"ZHECHE STATE JIESHU +++++++++++++++++++++++++++++++++"<<endl;
-        }
-
-    }
-
-
-    //判断驻车标志位
-    if (hasZhuched && GetDistance(now_gps_ins,*gpsMapLine[zhuchePointNum])>20)
-    {
-        hasZhuched = false;
-    }
-
-
-
-
-
-
-
-
-
-
-
-    if ( vehState==changingRoad || vehState==chaocheBack)
-    {
-        double lastAng = 0.0 - lastAngle;
-        if (controlAng>40)
-        {
-            controlAng =40;
-        }
-        else if (controlAng<-40)
-        {
-            controlAng = - 40;
-        }
-
-
-    }
-
-
-    //速度结合角度的限制
-    controlAng = limitAngle(realspeed, controlAng);
-
-
-    std::cout << "\n呼车指令状态:%d\n" <<  ServiceCarStatus.carState << std::endl;
-
-
-
-    //1220
-    if(PathPoint+80<gpsMapLine.size()-1){
-        if(gpsMapLine[PathPoint+80]->roadMode==4  && !ServiceCarStatus.daocheMode){
-            changingDangWei=true;
-        }
-    }
-
-    if(changingDangWei){
-        if(abs(realspeed)>0.1){
-            dSpeed=0;
-        }else{
-            dSpeed=0;
-            gps_decition->dangWei=2;
-            ServiceCarStatus.daocheMode=true;
-        }
-    }
-    //1220 end
-
-
-
-
-    for(int i = 0;i<ServiceCarStatus.car_stations.size();i++)
-    {
-        GPS_INS gpsIns;
-        GaussProjCal(ServiceCarStatus.car_stations[i].longtitude, ServiceCarStatus.car_stations[i].latitude,  &gpsIns.gps_x, &gpsIns.gps_y);
-
-        double dis = GetDistance(gpsIns, now_gps_ins);
-        if(dis<20)
-            ServiceCarStatus.currentstation = ServiceCarStatus.car_stations[i].ID;
-    }
-
-
-
-
-    if (ServiceCarStatus.carState == 0 && busMode)
-    {
-
-        minDecelerate=-1.0;
-    }
-
-
-
-    if (ServiceCarStatus.carState == 3 && busMode)
-    {
-
-        if(realspeed<0.1){
-            ServiceCarStatus.carState=0;
-            minDecelerate=-1.0;
-        }else{
-            nearStation=true;
-            dSpeed=0;
-        }
-
-    }
-
-
-
-
-
-
-
-    ///kkcai, 2020-01-03
-    //if (ServiceCarStatus.carState == 2 && busMode)
-    if (ServiceCarStatus.carState == 2)
-    {
-
-        aim_gps_ins.gps_lat=ServiceCarStatus.amilat;
-        aim_gps_ins.gps_lng=ServiceCarStatus.amilng;
-        //   gps2xy(ServiceCarStatus.amilat, ServiceCarStatus.amilng, &aim_gps_ins.gps_x, &aim_gps_ins.gps_y);
-        GaussProjCal( aim_gps_ins.gps_lng, aim_gps_ins.gps_lat,  &aim_gps_ins.gps_x, &aim_gps_ins.gps_y);
-        std::cout<<"lng"<<ServiceCarStatus.amilng<<std::endl;
-        qDebug("lat:%f", aim_gps_ins.gps_lat);
-        qDebug("lon:%f", aim_gps_ins.gps_lng);
-
-        std::cout<<"lat"<<ServiceCarStatus.amilat<<std::endl;
-        double dis = GetDistance(aim_gps_ins, now_gps_ins);
-        Point2D pt = Coordinate_Transfer((aim_gps_ins).gps_x, (aim_gps_ins).gps_y, now_gps_ins);
-
-        std::cout << "\n呼车dis距离:%f\n" << dis << std::endl;
-        std::cout << "\n呼车Y距离:%f\n" << pt.y << std::endl;
-
-        //         if (dis<20 && pt.y<8&& realspeed<0.1)
-        if (dis<20 && pt.y<5 && abs(pt.x)<3)
-        {
-            dSpeed = 0;
-            nearStation=true;
-            //is_arrivaled = true;
-            //ServiceCarStatus.status[0] = true;
-            ServiceCarStatus.istostation=1;
-            minDecelerate=-1.0;
-        }
-
-        else if (dis<20 && pt.y<15 && abs(pt.x)<3)
-        {
-            nearStation=true;
-            dSpeed = min(8.0, dSpeed);
-        }
-        else if (dis<30 && pt.y<20 && abs(pt.x)<3)
-        {
-            dSpeed = min(15.0, dSpeed);
-        }
-
-        else if (dis<50 && abs(pt.x)<3)
-        {
-            dSpeed = min(20.0, dSpeed);
-        }
-    }
-
-
-    dSecSpeed = dSpeed / 3.6;
-    gps_decition->speed = dSpeed;
-
-
-
-    if (gpsMapLine[PathPoint]->runMode == 2)
-    {
-        obsDistance = -1;
-
-    }
-
-    std::cout<<"juecesudu0="<<dSpeed<<std::endl;
-
-    //-------------------------------traffic light----------------------------------------------------------------------------------------
-
-    if(traffic_light_gps.gps_lat!=0 && traffic_light_gps.gps_lng!=0){
-        traffic_light_pathpoint = Compute00().getNoAngleNearestPointIndex(traffic_light_gps, gpsMapLine);
-        //    traffic_light_pathpoint=130;
-        float traffic_speed=ComputeTrafficLightSpeed(ServiceCarStatus.iTrafficeLightColor,ServiceCarStatus.iTrafficeLightTime,gpsMapLine,
-                                                     traffic_light_pathpoint ,PathPoint,secSpeed,dSpeed);
-        dSpeed = min((double)traffic_speed,dSpeed);
-        if(traffic_speed==0){
-            minDecelerate=-2.0;
-        }
-    }
-    //-------------------------------traffic light  end-----------------------------------------------------------------------------------------------
-
-
-    //-------------------------------v2x traffic light-----------------------------------------------------------------------------------------
-
-
-    double v2xTrafficSpeed= ComputeV2XTrafficLightSpeed( trafficLight,  gpsMapLine, v2xTrafficVector,
-                                                         PathPoint, secSpeed, dSpeed,  circleMode);
-
-
-    dSpeed = min(v2xTrafficSpeed,dSpeed);
-
-    //------------------------------v2x traffic light end--------------------------------------------------------------------------------------
-
-
-    if(obsDistance>0 && obsDistance<10){
-        dSpeed=0;
-    }
-    //  obsDistance=-1; //1227
-
-    if(ServiceCarStatus.group_control){
-        dSpeed = ServiceCarStatus.group_comm_speed;
-    }
-    if(dSpeed==0){
-        minDecelerate=min(-1.0f,minDecelerate);
-    }
-
-    std::cout<<"dSpeed= "<<dSpeed<<std::endl;
-
-    // givlog->debug("SPEED","dSpeed is %f",dSpeed);
-    phaseSpeedDecition(gps_decition, secSpeed, obsDistance, obsSpeed,now_gps_ins);
-
-
-
-
-
-    gps_decition->wheel_angle = 0.0 - controlAng;
-
-
-
-    lastAngle=gps_decition->wheel_angle;
-
-    //   qDebug("decide1 time is %d",xTime.elapsed());
-
-    return gps_decition;
-}
-
-
-
-void iv::decition::DecideGps00::initMethods(){
-
-    pid_Controller= new PIDController();
-    ge3_Adapter = new Ge3Adapter();
-    qingyuan_Adapter = new QingYuanAdapter();
-    vv7_Adapter = new VV7Adapter();
-    zhongche_Adapter = new ZhongcheAdapter();
-    bus_Adapter = new BusAdapter();
-    hapo_Adapter = new HapoAdapter();
-
-
-    mpid_Controller.reset(pid_Controller);
-    mge3_Adapter.reset(ge3_Adapter);
-    mqingyuan_Adapter.reset(qingyuan_Adapter);
-    mvv7_Adapter.reset(vv7_Adapter);
-    mzhongche_Adapter.reset(zhongche_Adapter);
-    mbus_Adapter.reset(bus_Adapter);
-    mhapo_Adapter.reset(hapo_Adapter);
-
-    frenetPlanner = new FrenetPlanner();
-    //    laneChangePlanner = new LaneChangePlanner();
-
-    mfrenetPlanner.reset(frenetPlanner);
-    //    mlaneChangePlanner.reset(laneChangePlanner);
-
-}
-
-
-void iv::decition::DecideGps00::phaseSpeedDecition(iv::decition::Decition  decition, double secSpeed, double obsDis, double obsSpeed, GPS_INS gpsIns ) {
-
-    pid_Controller->getControlDecition( gpsIns, gpsTraceNow,  dSpeed,  obsDis,  obsSpeed, false, true, &decition);
-
-    if(ServiceCarStatus.msysparam.mvehtype=="ge3"){
-        ge3_Adapter->getAdapterDeciton(gpsIns, gpsTraceNow, dSpeed, obsDis,obsSpeed,  decition->accelerator,ServiceCarStatus.mfCalAcc  ,changingDangWei, &decition);
-    }else if( ServiceCarStatus.msysparam.mvehtype=="qingyuan"){
-        qingyuan_Adapter->getAdapterDeciton(gpsIns, gpsTraceNow, dSpeed, obsDis,obsSpeed,  decition->accelerator,ServiceCarStatus.mfCalAcc  ,changingDangWei, &decition);
-    }else if( ServiceCarStatus.msysparam.mvehtype=="vv7"){
-        vv7_Adapter->getAdapterDeciton(gpsIns, gpsTraceNow, dSpeed, obsDis,obsSpeed,  decition->accelerator,ServiceCarStatus.mfCalAcc  ,changingDangWei, &decition);
-    }else if( ServiceCarStatus.msysparam.mvehtype=="zhongche"){
-        zhongche_Adapter->getAdapterDeciton(gpsIns, gpsTraceNow, dSpeed, obsDis,obsSpeed,  decition->accelerator,ServiceCarStatus.mfCalAcc  ,changingDangWei, &decition);
-    }else if(ServiceCarStatus.msysparam.mvehtype=="bus"){
-        bus_Adapter->getAdapterDeciton(gpsIns, gpsTraceNow, dSpeed, obsDis,obsSpeed,  decition->accelerator,ServiceCarStatus.mfCalAcc  ,changingDangWei, &decition);
-    }else if(ServiceCarStatus.msysparam.mvehtype=="hapo"){
-        hapo_Adapter->getAdapterDeciton(gpsIns, gpsTraceNow, dSpeed, obsDis,obsSpeed,  decition->accelerator,ServiceCarStatus.mfCalAcc  ,changingDangWei, &decition);
-    }
-}
-
-
-
-std::vector<iv::Point2D> iv::decition::DecideGps00::getGpsTrace(iv::GPS_INS now_gps_ins, const std::vector<GPSData> gpsMapLine, int lastIndex, bool circleMode) {
-    vector<iv::Point2D> trace;
-    //	int  PathPoint = Compute00().getNearestPointIndex(now_gps_ins, gpsMapLine, DecideGps00::lastGpsIndex, DecideGps00::minDis, DecideGps00::maxAngle);
-    /*if (PathPoint != -1)
-        lastGpsIndex = PathPoint;*/
-
-    if (gpsMapLine.size() > 600 && PathPoint >= 0) {
-        int aimIndex;
-        if(circleMode){
-            aimIndex=PathPoint+600;
-        }else{
-            aimIndex=min((PathPoint+600),(int)gpsMapLine.size());
-        }
-
-        for (int i = PathPoint; i < aimIndex; i++)
-        {
-            int index = i % gpsMapLine.size();
-            Point2D pt = Coordinate_Transfer((*gpsMapLine[index]).gps_x, (*gpsMapLine[index]).gps_y, now_gps_ins);
-            pt.x += offset_real * 0.032;
-            pt.v1 = (*gpsMapLine[index]).speed_mode;
-            pt.v2 = (*gpsMapLine[index]).mode2;
-            pt.roadMode=(*gpsMapLine[index]).roadMode;
-            if (gpsMapLine[index]->roadMode==3 && !hasZhuched)
-            {
-                readyZhucheMode = true;
-                DecideGps00::zhuchePointNum = index;
-            }
-
-
-
-            if (gpsMapLine[index]->roadMode==3 && !hasZhuched)
-            {
-                readyZhucheMode = true;
-                DecideGps00::zhuchePointNum = index;
-            }
-
-            //csvv7
-            if (gpsMapLine[index]->speed_mode==22 || gpsMapLine[index]->speed_mode==23)
-            {
-                readyParkMode = true;
-                DecideGps00::finishPointNum = index;
-            }
-
-            //			if (pt.v1 == 22 || pt.v1 == 23)
-            //			{
-            //				readyParkMode = true;
-            //				DecideGps00::finishPointNum = i;
-            //			}
-
-
-            switch (pt.v1)
-            {
-            case 0:
-                pt.speed = 80;
-                break;
-            case 1:
-                pt.speed = 25;
-                break;
-            case 2:
-                pt.speed =25;
-                break;
-            case 3:
-                pt.speed = 20;
-                break;
-            case 4:
-                pt.speed =18;
-                break;
-            case 5:
-                pt.speed = 18;
-                break;
-            case 7:
-                pt.speed = 10;
-                break;
-            case 22:
-                pt.speed = 5;
-                break;
-            case 23:
-                pt.speed = 5;
-                break;
-            default:
-                break;
-            }
-            trace.push_back(pt);
-        }
-    }
-    return trace;
-}
-
-std::vector<iv::Point2D>  iv::decition::DecideGps00::getGpsTraceOffset(std::vector<Point2D> gpsTrace, double offset) {
-
-    if (offset==0)
-    {
-        return gpsTrace;
-    }
-
-    std::vector<iv::Point2D> trace;
-    for (int j = 0; j < gpsTrace.size(); j++)
-    {
-        double sumx1 = 0, sumy1 = 0, count1 = 0;
-        double sumx2 = 0, sumy2 = 0, count2 = 0;
-        for (int k = max(0, j - 4); k <= j; k++)
-        {
-            count1 = count1 + 1;
-            sumx1 += gpsTrace[k].x;
-            sumy1 += gpsTrace[k].y;
-        }
-        for (int k = j; k <= min(gpsTrace.size() - 1, (size_t)(j + 4)); k++)
-        {
-            count2 = count2 + 1;
-            sumx2 += gpsTrace[k].x;
-            sumy2 += gpsTrace[k].y;
-        }
-        sumx1 /= count1; sumy1 /= count1;
-        sumx2 /= count2; sumy2 /= count2;
-
-        double anglevalue = atan2(sumy2 - sumy1, sumx2 - sumx1);
-
-        double carFrontx = gpsTrace[j].x;// -Form1.CarRear * Math.Cos(anglevalue);
-        double carFronty = gpsTrace[j].y;// -Form1.CarRear * Math.Sin(anglevalue);
-
-        double avoidLenth = abs(offset);
-        if (offset<0)
-        {
-            Point2D ptLeft(carFrontx + avoidLenth * cos(anglevalue + PI / 2),
-                           carFronty + avoidLenth  * sin(anglevalue + PI / 2));
-            ptLeft.speed = gpsTrace[j].speed;
-            ptLeft.v1 = gpsTrace[j].v1;
-            ptLeft.v2 = gpsTrace[j].v2;
-            trace.push_back(ptLeft);
-        }
-        else
-        {
-            Point2D ptRight(carFrontx + avoidLenth  * cos(anglevalue - PI / 2),
-                            carFronty + avoidLenth  * sin(anglevalue - PI / 2));
-            ptRight.speed = gpsTrace[j].speed;
-            ptRight.v1 = gpsTrace[j].v1;
-            ptRight.v2 = gpsTrace[j].v2;
-
-
-            trace.push_back(ptRight);
-        }
-    }
-    return trace;
-}
-
-
-double iv::decition::DecideGps00::getAngle(std::vector<Point2D> gpsTrace,GPS_INS gpsIns,iv::decition::Decition decition) {
-    double angle=0;
-    if ( abs(iv::decition::DecideGps00().minDis) < 20 && abs(iv::decition::DecideGps00().maxAngle) < 100)
-    {
-        //   angle = iv::decition::Compute00().getDecideAngle(gpsTrace, realspeed);
-        pid_Controller->getControlDecition(gpsIns, gpsTrace,  -1,  -1,  -1, true, false, &decition);
-        angle= decition->wheel_angle;
-    }
-    return angle;
-}
-
-double iv::decition::DecideGps00::getSpeed(std::vector<Point2D> gpsTrace) {
-    double speed=0;
-    int speedPoint = iv::decition::Compute00().getSpeedPointIndex(gpsTrace, max(10.0, realspeed));
-    speed = gpsTrace[speedPoint].speed;
-    for (int i = 0; i < speedPoint; i++) {
-        speed = min(speed, gpsTrace[i].speed);
-    }
-    return speed;
-}
-
-
-
-
-//void iv::decition::DecideGps00::getEsrObs(std::vector<iv::ObstacleBasic> obsRadars) {
-//
-//	if (!obsRadars.empty())
-//	{
-//		esrIndex = iv::decition::Compute00().getEsrIndex(gpsTrace, obsRadars);
-//
-//		if (esrIndex != -1)
-//		{
-//			 esrDistance = obsRadars[esrIndex].nomal_y;
-//
-//
-//
-//			obsSpeed = obsRadars[esrIndex].speed_y;
-//
-//		}
-//		else {
-//			esrDistance = -1;
-//		}
-//
-//	}
-//	else
-//	{
-//		esrIndex = -1;
-//		esrDistance = -1;
-//	}
-//	if (esrDistance < 0) {
-//		ODS("\n------------------>ESR障碍物距离:%f\n", esrDistance);
-//	}
-//	else {
-//		ODS("\n------------------>ESR障碍物距离:%f   ( %.05f , %.05f )\n", esrDistance, obsRadars[esrIndex].nomal_x, obsRadars[esrIndex].nomal_y);
-//	}
-//
-//	ODS("\n------------------>ESR障碍物速度:%f\n", obsSpeed);
-//}
-
-
-
-void iv::decition::DecideGps00::getEsrObsDistance(std::vector<Point2D> gpsTrace, int roadNum) {
-
-
-    int esrPathpoint;
-
-    esrIndex = iv::decition::Compute00().getEsrIndex(gpsTrace, roadNum, &esrPathpoint);
-
-    if (esrIndex != -1)
-    {
-        //优化
-        //        double distance = 0.0;
-        //        for(int i=0; i<esrPathpoint; ++i){
-        //            distance+=DirectDistance(gpsTrace[i].x,gpsTrace[i].y,gpsTrace[i+1].x,gpsTrace[i+1].y);
-        //        }
-        //        esrDistance = distance - Esr_Y_Offset;
-        //        if(esrDistance<=0){
-        //            esrDistance=1;
-        //        }
-
-
-        esrDistance = ServiceCarStatus.obs_radar[esrIndex].nomal_y;
-        obsSpeed = ServiceCarStatus.obs_radar[esrIndex].speed_y;
-
-    }
-    else {
-        esrDistance = -1;
-    }
-}
-
-
-
-
-void iv::decition::DecideGps00::getEsrObsDistanceAvoid() {
-
-    esrIndexAvoid = iv::decition::Compute00().getEsrIndexAvoid(gpsTraceAvoid);
-
-    if (esrIndexAvoid != -1)
-    {
-        esrDistanceAvoid = ServiceCarStatus.obs_radar[esrIndexAvoid].nomal_y;
-        obsSpeedAvoid = ServiceCarStatus.obs_radar[esrIndexAvoid].speed_y;
-
-    }
-    else {
-        esrDistanceAvoid = -1;
-    }
-
-    if (esrDistanceAvoid < 0) {
-        std::cout << "\nESR障碍物距离Avoid:%f\n" << esrDistanceAvoid << std::endl;
-    }
-    else {
-        std::cout << "\nESR障碍物距离Avoid:%f   %d:( %.05f , %.05f ,%.05f )\n" << esrDistanceAvoid << esrIndexAvoid << ServiceCarStatus.obs_radar[esrIndexAvoid].nomal_x << ServiceCarStatus.obs_radar[esrIndexAvoid].nomal_y << std::endl;
-    }
-
-    std::cout << "\nESR障碍物速度Avoid:%f\n" << obsSpeedAvoid <<std::endl;
-}
-
-
-
-
-double iv::decition::DecideGps00::limitAngle(double speed, double angle) {
-    double preAngle = angle;
-
-    if (speed > 15)
-    {
-        if (preAngle > 350)
-        {
-            preAngle = 350;
-        }
-        if (preAngle < -350)
-        {
-            preAngle = -350;
-        }
-    }
-    if (speed > 22)
-    {
-        if (preAngle > 200)
-        {
-            preAngle = 200;
-        }
-        if (preAngle < -200)
-        {
-            preAngle = -200;
-        }
-    }
-    if (speed > 25)
-    {
-        if (preAngle > 150)
-        {
-            preAngle = 150;
-        }
-        if (preAngle < -150)
-        {
-            preAngle = -150;
-        }
-    }
-    if (speed > 30)
-    {
-        if (preAngle > 70)
-        {
-            preAngle = 70;
-        }
-        if (preAngle < -70)
-        {
-            preAngle = -70;
-        }
-    }
-    if (speed > 45)                     //20
-    {
-        if (preAngle > 15)
-        {
-            preAngle = 15;
-        }
-        if (preAngle < -15)
-        {
-            preAngle = -15;
-        }
-    }
-    return preAngle;
-}
-
-
-
-double iv::decition::DecideGps00::limitSpeed(double angle, double speed) {
-
-    if (abs(angle) > 500 && speed > 8) speed = 8;
-    else if (abs(angle) > 350 && speed > 14) speed = 14;
-    else if (abs(angle) > 200 && speed > 21) speed = 21;
-    else if (abs(angle) > 150 && speed > 24) speed = 24;
-    else if (abs(angle) > 60 && speed > 29) speed = 29;
-    else if (abs(angle) > 20 && speed > 34) speed = 34;
-    return max(0.0, speed);
-}
-
-
-bool iv::decition::DecideGps00::checkAvoidEnable(double avoidX, iv::LidarGridPtr lidarGridPtr,int roadNum) {
-
-    if ((obsDisVector[roadNum]>0 && obsDisVector[roadNum]<obsDisVector[roadNow]+Veh_Lenth)||
-            (obsDisVector[roadNum]>0 && obsDisVector[roadNum]<15))
-    {
-        return false;
-    }
-
-    if (roadNum-roadNow>1)
-    {
-        for (int i = roadNow+1; i < roadNum; i++)
-        {
-            if (obsDisVector[i] < 8 + (i-roadNow) * 2 && obsDisVector[i]>0) {
-                return false;
-            }
-        }
-
-    }
-
-    else if (roadNow-roadNum>1)
-    {
-        for (int i = roadNow-1; i >roadNum; i--)
-        {
-            if (obsDisVector[i] < 8 + (roadNow-i) * 2 && obsDisVector[i]>0) {
-                return false;
-            }
-        }
-    }
-    return true;
-}
-
-
-
-bool iv::decition::DecideGps00::checkReturnEnable(double avoidX, iv::LidarGridPtr lidarGridPtr, int roadNum) {
-    //lsn
-    if (obsDisVector[roadNum]>0 && obsDisVector[roadNum]<20)
-    {
-        return false;
-    }
-    if ((obsDisVector[roadNum]>0 && obsDisVector[roadNum]<50 && obsDisVector[roadNum]< obsDisVector[roadNow]) ||
-            (obsDisVector[roadNum]>0 && obsDisVector[roadNum]<50 && obsDisVector[roadNow]<0))
-    {
-        return false;
-    }
-
-
-    if (roadNum - roadNow>1)
-    {
-        for (int i = roadNow + 1; i < roadNum; i++)
-        {
-            if (obsDisVector[i] < 8 + (i-roadNow) * 2 && obsDisVector[i]>0) {
-                return false;
-            }
-        }
-
-    }
-
-    else if (roadNow - roadNum>1)
-    {
-        for (int i = roadNow - 1; i >roadNum; i--)
-        {
-            if (obsDisVector[i] < 8 + (roadNow-i) * 2 && obsDisVector[i]>0) {
-                return false;
-            }
-        }
-    }
-    return true;
-}
-
-
-void iv::decition::DecideGps00::getObsAvoid(iv::LidarGridPtr lidarGridPtr) {
-
-
-
-    if (lidarGridPtr == NULL)
-    {
-        iv::decition::DecideGps00::lidarDistanceAvoid = iv::decition::DecideGps00::lastLidarDisAvoid;
-    }
-    else {
-        obsPointAvoid = Compute00().getLidarObsPointAvoid(gpsTraceAvoid, lidarGridPtr);
-        iv::decition::DecideGps00::lastLidarDisAvoid = iv::decition::DecideGps00::lidarDistanceAvoid;
-    }
-    std::cout << "\nLidarAvoid距离:%f\n" << iv::decition::DecideGps00::lidarDistanceAvoid << std::endl;
-    getEsrObsDistanceAvoid();
-
-    //lidarDistanceAvoid = -1;   //20200103 apollo_fu
-
-    if (esrDistanceAvoid>0 && iv::decition::DecideGps00::lidarDistanceAvoid > 0)
-    {
-        if (iv::decition::DecideGps00::lidarDistanceAvoid >= esrDistanceAvoid)
-        {
-            obsDistanceAvoid = esrDistanceAvoid;
-            obsSpeedAvoid = ServiceCarStatus.obs_radar[esrIndexAvoid].speed_y;
-        }
-        else if (!ServiceCarStatus.obs_radar.empty())
-        {
-            obsDistanceAvoid = iv::decition::DecideGps00::lidarDistanceAvoid;
-            obsSpeedAvoid = Compute00().getObsSpeed(obsPointAvoid, secSpeed);
-            std::cout << "\n计算obsSpeed:%f\n" << obsSpeedAvoid << std::endl;
-        }
-        else
-        {
-            obsDistanceAvoid = iv::decition::DecideGps00::lidarDistanceAvoid;
-            obsSpeedAvoid = obsSpeedAvoid = 0 - secSpeed;;
-            std::cout << "\n毫米波无数据,计算obsSpeed:%f\n" << obsSpeedAvoid << std::endl;
-        }
-    }
-    else if (esrDistanceAvoid>0)
-    {
-        obsDistanceAvoid = esrDistanceAvoid;
-        obsSpeedAvoid = ServiceCarStatus.obs_radar[esrIndexAvoid].speed_y;
-    }
-    else if (iv::decition::DecideGps00::lidarDistanceAvoid > 0)
-    {
-        obsDistanceAvoid = iv::decition::DecideGps00::lidarDistanceAvoid;
-        obsSpeedAvoid = Compute00().getObsSpeed(obsPointAvoid, secSpeed);
-        std::cout << "\n计算obsSpeed:%f\n" << obsSpeedAvoid << std::endl;
-    }
-    else {
-        obsDistanceAvoid = esrDistanceAvoid;
-        obsSpeedAvoid = 0 - secSpeed;
-    }
-
-    std::cout << "\n最终得出的obsDistanceAvoid:%f\n" << obsDistanceAvoid << std::endl;
-
-
-
-
-
-    if (iv::decition::DecideGps00::obsDistanceAvoid <0 && obsLostTimeAvoid<4)
-    {
-        iv::decition::DecideGps00::obsDistanceAvoid = iv::decition::DecideGps00::lastDistanceAvoid;
-        obsLostTimeAvoid++;
-    }
-    else
-    {
-        obsLostTimeAvoid = 0;
-        iv::decition::DecideGps00::lastDistanceAvoid = -1;
-    }
-
-
-
-
-    if (obsDistanceAvoid>0)
-    {
-        iv::decition::DecideGps00::lastDistanceAvoid = obsDistanceAvoid;
-    }
-
-    std::cout << "\nODSAvoid距离:%f\n" << iv::decition::DecideGps00::obsDistanceAvoid << std::endl;
-}
-
-void iv::decition::DecideGps00::init() {
-    for (int i = 0; i < roadSum; i++)
-    {
-        lastEsrIdVector.push_back(-1);
-        lastEsrCountVector.push_back(0);
-        GPS_INS gps_ins;
-        gps_ins.gps_x = 0;
-        gps_ins.gps_y = 0;
-        startAvoidGpsInsVector.push_back(gps_ins);
-        avoidMinDistanceVector.push_back(0);
-    }
-}
-
-
-
-#include <QTime>
-
-void iv::decition::DecideGps00::computeObsOnRoad(iv::LidarGridPtr lidarGridPtr, std::vector<Point2D> gpsTrace, int roadNum,
-                                                 const std::vector<GPSData> gpsMapLine, std::vector<iv::Perception::PerceptionOutput> lidar_per) {
-
-    //    QTime xTime;
-    //   xTime.start();
-    //    qDebug("time 0 is %d ",xTime.elapsed());
-    double obs,obsSd;
-    if (lidarGridPtr == NULL)
-    {
-        lidarDistance = lastLidarDis;
-        //	lidarDistance = lastlidarDistance;
-
-    }
-    else {
-        obsPoint = Compute00().getLidarObsPoint(gpsTrace, lidarGridPtr);
-        float lidarXiuZheng=0;
-        if(!ServiceCarStatus.useMobileEye){
-            lidarXiuZheng=0-ServiceCarStatus.msysparam.frontGpsXiuzheng;
-        }
-        lidarDistance = obsPoint.y + lidarXiuZheng;   //激光距离推到车头  gjw20191110 lidar
-        //    lidarDistance=-1;
-        if (lidarDistance<0)
-        {
-            lidarDistance = -1;
-        }
-        lastLidarDis = lidarDistance;
-    }
-
-
-   // obsPredict start
-    if(ServiceCarStatus.useObsPredict){
-        float preObsDis=200;
-        if(!lidar_per.empty()){
-                 preObsDis=PredictObsDistance(  secSpeed,  gpsTrace, lidar_per);
-                lastPreObsDistance=preObsDis;
-            }else{
-                preObsDis=lastPreObsDistance;
-            }
-            if(preObsDis<lidarDistance || lidarDistance==-1){
-                lidarDistance=preObsDis;
-            }
-    }
-    // obsPredict end
-
-    //    qDebug("time 1 is %d ",xTime.elapsed());
-    //    if(gpsMapLine[PathPoint]->roadMode==14||gpsMapLine[PathPoint]->roadMode==15){
-    //        lidarDistance=-1;
-    //    }
-
-    getEsrObsDistance(gpsTrace, roadNum);
-
-    //   qDebug("time 2 is %d ",xTime.elapsed());
-    //  esrDistance=-1;
-
-    //    if(PathPoint>2992 && PathPoint<4134){
-    //        lidarDistance=-1;
-    //    }
-
-
-    //    if(PathPoint>10193 && PathPoint<10929){
-    //        esrDistance=-1;
-    //    }
-
-
-    if(lidarDistance<0){
-        lidarDistance=500;
-    }
-    if(esrDistance>30){
-        esrDistance=500;
-    }
-
-
-
-    if(esrDistance<0){
-        esrDistance=500;
-    }
-
-
-    std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "激光雷达距离:" << lidarDistance << std::endl;
-
-
-    //        if(esrDistance>30){
-    //            esrDistance=-1;
-    //        }
-
-
-
-    //            if(esrDistance>=15 && esrDistance<=50&& ServiceCarStatus.mLidarS>0&&ServiceCarStatus.mLidarPer>0 ){
-    //                if(abs(lidarDistance-esrDistance)>5){
-
-    //                    esrDistance=-1;
-    //                }
-
-    //            }
-
-
-
-    //            if(esrDistance>=1&& esrDistance<=50&& ServiceCarStatus.mLidarS>0&&ServiceCarStatus.mLidarPer>0
-    //                && gpsMapLine[PathPoint]->runMode == 1    ){
-    //                if(abs(lidarDistance-esrDistance)>5){
-
-    //                    esrDistance=-1;
-    //                }
-
-    //            }
-
-
-
-    std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "毫米波距离:" << esrDistance << std::endl;
-    myesrDistance = esrDistance;
-
-
-
-    if(lidarDistance==500){
-        lidarDistance=-1;
-    }
-    if(esrDistance==500){
-        esrDistance=-1;
-    }
-
-
-    ServiceCarStatus.mRadarObs = esrDistance;
-    ServiceCarStatus.mLidarObs = lidarDistance;
-
-
-    //zhuanwan pingbi haomibo
-    if(gpsTraceNow[0].v1==4||gpsTraceNow[0].v1==5){
-        esrDistance=-1;
-    }
-
-    if (esrDistance>0 && lidarDistance > 0)
-    {
-        if (lidarDistance >= esrDistance)
-        {
-            //	obsDistance = esrDistance;
-            obs = esrDistance;
-            //	obsSpeed = ServiceCarStatus.obs_radar[esrIndex].speed_y;
-            obsSd=ServiceCarStatus.obs_radar[esrIndex].speed_y;
-        }
-        else if (!ServiceCarStatus.obs_radar.empty())
-        {
-            //	obsDistance = lidarDistance;
-            obs = lidarDistance;
-            //	obsSpeed = Compute00().getObsSpeed(obsPoint, secSpeed);
-            obsSd = Compute00().getObsSpeed(obsPoint, secSpeed);
-            std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "计算obsSpeed:" << obsSpeed << std::endl;
-        }
-        else
-        {
-            //	obsDistance = lidarDistance;
-            obs=lidarDistance;
-            //	obsSpeed = 0 - secSpeed;
-            obsSd = 0 -secSpeed;
-            std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "毫米波无数据,计算obsSpeed:" << obsSpeed << std::endl;
-        }
-    }
-    else if (esrDistance>0)
-    {
-        //		obsDistance = esrDistance;
-        //		obsSpeed = ServiceCarStatus.obs_radar[esrIndex].speed_y;
-        obs = esrDistance;
-        obsSd = ServiceCarStatus.obs_radar[esrIndex].speed_y;
-    }
-    else if (lidarDistance > 0)
-    {
-        //		obsDistance = lidarDistance;
-        //		obsSpeed = Compute00().getObsSpeed(obsPoint, secSpeed);
-        obs = lidarDistance;
-        obsSd = Compute00().getObsSpeed(obsPoint, secSpeed);
-        std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "计算obsSpeed:" << obsSpeed << std::endl;
-    }
-    else {
-        //		obsDistance = esrDistance;
-        //		obsSpeed = 0 - secSpeed;
-        obs = esrDistance;
-        obsSd = 0 - secSpeed;
-    }
-
-    if(roadNum==roadNow){
-        obsDistance=obs;
-        obsSpeed=obsSd;
-    }
-
-
-    //    if (obsDistance <0 && obsLostTime<4)
-    //    {
-    //        obsDistance = lastDistance;
-    //        obsLostTime++;
-    //    }
-    //    else
-    //    {
-    //        obsLostTime = 0;
-    //        lastDistance = -1;
-    //    }
-
-
-    std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "最终得出的obsDistance:" << obsDistance << std::endl;
-
-    ServiceCarStatus.mObs = obsDistance;
-    if(ServiceCarStatus.mObs>100){
-        ServiceCarStatus.mObs =-1;
-    }
-
-    if (obsDistance>0)
-    {
-        lastDistance = obsDistance;
-    }
-
-    //lsn
-    if(obs<0){
-        obsDisVector[roadNum]=500;
-    }else{
-        obsDisVector[roadNum]=obs;
-    }
-
-    //   qDebug("time 3 is %d ",xTime.elapsed());
-
-}
-
-
-
-
-//1220
-void iv::decition::DecideGps00::computeRearObsOnRoad(iv::LidarGridPtr lidarGridPtr, std::vector<Point2D> gpsTrace, int roadNum,
-                                                     const std::vector<GPSData> gpsMapLine) {
-
-    double obs,obsSd;
-
-    if(!ServiceCarStatus.obs_rear_radar.empty()){
-        getRearEsrObsDistance(gpsTrace, roadNum);
-    }
-    if (lidarGridPtr == NULL)
-    {
-        lidarDistance = lastLidarDis;
-        //	lidarDistance = lastlidarDistance;
-
-    }
-    else {
-        obsPoint = Compute00().getLidarRearObsPoint(gpsTrace, lidarGridPtr);
-        float lidarXiuZheng=0;
-        if(!ServiceCarStatus.useMobileEye){
-            lidarXiuZheng = ServiceCarStatus.msysparam.rearGpsXiuzheng;
-        }
-        if(abs(obsPoint.y)>lidarXiuZheng)
-            lidarDistance = abs(obsPoint.y)-lidarXiuZheng;   //激光距离推到车头 1220
-
-        //    lidarDistance=-1;
-        if (lidarDistance<0)
-        {
-            lidarDistance = -1;
-        }
-        lastLidarDis = lidarDistance;
-    }
-
-    //    if(gpsMapLine[PathPoint]->roadMode==14||gpsMapLine[PathPoint]->roadMode==15){
-    //        lidarDistance=-1;
-    //    }
-
-    //  getEsrObsDistance(gpsTrace, roadNum);
-    esrDistance=-1;
-
-
-    //    if(PathPoint>2992 && PathPoint<4134){
-    //        lidarDistance=-1;
-    //    }
-
-
-    //    if(PathPoint>10193 && PathPoint<10929){
-    //        esrDistance=-1;
-    //    }
-
-
-    if(lidarDistance<0){
-        lidarDistance=500;
-    }
-    if(esrDistance<0){
-        esrDistance=500;
-    }
-
-
-    std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "激光雷达距离:" << lidarDistance << std::endl;
-
-
-    //        if(esrDistance>30){
-    //            esrDistance=-1;
-    //        }
-
-
-
-    //            if(esrDistance>=15 && esrDistance<=50&& ServiceCarStatus.mLidarS>0&&ServiceCarStatus.mLidarPer>0 ){
-    //                if(abs(lidarDistance-esrDistance)>5){
-
-    //                    esrDistance=-1;
-    //                }
-
-    //            }
-
-
-
-    //            if(esrDistance>=1&& esrDistance<=50&& ServiceCarStatus.mLidarS>0&&ServiceCarStatus.mLidarPer>0
-    //                && gpsMapLine[PathPoint]->runMode == 1    ){
-    //                if(abs(lidarDistance-esrDistance)>5){
-
-    //                    esrDistance=-1;
-    //                }
-
-    //            }
-
-
-
-    std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "毫米波距离:" << esrDistance << std::endl;
-    myesrDistance = esrDistance;
-
-
-
-    if(lidarDistance==500){
-        lidarDistance=-1;
-    }
-    if(esrDistance==500){
-        esrDistance=-1;
-    }
-
-
-    ServiceCarStatus.mRadarObs = esrDistance;
-    ServiceCarStatus.mLidarObs = lidarDistance;
-
-
-    //zhuanwan pingbi haomibo
-    if(gpsTraceNow[0].v1==4||gpsTraceNow[0].v1==5){
-        esrDistance=-1;
-    }
-
-    if (esrDistance>0 && lidarDistance > 0)
-    {
-        if (lidarDistance >= esrDistance)
-        {
-            //	obsDistance = esrDistance;
-            obs = esrDistance;
-            //	obsSpeed = ServiceCarStatus.obs_radar[esrIndex].speed_y;
-            obsSd=ServiceCarStatus.obs_radar[esrIndex].speed_y;
-        }
-        else if (!ServiceCarStatus.obs_radar.empty())
-        {
-            //	obsDistance = lidarDistance;
-            obs = lidarDistance;
-            //	obsSpeed = Compute00().getObsSpeed(obsPoint, secSpeed);
-            obsSd = Compute00().getObsSpeed(obsPoint, secSpeed);
-            std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "计算obsSpeed:" << obsSpeed << std::endl;
-        }
-        else
-        {
-            //	obsDistance = lidarDistance;
-            obs=lidarDistance;
-            //	obsSpeed = 0 - secSpeed;
-            obsSd = 0 -secSpeed;
-            std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "毫米波无数据,计算obsSpeed:" << obsSpeed << std::endl;
-        }
-    }
-    else if (esrDistance>0)
-    {
-        //		obsDistance = esrDistance;
-        //		obsSpeed = ServiceCarStatus.obs_radar[esrIndex].speed_y;
-        obs = esrDistance;
-        obsSd = ServiceCarStatus.obs_radar[esrIndex].speed_y;
-    }
-    else if (lidarDistance > 0)
-    {
-        //		obsDistance = lidarDistance;
-        //		obsSpeed = Compute00().getObsSpeed(obsPoint, secSpeed);
-        obs = lidarDistance;
-        obsSd = Compute00().getObsSpeed(obsPoint, secSpeed);
-        std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "计算obsSpeed:" << obsSpeed << std::endl;
-    }
-    else {
-        //		obsDistance = esrDistance;
-        //		obsSpeed = 0 - secSpeed;
-        obs = esrDistance;
-        obsSd = 0 - secSpeed;
-    }
-
-    if(roadNum==roadNow){
-        obsDistance=obs;
-        obsSpeed=obsSd;
-    }
-
-
-    if (obsDistance <0 && obsLostTime<4)
-    {
-        obsDistance = lastDistance;
-        obsLostTime++;
-    }
-    else
-    {
-        obsLostTime = 0;
-        lastDistance = -1;
-    }
-
-
-    std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "最终得出的obsDistance:" << obsDistance << std::endl;
-
-    ServiceCarStatus.mObs = obsDistance;
-    if(ServiceCarStatus.mObs>100){
-        ServiceCarStatus.mObs =-1;
-    }
-
-    if (obsDistance>0)
-    {
-        lastDistance = obsDistance;
-    }
-
-    //lsn
-    if(obs<0){
-        obsDisVector[roadNum]=500;
-    }else{
-        obsDisVector[roadNum]=obs;
-    }
-
-}
-
-
-
-void iv::decition::DecideGps00::predictObsOnRoad(std::vector<iv::Perception::PerceptionOutput> lidar_per,std::vector<Point2D> gpsTrace,double realSpeed){
-    double preObsDis;
-
-    if(!lidar_per.empty()){
-        preObsDis=PredictObsDistance(  realSpeed,  gpsTrace, lidar_per);
-        lastPreObsDistance=preObsDis;
-
-    }else{
-        preObsDis=lastPreObsDistance;
-    }
-    if(preObsDis<obsDistance){
-        obsDistance=preObsDis;
-        lastDistance=obsDistance;
-    }
-}
-
-int iv::decition::DecideGps00::chooseAvoidRoad(iv::LidarGridPtr lidarGridPtr, GPS_INS now_gps_ins, const std::vector<GPSData> gpsMapLine,std::vector<iv::Perception::PerceptionOutput> lidar_per) {
-    roadPre = -1;
-
-    if (roadNow<roadOri)
-    {
-        for (int i = 0; i < roadNow; i++)
-        {
-            gpsTraceAvoid.clear();
-            //	gpsTraceAvoid = getGpsTrace(now_gps_ins, gmapsR[int(abs(roadWidth * 2)*(roadOri-i))], lastGpsIndex);
-            avoidX = (roadWidth)*(roadOri - i);
-            gpsTraceAvoid = getGpsTraceOffset(gpsTraceOri, avoidX);
-            //	computeObsOnRoad(lidarGridPtr, gpsTraceAvoid, roadNow + i);
-            computeObsOnRoad(lidarGridPtr, gpsTraceNow, roadNow,gpsMapLine,lidar_per);
-        }
-
-
-        for (int i = roadOri+1; i < roadSum; i++)
-        {
-            gpsTraceAvoid.clear();
-            //	gpsTraceAvoid = getGpsTrace(now_gps_ins, gmapsL[int(abs(roadWidth * 2)*(i - roadOri))], lastGpsIndex);
-            avoidX = (roadWidth)*(roadOri - i);
-            gpsTraceAvoid = getGpsTraceOffset(gpsTraceOri, avoidX);
-            //	bsOnRoad(lidarGridPtr, gpsTraceAvoid, roadNow + i);
-            computeObsOnRoad(lidarGridPtr, gpsTraceAvoid, i,gpsMapLine,lidar_per);
-        }
-    }
-    else if (roadNow>roadOri)
-    {
-        for (int i = 0; i < roadOri; i++)
-        {
-            gpsTraceAvoid.clear();
-            //	gpsTraceAvoid = getGpsTrace(now_gps_ins, gmapsR[int(abs(roadWidth * 2)*(roadOri - i))], lastGpsIndex);
-            avoidX = (roadWidth)*(roadOri - i);
-            gpsTraceAvoid = getGpsTraceOffset(gpsTraceOri, avoidX);
-            //	computeObsOnRoad(lidarGridPtr, gpsTraceAvoid, roadNow + i);
-           computeObsOnRoad(lidarGridPtr, gpsTraceNow, roadNow,gpsMapLine,lidar_per);
-        }
-        for (int i = roadNow + 1; i < roadSum; i++)
-        {
-            gpsTraceAvoid.clear();
-            //		gpsTraceAvoid = getGpsTrace(now_gps_ins, gmapsL[int(abs(roadWidth * 2)*(i - roadOri))], lastGpsIndex);
-            avoidX = (roadWidth)*(roadOri - i);
-            gpsTraceAvoid = getGpsTraceOffset(gpsTraceOri, avoidX);
-            //	computeObsOnRoad(lidarGridPtr, gpsTraceAvoid, roadNow + i);
-           computeObsOnRoad(lidarGridPtr, gpsTraceNow, roadNow,gpsMapLine,lidar_per);
-        }
-
-    }
-
-    else
-    {
-        for (int i = 0; i < roadOri; i++)
-        {
-            gpsTraceAvoid.clear();
-            //	gpsTraceAvoid = getGpsTrace(now_gps_ins, gmapsR[int(abs(roadWidth * 2)*(roadOri - i))], lastGpsIndex);
-            avoidX = (roadWidth)*(roadOri - i);
-            gpsTraceAvoid = getGpsTraceOffset(gpsTraceOri, avoidX);
-            //	computeObsOnRoad(lidarGridPtr, gpsTraceAvoid, roadNow + i);
-           computeObsOnRoad(lidarGridPtr, gpsTraceNow, roadNow,gpsMapLine,lidar_per);
-        }
-        for (int i = roadOri + 1; i < roadSum; i++)
-        {
-            gpsTraceAvoid.clear();
-            //		gpsTraceAvoid = getGpsTrace(now_gps_ins, gmapsL[int(abs(roadWidth * 2)*(i - roadOri))], lastGpsIndex);
-            avoidX = (roadWidth)*(roadOri - i);
-            gpsTraceAvoid = getGpsTraceOffset(gpsTraceOri, avoidX);
-            //	computeObsOnRoad(lidarGridPtr, gpsTraceAvoid, roadNow + i);
-           computeObsOnRoad(lidarGridPtr, gpsTraceNow, roadNow,gpsMapLine,lidar_per);
-        }
-
-    }
-
-    if (lidarGridPtr!=NULL)
-    {
-        hasCheckedAvoidLidar = true;
-    }
-
-    for(int i=0; i<roadSum;i++){
-        std::cout<<"\odsjuli====================:\n"<<i<<"chedaojuli:"<<obsDisVector[i]<<endl;
-
-    }
-
-    checkAvoidObsTimes++;
-    if (checkAvoidObsTimes<4 || hasCheckedAvoidLidar==false)
-    {
-        return - 1;
-    }
-
-
-    for (int i = 1; i < roadSum; i++)
-    {
-        if (roadNow + i < roadSum) {
-            avoidX = (roadOri-roadNow-i)*roadWidth;
-            if (checkAvoidEnable(avoidX, lidarGridPtr, roadNow+i))
-            {
-                /*if (roadNow==roadOri)
-                {
-                    avoidRunDistance = obsDisVector[roadNow] + Veh_Lenth;
-                    startAvoid_gps_ins = now_gps_ins;
-                }	*/
-                avoidMinDistanceVector[roadNow]= obsDisVector[roadNow] + Veh_Lenth;
-                startAvoidGpsInsVector[roadNow] = now_gps_ins;
-                roadPre = roadNow + i;
-                return roadPre;
-            }
-        }
-
-        if (roadNow - i >= 0)
-        {
-            avoidX = (roadOri - roadNow+i)*roadWidth;
-            if (checkAvoidEnable(avoidX, lidarGridPtr, roadNow - i))
-            {
-                /*if (roadNow == roadOri)
-                {
-                    avoidRunDistance = obsDisVector[roadNow] + Veh_Lenth;
-                    startAvoid_gps_ins = now_gps_ins;
-                }*/
-                avoidMinDistanceVector[roadNow] = obsDisVector[roadNow] + Veh_Lenth;
-                startAvoidGpsInsVector[roadNow] = now_gps_ins;
-                roadPre = roadNow - i;
-                return roadPre;
-            }
-        }
-
-    }
-    return roadPre;
-}
-
-int iv::decition::DecideGps00::chooseBackRoad(iv::LidarGridPtr lidarGridPtr, GPS_INS now_gps_ins, std::vector<GPSData> gpsMapLine,std::vector<iv::Perception::PerceptionOutput> lidar_per) {
-    roadPre = -1;
-
-    computeObsOnRoad(lidarGridPtr, gpsTraceNow, roadNow,gpsMapLine,lidar_per);
-
-
-
-    if (roadNow>roadOri+1)
-    {
-        for (int i = roadOri+1; i < roadNow; i++)
-        {
-            gpsTraceBack.clear();
-            //	gpsTraceBack = getGpsTrace(now_gps_ins, gmapsL[int(abs(roadWidth * 2)*(i-roadOri))], lastGpsIndex);
-            avoidX = (roadWidth)*(roadOri - i);
-            gpsTraceBack = getGpsTraceOffset(gpsTraceOri, avoidX);
-            computeObsOnRoad(lidarGridPtr, gpsTraceNow, roadNow,gpsMapLine,lidar_per);
-        }
-    }
-    else if (roadNow < roadOri - 1) {
-
-        for (int i = roadOri - 1; i > roadNow; i--)
-        {
-            gpsTraceBack.clear();
-            //	gpsTraceBack = getGpsTrace(now_gps_ins, gmapsR[int(abs(roadWidth * 2)*(roadOri-i))], lastGpsIndex);
-            avoidX = (roadWidth)*(roadOri - i);
-            gpsTraceBack = getGpsTraceOffset(gpsTraceOri, avoidX);
-            computeObsOnRoad(lidarGridPtr, gpsTraceNow, roadNow,gpsMapLine,lidar_per);
-        }
-
-    }
-
-
-
-    if (lidarGridPtr != NULL)
-    {
-        hasCheckedBackLidar = true;
-    }
-
-
-
-    checkBackObsTimes++;
-    if (checkBackObsTimes<4 || hasCheckedBackLidar == false)
-    {
-        return -1;
-    }
-
-
-
-
-
-
-
-    //if ((GetDistance(now_gps_ins, startAvoid_gps_ins)>avoidRunDistance)&&
-    //(checkReturnEnable(avoidX, lidarGridPtr,roadOri)))
-    if ((GetDistance(now_gps_ins, startAvoidGpsInsVector[roadOri])>max(avoidMinDistanceVector[roadOri],30.0)) &&
-            (checkReturnEnable(avoidX, lidarGridPtr, roadOri)))
-    {
-        roadPre = roadOri;
-        return roadPre;
-    }
-
-    if (roadNow-roadOri>1)
-    {
-        for (int i = roadOri + 1;i < roadNow;i++) {
-            if (checkReturnEnable(avoidX, lidarGridPtr, i)&&
-                    (GetDistance(now_gps_ins, startAvoidGpsInsVector[i])>  avoidMinDistanceVector[i])&&
-                    (GetDistance(now_gps_ins, startAvoidGpsInsVector[i])> 30.0))
-            {
-                roadPre = i;
-                return roadPre;
-            }
-        }
-    }
-
-    else if (roadNow <roadOri-1)
-    {
-        for (int i = roadOri - 1;i > roadNow;i--) {
-            if (checkReturnEnable(avoidX, lidarGridPtr, i)&&
-                    (GetDistance(now_gps_ins, startAvoidGpsInsVector[i])>avoidMinDistanceVector[i])&&
-                    (GetDistance(now_gps_ins, startAvoidGpsInsVector[i])>  30.0))
-            {
-                roadPre = i;
-                return roadPre;
-            }
-        }
-    }
-
-    return roadPre;
-}
-
-
-double iv::decition::DecideGps00::trumpet() {
-    if (trumpetFirstCount)
-    {
-        trumpetFirstCount = false;
-        trumpetLastTime= GetTickCount();
-        trumpetTimeSpan = 0.0;
-    }
-    else
-    {
-        trumpetStartTime= GetTickCount();
-        trumpetTimeSpan += trumpetStartTime - trumpetLastTime;
-        trumpetLastTime = trumpetStartTime;
-    }
-
-    return trumpetTimeSpan;
-}
-
-
-
-
-double iv::decition::DecideGps00::transferP() {
-    if (transferFirstCount)
-    {
-        transferFirstCount = false;
-        transferLastTime= GetTickCount();
-        transferTimeSpan = 0.0;
-    }
-    else
-    {
-        transferStartTime= GetTickCount();
-        transferTimeSpan += transferStartTime - transferLastTime;
-        transferLastTime = transferStartTime;
-    }
-
-    return transferTimeSpan;
-}
-
-
-
-void  iv::decition::DecideGps00::handBrakePark(iv::decition::Decition  decition, long duringTime, GPS_INS now_gps_ins) {
-
-    if (abs(now_gps_ins.speed)>0.1)
-    {
-        decition->accelerator = 0;
-        decition->brake = 20;
-        decition->wheel_angle = 0;
-
-    }
-    else
-    {
-
-        decition->accelerator = 0;
-        decition->brake = 20;
-        decition->wheel_angle = 0;
-        handPark = true;
-        handParkTime = duringTime;
-    }
-
-}
-
-
-
-
-void iv::decition::DecideGps00::getMapBeside(std::vector<iv::GPSData> navigation_data, iv::GPS_INS now_gps_ins) {
-    gmapsL.clear();
-    gmapsR.clear();
-    for (int i = 0; i < 31; i++)
-    {
-        std::vector<iv::GPSData> gpsMapLineBeside;
-        //	gpsMapLineBeside = iv::decition::ComputeUnit().getBesideGpsMapLine(*ServiceCarStatus.location, navigation_data, -0.5*i);
-        gpsMapLineBeside = iv::decition::Compute00().getBesideGpsMapLine(now_gps_ins, navigation_data, -0.5*i);
-
-        gmapsL.push_back(gpsMapLineBeside);
-    }
-
-
-    for (int i = 0; i < 31; i++)
-    {
-        std::vector<iv::GPSData> gpsMapLineBeside;
-        //		gpsMapLineBeside = iv::decition::ComputeUnit().getBesideGpsMapLine(*ServiceCarStatus.location, navigation_data, 0.5*i);
-        gpsMapLineBeside = iv::decition::Compute00().getBesideGpsMapLine(now_gps_ins, navigation_data, 0.5*i);
-
-        gmapsR.push_back(gpsMapLineBeside);
-    }
-
-}
-
-
-bool iv::decition::DecideGps00::checkChaoCheBack(iv::LidarGridPtr lidarGridPtr) {
-
-    if (lidarGridPtr == NULL)
-    {
-        return false;
-        //	lidarDistance = lastlidarDistance;
-
-    }
-    else {
-
-
-
-
-        obsPoint = Compute00().getLidarObsPoint(gpsTraceOri, lidarGridPtr);
-        double lidarDistance = obsPoint.y - 2.5;   //激光距离推到车头
-        //     ODS("\n超车雷达距离:%f\n", lidarDistance);
-        if (lidarDistance >-20 && lidarDistance<35)
-        {
-            checkChaoCheBackCounts = 0;
-            return false;
-        }
-        else {
-            checkChaoCheBackCounts++;
-        }
-
-        if (checkChaoCheBackCounts>2) {
-            checkChaoCheBackCounts = 0;
-            return true;
-        }
-    }
-
-    return false;
-
-}
-
-void iv::decition::DecideGps00::updateGroupDate(GPS_INS now_gps_ins,float realspeed,float theta,float s){
-    Point2D pt = Coordinate_Transfer( now_gps_ins.gps_x, now_gps_ins.gps_y, group_ori_gps);
-
-    ServiceCarStatus.group_x_local=pt.x;
-    //  ServiceCarStatus.group_y_local=pt.y;
-    ServiceCarStatus.group_y_local=s;
-    if(realspeed<0.36){
-        ServiceCarStatus.group_velx_local=0;
-        ServiceCarStatus.group_vely_local=0;
-    }else{
-        ServiceCarStatus.group_velx_local=realspeed*sin(theta)/3.6;
-        ServiceCarStatus.group_vely_local=realspeed*cos(theta)/3.6;
-    }
-
-
-    ServiceCarStatus.group_pathpoint=PathPoint;
-
-}
-
-
-
-float  iv::decition::DecideGps00::ComputeTrafficLightSpeed(int traffic_light_color, int traffic_light_time,  const std::vector<GPSData> gpsMapLine,int traffic_light_pathpoint,
-                                                           int pathpoint,float secSpeed,float dSpeed){
-    float traffic_speed=200;
-    float traffic_dis=0;
-    float passTime;
-    float passSpeed;
-    bool passEnable=false;
-
-    if(abs(secSpeed)<0.1){
-        secSpeed=0;
-    }
-
-
-
-    if(pathpoint <= traffic_light_pathpoint){
-        for(int i=pathpoint;i<traffic_light_pathpoint;i++){
-            traffic_dis +=GetDistance(*gpsMapLine[i],*gpsMapLine[i+1]);
-        }
-    }else{
-        for(int i=pathpoint;i<gpsMapLine.size()-1;i++){
-            traffic_dis +=GetDistance(*gpsMapLine[i],*gpsMapLine[i+1]);
-        }
-        for(int i=0;i<traffic_light_pathpoint;i++){
-            traffic_dis+=GetDistance(*gpsMapLine[i],*gpsMapLine[i+1]);
-        }
-    }
-
-    //    if(traffic_light_color != 0)
-    //    {
-    //        int a = 3;
-    //    }
-
-
-    if(traffic_light_color==0 && traffic_dis<10){
-        traffic_speed=0;
-    }
-    //    else   //20200108
-    //    {
-    //        traffic_speed=10;
-    //    }
-    return  traffic_speed;
-
-    passSpeed = min((float)(dSpeed/3.6),secSpeed);
-    passTime = traffic_dis/(dSpeed/3.6);
-
-
-
-
-
-    switch(traffic_light_color){
-    case 0:
-        if(passTime>traffic_light_time+1 && traffic_dis>10){
-            passEnable=true;
-        }else{
-            passEnable=false;
-        }
-        break;
-    case 1:
-        if(passTime<traffic_light_time-1 && traffic_dis<10){
-            passEnable=true;
-        }else{
-            passEnable = false;
-        }
-        break;
-    case 2:
-        if(passTime<traffic_light_time){
-            passEnable= true;
-        }else{
-            passEnable=false;
-        }
-        break;
-
-
-    default:
-        break;
-    }
-
-    if(!passEnable){
-        if(traffic_dis<5){
-            traffic_speed=0;
-        }else if(traffic_dis<10){
-            traffic_speed=5;
-        }else if(traffic_dis<20){
-            traffic_speed=15;
-        }else if(traffic_dis<30){
-            traffic_speed=25;
-        }else if(traffic_dis<50){
-            traffic_speed=30;
-        }
-    }
-    return traffic_speed;
-
-}
-
-void iv::decition::DecideGps00::computeObsOnRoadByFrenet(iv::LidarGridPtr lidarGridPtr, const std::vector<Point2D>& gpsTrace, double & obs, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps)
-{
-    //    Point2D obsCombinePoint = Point2D(-1,-1);
-    iv::decition::FrenetPoint car_now_frenet_point = iv::decition::FrenetPlanner::getFrenetfromXY(0,0,gpsTrace,gpsMap,pathpoint,nowGps);
-    double obsSd;
-    if (lidarGridPtr == NULL)
-    {
-        lidarDistance = lastLidarDis;
-        //	lidarDistance = lastlidarDistance;
-    }
-    else {
-        obsPoint = Compute00().getLidarObsPoint(gpsTrace, lidarGridPtr);
-        //        lidarDistance = obsPoint.y-2.5;   //激光距离推到车头
-        iv::decition::FrenetPoint lidarFPointTmp = iv::decition::FrenetPlanner::getFrenetfromXY(this->obsPoint.x,this->obsPoint.y,gpsTrace,gpsMap,pathpoint,nowGps);
-        lidarDistance = lidarFPointTmp.s - car_now_frenet_point.s - 2.5;
-
-        //    lidarDistance=-1;
-        if (lidarDistance<0)
-        {
-            lidarDistance = -1;
-        }
-        lastLidarDis = lidarDistance;
-    }
-
-    FrenetPoint esr_obs_frenet_point;
-    getEsrObsDistanceByFrenet(gpsTrace, car_now_frenet_point,esr_obs_frenet_point,gpsMap,pathpoint,nowGps);
-
-    if(lidarDistance<0){
-        lidarDistance=500;
-    }
-    if(esrDistance<0){
-        esrDistance=500;
-    }
-
-    std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "激光雷达距离:" << lidarDistance << std::endl;
-
-    std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "毫米波距离:" << esrDistance << std::endl;
-    myesrDistance = esrDistance;
-
-    if(lidarDistance==500){
-        lidarDistance=-1;
-    }
-    if(esrDistance==500){
-        esrDistance=-1;
-    }
-
-    ServiceCarStatus.mRadarObs = esrDistance;
-    ServiceCarStatus.mLidarObs = lidarDistance;
-
-    //    //zhuanwan pingbi haomibo
-    //    if(gpsTraceNow[0].v1==4||gpsTraceNow[0].v1==5){
-    //        esrDistance=-1;
-    //    }
-
-    if (esrDistance>0 && lidarDistance > 0)
-    {
-        if (lidarDistance >= esrDistance)
-        {
-            obs = esrDistance;
-            //            obsSd=ServiceCarStatus.obs_radar[esrIndex].speed_y;
-            obsSd = obsSpeed;
-            //障碍物信息使用毫米波采集的。其位置坐标加上偏移量,转换成相对于惯导的位置,即转换成车辆坐标系下的位置坐标。
-            //            obsCombinePoint = Point2D(ServiceCarStatus.obs_radar[esrIndex].nomal_x+Esr_Offset,ServiceCarStatus.obs_radar[esrIndex].nomal_y+Esr_Y_Offset);
-        }
-        else if (!ServiceCarStatus.obs_radar.empty())
-        {
-            obs = lidarDistance;
-            //            obsCombinePoint = obsPoint;
-            //            obsSd = Compute00().getObsSpeedByFrenet(obsPoint, secSpeed,gpsTrace);
-            obsSd = Compute00().getObsSpeedByFrenet(obsPoint, secSpeed,gpsTrace,gpsMap,pathpoint,nowGps);
-            std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "计算obsSpeed:" << obsSpeed << std::endl;
-        }
-        else
-        {
-            obs=lidarDistance;
-            //            obsCombinePoint = obsPoint;
-            obsSd = 0 -secSpeed*cos(car_now_frenet_point.tangent_Ang-PI/2);
-            std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "毫米波无数据,计算obsSpeed:" << obsSpeed << std::endl;
-        }
-    }
-    else if (esrDistance>0)
-    {
-        obs = esrDistance;
-        //        obsSd = ServiceCarStatus.obs_radar[esrIndex].speed_y;
-        obsSd = obsSpeed;
-        //障碍物信息使用毫米波采集的。其位置坐标加上偏移量,转换成相对于惯导的位置,即转换成车辆坐标系下的位置坐标。
-        //        obsCombinePoint = Point2D(ServiceCarStatus.obs_radar[esrIndex].nomal_x+Esr_Offset,ServiceCarStatus.obs_radar[esrIndex].nomal_y+Esr_Y_Offset);
-    }
-    else if (lidarDistance > 0)
-    {
-        obs = lidarDistance;
-        //        obsCombinePoint = obsPoint;
-        obsSd = Compute00().getObsSpeedByFrenet(obsPoint, secSpeed,gpsTrace,gpsMap,pathpoint,nowGps);
-        std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "计算obsSpeed:" << obsSpeed << std::endl;
-    }
-    else {
-        obs = esrDistance;
-        //        obsCombinePoint = Point2D(ServiceCarStatus.obs_radar[esrIndex].nomal_x+Esr_Offset,ServiceCarStatus.obs_radar[esrIndex].nomal_y+Esr_Y_Offset);
-        obsSd = 0 - secSpeed*cos(car_now_frenet_point.tangent_Ang-PI/2);
-    }
-
-    obsDistance=obs;
-    obsSpeed=obsSd;
-
-    std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "最终得出的obsDistance:" << obsDistance << std::endl;
-
-    ServiceCarStatus.mObs = obsDistance;
-    if(ServiceCarStatus.mObs>100){
-        ServiceCarStatus.mObs =-1;
-    }
-
-    if (obsDistance>0)
-    {
-        lastDistance = obsDistance;
-    }
-
-    if(obs<0){
-        obsDistance=500;
-    }else{
-        obsDistance=obs;
-    }
-}
-
-void iv::decition::DecideGps00::getRearEsrObsDistance(std::vector<Point2D> gpsTrace, int roadNum) {
-
-
-    esrIndex = iv::decition::Compute00().getRearEsrIndex(gpsTrace, roadNum);
-
-    if (esrIndex != -1)
-    {
-        esrDistance = ServiceCarStatus.obs_rear_radar[esrIndex].nomal_y;
-        obsSpeed = ServiceCarStatus.obs_rear_radar[esrIndex].speed_y;
-
-    }
-    else {
-        esrDistance = -1;
-    }
-}
-
-void iv::decition::DecideGps00::getEsrObsDistanceByFrenet(const std::vector<Point2D>& gpsTrace, const FrenetPoint car_now_frenet_point, FrenetPoint &esrObs_F_Point, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps) {
-
-    esrIndex = iv::decition::Compute00().getEsrIndexByFrenet(gpsTrace,esrObs_F_Point,gpsMap,pathpoint,nowGps);
-
-    if (esrIndex != -1)
-    {
-        //障碍物的距离,是障碍物和车辆沿道路上的距离,即s。并不直接是它的x坐标或y坐标或两点直线坐标。
-        //严格来说应是 esrDistance=障碍物的s - 车辆的s - Esr_Y_Offset,但这是根据车辆位置实时搜索路径,故车辆的s极其小。
-        esrDistance = esrObs_F_Point.s - car_now_frenet_point.s - Esr_Y_Offset;  //-Esr_Y_Offset是把距离推到车头,换算frenet坐标时,把它加上了的。故需减去。
-
-        double speedx=ServiceCarStatus.obs_radar[esrIndex].speed_x;  //障碍物相对于车辆x轴的速度
-        double speedy=ServiceCarStatus.obs_radar[esrIndex].speed_y;  //障碍物相对于车辆y轴的速度
-        double speed_combine = sqrt(speedx*speedx+speedy*speedy);    //将x、y轴两个方向的速度求矢量和
-        //障碍物的速度方向与道路方向的夹角。用于将速度分解到s方向和d方向。
-        //所谓道路方向是指,道路上离障碍物的最近的点沿道路弧线的切线方向。
-        double Etheta = esrObs_F_Point.tangent_Ang - atan2(speedy,speedx);
-
-        obsSpeed = speed_combine*cos(Etheta);  //由speed_combine分解的s轴方向上的速度
-    }
-    else {
-        esrDistance = -1;
-    }
-}
-
-void iv::decition::DecideGps00::getV2XTrafficPositionVector(const std::vector<GPSData> gpsMapLine){
-    v2xTrafficVector.clear();
-    for (int var = 0; var < gpsMapLine.size(); var++) {
-        if(gpsMapLine[var]->roadMode==6){
-            v2xTrafficVector.push_back(var);
-        }
-    }
-}
-
-float iv::decition::DecideGps00::ComputeV2XTrafficLightSpeed(iv::TrafficLight trafficLight, const std::vector<GPSData> gpsMapLine,std::vector<int> v2xTrafficVector,
-                                                             int pathpoint,float secSpeed,float dSpeed, bool circleMode){
-    float trafficSpeed=200;
-    int nearTraffixPoint=-1;
-    float nearTrafficDis=0;
-    int traffic_color=0;
-    int traffic_time=0;
-    bool passThrough=false;
-    float dSecSpeed=dSpeed/3.6;
-
-    if(v2xTrafficVector.empty()){
-        return trafficSpeed;
-    }
-    if(!circleMode){
-        if(pathpoint>v2xTrafficVector.back()){
-            return trafficSpeed;
-        }else {
-            for(int i=0; i< v2xTrafficVector.size();i++){
-                if (pathpoint<= v2xTrafficVector[i]){
-                    nearTraffixPoint=v2xTrafficVector[i];
-                    break;
-                }
-            }
-        }
-    }else if(circleMode){
-        if(pathpoint>v2xTrafficVector.back()){
-            nearTraffixPoint=v2xTrafficVector[0];
-        }else {
-            for(int i=0; i< v2xTrafficVector.size();i++){
-                if (pathpoint<= v2xTrafficVector[i]){
-                    nearTraffixPoint=v2xTrafficVector[i];
-                    break;
-                }
-            }
-        }
-    }
-
-
-    if(nearTraffixPoint!=-1){
-        for(int i=pathpoint;i<nearTraffixPoint;i++){
-            nearTrafficDis +=GetDistance(*gpsMapLine[i],*gpsMapLine[i+1]);
-        }
-    }
-
-    if(nearTrafficDis>50){
-        return trafficSpeed;
-    }
-
-
-    int roadMode = gpsMapLine[pathpoint]->roadMode;
-    if(roadMode==14 || roadMode==16){
-        traffic_color=trafficLight.leftColor;
-        traffic_time=trafficLight.leftTime;
-    }else if(roadMode==15 ||roadMode==17){
-        traffic_color=trafficLight.rightColor;
-        traffic_time=trafficLight.rightTime;
-    }else {
-        traffic_color=trafficLight.straightColor;
-        traffic_time=trafficLight.straightTime;
-    }
-
-
-    passThrough=computeTrafficPass(nearTrafficDis,traffic_color,traffic_time,secSpeed,dSecSpeed);
-    if(passThrough){
-        return trafficSpeed;
-    }else{
-        trafficSpeed=computeTrafficSpeedLimt(nearTrafficDis);
-        if(nearTrafficDis<6){
-            float decelerate =0-( secSpeed*secSpeed*0.5/nearTrafficDis);
-            minDecelerate=min(minDecelerate,decelerate);
-        }
-        return trafficSpeed;
-    }
-
-    return trafficSpeed;
-}
-
-bool iv::decition::DecideGps00::computeTrafficPass(float trafficDis,int trafficColor,float trafficTime,float realSecSpeed,float dSecSpeed){
-    float passTime=0;
-    if (trafficColor==2 || trafficColor==3){
-        return false;
-    }else if(trafficColor==0){
-        return true;
-    }else{
-        passTime=trafficDis/dSecSpeed;
-        if(passTime+1< trafficTime){
-            return true;
-        }else{
-            return false;
-        }
-
-    }
-
-}
-
-float iv::decition::DecideGps00::computeTrafficSpeedLimt(float trafficDis){
-    float limit=200;
-    if(trafficDis<10){
-        limit = 0;
-    }else if(trafficDis<15){
-        limit = 5;
-    }else if(trafficDis<20){
-        limit=10;
-    }else if(trafficDis<30){
-        limit=15;
-    }
-    return limit;
-}
-
-void iv::decition::DecideGps00::adjuseGpsLidarPosition(){
-
-    ServiceCarStatus.msysparam.lidarGpsXiuzheng -=  ServiceCarStatus.msysparam.gpsOffset_y;
-    ServiceCarStatus.msysparam.radarGpsXiuzheng -=  ServiceCarStatus.msysparam.gpsOffset_y;
-    ServiceCarStatus.msysparam.rearRadarGpsXiuzheng +=  ServiceCarStatus.msysparam.gpsOffset_y;
-    ServiceCarStatus.msysparam.rearLidarGpsXiuzheng +=  ServiceCarStatus.msysparam.gpsOffset_y;
-    ServiceCarStatus.msysparam.frontGpsXiuzheng -=  ServiceCarStatus.msysparam.gpsOffset_y;
-    ServiceCarStatus.msysparam.rearGpsXiuzheng +=  ServiceCarStatus.msysparam.gpsOffset_y;
-}
+#include <decition/decide_gps_00.h>
+#include <decition/adc_tools/compute_00.h>
+#include <decition/adc_tools/gps_distance.h>
+#include <decition/decition_type.h>
+#include <decition/adc_tools/transfer.h>
+#include <decition/obs_predict.h>
+#include <common/constants.h>
+#include <common/car_status.h>
+#include <math.h>
+#include <iostream>
+#include <fstream>
+#include <control/can.h>
+#include <time.h>
+#include <decition/adc_controller/base_controller.h>
+#include <decition/adc_controller/pid_controller.h>
+#include <decition/adc_planner/lane_change_planner.h>
+#include <decition/adc_planner/frenet_planner.h>
+#include <QTime>
+
+using namespace std;
+
+#include "ivlog.h"
+extern iv::Ivlog * givlog;
+
+#define PI (3.1415926535897932384626433832795)
+
+iv::decition::DecideGps00::DecideGps00() {
+
+}
+iv::decition::DecideGps00::~DecideGps00() {
+
+}
+
+float iv::decition::DecideGps00::xiuzhengCs=0;
+
+int iv::decition::DecideGps00::PathPoint = -1;
+double iv::decition::DecideGps00::minDis = iv::MaxValue;
+double iv::decition::DecideGps00::maxAngle = iv::MinValue;
+//int iv::decition::DecideGps00::lastGpsIndex = iv::MaxValue;
+int iv::decition::DecideGps00::lastGpsIndex = 0;
+double iv::decition::DecideGps00::controlSpeed = 0;
+double iv::decition::DecideGps00::controlBrake = 0;
+double iv::decition::DecideGps00::controlAng = 0;
+double iv::decition::DecideGps00::Iv = 0;
+double iv::decition::DecideGps00::lastU = 0;
+double iv::decition::DecideGps00::lastVt = 0;
+double iv::decition::DecideGps00::lastEv = 0;
+
+int iv::decition::DecideGps00::gpsLineParkIndex = 0;
+int iv::decition::DecideGps00::gpsMapParkIndex = 0;
+double iv::decition::DecideGps00::lastDistance = MaxValue;
+double iv::decition::DecideGps00::lastPreObsDistance = MaxValue;
+double iv::decition::DecideGps00::obsDistance = -1;
+double iv::decition::DecideGps00::obsSpeed=0;
+double iv::decition::DecideGps00::obsDistanceAvoid = -1;
+double iv::decition::DecideGps00::lastDistanceAvoid = -1;
+
+double iv::decition::DecideGps00::lidarDistance = -1;
+double iv::decition::DecideGps00::myesrDistance = -1;
+double iv::decition::DecideGps00::lastLidarDis = -1;
+
+bool iv::decition::DecideGps00::parkMode = false;
+bool iv::decition::DecideGps00::readyParkMode = false;
+
+bool iv::decition::DecideGps00::zhucheMode = false;
+bool iv::decition::DecideGps00::readyZhucheMode = false;
+bool iv::decition::DecideGps00::hasZhuched = false;
+
+double iv::decition::DecideGps00::lastLidarDisAvoid = -1;
+double iv::decition::DecideGps00::lidarDistanceAvoid = -1;
+
+int iv::decition::DecideGps00::finishPointNum = -1;
+int iv::decition::DecideGps00::zhuchePointNum = 0;
+
+///kkcai, 2020-01-03
+bool iv::decition::DecideGps00::isFirstRun = true;
+//////////////////////////////////////////////
+
+float iv::decition::DecideGps00::minDecelerate=0;
+//bool iv::decition::DecideGps00::startingFlag = true;//起步标志,在起步时需要进行frenet规划。
+
+double offset_real = 0;
+double realspeed;
+double dSpeed;
+double dSecSpeed;
+double secSpeed;
+double ac;
+
+
+iv::Point2D obsPoint(-1, -1);
+iv::Point2D obsPointAvoid(-1, -1);
+
+
+int esrIndex = -1;
+int esrIndexAvoid = -1;
+double obsSpeedAvoid = 0;
+
+double esrDistance = -1;
+double esrDistanceAvoid = -1;
+int obsLostTime = 0;
+int obsLostTimeAvoid = 0;
+
+// double avoidTime = 0;
+
+
+double avoidX =0;
+float roadWidth = 3.5;
+int roadSum =10;
+int roadNow = 0;
+int roadOri =0;
+int roadPre = -1;
+int lastRoadOri = 0;
+
+int lightTimes = 0;
+
+
+int lastRoadNum=1;
+
+int stopCount = 0;
+
+int gpsMissCount = 0;
+
+bool rapidStop = false;
+
+bool hasTrumpeted = false;
+
+
+bool changeRoad=false;
+//实验手刹
+bool handFirst = true;
+double handTimeSpan = 0;
+double handStartTime = 0;
+double handLastTime = 0;
+bool handPark = false;
+long handParkTime=10000;
+
+//喇叭
+bool trumpetFirstCount=true;
+double trumpetTimeSpan = 0;
+double trumpetStartTime = 0;
+double trumpetLastTime = 0;
+
+//过渡
+bool transferFirstCount=true;
+double transferTimeSpan = 0;
+double transferStartTime = 0;
+double transferLastTime = 0;
+
+bool busMode = false;
+bool parkBesideRoad=false;
+
+bool chaocheMode = false;
+bool specialSignle = false;
+
+double offsetX = 0;
+
+double steerSpeed=9000;
+
+bool transferPieriod;
+bool transferPieriod2;
+double traceDevi;
+
+bool startingFlag = true;  //起步标志,在起步时需要进行frenet规划。
+bool useFrenet = false;    //标志是否启用frenet算法避障
+bool useOldAvoid = true;   //标志是否用老方法避障
+
+enum VehState { normalRun, park, readyPark, stopObs, avoidObs, preAvoid, avoiding, backOri,preBack,
+                waitAvoid ,shoushaTest,justRun, changingRoad, chaoche, chaocheBack, reverseCar,reversing, reverseCircle, reverseDirect,reverseArr,
+                dRever,dRever0,dRever1,dRever2,dRever3,dRever4} vehState;
+
+
+std::vector<iv::Point2D>  gpsTraceAim; //记录变道后的目标路径,若车辆经frenet规划行驶至该路径上后,就关闭frenet规划
+std::vector<iv::Point2D>  gpsTraceAvoid,gpsTraceNow,gpsTraceBack,gpsTracePre,gpsTraceOri,gpsTraceRear;
+
+std::vector<double> esrDisVector(roadSum, -1);
+std::vector<double> lidarDisVector(roadSum, -1);
+std::vector<double> obsDisVector(roadSum,-1);
+std::vector<double> obsSpeedVector(roadSum, 0);
+
+std::vector<int> obsLostTimeVector(roadSum, 0);
+
+std::vector<double> lastLidarDisVector(roadSum, -1);
+std::vector<double> lastDistanceVector(roadSum, -1);
+
+bool qiedianCount = false;
+//日常展示
+
+iv::decition::Decition iv::decition::DecideGps00::getDecideFromGPS(GPS_INS now_gps_ins,
+                                                                   const std::vector<GPSData> gpsMapLine,
+                                                                   iv::LidarGridPtr lidarGridPtr,
+                                                                   std::vector<iv::Perception::PerceptionOutput> lidar_per,
+                                                                   iv::TrafficLight trafficLight)
+{
+    //   QTime xTime;
+    //    xTime.start();
+    //39.14034649083606 117.0863975920476 20507469.630314853  4334165.046101382 353
+    Decition gps_decition(new DecitionBasic);
+    //    vector<iv::Point2D> fpTraceTmp;
+
+
+    //如果useFrenet、useOldAvoid两者不互为相异,则采用原来的方法。“^”为异或运算符。
+    if(!(useFrenet^useOldAvoid)){
+        useFrenet = false;
+        useOldAvoid = true;
+    }
+
+    //    //如果useFrenet、useOldAvoid两者均为真或均为假,则采用原来的方法
+    //    if(useFrenet&&useOldAvoid || !useFrenet&&!useOldAvoid){
+    //        useFrenet = false;
+    //        useOldAvoid = true;
+    //    }
+
+    //  ServiceCarStatus.group_control=false;
+
+
+
+
+//    GPS_INS gps= Coordinate_UnTransfer(0,1.5,now_gps_ins);
+//    now_gps_ins.gps_x=gps.gps_x;
+//    now_gps_ins.gps_y=gps.gps_y;
+
+    //    GaussProjInvCal(now_gps_ins.gps_x, now_gps_ins.gps_y,&now_gps_ins.gps_lng, &now_gps_ins.gps_lat);
+
+
+    if (isFirstRun)
+    {
+        initMethods();
+        vehState = normalRun;
+        startAvoid_gps_ins = now_gps_ins;
+        init();
+        PathPoint = Compute00().getFirstNearestPointIndex(now_gps_ins, gpsMapLine,
+                                                          DecideGps00::lastGpsIndex,
+                                                          DecideGps00::minDis,
+                                                          DecideGps00::maxAngle);
+        DecideGps00::lastGpsIndex = PathPoint;
+
+        adjuseGpsLidarPosition();
+        if(ServiceCarStatus.speed_control==true){
+            Compute00().getDesiredSpeed(gpsMapLine);   //add by zj
+        }
+
+        //	ServiceCarStatus.carState = 1;
+        //        roadOri = gpsMapLine[PathPoint]->roadOri;
+        //        roadNow = roadOri;
+        //        roadSum = gpsMapLine[PathPoint]->roadSum;
+        //  busMode = false;
+        //  vehState = dRever;
+
+        double dis =  GetDistance(*gpsMapLine[0], *gpsMapLine[gpsMapLine.size()-1]);
+        if(dis<15){
+            circleMode=true;  //201200102
+        }else{
+            circleMode=false;
+        }
+        //     circleMode = true;
+
+
+        getV2XTrafficPositionVector(gpsMapLine);
+        //        group_ori_gps=*gpsMapLine[0];
+        ServiceCarStatus.bocheMode=false;
+        ServiceCarStatus.daocheMode=false;
+        parkMode=false;
+        readyParkMode=false;
+        finishPointNum=-1;
+        isFirstRun = false;
+    }
+
+
+    if(ServiceCarStatus.msysparam.gpsOffset_x!=0 || ServiceCarStatus.msysparam.gpsOffset_y!=0 ){
+        GPS_INS gpsOffset = Coordinate_UnTransfer(ServiceCarStatus.msysparam.gpsOffset_x, ServiceCarStatus.msysparam.gpsOffset_y, now_gps_ins);
+        now_gps_ins.gps_x=gpsOffset.gps_x;
+        now_gps_ins.gps_y=gpsOffset.gps_y;
+        GaussProjInvCal(now_gps_ins.gps_x,  now_gps_ins.gps_y, &now_gps_ins.gps_lng, &now_gps_ins.gps_lat);
+    }
+
+    //1227
+    //  ServiceCarStatus.daocheMode=true;
+
+    //1220
+    changingDangWei=false;
+
+    minDecelerate=0;
+    if(now_gps_ins.gps_lat<0||now_gps_ins.gps_lat>90){
+        //  int a=0;
+        gps_decition->wheel_angle = 0;
+        gps_decition->speed = dSpeed;
+
+        gps_decition->accelerator = -0.5;
+        gps_decition->brake=10;
+        return gps_decition;
+    }
+
+
+
+
+
+    //1220
+
+
+    if(ServiceCarStatus.daocheMode){
+
+        now_gps_ins.ins_heading_angle=now_gps_ins.ins_heading_angle+180;
+        if( now_gps_ins.ins_heading_angle>=360)
+            now_gps_ins.ins_heading_angle= now_gps_ins.ins_heading_angle-360;
+    }
+    //1220 end
+
+
+
+    //1125 traficc
+    traffic_light_gps.gps_lat=ServiceCarStatus.iTrafficeLightLat;
+    traffic_light_gps.gps_lng=ServiceCarStatus.iTrafficeLightLon;
+    GaussProjCal(traffic_light_gps.gps_lng,traffic_light_gps.gps_lat, &traffic_light_gps.gps_x, &traffic_light_gps.gps_y);
+
+
+    //xiesi
+    ///kkcai, 2020-01-03
+    //ServiceCarStatus.busmode=true;
+    //ServiceCarStatus.busmode=false;//20200102
+    ///////////////////////////////////////////////////
+
+
+    busMode = ServiceCarStatus.busmode;
+    nearStation=false;
+
+    gps_decition->leftlamp = false;
+    gps_decition->rightlamp = false;
+    //    qDebug("heading is %g",now_gps_ins.ins_heading_angle);
+
+
+    aim_gps_ins.gps_lat= ServiceCarStatus.mfParkLat;
+    aim_gps_ins.gps_lng= ServiceCarStatus.mfParkLng;
+
+    aim_gps_ins.ins_heading_angle= ServiceCarStatus.mfParkHeading;
+
+
+
+
+    GaussProjCal(aim_gps_ins.gps_lng,aim_gps_ins.gps_lat, &aim_gps_ins.gps_x, &aim_gps_ins.gps_y);
+    is_arrivaled = false;
+
+
+
+
+    //  xiuzhengCs=-0.8;  //1026
+
+    xiuzhengCs=0;
+    //    if (parkMode)
+    //    {
+
+
+    //        handBrakePark(gps_decition,10000,now_gps_ins);
+    //        return gps_decition;
+    //    }
+
+
+
+
+
+    realspeed = now_gps_ins.speed;
+
+    secSpeed = realspeed / 3.6;
+
+
+
+
+    //sidePark
+
+    if(ServiceCarStatus.mnParkType==1){
+
+        if( vehState!=dRever &&  vehState!=dRever0  &&  vehState!=dRever1 &&  vehState!=dRever2  &&  vehState!=dRever3 && vehState!=dRever4 && vehState!=reverseArr ){
+            int bocheEN=Compute00().bocheDirectCompute(now_gps_ins, aim_gps_ins);
+            if(bocheEN==1){
+                ServiceCarStatus.bocheEnable=1;
+            }else if(bocheEN==0){
+                ServiceCarStatus.bocheEnable=0;
+            }
+        }else{
+            ServiceCarStatus.bocheEnable=2;
+        }
+
+
+
+        if(ServiceCarStatus.bocheMode && vehState!=dRever &&  vehState!=dRever0  &&  vehState!=dRever1 &&
+                vehState!=dRever2  &&  vehState!=dRever3 && vehState!=dRever4&&  vehState!=reverseArr ){
+            if(abs(realspeed)>0.1){
+                dSpeed=0;
+                minDecelerate=min(minDecelerate,-0.5f);
+                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
+                gps_decition->wheel_angle=0;
+                return gps_decition;
+            }else{
+                if(trumpet()>3000){
+                    trumpetFirstCount=true;
+                    vehState=dRever;
+                }
+
+            }
+            //         ServiceCarStatus.bocheMode=false;
+        }
+
+    }
+
+
+    //chuizhiPark
+
+    if(ServiceCarStatus.mnParkType==0){
+        if( vehState!=reverseCar &&  vehState!=reversing  &&  vehState!=reverseCircle &&  vehState!=reverseDirect &&  vehState!=reverseArr ){
+            int bocheEN=Compute00().bocheCompute(now_gps_ins, aim_gps_ins);
+            if(bocheEN==1){
+                ServiceCarStatus.bocheEnable=1;
+            }else if(bocheEN==0){
+                ServiceCarStatus.bocheEnable=0;
+            }
+        }else{
+            ServiceCarStatus.bocheEnable=2;
+        }
+
+
+
+        if(ServiceCarStatus.bocheMode && vehState!=reverseCar &&  vehState!=reversing  &&  vehState!=reverseCircle &&  vehState!=reverseDirect&&  vehState!=reverseArr ){
+
+            if(abs(realspeed)>0.1){
+                dSpeed=0;
+                minDecelerate=min(minDecelerate,-0.5f);
+                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
+                gps_decition->wheel_angle=0;
+                return gps_decition;
+            }else{
+                if(trumpet()>3000){
+                    trumpetFirstCount=true;
+                    vehState=reverseCar;
+                }
+
+            }
+            //     ServiceCarStatus.bocheMode=false;
+
+        }
+    }
+    // ChuiZhiTingChe
+    if (vehState == reverseCar)
+    {
+        Compute00().bocheCompute(now_gps_ins, aim_gps_ins);
+
+        vehState = reversing;
+        qiedianCount=true;
+
+
+    }
+    if (vehState == reversing)
+    {
+        double dis = GetDistance(now_gps_ins, Compute00().nearTpoint);
+        if (dis<2.0)//0.5
+        {
+            vehState = reverseCircle;
+            qiedianCount = true;
+            cout<<"到达近切点+++++++++++++++++++++++++++++++++"<<endl;
+        }
+        else {
+            controlAng = 0;
+            dSpeed = 2;
+            dSecSpeed = dSpeed / 3.6;
+            gps_decition->wheel_angle = 0;
+            gps_decition->speed = dSpeed;
+            obsDistance=-1;
+            phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
+            //	gps_decition->accelerator = 0;
+            return gps_decition;
+        }
+    }
+
+    if (vehState == reverseCircle)
+    {
+        double dis = GetDistance(now_gps_ins, Compute00().farTpoint);
+        double angdis =abs(now_gps_ins.ins_heading_angle - aim_gps_ins.ins_heading_angle);
+        if((((angdis<5)||(angdis>355)))&&(dis<3.0))
+            //       if((((angdis<4)||(angdis>356)))&&(dis<2.0))
+        {
+            vehState = reverseDirect;
+            qiedianCount = true;
+            cout<<"到达远切点+++++++++++++++++++++++++++++++++"<<endl;
+
+        }
+        else {
+            if (qiedianCount && trumpet()<0)
+                //         if (qiedianCount && trumpet()<1500)
+            {
+
+                //                gps_decition->brake = 10;
+                //                gps_decition->torque = 0;
+                dSpeed=0;
+                minDecelerate=min(minDecelerate,-0.5f);
+                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
+            }
+            else
+            {
+                qiedianCount = false;
+                trumpetFirstCount = true;
+
+
+                dSpeed = 2;
+                dSecSpeed = dSpeed / 3.6;
+                gps_decition->speed = dSpeed;
+                obsDistance=-1;
+                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
+
+            }
+
+            controlAng = Compute00().bocheAngle*16.5;
+            gps_decition->wheel_angle = 0 - controlAng*1.05;
+
+            cout<<"farTpointDistance================"<<dis<<endl;
+
+            return gps_decition;
+        }
+    }
+
+    if (vehState == reverseDirect)
+    {
+        //	double dis = GetDistance(now_gps_ins, aim_gps_ins);
+        Point2D pt = Coordinate_Transfer(now_gps_ins.gps_x,now_gps_ins.gps_y, aim_gps_ins);
+
+        if ((pt.y)<0.5)
+        {
+
+            qiedianCount=true;
+            vehState=reverseArr;
+            cout<<"到达泊车点+++++++++++++++++++++++++++++++++"<<endl;
+            //            gps_decition->accelerator = -3;
+            //            gps_decition->brake = 10;
+            //            gps_decition->torque = 0;
+            gps_decition->wheel_angle=0;
+            dSpeed=0;
+            minDecelerate=min(minDecelerate,-0.5f);
+            phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
+            return gps_decition;
+
+
+
+
+        }
+        else {
+
+            //if (qiedianCount && trumpet()<0)
+            if (qiedianCount && trumpet()<1000)
+            {
+
+                //                gps_decition->brake = 10;
+                //                gps_decition->torque = 0;
+                dSpeed=0;
+                minDecelerate=min(minDecelerate,-0.5f);
+                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
+            }
+            else
+            {
+                qiedianCount = false;
+                trumpetFirstCount = true;
+                dSpeed = 1;
+                dSecSpeed = dSpeed / 3.6;
+                gps_decition->speed = dSpeed;
+                obsDistance=-1;
+                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
+            }
+
+
+
+            controlAng = 0;
+
+            gps_decition->wheel_angle = 0;
+
+            return gps_decition;
+        }
+    }
+
+
+
+    if (vehState == reverseArr)
+    {
+        //
+
+        ServiceCarStatus.bocheMode=false;
+        if (qiedianCount && trumpet()<1500)
+        {
+
+            //            gps_decition->brake = 10;
+            //            gps_decition->torque = 0;
+            dSpeed=0;
+            minDecelerate=min(minDecelerate,-0.5f);
+            phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
+            ServiceCarStatus.bocheMode=false;
+        }
+        else
+        {
+            qiedianCount = false;
+            trumpetFirstCount = true;
+            ServiceCarStatus.bocheEnable=0;
+            vehState=normalRun;
+            ServiceCarStatus.mbRunPause=true;
+            ServiceCarStatus.mnBocheComplete=100;
+            cout<<"泊车daowei mbRunPause+++++++++++++++++++++++++++++++++"<<endl;
+        }
+
+
+        gps_decition->wheel_angle = 0 ;
+
+
+
+        return gps_decition;
+
+    }
+
+
+
+    //ceFangWeiBoChe
+
+    if (vehState == dRever)
+    {
+        GaussProjCal(aim_gps_ins.gps_lng, aim_gps_ins.gps_lat, &aim_gps_ins.gps_x, &aim_gps_ins.gps_y);
+
+        Compute00().bocheDirectCompute(now_gps_ins, aim_gps_ins);
+
+        vehState = dRever0;
+        qiedianCount=true;
+
+
+        std::cout<<"enter side boche mode"<<std::endl;
+
+
+
+    }
+    if (vehState == dRever0)
+    {
+        double dis = GetDistance(now_gps_ins, Compute00().dTpoint0);
+        if (dis<2.0)
+        {
+            vehState = dRever1;
+            qiedianCount = true;
+            cout<<"到达近切点+++++++++++++++++++++++++++++++++"<<endl;
+        }
+        else {
+            controlAng = 0;
+            dSpeed = 2;
+            dSecSpeed = dSpeed / 3.6;
+            gps_decition->wheel_angle = 0;
+            gps_decition->speed = dSpeed;
+            obsDistance=-1;
+            phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
+            //	gps_decition->accelerator = 0;
+            return gps_decition;
+        }
+    }
+
+
+    if (vehState == dRever1)
+    {
+        double dis = GetDistance(now_gps_ins, Compute00().dTpoint1);
+
+        if(dis<2.0)
+        {
+            vehState = dRever2;
+            qiedianCount = true;
+            cout<<"到达远切点+++++++++++++++++++++++++++++++++"<<endl;
+
+        }
+        else {
+            if (qiedianCount && trumpet()<1000)
+
+            {
+
+                //                gps_decition->brake = 10;
+                //                gps_decition->torque = 0;
+                dSpeed=0;
+                minDecelerate=min(minDecelerate,-0.5f);
+                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
+            }
+            else
+            {
+                qiedianCount = false;
+                trumpetFirstCount = true;
+
+
+                dSpeed = 2;
+                dSecSpeed = dSpeed / 3.6;
+                gps_decition->speed = dSpeed;
+                obsDistance=-1;
+                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
+
+            }
+
+            controlAng = Compute00().dBocheAngle*16.5;
+            gps_decition->wheel_angle = 0 - controlAng;
+
+            cout<<"farTpointDistance================"<<dis<<endl;
+
+            return gps_decition;
+        }
+    }
+
+
+    if (vehState == dRever2)
+    {
+        double dis = GetDistance(now_gps_ins, Compute00().dTpoint2);
+        Point2D pt1 = Coordinate_Transfer(now_gps_ins.gps_x,now_gps_ins.gps_y, aim_gps_ins);
+        Point2D pt2 = Coordinate_Transfer(Compute00().dTpoint2.gps_x,Compute00().dTpoint2.gps_y, aim_gps_ins);
+        double xx= (pt1.x-pt2.x);
+        // if(xx>0)
+        if(xx>-0.5)
+        {
+            GaussProjCal(aim_gps_ins.gps_lng, aim_gps_ins.gps_lat, &aim_gps_ins.gps_x, &aim_gps_ins.gps_y);
+            Point2D ptt = Coordinate_Transfer(now_gps_ins.gps_x,now_gps_ins.gps_y, aim_gps_ins);
+            double xxx=ptt.x;
+            double yyy =ptt.y;
+//            if(xxx<-1.5||xx>1){
+//                int a=0;
+//            }
+            vehState = dRever3;
+            qiedianCount = true;
+            cout<<"到达远切点+++++++++++++++++++++++++++++++++"<<endl;
+            cout<<"xxx+++++++++++++++++++++++++++++++++"<<xxx<<endl;
+            cout<<"yyy+++++++++++++++++++++++++++++++++"<<yyy<<endl;
+
+
+        }
+        else {
+            if (qiedianCount && trumpet()<1000)
+
+            {
+
+                /*  gps_decition->brake = 10;
+                gps_decition->torque = 0;  */
+                dSpeed=0;
+                minDecelerate=min(minDecelerate,-0.5f);
+                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
+            }
+            else
+            {
+                qiedianCount = false;
+                trumpetFirstCount = true;
+
+
+                dSpeed = 2;
+                dSecSpeed = dSpeed / 3.6;
+                gps_decition->speed = dSpeed;
+                obsDistance=-1;
+                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
+
+            }
+
+
+            gps_decition->wheel_angle = 0 ;
+
+            cout<<"farTpointDistance================"<<dis<<endl;
+
+            return gps_decition;
+        }
+    }
+
+
+    if (vehState == dRever3)
+    {
+        double dis = GetDistance(now_gps_ins, Compute00().dTpoint3);
+        double angdis =abs(now_gps_ins.ins_heading_angle - aim_gps_ins.ins_heading_angle);
+        if((((angdis<5)||(angdis>355)))&&(dis<10.0))
+        {
+            vehState = dRever4;
+            qiedianCount = true;
+            cout<<"到达远切点+++++++++++++++++++++++++++++++++"<<endl;
+
+        }
+        else {
+            if (qiedianCount && trumpet()<1000)
+
+            {
+
+                //                gps_decition->brake = 10;
+                //                gps_decition->torque = 0;
+                dSpeed=0;
+                minDecelerate=min(minDecelerate,-0.5f);
+                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
+            }
+            else
+            {
+                qiedianCount = false;
+                trumpetFirstCount = true;
+
+
+                dSpeed = 2;
+                dSecSpeed = dSpeed / 3.6;
+                gps_decition->speed = dSpeed;
+                obsDistance=-1;
+                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
+
+            }
+
+            controlAng = 0-Compute00().dBocheAngle*16.5;
+            gps_decition->wheel_angle = 0 - controlAng*0.95;
+
+            cout<<"farTpointDistance================"<<dis<<endl;
+
+            return gps_decition;
+        }
+    }
+
+
+
+    if (vehState == dRever4)
+    {
+        //	double dis = GetDistance(now_gps_ins, aim_gps_ins);
+        Point2D pt = Coordinate_Transfer(now_gps_ins.gps_x,now_gps_ins.gps_y, aim_gps_ins);
+
+        if ((pt.y)<0.5)
+        {
+
+            qiedianCount=true;
+            vehState=reverseArr;
+            cout<<"到达泊车点+++++++++++++++++++++++++++++++++"<<endl;
+            //            gps_decition->accelerator = -3;
+            //            gps_decition->brake =10 ;
+            dSpeed=0;
+            minDecelerate=min(minDecelerate,-0.5f);
+            phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
+
+            gps_decition->wheel_angle=0;
+            return gps_decition;
+
+
+
+
+        }
+        else {
+
+            //if (qiedianCount && trumpet()<0)
+            if (qiedianCount && trumpet()<1000)
+            {
+
+                //                gps_decition->brake = 10;
+                //                gps_decition->torque = 0;
+                dSpeed=0;
+                minDecelerate=min(minDecelerate,-0.5f);
+                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
+            }
+            else
+            {
+                qiedianCount = false;
+                trumpetFirstCount = true;
+                dSpeed = 2;
+                dSecSpeed = dSpeed / 3.6;
+                gps_decition->speed = dSpeed;
+                obsDistance=-1;
+                phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
+            }
+
+
+
+            controlAng = 0;
+
+            gps_decition->wheel_angle = 0;
+
+            return gps_decition;
+        }
+    }
+
+
+
+    if (vehState == reverseArr)
+    {
+        //
+        ServiceCarStatus.bocheMode=false;
+
+        if (qiedianCount && trumpet()<1500)
+        {
+
+            //            gps_decition->brake = 10;
+            //            gps_decition->torque = 0;
+            dSpeed=0;
+            minDecelerate=min(minDecelerate,-0.5f);
+            phaseSpeedDecition(gps_decition, secSpeed, -1, 0, now_gps_ins);
+        }
+        else
+        {
+            qiedianCount = false;
+            trumpetFirstCount = true;
+            ServiceCarStatus.bocheEnable=0;
+            vehState=normalRun;
+            ServiceCarStatus.mbRunPause=true;
+            ServiceCarStatus.mnBocheComplete=100;
+            cout<<"泊车daowei mbRunPause+++++++++++++++++++++++++++++++++"<<endl;
+        }
+
+
+        gps_decition->wheel_angle = 0 ;
+
+
+
+        return gps_decition;
+
+    }
+
+
+
+
+
+
+
+
+
+
+
+    obsDistance = -1;
+    esrIndex = -1;
+    lidarDistance = -1;
+
+    obsDistanceAvoid = -1;
+    esrIndexAvoid = -1;
+    roadPre = -1;
+
+
+
+
+
+
+
+
+
+    avoidX = (roadOri-roadNow)*roadWidth;
+
+    gpsTraceOri.clear();
+    gpsTraceNow.clear();
+    gpsTraceAim.clear();
+    gpsTraceAvoid.clear();
+    gpsTraceBack.clear();
+
+
+
+
+
+
+
+    if (!isFirstRun)
+    {
+        //   PathPoint = Compute00().getNearestPointIndex(now_gps_ins, gpsMapLine, DecideGps00::lastGpsIndex, DecideGps00::minDis, DecideGps00::maxAngle);
+        //    if(PathPoint<0){
+        PathPoint = Compute00().getFirstNearestPointIndex(now_gps_ins, gpsMapLine, DecideGps00::lastGpsIndex, DecideGps00::minDis, DecideGps00::maxAngle);
+        //    }
+
+    }
+
+
+    if (PathPoint<0)
+    {
+
+        minDecelerate=-1.0;
+        phaseSpeedDecition(gps_decition, secSpeed, -1, 0,now_gps_ins);
+        return gps_decition;
+
+    }
+
+    DecideGps00::lastGpsIndex = PathPoint;
+    //2020-01-03, kkcai
+    //if(!circleMode && PathPoint>gpsMapLine.size()-200){
+    if(!circleMode && PathPoint>gpsMapLine.size()-100){
+        minDecelerate=-1.0;
+        std::cout<<"map finish brake"<<std::endl;
+    }
+
+
+
+
+    roadOri = gpsMapLine[PathPoint]->roadOri;
+
+    roadSum = gpsMapLine[PathPoint]->roadSum;
+
+
+    if ( gpsMapLine[PathPoint]->runMode == 0 &&(vehState == avoidObs||vehState ==stopObs||vehState == preAvoid
+                                                ||vehState == avoiding||vehState == backOri||vehState ==preBack||vehState ==waitAvoid ) )
+    {
+        vehState = normalRun;
+        roadNow = roadOri;
+    }
+
+
+
+    //    if (PathPoint!=-1&&((now_gps_ins.rtk_status==6)||(now_gps_ins.rtk_status==5))&&GetDistance(now_gps_ins,*gpsMapLine[PathPoint])<30)
+    //    {
+    //        DecideGps00::lastGpsIndex = PathPoint;
+    //        gpsMissCount = 0;
+
+    //    }
+    //    else
+    //    {
+    //        gpsMissCount++;
+    //    }
+
+    gpsTraceOri= getGpsTrace(now_gps_ins, gpsMapLine, lastGpsIndex,circleMode);
+    //    gpsTraceOri = laneChangePlanner->getPath(now_gps_ins,gpsMapLine,PathPoint,0,lidarGridPtr);
+    if(gpsTraceOri.empty()){
+        gps_decition->wheel_angle = 0;
+        gps_decition->speed = dSpeed;
+
+        gps_decition->accelerator = -0.5;
+        gps_decition->brake=10;
+        return gps_decition;
+    }
+
+
+
+    traceDevi=gpsTraceOri[0].x;
+
+    //起步进行frenet规划后,车辆行驶至地图路线上,起步操作完毕。
+    //如果车辆本身启动位置在地图路线上,可不用进行frenet规划。
+    //    if(GetDistance(now_gps_ins,*gpsMapLine[PathPoint]) < 1){
+    //        startingFlag = false;
+    //    }
+    startingFlag = false;
+    if(startingFlag){
+        //        gpsTraceAim = gpsTraceOri;
+        if(abs(gpsTraceOri[0].x)>1){
+            cout<<"frenetPlanner->getPath:pre"<<endl;
+            gpsTraceNow = frenetPlanner->getPath(now_gps_ins,gpsMapLine,PathPoint,0,lidarGridPtr);
+            cout<<"frenetPlanner->getPath,gpsTraceNow.size: "<<gpsTraceNow.size()<<endl;
+            if(gpsTraceNow.size()==0){
+                gps_decition->accelerator = 0;
+                gps_decition->brake=10;
+                gps_decition->wheel_angle = lastAngle;
+                gps_decition->speed = 0;
+                return gps_decition;
+            }
+        }else{
+            startingFlag = false;
+        }
+    }
+
+
+    if(useFrenet){
+        //如果车辆在变道中,启用frenet规划局部路径
+        if(vehState == avoiding || vehState == backOri){
+            avoidX = (roadOri - roadNow)*roadWidth;
+            gpsTraceNow = frenetPlanner->getPath(now_gps_ins,gpsMapLine,PathPoint,avoidX,lidarGridPtr);
+            //gpsTraceAim = laneChangePlanner->getPath(now_gps_ins,gpsMapLine,PathPoint,avoidX,lidarGridPtr);
+            gpsTraceAim = getGpsTraceOffset(gpsTraceOri, avoidX);
+            if(gpsTraceNow.size()==0){
+                gps_decition->accelerator = 0;
+                gps_decition->brake=10;
+                gps_decition->wheel_angle = lastAngle;
+                gps_decition->speed = 0;
+                return gps_decition;
+            }
+        }
+    }
+
+    if(gpsTraceNow.size()==0){
+        if (roadNow==roadOri)
+        {
+            gpsTraceNow.assign(gpsTraceOri.begin(), gpsTraceOri.end());
+            //gpsTraceNow = getGpsTrace(now_gps_ins, gpsMapLine, lastGpsIndex);
+        }else
+        {
+            //	gpsTraceNow = getGpsTrace(now_gps_ins, gmapsR[int(abs(roadWidth * 2)*(roadOri-roadNow))], lastGpsIndex);
+            gpsTraceNow = getGpsTraceOffset(gpsTraceOri, avoidX);
+            //gpsTraceNow = laneChangePlanner->getPath(now_gps_ins,gpsMapLine,PathPoint,avoidX,lidarGridPtr);
+        }
+    }
+
+
+    //  dSpeed = getSpeed(gpsTraceNow);
+    dSpeed = 80;
+
+    planTrace = gpsTraceNow; //Add By YuChuli, 2020.11.26
+
+    dSpeed = limitSpeed(controlAng, dSpeed);
+
+
+
+    controlAng= getAngle(gpsTraceNow,now_gps_ins,gps_decition);
+    if(!circleMode && PathPoint>(gpsMapLine.size()-100)){
+        controlAng=0;
+    }
+
+
+
+    //1220
+    if(ServiceCarStatus.daocheMode){
+        controlAng=0-controlAng;
+    }
+
+    //2020-0106
+    if(vehState==avoiding){
+        controlAng=max(-150.0,controlAng);
+        controlAng=min(150.0,controlAng);
+    }
+    if(vehState==backOri){
+        controlAng=max(-120.0,controlAng);
+        controlAng=min(120.0,controlAng);
+    }
+
+    //准备驻车
+
+    if (readyZhucheMode)
+    {
+
+        cout<<"ready ZHECHE STATE+++++++++++++++++++++++++++++++++"<<endl;
+        cout<<"zhuche point : "<<zhuchePointNum<<endl;
+
+        double dis = GetDistance(*gpsMapLine[zhuchePointNum], now_gps_ins);
+
+        if (dis<35)
+        {
+            Point2D pt = Coordinate_Transfer((*gpsMapLine[zhuchePointNum]).gps_x, (*gpsMapLine[zhuchePointNum]).gps_y, now_gps_ins);
+            double zhucheDistance = pt.y;
+#if 0
+
+            if (dSpeed > 15)
+            {
+                dSpeed = 15;
+            }
+
+
+
+            if (zhucheDistance < 20 && dis < 25)
+            {
+                dSpeed = min(dSpeed, 5.0);
+            }
+#else
+            if (dSpeed > 12)
+            {
+                dSpeed = 12;
+            }
+
+
+
+            if (zhucheDistance < 9 && dis < 9)
+            {
+                dSpeed = min(dSpeed, 5.0);
+            }
+#endif
+
+
+            if (zhucheDistance < 3.0 && dis < 3.5)
+            {
+                dSpeed = min(dSpeed, 5.0);
+                zhucheMode = true;
+                readyZhucheMode = false;
+                cout<<"jinru ZHECHE STATE+++++++++++++++++++++++++++++++++"<<endl;
+
+                //1125
+                //                 gps_decition->brake=20;
+                //                 gps_decition->accelerator = -3;
+                //                 gps_decition->wheel_angle = 0-controlAng;
+                //                 gps_decition->speed = 0;
+                //                 gps_decition->torque=0;
+                //                 return gps_decition;
+
+
+
+
+
+            }
+
+        }
+
+    }
+
+
+
+
+
+    if (readyParkMode)
+    {
+        double parkDis = GetDistance(now_gps_ins, *gpsMapLine[finishPointNum]);
+        hasZhuched = true;
+
+        if (parkDis < 25)
+        {
+            Point2D pt = Coordinate_Transfer((*gpsMapLine[finishPointNum]).gps_x, (*gpsMapLine[finishPointNum]).gps_y, now_gps_ins);
+            double parkDistance = pt.y;
+
+
+            if (dSpeed > 15)
+            {
+                dSpeed = 15;
+            }
+
+            //dSpeed = 15;//////////////////////////////
+
+            if (parkDistance < 15 && parkDistance >= 4.5 && parkDis<20)
+            {
+                dSpeed = min(dSpeed, 8.0);
+            }else if (parkDistance < 4.5 && parkDistance >= 3.5 && parkDis<5.0){
+                dSpeed = min(dSpeed, 5.0);
+            }else if(parkDistance < 3.5 && parkDis<4.0){
+                dSpeed = min(dSpeed, 3.0);
+            }
+
+
+            //            float stopDis=2;
+            //            if(ServiceCarStatus.msysparam.mvehtype=="ge3"){
+            //                stopDis=1.6;
+            //            } else if(ServiceCarStatus.msysparam.mvehtype=="vv7"){
+            //                stopDis=1.8;
+            //            }
+
+            if (parkDistance < 1.6  && parkDis<2.0)
+            {
+                // dSpeed = 0;
+                parkMode = true;
+                readyParkMode = false;
+            }
+
+
+        }
+    }
+
+
+
+    if (gpsMapLine[PathPoint]->roadMode ==0)
+    {
+        //dSpeed = min(10.0,dSpeed);
+
+        dSpeed = min(ServiceCarStatus.mroadmode_vel.mfmode0,dSpeed);
+        gps_decition->leftlamp = false;
+        gps_decition->rightlamp = false;
+
+    }else  if (gpsMapLine[PathPoint]->roadMode == 5)
+    {
+        //dSpeed = min(8.0,dSpeed);
+
+        dSpeed = min(ServiceCarStatus.mroadmode_vel.mfmode5,dSpeed);
+        gps_decition->leftlamp = false;
+        gps_decition->rightlamp = false;
+
+    }else if (gpsMapLine[PathPoint]->roadMode == 11)
+    {
+        dSpeed = min(ServiceCarStatus.mroadmode_vel.mfmode11,dSpeed);
+
+    }else if (gpsMapLine[PathPoint]->roadMode == 14)
+    {
+        //dSpeed = min(8.0,dSpeed);
+
+        dSpeed = min(ServiceCarStatus.mroadmode_vel.mfmode14,dSpeed);
+        gps_decition->leftlamp = true;
+        gps_decition->rightlamp = false;
+    }else if (gpsMapLine[PathPoint]->roadMode == 15)
+    {
+        //dSpeed = min(8.0,dSpeed);
+
+        dSpeed = min(ServiceCarStatus.mroadmode_vel.mfmode15,dSpeed);
+        gps_decition->leftlamp = false;
+        gps_decition->rightlamp = true;
+    }else if (gpsMapLine[PathPoint]->roadMode == 16)
+    {
+        // dSpeed = min(10.0,dSpeed);
+        dSpeed = min(ServiceCarStatus.mroadmode_vel.mfmode16,dSpeed);
+        gps_decition->leftlamp = true;
+        gps_decition->rightlamp = false;
+    }else if (gpsMapLine[PathPoint]->roadMode == 17)
+    {
+        //  dSpeed = min(10.0,dSpeed);
+        dSpeed = min(ServiceCarStatus.mroadmode_vel.mfmode17,dSpeed);
+        gps_decition->leftlamp = false;
+        gps_decition->rightlamp = true;
+    }else if (gpsMapLine[PathPoint]->roadMode == 18)
+    {
+        // dSpeed = min(10.0,dSpeed);
+        dSpeed = min(ServiceCarStatus.mroadmode_vel.mfmode18,dSpeed);
+        /*if(gpsMapLine[PathPoint]->light_left_or_right == 1)
+        {
+            gps_decition->leftlamp = true;
+            gps_decition->rightlamp = false;
+        }
+        else if(gpsMapLine[PathPoint]->light_left_or_right == 2)
+        {
+            gps_decition->leftlamp = false;
+            gps_decition->rightlamp = true;
+        }*/
+    }else if (gpsMapLine[PathPoint]->roadMode == 1)
+    {
+        dSpeed = min(10.0,dSpeed);
+    }else if (gpsMapLine[PathPoint]->roadMode == 2)
+    {
+        dSpeed = min(15.0,dSpeed);
+    }
+    else if (gpsMapLine[PathPoint]->roadMode == 7)
+    {
+        dSpeed = min(15.0,dSpeed);
+        xiuzhengCs=1.5;
+    }else if (gpsMapLine[PathPoint]->roadMode == 4) //1220
+    {
+        dSpeed = min(4.0,dSpeed);
+
+    }
+
+
+
+
+
+    if (gpsMapLine[PathPoint]->speed_mode == 2)
+    {
+        dSpeed = min(25.0,dSpeed);
+
+    }
+    dSecSpeed = dSpeed / 3.6;
+
+
+
+
+
+
+    std::cout<<"juecesudu2="<<dSpeed<<std::endl;
+
+
+
+
+
+
+
+    if(vehState==changingRoad){
+        if(gpsTraceNow[0].x>1.0){
+            gps_decition->leftlamp = false;
+            gps_decition->rightlamp = true;
+        }else if(gpsTraceNow[0].x<-1.0){
+            gps_decition->leftlamp = true;
+            gps_decition->rightlamp = false;
+        }else{
+            vehState==normalRun;
+        }
+    }
+
+    //    qDebug("decide0 time is %d",xTime.elapsed());
+
+    //1220
+    if(!ServiceCarStatus.daocheMode){
+        computeObsOnRoad(lidarGridPtr, gpsTraceNow, roadNow,gpsMapLine,lidar_per);
+    }else{
+        gpsTraceRear.clear();
+        for(int i=0;i<gpsTraceNow.size();i++){
+            Point2D pt;
+            pt.x=0-gpsTraceNow[i].x;
+            pt.y=0-gpsTraceNow[i].y;
+            gpsTraceRear.push_back(pt);
+        }
+        computeObsOnRoad(lidarGridPtr, gpsTraceNow, roadNow,gpsMapLine,lidar_per);
+        //  obsDistance=-1; //1227
+    }
+
+
+
+
+    //old_bz--------------------------------------------------------------------------------------------------
+
+    if (vehState == avoiding)
+    {
+        cout<<"\n==================avoiding=================\n"<<endl;
+        //  vehState=normalRun; //1025
+        if (dSpeed > 10) {
+            dSpeed = 10;
+        }
+        //若车辆到达变道后的路径,改变车辆状态,关闭frenet规划
+        if (useFrenet && abs(gpsTraceAim[0].x)<1.0) {
+            vehState = normalRun;
+            //            useFrenet = false;
+            //            useOldAvoid = true;
+        }
+        else if (useOldAvoid && abs(gpsTraceNow[0].x)<1.0) {
+            // vehState = avoidObs; 0929
+            vehState = normalRun;
+        }
+        else if (gpsTraceNow[0].x>0)
+        {
+            gps_decition->leftlamp = false;
+            gps_decition->rightlamp = true;
+        }
+        else if(gpsTraceNow[0].x<0)
+        {
+            gps_decition->leftlamp = true;
+            gps_decition->rightlamp = false;
+        }
+    }
+
+
+    if (vehState==preBack)
+    {
+        vehState = backOri;
+    }
+
+
+    if (vehState==backOri)
+    {
+        cout<<"\n================backOri===========\n"<<endl;
+        //  vehState=normalRun; //1025
+        if (dSpeed > 10) {
+            dSpeed = 10;
+        }
+
+        //若车辆到达变道后的路径,改变车辆状态,关闭frenet规划
+        if (useFrenet && abs(gpsTraceAim[0].x)<1.0) {
+            vehState = normalRun;
+            //            useFrenet = false;
+            //            useOldAvoid = true;
+        }
+        else if (useOldAvoid && abs(gpsTraceNow[0].x)<1.0) {
+            // vehState = avoidObs; 0929
+            vehState = normalRun;
+        }
+        else if (gpsTraceNow[0].x>0)
+        {
+            gps_decition->leftlamp = false;
+            gps_decition->rightlamp = true;
+        }
+        else if (gpsTraceNow[0].x<0)
+        {
+            gps_decition->leftlamp = true;
+            gps_decition->rightlamp = false;
+        }
+    }
+
+    std::cout<<"\n原始RoadOri:%d\n"<<roadOri<<endl;
+
+    cout<<"\n当前RoadNum:%d\n"<<roadNow<<endl;
+
+
+
+
+
+
+
+
+
+    //   计算回归原始路线
+
+    if (roadNow!=roadOri)
+    {
+        //        useFrenet = true;
+        //        useOldAvoid = false;
+
+        if(useFrenet){
+            if ((GetDistance(now_gps_ins, startAvoidGpsInsVector[roadOri])>max(avoidMinDistanceVector[roadOri],30.0)))
+            {
+                double offsetL = -(roadSum - 1)*roadWidth;
+                double offsetR = (roadOri - 0)*roadWidth;
+                roadPre = frenetPlanner->chooseRoadByFrenet(now_gps_ins,gpsMapLine,PathPoint,offsetL,offsetR,lidarGridPtr,roadNow);
+            }
+        }
+        else if(useOldAvoid){
+            roadPre = chooseBackRoad(lidarGridPtr, now_gps_ins, gpsMapLine,lidar_per);
+            avoidX = (roadOri - roadNow)*roadWidth; //1012
+        }
+    }
+    if (roadNow != roadOri && roadPre!=-1)
+    {
+
+        roadNow = roadPre;
+        avoidX = (roadOri - roadNow)*roadWidth;
+        gpsTraceNow.clear();
+        if(useOldAvoid){
+            gpsTraceNow = getGpsTraceOffset(gpsTraceOri, avoidX);
+        }
+        else if(useFrenet){
+            gpsTraceNow = frenetPlanner->getPath(now_gps_ins,gpsMapLine,PathPoint,avoidX,lidarGridPtr);
+        }
+
+        vehState = backOri;
+        hasCheckedBackLidar = false;
+        //  checkBackObsTimes = 0;
+
+        cout<<"\n回归RoadNum:%d\n"<< roadNow<<endl;
+
+    }
+
+    //shiyanbizhang 0929
+    if(obsDistance>0&& (obsDistance<ServiceCarStatus.socfDis+20.0) &&(abs(realspeed)<1.0) &&
+            (vehState==normalRun||vehState==backOri || vehState==avoiding) &&(ObsTimeStart==-1)
+            && (gpsMapLine[PathPoint]->runMode==1)){
+        ObsTimeStart=GetTickCount();
+        cout<<"\n====================preAvoid time count start==================\n"<<endl;
+    }
+    if(ObsTimeStart!=-1){
+        ObsTimeEnd=GetTickCount();
+    }
+    if(ObsTimeEnd!=-1){
+        ObsTimeSpan=ObsTimeEnd-ObsTimeStart;
+    }
+    if(ObsTimeSpan>ObsTimeWidth &&(obsDistance>1.5||obsDistance<0) && (gpsMapLine[PathPoint]->runMode==1)){ //1026
+        vehState=avoidObs;
+        ObsTimeStart=-1;
+        ObsTimeEnd=-1;
+        ObsTimeSpan=-1;
+        cout<<"\n====================preAvoid time count finish==================\n"<<endl;
+    }
+
+    if(obsDistance<0 ||obsDistance>ServiceCarStatus.socfDis){
+        ObsTimeStart=-1;
+        ObsTimeEnd=-1;
+        ObsTimeSpan=-1;
+
+    }
+
+
+    //避障模式
+
+
+    if (vehState == avoidObs   || vehState==waitAvoid ) {
+
+        //      if (obsDistance <20 && obsDistance >0)
+        if (obsDistance <ServiceCarStatus.aocfDis && obsDistance >0)
+        {
+            dSpeed = min(7.0,dSpeed);
+            avoidTimes++;
+            //          if (avoidTimes>=6)
+            if (avoidTimes>=ServiceCarStatus.aocfTimes)
+            {
+                vehState = preAvoid;
+                avoidTimes = 0;
+            }
+
+        }
+        //        else if (obsDistance < 35 && obsDistance >0 && dSpeed>10)
+        //        {
+        //            dSpeed = 10;
+        //            avoidTimes = 0;
+        //        }
+        else if (obsDistance < 40 && obsDistance >0 && dSpeed>15)
+        {
+            dSpeed =  min(15.0,dSpeed);
+            avoidTimes = 0;
+        }
+        else
+        {
+            avoidTimes = 0;
+        }
+
+    }
+
+
+    if (vehState == preAvoid)
+    {
+        cout<<"\n====================preAvoid==================\n"<<endl;
+        /* if (obsDisVector[roadNow]>30)*/  //if (obsDisVector[roadNow]>30||obsDisVector[roadNow]<0)
+        if (obsDisVector[roadNow]>ServiceCarStatus.aocfDis)
+        {
+            // vehState = avoidObs; 0929
+            vehState=normalRun;
+        }
+        else
+        {
+            //roadPre = chooseAvoidRoad(lidarGridPtr, now_gps_ins,gpsMapLine);
+            if(useOldAvoid){
+                roadPre = chooseAvoidRoad(lidarGridPtr, now_gps_ins,gpsMapLine,lidar_per);
+                avoidX = (roadOri - roadNow)*roadWidth;  //1012
+            }
+            else if(useFrenet){
+                double offsetL = -(roadSum - 1)*roadWidth;
+                double offsetR = (roadOri - 0)*roadWidth;
+                roadPre = frenetPlanner->chooseRoadByFrenet(now_gps_ins,gpsMapLine,PathPoint,offsetL,offsetR,lidarGridPtr,roadNow);
+            }
+
+            if (roadPre == -1 && obsDisVector[roadNow]<1.5 && obsDisVector[roadNow]>0)
+            {
+                //  vehState = waitAvoid; 0929
+                vehState = avoidObs;
+            }
+            else if (roadPre != -1)
+            {
+                if(useOldAvoid){
+                    roadNow = roadPre;
+                    avoidX = (roadOri - roadNow)*roadWidth;
+                    gpsTraceNow.clear();
+                    gpsTraceNow = getGpsTraceOffset(gpsTraceOri, avoidX);
+                }
+                else if(useFrenet){
+                    if(roadPre != roadNow){
+                        avoidMinDistanceVector[roadNow] = obsDisVector[roadNow] + Veh_Lenth;
+                        startAvoidGpsInsVector[roadNow] = now_gps_ins;
+                    }
+                    roadNow = roadPre;
+                    avoidX = (roadOri - roadNow)*roadWidth;
+                    gpsTraceNow = frenetPlanner->getPath(now_gps_ins,gpsMapLine,PathPoint,avoidX,lidarGridPtr);
+                }
+
+
+                vehState = avoiding;
+
+                hasCheckedAvoidLidar = false;
+
+                cout<<"\n避障到RoadNum:%d\n"<<roadNow<<endl;
+
+            }
+        }
+    }
+
+    //--------------------------------------------------------------------------------old_bz_end
+
+
+
+
+
+    //TOUCHEPINGBI
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    if (parkMode)
+    {
+        minDecelerate=-1.0;
+
+        if(finishPointNum<0||finishPointNum>=gpsMapLine.size()){
+            parkMode=false;
+        }else if(GetDistance(now_gps_ins, *gpsMapLine[finishPointNum])>20){
+            parkMode=false;
+        }
+
+    }
+
+
+
+    //驻车
+
+    if (zhucheMode)
+    {
+        int mzcTime = ServiceCarStatus.msysparam.mzhuchetime * 1000;
+
+        //        if(trumpet()<16000)
+        if (trumpet()<mzcTime)
+        {
+            //            if (trumpet()<12000){
+            cout<<"ZHECHE ING STATE+++++++++++++++++++++++++++++++++"<<endl;
+            minDecelerate=-1.0;
+            if(abs(realspeed)<0.2){
+                controlAng=0;  //tju
+            }
+        }
+        else
+        {
+            hasZhuched = true; //1125
+            zhucheMode = false;
+            trumpetFirstCount = true;
+            cout<<"ZHECHE STATE JIESHU +++++++++++++++++++++++++++++++++"<<endl;
+        }
+
+    }
+
+
+    //判断驻车标志位
+    if (hasZhuched && GetDistance(now_gps_ins,*gpsMapLine[zhuchePointNum])>20)
+    {
+        hasZhuched = false;
+    }
+
+
+
+
+
+
+
+
+
+
+
+    if ( vehState==changingRoad || vehState==chaocheBack)
+    {
+        double lastAng = 0.0 - lastAngle;
+        if (controlAng>40)
+        {
+            controlAng =40;
+        }
+        else if (controlAng<-40)
+        {
+            controlAng = - 40;
+        }
+
+
+    }
+
+
+    //速度结合角度的限制
+    controlAng = limitAngle(realspeed, controlAng);
+
+
+    std::cout << "\n呼车指令状态:%d\n" <<  ServiceCarStatus.carState << std::endl;
+
+
+
+    //1220
+    if(PathPoint+80<gpsMapLine.size()-1){
+        if(gpsMapLine[PathPoint+80]->roadMode==4  && !ServiceCarStatus.daocheMode){
+            changingDangWei=true;
+        }
+    }
+
+    if(changingDangWei){
+        if(abs(realspeed)>0.1){
+            dSpeed=0;
+        }else{
+            dSpeed=0;
+            gps_decition->dangWei=2;
+            ServiceCarStatus.daocheMode=true;
+        }
+    }
+    //1220 end
+
+
+
+
+    for(int i = 0;i<ServiceCarStatus.car_stations.size();i++)
+    {
+        GPS_INS gpsIns;
+        GaussProjCal(ServiceCarStatus.car_stations[i].longtitude, ServiceCarStatus.car_stations[i].latitude,  &gpsIns.gps_x, &gpsIns.gps_y);
+
+        double dis = GetDistance(gpsIns, now_gps_ins);
+        if(dis<20)
+            ServiceCarStatus.currentstation = ServiceCarStatus.car_stations[i].ID;
+    }
+
+
+
+
+    if (ServiceCarStatus.carState == 0 && busMode)
+    {
+
+        minDecelerate=-1.0;
+    }
+
+
+
+    if (ServiceCarStatus.carState == 3 && busMode)
+    {
+
+        if(realspeed<0.1){
+            ServiceCarStatus.carState=0;
+            minDecelerate=-1.0;
+        }else{
+            nearStation=true;
+            dSpeed=0;
+        }
+
+    }
+
+
+
+
+
+
+
+    ///kkcai, 2020-01-03
+    //if (ServiceCarStatus.carState == 2 && busMode)
+    if (ServiceCarStatus.carState == 2)
+    {
+
+        aim_gps_ins.gps_lat=ServiceCarStatus.amilat;
+        aim_gps_ins.gps_lng=ServiceCarStatus.amilng;
+        //   gps2xy(ServiceCarStatus.amilat, ServiceCarStatus.amilng, &aim_gps_ins.gps_x, &aim_gps_ins.gps_y);
+        GaussProjCal( aim_gps_ins.gps_lng, aim_gps_ins.gps_lat,  &aim_gps_ins.gps_x, &aim_gps_ins.gps_y);
+        std::cout<<"lng"<<ServiceCarStatus.amilng<<std::endl;
+        qDebug("lat:%f", aim_gps_ins.gps_lat);
+        qDebug("lon:%f", aim_gps_ins.gps_lng);
+
+        std::cout<<"lat"<<ServiceCarStatus.amilat<<std::endl;
+        double dis = GetDistance(aim_gps_ins, now_gps_ins);
+        Point2D pt = Coordinate_Transfer((aim_gps_ins).gps_x, (aim_gps_ins).gps_y, now_gps_ins);
+
+        std::cout << "\n呼车dis距离:%f\n" << dis << std::endl;
+        std::cout << "\n呼车Y距离:%f\n" << pt.y << std::endl;
+
+        //         if (dis<20 && pt.y<8&& realspeed<0.1)
+        if (dis<20 && pt.y<5 && abs(pt.x)<3)
+        {
+            dSpeed = 0;
+            nearStation=true;
+            //is_arrivaled = true;
+            //ServiceCarStatus.status[0] = true;
+            ServiceCarStatus.istostation=1;
+            minDecelerate=-1.0;
+        }
+
+        else if (dis<20 && pt.y<15 && abs(pt.x)<3)
+        {
+            nearStation=true;
+            dSpeed = min(8.0, dSpeed);
+        }
+        else if (dis<30 && pt.y<20 && abs(pt.x)<3)
+        {
+            dSpeed = min(15.0, dSpeed);
+        }
+
+        else if (dis<50 && abs(pt.x)<3)
+        {
+            dSpeed = min(20.0, dSpeed);
+        }
+    }
+
+
+    dSecSpeed = dSpeed / 3.6;
+    gps_decition->speed = dSpeed;
+
+
+
+    if (gpsMapLine[PathPoint]->runMode == 2)
+    {
+        obsDistance = -1;
+
+    }
+
+    std::cout<<"juecesudu0="<<dSpeed<<std::endl;
+
+    //-------------------------------traffic light----------------------------------------------------------------------------------------
+
+    if(traffic_light_gps.gps_lat!=0 && traffic_light_gps.gps_lng!=0){
+        traffic_light_pathpoint = Compute00().getNoAngleNearestPointIndex(traffic_light_gps, gpsMapLine);
+        //    traffic_light_pathpoint=130;
+        float traffic_speed=ComputeTrafficLightSpeed(ServiceCarStatus.iTrafficeLightColor,ServiceCarStatus.iTrafficeLightTime,gpsMapLine,
+                                                     traffic_light_pathpoint ,PathPoint,secSpeed,dSpeed);
+        dSpeed = min((double)traffic_speed,dSpeed);
+        if(traffic_speed==0){
+            minDecelerate=-2.0;
+        }
+    }
+    //-------------------------------traffic light  end-----------------------------------------------------------------------------------------------
+
+
+    //-------------------------------v2x traffic light-----------------------------------------------------------------------------------------
+
+
+    double v2xTrafficSpeed= ComputeV2XTrafficLightSpeed( trafficLight,  gpsMapLine, v2xTrafficVector,
+                                                         PathPoint, secSpeed, dSpeed,  circleMode);
+
+
+    dSpeed = min(v2xTrafficSpeed,dSpeed);
+
+    //------------------------------v2x traffic light end--------------------------------------------------------------------------------------
+
+
+    if(obsDistance>0 && obsDistance<10){
+        dSpeed=0;
+    }
+    //  obsDistance=-1; //1227
+
+    if(ServiceCarStatus.group_control){
+        dSpeed = ServiceCarStatus.group_comm_speed;
+    }
+    if(dSpeed==0){
+        minDecelerate=min(-1.0f,minDecelerate);
+    }
+
+    std::cout<<"dSpeed= "<<dSpeed<<std::endl;
+
+    // givlog->debug("SPEED","dSpeed is %f",dSpeed);
+    phaseSpeedDecition(gps_decition, secSpeed, obsDistance, obsSpeed,now_gps_ins);
+
+
+
+
+
+    gps_decition->wheel_angle = 0.0 - controlAng;
+
+
+
+    lastAngle=gps_decition->wheel_angle;
+
+    //   qDebug("decide1 time is %d",xTime.elapsed());
+
+    return gps_decition;
+}
+
+
+
+void iv::decition::DecideGps00::initMethods(){
+
+    pid_Controller= new PIDController();
+    ge3_Adapter = new Ge3Adapter();
+    qingyuan_Adapter = new QingYuanAdapter();
+    vv7_Adapter = new VV7Adapter();
+    zhongche_Adapter = new ZhongcheAdapter();
+    bus_Adapter = new BusAdapter();
+    hapo_Adapter = new HapoAdapter();
+
+
+    mpid_Controller.reset(pid_Controller);
+    mge3_Adapter.reset(ge3_Adapter);
+    mqingyuan_Adapter.reset(qingyuan_Adapter);
+    mvv7_Adapter.reset(vv7_Adapter);
+    mzhongche_Adapter.reset(zhongche_Adapter);
+    mbus_Adapter.reset(bus_Adapter);
+    mhapo_Adapter.reset(hapo_Adapter);
+
+    frenetPlanner = new FrenetPlanner();
+    //    laneChangePlanner = new LaneChangePlanner();
+
+    mfrenetPlanner.reset(frenetPlanner);
+    //    mlaneChangePlanner.reset(laneChangePlanner);
+
+}
+
+
+void iv::decition::DecideGps00::phaseSpeedDecition(iv::decition::Decition  decition, double secSpeed, double obsDis, double obsSpeed, GPS_INS gpsIns ) {
+
+    pid_Controller->getControlDecition( gpsIns, gpsTraceNow,  dSpeed,  obsDis,  obsSpeed, false, true, &decition);
+
+    if(ServiceCarStatus.msysparam.mvehtype=="ge3"){
+        ge3_Adapter->getAdapterDeciton(gpsIns, gpsTraceNow, dSpeed, obsDis,obsSpeed,  decition->accelerator,ServiceCarStatus.mfCalAcc  ,changingDangWei, &decition);
+    }else if( ServiceCarStatus.msysparam.mvehtype=="qingyuan"){
+        qingyuan_Adapter->getAdapterDeciton(gpsIns, gpsTraceNow, dSpeed, obsDis,obsSpeed,  decition->accelerator,ServiceCarStatus.mfCalAcc  ,changingDangWei, &decition);
+    }else if( ServiceCarStatus.msysparam.mvehtype=="vv7"){
+        vv7_Adapter->getAdapterDeciton(gpsIns, gpsTraceNow, dSpeed, obsDis,obsSpeed,  decition->accelerator,ServiceCarStatus.mfCalAcc  ,changingDangWei, &decition);
+    }else if( ServiceCarStatus.msysparam.mvehtype=="zhongche"){
+        zhongche_Adapter->getAdapterDeciton(gpsIns, gpsTraceNow, dSpeed, obsDis,obsSpeed,  decition->accelerator,ServiceCarStatus.mfCalAcc  ,changingDangWei, &decition);
+    }else if(ServiceCarStatus.msysparam.mvehtype=="bus"){
+        bus_Adapter->getAdapterDeciton(gpsIns, gpsTraceNow, dSpeed, obsDis,obsSpeed,  decition->accelerator,ServiceCarStatus.mfCalAcc  ,changingDangWei, &decition);
+    }else if(ServiceCarStatus.msysparam.mvehtype=="hapo"){
+        hapo_Adapter->getAdapterDeciton(gpsIns, gpsTraceNow, dSpeed, obsDis,obsSpeed,  decition->accelerator,ServiceCarStatus.mfCalAcc  ,changingDangWei, &decition);
+    }
+}
+
+
+
+std::vector<iv::Point2D> iv::decition::DecideGps00::getGpsTrace(iv::GPS_INS now_gps_ins, const std::vector<GPSData> gpsMapLine, int lastIndex, bool circleMode) {
+    vector<iv::Point2D> trace;
+    //	int  PathPoint = Compute00().getNearestPointIndex(now_gps_ins, gpsMapLine, DecideGps00::lastGpsIndex, DecideGps00::minDis, DecideGps00::maxAngle);
+    /*if (PathPoint != -1)
+        lastGpsIndex = PathPoint;*/
+
+    if (gpsMapLine.size() > 600 && PathPoint >= 0) {
+        int aimIndex;
+        if(circleMode){
+            aimIndex=PathPoint+600;
+        }else{
+            aimIndex=min((PathPoint+600),(int)gpsMapLine.size());
+        }
+
+        for (int i = PathPoint; i < aimIndex; i++)
+        {
+            int index = i % gpsMapLine.size();
+            Point2D pt = Coordinate_Transfer((*gpsMapLine[index]).gps_x, (*gpsMapLine[index]).gps_y, now_gps_ins);
+            pt.x += offset_real * 0.032;
+            pt.v1 = (*gpsMapLine[index]).speed_mode;
+            pt.v2 = (*gpsMapLine[index]).mode2;
+            pt.roadMode=(*gpsMapLine[index]).roadMode;
+            if (gpsMapLine[index]->roadMode==3 && !hasZhuched)
+            {
+                readyZhucheMode = true;
+                DecideGps00::zhuchePointNum = index;
+            }
+
+
+
+            if (gpsMapLine[index]->roadMode==3 && !hasZhuched)
+            {
+                readyZhucheMode = true;
+                DecideGps00::zhuchePointNum = index;
+            }
+
+            //csvv7
+            if (gpsMapLine[index]->speed_mode==22 || gpsMapLine[index]->speed_mode==23)
+            {
+                readyParkMode = true;
+                DecideGps00::finishPointNum = index;
+            }
+
+            //			if (pt.v1 == 22 || pt.v1 == 23)
+            //			{
+            //				readyParkMode = true;
+            //				DecideGps00::finishPointNum = i;
+            //			}
+
+
+            switch (pt.v1)
+            {
+            case 0:
+                pt.speed = 80;
+                break;
+            case 1:
+                pt.speed = 25;
+                break;
+            case 2:
+                pt.speed =25;
+                break;
+            case 3:
+                pt.speed = 20;
+                break;
+            case 4:
+                pt.speed =18;
+                break;
+            case 5:
+                pt.speed = 18;
+                break;
+            case 7:
+                pt.speed = 10;
+                break;
+            case 22:
+                pt.speed = 5;
+                break;
+            case 23:
+                pt.speed = 5;
+                break;
+            default:
+                break;
+            }
+            trace.push_back(pt);
+        }
+    }
+    return trace;
+}
+
+std::vector<iv::Point2D>  iv::decition::DecideGps00::getGpsTraceOffset(std::vector<Point2D> gpsTrace, double offset) {
+
+    if (offset==0)
+    {
+        return gpsTrace;
+    }
+
+    std::vector<iv::Point2D> trace;
+    for (int j = 0; j < gpsTrace.size(); j++)
+    {
+        double sumx1 = 0, sumy1 = 0, count1 = 0;
+        double sumx2 = 0, sumy2 = 0, count2 = 0;
+        for (int k = max(0, j - 4); k <= j; k++)
+        {
+            count1 = count1 + 1;
+            sumx1 += gpsTrace[k].x;
+            sumy1 += gpsTrace[k].y;
+        }
+        for (int k = j; k <= min(gpsTrace.size() - 1, (size_t)(j + 4)); k++)
+        {
+            count2 = count2 + 1;
+            sumx2 += gpsTrace[k].x;
+            sumy2 += gpsTrace[k].y;
+        }
+        sumx1 /= count1; sumy1 /= count1;
+        sumx2 /= count2; sumy2 /= count2;
+
+        double anglevalue = atan2(sumy2 - sumy1, sumx2 - sumx1);
+
+        double carFrontx = gpsTrace[j].x;// -Form1.CarRear * Math.Cos(anglevalue);
+        double carFronty = gpsTrace[j].y;// -Form1.CarRear * Math.Sin(anglevalue);
+
+        double avoidLenth = abs(offset);
+        if (offset<0)
+        {
+            Point2D ptLeft(carFrontx + avoidLenth * cos(anglevalue + PI / 2),
+                           carFronty + avoidLenth  * sin(anglevalue + PI / 2));
+            ptLeft.speed = gpsTrace[j].speed;
+            ptLeft.v1 = gpsTrace[j].v1;
+            ptLeft.v2 = gpsTrace[j].v2;
+            trace.push_back(ptLeft);
+        }
+        else
+        {
+            Point2D ptRight(carFrontx + avoidLenth  * cos(anglevalue - PI / 2),
+                            carFronty + avoidLenth  * sin(anglevalue - PI / 2));
+            ptRight.speed = gpsTrace[j].speed;
+            ptRight.v1 = gpsTrace[j].v1;
+            ptRight.v2 = gpsTrace[j].v2;
+
+
+            trace.push_back(ptRight);
+        }
+    }
+    return trace;
+}
+
+
+double iv::decition::DecideGps00::getAngle(std::vector<Point2D> gpsTrace,GPS_INS gpsIns,iv::decition::Decition decition) {
+    double angle=0;
+    if ( abs(iv::decition::DecideGps00().minDis) < 20 && abs(iv::decition::DecideGps00().maxAngle) < 100)
+    {
+        //   angle = iv::decition::Compute00().getDecideAngle(gpsTrace, realspeed);
+        pid_Controller->getControlDecition(gpsIns, gpsTrace,  -1,  -1,  -1, true, false, &decition);
+        angle= decition->wheel_angle;
+    }
+    return angle;
+}
+
+double iv::decition::DecideGps00::getSpeed(std::vector<Point2D> gpsTrace) {
+    double speed=0;
+    int speedPoint = iv::decition::Compute00().getSpeedPointIndex(gpsTrace, max(10.0, realspeed));
+    speed = gpsTrace[speedPoint].speed;
+    for (int i = 0; i < speedPoint; i++) {
+        speed = min(speed, gpsTrace[i].speed);
+    }
+    return speed;
+}
+
+
+
+
+//void iv::decition::DecideGps00::getEsrObs(std::vector<iv::ObstacleBasic> obsRadars) {
+//
+//	if (!obsRadars.empty())
+//	{
+//		esrIndex = iv::decition::Compute00().getEsrIndex(gpsTrace, obsRadars);
+//
+//		if (esrIndex != -1)
+//		{
+//			 esrDistance = obsRadars[esrIndex].nomal_y;
+//
+//
+//
+//			obsSpeed = obsRadars[esrIndex].speed_y;
+//
+//		}
+//		else {
+//			esrDistance = -1;
+//		}
+//
+//	}
+//	else
+//	{
+//		esrIndex = -1;
+//		esrDistance = -1;
+//	}
+//	if (esrDistance < 0) {
+//		ODS("\n------------------>ESR障碍物距离:%f\n", esrDistance);
+//	}
+//	else {
+//		ODS("\n------------------>ESR障碍物距离:%f   ( %.05f , %.05f )\n", esrDistance, obsRadars[esrIndex].nomal_x, obsRadars[esrIndex].nomal_y);
+//	}
+//
+//	ODS("\n------------------>ESR障碍物速度:%f\n", obsSpeed);
+//}
+
+
+
+void iv::decition::DecideGps00::getEsrObsDistance(std::vector<Point2D> gpsTrace, int roadNum) {
+
+
+    int esrPathpoint;
+
+    esrIndex = iv::decition::Compute00().getEsrIndex(gpsTrace, roadNum, &esrPathpoint);
+
+    if (esrIndex != -1)
+    {
+        //优化
+        //        double distance = 0.0;
+        //        for(int i=0; i<esrPathpoint; ++i){
+        //            distance+=DirectDistance(gpsTrace[i].x,gpsTrace[i].y,gpsTrace[i+1].x,gpsTrace[i+1].y);
+        //        }
+        //        esrDistance = distance - Esr_Y_Offset;
+        //        if(esrDistance<=0){
+        //            esrDistance=1;
+        //        }
+
+
+        esrDistance = ServiceCarStatus.obs_radar[esrIndex].nomal_y;
+        obsSpeed = ServiceCarStatus.obs_radar[esrIndex].speed_y;
+
+    }
+    else {
+        esrDistance = -1;
+    }
+}
+
+
+
+
+void iv::decition::DecideGps00::getEsrObsDistanceAvoid() {
+
+    esrIndexAvoid = iv::decition::Compute00().getEsrIndexAvoid(gpsTraceAvoid);
+
+    if (esrIndexAvoid != -1)
+    {
+        esrDistanceAvoid = ServiceCarStatus.obs_radar[esrIndexAvoid].nomal_y;
+        obsSpeedAvoid = ServiceCarStatus.obs_radar[esrIndexAvoid].speed_y;
+
+    }
+    else {
+        esrDistanceAvoid = -1;
+    }
+
+    if (esrDistanceAvoid < 0) {
+        std::cout << "\nESR障碍物距离Avoid:%f\n" << esrDistanceAvoid << std::endl;
+    }
+    else {
+        std::cout << "\nESR障碍物距离Avoid:%f   %d:( %.05f , %.05f ,%.05f )\n" << esrDistanceAvoid << esrIndexAvoid << ServiceCarStatus.obs_radar[esrIndexAvoid].nomal_x << ServiceCarStatus.obs_radar[esrIndexAvoid].nomal_y << std::endl;
+    }
+
+    std::cout << "\nESR障碍物速度Avoid:%f\n" << obsSpeedAvoid <<std::endl;
+}
+
+
+
+
+double iv::decition::DecideGps00::limitAngle(double speed, double angle) {
+    double preAngle = angle;
+
+    if (speed > 15)
+    {
+        if (preAngle > 350)
+        {
+            preAngle = 350;
+        }
+        if (preAngle < -350)
+        {
+            preAngle = -350;
+        }
+    }
+    if (speed > 22)
+    {
+        if (preAngle > 200)
+        {
+            preAngle = 200;
+        }
+        if (preAngle < -200)
+        {
+            preAngle = -200;
+        }
+    }
+    if (speed > 25)
+    {
+        if (preAngle > 150)
+        {
+            preAngle = 150;
+        }
+        if (preAngle < -150)
+        {
+            preAngle = -150;
+        }
+    }
+    if (speed > 30)
+    {
+        if (preAngle > 70)
+        {
+            preAngle = 70;
+        }
+        if (preAngle < -70)
+        {
+            preAngle = -70;
+        }
+    }
+    if (speed > 45)                     //20
+    {
+        if (preAngle > 15)
+        {
+            preAngle = 15;
+        }
+        if (preAngle < -15)
+        {
+            preAngle = -15;
+        }
+    }
+    return preAngle;
+}
+
+
+
+double iv::decition::DecideGps00::limitSpeed(double angle, double speed) {
+
+    if (abs(angle) > 500 && speed > 8) speed = 8;
+    else if (abs(angle) > 350 && speed > 14) speed = 14;
+    else if (abs(angle) > 200 && speed > 21) speed = 21;
+    else if (abs(angle) > 150 && speed > 24) speed = 24;
+    else if (abs(angle) > 60 && speed > 29) speed = 29;
+    else if (abs(angle) > 20 && speed > 34) speed = 34;
+    return max(0.0, speed);
+}
+
+
+bool iv::decition::DecideGps00::checkAvoidEnable(double avoidX, iv::LidarGridPtr lidarGridPtr,int roadNum) {
+
+    if ((obsDisVector[roadNum]>0 && obsDisVector[roadNum]<obsDisVector[roadNow]+Veh_Lenth)||
+            (obsDisVector[roadNum]>0 && obsDisVector[roadNum]<15))
+    {
+        return false;
+    }
+
+    if (roadNum-roadNow>1)
+    {
+        for (int i = roadNow+1; i < roadNum; i++)
+        {
+            if (obsDisVector[i] < 8 + (i-roadNow) * 2 && obsDisVector[i]>0) {
+                return false;
+            }
+        }
+
+    }
+
+    else if (roadNow-roadNum>1)
+    {
+        for (int i = roadNow-1; i >roadNum; i--)
+        {
+            if (obsDisVector[i] < 8 + (roadNow-i) * 2 && obsDisVector[i]>0) {
+                return false;
+            }
+        }
+    }
+    return true;
+}
+
+
+
+bool iv::decition::DecideGps00::checkReturnEnable(double avoidX, iv::LidarGridPtr lidarGridPtr, int roadNum) {
+    //lsn
+    if (obsDisVector[roadNum]>0 && obsDisVector[roadNum]<20)
+    {
+        return false;
+    }
+    if ((obsDisVector[roadNum]>0 && obsDisVector[roadNum]<50 && obsDisVector[roadNum]< obsDisVector[roadNow]) ||
+            (obsDisVector[roadNum]>0 && obsDisVector[roadNum]<50 && obsDisVector[roadNow]<0))
+    {
+        return false;
+    }
+
+
+    if (roadNum - roadNow>1)
+    {
+        for (int i = roadNow + 1; i < roadNum; i++)
+        {
+            if (obsDisVector[i] < 8 + (i-roadNow) * 2 && obsDisVector[i]>0) {
+                return false;
+            }
+        }
+
+    }
+
+    else if (roadNow - roadNum>1)
+    {
+        for (int i = roadNow - 1; i >roadNum; i--)
+        {
+            if (obsDisVector[i] < 8 + (roadNow-i) * 2 && obsDisVector[i]>0) {
+                return false;
+            }
+        }
+    }
+    return true;
+}
+
+
+void iv::decition::DecideGps00::getObsAvoid(iv::LidarGridPtr lidarGridPtr) {
+
+
+
+    if (lidarGridPtr == NULL)
+    {
+        iv::decition::DecideGps00::lidarDistanceAvoid = iv::decition::DecideGps00::lastLidarDisAvoid;
+    }
+    else {
+        obsPointAvoid = Compute00().getLidarObsPointAvoid(gpsTraceAvoid, lidarGridPtr);
+        iv::decition::DecideGps00::lastLidarDisAvoid = iv::decition::DecideGps00::lidarDistanceAvoid;
+    }
+    std::cout << "\nLidarAvoid距离:%f\n" << iv::decition::DecideGps00::lidarDistanceAvoid << std::endl;
+    getEsrObsDistanceAvoid();
+
+    //lidarDistanceAvoid = -1;   //20200103 apollo_fu
+
+    if (esrDistanceAvoid>0 && iv::decition::DecideGps00::lidarDistanceAvoid > 0)
+    {
+        if (iv::decition::DecideGps00::lidarDistanceAvoid >= esrDistanceAvoid)
+        {
+            obsDistanceAvoid = esrDistanceAvoid;
+            obsSpeedAvoid = ServiceCarStatus.obs_radar[esrIndexAvoid].speed_y;
+        }
+        else if (!ServiceCarStatus.obs_radar.empty())
+        {
+            obsDistanceAvoid = iv::decition::DecideGps00::lidarDistanceAvoid;
+            obsSpeedAvoid = Compute00().getObsSpeed(obsPointAvoid, secSpeed);
+            std::cout << "\n计算obsSpeed:%f\n" << obsSpeedAvoid << std::endl;
+        }
+        else
+        {
+            obsDistanceAvoid = iv::decition::DecideGps00::lidarDistanceAvoid;
+            obsSpeedAvoid = obsSpeedAvoid = 0 - secSpeed;;
+            std::cout << "\n毫米波无数据,计算obsSpeed:%f\n" << obsSpeedAvoid << std::endl;
+        }
+    }
+    else if (esrDistanceAvoid>0)
+    {
+        obsDistanceAvoid = esrDistanceAvoid;
+        obsSpeedAvoid = ServiceCarStatus.obs_radar[esrIndexAvoid].speed_y;
+    }
+    else if (iv::decition::DecideGps00::lidarDistanceAvoid > 0)
+    {
+        obsDistanceAvoid = iv::decition::DecideGps00::lidarDistanceAvoid;
+        obsSpeedAvoid = Compute00().getObsSpeed(obsPointAvoid, secSpeed);
+        std::cout << "\n计算obsSpeed:%f\n" << obsSpeedAvoid << std::endl;
+    }
+    else {
+        obsDistanceAvoid = esrDistanceAvoid;
+        obsSpeedAvoid = 0 - secSpeed;
+    }
+
+    std::cout << "\n最终得出的obsDistanceAvoid:%f\n" << obsDistanceAvoid << std::endl;
+
+
+
+
+
+    if (iv::decition::DecideGps00::obsDistanceAvoid <0 && obsLostTimeAvoid<4)
+    {
+        iv::decition::DecideGps00::obsDistanceAvoid = iv::decition::DecideGps00::lastDistanceAvoid;
+        obsLostTimeAvoid++;
+    }
+    else
+    {
+        obsLostTimeAvoid = 0;
+        iv::decition::DecideGps00::lastDistanceAvoid = -1;
+    }
+
+
+
+
+    if (obsDistanceAvoid>0)
+    {
+        iv::decition::DecideGps00::lastDistanceAvoid = obsDistanceAvoid;
+    }
+
+    std::cout << "\nODSAvoid距离:%f\n" << iv::decition::DecideGps00::obsDistanceAvoid << std::endl;
+}
+
+void iv::decition::DecideGps00::init() {
+    for (int i = 0; i < roadSum; i++)
+    {
+        lastEsrIdVector.push_back(-1);
+        lastEsrCountVector.push_back(0);
+        GPS_INS gps_ins;
+        gps_ins.gps_x = 0;
+        gps_ins.gps_y = 0;
+        startAvoidGpsInsVector.push_back(gps_ins);
+        avoidMinDistanceVector.push_back(0);
+    }
+}
+
+
+
+#include <QTime>
+
+void iv::decition::DecideGps00::computeObsOnRoad(iv::LidarGridPtr lidarGridPtr, std::vector<Point2D> gpsTrace, int roadNum,
+                                                 const std::vector<GPSData> gpsMapLine, std::vector<iv::Perception::PerceptionOutput> lidar_per) {
+
+    //    QTime xTime;
+    //   xTime.start();
+    //    qDebug("time 0 is %d ",xTime.elapsed());
+    double obs,obsSd;
+    if (lidarGridPtr == NULL)
+    {
+        lidarDistance = lastLidarDis;
+        //	lidarDistance = lastlidarDistance;
+
+    }
+    else {
+        obsPoint = Compute00().getLidarObsPoint(gpsTrace, lidarGridPtr);
+        float lidarXiuZheng=0;
+        if(!ServiceCarStatus.useMobileEye){
+            lidarXiuZheng=0-ServiceCarStatus.msysparam.frontGpsXiuzheng;
+        }
+        lidarDistance = obsPoint.y + lidarXiuZheng;   //激光距离推到车头  gjw20191110 lidar
+        //    lidarDistance=-1;
+        if (lidarDistance<0)
+        {
+            lidarDistance = -1;
+        }
+        lastLidarDis = lidarDistance;
+    }
+
+
+   // obsPredict start
+    if(ServiceCarStatus.useObsPredict){
+        float preObsDis=200;
+        if(!lidar_per.empty()){
+                 preObsDis=PredictObsDistance(  secSpeed,  gpsTrace, lidar_per);
+                lastPreObsDistance=preObsDis;
+            }else{
+                preObsDis=lastPreObsDistance;
+            }
+            if(preObsDis<lidarDistance || lidarDistance==-1){
+                lidarDistance=preObsDis;
+            }
+    }
+    // obsPredict end
+
+    //    qDebug("time 1 is %d ",xTime.elapsed());
+    //    if(gpsMapLine[PathPoint]->roadMode==14||gpsMapLine[PathPoint]->roadMode==15){
+    //        lidarDistance=-1;
+    //    }
+
+    getEsrObsDistance(gpsTrace, roadNum);
+
+    //   qDebug("time 2 is %d ",xTime.elapsed());
+    //  esrDistance=-1;
+
+    //    if(PathPoint>2992 && PathPoint<4134){
+    //        lidarDistance=-1;
+    //    }
+
+
+    //    if(PathPoint>10193 && PathPoint<10929){
+    //        esrDistance=-1;
+    //    }
+
+
+    if(lidarDistance<0){
+        lidarDistance=500;
+    }
+    if(esrDistance>30){
+        esrDistance=500;
+    }
+
+
+
+    if(esrDistance<0){
+        esrDistance=500;
+    }
+
+
+    std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "激光雷达距离:" << lidarDistance << std::endl;
+
+
+    //        if(esrDistance>30){
+    //            esrDistance=-1;
+    //        }
+
+
+
+    //            if(esrDistance>=15 && esrDistance<=50&& ServiceCarStatus.mLidarS>0&&ServiceCarStatus.mLidarPer>0 ){
+    //                if(abs(lidarDistance-esrDistance)>5){
+
+    //                    esrDistance=-1;
+    //                }
+
+    //            }
+
+
+
+    //            if(esrDistance>=1&& esrDistance<=50&& ServiceCarStatus.mLidarS>0&&ServiceCarStatus.mLidarPer>0
+    //                && gpsMapLine[PathPoint]->runMode == 1    ){
+    //                if(abs(lidarDistance-esrDistance)>5){
+
+    //                    esrDistance=-1;
+    //                }
+
+    //            }
+
+
+
+    std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "毫米波距离:" << esrDistance << std::endl;
+    myesrDistance = esrDistance;
+
+
+
+    if(lidarDistance==500){
+        lidarDistance=-1;
+    }
+    if(esrDistance==500){
+        esrDistance=-1;
+    }
+
+
+    ServiceCarStatus.mRadarObs = esrDistance;
+    ServiceCarStatus.mLidarObs = lidarDistance;
+
+
+    //zhuanwan pingbi haomibo
+    if(gpsTraceNow[0].v1==4||gpsTraceNow[0].v1==5){
+        esrDistance=-1;
+    }
+
+    if (esrDistance>0 && lidarDistance > 0)
+    {
+        if (lidarDistance >= esrDistance)
+        {
+            //	obsDistance = esrDistance;
+            obs = esrDistance;
+            //	obsSpeed = ServiceCarStatus.obs_radar[esrIndex].speed_y;
+            obsSd=ServiceCarStatus.obs_radar[esrIndex].speed_y;
+        }
+        else if (!ServiceCarStatus.obs_radar.empty())
+        {
+            //	obsDistance = lidarDistance;
+            obs = lidarDistance;
+            //	obsSpeed = Compute00().getObsSpeed(obsPoint, secSpeed);
+            obsSd = Compute00().getObsSpeed(obsPoint, secSpeed);
+            std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "计算obsSpeed:" << obsSpeed << std::endl;
+        }
+        else
+        {
+            //	obsDistance = lidarDistance;
+            obs=lidarDistance;
+            //	obsSpeed = 0 - secSpeed;
+            obsSd = 0 -secSpeed;
+            std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "毫米波无数据,计算obsSpeed:" << obsSpeed << std::endl;
+        }
+    }
+    else if (esrDistance>0)
+    {
+        //		obsDistance = esrDistance;
+        //		obsSpeed = ServiceCarStatus.obs_radar[esrIndex].speed_y;
+        obs = esrDistance;
+        obsSd = ServiceCarStatus.obs_radar[esrIndex].speed_y;
+    }
+    else if (lidarDistance > 0)
+    {
+        //		obsDistance = lidarDistance;
+        //		obsSpeed = Compute00().getObsSpeed(obsPoint, secSpeed);
+        obs = lidarDistance;
+        obsSd = Compute00().getObsSpeed(obsPoint, secSpeed);
+        std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "计算obsSpeed:" << obsSpeed << std::endl;
+    }
+    else {
+        //		obsDistance = esrDistance;
+        //		obsSpeed = 0 - secSpeed;
+        obs = esrDistance;
+        obsSd = 0 - secSpeed;
+    }
+
+    if(roadNum==roadNow){
+        obsDistance=obs;
+        obsSpeed=obsSd;
+    }
+
+
+    //    if (obsDistance <0 && obsLostTime<4)
+    //    {
+    //        obsDistance = lastDistance;
+    //        obsLostTime++;
+    //    }
+    //    else
+    //    {
+    //        obsLostTime = 0;
+    //        lastDistance = -1;
+    //    }
+
+
+    std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "最终得出的obsDistance:" << obsDistance << std::endl;
+
+    ServiceCarStatus.mObs = obsDistance;
+    if(ServiceCarStatus.mObs>100){
+        ServiceCarStatus.mObs =-1;
+    }
+
+    if (obsDistance>0)
+    {
+        lastDistance = obsDistance;
+    }
+
+    //lsn
+    if(obs<0){
+        obsDisVector[roadNum]=500;
+    }else{
+        obsDisVector[roadNum]=obs;
+    }
+
+    //   qDebug("time 3 is %d ",xTime.elapsed());
+
+}
+
+
+
+
+//1220
+void iv::decition::DecideGps00::computeRearObsOnRoad(iv::LidarGridPtr lidarGridPtr, std::vector<Point2D> gpsTrace, int roadNum,
+                                                     const std::vector<GPSData> gpsMapLine) {
+
+    double obs,obsSd;
+
+    if(!ServiceCarStatus.obs_rear_radar.empty()){
+        getRearEsrObsDistance(gpsTrace, roadNum);
+    }
+    if (lidarGridPtr == NULL)
+    {
+        lidarDistance = lastLidarDis;
+        //	lidarDistance = lastlidarDistance;
+
+    }
+    else {
+        obsPoint = Compute00().getLidarRearObsPoint(gpsTrace, lidarGridPtr);
+        float lidarXiuZheng=0;
+        if(!ServiceCarStatus.useMobileEye){
+            lidarXiuZheng = ServiceCarStatus.msysparam.rearGpsXiuzheng;
+        }
+        if(abs(obsPoint.y)>lidarXiuZheng)
+            lidarDistance = abs(obsPoint.y)-lidarXiuZheng;   //激光距离推到车头 1220
+
+        //    lidarDistance=-1;
+        if (lidarDistance<0)
+        {
+            lidarDistance = -1;
+        }
+        lastLidarDis = lidarDistance;
+    }
+
+    //    if(gpsMapLine[PathPoint]->roadMode==14||gpsMapLine[PathPoint]->roadMode==15){
+    //        lidarDistance=-1;
+    //    }
+
+    //  getEsrObsDistance(gpsTrace, roadNum);
+    esrDistance=-1;
+
+
+    //    if(PathPoint>2992 && PathPoint<4134){
+    //        lidarDistance=-1;
+    //    }
+
+
+    //    if(PathPoint>10193 && PathPoint<10929){
+    //        esrDistance=-1;
+    //    }
+
+
+    if(lidarDistance<0){
+        lidarDistance=500;
+    }
+    if(esrDistance<0){
+        esrDistance=500;
+    }
+
+
+    std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "激光雷达距离:" << lidarDistance << std::endl;
+
+
+    //        if(esrDistance>30){
+    //            esrDistance=-1;
+    //        }
+
+
+
+    //            if(esrDistance>=15 && esrDistance<=50&& ServiceCarStatus.mLidarS>0&&ServiceCarStatus.mLidarPer>0 ){
+    //                if(abs(lidarDistance-esrDistance)>5){
+
+    //                    esrDistance=-1;
+    //                }
+
+    //            }
+
+
+
+    //            if(esrDistance>=1&& esrDistance<=50&& ServiceCarStatus.mLidarS>0&&ServiceCarStatus.mLidarPer>0
+    //                && gpsMapLine[PathPoint]->runMode == 1    ){
+    //                if(abs(lidarDistance-esrDistance)>5){
+
+    //                    esrDistance=-1;
+    //                }
+
+    //            }
+
+
+
+    std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "毫米波距离:" << esrDistance << std::endl;
+    myesrDistance = esrDistance;
+
+
+
+    if(lidarDistance==500){
+        lidarDistance=-1;
+    }
+    if(esrDistance==500){
+        esrDistance=-1;
+    }
+
+
+    ServiceCarStatus.mRadarObs = esrDistance;
+    ServiceCarStatus.mLidarObs = lidarDistance;
+
+
+    //zhuanwan pingbi haomibo
+    if(gpsTraceNow[0].v1==4||gpsTraceNow[0].v1==5){
+        esrDistance=-1;
+    }
+
+    if (esrDistance>0 && lidarDistance > 0)
+    {
+        if (lidarDistance >= esrDistance)
+        {
+            //	obsDistance = esrDistance;
+            obs = esrDistance;
+            //	obsSpeed = ServiceCarStatus.obs_radar[esrIndex].speed_y;
+            obsSd=ServiceCarStatus.obs_radar[esrIndex].speed_y;
+        }
+        else if (!ServiceCarStatus.obs_radar.empty())
+        {
+            //	obsDistance = lidarDistance;
+            obs = lidarDistance;
+            //	obsSpeed = Compute00().getObsSpeed(obsPoint, secSpeed);
+            obsSd = Compute00().getObsSpeed(obsPoint, secSpeed);
+            std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "计算obsSpeed:" << obsSpeed << std::endl;
+        }
+        else
+        {
+            //	obsDistance = lidarDistance;
+            obs=lidarDistance;
+            //	obsSpeed = 0 - secSpeed;
+            obsSd = 0 -secSpeed;
+            std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "毫米波无数据,计算obsSpeed:" << obsSpeed << std::endl;
+        }
+    }
+    else if (esrDistance>0)
+    {
+        //		obsDistance = esrDistance;
+        //		obsSpeed = ServiceCarStatus.obs_radar[esrIndex].speed_y;
+        obs = esrDistance;
+        obsSd = ServiceCarStatus.obs_radar[esrIndex].speed_y;
+    }
+    else if (lidarDistance > 0)
+    {
+        //		obsDistance = lidarDistance;
+        //		obsSpeed = Compute00().getObsSpeed(obsPoint, secSpeed);
+        obs = lidarDistance;
+        obsSd = Compute00().getObsSpeed(obsPoint, secSpeed);
+        std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "计算obsSpeed:" << obsSpeed << std::endl;
+    }
+    else {
+        //		obsDistance = esrDistance;
+        //		obsSpeed = 0 - secSpeed;
+        obs = esrDistance;
+        obsSd = 0 - secSpeed;
+    }
+
+    if(roadNum==roadNow){
+        obsDistance=obs;
+        obsSpeed=obsSd;
+    }
+
+
+    if (obsDistance <0 && obsLostTime<4)
+    {
+        obsDistance = lastDistance;
+        obsLostTime++;
+    }
+    else
+    {
+        obsLostTime = 0;
+        lastDistance = -1;
+    }
+
+
+    std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "最终得出的obsDistance:" << obsDistance << std::endl;
+
+    ServiceCarStatus.mObs = obsDistance;
+    if(ServiceCarStatus.mObs>100){
+        ServiceCarStatus.mObs =-1;
+    }
+
+    if (obsDistance>0)
+    {
+        lastDistance = obsDistance;
+    }
+
+    //lsn
+    if(obs<0){
+        obsDisVector[roadNum]=500;
+    }else{
+        obsDisVector[roadNum]=obs;
+    }
+
+}
+
+
+
+void iv::decition::DecideGps00::predictObsOnRoad(std::vector<iv::Perception::PerceptionOutput> lidar_per,std::vector<Point2D> gpsTrace,double realSpeed){
+    double preObsDis;
+
+    if(!lidar_per.empty()){
+        preObsDis=PredictObsDistance(  realSpeed,  gpsTrace, lidar_per);
+        lastPreObsDistance=preObsDis;
+
+    }else{
+        preObsDis=lastPreObsDistance;
+    }
+    if(preObsDis<obsDistance){
+        obsDistance=preObsDis;
+        lastDistance=obsDistance;
+    }
+}
+
+int iv::decition::DecideGps00::chooseAvoidRoad(iv::LidarGridPtr lidarGridPtr, GPS_INS now_gps_ins, const std::vector<GPSData> gpsMapLine,std::vector<iv::Perception::PerceptionOutput> lidar_per) {
+    roadPre = -1;
+
+    if (roadNow<roadOri)
+    {
+        for (int i = 0; i < roadNow; i++)
+        {
+            gpsTraceAvoid.clear();
+            //	gpsTraceAvoid = getGpsTrace(now_gps_ins, gmapsR[int(abs(roadWidth * 2)*(roadOri-i))], lastGpsIndex);
+            avoidX = (roadWidth)*(roadOri - i);
+            gpsTraceAvoid = getGpsTraceOffset(gpsTraceOri, avoidX);
+            //	computeObsOnRoad(lidarGridPtr, gpsTraceAvoid, roadNow + i);
+            computeObsOnRoad(lidarGridPtr, gpsTraceNow, roadNow,gpsMapLine,lidar_per);
+        }
+
+
+        for (int i = roadOri+1; i < roadSum; i++)
+        {
+            gpsTraceAvoid.clear();
+            //	gpsTraceAvoid = getGpsTrace(now_gps_ins, gmapsL[int(abs(roadWidth * 2)*(i - roadOri))], lastGpsIndex);
+            avoidX = (roadWidth)*(roadOri - i);
+            gpsTraceAvoid = getGpsTraceOffset(gpsTraceOri, avoidX);
+            //	bsOnRoad(lidarGridPtr, gpsTraceAvoid, roadNow + i);
+            computeObsOnRoad(lidarGridPtr, gpsTraceAvoid, i,gpsMapLine,lidar_per);
+        }
+    }
+    else if (roadNow>roadOri)
+    {
+        for (int i = 0; i < roadOri; i++)
+        {
+            gpsTraceAvoid.clear();
+            //	gpsTraceAvoid = getGpsTrace(now_gps_ins, gmapsR[int(abs(roadWidth * 2)*(roadOri - i))], lastGpsIndex);
+            avoidX = (roadWidth)*(roadOri - i);
+            gpsTraceAvoid = getGpsTraceOffset(gpsTraceOri, avoidX);
+            //	computeObsOnRoad(lidarGridPtr, gpsTraceAvoid, roadNow + i);
+           computeObsOnRoad(lidarGridPtr, gpsTraceNow, roadNow,gpsMapLine,lidar_per);
+        }
+        for (int i = roadNow + 1; i < roadSum; i++)
+        {
+            gpsTraceAvoid.clear();
+            //		gpsTraceAvoid = getGpsTrace(now_gps_ins, gmapsL[int(abs(roadWidth * 2)*(i - roadOri))], lastGpsIndex);
+            avoidX = (roadWidth)*(roadOri - i);
+            gpsTraceAvoid = getGpsTraceOffset(gpsTraceOri, avoidX);
+            //	computeObsOnRoad(lidarGridPtr, gpsTraceAvoid, roadNow + i);
+           computeObsOnRoad(lidarGridPtr, gpsTraceNow, roadNow,gpsMapLine,lidar_per);
+        }
+
+    }
+
+    else
+    {
+        for (int i = 0; i < roadOri; i++)
+        {
+            gpsTraceAvoid.clear();
+            //	gpsTraceAvoid = getGpsTrace(now_gps_ins, gmapsR[int(abs(roadWidth * 2)*(roadOri - i))], lastGpsIndex);
+            avoidX = (roadWidth)*(roadOri - i);
+            gpsTraceAvoid = getGpsTraceOffset(gpsTraceOri, avoidX);
+            //	computeObsOnRoad(lidarGridPtr, gpsTraceAvoid, roadNow + i);
+           computeObsOnRoad(lidarGridPtr, gpsTraceNow, roadNow,gpsMapLine,lidar_per);
+        }
+        for (int i = roadOri + 1; i < roadSum; i++)
+        {
+            gpsTraceAvoid.clear();
+            //		gpsTraceAvoid = getGpsTrace(now_gps_ins, gmapsL[int(abs(roadWidth * 2)*(i - roadOri))], lastGpsIndex);
+            avoidX = (roadWidth)*(roadOri - i);
+            gpsTraceAvoid = getGpsTraceOffset(gpsTraceOri, avoidX);
+            //	computeObsOnRoad(lidarGridPtr, gpsTraceAvoid, roadNow + i);
+           computeObsOnRoad(lidarGridPtr, gpsTraceNow, roadNow,gpsMapLine,lidar_per);
+        }
+
+    }
+
+    if (lidarGridPtr!=NULL)
+    {
+        hasCheckedAvoidLidar = true;
+    }
+
+    for(int i=0; i<roadSum;i++){
+        std::cout<<"\odsjuli====================:\n"<<i<<"chedaojuli:"<<obsDisVector[i]<<endl;
+
+    }
+
+    checkAvoidObsTimes++;
+    if (checkAvoidObsTimes<4 || hasCheckedAvoidLidar==false)
+    {
+        return - 1;
+    }
+
+
+    for (int i = 1; i < roadSum; i++)
+    {
+        if (roadNow + i < roadSum) {
+            avoidX = (roadOri-roadNow-i)*roadWidth;
+            if (checkAvoidEnable(avoidX, lidarGridPtr, roadNow+i))
+            {
+                /*if (roadNow==roadOri)
+                {
+                    avoidRunDistance = obsDisVector[roadNow] + Veh_Lenth;
+                    startAvoid_gps_ins = now_gps_ins;
+                }	*/
+                avoidMinDistanceVector[roadNow]= obsDisVector[roadNow] + Veh_Lenth;
+                startAvoidGpsInsVector[roadNow] = now_gps_ins;
+                roadPre = roadNow + i;
+                return roadPre;
+            }
+        }
+
+        if (roadNow - i >= 0)
+        {
+            avoidX = (roadOri - roadNow+i)*roadWidth;
+            if (checkAvoidEnable(avoidX, lidarGridPtr, roadNow - i))
+            {
+                /*if (roadNow == roadOri)
+                {
+                    avoidRunDistance = obsDisVector[roadNow] + Veh_Lenth;
+                    startAvoid_gps_ins = now_gps_ins;
+                }*/
+                avoidMinDistanceVector[roadNow] = obsDisVector[roadNow] + Veh_Lenth;
+                startAvoidGpsInsVector[roadNow] = now_gps_ins;
+                roadPre = roadNow - i;
+                return roadPre;
+            }
+        }
+
+    }
+    return roadPre;
+}
+
+int iv::decition::DecideGps00::chooseBackRoad(iv::LidarGridPtr lidarGridPtr, GPS_INS now_gps_ins, std::vector<GPSData> gpsMapLine,std::vector<iv::Perception::PerceptionOutput> lidar_per) {
+    roadPre = -1;
+
+    computeObsOnRoad(lidarGridPtr, gpsTraceNow, roadNow,gpsMapLine,lidar_per);
+
+
+
+    if (roadNow>roadOri+1)
+    {
+        for (int i = roadOri+1; i < roadNow; i++)
+        {
+            gpsTraceBack.clear();
+            //	gpsTraceBack = getGpsTrace(now_gps_ins, gmapsL[int(abs(roadWidth * 2)*(i-roadOri))], lastGpsIndex);
+            avoidX = (roadWidth)*(roadOri - i);
+            gpsTraceBack = getGpsTraceOffset(gpsTraceOri, avoidX);
+            computeObsOnRoad(lidarGridPtr, gpsTraceNow, roadNow,gpsMapLine,lidar_per);
+        }
+    }
+    else if (roadNow < roadOri - 1) {
+
+        for (int i = roadOri - 1; i > roadNow; i--)
+        {
+            gpsTraceBack.clear();
+            //	gpsTraceBack = getGpsTrace(now_gps_ins, gmapsR[int(abs(roadWidth * 2)*(roadOri-i))], lastGpsIndex);
+            avoidX = (roadWidth)*(roadOri - i);
+            gpsTraceBack = getGpsTraceOffset(gpsTraceOri, avoidX);
+            computeObsOnRoad(lidarGridPtr, gpsTraceNow, roadNow,gpsMapLine,lidar_per);
+        }
+
+    }
+
+
+
+    if (lidarGridPtr != NULL)
+    {
+        hasCheckedBackLidar = true;
+    }
+
+
+
+    checkBackObsTimes++;
+    if (checkBackObsTimes<4 || hasCheckedBackLidar == false)
+    {
+        return -1;
+    }
+
+
+
+
+
+
+
+    //if ((GetDistance(now_gps_ins, startAvoid_gps_ins)>avoidRunDistance)&&
+    //(checkReturnEnable(avoidX, lidarGridPtr,roadOri)))
+    if ((GetDistance(now_gps_ins, startAvoidGpsInsVector[roadOri])>max(avoidMinDistanceVector[roadOri],30.0)) &&
+            (checkReturnEnable(avoidX, lidarGridPtr, roadOri)))
+    {
+        roadPre = roadOri;
+        return roadPre;
+    }
+
+    if (roadNow-roadOri>1)
+    {
+        for (int i = roadOri + 1;i < roadNow;i++) {
+            if (checkReturnEnable(avoidX, lidarGridPtr, i)&&
+                    (GetDistance(now_gps_ins, startAvoidGpsInsVector[i])>  avoidMinDistanceVector[i])&&
+                    (GetDistance(now_gps_ins, startAvoidGpsInsVector[i])> 30.0))
+            {
+                roadPre = i;
+                return roadPre;
+            }
+        }
+    }
+
+    else if (roadNow <roadOri-1)
+    {
+        for (int i = roadOri - 1;i > roadNow;i--) {
+            if (checkReturnEnable(avoidX, lidarGridPtr, i)&&
+                    (GetDistance(now_gps_ins, startAvoidGpsInsVector[i])>avoidMinDistanceVector[i])&&
+                    (GetDistance(now_gps_ins, startAvoidGpsInsVector[i])>  30.0))
+            {
+                roadPre = i;
+                return roadPre;
+            }
+        }
+    }
+
+    return roadPre;
+}
+
+
+double iv::decition::DecideGps00::trumpet() {
+    if (trumpetFirstCount)
+    {
+        trumpetFirstCount = false;
+        trumpetLastTime= GetTickCount();
+        trumpetTimeSpan = 0.0;
+    }
+    else
+    {
+        trumpetStartTime= GetTickCount();
+        trumpetTimeSpan += trumpetStartTime - trumpetLastTime;
+        trumpetLastTime = trumpetStartTime;
+    }
+
+    return trumpetTimeSpan;
+}
+
+
+
+
+double iv::decition::DecideGps00::transferP() {
+    if (transferFirstCount)
+    {
+        transferFirstCount = false;
+        transferLastTime= GetTickCount();
+        transferTimeSpan = 0.0;
+    }
+    else
+    {
+        transferStartTime= GetTickCount();
+        transferTimeSpan += transferStartTime - transferLastTime;
+        transferLastTime = transferStartTime;
+    }
+
+    return transferTimeSpan;
+}
+
+
+
+void  iv::decition::DecideGps00::handBrakePark(iv::decition::Decition  decition, long duringTime, GPS_INS now_gps_ins) {
+
+    if (abs(now_gps_ins.speed)>0.1)
+    {
+        decition->accelerator = 0;
+        decition->brake = 20;
+        decition->wheel_angle = 0;
+
+    }
+    else
+    {
+
+        decition->accelerator = 0;
+        decition->brake = 20;
+        decition->wheel_angle = 0;
+        handPark = true;
+        handParkTime = duringTime;
+    }
+
+}
+
+
+
+
+void iv::decition::DecideGps00::getMapBeside(std::vector<iv::GPSData> navigation_data, iv::GPS_INS now_gps_ins) {
+    gmapsL.clear();
+    gmapsR.clear();
+    for (int i = 0; i < 31; i++)
+    {
+        std::vector<iv::GPSData> gpsMapLineBeside;
+        //	gpsMapLineBeside = iv::decition::ComputeUnit().getBesideGpsMapLine(*ServiceCarStatus.location, navigation_data, -0.5*i);
+        gpsMapLineBeside = iv::decition::Compute00().getBesideGpsMapLine(now_gps_ins, navigation_data, -0.5*i);
+
+        gmapsL.push_back(gpsMapLineBeside);
+    }
+
+
+    for (int i = 0; i < 31; i++)
+    {
+        std::vector<iv::GPSData> gpsMapLineBeside;
+        //		gpsMapLineBeside = iv::decition::ComputeUnit().getBesideGpsMapLine(*ServiceCarStatus.location, navigation_data, 0.5*i);
+        gpsMapLineBeside = iv::decition::Compute00().getBesideGpsMapLine(now_gps_ins, navigation_data, 0.5*i);
+
+        gmapsR.push_back(gpsMapLineBeside);
+    }
+
+}
+
+
+bool iv::decition::DecideGps00::checkChaoCheBack(iv::LidarGridPtr lidarGridPtr) {
+
+    if (lidarGridPtr == NULL)
+    {
+        return false;
+        //	lidarDistance = lastlidarDistance;
+
+    }
+    else {
+
+
+
+
+        obsPoint = Compute00().getLidarObsPoint(gpsTraceOri, lidarGridPtr);
+        double lidarDistance = obsPoint.y - 2.5;   //激光距离推到车头
+        //     ODS("\n超车雷达距离:%f\n", lidarDistance);
+        if (lidarDistance >-20 && lidarDistance<35)
+        {
+            checkChaoCheBackCounts = 0;
+            return false;
+        }
+        else {
+            checkChaoCheBackCounts++;
+        }
+
+        if (checkChaoCheBackCounts>2) {
+            checkChaoCheBackCounts = 0;
+            return true;
+        }
+    }
+
+    return false;
+
+}
+
+void iv::decition::DecideGps00::updateGroupDate(GPS_INS now_gps_ins,float realspeed,float theta,float s){
+    Point2D pt = Coordinate_Transfer( now_gps_ins.gps_x, now_gps_ins.gps_y, group_ori_gps);
+
+    ServiceCarStatus.group_x_local=pt.x;
+    //  ServiceCarStatus.group_y_local=pt.y;
+    ServiceCarStatus.group_y_local=s;
+    if(realspeed<0.36){
+        ServiceCarStatus.group_velx_local=0;
+        ServiceCarStatus.group_vely_local=0;
+    }else{
+        ServiceCarStatus.group_velx_local=realspeed*sin(theta)/3.6;
+        ServiceCarStatus.group_vely_local=realspeed*cos(theta)/3.6;
+    }
+
+
+    ServiceCarStatus.group_pathpoint=PathPoint;
+
+}
+
+
+
+float  iv::decition::DecideGps00::ComputeTrafficLightSpeed(int traffic_light_color, int traffic_light_time,  const std::vector<GPSData> gpsMapLine,int traffic_light_pathpoint,
+                                                           int pathpoint,float secSpeed,float dSpeed){
+    float traffic_speed=200;
+    float traffic_dis=0;
+    float passTime;
+    float passSpeed;
+    bool passEnable=false;
+
+    if(abs(secSpeed)<0.1){
+        secSpeed=0;
+    }
+
+
+
+    if(pathpoint <= traffic_light_pathpoint){
+        for(int i=pathpoint;i<traffic_light_pathpoint;i++){
+            traffic_dis +=GetDistance(*gpsMapLine[i],*gpsMapLine[i+1]);
+        }
+    }else{
+        for(int i=pathpoint;i<gpsMapLine.size()-1;i++){
+            traffic_dis +=GetDistance(*gpsMapLine[i],*gpsMapLine[i+1]);
+        }
+        for(int i=0;i<traffic_light_pathpoint;i++){
+            traffic_dis+=GetDistance(*gpsMapLine[i],*gpsMapLine[i+1]);
+        }
+    }
+
+    //    if(traffic_light_color != 0)
+    //    {
+    //        int a = 3;
+    //    }
+
+
+    if(traffic_light_color==0 && traffic_dis<10){
+        traffic_speed=0;
+    }
+    //    else   //20200108
+    //    {
+    //        traffic_speed=10;
+    //    }
+    return  traffic_speed;
+
+    passSpeed = min((float)(dSpeed/3.6),secSpeed);
+    passTime = traffic_dis/(dSpeed/3.6);
+
+
+
+
+
+    switch(traffic_light_color){
+    case 0:
+        if(passTime>traffic_light_time+1 && traffic_dis>10){
+            passEnable=true;
+        }else{
+            passEnable=false;
+        }
+        break;
+    case 1:
+        if(passTime<traffic_light_time-1 && traffic_dis<10){
+            passEnable=true;
+        }else{
+            passEnable = false;
+        }
+        break;
+    case 2:
+        if(passTime<traffic_light_time){
+            passEnable= true;
+        }else{
+            passEnable=false;
+        }
+        break;
+
+
+    default:
+        break;
+    }
+
+    if(!passEnable){
+        if(traffic_dis<5){
+            traffic_speed=0;
+        }else if(traffic_dis<10){
+            traffic_speed=5;
+        }else if(traffic_dis<20){
+            traffic_speed=15;
+        }else if(traffic_dis<30){
+            traffic_speed=25;
+        }else if(traffic_dis<50){
+            traffic_speed=30;
+        }
+    }
+    return traffic_speed;
+
+}
+
+void iv::decition::DecideGps00::computeObsOnRoadByFrenet(iv::LidarGridPtr lidarGridPtr, const std::vector<Point2D>& gpsTrace, double & obs, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps)
+{
+    //    Point2D obsCombinePoint = Point2D(-1,-1);
+    iv::decition::FrenetPoint car_now_frenet_point = iv::decition::FrenetPlanner::getFrenetfromXY(0,0,gpsTrace,gpsMap,pathpoint,nowGps);
+    double obsSd;
+    if (lidarGridPtr == NULL)
+    {
+        lidarDistance = lastLidarDis;
+        //	lidarDistance = lastlidarDistance;
+    }
+    else {
+        obsPoint = Compute00().getLidarObsPoint(gpsTrace, lidarGridPtr);
+        //        lidarDistance = obsPoint.y-2.5;   //激光距离推到车头
+        iv::decition::FrenetPoint lidarFPointTmp = iv::decition::FrenetPlanner::getFrenetfromXY(this->obsPoint.x,this->obsPoint.y,gpsTrace,gpsMap,pathpoint,nowGps);
+        lidarDistance = lidarFPointTmp.s - car_now_frenet_point.s - 2.5;
+
+        //    lidarDistance=-1;
+        if (lidarDistance<0)
+        {
+            lidarDistance = -1;
+        }
+        lastLidarDis = lidarDistance;
+    }
+
+    FrenetPoint esr_obs_frenet_point;
+    getEsrObsDistanceByFrenet(gpsTrace, car_now_frenet_point,esr_obs_frenet_point,gpsMap,pathpoint,nowGps);
+
+    if(lidarDistance<0){
+        lidarDistance=500;
+    }
+    if(esrDistance<0){
+        esrDistance=500;
+    }
+
+    std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "激光雷达距离:" << lidarDistance << std::endl;
+
+    std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "毫米波距离:" << esrDistance << std::endl;
+    myesrDistance = esrDistance;
+
+    if(lidarDistance==500){
+        lidarDistance=-1;
+    }
+    if(esrDistance==500){
+        esrDistance=-1;
+    }
+
+    ServiceCarStatus.mRadarObs = esrDistance;
+    ServiceCarStatus.mLidarObs = lidarDistance;
+
+    //    //zhuanwan pingbi haomibo
+    //    if(gpsTraceNow[0].v1==4||gpsTraceNow[0].v1==5){
+    //        esrDistance=-1;
+    //    }
+
+    if (esrDistance>0 && lidarDistance > 0)
+    {
+        if (lidarDistance >= esrDistance)
+        {
+            obs = esrDistance;
+            //            obsSd=ServiceCarStatus.obs_radar[esrIndex].speed_y;
+            obsSd = obsSpeed;
+            //障碍物信息使用毫米波采集的。其位置坐标加上偏移量,转换成相对于惯导的位置,即转换成车辆坐标系下的位置坐标。
+            //            obsCombinePoint = Point2D(ServiceCarStatus.obs_radar[esrIndex].nomal_x+Esr_Offset,ServiceCarStatus.obs_radar[esrIndex].nomal_y+Esr_Y_Offset);
+        }
+        else if (!ServiceCarStatus.obs_radar.empty())
+        {
+            obs = lidarDistance;
+            //            obsCombinePoint = obsPoint;
+            //            obsSd = Compute00().getObsSpeedByFrenet(obsPoint, secSpeed,gpsTrace);
+            obsSd = Compute00().getObsSpeedByFrenet(obsPoint, secSpeed,gpsTrace,gpsMap,pathpoint,nowGps);
+            std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "计算obsSpeed:" << obsSpeed << std::endl;
+        }
+        else
+        {
+            obs=lidarDistance;
+            //            obsCombinePoint = obsPoint;
+            obsSd = 0 -secSpeed*cos(car_now_frenet_point.tangent_Ang-PI/2);
+            std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "毫米波无数据,计算obsSpeed:" << obsSpeed << std::endl;
+        }
+    }
+    else if (esrDistance>0)
+    {
+        obs = esrDistance;
+        //        obsSd = ServiceCarStatus.obs_radar[esrIndex].speed_y;
+        obsSd = obsSpeed;
+        //障碍物信息使用毫米波采集的。其位置坐标加上偏移量,转换成相对于惯导的位置,即转换成车辆坐标系下的位置坐标。
+        //        obsCombinePoint = Point2D(ServiceCarStatus.obs_radar[esrIndex].nomal_x+Esr_Offset,ServiceCarStatus.obs_radar[esrIndex].nomal_y+Esr_Y_Offset);
+    }
+    else if (lidarDistance > 0)
+    {
+        obs = lidarDistance;
+        //        obsCombinePoint = obsPoint;
+        obsSd = Compute00().getObsSpeedByFrenet(obsPoint, secSpeed,gpsTrace,gpsMap,pathpoint,nowGps);
+        std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "计算obsSpeed:" << obsSpeed << std::endl;
+    }
+    else {
+        obs = esrDistance;
+        //        obsCombinePoint = Point2D(ServiceCarStatus.obs_radar[esrIndex].nomal_x+Esr_Offset,ServiceCarStatus.obs_radar[esrIndex].nomal_y+Esr_Y_Offset);
+        obsSd = 0 - secSpeed*cos(car_now_frenet_point.tangent_Ang-PI/2);
+    }
+
+    obsDistance=obs;
+    obsSpeed=obsSd;
+
+    std::cout <<ServiceCarStatus.mRunTime.elapsed()<<"ms:"<< "最终得出的obsDistance:" << obsDistance << std::endl;
+
+    ServiceCarStatus.mObs = obsDistance;
+    if(ServiceCarStatus.mObs>100){
+        ServiceCarStatus.mObs =-1;
+    }
+
+    if (obsDistance>0)
+    {
+        lastDistance = obsDistance;
+    }
+
+    if(obs<0){
+        obsDistance=500;
+    }else{
+        obsDistance=obs;
+    }
+}
+
+void iv::decition::DecideGps00::getRearEsrObsDistance(std::vector<Point2D> gpsTrace, int roadNum) {
+
+
+    esrIndex = iv::decition::Compute00().getRearEsrIndex(gpsTrace, roadNum);
+
+    if (esrIndex != -1)
+    {
+        esrDistance = ServiceCarStatus.obs_rear_radar[esrIndex].nomal_y;
+        obsSpeed = ServiceCarStatus.obs_rear_radar[esrIndex].speed_y;
+
+    }
+    else {
+        esrDistance = -1;
+    }
+}
+
+void iv::decition::DecideGps00::getEsrObsDistanceByFrenet(const std::vector<Point2D>& gpsTrace, const FrenetPoint car_now_frenet_point, FrenetPoint &esrObs_F_Point, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps) {
+
+    esrIndex = iv::decition::Compute00().getEsrIndexByFrenet(gpsTrace,esrObs_F_Point,gpsMap,pathpoint,nowGps);
+
+    if (esrIndex != -1)
+    {
+        //障碍物的距离,是障碍物和车辆沿道路上的距离,即s。并不直接是它的x坐标或y坐标或两点直线坐标。
+        //严格来说应是 esrDistance=障碍物的s - 车辆的s - Esr_Y_Offset,但这是根据车辆位置实时搜索路径,故车辆的s极其小。
+        esrDistance = esrObs_F_Point.s - car_now_frenet_point.s - Esr_Y_Offset;  //-Esr_Y_Offset是把距离推到车头,换算frenet坐标时,把它加上了的。故需减去。
+
+        double speedx=ServiceCarStatus.obs_radar[esrIndex].speed_x;  //障碍物相对于车辆x轴的速度
+        double speedy=ServiceCarStatus.obs_radar[esrIndex].speed_y;  //障碍物相对于车辆y轴的速度
+        double speed_combine = sqrt(speedx*speedx+speedy*speedy);    //将x、y轴两个方向的速度求矢量和
+        //障碍物的速度方向与道路方向的夹角。用于将速度分解到s方向和d方向。
+        //所谓道路方向是指,道路上离障碍物的最近的点沿道路弧线的切线方向。
+        double Etheta = esrObs_F_Point.tangent_Ang - atan2(speedy,speedx);
+
+        obsSpeed = speed_combine*cos(Etheta);  //由speed_combine分解的s轴方向上的速度
+    }
+    else {
+        esrDistance = -1;
+    }
+}
+
+void iv::decition::DecideGps00::getV2XTrafficPositionVector(const std::vector<GPSData> gpsMapLine){
+    v2xTrafficVector.clear();
+    for (int var = 0; var < gpsMapLine.size(); var++) {
+        if(gpsMapLine[var]->roadMode==6){
+            v2xTrafficVector.push_back(var);
+        }
+    }
+}
+
+float iv::decition::DecideGps00::ComputeV2XTrafficLightSpeed(iv::TrafficLight trafficLight, const std::vector<GPSData> gpsMapLine,std::vector<int> v2xTrafficVector,
+                                                             int pathpoint,float secSpeed,float dSpeed, bool circleMode){
+    float trafficSpeed=200;
+    int nearTraffixPoint=-1;
+    float nearTrafficDis=0;
+    int traffic_color=0;
+    int traffic_time=0;
+    bool passThrough=false;
+    float dSecSpeed=dSpeed/3.6;
+
+    if(v2xTrafficVector.empty()){
+        return trafficSpeed;
+    }
+    if(!circleMode){
+        if(pathpoint>v2xTrafficVector.back()){
+            return trafficSpeed;
+        }else {
+            for(int i=0; i< v2xTrafficVector.size();i++){
+                if (pathpoint<= v2xTrafficVector[i]){
+                    nearTraffixPoint=v2xTrafficVector[i];
+                    break;
+                }
+            }
+        }
+    }else if(circleMode){
+        if(pathpoint>v2xTrafficVector.back()){
+            nearTraffixPoint=v2xTrafficVector[0];
+        }else {
+            for(int i=0; i< v2xTrafficVector.size();i++){
+                if (pathpoint<= v2xTrafficVector[i]){
+                    nearTraffixPoint=v2xTrafficVector[i];
+                    break;
+                }
+            }
+        }
+    }
+
+
+    if(nearTraffixPoint!=-1){
+        for(int i=pathpoint;i<nearTraffixPoint;i++){
+            nearTrafficDis +=GetDistance(*gpsMapLine[i],*gpsMapLine[i+1]);
+        }
+    }
+
+    if(nearTrafficDis>50){
+        return trafficSpeed;
+    }
+
+
+    int roadMode = gpsMapLine[pathpoint]->roadMode;
+    if(roadMode==14 || roadMode==16){
+        traffic_color=trafficLight.leftColor;
+        traffic_time=trafficLight.leftTime;
+    }else if(roadMode==15 ||roadMode==17){
+        traffic_color=trafficLight.rightColor;
+        traffic_time=trafficLight.rightTime;
+    }else {
+        traffic_color=trafficLight.straightColor;
+        traffic_time=trafficLight.straightTime;
+    }
+
+
+    passThrough=computeTrafficPass(nearTrafficDis,traffic_color,traffic_time,secSpeed,dSecSpeed);
+    if(passThrough){
+        return trafficSpeed;
+    }else{
+        trafficSpeed=computeTrafficSpeedLimt(nearTrafficDis);
+        if(nearTrafficDis<6){
+            float decelerate =0-( secSpeed*secSpeed*0.5/nearTrafficDis);
+            minDecelerate=min(minDecelerate,decelerate);
+        }
+        return trafficSpeed;
+    }
+
+    return trafficSpeed;
+}
+
+bool iv::decition::DecideGps00::computeTrafficPass(float trafficDis,int trafficColor,float trafficTime,float realSecSpeed,float dSecSpeed){
+    float passTime=0;
+    if (trafficColor==2 || trafficColor==3){
+        return false;
+    }else if(trafficColor==0){
+        return true;
+    }else{
+        passTime=trafficDis/dSecSpeed;
+        if(passTime+1< trafficTime){
+            return true;
+        }else{
+            return false;
+        }
+
+    }
+
+}
+
+float iv::decition::DecideGps00::computeTrafficSpeedLimt(float trafficDis){
+    float limit=200;
+    if(trafficDis<10){
+        limit = 0;
+    }else if(trafficDis<15){
+        limit = 5;
+    }else if(trafficDis<20){
+        limit=10;
+    }else if(trafficDis<30){
+        limit=15;
+    }
+    return limit;
+}
+
+void iv::decition::DecideGps00::adjuseGpsLidarPosition(){
+
+    ServiceCarStatus.msysparam.lidarGpsXiuzheng -=  ServiceCarStatus.msysparam.gpsOffset_y;
+    ServiceCarStatus.msysparam.radarGpsXiuzheng -=  ServiceCarStatus.msysparam.gpsOffset_y;
+    ServiceCarStatus.msysparam.rearRadarGpsXiuzheng +=  ServiceCarStatus.msysparam.gpsOffset_y;
+    ServiceCarStatus.msysparam.rearLidarGpsXiuzheng +=  ServiceCarStatus.msysparam.gpsOffset_y;
+    ServiceCarStatus.msysparam.frontGpsXiuzheng -=  ServiceCarStatus.msysparam.gpsOffset_y;
+    ServiceCarStatus.msysparam.rearGpsXiuzheng +=  ServiceCarStatus.msysparam.gpsOffset_y;
+}

+ 249 - 249
src/decition/decition_brain/decition/decide_gps_00.h

@@ -1,249 +1,249 @@
-#pragma once
-#ifndef _IV_DECITION__DECIDE_GPS_00_
-#define _IV_DECITION__DECIDE_GPS_00_
-
-#include <common/gps_type.h>
-#include <decition/decition_type.h>
-#include <common/obstacle_type.h>
-#include <vector>
-#include <decition/adc_tools/gnss_coordinate_convert.h>
-#include <decition/adc_planner/frenet_planner.h>
-#include<decition/adc_controller/pid_controller.h>
-#include <decition/adc_adapter/ge3_adapter.h>
-#include <decition/adc_adapter/qingyuan_adapter.h>
-#include <decition/adc_adapter/vv7_adapter.h>
-#include <decition/adc_adapter/zhongche_adapter.h>
-#include <decition/adc_adapter/bus_adapter.h>
-#include <decition/adc_adapter/hapo_adapter.h>
-#include "perception/perceptionoutput.h"
-#include "ivlog.h"
-#include <memory>
-
-namespace iv {
-namespace decition {
-//根据传感器传输来的信息作出决策
-class DecideGps00 {
-public:
-    DecideGps00();
-    ~DecideGps00();
-
-    static double minDis;
-    static double maxAngle;
-    static int lastGpsIndex;
-    static double lidarDistance;
-    static double myesrDistance;
-    static double lastLidarDis;
-    static double lastLidarDisAvoid;
-
-    static double lastPreObsDistance;
-
-    static int gpsLineParkIndex;
-    static int gpsMapParkIndex;
-
-    static double lastDistance;
-
-    static float xiuzhengCs;
-
-    static double controlAng;
-    double laneAng;
-    static double controlSpeed;
-    static double controlBrake;
-
-    static bool parkMode;
-    static bool readyParkMode;
-
-    static bool zhucheMode;
-    static bool readyZhucheMode;
-    static bool hasZhuched;
-    static double Iv;
-    static double lastEv;
-    static double lastVt;
-    static double lastU;
-    static double obsDistance;
-    static double obsSpeed;
-    static double lidarDistanceAvoid;
-    static double obsDistanceAvoid;
-    static double lastDistanceAvoid;
-
-    GPS_INS group_ori_gps;
-    GPS_INS startAvoid_gps_ins;
-    static int finishPointNum;
-    static int zhuchePointNum;
-    double avoidRunDistance=0;
-
-    std::vector<iv::GPS_INS> startAvoidGpsInsVector;
-    std::vector<double> avoidMinDistanceVector;
-    std::vector<int> v2xTrafficVector;
-
-    ///kkcai, 2020-01-03
-    //bool isFirstRun = true;
-    static bool isFirstRun;
-    /////////////////////////////////////
-
-//    static bool startingFlag;//起步标志,在起步时需要进行frenet规划。
-    static float minDecelerate;
-
-
-    double startTime = 0;
-    double firstTime = 0;
-
-    bool circleMode=false;
-
-    int avoidTimes = 0;
-    int backTimes = 0;
-
-    int checkAvoidObsTimes = 0;
-    int checkBackObsTimes = 0;
-
-    bool hasCheckedAvoidLidar=false;
-    bool hasCheckedBackLidar=false;
-
-    bool personWaited = false;
-    bool roadLightWaited = false;
-
-    double decision_Angle = 0;
-    double lastAngle=0;
-
-    iv::Point2D obsPoint;
-
-    int checkAvoidTimes=0;
-    int checkBackTimes=0;
-    int chaocheCounts=0;
-
-    static int PathPoint;
-    float lastGroupOffsetX=0.0;
-
-    GPS_INS traffic_light_gps;
-    int traffic_light_pathpoint;
-
-    bool changingDangWei=false;
-
-    BaseController *pid_Controller;
-    BaseAdapter *ge3_Adapter;
-    BaseAdapter *qingyuan_Adapter;
-    BaseAdapter *vv7_Adapter;
-    BaseAdapter *zhongche_Adapter;
-    BaseAdapter *bus_Adapter;
-    BaseAdapter *hapo_Adapter;
-
-    std::shared_ptr<BaseController> mpid_Controller;
-    std::shared_ptr<BaseAdapter> mge3_Adapter;
-    std::shared_ptr<BaseAdapter> mqingyuan_Adapter;
-    std::shared_ptr<BaseAdapter> mvv7_Adapter;
-    std::shared_ptr<BaseAdapter> mzhongche_Adapter;
-    std::shared_ptr<BaseAdapter> mbus_Adapter;
-    std::shared_ptr<BaseAdapter> mhapo_Adapter;
-
-
-	FrenetPlanner *frenetPlanner;
-//    BasePlanner *laneChangePlanner;
-	
-	std::shared_ptr<FrenetPlanner> mfrenetPlanner;
-//    std::shared_ptr<BasePlanner> mlaneChangePlanner;
-
-
-    Decition getDecideFromGPS(GPS_INS gpsIns, const std::vector<GPSData> navigation_data, iv::LidarGridPtr lidarGridPtr,
-                              std::vector<iv::Perception::PerceptionOutput> lidar_per,iv::TrafficLight trafficLight);
-
-    void initMethods();
-    static std::vector<Point2D> getGpsTrace(GPS_INS rp, const std::vector<GPSData> gpsMap, int lastIndex, bool circleMode);
-
-
-    static double getAngle(std::vector<Point2D> gpsTrace);
-    double getAngle(std::vector<Point2D> gpsTrace, GPS_INS gpsIns,iv::decition::Decition decition);
-    static double getSpeed(std::vector<Point2D> gpsTrace);
-
-    static void getEsrObsDistance(std::vector<Point2D> gpsTrace, int roadNum);
-    static void getRearEsrObsDistance(std::vector<Point2D> gpsTrace, int roadNum);
-    static void getEsrObsDistanceAvoid();
-
-    void getObsAvoid(iv::LidarGridPtr lidarGridPtr);
-    void phaseSpeedDecition(iv::decition::Decition decition, double secSpeed, double obsDis, double obsSpeed, GPS_INS gpsIns );
-
-    double limitAngle(double speed, double angle);
-    double limitSpeed(double angle, double speed);
-
-    bool checkAvoidEnable(double avoidX, iv::LidarGridPtr lidarGridPtr, int roadNum);
-    bool checkReturnEnable(double avoidX, iv::LidarGridPtr lidarGridPtr, int roadNum);
-
-    void computeObsOnRoad(iv::LidarGridPtr lidarGridPtr, std::vector<Point2D> gpsTrace, int roadNum,const std::vector<GPSData> gpsMapLine, std::vector<iv::Perception::PerceptionOutput> lidar_per);
-    static void getEsrObsDistanceByFrenet(const std::vector<Point2D>& gpsTrace, iv::decition::FrenetPoint car_now_frenet_point,iv::decition::FrenetPoint &esrObs_F_Point, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps);
-
-    void computeRearObsOnRoad(iv::LidarGridPtr lidarGridPtr, std::vector<Point2D> gpsTrace, int roadNum,const std::vector<GPSData> gpsMapLine);
-    void computeObsOnRoadByFrenet(iv::LidarGridPtr lidarGridPtr,const std::vector<Point2D>& gpsTrace, double & obs, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps);
-
-    void predictObsOnRoad(std::vector<iv::Perception::PerceptionOutput> lidar_per,std::vector<Point2D> gpsTrace,double realSpeed);
-
-    int chooseAvoidRoad(iv::LidarGridPtr lidarGridPtr, GPS_INS now_gps_ins,std::vector<GPSData> gpsMapLine,std::vector<iv::Perception::PerceptionOutput> lidar_per);
-    int chooseBackRoad(iv::LidarGridPtr lidarGridPtr, GPS_INS now_gps_ins, std::vector<GPSData> gpsMapLine,std::vector<iv::Perception::PerceptionOutput> lidar_per);
-
-    void getMapBeside(std::vector<iv::GPSData> navigation_data, iv::GPS_INS now_gps_ins);
-
-    void  handBrakePark(iv::decition::Decition  decition, long duringTime, GPS_INS now_gps_ins);
-
-    bool checkChaoCheBack(iv::LidarGridPtr);
-    double trumpet();
-    double transferP();
-
-    bool nearStation;
-
-    void updateGroupDate(GPS_INS now_gps_ins,float realspeed,float theta,float s);
-    void init();
-
-    std::vector<Point2D>  getGpsTraceOffset(std::vector<Point2D> gpsTrace, double offset);
-
-    std::vector<iv::Point2D> getGpsTraceBackExa(iv::GPS_INS now_gps_ins, const std::vector<GPSData> gpsMapLine, int pathpo);
-
-    float ComputeTrafficLightSpeed(int traffic_light_color, int traffic_light_time,  const std::vector<GPSData> gpsMapLine,int traffic_light_pathpoint,
-                                   int pathpoint,float secSpeed,float dSpeed);
-    void getV2XTrafficPositionVector( const std::vector<GPSData> gpsMapLine);
-    float ComputeV2XTrafficLightSpeed(iv::TrafficLight TrafficLight, const std::vector<GPSData> gpsMapLine,std::vector<int> v2xTrafficVector,
-                                   int pathpoint,float secSpeed,float dSpeed,bool circleMode);
-    float getTrafficLightSpeed(int traffic_light_color, int traffic_light_time, float dis);
-
-    bool computeTrafficPass(float trafficDis,int trafficColor,float trafficTime,float realSecSpeed,float dSecSpeed);
-    float computeTrafficSpeedLimt(float trafficDis);
-    void adjuseGpsLidarPosition();
-
-    GPS_INS aim_gps_ins;
-    GPS_INS chaoche_start_gps;
-    bool is_arrivaled=false;
-
-    double chaocheObsDis = 0;
-    double preChaocheDis = 0;
-    double aimObsSpeed = 0;
-    double followSpeed = 30;
-    double chaocheSpeed = 50;
-    int checkChaoCheBackCounts = 0;
-
-    float lastTorque=0;
-    float splimit=-1;
-
-    float  ObsTimeSpan=-1;
-    double ObsTimeStart=-1;
-    double ObsTimeEnd=-1;
-    float ObsTimeWidth=1500;
-    std::vector<iv::Point2D> planTrace;
-private:
-    //  void changeRoad(int roadNum);
-
-
-};
-
-}
-}
-
-extern bool handPark;
-extern long handParkTime;
-extern bool rapidStop;
-extern int gpsMissCount;
-extern bool changeRoad;
-extern double avoidX;
-extern bool parkBesideRoad;
-extern double steerSpeed;
-extern bool transferPieriod;
-extern bool transferPieriod2;
-extern double traceDevi;
-#endif // !  _IV_DECITION__DECIDE_GPS_00_
-
-
+#pragma once
+#ifndef _IV_DECITION__DECIDE_GPS_00_
+#define _IV_DECITION__DECIDE_GPS_00_
+
+#include <common/gps_type.h>
+#include <decition/decition_type.h>
+#include <common/obstacle_type.h>
+#include <vector>
+#include <decition/adc_tools/gnss_coordinate_convert.h>
+#include <decition/adc_planner/frenet_planner.h>
+#include<decition/adc_controller/pid_controller.h>
+#include <decition/adc_adapter/ge3_adapter.h>
+#include <decition/adc_adapter/qingyuan_adapter.h>
+#include <decition/adc_adapter/vv7_adapter.h>
+#include <decition/adc_adapter/zhongche_adapter.h>
+#include <decition/adc_adapter/bus_adapter.h>
+#include <decition/adc_adapter/hapo_adapter.h>
+#include "perception/perceptionoutput.h"
+#include "ivlog.h"
+#include <memory>
+
+namespace iv {
+namespace decition {
+//根据传感器传输来的信息作出决策
+class DecideGps00 {
+public:
+    DecideGps00();
+    ~DecideGps00();
+
+    static double minDis;
+    static double maxAngle;
+    static int lastGpsIndex;
+    static double lidarDistance;
+    static double myesrDistance;
+    static double lastLidarDis;
+    static double lastLidarDisAvoid;
+
+    static double lastPreObsDistance;
+
+    static int gpsLineParkIndex;
+    static int gpsMapParkIndex;
+
+    static double lastDistance;
+
+    static float xiuzhengCs;
+
+    static double controlAng;
+    double laneAng;
+    static double controlSpeed;
+    static double controlBrake;
+
+    static bool parkMode;
+    static bool readyParkMode;
+
+    static bool zhucheMode;
+    static bool readyZhucheMode;
+    static bool hasZhuched;
+    static double Iv;
+    static double lastEv;
+    static double lastVt;
+    static double lastU;
+    static double obsDistance;
+    static double obsSpeed;
+    static double lidarDistanceAvoid;
+    static double obsDistanceAvoid;
+    static double lastDistanceAvoid;
+
+    GPS_INS group_ori_gps;
+    GPS_INS startAvoid_gps_ins;
+    static int finishPointNum;
+    static int zhuchePointNum;
+    double avoidRunDistance=0;
+
+    std::vector<iv::GPS_INS> startAvoidGpsInsVector;
+    std::vector<double> avoidMinDistanceVector;
+    std::vector<int> v2xTrafficVector;
+
+    ///kkcai, 2020-01-03
+    //bool isFirstRun = true;
+    static bool isFirstRun;
+    /////////////////////////////////////
+
+//    static bool startingFlag;//起步标志,在起步时需要进行frenet规划。
+    static float minDecelerate;
+
+
+    double startTime = 0;
+    double firstTime = 0;
+
+    bool circleMode=false;
+
+    int avoidTimes = 0;
+    int backTimes = 0;
+
+    int checkAvoidObsTimes = 0;
+    int checkBackObsTimes = 0;
+
+    bool hasCheckedAvoidLidar=false;
+    bool hasCheckedBackLidar=false;
+
+    bool personWaited = false;
+    bool roadLightWaited = false;
+
+    double decision_Angle = 0;
+    double lastAngle=0;
+
+    iv::Point2D obsPoint;
+
+    int checkAvoidTimes=0;
+    int checkBackTimes=0;
+    int chaocheCounts=0;
+
+    static int PathPoint;
+    float lastGroupOffsetX=0.0;
+
+    GPS_INS traffic_light_gps;
+    int traffic_light_pathpoint;
+
+    bool changingDangWei=false;
+
+    BaseController *pid_Controller;
+    BaseAdapter *ge3_Adapter;
+    BaseAdapter *qingyuan_Adapter;
+    BaseAdapter *vv7_Adapter;
+    BaseAdapter *zhongche_Adapter;
+    BaseAdapter *bus_Adapter;
+    BaseAdapter *hapo_Adapter;
+
+    std::shared_ptr<BaseController> mpid_Controller;
+    std::shared_ptr<BaseAdapter> mge3_Adapter;
+    std::shared_ptr<BaseAdapter> mqingyuan_Adapter;
+    std::shared_ptr<BaseAdapter> mvv7_Adapter;
+    std::shared_ptr<BaseAdapter> mzhongche_Adapter;
+    std::shared_ptr<BaseAdapter> mbus_Adapter;
+    std::shared_ptr<BaseAdapter> mhapo_Adapter;
+
+
+	FrenetPlanner *frenetPlanner;
+//    BasePlanner *laneChangePlanner;
+	
+	std::shared_ptr<FrenetPlanner> mfrenetPlanner;
+//    std::shared_ptr<BasePlanner> mlaneChangePlanner;
+
+
+    Decition getDecideFromGPS(GPS_INS gpsIns, const std::vector<GPSData> navigation_data, iv::LidarGridPtr lidarGridPtr,
+                              std::vector<iv::Perception::PerceptionOutput> lidar_per,iv::TrafficLight trafficLight);
+
+    void initMethods();
+    static std::vector<Point2D> getGpsTrace(GPS_INS rp, const std::vector<GPSData> gpsMap, int lastIndex, bool circleMode);
+
+
+    static double getAngle(std::vector<Point2D> gpsTrace);
+    double getAngle(std::vector<Point2D> gpsTrace, GPS_INS gpsIns,iv::decition::Decition decition);
+    static double getSpeed(std::vector<Point2D> gpsTrace);
+
+    static void getEsrObsDistance(std::vector<Point2D> gpsTrace, int roadNum);
+    static void getRearEsrObsDistance(std::vector<Point2D> gpsTrace, int roadNum);
+    static void getEsrObsDistanceAvoid();
+
+    void getObsAvoid(iv::LidarGridPtr lidarGridPtr);
+    void phaseSpeedDecition(iv::decition::Decition decition, double secSpeed, double obsDis, double obsSpeed, GPS_INS gpsIns );
+
+    double limitAngle(double speed, double angle);
+    double limitSpeed(double angle, double speed);
+
+    bool checkAvoidEnable(double avoidX, iv::LidarGridPtr lidarGridPtr, int roadNum);
+    bool checkReturnEnable(double avoidX, iv::LidarGridPtr lidarGridPtr, int roadNum);
+
+    void computeObsOnRoad(iv::LidarGridPtr lidarGridPtr, std::vector<Point2D> gpsTrace, int roadNum,const std::vector<GPSData> gpsMapLine, std::vector<iv::Perception::PerceptionOutput> lidar_per);
+    static void getEsrObsDistanceByFrenet(const std::vector<Point2D>& gpsTrace, iv::decition::FrenetPoint car_now_frenet_point,iv::decition::FrenetPoint &esrObs_F_Point, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps);
+
+    void computeRearObsOnRoad(iv::LidarGridPtr lidarGridPtr, std::vector<Point2D> gpsTrace, int roadNum,const std::vector<GPSData> gpsMapLine);
+    void computeObsOnRoadByFrenet(iv::LidarGridPtr lidarGridPtr,const std::vector<Point2D>& gpsTrace, double & obs, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps);
+
+    void predictObsOnRoad(std::vector<iv::Perception::PerceptionOutput> lidar_per,std::vector<Point2D> gpsTrace,double realSpeed);
+
+    int chooseAvoidRoad(iv::LidarGridPtr lidarGridPtr, GPS_INS now_gps_ins,std::vector<GPSData> gpsMapLine,std::vector<iv::Perception::PerceptionOutput> lidar_per);
+    int chooseBackRoad(iv::LidarGridPtr lidarGridPtr, GPS_INS now_gps_ins, std::vector<GPSData> gpsMapLine,std::vector<iv::Perception::PerceptionOutput> lidar_per);
+
+    void getMapBeside(std::vector<iv::GPSData> navigation_data, iv::GPS_INS now_gps_ins);
+
+    void  handBrakePark(iv::decition::Decition  decition, long duringTime, GPS_INS now_gps_ins);
+
+    bool checkChaoCheBack(iv::LidarGridPtr);
+    double trumpet();
+    double transferP();
+
+    bool nearStation;
+
+    void updateGroupDate(GPS_INS now_gps_ins,float realspeed,float theta,float s);
+    void init();
+
+    std::vector<Point2D>  getGpsTraceOffset(std::vector<Point2D> gpsTrace, double offset);
+
+    std::vector<iv::Point2D> getGpsTraceBackExa(iv::GPS_INS now_gps_ins, const std::vector<GPSData> gpsMapLine, int pathpo);
+
+    float ComputeTrafficLightSpeed(int traffic_light_color, int traffic_light_time,  const std::vector<GPSData> gpsMapLine,int traffic_light_pathpoint,
+                                   int pathpoint,float secSpeed,float dSpeed);
+    void getV2XTrafficPositionVector( const std::vector<GPSData> gpsMapLine);
+    float ComputeV2XTrafficLightSpeed(iv::TrafficLight TrafficLight, const std::vector<GPSData> gpsMapLine,std::vector<int> v2xTrafficVector,
+                                   int pathpoint,float secSpeed,float dSpeed,bool circleMode);
+    float getTrafficLightSpeed(int traffic_light_color, int traffic_light_time, float dis);
+
+    bool computeTrafficPass(float trafficDis,int trafficColor,float trafficTime,float realSecSpeed,float dSecSpeed);
+    float computeTrafficSpeedLimt(float trafficDis);
+    void adjuseGpsLidarPosition();
+
+    GPS_INS aim_gps_ins;
+    GPS_INS chaoche_start_gps;
+    bool is_arrivaled=false;
+
+    double chaocheObsDis = 0;
+    double preChaocheDis = 0;
+    double aimObsSpeed = 0;
+    double followSpeed = 30;
+    double chaocheSpeed = 50;
+    int checkChaoCheBackCounts = 0;
+
+    float lastTorque=0;
+    float splimit=-1;
+
+    float  ObsTimeSpan=-1;
+    double ObsTimeStart=-1;
+    double ObsTimeEnd=-1;
+    float ObsTimeWidth=1500;
+    std::vector<iv::Point2D> planTrace;
+private:
+    //  void changeRoad(int roadNum);
+
+
+};
+
+}
+}
+
+extern bool handPark;
+extern long handParkTime;
+extern bool rapidStop;
+extern int gpsMissCount;
+extern bool changeRoad;
+extern double avoidX;
+extern bool parkBesideRoad;
+extern double steerSpeed;
+extern bool transferPieriod;
+extern bool transferPieriod2;
+extern double traceDevi;
+#endif // !  _IV_DECITION__DECIDE_GPS_00_
+
+

+ 252 - 252
src/decition/decition_brain/decition/decide_line_00.h

@@ -1,252 +1,252 @@
-#pragma once
-#ifndef _IV_DECITION__DECIDE_LINE_00_
-#define _IV_DECITION__DECIDE_LINE_00_
-
-#include <common/gps_type.h>
-#include <decition/decition_type.h>
-#include <common/obstacle_type.h>
-#include<vector> 
-#include <decition/gnss_coordinate_convert.h>
-#include <decition/decide_gps_00.h>
-
-
-
-namespace iv {
-	namespace decition {
-		//根据传感器传输来的信息作出决策
-        class DecideLine00 {
-		public:
-            DecideLine00();
-            ~DecideLine00();
-
-			static  double minDis;
-			static double maxAngle;
-			static   int lastGpsIndex;
-			static double lidarDistance;
-            static double myesrDistance;
-			static double lastLidarDis;
-			static double lastLidarDisAvoid;
-
-			
-			
-
-			static  int gpsLineParkIndex;
-			static  int gpsMapParkIndex;
-
-
-			static double lastDistance;
-
-		
-
-			
-
-
-
-			static double controlAng;
-			static double controlSpeed;
-			static double controlBrake;
-
-			static bool parkMode;
-			static bool readyParkMode;
-
-			static bool zhucheMode;
-			static bool readyZhucheMode;
-			static bool hasZhuched;
-			static double Iv;
-			static double lastEv;
-			static double lastVt;
-			static double lastU;
-			static double obsDistance;
-			static double lidarDistanceAvoid;
-			static double obsDistanceAvoid;
-			static double lastDistanceAvoid;
-
-			GPS_INS startAvoid_gps_ins;
-			static int finishPointNum;
-			static int zhuchePointNum;
-			double avoidRunDistance=0;
-
-			std::vector<iv::GPS_INS> startAvoidGpsInsVector;
-			std::vector<double> avoidMinDistanceVector;
-
-
-			bool isFirstRun = true;
-			double startTime = 0;
-			double firstTime = 0;
-
-			int avoidTimes = 0;
-			int backTimes = 0;
-
-			int checkAvoidObsTimes = 0;
-			int checkBackObsTimes = 0;
-
-			bool hasCheckedAvoidLidar=false;
-			bool hasCheckedBackLidar=false;
-
-			bool personWaited = false;
-			bool roadLightWaited = false;
-
-			double decision_Angle = 0;
-            double lastAngle=0;
-
-			iv::Point2D obsPoint;
-
-			int checkAvoidTimes=0;
-			int checkBackTimes=0;
-
-			 static int PathPoint;
-//             float dSpeed=0;
-//             float dSecSpeed=0;
-
-			//		Decition getDecideFromGPS(GPS_INS gpsIns, const std::vector<GPSData> navigation_data, std::vector<ObstacleBasic> obsRadars, iv::LidarGridPtr lidarGridPtr);
-
-            Decition getDecideFromGPS(GPS_INS gpsIns, const std::vector<GPSData> navigation_data, iv::LidarGridPtr lidarGridPtr,std::vector<iv::Perception::PerceptionOutput> lidar_per);
-
-			static std::vector<Point2D> getGpsTrace(GPS_INS rp, const std::vector<GPSData> gpsMap, int lastIndex);
-             std::vector<Point2D> getGpsTraceByMobileEye(float a,float b, float c);
-		
-
-			static double getAngle(std::vector<Point2D> gpsTrace);
-			static double getSpeed(std::vector<Point2D> gpsTrace);
-
-			//		static void getEsrObs(std::vector<iv::ObstacleBasic> obsRadars);
-			static void getEsrObsDistance(std::vector<Point2D> gpsTrace, int roadNum);
-			static void getEsrObsDistanceAvoid();
-
-			void getObsAvoid(iv::LidarGridPtr lidarGridPtr);
-
-            void phaseSpeedDecition(iv::decition::Decition decition, double secSpeed, double obsDistance, double obsSpeed, GPS_INS gpsIns );
-
-			double limitAngle(double speed, double angle);
-			double limitSpeed(double angle, double speed);
-
-			bool checkAvoidEnable(double avoidX, iv::LidarGridPtr lidarGridPtr, int roadNum);
-			bool checkReturnEnable(double avoidX, iv::LidarGridPtr lidarGridPtr, int roadNum);
-
-			void computeObsOnRoad(iv::LidarGridPtr lidarGridPtr, std::vector<Point2D> gpsTrace, int roadNum);
-
-			int chooseAvoidRoad(iv::LidarGridPtr lidarGridPtr, GPS_INS now_gps_ins);
-			int chooseBackRoad(iv::LidarGridPtr lidarGridPtr, GPS_INS now_gps_ins, std::vector<GPSData> gpsMapLine);
-			
-
-			void getMapBeside(std::vector<iv::GPSData> navigation_data, iv::GPS_INS now_gps_ins);
-
-			void  handBrakePark(iv::decition::Decition  decition, long duringTime, GPS_INS now_gps_ins);
-
-
-			double trumpet();
-
-			void init();
-
-			std::vector<Point2D>  getGpsTraceOffset(std::vector<Point2D> gpsTrace, double offset);
-
-			GPS_INS aim_gps_ins;
-			bool is_arrivaled=false;
-
-
-
-
-
-            double offset_real = 0;
-            double realspeed;
-            double dSpeed;
-            double dSecSpeed;
-            double secSpeed;
-            double ac;
-
-
-
-
-
-
-            int esrLineIndex = -1;
-            int esrIndexAvoid = -1;
-            double obsSpeed = 0;
-            double obsSpeedAvoid = 0;
-
-            double esrLineDistance = -1;
-            double esrDistanceAvoid = -1;
-            int obsLostTime = 0;
-            int obsLostTimeAvoid = 0;
-
-
-
-
-            // double avoidTime = 0;
-
-
-            double avoidX =0;
-            float roadWidth = 4;
-            int roadSum =4;
-            int roadNow = 3;
-            int roadOri =3;
-            int roadPre = -1;
-            int lastRoadOri = 3;
-
-            int lightTimes = 0;
-
-
-            int lastRoadNum=1;
-
-            int stopCount = 0;
-
-            int gpsMissCount = 0;
-
-            bool rapidStop = false;
-
-            bool hasTrumpeted = false;
-
-
-            bool changingDangWei=false;
-
-            //实验手刹
-            bool handFirst = true;
-            double handTimeSpan = 0;
-            double handStartTime = 0;
-            double handLastTime = 0;
-            bool handPark = false;
-            long handParkTime=10000;
-
-            //喇叭
-            bool trumpetFirstCount=true;
-            double trumpetTimeSpan = 0;
-            double trumpetStartTime = 0;
-            double trumpetLastTime = 0;
-
-            bool busMode = false;
-
-            enum VehState { normalRun, park, readyPark, stopObs, avoidObs, preAvoid, avoiding, backOri,preBack,
-                waitAvoid ,shoushaTest,justRun} vehState;
-
-
-
-            std::vector<iv::Point2D>  gpsTraceAvoid,gpsTraceNow,gpsTraceBack,gpsTracePre,gpsTraceOri;
-
-
-            float  outGarageDistance=0;
-            double outGarageTimeLast=-1;
-            double outGarageTimeNow=-1;
-            float outGarageLong=10;
-
-            double waitGpsTimeStart=-1;
-            double waitGpsTimeNow=-1;
-            float waitGpsTimeSpan=-1;
-            float waitGpsTimeWidth=5000;
-            bool waitGps=false;
-
-
-		private:
-               iv::decition::DecideGps00* decitionGpstool ;			//决策器
-               std::shared_ptr<DecideGps00> mdecitionGpstool;
-		};
-
-	}
-}
-
-extern bool handPark;
-extern long handParkTime;
-extern bool rapidStop;
-extern int gpsMissCount;
-#endif // !  _IV_DECITION__DECIDE_LINE_00_
-
-
+#pragma once
+#ifndef _IV_DECITION__DECIDE_LINE_00_
+#define _IV_DECITION__DECIDE_LINE_00_
+
+#include <common/gps_type.h>
+#include <decition/decition_type.h>
+#include <common/obstacle_type.h>
+#include<vector> 
+#include <decition/gnss_coordinate_convert.h>
+#include <decition/decide_gps_00.h>
+
+
+
+namespace iv {
+	namespace decition {
+		//根据传感器传输来的信息作出决策
+        class DecideLine00 {
+		public:
+            DecideLine00();
+            ~DecideLine00();
+
+			static  double minDis;
+			static double maxAngle;
+			static   int lastGpsIndex;
+			static double lidarDistance;
+            static double myesrDistance;
+			static double lastLidarDis;
+			static double lastLidarDisAvoid;
+
+			
+			
+
+			static  int gpsLineParkIndex;
+			static  int gpsMapParkIndex;
+
+
+			static double lastDistance;
+
+		
+
+			
+
+
+
+			static double controlAng;
+			static double controlSpeed;
+			static double controlBrake;
+
+			static bool parkMode;
+			static bool readyParkMode;
+
+			static bool zhucheMode;
+			static bool readyZhucheMode;
+			static bool hasZhuched;
+			static double Iv;
+			static double lastEv;
+			static double lastVt;
+			static double lastU;
+			static double obsDistance;
+			static double lidarDistanceAvoid;
+			static double obsDistanceAvoid;
+			static double lastDistanceAvoid;
+
+			GPS_INS startAvoid_gps_ins;
+			static int finishPointNum;
+			static int zhuchePointNum;
+			double avoidRunDistance=0;
+
+			std::vector<iv::GPS_INS> startAvoidGpsInsVector;
+			std::vector<double> avoidMinDistanceVector;
+
+
+			bool isFirstRun = true;
+			double startTime = 0;
+			double firstTime = 0;
+
+			int avoidTimes = 0;
+			int backTimes = 0;
+
+			int checkAvoidObsTimes = 0;
+			int checkBackObsTimes = 0;
+
+			bool hasCheckedAvoidLidar=false;
+			bool hasCheckedBackLidar=false;
+
+			bool personWaited = false;
+			bool roadLightWaited = false;
+
+			double decision_Angle = 0;
+            double lastAngle=0;
+
+			iv::Point2D obsPoint;
+
+			int checkAvoidTimes=0;
+			int checkBackTimes=0;
+
+			 static int PathPoint;
+//             float dSpeed=0;
+//             float dSecSpeed=0;
+
+			//		Decition getDecideFromGPS(GPS_INS gpsIns, const std::vector<GPSData> navigation_data, std::vector<ObstacleBasic> obsRadars, iv::LidarGridPtr lidarGridPtr);
+
+            Decition getDecideFromGPS(GPS_INS gpsIns, const std::vector<GPSData> navigation_data, iv::LidarGridPtr lidarGridPtr,std::vector<iv::Perception::PerceptionOutput> lidar_per);
+
+			static std::vector<Point2D> getGpsTrace(GPS_INS rp, const std::vector<GPSData> gpsMap, int lastIndex);
+             std::vector<Point2D> getGpsTraceByMobileEye(float a,float b, float c);
+		
+
+			static double getAngle(std::vector<Point2D> gpsTrace);
+			static double getSpeed(std::vector<Point2D> gpsTrace);
+
+			//		static void getEsrObs(std::vector<iv::ObstacleBasic> obsRadars);
+			static void getEsrObsDistance(std::vector<Point2D> gpsTrace, int roadNum);
+			static void getEsrObsDistanceAvoid();
+
+			void getObsAvoid(iv::LidarGridPtr lidarGridPtr);
+
+            void phaseSpeedDecition(iv::decition::Decition decition, double secSpeed, double obsDistance, double obsSpeed, GPS_INS gpsIns );
+
+			double limitAngle(double speed, double angle);
+			double limitSpeed(double angle, double speed);
+
+			bool checkAvoidEnable(double avoidX, iv::LidarGridPtr lidarGridPtr, int roadNum);
+			bool checkReturnEnable(double avoidX, iv::LidarGridPtr lidarGridPtr, int roadNum);
+
+			void computeObsOnRoad(iv::LidarGridPtr lidarGridPtr, std::vector<Point2D> gpsTrace, int roadNum);
+
+			int chooseAvoidRoad(iv::LidarGridPtr lidarGridPtr, GPS_INS now_gps_ins);
+			int chooseBackRoad(iv::LidarGridPtr lidarGridPtr, GPS_INS now_gps_ins, std::vector<GPSData> gpsMapLine);
+			
+
+			void getMapBeside(std::vector<iv::GPSData> navigation_data, iv::GPS_INS now_gps_ins);
+
+			void  handBrakePark(iv::decition::Decition  decition, long duringTime, GPS_INS now_gps_ins);
+
+
+			double trumpet();
+
+			void init();
+
+			std::vector<Point2D>  getGpsTraceOffset(std::vector<Point2D> gpsTrace, double offset);
+
+			GPS_INS aim_gps_ins;
+			bool is_arrivaled=false;
+
+
+
+
+
+            double offset_real = 0;
+            double realspeed;
+            double dSpeed;
+            double dSecSpeed;
+            double secSpeed;
+            double ac;
+
+
+
+
+
+
+            int esrLineIndex = -1;
+            int esrIndexAvoid = -1;
+            double obsSpeed = 0;
+            double obsSpeedAvoid = 0;
+
+            double esrLineDistance = -1;
+            double esrDistanceAvoid = -1;
+            int obsLostTime = 0;
+            int obsLostTimeAvoid = 0;
+
+
+
+
+            // double avoidTime = 0;
+
+
+            double avoidX =0;
+            float roadWidth = 4;
+            int roadSum =4;
+            int roadNow = 3;
+            int roadOri =3;
+            int roadPre = -1;
+            int lastRoadOri = 3;
+
+            int lightTimes = 0;
+
+
+            int lastRoadNum=1;
+
+            int stopCount = 0;
+
+            int gpsMissCount = 0;
+
+            bool rapidStop = false;
+
+            bool hasTrumpeted = false;
+
+
+            bool changingDangWei=false;
+
+            //实验手刹
+            bool handFirst = true;
+            double handTimeSpan = 0;
+            double handStartTime = 0;
+            double handLastTime = 0;
+            bool handPark = false;
+            long handParkTime=10000;
+
+            //喇叭
+            bool trumpetFirstCount=true;
+            double trumpetTimeSpan = 0;
+            double trumpetStartTime = 0;
+            double trumpetLastTime = 0;
+
+            bool busMode = false;
+
+            enum VehState { normalRun, park, readyPark, stopObs, avoidObs, preAvoid, avoiding, backOri,preBack,
+                waitAvoid ,shoushaTest,justRun} vehState;
+
+
+
+            std::vector<iv::Point2D>  gpsTraceAvoid,gpsTraceNow,gpsTraceBack,gpsTracePre,gpsTraceOri;
+
+
+            float  outGarageDistance=0;
+            double outGarageTimeLast=-1;
+            double outGarageTimeNow=-1;
+            float outGarageLong=10;
+
+            double waitGpsTimeStart=-1;
+            double waitGpsTimeNow=-1;
+            float waitGpsTimeSpan=-1;
+            float waitGpsTimeWidth=5000;
+            bool waitGps=false;
+
+
+		private:
+               iv::decition::DecideGps00* decitionGpstool ;			//决策器
+               std::shared_ptr<DecideGps00> mdecitionGpstool;
+		};
+
+	}
+}
+
+extern bool handPark;
+extern long handParkTime;
+extern bool rapidStop;
+extern int gpsMissCount;
+#endif // !  _IV_DECITION__DECIDE_LINE_00_
+
+

+ 979 - 979
src/decition/decition_brain/decition/decide_line_00_.cpp

@@ -1,979 +1,979 @@
-#include <decition/decide_line_00.h>
-#include <decition/compute_00.h>
-#include <decition/gps_distance.h>
-#include <decition/decition_type.h>
-#include <decition/transfer.h>
-#include <common/constants.h>
-#include <common/car_status.h>
-#include <math.h>
-#include <iostream>
-#include <fstream>
-#include <control/can.h>
-#include <time.h>
-using namespace std;
-
-#define PI (3.1415926535897932384626433832795)
-
-iv::decition::DecideLine00::DecideLine00() {
-      decitionGpstool = new iv::decition::DecideGps00();
-      mdecitionGpstool.reset(decitionGpstool);
-}
-iv::decition::DecideLine00::~DecideLine00() {
-
-}
-
-
-int iv::decition::DecideLine00::PathPoint = -1;
-double iv::decition::DecideLine00::minDis = iv::MaxValue;
-double iv::decition::DecideLine00::maxAngle = iv::MinValue;
-//int iv::decition::DecideLine00::lastGpsIndex = iv::MaxValue;
-int iv::decition::DecideLine00::lastGpsIndex = 0;
-double iv::decition::DecideLine00::controlSpeed = 0;
-double iv::decition::DecideLine00::controlBrake = 0;
-double iv::decition::DecideLine00::controlAng = 0;
-double iv::decition::DecideLine00::Iv = 0;
-double iv::decition::DecideLine00::lastU = 0;
-double iv::decition::DecideLine00::lastVt = 0;
-double iv::decition::DecideLine00::lastEv = 0;
-
-int iv::decition::DecideLine00::gpsLineParkIndex = 0;
-int iv::decition::DecideLine00::gpsMapParkIndex = 0;
-double iv::decition::DecideLine00::lastDistance = MaxValue;
-double iv::decition::DecideLine00::obsDistance = -1;
-double iv::decition::DecideLine00::obsDistanceAvoid = -1;
-double iv::decition::DecideLine00::lastDistanceAvoid = -1;
-
-double iv::decition::DecideLine00::lidarDistance = -1;
-double iv::decition::DecideLine00::myesrDistance = -1;
-double iv::decition::DecideLine00::lastLidarDis = -1;
-
-bool iv::decition::DecideLine00::parkMode = false;
-bool iv::decition::DecideLine00::readyParkMode = false;
-
-bool iv::decition::DecideLine00::zhucheMode = false;
-bool iv::decition::DecideLine00::readyZhucheMode = false;
-bool iv::decition::DecideLine00::hasZhuched = false;
-
-double iv::decition::DecideLine00::lastLidarDisAvoid = -1;
-double iv::decition::DecideLine00::lidarDistanceAvoid = -1;
-
-int iv::decition::DecideLine00::finishPointNum = 0;
-int iv::decition::DecideLine00::zhuchePointNum = 0;
-
-
-
-
-
-//日常展示
-
-iv::decition::Decition    iv::decition::DecideLine00::getDecideFromGPS(GPS_INS now_gps_ins, const std::vector<GPSData> gpsMapLine, iv::LidarGridPtr lidarGridPtr,
-                                                                       std::vector<iv::Perception::PerceptionOutput> lidar_per) {
-
-	Decition gps_decition(new DecitionBasic);
-
-
-	if (isFirstRun)
-	{
-		vehState = normalRun;	
-		startAvoid_gps_ins = now_gps_ins;
-
-
-		ServiceCarStatus.carState = 1;
-		/*roadOri = gpsMapLine[PathPoint]->roadOri;
-		roadNow = roadOri;*/
-		busMode = false;
-
-
-       waitGpsTimeWidth= ServiceCarStatus.waitGpsTimeWidth;
-        outGarageLong=ServiceCarStatus.outGarageLong;
-		isFirstRun = false;
-	}
-    busMode=ServiceCarStatus.busmode;
-    ServiceCarStatus.useMobileEye=true;
-	gps_decition->leftlamp = false;
-	gps_decition->rightlamp = false;
-
-	
-	is_arrivaled = false;
-	
-
-
-	
-
-
-	
-
-	if (parkMode)
-	{
-
-		
-		handBrakePark(gps_decition,10000,now_gps_ins);
-		return gps_decition;
-	}
-
-
-	//驻车
-
-	if (zhucheMode)
-	{
-
-		if (trumpet()<5000)
-		{
-			gps_decition->brake=20;
-			gps_decition->accelerator = 0;
-			gps_decition->wheel_angle = 0;
-			gps_decition->speed = 0;
-			return gps_decition;
-		}
-		else
-		{
-			hasZhuched = true;
-			zhucheMode = false;
-			trumpetFirstCount = true;
-		}
-
-	}
-
-
-	//判断驻车标志位
-	if (hasZhuched && GetDistance(now_gps_ins,*gpsMapLine[zhuchePointNum])>20)
-	{
-		hasZhuched = false;
-	}
-
-
-
-	obsDistance = -1;
-    esrLineIndex = -1;
-	lidarDistance = -1;
-
-
-	roadPre = -1;
-
-
-
-    //realspeed = now_gps_ins.speed;
-    realspeed = ServiceCarStatus.vehSpeed_st;
-	secSpeed = realspeed / 3.6;
-
-
-    std::cout << "\n#############realspeed:\n" <<  realspeed << std::endl;
-
-	avoidX = (roadOri-roadNow)*roadWidth;
-
-	gpsTraceOri.clear();
-	gpsTraceNow.clear();
-	gpsTraceAvoid.clear();
-	gpsTraceBack.clear();
-
-
-    gpsTraceOri=getGpsTraceByMobileEye(ServiceCarStatus.Lane.curvature,ServiceCarStatus.Lane.heading,
-                                       (ServiceCarStatus.aftermarketLane.dist_to_lane_l+ServiceCarStatus.aftermarketLane.dist_to_lane_r)*0.5);
-     controlAng = iv::decition::Compute00().getDecideAngleByLanePID(realspeed);
-  //  controlAng = iv::decition::Compute00().getDecideAngle(gpsTraceOri, realspeed);
-    if(outGarageTimeLast!=-1){
-        outGarageTimeNow=GetTickCount();
-    }
-    if(outGarageTimeNow!=-1){
-        outGarageDistance+= (outGarageTimeNow-outGarageTimeLast)*secSpeed*0.001;
-         std::cout << "使用mobileEye决策————outGarageDistance:"<<outGarageDistance<< std::endl;
-    }
-    if(outGarageDistance>outGarageLong && !waitGps){
-        waitGps=true;
-
-        outGarageTimeLast=-1;
-        outGarageTimeNow=-1;
-        outGarageDistance=0;
-
-
-    }
-
-    if(ServiceCarStatus.m_bOutGarage && !waitGps){
-        outGarageTimeLast=GetTickCount();
-    }
-
-    if(waitGps){
-         std::cout << "使用mobileEye决策————waitGps"<< std::endl;
-        if(waitGpsTimeStart==-1){
-            waitGpsTimeStart=GetTickCount();
-        }
-        if(waitGpsTimeStart!=-1){
-            waitGpsTimeNow=GetTickCount();
-        }
-        if(waitGpsTimeNow!=-1){
-            waitGpsTimeSpan=waitGpsTimeNow-waitGpsTimeStart;
-            std::cout << "使用mobileEye决策————waitGps————waitGpsTimeSpan:"<<waitGpsTimeSpan <<std::endl;
-        }
-        if(waitGpsTimeSpan>waitGpsTimeWidth){
-            waitGps=false;
-            waitGpsTimeStart=-1;
-            waitGpsTimeNow=-1;
-            waitGpsTimeSpan=0;
-             ServiceCarStatus.m_bOutGarage=false;
-               std::cout << "使用mobileEye决策————waitGps————退出"<< std::endl;
-        }
-
-        gps_decition->accelerator =0;
-        gps_decition->torque = 0;
-        gps_decition->brake=0.8;
-        gps_decition->wheel_angle = 0.0 - controlAng;
-        //           gps_decition->wheel_angle = 0;
-
-        return gps_decition;
-
-    }
-
-	
-
-
-
-	
-
-		
-
-  //  controlAng = iv::decition::Compute00().getDecideAngleByLane(realspeed);
-
-
-	if (readyParkMode)
-	{
-		double parkDis = GetDistance(now_gps_ins, *gpsMapLine[finishPointNum]);
-
-	
-		if (parkDis < 25)
-		{
-			Point2D pt = Coordinate_Transfer((*gpsMapLine[finishPointNum]).gps_x, (*gpsMapLine[finishPointNum]).gps_y, now_gps_ins);
-			double parkDistance = pt.y;
-
-
-			if (dSpeed > 15)
-			{
-				dSpeed = 15;
-			}
-
-
-			
-			if (parkDistance < 5 && parkDistance >= 4)
-			{
-                dSpeed = min(dSpeed, 8.0);
-			}
-
-
-
-			if (parkDistance < 1.5)
-			{
-				dSpeed = 0;
-				parkMode = true;
-				readyParkMode = false;
-			}
-
-
-		}
-	}
-
-
-
-	//准备驻车
-
-	if (readyZhucheMode)
-	{
-		double dis = GetDistance(*gpsMapLine[zhuchePointNum], now_gps_ins);
-
-		if (dis<25)
-		{
-			Point2D pt = Coordinate_Transfer((*gpsMapLine[zhuchePointNum]).gps_x, (*gpsMapLine[zhuchePointNum]).gps_y, now_gps_ins);
-			double zhucheDistance = pt.y;
-
-
-			if (dSpeed > 15)
-			{
-				dSpeed = 15;
-			}
-
-
-
-			if (zhucheDistance < 5 && zhucheDistance >= 4)
-			{
-                dSpeed = min(dSpeed, 8.0);
-			}
-
-
-
-			if (zhucheDistance < 3)
-			{
-				dSpeed = 0;
-				zhucheMode = true;
-				readyZhucheMode = false;
-			}
-
-		}
-		
-		
-
-	}
-
-
-
-
-
-    dSpeed=15;
-
-
-	//速度结合角度的限制
-	controlAng = limitAngle(realspeed, controlAng);
-	dSpeed = limitSpeed(controlAng, dSpeed);
-
-	gps_decition->speed = dSpeed;
-
-
-	dSecSpeed = dSpeed / 3.6;
-	//	 ac = 2 * max(10, realspeed) / ((dSecSpeed*dSecSpeed) - (secSpeed*secSpeed));
-
-
-
-
-
-	/* if (obsDistance <0 && ac<0 && ac >= -0.5)
-	{
-	gps_decition->accelerator = 0;
-	gps_decition->brake = 0;
-	}
-	else {*/
-
-	
-
-
-
-
-
-
-
-
-        std::cout << "\n呼车指令状态:%d\n" <<  ServiceCarStatus.carState << std::endl;
-		
-		//停车
-        if (ServiceCarStatus.carState == 0 && busMode)  //stop
-        {
-
-            gps_decition->accelerator =0;
-            gps_decition->torque = 0;
-            gps_decition->brake=0.5;
-            gps_decition->wheel_angle = 0.0 - controlAng;
-            //           gps_decition->wheel_angle = 0;
-
-            return gps_decition;
-
-        }
-
-
-
-        if (ServiceCarStatus.carState == 3 && busMode)   //  lin stop
-        {
-
-            ServiceCarStatus.carState=0;
-            gps_decition->accelerator = 0;
-            gps_decition->torque = 0;
-            gps_decition->brake=0.5;
-            gps_decition->wheel_angle = 0.0 - controlAng;
-            return gps_decition;
-
-
-        }
-
-
-
-
-
-
-
-        if (ServiceCarStatus.carState == 2 && busMode)  // dao zhan dian
-        {
-            dSpeed=3;
-        }
-
-
-
-
-                if (now_gps_ins.ins_status !=4 ) {
-
-                    dSpeed = min(15.0, dSpeed);
-
-                }
-
-
-        dSpeed=3;
-		dSecSpeed = dSpeed / 3.6;
-		gps_decition->speed = dSpeed;
-
-
-        decitionGpstool->computeObsOnRoad(lidarGridPtr,gpsTraceOri,0,gpsMapLine,lidar_per);
-
-        int confL=ServiceCarStatus.aftermarketLane.lane_conf_left;
-         int confR=ServiceCarStatus.aftermarketLane.lane_conf_right;
-         int conf=min(confL,confR);
-         if(conf<=1){
-
-         }
-
-        phaseSpeedDecition(gps_decition, secSpeed, decitionGpstool->obsDistance, decitionGpstool->obsSpeed,now_gps_ins);
-
-    gps_decition->wheel_angle = 0.0 - controlAng;
-
-    lastAngle=gps_decition->wheel_angle;
-
-	
-	return gps_decition;
-
-
-}
-
-
-
-void iv::decition::DecideLine00::phaseSpeedDecition(iv::decition::Decition  decition, double secSpeed, double obsDistance, double obsSpeed, GPS_INS gpsIns) {
-
-    //      obsDistance = -1;
-
-
-    std::cout << "\n计算用obs速度:%f\n" << obsSpeed << std::endl;
-    std::cout << "\n计算用obs距离:%f\n" << obsDistance << std::endl;
-
-
-
-    //  double acc = gpsIns.accel_y;
-    //    if(dSpeed>0)
-    //    dSpeed=dSpeed;
-    if(obsDistance<5 && obsDistance>0){
-        dSpeed=0;
-    }
-
-    dSecSpeed = dSpeed / 3.6;
-
-    double vt = dSecSpeed;
-    double vs = secSpeed;
-
-
-    if (abs(vs) < 0.05) vs = 0;
-    if (abs(obsSpeed) < 0.05) obsSpeed = 0;
-
-
-
-
-    double vl = vs + obsSpeed;
-    double vh = vs;
-    double dmax = 150;
-
-    //车距滤波
-    if (obsDistance < 0||obsDistance>100) {
-        obsDistance = 500;
-        obsSpeed=0;
-    }
-    if (obsDistance < 1) obsDistance = 1;
-
-    if (obsDistance > 150) vl = 25; //25m/s
-
-    if (obsSpeed <-15) obsDistance = obsDistance * 0.25 + lastDistance * 0.75;
-    else obsDistance = obsDistance * 0.5 + lastDistance * 0.5;
-
-
-
-    //TTC计算
-    double ds = 0.2566 * vl * vl + 5;
-    double ttcr = (vh - vl) / obsDistance;
-    double ttc = 15;
-    if (15 * (vh - vl) > obsDistance)
-        ttc = obsDistance / (vh - vl);
-
-
-    ServiceCarStatus.mfttc = ttc;
-
-
-    if (obsDistance <= dmax)
-    {
-        if (ttc > 10)
-        {
-            if (obsDistance > ds + 5)
-            {
-                double dds = min(30.0, obsDistance - (ds + 5));
-                vt = vt * dds / 30 + vl * (1 - dds / 30);
-            }
-            else
-            {
-                vt = min(vt, vl);
-            }
-        }
-        else
-        {
-            vt = min(vt, vl);
-        }
-    }
-
-    //   vt=min(vt,dSecSpeed);
-    vt=dSecSpeed;
-    std::cout << "\nvt:%f\n" << vt << std::endl;
-    //速度控制
-
-
-
-
-
-    double Id = 0;
-
-
-
-
-    double ed = ds - obsDistance;
-    if (obsDistance > 150) ed = 0;
-    double ev = vs - vt;
-    double u = 0;
-
-    if (ttc>10)  //if (ttc>10)
-    {
-
-        double kp = 0.5;        //double kp = 0.5;
-        double kd = 0.3;       //kd = 0.03
-        double k11 = 0.18;      //double k11 = 0.025;
-        double k12 = 0.000125;
-
-
-        double dev = (ev - lastEv) / 0.1;
-
-        Iv = 0.925 * Iv + ev;
-
-        Id = 0.85 * Id + ed;
-
-        if (abs(vh) < 2.0&& abs(vl) < 2.0)
-        {
-            Iv = 0.0; Id = 0.0;
-        }
-
-        /*u = kp * ev + kd * dev + k11 * Iv + k12 * Id;*/
-        u = kp * ev + kd * dev;
-    }
-
-
-    else if (ttc < 1.6 || (ttc <= 10 && obsDistance <= 0.75 * ds))
-    {
-        //AEB控制
-        Id = 0; Iv = 0;
-
-        u = 0;
-        if (ttc < 0.8) u = 7;
-        else if (ttc < 1.6) u = 3 + 5 * (1.6 - ttc);
-        else
-        {
-            u = (10 - ttc) * (10 - ttc) / 23.52;
-        }
-
-    }
-    else
-    {
-        //制动控制
-        Id = 0; Iv = 0;
-
-        if (obsDistance > 1.25 * ds)
-        {
-            double rev_ed = 1 / ed;
-
-            u = -0.5 * obsDistance * obsDistance * rev_ed * ttcr * ttcr;
-        }
-        else
-        {
-            if (abs(vl) > 2.0)
-                u = 0;
-            else
-                u = max(lastU, 1.0);
-        }
-    }
-
-    if (abs(vl) < 1.0 && abs(vh) < 1.0
-            && obsDistance < 2 * ds)
-    {
-        u = 0.5;
-    }
-
-
-
-
-
-
-    //u 限值
-    if (gpsIns.ins_pitch_angle>4&&u<-2.0)
-    {
-        u = -2.0;
-    }else if(ttc<3 && u<-0.2){
-        u=-0.2;
-    }
-    else
-    {
-
-        //     if (u < -0.7) u = -0.7;
-        if (u < -1.5) u = -1.5;
-    }
-
-    //        if (ttc > 8)
-    //        {
-    //            if (u > 0.8) u = 0.8;
-    //        }
-
-    if (u >= 0 && lastU <= 0)
-    {
-        if (u > 0.5) u = 0.5;
-    }
-    else if (u >= 0 && lastU >= 0)
-    {
-        if (u > lastU + 0.5) u = lastU + 0.5;
-    }
-    else if (u <= 0 && lastU >= 0)
-    {
-        if (u < -0.04) u = -0.04;
-    }
-    else if (u <= 0 && lastU <= 0)
-    {
-        if (u < lastU - 0.04) u = lastU - 0.04;
-    }
-
-
-
-
-    lastU = u;
-    lastEv = ev;
-    lastVt = vt;
-
-    //brakeValue start
-    if (u > 0)
-    {
-
-        decition->torque=0;
-        controlBrake=u; //102
-        if(obsDistance>0 && obsDistance<10){
-            controlBrake=u*1.5;
-        }
-        if(abs(dSpeed-realspeed)<3 &&(obsDistance>40 || obsDistance<0)&&ttc>8 && dSpeed>0){
-            controlBrake=0;
-            decition->torque=max(0.0,ServiceCarStatus.torque_st-10.0);
-        }
-        //0110
-        if(changingDangWei){
-            controlBrake=max(0.3,controlBrake);
-        }
-
-    } //brakeValue end
-    else
-    {
-        controlBrake = 0;
-
-        if(ServiceCarStatus.torque_st==0){
-            decition->torque = (u*(-16)+((0-u)-ServiceCarStatus.mfVehAcc)*10)*0.7; //*1.0
-            decition->torque =max( decition->torque,1.0f);
-
-        }else{
-            decition->torque= ServiceCarStatus.torque_st+((0-u)-ServiceCarStatus.mfVehAcc)*10;//1115    *10
-            }
-
-        if(((gpsIns.ins_pitch_angle>-2.5 && ServiceCarStatus.daocheMode)||
-            (gpsIns.ins_pitch_angle<2.5 && !ServiceCarStatus.daocheMode))){
-            if(realspeed<5  ){
-                decition->torque=min((float)25.0,decition->torque); //youmenxianxiao  30
-            }else if(realspeed<10){
-                decition->torque=min((float)25.0,decition->torque);  //40
-            }
-        }
-        decition->torque = min((float)(ServiceCarStatus.torque_st+5.0),decition->torque); //1115 5.0
-
-
-        // 斜坡加大油门   0217 lsn
-
-
-
-
-        if(((gpsIns.ins_pitch_angle<-2.5 && ServiceCarStatus.daocheMode)||
-            (gpsIns.ins_pitch_angle>2.5 && !ServiceCarStatus.daocheMode))
-                && abs(realspeed)<1.0){
-            decition->torque=max((float)20.0,decition->torque);
-            decition->torque=min((float)40.0,decition->torque);
-        }
-
-
-
-       else if(((gpsIns.ins_pitch_angle<-2.5 && ServiceCarStatus.daocheMode)||
-            (gpsIns.ins_pitch_angle>2.5 && !ServiceCarStatus.daocheMode))
-                && abs(realspeed)<10.0){
-                decition->torque=min((float)40.0,decition->torque); //youmenxianxiao  30
-        }
-
-
-
-
-        // 斜坡加大油门  end
-
-        decition->torque=min((float)100.0,decition->torque);
-        decition->torque=max((float)0.0,decition->torque);
-    }
-
-
-
-
-
-
-
-
-
-
-
-
-
-    //if (vt<2)                                                    //怠速
-    //{
-    //	controlSpeed = 0;
-    //}
-
-
-
-
-
-
-    //刹车限制
-
-    int BrakeIntMax = 10;
-    if (vs < 10.0 / 3.6) BrakeIntMax = 4;
-    else if (vs < 20.0 / 3.6) BrakeIntMax = 6;
-
-    //`
-    if(ttc>10){
-        BrakeIntMax = 2;
-    }else if(ttc>6){
-        BrakeIntMax = 3;
-    }else if(ttc>3){
-        BrakeIntMax = 4;
-    }else if(ttc>1.6){
-        BrakeIntMax = 5;
-    }else if(ttc>0.8){
-        BrakeIntMax = 8;
-    }else{
-        BrakeIntMax = 10;
-    }
-    if(obsDistance>0 && obsDistance<10){
-        BrakeIntMax=max(BrakeIntMax,3);
-    }
-
-    if (controlBrake > BrakeIntMax) controlBrake = BrakeIntMax;
-
-
-
-
-    //    if((obsDistance<0 || obsDistance>40)&&abs(dSpeed-realspeed)<3 && controlBrake>0){
-    //        controlBrake=0;
-    //        controlSpeed = max(ServiceCarStatus.torque_st-1.0,0.0); //1115
-    //    }
-    if((obsDistance<0 || obsDistance>40)&&abs(dSpeed-realspeed)<3 && controlBrake>0 && dSpeed>10){
-        controlBrake=0;
-        controlSpeed = max(ServiceCarStatus.torque_st-1.0,1.0); //1115
-    }
-
-
-
-    decition->brake = controlBrake;
-    decition->brake=min(100.0,double(decition->brake));
-    //   decition->torque = controlSpeed;
-
-    if (obsDistance>0)
-    {
-        iv::decition::DecideGps00::lastDistance = obsDistance;
-    }
-    else
-    {
-        iv::decition::DecideGps00::lastDistance = 200;
-    }
-
-
-
-    //1115
-
-    //        if(decition->torque>0){
-    //            if(decition->torque>lastTorque){
-    //                decition->torque=min(float(lastTorque+1.0),decition->torque);
-    //            }
-    ////            else if(decition->torque<lastTorque){
-    ////                decition->torque=max(float(lastTorque-5.0), decition->torque);
-    ////            }
-    //        }
-
-    //        lastTorque=decition->torque;
-
-    //斜坡刹车加大 lsn 0217
-    if (abs(gpsIns.ins_pitch_angle)>2.5 &&(decition->brake>0||dSpeed==0)){
-        decition->brake=max(2.0f,decition->brake);
-    }
-    //斜坡刹车加大 end
-
-
-    //0227 10m nei xianzhi shache
-    if(obsDistance<10 &&obsDistance>0){
-        decition->torque=0;
-        decition->brake=max(decition->brake,0.8f);
-    }
-
-
-
-
-
-    decition->accelerator=decition->torque;
-
-
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-double iv::decition::DecideLine00::limitAngle(double speed, double angle) {
-	double preAngle = angle;
-
-	if (speed > 15)
-	{
-		if (preAngle > 350)
-		{
-			preAngle = 350;
-		}
-		if (preAngle < -350)
-		{
-			preAngle = -350;
-		}
-	}
-	if (speed > 22)
-	{
-		if (preAngle > 200)
-		{
-			preAngle = 200;
-		}
-		if (preAngle < -200)
-		{
-			preAngle = -200;
-		}
-	}
-	if (speed > 25)
-	{
-		if (preAngle > 150)
-		{
-			preAngle = 150;
-		}
-		if (preAngle < -150)
-		{
-			preAngle = -150;
-		}
-	}
-	if (speed > 30)
-	{
-		if (preAngle > 70)
-		{
-			preAngle = 70;
-		}
-		if (preAngle < -70)
-		{
-			preAngle = -70;
-		}
-	}
-	if (speed > 45)                     //20
-	{
-		if (preAngle > 15)
-		{
-			preAngle = 15;
-		}
-		if (preAngle < -15)
-		{
-			preAngle = -15;
-		}
-	}
-	return preAngle;
-}
-
-
-
-double iv::decition::DecideLine00::limitSpeed(double angle, double speed) {
-
-	if (abs(angle) > 500 && speed > 8) speed = 8;
-	else if (abs(angle) > 350 && speed > 14) speed = 14;
-	else if (abs(angle) > 200 && speed > 21) speed = 21;
-	else if (abs(angle) > 150 && speed > 24) speed = 24;
-	else if (abs(angle) > 60 && speed > 29) speed = 29;
-	else if (abs(angle) > 20 && speed > 34) speed = 34;
-    return max(0.0, speed);
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-double iv::decition::DecideLine00::trumpet() {
-	if (trumpetFirstCount)
-	{
-		trumpetFirstCount = false;
-		trumpetLastTime= GetTickCount();
-        trumpetTimeSpan = 0.0;
-	}
-	else
-	{
-		trumpetStartTime= GetTickCount();
-		trumpetTimeSpan += trumpetStartTime - trumpetLastTime;
-		trumpetLastTime = trumpetStartTime;
-	}
-	
-	return trumpetTimeSpan;
-}
-
-
-void  iv::decition::DecideLine00::handBrakePark(iv::decition::Decition  decition, long duringTime, GPS_INS now_gps_ins) {
-
-	if (abs(now_gps_ins.speed)>0.1)
-	{
-		decition->accelerator = 0;
-		decition->brake = 20;
-		decition->wheel_angle = 0;
-	
-	}
-	else
-	{
-
-		decition->accelerator = 0;
-		decition->brake = 20;
-		decition->wheel_angle = 0;
-		handPark = true;
-		handParkTime = duringTime;		
-	}
-
-}
-
-
-
-std::vector<iv::Point2D> iv::decition::DecideLine00::getGpsTraceByMobileEye(float a,float b, float c){
-    vector<iv::Point2D> trace;
-    for(int i=0; i<600;i++){
-       float y=0.1*i;
-       float x=(a*y*y+b*y+c);
-       iv::Point2D pt;
-        pt.x=x;
-        pt.y=y;
-        trace.push_back(pt);
-    }
-    return trace;
-}
-
+#include <decition/decide_line_00.h>
+#include <decition/compute_00.h>
+#include <decition/gps_distance.h>
+#include <decition/decition_type.h>
+#include <decition/transfer.h>
+#include <common/constants.h>
+#include <common/car_status.h>
+#include <math.h>
+#include <iostream>
+#include <fstream>
+#include <control/can.h>
+#include <time.h>
+using namespace std;
+
+#define PI (3.1415926535897932384626433832795)
+
+iv::decition::DecideLine00::DecideLine00() {
+      decitionGpstool = new iv::decition::DecideGps00();
+      mdecitionGpstool.reset(decitionGpstool);
+}
+iv::decition::DecideLine00::~DecideLine00() {
+
+}
+
+
+int iv::decition::DecideLine00::PathPoint = -1;
+double iv::decition::DecideLine00::minDis = iv::MaxValue;
+double iv::decition::DecideLine00::maxAngle = iv::MinValue;
+//int iv::decition::DecideLine00::lastGpsIndex = iv::MaxValue;
+int iv::decition::DecideLine00::lastGpsIndex = 0;
+double iv::decition::DecideLine00::controlSpeed = 0;
+double iv::decition::DecideLine00::controlBrake = 0;
+double iv::decition::DecideLine00::controlAng = 0;
+double iv::decition::DecideLine00::Iv = 0;
+double iv::decition::DecideLine00::lastU = 0;
+double iv::decition::DecideLine00::lastVt = 0;
+double iv::decition::DecideLine00::lastEv = 0;
+
+int iv::decition::DecideLine00::gpsLineParkIndex = 0;
+int iv::decition::DecideLine00::gpsMapParkIndex = 0;
+double iv::decition::DecideLine00::lastDistance = MaxValue;
+double iv::decition::DecideLine00::obsDistance = -1;
+double iv::decition::DecideLine00::obsDistanceAvoid = -1;
+double iv::decition::DecideLine00::lastDistanceAvoid = -1;
+
+double iv::decition::DecideLine00::lidarDistance = -1;
+double iv::decition::DecideLine00::myesrDistance = -1;
+double iv::decition::DecideLine00::lastLidarDis = -1;
+
+bool iv::decition::DecideLine00::parkMode = false;
+bool iv::decition::DecideLine00::readyParkMode = false;
+
+bool iv::decition::DecideLine00::zhucheMode = false;
+bool iv::decition::DecideLine00::readyZhucheMode = false;
+bool iv::decition::DecideLine00::hasZhuched = false;
+
+double iv::decition::DecideLine00::lastLidarDisAvoid = -1;
+double iv::decition::DecideLine00::lidarDistanceAvoid = -1;
+
+int iv::decition::DecideLine00::finishPointNum = 0;
+int iv::decition::DecideLine00::zhuchePointNum = 0;
+
+
+
+
+
+//日常展示
+
+iv::decition::Decition    iv::decition::DecideLine00::getDecideFromGPS(GPS_INS now_gps_ins, const std::vector<GPSData> gpsMapLine, iv::LidarGridPtr lidarGridPtr,
+                                                                       std::vector<iv::Perception::PerceptionOutput> lidar_per) {
+
+	Decition gps_decition(new DecitionBasic);
+
+
+	if (isFirstRun)
+	{
+		vehState = normalRun;	
+		startAvoid_gps_ins = now_gps_ins;
+
+
+		ServiceCarStatus.carState = 1;
+		/*roadOri = gpsMapLine[PathPoint]->roadOri;
+		roadNow = roadOri;*/
+		busMode = false;
+
+
+       waitGpsTimeWidth= ServiceCarStatus.waitGpsTimeWidth;
+        outGarageLong=ServiceCarStatus.outGarageLong;
+		isFirstRun = false;
+	}
+    busMode=ServiceCarStatus.busmode;
+    ServiceCarStatus.useMobileEye=true;
+	gps_decition->leftlamp = false;
+	gps_decition->rightlamp = false;
+
+	
+	is_arrivaled = false;
+	
+
+
+	
+
+
+	
+
+	if (parkMode)
+	{
+
+		
+		handBrakePark(gps_decition,10000,now_gps_ins);
+		return gps_decition;
+	}
+
+
+	//驻车
+
+	if (zhucheMode)
+	{
+
+		if (trumpet()<5000)
+		{
+			gps_decition->brake=20;
+			gps_decition->accelerator = 0;
+			gps_decition->wheel_angle = 0;
+			gps_decition->speed = 0;
+			return gps_decition;
+		}
+		else
+		{
+			hasZhuched = true;
+			zhucheMode = false;
+			trumpetFirstCount = true;
+		}
+
+	}
+
+
+	//判断驻车标志位
+	if (hasZhuched && GetDistance(now_gps_ins,*gpsMapLine[zhuchePointNum])>20)
+	{
+		hasZhuched = false;
+	}
+
+
+
+	obsDistance = -1;
+    esrLineIndex = -1;
+	lidarDistance = -1;
+
+
+	roadPre = -1;
+
+
+
+    //realspeed = now_gps_ins.speed;
+    realspeed = ServiceCarStatus.vehSpeed_st;
+	secSpeed = realspeed / 3.6;
+
+
+    std::cout << "\n#############realspeed:\n" <<  realspeed << std::endl;
+
+	avoidX = (roadOri-roadNow)*roadWidth;
+
+	gpsTraceOri.clear();
+	gpsTraceNow.clear();
+	gpsTraceAvoid.clear();
+	gpsTraceBack.clear();
+
+
+    gpsTraceOri=getGpsTraceByMobileEye(ServiceCarStatus.Lane.curvature,ServiceCarStatus.Lane.heading,
+                                       (ServiceCarStatus.aftermarketLane.dist_to_lane_l+ServiceCarStatus.aftermarketLane.dist_to_lane_r)*0.5);
+     controlAng = iv::decition::Compute00().getDecideAngleByLanePID(realspeed);
+  //  controlAng = iv::decition::Compute00().getDecideAngle(gpsTraceOri, realspeed);
+    if(outGarageTimeLast!=-1){
+        outGarageTimeNow=GetTickCount();
+    }
+    if(outGarageTimeNow!=-1){
+        outGarageDistance+= (outGarageTimeNow-outGarageTimeLast)*secSpeed*0.001;
+         std::cout << "使用mobileEye决策————outGarageDistance:"<<outGarageDistance<< std::endl;
+    }
+    if(outGarageDistance>outGarageLong && !waitGps){
+        waitGps=true;
+
+        outGarageTimeLast=-1;
+        outGarageTimeNow=-1;
+        outGarageDistance=0;
+
+
+    }
+
+    if(ServiceCarStatus.m_bOutGarage && !waitGps){
+        outGarageTimeLast=GetTickCount();
+    }
+
+    if(waitGps){
+         std::cout << "使用mobileEye决策————waitGps"<< std::endl;
+        if(waitGpsTimeStart==-1){
+            waitGpsTimeStart=GetTickCount();
+        }
+        if(waitGpsTimeStart!=-1){
+            waitGpsTimeNow=GetTickCount();
+        }
+        if(waitGpsTimeNow!=-1){
+            waitGpsTimeSpan=waitGpsTimeNow-waitGpsTimeStart;
+            std::cout << "使用mobileEye决策————waitGps————waitGpsTimeSpan:"<<waitGpsTimeSpan <<std::endl;
+        }
+        if(waitGpsTimeSpan>waitGpsTimeWidth){
+            waitGps=false;
+            waitGpsTimeStart=-1;
+            waitGpsTimeNow=-1;
+            waitGpsTimeSpan=0;
+             ServiceCarStatus.m_bOutGarage=false;
+               std::cout << "使用mobileEye决策————waitGps————退出"<< std::endl;
+        }
+
+        gps_decition->accelerator =0;
+        gps_decition->torque = 0;
+        gps_decition->brake=0.8;
+        gps_decition->wheel_angle = 0.0 - controlAng;
+        //           gps_decition->wheel_angle = 0;
+
+        return gps_decition;
+
+    }
+
+	
+
+
+
+	
+
+		
+
+  //  controlAng = iv::decition::Compute00().getDecideAngleByLane(realspeed);
+
+
+	if (readyParkMode)
+	{
+		double parkDis = GetDistance(now_gps_ins, *gpsMapLine[finishPointNum]);
+
+	
+		if (parkDis < 25)
+		{
+			Point2D pt = Coordinate_Transfer((*gpsMapLine[finishPointNum]).gps_x, (*gpsMapLine[finishPointNum]).gps_y, now_gps_ins);
+			double parkDistance = pt.y;
+
+
+			if (dSpeed > 15)
+			{
+				dSpeed = 15;
+			}
+
+
+			
+			if (parkDistance < 5 && parkDistance >= 4)
+			{
+                dSpeed = min(dSpeed, 8.0);
+			}
+
+
+
+			if (parkDistance < 1.5)
+			{
+				dSpeed = 0;
+				parkMode = true;
+				readyParkMode = false;
+			}
+
+
+		}
+	}
+
+
+
+	//准备驻车
+
+	if (readyZhucheMode)
+	{
+		double dis = GetDistance(*gpsMapLine[zhuchePointNum], now_gps_ins);
+
+		if (dis<25)
+		{
+			Point2D pt = Coordinate_Transfer((*gpsMapLine[zhuchePointNum]).gps_x, (*gpsMapLine[zhuchePointNum]).gps_y, now_gps_ins);
+			double zhucheDistance = pt.y;
+
+
+			if (dSpeed > 15)
+			{
+				dSpeed = 15;
+			}
+
+
+
+			if (zhucheDistance < 5 && zhucheDistance >= 4)
+			{
+                dSpeed = min(dSpeed, 8.0);
+			}
+
+
+
+			if (zhucheDistance < 3)
+			{
+				dSpeed = 0;
+				zhucheMode = true;
+				readyZhucheMode = false;
+			}
+
+		}
+		
+		
+
+	}
+
+
+
+
+
+    dSpeed=15;
+
+
+	//速度结合角度的限制
+	controlAng = limitAngle(realspeed, controlAng);
+	dSpeed = limitSpeed(controlAng, dSpeed);
+
+	gps_decition->speed = dSpeed;
+
+
+	dSecSpeed = dSpeed / 3.6;
+	//	 ac = 2 * max(10, realspeed) / ((dSecSpeed*dSecSpeed) - (secSpeed*secSpeed));
+
+
+
+
+
+	/* if (obsDistance <0 && ac<0 && ac >= -0.5)
+	{
+	gps_decition->accelerator = 0;
+	gps_decition->brake = 0;
+	}
+	else {*/
+
+	
+
+
+
+
+
+
+
+
+        std::cout << "\n呼车指令状态:%d\n" <<  ServiceCarStatus.carState << std::endl;
+		
+		//停车
+        if (ServiceCarStatus.carState == 0 && busMode)  //stop
+        {
+
+            gps_decition->accelerator =0;
+            gps_decition->torque = 0;
+            gps_decition->brake=0.5;
+            gps_decition->wheel_angle = 0.0 - controlAng;
+            //           gps_decition->wheel_angle = 0;
+
+            return gps_decition;
+
+        }
+
+
+
+        if (ServiceCarStatus.carState == 3 && busMode)   //  lin stop
+        {
+
+            ServiceCarStatus.carState=0;
+            gps_decition->accelerator = 0;
+            gps_decition->torque = 0;
+            gps_decition->brake=0.5;
+            gps_decition->wheel_angle = 0.0 - controlAng;
+            return gps_decition;
+
+
+        }
+
+
+
+
+
+
+
+        if (ServiceCarStatus.carState == 2 && busMode)  // dao zhan dian
+        {
+            dSpeed=3;
+        }
+
+
+
+
+                if (now_gps_ins.ins_status !=4 ) {
+
+                    dSpeed = min(15.0, dSpeed);
+
+                }
+
+
+        dSpeed=3;
+		dSecSpeed = dSpeed / 3.6;
+		gps_decition->speed = dSpeed;
+
+
+        decitionGpstool->computeObsOnRoad(lidarGridPtr,gpsTraceOri,0,gpsMapLine,lidar_per);
+
+        int confL=ServiceCarStatus.aftermarketLane.lane_conf_left;
+         int confR=ServiceCarStatus.aftermarketLane.lane_conf_right;
+         int conf=min(confL,confR);
+         if(conf<=1){
+
+         }
+
+        phaseSpeedDecition(gps_decition, secSpeed, decitionGpstool->obsDistance, decitionGpstool->obsSpeed,now_gps_ins);
+
+    gps_decition->wheel_angle = 0.0 - controlAng;
+
+    lastAngle=gps_decition->wheel_angle;
+
+	
+	return gps_decition;
+
+
+}
+
+
+
+void iv::decition::DecideLine00::phaseSpeedDecition(iv::decition::Decition  decition, double secSpeed, double obsDistance, double obsSpeed, GPS_INS gpsIns) {
+
+    //      obsDistance = -1;
+
+
+    std::cout << "\n计算用obs速度:%f\n" << obsSpeed << std::endl;
+    std::cout << "\n计算用obs距离:%f\n" << obsDistance << std::endl;
+
+
+
+    //  double acc = gpsIns.accel_y;
+    //    if(dSpeed>0)
+    //    dSpeed=dSpeed;
+    if(obsDistance<5 && obsDistance>0){
+        dSpeed=0;
+    }
+
+    dSecSpeed = dSpeed / 3.6;
+
+    double vt = dSecSpeed;
+    double vs = secSpeed;
+
+
+    if (abs(vs) < 0.05) vs = 0;
+    if (abs(obsSpeed) < 0.05) obsSpeed = 0;
+
+
+
+
+    double vl = vs + obsSpeed;
+    double vh = vs;
+    double dmax = 150;
+
+    //车距滤波
+    if (obsDistance < 0||obsDistance>100) {
+        obsDistance = 500;
+        obsSpeed=0;
+    }
+    if (obsDistance < 1) obsDistance = 1;
+
+    if (obsDistance > 150) vl = 25; //25m/s
+
+    if (obsSpeed <-15) obsDistance = obsDistance * 0.25 + lastDistance * 0.75;
+    else obsDistance = obsDistance * 0.5 + lastDistance * 0.5;
+
+
+
+    //TTC计算
+    double ds = 0.2566 * vl * vl + 5;
+    double ttcr = (vh - vl) / obsDistance;
+    double ttc = 15;
+    if (15 * (vh - vl) > obsDistance)
+        ttc = obsDistance / (vh - vl);
+
+
+    ServiceCarStatus.mfttc = ttc;
+
+
+    if (obsDistance <= dmax)
+    {
+        if (ttc > 10)
+        {
+            if (obsDistance > ds + 5)
+            {
+                double dds = min(30.0, obsDistance - (ds + 5));
+                vt = vt * dds / 30 + vl * (1 - dds / 30);
+            }
+            else
+            {
+                vt = min(vt, vl);
+            }
+        }
+        else
+        {
+            vt = min(vt, vl);
+        }
+    }
+
+    //   vt=min(vt,dSecSpeed);
+    vt=dSecSpeed;
+    std::cout << "\nvt:%f\n" << vt << std::endl;
+    //速度控制
+
+
+
+
+
+    double Id = 0;
+
+
+
+
+    double ed = ds - obsDistance;
+    if (obsDistance > 150) ed = 0;
+    double ev = vs - vt;
+    double u = 0;
+
+    if (ttc>10)  //if (ttc>10)
+    {
+
+        double kp = 0.5;        //double kp = 0.5;
+        double kd = 0.3;       //kd = 0.03
+        double k11 = 0.18;      //double k11 = 0.025;
+        double k12 = 0.000125;
+
+
+        double dev = (ev - lastEv) / 0.1;
+
+        Iv = 0.925 * Iv + ev;
+
+        Id = 0.85 * Id + ed;
+
+        if (abs(vh) < 2.0&& abs(vl) < 2.0)
+        {
+            Iv = 0.0; Id = 0.0;
+        }
+
+        /*u = kp * ev + kd * dev + k11 * Iv + k12 * Id;*/
+        u = kp * ev + kd * dev;
+    }
+
+
+    else if (ttc < 1.6 || (ttc <= 10 && obsDistance <= 0.75 * ds))
+    {
+        //AEB控制
+        Id = 0; Iv = 0;
+
+        u = 0;
+        if (ttc < 0.8) u = 7;
+        else if (ttc < 1.6) u = 3 + 5 * (1.6 - ttc);
+        else
+        {
+            u = (10 - ttc) * (10 - ttc) / 23.52;
+        }
+
+    }
+    else
+    {
+        //制动控制
+        Id = 0; Iv = 0;
+
+        if (obsDistance > 1.25 * ds)
+        {
+            double rev_ed = 1 / ed;
+
+            u = -0.5 * obsDistance * obsDistance * rev_ed * ttcr * ttcr;
+        }
+        else
+        {
+            if (abs(vl) > 2.0)
+                u = 0;
+            else
+                u = max(lastU, 1.0);
+        }
+    }
+
+    if (abs(vl) < 1.0 && abs(vh) < 1.0
+            && obsDistance < 2 * ds)
+    {
+        u = 0.5;
+    }
+
+
+
+
+
+
+    //u 限值
+    if (gpsIns.ins_pitch_angle>4&&u<-2.0)
+    {
+        u = -2.0;
+    }else if(ttc<3 && u<-0.2){
+        u=-0.2;
+    }
+    else
+    {
+
+        //     if (u < -0.7) u = -0.7;
+        if (u < -1.5) u = -1.5;
+    }
+
+    //        if (ttc > 8)
+    //        {
+    //            if (u > 0.8) u = 0.8;
+    //        }
+
+    if (u >= 0 && lastU <= 0)
+    {
+        if (u > 0.5) u = 0.5;
+    }
+    else if (u >= 0 && lastU >= 0)
+    {
+        if (u > lastU + 0.5) u = lastU + 0.5;
+    }
+    else if (u <= 0 && lastU >= 0)
+    {
+        if (u < -0.04) u = -0.04;
+    }
+    else if (u <= 0 && lastU <= 0)
+    {
+        if (u < lastU - 0.04) u = lastU - 0.04;
+    }
+
+
+
+
+    lastU = u;
+    lastEv = ev;
+    lastVt = vt;
+
+    //brakeValue start
+    if (u > 0)
+    {
+
+        decition->torque=0;
+        controlBrake=u; //102
+        if(obsDistance>0 && obsDistance<10){
+            controlBrake=u*1.5;
+        }
+        if(abs(dSpeed-realspeed)<3 &&(obsDistance>40 || obsDistance<0)&&ttc>8 && dSpeed>0){
+            controlBrake=0;
+            decition->torque=max(0.0,ServiceCarStatus.torque_st-10.0);
+        }
+        //0110
+        if(changingDangWei){
+            controlBrake=max(0.3,controlBrake);
+        }
+
+    } //brakeValue end
+    else
+    {
+        controlBrake = 0;
+
+        if(ServiceCarStatus.torque_st==0){
+            decition->torque = (u*(-16)+((0-u)-ServiceCarStatus.mfVehAcc)*10)*0.7; //*1.0
+            decition->torque =max( decition->torque,1.0f);
+
+        }else{
+            decition->torque= ServiceCarStatus.torque_st+((0-u)-ServiceCarStatus.mfVehAcc)*10;//1115    *10
+            }
+
+        if(((gpsIns.ins_pitch_angle>-2.5 && ServiceCarStatus.daocheMode)||
+            (gpsIns.ins_pitch_angle<2.5 && !ServiceCarStatus.daocheMode))){
+            if(realspeed<5  ){
+                decition->torque=min((float)25.0,decition->torque); //youmenxianxiao  30
+            }else if(realspeed<10){
+                decition->torque=min((float)25.0,decition->torque);  //40
+            }
+        }
+        decition->torque = min((float)(ServiceCarStatus.torque_st+5.0),decition->torque); //1115 5.0
+
+
+        // 斜坡加大油门   0217 lsn
+
+
+
+
+        if(((gpsIns.ins_pitch_angle<-2.5 && ServiceCarStatus.daocheMode)||
+            (gpsIns.ins_pitch_angle>2.5 && !ServiceCarStatus.daocheMode))
+                && abs(realspeed)<1.0){
+            decition->torque=max((float)20.0,decition->torque);
+            decition->torque=min((float)40.0,decition->torque);
+        }
+
+
+
+       else if(((gpsIns.ins_pitch_angle<-2.5 && ServiceCarStatus.daocheMode)||
+            (gpsIns.ins_pitch_angle>2.5 && !ServiceCarStatus.daocheMode))
+                && abs(realspeed)<10.0){
+                decition->torque=min((float)40.0,decition->torque); //youmenxianxiao  30
+        }
+
+
+
+
+        // 斜坡加大油门  end
+
+        decition->torque=min((float)100.0,decition->torque);
+        decition->torque=max((float)0.0,decition->torque);
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+    //if (vt<2)                                                    //怠速
+    //{
+    //	controlSpeed = 0;
+    //}
+
+
+
+
+
+
+    //刹车限制
+
+    int BrakeIntMax = 10;
+    if (vs < 10.0 / 3.6) BrakeIntMax = 4;
+    else if (vs < 20.0 / 3.6) BrakeIntMax = 6;
+
+    //`
+    if(ttc>10){
+        BrakeIntMax = 2;
+    }else if(ttc>6){
+        BrakeIntMax = 3;
+    }else if(ttc>3){
+        BrakeIntMax = 4;
+    }else if(ttc>1.6){
+        BrakeIntMax = 5;
+    }else if(ttc>0.8){
+        BrakeIntMax = 8;
+    }else{
+        BrakeIntMax = 10;
+    }
+    if(obsDistance>0 && obsDistance<10){
+        BrakeIntMax=max(BrakeIntMax,3);
+    }
+
+    if (controlBrake > BrakeIntMax) controlBrake = BrakeIntMax;
+
+
+
+
+    //    if((obsDistance<0 || obsDistance>40)&&abs(dSpeed-realspeed)<3 && controlBrake>0){
+    //        controlBrake=0;
+    //        controlSpeed = max(ServiceCarStatus.torque_st-1.0,0.0); //1115
+    //    }
+    if((obsDistance<0 || obsDistance>40)&&abs(dSpeed-realspeed)<3 && controlBrake>0 && dSpeed>10){
+        controlBrake=0;
+        controlSpeed = max(ServiceCarStatus.torque_st-1.0,1.0); //1115
+    }
+
+
+
+    decition->brake = controlBrake;
+    decition->brake=min(100.0,double(decition->brake));
+    //   decition->torque = controlSpeed;
+
+    if (obsDistance>0)
+    {
+        iv::decition::DecideGps00::lastDistance = obsDistance;
+    }
+    else
+    {
+        iv::decition::DecideGps00::lastDistance = 200;
+    }
+
+
+
+    //1115
+
+    //        if(decition->torque>0){
+    //            if(decition->torque>lastTorque){
+    //                decition->torque=min(float(lastTorque+1.0),decition->torque);
+    //            }
+    ////            else if(decition->torque<lastTorque){
+    ////                decition->torque=max(float(lastTorque-5.0), decition->torque);
+    ////            }
+    //        }
+
+    //        lastTorque=decition->torque;
+
+    //斜坡刹车加大 lsn 0217
+    if (abs(gpsIns.ins_pitch_angle)>2.5 &&(decition->brake>0||dSpeed==0)){
+        decition->brake=max(2.0f,decition->brake);
+    }
+    //斜坡刹车加大 end
+
+
+    //0227 10m nei xianzhi shache
+    if(obsDistance<10 &&obsDistance>0){
+        decition->torque=0;
+        decition->brake=max(decition->brake,0.8f);
+    }
+
+
+
+
+
+    decition->accelerator=decition->torque;
+
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+double iv::decition::DecideLine00::limitAngle(double speed, double angle) {
+	double preAngle = angle;
+
+	if (speed > 15)
+	{
+		if (preAngle > 350)
+		{
+			preAngle = 350;
+		}
+		if (preAngle < -350)
+		{
+			preAngle = -350;
+		}
+	}
+	if (speed > 22)
+	{
+		if (preAngle > 200)
+		{
+			preAngle = 200;
+		}
+		if (preAngle < -200)
+		{
+			preAngle = -200;
+		}
+	}
+	if (speed > 25)
+	{
+		if (preAngle > 150)
+		{
+			preAngle = 150;
+		}
+		if (preAngle < -150)
+		{
+			preAngle = -150;
+		}
+	}
+	if (speed > 30)
+	{
+		if (preAngle > 70)
+		{
+			preAngle = 70;
+		}
+		if (preAngle < -70)
+		{
+			preAngle = -70;
+		}
+	}
+	if (speed > 45)                     //20
+	{
+		if (preAngle > 15)
+		{
+			preAngle = 15;
+		}
+		if (preAngle < -15)
+		{
+			preAngle = -15;
+		}
+	}
+	return preAngle;
+}
+
+
+
+double iv::decition::DecideLine00::limitSpeed(double angle, double speed) {
+
+	if (abs(angle) > 500 && speed > 8) speed = 8;
+	else if (abs(angle) > 350 && speed > 14) speed = 14;
+	else if (abs(angle) > 200 && speed > 21) speed = 21;
+	else if (abs(angle) > 150 && speed > 24) speed = 24;
+	else if (abs(angle) > 60 && speed > 29) speed = 29;
+	else if (abs(angle) > 20 && speed > 34) speed = 34;
+    return max(0.0, speed);
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+double iv::decition::DecideLine00::trumpet() {
+	if (trumpetFirstCount)
+	{
+		trumpetFirstCount = false;
+		trumpetLastTime= GetTickCount();
+        trumpetTimeSpan = 0.0;
+	}
+	else
+	{
+		trumpetStartTime= GetTickCount();
+		trumpetTimeSpan += trumpetStartTime - trumpetLastTime;
+		trumpetLastTime = trumpetStartTime;
+	}
+	
+	return trumpetTimeSpan;
+}
+
+
+void  iv::decition::DecideLine00::handBrakePark(iv::decition::Decition  decition, long duringTime, GPS_INS now_gps_ins) {
+
+	if (abs(now_gps_ins.speed)>0.1)
+	{
+		decition->accelerator = 0;
+		decition->brake = 20;
+		decition->wheel_angle = 0;
+	
+	}
+	else
+	{
+
+		decition->accelerator = 0;
+		decition->brake = 20;
+		decition->wheel_angle = 0;
+		handPark = true;
+		handParkTime = duringTime;		
+	}
+
+}
+
+
+
+std::vector<iv::Point2D> iv::decition::DecideLine00::getGpsTraceByMobileEye(float a,float b, float c){
+    vector<iv::Point2D> trace;
+    for(int i=0; i<600;i++){
+       float y=0.1*i;
+       float x=(a*y*y+b*y+c);
+       iv::Point2D pt;
+        pt.x=x;
+        pt.y=y;
+        trace.push_back(pt);
+    }
+    return trace;
+}
+

+ 62 - 62
src/decition/decition_brain/decition/decition_maker.h

@@ -1,62 +1,62 @@
-#pragma once
-#ifndef _IV_DECITION_DECITION_MAKER_
-#define _IV_DECITION_DECITION_MAKER_
-
-#include <common/gps_type.h>
-#include <decition/decition_type.h>
-#include<vector> 
-
-namespace iv {
-	namespace decition {
-		//根据传感器传输来的信息作出决策
-		class DecitionMaker
-		{
-		public:
-			DecitionMaker();
-			~DecitionMaker();
-
-            bool isFirstRun = true;                      //第一次找点标志
-            bool isComplete = false;
-			std::vector<iv::GPS_INS> vec_Gps_Group;
-			double angleDeviation;
-			double distanceDeviation;
-			double speedDeviation;
-			double origin_x;
-			double origin_y;
-			long lastNearPointNum = 0;
-			long objPointNum = 0;
-			GPS_INS startPoint;                          //起始位置最近点
-			GPS_INS nearestGpsIns;                       //最近车前路径点
-			GPS_INS nowGpsIns;                           //当前车位置点
-			GPS_INS objGpsIns;                           //跟踪目标点
-
-			float vehLenthAdj = 0;                       //实时定位点调整长度
-
-			GPS_INS getNearestGpsIns(iv::GPS_INS gps_ins, const std::vector<iv::GPSData> navigation_data);
-
-			iv::decition::Decition getDecideForGPS(iv::GPS_INS gpsIns, const std::vector<iv::GPSData> navigation_data);
-
-			void getStartPoint(iv::GPS_INS gps_ins, const std::vector<iv::GPSData> navigation_data);
-
-			void adjustOriginPoint(iv::GPS_INS gps_ins);
-
-			double getDistanceDeviation(GPS_INS nowGPSIns, GPS_INS nearestGPSIns);
-
-			double getCrossAngle(GPS_INS nowGPSIns, GPS_INS nearestGPSIns);
-
-			double getDirectCrossAngle(iv::GPS_INS nowGPSIns, iv::GPS_INS nearestGPSIns);
-
-			float getSpeedObj(GPS_INS nowGPSIns, GPS_INS nearestGPSIns);
-
-			void checkDistance(GPS_INS nowGPSIns, const std::vector<iv::GPSData> navigation_data,double maxDistance);
-			
-            bool checkComplete(GPS_INS nowGPSIns, const std::vector<iv::GPSData> navigation_data);
-
-		private:
-
-		};
-
-	}
-}
-
-#endif // !_IV_DECITION_DECITION_MAKER_
+#pragma once
+#ifndef _IV_DECITION_DECITION_MAKER_
+#define _IV_DECITION_DECITION_MAKER_
+
+#include <common/gps_type.h>
+#include <decition/decition_type.h>
+#include<vector> 
+
+namespace iv {
+	namespace decition {
+		//根据传感器传输来的信息作出决策
+		class DecitionMaker
+		{
+		public:
+			DecitionMaker();
+			~DecitionMaker();
+
+            bool isFirstRun = true;                      //第一次找点标志
+            bool isComplete = false;
+			std::vector<iv::GPS_INS> vec_Gps_Group;
+			double angleDeviation;
+			double distanceDeviation;
+			double speedDeviation;
+			double origin_x;
+			double origin_y;
+			long lastNearPointNum = 0;
+			long objPointNum = 0;
+			GPS_INS startPoint;                          //起始位置最近点
+			GPS_INS nearestGpsIns;                       //最近车前路径点
+			GPS_INS nowGpsIns;                           //当前车位置点
+			GPS_INS objGpsIns;                           //跟踪目标点
+
+			float vehLenthAdj = 0;                       //实时定位点调整长度
+
+			GPS_INS getNearestGpsIns(iv::GPS_INS gps_ins, const std::vector<iv::GPSData> navigation_data);
+
+			iv::decition::Decition getDecideForGPS(iv::GPS_INS gpsIns, const std::vector<iv::GPSData> navigation_data);
+
+			void getStartPoint(iv::GPS_INS gps_ins, const std::vector<iv::GPSData> navigation_data);
+
+			void adjustOriginPoint(iv::GPS_INS gps_ins);
+
+			double getDistanceDeviation(GPS_INS nowGPSIns, GPS_INS nearestGPSIns);
+
+			double getCrossAngle(GPS_INS nowGPSIns, GPS_INS nearestGPSIns);
+
+			double getDirectCrossAngle(iv::GPS_INS nowGPSIns, iv::GPS_INS nearestGPSIns);
+
+			float getSpeedObj(GPS_INS nowGPSIns, GPS_INS nearestGPSIns);
+
+			void checkDistance(GPS_INS nowGPSIns, const std::vector<iv::GPSData> navigation_data,double maxDistance);
+			
+            bool checkComplete(GPS_INS nowGPSIns, const std::vector<iv::GPSData> navigation_data);
+
+		private:
+
+		};
+
+	}
+}
+
+#endif // !_IV_DECITION_DECITION_MAKER_

+ 61 - 61
src/decition/decition_brain/decition/decition_type.h

@@ -1,61 +1,61 @@
-#pragma once
-#ifndef _IV_DECITION_DECITION_TYPE_
-#define _IV_DECITION_DECITION_TYPE_
-#include <common/boost.h>
-namespace iv {
-namespace decition {
-struct DecitionBasic {
-    float speed;				//车速
-    float wheel_angle;			//转向角度
-    float brake;				//刹车
-    float accelerator;			//油门
-    float torque;               //力矩
-    bool leftlamp;				//左转向灯
-    bool rightlamp;				//右转向灯
-
-    int  engine;
-    int  grade;
-    int  mode;
-    int handBrake;
-    bool speak;
-    bool door;
-    bool bright;
-    int dangWei;
-
-    float angSpeed;
-    int brakeType :1;
-    char brakeEnable;  //add by fjk
-    bool left;         //add by fjk
-    bool right;        //add by fjk
-
-    bool angleEnable;
-    bool speedEnable;
-    bool dangweiEnable;
-    int  driveMode;
-
-    int directLight;
-    int brakeLight;
-    int backLight;
-    int topLight;
-
-    int farLight;
-    int nearLight;
-
-
-
-    bool   air_enable ;                  //空调使能
-    bool   air_on;
-    float   air_temp ;                  //空调温度
-    float   air_mode ;                  //空调模式
-    float   wind_level ;                  //空调风力
-    float   roof_light ;                  //顶灯
-    float   home_light ;                  //日光灯
-    float   air_worktime ;                  //空调工作时间
-    float   air_offtime ;                  //空调关闭时间
-
-};
-typedef boost::shared_ptr<DecitionBasic> Decition;	//决策
-}
-}
-#endif // !_IV_DECITION_DECITION_TYPE_
-
+#pragma once
+#ifndef _IV_DECITION_DECITION_TYPE_
+#define _IV_DECITION_DECITION_TYPE_
+#include <common/boost.h>
+namespace iv {
+namespace decition {
+struct DecitionBasic {
+    float speed;				//车速
+    float wheel_angle;			//转向角度
+    float brake;				//刹车
+    float accelerator;			//油门
+    float torque;               //力矩
+    bool leftlamp;				//左转向灯
+    bool rightlamp;				//右转向灯
+
+    int  engine;
+    int  grade;
+    int  mode;
+    int handBrake;
+    bool speak;
+    bool door;
+    bool bright;
+    int dangWei;
+
+    float angSpeed;
+    int brakeType :1;
+    char brakeEnable;  //add by fjk
+    bool left;         //add by fjk
+    bool right;        //add by fjk
+
+    bool angleEnable;
+    bool speedEnable;
+    bool dangweiEnable;
+    int  driveMode;
+
+    int directLight;
+    int brakeLight;
+    int backLight;
+    int topLight;
+
+    int farLight;
+    int nearLight;
+
+
+
+    bool   air_enable ;                  //空调使能
+    bool   air_on;
+    float   air_temp ;                  //空调温度
+    float   air_mode ;                  //空调模式
+    float   wind_level ;                  //空调风力
+    float   roof_light ;                  //顶灯
+    float   home_light ;                  //日光灯
+    float   air_worktime ;                  //空调工作时间
+    float   air_offtime ;                  //空调关闭时间
+
+};
+typedef boost::shared_ptr<DecitionBasic> Decition;	//决策
+}
+}
+#endif // !_IV_DECITION_DECITION_TYPE_
+

+ 22 - 22
src/decition/decition_brain/decition/decition_voter.cpp

@@ -1,22 +1,22 @@
-#include <decition/decition_voter.h>
-
-
-iv::decition::DecitionVoter::DecitionVoter()
-{
-}
-
-iv::decition::DecitionVoter::~DecitionVoter()
-{
-}
-
-void iv::decition::DecitionVoter::decideFromAll(iv::decition::Decition & decition_final, iv::decition::Decition & decition_lidar, iv::decition::Decition & decition_radar, iv::decition::Decition & decition_camera, iv::decition::Decition & decition_gps, iv::decition::Decition & decition_localmap)
-{
-    //todo 按照优先级决定采用谁的决策  或融合采用
-    if (decition_gps != NULL) {
-        decition_final->speed = decition_gps->speed;
-        decition_final->wheel_angle = decition_gps->wheel_angle;
-        decition_final->accelerator = decition_gps->accelerator;
-        decition_final->brake = decition_gps->brake;
-    }
-
-}
+#include <decition/decition_voter.h>
+
+
+iv::decition::DecitionVoter::DecitionVoter()
+{
+}
+
+iv::decition::DecitionVoter::~DecitionVoter()
+{
+}
+
+void iv::decition::DecitionVoter::decideFromAll(iv::decition::Decition & decition_final, iv::decition::Decition & decition_lidar, iv::decition::Decition & decition_radar, iv::decition::Decition & decition_camera, iv::decition::Decition & decition_gps, iv::decition::Decition & decition_localmap)
+{
+    //todo 按照优先级决定采用谁的决策  或融合采用
+    if (decition_gps != NULL) {
+        decition_final->speed = decition_gps->speed;
+        decition_final->wheel_angle = decition_gps->wheel_angle;
+        decition_final->accelerator = decition_gps->accelerator;
+        decition_final->brake = decition_gps->brake;
+    }
+
+}

+ 28 - 28
src/decition/decition_brain/decition/decition_voter.h

@@ -1,28 +1,28 @@
-#pragma once
-//对来自不同传感器所作出的决策进行加权判断  得出最终的决策(速度、角度)
-//障碍物信息-激光雷达
-//障碍物信息-毫米波雷达
-//障碍物信息-摄像头
-//局部地图规划出的路线
-//GPS 惯导和导航数据计算得出的路线
-#ifndef _IV_DECITION_VOTER_
-#define _IV_DECITION_VOTER_
-
-#include <decition/decition_type.h>
-
-namespace iv {
-	namespace decition {
-		class DecitionVoter
-		{
-		public:
-			DecitionVoter();
-			~DecitionVoter();
-
-			void decideFromAll(iv::decition::Decition & decition_final,iv::decition::Decition & decition_lidar, iv::decition::Decition & decition_radar, iv::decition::Decition & decition_camera, iv::decition::Decition & decition_gps, iv::decition::Decition & decition_localmap);
-
-		private:
-
-		};
-	}
-}
-#endif // !_IV_DECITION_VOTER_
+#pragma once
+//对来自不同传感器所作出的决策进行加权判断  得出最终的决策(速度、角度)
+//障碍物信息-激光雷达
+//障碍物信息-毫米波雷达
+//障碍物信息-摄像头
+//局部地图规划出的路线
+//GPS 惯导和导航数据计算得出的路线
+#ifndef _IV_DECITION_VOTER_
+#define _IV_DECITION_VOTER_
+
+#include <decition/decition_type.h>
+
+namespace iv {
+	namespace decition {
+		class DecitionVoter
+		{
+		public:
+			DecitionVoter();
+			~DecitionVoter();
+
+			void decideFromAll(iv::decition::Decition & decition_final,iv::decition::Decition & decition_lidar, iv::decition::Decition & decition_radar, iv::decition::Decition & decition_camera, iv::decition::Decition & decition_gps, iv::decition::Decition & decition_localmap);
+
+		private:
+
+		};
+	}
+}
+#endif // !_IV_DECITION_VOTER_

+ 58 - 58
src/decition/decition_brain/decition/fanyaapi.cpp

@@ -1,58 +1,58 @@
-#include "fanyaapi.h"
-#include <QMutex>
-
-QMutex gMutexDecison;
-qint64 gTimeDecision = 0;
-double gdecision[3];
-
-using namespace fanya;
-
-
-
-void ListenDecision(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
-{
-    if(nSize < 3*sizeof(double))return;
-    gMutexDecison.lock();
-    memcpy(gdecision,strdata,3*sizeof(double));
-    gTimeDecision = QDateTime::currentMSecsSinceEpoch();
-    gMutexDecison.unlock();
-}
-
-fanyaapi::fanyaapi()
-{
-    mpa = iv::modulecomm::RegisterRecv("mpcdecision",ListenDecision);
-    mpb = iv::modulecomm::RegisterSend("GPS",1000,1);
-    mpc = iv::modulecomm::RegisterSend("MAP",10000000,1);
-    mpd = iv::modulecomm::RegisterSend("desiredspeed",1000,1);
-
-}
-
-int  fanyaapi::GetDecision(double &speed, double &decison, double &wheel)
-{
-    qint64 now = QDateTime::currentMSecsSinceEpoch();
-    if((now - gTimeDecision)> 1000)
-    {
-        return -1;
-    }
-    gMutexDecison.lock();
-    speed = gdecision[0];
-    decison = gdecision[1];
-    wheel = gdecision[2];
-    gMutexDecison.unlock();
-    return 0;
-}
-
-void fanyaapi::SetGPS(GPS_INS xgps)
-{
-    iv::modulecomm::ModuleSendMsg(mpb,(char *)&xgps,sizeof(GPS_INS));
-}
-
-void fanyaapi::SetMAP(std::vector<MAP_DATA> xvectorMAP)
-{
-    iv::modulecomm::ModuleSendMsg(mpc,(char *)xvectorMAP.data(),xvectorMAP.size() *sizeof(MAP_DATA));
-}
-
-void fanyaapi::SetDesiredspeed(double fspeed)
-{
-    iv::modulecomm::ModuleSendMsg(mpd,(char *)&fspeed,sizeof(fspeed));
-}
+#include "fanyaapi.h"
+#include <QMutex>
+
+QMutex gMutexDecison;
+qint64 gTimeDecision = 0;
+double gdecision[3];
+
+using namespace fanya;
+
+
+
+void ListenDecision(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
+{
+    if(nSize < 3*sizeof(double))return;
+    gMutexDecison.lock();
+    memcpy(gdecision,strdata,3*sizeof(double));
+    gTimeDecision = QDateTime::currentMSecsSinceEpoch();
+    gMutexDecison.unlock();
+}
+
+fanyaapi::fanyaapi()
+{
+    mpa = iv::modulecomm::RegisterRecv("mpcdecision",ListenDecision);
+    mpb = iv::modulecomm::RegisterSend("GPS",1000,1);
+    mpc = iv::modulecomm::RegisterSend("MAP",10000000,1);
+    mpd = iv::modulecomm::RegisterSend("desiredspeed",1000,1);
+
+}
+
+int  fanyaapi::GetDecision(double &speed, double &decison, double &wheel)
+{
+    qint64 now = QDateTime::currentMSecsSinceEpoch();
+    if((now - gTimeDecision)> 1000)
+    {
+        return -1;
+    }
+    gMutexDecison.lock();
+    speed = gdecision[0];
+    decison = gdecision[1];
+    wheel = gdecision[2];
+    gMutexDecison.unlock();
+    return 0;
+}
+
+void fanyaapi::SetGPS(GPS_INS xgps)
+{
+    iv::modulecomm::ModuleSendMsg(mpb,(char *)&xgps,sizeof(GPS_INS));
+}
+
+void fanyaapi::SetMAP(std::vector<MAP_DATA> xvectorMAP)
+{
+    iv::modulecomm::ModuleSendMsg(mpc,(char *)xvectorMAP.data(),xvectorMAP.size() *sizeof(MAP_DATA));
+}
+
+void fanyaapi::SetDesiredspeed(double fspeed)
+{
+    iv::modulecomm::ModuleSendMsg(mpd,(char *)&fspeed,sizeof(fspeed));
+}

+ 38 - 38
src/decition/decition_brain/decition/fanyaapi.h

@@ -1,38 +1,38 @@
-#ifndef FANYAAPI_H
-#define FANYAAPI_H
-
-#include <vector>
-#include "modulecomm.h"
-
-namespace fanya {
-struct GPS_INS        //惯导数据结构体
-{
-    double  gps_lat;  //纬度
-    double  gps_lng;  //经度
-    double  ins_heading; //航向
-    double  speed_y;   //纵向速度
-};
-struct MAP_DATA        //地图数据结构体
-{
-    double  gps_lat;  //纬度
-    double  gps_lng;  //经度
-    double  ins_heading; //航向
-};
-
-}
-
-
-class fanyaapi
-{
-public:
-    fanyaapi();
-    void SetGPS(fanya::GPS_INS xgps);
-    void SetMAP(std::vector<fanya::MAP_DATA> xvectorMAP);
-    void SetDesiredspeed(double fspeed);
-    int GetDecision(double & speed,double & decison, double & wheel);
-
-private:
-    void * mpa, * mpb, * mpc, * mpd;
-};
-
-#endif // FANYAAPI_H
+#ifndef FANYAAPI_H
+#define FANYAAPI_H
+
+#include <vector>
+#include "modulecomm.h"
+
+namespace fanya {
+struct GPS_INS        //惯导数据结构体
+{
+    double  gps_lat;  //纬度
+    double  gps_lng;  //经度
+    double  ins_heading; //航向
+    double  speed_y;   //纵向速度
+};
+struct MAP_DATA        //地图数据结构体
+{
+    double  gps_lat;  //纬度
+    double  gps_lng;  //经度
+    double  ins_heading; //航向
+};
+
+}
+
+
+class fanyaapi
+{
+public:
+    fanyaapi();
+    void SetGPS(fanya::GPS_INS xgps);
+    void SetMAP(std::vector<fanya::MAP_DATA> xvectorMAP);
+    void SetDesiredspeed(double fspeed);
+    int GetDecision(double & speed,double & decison, double & wheel);
+
+private:
+    void * mpa, * mpb, * mpc, * mpd;
+};
+
+#endif // FANYAAPI_H

+ 153 - 153
src/decition/decition_brain/decition/gnss_coordinate_convert.cpp

@@ -1,153 +1,153 @@
-#include <decition/gnss_coordinate_convert.h>
-
-void gps2xy(double J4, double K4, double *x, double *y)
-{
-    int L4 = (int)((K4 - 1.5) / 3) + 1;
-    double M4 = K4 - (L4 * 3);
-    double N4 = sin(J4 * 3.1415926536 / 180);
-    double O4 = cos(J4 * 3.1415926536 / 180);
-    double P4 = tan(J4 * 3.1415926536 / 180);
-    double Q4 = 111134.8611 * J4 - N4 * O4 * (32005.7799 + 133.9238 * N4 * N4 + 0.6973 * N4 * N4 * N4 * N4 + 0.0039 * N4 * N4 * N4 * N4 * N4 * N4);
-    double R4 = sqrt(0.006738525414683) * O4;
-    double S4 = sqrt(1 + R4 * R4);
-    double T4 = 6399698.901783 / S4;
-    double U4 = (T4 / S4) / S4;
-    double V4 = O4 * M4 * 3.1415926536 / 180;
-    double W4 = 0.5 + (5 - P4 * P4 + 9 * R4 * R4 + 4 * R4 * R4 * R4 * R4) * V4 * V4 / 24;
-    double X4 = V4 * V4 * V4 * V4 / 720 * (61 + (P4 * P4 - 58) * P4 * P4);
-    double Y4 = 1 + V4 * V4 * (1 - P4 * P4 + R4 * R4) / 6;
-    double Z4 = V4 * V4 * V4 * V4 * (5 - 18 * P4 * P4 * P4 * P4 * P4 * P4 + 14 * R4 * R4 - 58 * R4 * R4 * P4 * P4) / 120;
-
-    *y = Q4 + T4 * P4 * V4 * V4 * (W4 + X4);
-    *x = 500000 + T4 * V4 * (Y4 + Z4);
-}
-/*
-//高斯投影由经纬度(Unit:DD)反算大地坐标(含带号,Unit:Metres)
-void GaussProjCal(double longitude, double latitude, double *X, double *Y)
-{
-    int ProjNo = 0; int ZoneWide; ////带宽
-    double longitude1, latitude1, longitude0, latitude0, X0, Y0, xval, yval;
-    double a, f, e2, ee, NN, T, C, A, M, iPI;
-    iPI = 0.0174532925199433; ////3.1415926535898/180.0;
-    ZoneWide = 6; ////6度带宽
-    a = 6378245.0; f = 1.0 / 298.3; //54年北京坐标系参数
-                                    ////a=6378140.0; f=1/298.257; //80年西安坐标系参数
-    ProjNo = (int)(longitude / ZoneWide);
-    longitude0 = ProjNo * ZoneWide + ZoneWide / 2;
-    longitude0 = longitude0 * iPI;
-    latitude0 = 0;
-    longitude1 = longitude * iPI; //经度转换为弧度
-    latitude1 = latitude * iPI; //纬度转换为弧度
-    e2 = 2 * f - f * f;
-    ee = e2 * (1.0 - e2);
-    NN = a / sqrt(1.0 - e2 * sin(latitude1)*sin(latitude1));
-    T = tan(latitude1)*tan(latitude1);
-    C = ee * cos(latitude1)*cos(latitude1);
-    A = (longitude1 - longitude0)*cos(latitude1);
-    M = a * ((1 - e2 / 4 - 3 * e2*e2 / 64 - 5 * e2*e2*e2 / 256)*latitude1 - (3 * e2 / 8 + 3 * e2*e2 / 32 + 45 * e2*e2
-        *e2 / 1024)*sin(2 * latitude1)
-        + (15 * e2*e2 / 256 + 45 * e2*e2*e2 / 1024)*sin(4 * latitude1) - (35 * e2*e2*e2 / 3072)*sin(6 * latitude1));
-    xval = NN * (A + (1 - T + C)*A*A*A / 6 + (5 - 18 * T + T * T + 72 * C - 58 * ee)*A*A*A*A*A / 120);
-    yval = M + NN * tan(latitude1)*(A*A / 2 + (5 - T + 9 * C + 4 * C*C)*A*A*A*A / 24
-        + (61 - 58 * T + T * T + 600 * C - 330 * ee)*A*A*A*A*A*A / 720);
-    X0 = 1000000L * (ProjNo + 1) + 500000L;
-    Y0 = 0;
-    xval = xval + X0; yval = yval + Y0;
-    *X = xval;
-    *Y = yval;
-}
-*/
-
-
-//=======================zhaobo0904
-#define PI  3.14159265358979
-void GaussProjCal(double lon, double lat, double *X, double *Y)
-{
-    // 1975 年国际椭球体长半轴 a, 第一离心率 e2, 第二离心率 ep2
-    double a = 6378140.0;
-    double e2 = 0.006694384999588;
-    double ep2 = e2/(1-e2);
-
-    // 原点所在经度
-    double lon_origin = 6.0*int(lon/6) + 3.0;
-    lon_origin *= PI / 180.0;
-
-    double k0 = 0.9996;
-
-    // 角度转弧度
-    double lat1 = lat * PI / 180.0;
-    double lon1 = lon * PI / 180.0;
-
-
-    // 经线在该点处的曲率半径,
-    double N = a / sqrt(1 - e2*sin(lat1)*sin(lat1));
-
-
-    // 赤道到该点的经线长度近似值 M, 使用泰勒展开逐项积分然后取前四项.
-    // 这个近似值是将 N 作为纬度 \phi 的函数展开为泰勒计数, 然后在区间 [0, lat1] 上积分得到的.
-    // 首先计算前四项的系数 a1~a4.
-    double a1 = 1 - e2/4 - (3*e2*e2)/64 - (5*e2*e2*e2)/256;
-    double a2 = (3*e2)/8 + (3*e2*e2)/32 + (45*e2*e2*e2)/1024;
-    double a3 = (15*e2*e2)/256 + (45*e2*e2*e2)/1024;
-    double a4 = (35*e2*e2*e2)/3072;
-    double M = a * (a1*lat1 - a2*sin(2*lat1) + a3*sin(4*lat1) - a4*sin(6*lat1));
-
-    // 辅助量
-    double T = tan(lat1)*tan(lat1);
-    double C = ep2*cos(lat1)*cos(lat1);
-    double A = (lon1 - lon_origin)*cos(lat1);
-
-    *X = 500000.0 + k0 * N * (A + (1 - T + C)*(A*A*A)/6 + (5 - 18*T + T*T + 72*C - 58*ep2)*(A*A*A*A*A)/120);
-    *Y = M + N * tan(lat1) * ((A*A)/2 +
-                              (5 - T + 9*C + 4*C*C)*(A*A*A*A)/24 +
-                              (61 - 58*T + T*T + 600*C - 330*ep2)*(A*A*A*A*A*A)/720);
-
-
-    *Y *= k0;
-    return;
-}
-//==========================================================
-
-
-
-
-
-//高斯投影由大地坐标(Unit:Metres)反算经纬度(Unit:DD)
-void GaussProjInvCal(double X, double Y, double *longitude, double *latitude)
-{
-    int ProjNo; int ZoneWide; ////带宽
-    double longitude1, latitude1, longitude0, latitude0, X0, Y0, xval, yval;
-    double e1, e2, f, a, ee, NN, T, C, M, D, R, u, fai, iPI;
-    iPI = 0.0174532925199433; ////3.1415926535898/180.0;
-    a = 6378245.0; f = 1.0 / 298.3; //54年北京坐标系参数
-    ////a=6378140.0; f=1/298.257; //80年西安坐标系参数
-    ZoneWide = 6; ////6度带宽
-    ProjNo = (int)(X / 1000000L); //查找带号
-    longitude0 = (ProjNo - 1) * ZoneWide + ZoneWide / 2;
-    longitude0 = longitude0 * iPI; //中央经线
-    X0 = ProjNo * 1000000L + 500000L;
-    Y0 = 0;
-    xval = X - X0; yval = Y - Y0; //带内大地坐标
-    e2 = 2 * f - f * f;
-    e1 = (1.0 - sqrt(1 - e2)) / (1.0 + sqrt(1 - e2));
-    ee = e2 / (1 - e2);
-    M = yval;
-    u = M / (a*(1 - e2 / 4 - 3 * e2*e2 / 64 - 5 * e2*e2*e2 / 256));
-    fai = u + (3 * e1 / 2 - 27 * e1*e1*e1 / 32)*sin(2 * u) + (21 * e1*e1 / 16 - 55 * e1*e1*e1*e1 / 32)*sin(
-                4 * u)
-            + (151 * e1*e1*e1 / 96)*sin(6 * u) + (1097 * e1*e1*e1*e1 / 512)*sin(8 * u);
-    C = ee * cos(fai)*cos(fai);
-    T = tan(fai)*tan(fai);
-    NN = a / sqrt(1.0 - e2 * sin(fai)*sin(fai));
-    R = a * (1 - e2) / sqrt((1 - e2 * sin(fai)*sin(fai))*(1 - e2 * sin(fai)*sin(fai))*(1 - e2 * sin
-                                                                                       (fai)*sin(fai)));
-    D = xval / NN;
-    //计算经度(Longitude) 纬度(Latitude)
-    longitude1 = longitude0 + (D - (1 + 2 * T + C)*D*D*D / 6 + (5 - 2 * C + 28 * T - 3 * C*C + 8 * ee + 24 * T*T)*D
-                               *D*D*D*D / 120) / cos(fai);
-    latitude1 = fai - (NN*tan(fai) / R)*(D*D / 2 - (5 + 3 * T + 10 * C - 4 * C*C - 9 * ee)*D*D*D*D / 24
-                                         + (61 + 90 * T + 298 * C + 45 * T*T - 256 * ee - 3 * C*C)*D*D*D*D*D*D / 720);
-    //转换为度 DD
-    *longitude = longitude1 / iPI;
-    *latitude = latitude1 / iPI;
-}
+#include <decition/gnss_coordinate_convert.h>
+
+void gps2xy(double J4, double K4, double *x, double *y)
+{
+    int L4 = (int)((K4 - 1.5) / 3) + 1;
+    double M4 = K4 - (L4 * 3);
+    double N4 = sin(J4 * 3.1415926536 / 180);
+    double O4 = cos(J4 * 3.1415926536 / 180);
+    double P4 = tan(J4 * 3.1415926536 / 180);
+    double Q4 = 111134.8611 * J4 - N4 * O4 * (32005.7799 + 133.9238 * N4 * N4 + 0.6973 * N4 * N4 * N4 * N4 + 0.0039 * N4 * N4 * N4 * N4 * N4 * N4);
+    double R4 = sqrt(0.006738525414683) * O4;
+    double S4 = sqrt(1 + R4 * R4);
+    double T4 = 6399698.901783 / S4;
+    double U4 = (T4 / S4) / S4;
+    double V4 = O4 * M4 * 3.1415926536 / 180;
+    double W4 = 0.5 + (5 - P4 * P4 + 9 * R4 * R4 + 4 * R4 * R4 * R4 * R4) * V4 * V4 / 24;
+    double X4 = V4 * V4 * V4 * V4 / 720 * (61 + (P4 * P4 - 58) * P4 * P4);
+    double Y4 = 1 + V4 * V4 * (1 - P4 * P4 + R4 * R4) / 6;
+    double Z4 = V4 * V4 * V4 * V4 * (5 - 18 * P4 * P4 * P4 * P4 * P4 * P4 + 14 * R4 * R4 - 58 * R4 * R4 * P4 * P4) / 120;
+
+    *y = Q4 + T4 * P4 * V4 * V4 * (W4 + X4);
+    *x = 500000 + T4 * V4 * (Y4 + Z4);
+}
+/*
+//高斯投影由经纬度(Unit:DD)反算大地坐标(含带号,Unit:Metres)
+void GaussProjCal(double longitude, double latitude, double *X, double *Y)
+{
+    int ProjNo = 0; int ZoneWide; ////带宽
+    double longitude1, latitude1, longitude0, latitude0, X0, Y0, xval, yval;
+    double a, f, e2, ee, NN, T, C, A, M, iPI;
+    iPI = 0.0174532925199433; ////3.1415926535898/180.0;
+    ZoneWide = 6; ////6度带宽
+    a = 6378245.0; f = 1.0 / 298.3; //54年北京坐标系参数
+                                    ////a=6378140.0; f=1/298.257; //80年西安坐标系参数
+    ProjNo = (int)(longitude / ZoneWide);
+    longitude0 = ProjNo * ZoneWide + ZoneWide / 2;
+    longitude0 = longitude0 * iPI;
+    latitude0 = 0;
+    longitude1 = longitude * iPI; //经度转换为弧度
+    latitude1 = latitude * iPI; //纬度转换为弧度
+    e2 = 2 * f - f * f;
+    ee = e2 * (1.0 - e2);
+    NN = a / sqrt(1.0 - e2 * sin(latitude1)*sin(latitude1));
+    T = tan(latitude1)*tan(latitude1);
+    C = ee * cos(latitude1)*cos(latitude1);
+    A = (longitude1 - longitude0)*cos(latitude1);
+    M = a * ((1 - e2 / 4 - 3 * e2*e2 / 64 - 5 * e2*e2*e2 / 256)*latitude1 - (3 * e2 / 8 + 3 * e2*e2 / 32 + 45 * e2*e2
+        *e2 / 1024)*sin(2 * latitude1)
+        + (15 * e2*e2 / 256 + 45 * e2*e2*e2 / 1024)*sin(4 * latitude1) - (35 * e2*e2*e2 / 3072)*sin(6 * latitude1));
+    xval = NN * (A + (1 - T + C)*A*A*A / 6 + (5 - 18 * T + T * T + 72 * C - 58 * ee)*A*A*A*A*A / 120);
+    yval = M + NN * tan(latitude1)*(A*A / 2 + (5 - T + 9 * C + 4 * C*C)*A*A*A*A / 24
+        + (61 - 58 * T + T * T + 600 * C - 330 * ee)*A*A*A*A*A*A / 720);
+    X0 = 1000000L * (ProjNo + 1) + 500000L;
+    Y0 = 0;
+    xval = xval + X0; yval = yval + Y0;
+    *X = xval;
+    *Y = yval;
+}
+*/
+
+
+//=======================zhaobo0904
+#define PI  3.14159265358979
+void GaussProjCal(double lon, double lat, double *X, double *Y)
+{
+    // 1975 年国际椭球体长半轴 a, 第一离心率 e2, 第二离心率 ep2
+    double a = 6378140.0;
+    double e2 = 0.006694384999588;
+    double ep2 = e2/(1-e2);
+
+    // 原点所在经度
+    double lon_origin = 6.0*int(lon/6) + 3.0;
+    lon_origin *= PI / 180.0;
+
+    double k0 = 0.9996;
+
+    // 角度转弧度
+    double lat1 = lat * PI / 180.0;
+    double lon1 = lon * PI / 180.0;
+
+
+    // 经线在该点处的曲率半径,
+    double N = a / sqrt(1 - e2*sin(lat1)*sin(lat1));
+
+
+    // 赤道到该点的经线长度近似值 M, 使用泰勒展开逐项积分然后取前四项.
+    // 这个近似值是将 N 作为纬度 \phi 的函数展开为泰勒计数, 然后在区间 [0, lat1] 上积分得到的.
+    // 首先计算前四项的系数 a1~a4.
+    double a1 = 1 - e2/4 - (3*e2*e2)/64 - (5*e2*e2*e2)/256;
+    double a2 = (3*e2)/8 + (3*e2*e2)/32 + (45*e2*e2*e2)/1024;
+    double a3 = (15*e2*e2)/256 + (45*e2*e2*e2)/1024;
+    double a4 = (35*e2*e2*e2)/3072;
+    double M = a * (a1*lat1 - a2*sin(2*lat1) + a3*sin(4*lat1) - a4*sin(6*lat1));
+
+    // 辅助量
+    double T = tan(lat1)*tan(lat1);
+    double C = ep2*cos(lat1)*cos(lat1);
+    double A = (lon1 - lon_origin)*cos(lat1);
+
+    *X = 500000.0 + k0 * N * (A + (1 - T + C)*(A*A*A)/6 + (5 - 18*T + T*T + 72*C - 58*ep2)*(A*A*A*A*A)/120);
+    *Y = M + N * tan(lat1) * ((A*A)/2 +
+                              (5 - T + 9*C + 4*C*C)*(A*A*A*A)/24 +
+                              (61 - 58*T + T*T + 600*C - 330*ep2)*(A*A*A*A*A*A)/720);
+
+
+    *Y *= k0;
+    return;
+}
+//==========================================================
+
+
+
+
+
+//高斯投影由大地坐标(Unit:Metres)反算经纬度(Unit:DD)
+void GaussProjInvCal(double X, double Y, double *longitude, double *latitude)
+{
+    int ProjNo; int ZoneWide; ////带宽
+    double longitude1, latitude1, longitude0, latitude0, X0, Y0, xval, yval;
+    double e1, e2, f, a, ee, NN, T, C, M, D, R, u, fai, iPI;
+    iPI = 0.0174532925199433; ////3.1415926535898/180.0;
+    a = 6378245.0; f = 1.0 / 298.3; //54年北京坐标系参数
+    ////a=6378140.0; f=1/298.257; //80年西安坐标系参数
+    ZoneWide = 6; ////6度带宽
+    ProjNo = (int)(X / 1000000L); //查找带号
+    longitude0 = (ProjNo - 1) * ZoneWide + ZoneWide / 2;
+    longitude0 = longitude0 * iPI; //中央经线
+    X0 = ProjNo * 1000000L + 500000L;
+    Y0 = 0;
+    xval = X - X0; yval = Y - Y0; //带内大地坐标
+    e2 = 2 * f - f * f;
+    e1 = (1.0 - sqrt(1 - e2)) / (1.0 + sqrt(1 - e2));
+    ee = e2 / (1 - e2);
+    M = yval;
+    u = M / (a*(1 - e2 / 4 - 3 * e2*e2 / 64 - 5 * e2*e2*e2 / 256));
+    fai = u + (3 * e1 / 2 - 27 * e1*e1*e1 / 32)*sin(2 * u) + (21 * e1*e1 / 16 - 55 * e1*e1*e1*e1 / 32)*sin(
+                4 * u)
+            + (151 * e1*e1*e1 / 96)*sin(6 * u) + (1097 * e1*e1*e1*e1 / 512)*sin(8 * u);
+    C = ee * cos(fai)*cos(fai);
+    T = tan(fai)*tan(fai);
+    NN = a / sqrt(1.0 - e2 * sin(fai)*sin(fai));
+    R = a * (1 - e2) / sqrt((1 - e2 * sin(fai)*sin(fai))*(1 - e2 * sin(fai)*sin(fai))*(1 - e2 * sin
+                                                                                       (fai)*sin(fai)));
+    D = xval / NN;
+    //计算经度(Longitude) 纬度(Latitude)
+    longitude1 = longitude0 + (D - (1 + 2 * T + C)*D*D*D / 6 + (5 - 2 * C + 28 * T - 3 * C*C + 8 * ee + 24 * T*T)*D
+                               *D*D*D*D / 120) / cos(fai);
+    latitude1 = fai - (NN*tan(fai) / R)*(D*D / 2 - (5 + 3 * T + 10 * C - 4 * C*C - 9 * ee)*D*D*D*D / 24
+                                         + (61 + 90 * T + 298 * C + 45 * T*T - 256 * ee - 3 * C*C)*D*D*D*D*D*D / 720);
+    //转换为度 DD
+    *longitude = longitude1 / iPI;
+    *latitude = latitude1 / iPI;
+}

+ 26 - 26
src/decition/decition_brain/decition/gnss_coordinate_convert.h

@@ -1,26 +1,26 @@
-#pragma once
-#ifndef _IV_PERCEPTION_GNSS_CONVERT_
-#define _IV_PERCEPTION_GNSS_CONVERT_
-
-#include <math.h>
-//double nmeaConvert2Lat(string lat)
-//{
-//	Console.WriteLine(lat);
-//	double nmea_d = double.Parse(lat.Substring(0, 2));
-//	double nmea_m = double.Parse(lat.Substring(2, 6));
-//	return nmea_d + nmea_m / 60;
-//}
-//
-//double nmeaConvert2Lon(string lon)
-//{
-//	Console.WriteLine(lon);
-//	double nmea_d = double.Parse(lon.Substring(0, 3));
-//	double nmea_m = double.Parse(lon.Substring(3, 7));
-//	return nmea_d + nmea_m / 60;
-//}
-
-void gps2xy(double , double , double *, double *);
-void GaussProjCal(double longitude, double latitude, double *X, double *Y);
-void GaussProjInvCal(double X, double Y, double *longitude, double *latitude);
-
-#endif // !_IV_PERCEPTION_GNSS_CONVERT_
+#pragma once
+#ifndef _IV_PERCEPTION_GNSS_CONVERT_
+#define _IV_PERCEPTION_GNSS_CONVERT_
+
+#include <math.h>
+//double nmeaConvert2Lat(string lat)
+//{
+//	Console.WriteLine(lat);
+//	double nmea_d = double.Parse(lat.Substring(0, 2));
+//	double nmea_m = double.Parse(lat.Substring(2, 6));
+//	return nmea_d + nmea_m / 60;
+//}
+//
+//double nmeaConvert2Lon(string lon)
+//{
+//	Console.WriteLine(lon);
+//	double nmea_d = double.Parse(lon.Substring(0, 3));
+//	double nmea_m = double.Parse(lon.Substring(3, 7));
+//	return nmea_d + nmea_m / 60;
+//}
+
+void gps2xy(double , double , double *, double *);
+void GaussProjCal(double longitude, double latitude, double *X, double *Y);
+void GaussProjInvCal(double X, double Y, double *longitude, double *latitude);
+
+#endif // !_IV_PERCEPTION_GNSS_CONVERT_

+ 45 - 45
src/decition/decition_brain/decition/gps_distance.cpp

@@ -1,45 +1,45 @@
-#include <decition/gps_distance.h>
-#include <math.h>
-#define M_PI (3.1415926535897932384626433832795)
-
-// 计算弧度
-double iv::decition::rad(double d)
-{
-    const double PI = 3.1415926535898;
-    return d * PI / 180.0;
-}
-
-// 从两个gps坐标点(经纬度)获得两点的直线距离,单位是米
-double iv::decition::CalcDistance(double fLati1, double fLong1, double fLati2, double fLong2)
-{
-    const float EARTH_RADIUS = 6378.137;
-    double radLat1 = rad(fLati1);
-    double radLat2 = rad(fLati2);
-    double a = radLat1 - radLat2;
-
-    double b = rad(fLong1) - rad(fLong2);
-    double s = 2 * asin(sqrt(pow(sin(a / 2), 2) + cos(radLat1)*cos(radLat2)*pow(sin(b / 2), 2)));
-    s = s * EARTH_RADIUS;
-    //	s = (int)(s * 10000000) / 10000;
-    return s;
-}
-
-
-// 从直角坐标两点的直线距离,单位是米
-double iv::decition::DirectDistance(double x1, double y1, double x2, double y2)
-{
-    double s = sqrt(pow((x1-x2), 2) +pow((y1-y2), 2));
-    return s;
-}
-
-
-// 从直角坐标计算两点的夹角
-double iv::decition::DirectAngle(double x1, double y1, double x2, double y2)
-{
-    double angle = atan((y2 - y1) / (x2 - x1)) * 180 / M_PI;
-    return angle;
-}
-
-
-
-
+#include <decition/gps_distance.h>
+#include <math.h>
+#define M_PI (3.1415926535897932384626433832795)
+
+// 计算弧度
+double iv::decition::rad(double d)
+{
+    const double PI = 3.1415926535898;
+    return d * PI / 180.0;
+}
+
+// 从两个gps坐标点(经纬度)获得两点的直线距离,单位是米
+double iv::decition::CalcDistance(double fLati1, double fLong1, double fLati2, double fLong2)
+{
+    const float EARTH_RADIUS = 6378.137;
+    double radLat1 = rad(fLati1);
+    double radLat2 = rad(fLati2);
+    double a = radLat1 - radLat2;
+
+    double b = rad(fLong1) - rad(fLong2);
+    double s = 2 * asin(sqrt(pow(sin(a / 2), 2) + cos(radLat1)*cos(radLat2)*pow(sin(b / 2), 2)));
+    s = s * EARTH_RADIUS;
+    //	s = (int)(s * 10000000) / 10000;
+    return s;
+}
+
+
+// 从直角坐标两点的直线距离,单位是米
+double iv::decition::DirectDistance(double x1, double y1, double x2, double y2)
+{
+    double s = sqrt(pow((x1-x2), 2) +pow((y1-y2), 2));
+    return s;
+}
+
+
+// 从直角坐标计算两点的夹角
+double iv::decition::DirectAngle(double x1, double y1, double x2, double y2)
+{
+    double angle = atan((y2 - y1) / (x2 - x1)) * 180 / M_PI;
+    return angle;
+}
+
+
+
+

+ 26 - 26
src/decition/decition_brain/decition/gps_distance.h

@@ -1,26 +1,26 @@
-#pragma once
-#ifndef _IV_DECITION_GPS_DISTANCE_
-#define _IV_DECITION_GPS_DISTANCE_
-
-namespace iv {
-	namespace decition {
-        // 计算弧度
-		double rad(double d);
-
-		// 从两个gps坐标点(经纬度)获得两点的直线距离,单位是米
-		double CalcDistance(double , double , double , double );
-
-		//计算直角坐标距离
-		double DirectDistance(double, double, double, double);
-
-		//计算直角坐标角度
-		double DirectAngle(double, double, double, double);
-
-
-	}
-}
-
-
-
-
-#endif // !_IV_DECITION_GPS_DISTANCE_
+#pragma once
+#ifndef _IV_DECITION_GPS_DISTANCE_
+#define _IV_DECITION_GPS_DISTANCE_
+
+namespace iv {
+	namespace decition {
+        // 计算弧度
+		double rad(double d);
+
+		// 从两个gps坐标点(经纬度)获得两点的直线距离,单位是米
+		double CalcDistance(double , double , double , double );
+
+		//计算直角坐标距离
+		double DirectDistance(double, double, double, double);
+
+		//计算直角坐标角度
+		double DirectAngle(double, double, double, double);
+
+
+	}
+}
+
+
+
+
+#endif // !_IV_DECITION_GPS_DISTANCE_

+ 138 - 138
src/decition/decition_brain/decition/obs_predict.cpp

@@ -1,138 +1,138 @@
-#include <decition/transfer.h>
-#include <decition/decition_type.h>
-#include <math.h>
-#include <iostream>
-#include <fstream>
-using namespace std;
-#define PI (3.1415926535897932384626433832795)
-
-
-
-///大地转车体
-iv::Point2D iv::decition::Coordinate_Transfer(double x_path, double y_path, iv::GPS_INS pos)
-{
-    double x_vehicle, y_vehicle;
-    double theta = atan2(x_path - pos.gps_x, y_path - pos.gps_y);
-
-    double distance = sqrt((x_path - pos.gps_x) * (x_path - pos.gps_x) + (y_path - pos.gps_y) * (y_path - pos.gps_y));
-    double angle = theta - (-90 + pos.ins_heading_angle) / 180 * PI;
-
-    x_vehicle = -cos(angle) * distance;
-    y_vehicle = sin(angle) * distance;
-    return  iv::Point2D(x_vehicle, y_vehicle);
-}
-
-///车体转大地
-iv::GPS_INS iv::decition::Coordinate_UnTransfer(double x_path, double y_path, iv::GPS_INS pos)
-{
-    iv::GPS_INS gps_ins;
-    double x_vehicle, y_vehicle;
-    double theta = atan2(x_path, y_path);
-
-    double distance = sqrt(x_path * x_path + y_path * y_path);
-    double angle = (pos.ins_heading_angle / 180 * PI + theta);
-
-    x_vehicle = pos.gps_x + distance * sin(angle);
-    y_vehicle = pos.gps_y + distance * cos(angle);
-    gps_ins.gps_x = x_vehicle;
-    gps_ins.gps_y = y_vehicle;
-
-    return  gps_ins;
-}
-
-double iv::decition::GetDistance(iv::Point2D x1, iv::Point2D x2)
-{
-    return sqrt((x1.x - x2.x) * (x1.x - x2.x) + (x1.y - x2.y) * (x1.y - x2.y));
-}
-
-double iv::decition::GetDistance(iv::GPS_INS p1, iv::GPS_INS p2)
-{
-    return sqrt((p1.gps_x - p2.gps_x) * (p1.gps_x - p2.gps_x) + (p1.gps_y - p2.gps_y) * (p1.gps_y - p2.gps_y));
-}
-
-
-
-
-//GPS转大地坐标
-void iv::decition::BLH2XYZ(iv::GPS_INS gp)
-{
-    int nFlag = 2;
-
-    double B = gp.gps_lat;
-
-    double L = gp.gps_lng;
-
-
-
-    double N, E, h;
-    double L0 = GetL0InDegree(L);//根据经度求中央子午线经度
-
-    double a = 6378245.0;            //地球半径  北京6378245
-    double F = 298.257223563;        //地球扁率
-    double iPI = 0.0174532925199433; //2pi除以360,用于角度转换
-
-    double f = 1 / F;
-    double b = a * (1 - f);
-    double ee = (a * a - b * b) / (a * a);
-    double e2 = (a * a - b * b) / (b * b);
-    double n = (a - b) / (a + b), n2 = (n * n), n3 = (n2 * n), n4 = (n2 * n2), n5 = (n4 * n);
-    double al = (a + b) * (1 + n2 / 4 + n4 / 64) / 2;
-    double bt = -3 * n / 2 + 9 * n3 / 16 - 3 * n5 / 32;
-    double gm = 15 * n2 / 16 - 15 * n4 / 32;
-    double dt = -35 * n3 / 48 + 105 * n5 / 256;
-    double ep = 315 * n4 / 512;
-
-    B = B * iPI;
-    L = L * iPI;
-    L0 = L0 * iPI;
-
-    double l = L - L0, cl = (cos(B) * l), cl2 = (cl * cl), cl3 = (cl2 * cl), cl4 = (cl2 * cl2), cl5 = (cl4 * cl), cl6 = (cl5 * cl), cl7 = (cl6 * cl), cl8 = (cl4 * cl4);
-    double lB = al * (B + bt * sin(2 * B) + gm * sin(4 * B) + dt * sin(6 * B) + ep * sin(8 * B));
-    double t = tan(B), t2 = (t * t), t4 = (t2 * t2), t6 = (t4 * t2);
-    double Nn = a / sqrt(1 - ee * sin(B) * sin(B));
-    double yt = e2 * cos(B) * cos(B);
-    N = lB;
-    N += t * Nn * cl2 / 2;
-    N += t * Nn * cl4 * (5 - t2 + 9 * yt + 4 * yt * yt) / 24;
-    N += t * Nn * cl6 * (61 - 58 * t2 + t4 + 270 * yt - 330 * t2 * yt) / 720;
-    N += t * Nn * cl8 * (1385 - 3111 * t2 + 543 * t4 - t6) / 40320;
-
-    E = Nn * cl;
-    E += Nn * cl3 * (1 - t2 + yt) / 6;
-    E += Nn * cl5 * (5 - 18 * t2 + t4 + 14 * yt - 58 * t2 * yt) / 120;
-    E += Nn * cl7 * (61 - 479 * t2 + 179 * t4 - t6) / 5040;
-
-    E += 500000;
-    if (nFlag == 1)
-    {
-        //UTM投影
-        N = 0.9996 * N;
-        E = 0.9996 * (E - 500000.0) + 500000.0;//Get y
-    }
-    if (nFlag == 2)
-    {
-        //UTM投影
-        N = 0.9999 * N;
-        E = 0.9999 * (E - 500000.0) + 250000.0;//Get y
-    }
-
-    //原
-    //pt2d.x = N;
-    //pt2d.y = E;
-    //
-    gp.gps_x = E - 280000;
-    gp.gps_y = N - 4325000;
-
-}
-
-
-double iv::decition::GetL0InDegree(double dLIn)
-{
-    //3°带求带号及中央子午线经度(d的形式)
-    //具体公式请参阅《常用大地坐标系及其变换》朱华统,解放军出版社138页
-    double L = dLIn;//d.d
-    double L_ddd_Style = L;
-    double ZoneNumber = (int)((L_ddd_Style - 1.5) / 3.0) + 1;
-    double L0 = ZoneNumber * 3.0;//degree
-    return L0;
-}
+#include <decition/transfer.h>
+#include <decition/decition_type.h>
+#include <math.h>
+#include <iostream>
+#include <fstream>
+using namespace std;
+#define PI (3.1415926535897932384626433832795)
+
+
+
+///大地转车体
+iv::Point2D iv::decition::Coordinate_Transfer(double x_path, double y_path, iv::GPS_INS pos)
+{
+    double x_vehicle, y_vehicle;
+    double theta = atan2(x_path - pos.gps_x, y_path - pos.gps_y);
+
+    double distance = sqrt((x_path - pos.gps_x) * (x_path - pos.gps_x) + (y_path - pos.gps_y) * (y_path - pos.gps_y));
+    double angle = theta - (-90 + pos.ins_heading_angle) / 180 * PI;
+
+    x_vehicle = -cos(angle) * distance;
+    y_vehicle = sin(angle) * distance;
+    return  iv::Point2D(x_vehicle, y_vehicle);
+}
+
+///车体转大地
+iv::GPS_INS iv::decition::Coordinate_UnTransfer(double x_path, double y_path, iv::GPS_INS pos)
+{
+    iv::GPS_INS gps_ins;
+    double x_vehicle, y_vehicle;
+    double theta = atan2(x_path, y_path);
+
+    double distance = sqrt(x_path * x_path + y_path * y_path);
+    double angle = (pos.ins_heading_angle / 180 * PI + theta);
+
+    x_vehicle = pos.gps_x + distance * sin(angle);
+    y_vehicle = pos.gps_y + distance * cos(angle);
+    gps_ins.gps_x = x_vehicle;
+    gps_ins.gps_y = y_vehicle;
+
+    return  gps_ins;
+}
+
+double iv::decition::GetDistance(iv::Point2D x1, iv::Point2D x2)
+{
+    return sqrt((x1.x - x2.x) * (x1.x - x2.x) + (x1.y - x2.y) * (x1.y - x2.y));
+}
+
+double iv::decition::GetDistance(iv::GPS_INS p1, iv::GPS_INS p2)
+{
+    return sqrt((p1.gps_x - p2.gps_x) * (p1.gps_x - p2.gps_x) + (p1.gps_y - p2.gps_y) * (p1.gps_y - p2.gps_y));
+}
+
+
+
+
+//GPS转大地坐标
+void iv::decition::BLH2XYZ(iv::GPS_INS gp)
+{
+    int nFlag = 2;
+
+    double B = gp.gps_lat;
+
+    double L = gp.gps_lng;
+
+
+
+    double N, E, h;
+    double L0 = GetL0InDegree(L);//根据经度求中央子午线经度
+
+    double a = 6378245.0;            //地球半径  北京6378245
+    double F = 298.257223563;        //地球扁率
+    double iPI = 0.0174532925199433; //2pi除以360,用于角度转换
+
+    double f = 1 / F;
+    double b = a * (1 - f);
+    double ee = (a * a - b * b) / (a * a);
+    double e2 = (a * a - b * b) / (b * b);
+    double n = (a - b) / (a + b), n2 = (n * n), n3 = (n2 * n), n4 = (n2 * n2), n5 = (n4 * n);
+    double al = (a + b) * (1 + n2 / 4 + n4 / 64) / 2;
+    double bt = -3 * n / 2 + 9 * n3 / 16 - 3 * n5 / 32;
+    double gm = 15 * n2 / 16 - 15 * n4 / 32;
+    double dt = -35 * n3 / 48 + 105 * n5 / 256;
+    double ep = 315 * n4 / 512;
+
+    B = B * iPI;
+    L = L * iPI;
+    L0 = L0 * iPI;
+
+    double l = L - L0, cl = (cos(B) * l), cl2 = (cl * cl), cl3 = (cl2 * cl), cl4 = (cl2 * cl2), cl5 = (cl4 * cl), cl6 = (cl5 * cl), cl7 = (cl6 * cl), cl8 = (cl4 * cl4);
+    double lB = al * (B + bt * sin(2 * B) + gm * sin(4 * B) + dt * sin(6 * B) + ep * sin(8 * B));
+    double t = tan(B), t2 = (t * t), t4 = (t2 * t2), t6 = (t4 * t2);
+    double Nn = a / sqrt(1 - ee * sin(B) * sin(B));
+    double yt = e2 * cos(B) * cos(B);
+    N = lB;
+    N += t * Nn * cl2 / 2;
+    N += t * Nn * cl4 * (5 - t2 + 9 * yt + 4 * yt * yt) / 24;
+    N += t * Nn * cl6 * (61 - 58 * t2 + t4 + 270 * yt - 330 * t2 * yt) / 720;
+    N += t * Nn * cl8 * (1385 - 3111 * t2 + 543 * t4 - t6) / 40320;
+
+    E = Nn * cl;
+    E += Nn * cl3 * (1 - t2 + yt) / 6;
+    E += Nn * cl5 * (5 - 18 * t2 + t4 + 14 * yt - 58 * t2 * yt) / 120;
+    E += Nn * cl7 * (61 - 479 * t2 + 179 * t4 - t6) / 5040;
+
+    E += 500000;
+    if (nFlag == 1)
+    {
+        //UTM投影
+        N = 0.9996 * N;
+        E = 0.9996 * (E - 500000.0) + 500000.0;//Get y
+    }
+    if (nFlag == 2)
+    {
+        //UTM投影
+        N = 0.9999 * N;
+        E = 0.9999 * (E - 500000.0) + 250000.0;//Get y
+    }
+
+    //原
+    //pt2d.x = N;
+    //pt2d.y = E;
+    //
+    gp.gps_x = E - 280000;
+    gp.gps_y = N - 4325000;
+
+}
+
+
+double iv::decition::GetL0InDegree(double dLIn)
+{
+    //3°带求带号及中央子午线经度(d的形式)
+    //具体公式请参阅《常用大地坐标系及其变换》朱华统,解放军出版社138页
+    double L = dLIn;//d.d
+    double L_ddd_Style = L;
+    double ZoneNumber = (int)((L_ddd_Style - 1.5) / 3.0) + 1;
+    double L0 = ZoneNumber * 3.0;//degree
+    return L0;
+}

+ 27 - 27
src/decition/decition_brain/decition/transfer.h

@@ -1,27 +1,27 @@
-#pragma once
-#ifndef _IV_DECITION_TRANSFER_
-#define _IV_DECITION_TRANSFER_
-
-#include <common/gps_type.h>
-#include <decition/decition_type.h>
-#include<vector> 
-
-namespace iv {
-    namespace decition {
-        //根据传感器传输来的信息作出决策
-
-        double GetL0InDegree(double dLIn);
-
-        void BLH2XYZ(GPS_INS gps_ins);
-
-        ///大地转车体
-        Point2D Coordinate_Transfer(double x_path, double y_path, GPS_INS pos);
-
-        ///车体转大地
-        GPS_INS Coordinate_UnTransfer(double x_path, double y_path, GPS_INS pos);
-        double GetDistance(Point2D x1, Point2D x2);
-        double GetDistance(GPS_INS p1, GPS_INS p2);
-    }
-}
-
-#endif // ! _IV_DECITION_TRANSFER_
+#pragma once
+#ifndef _IV_DECITION_TRANSFER_
+#define _IV_DECITION_TRANSFER_
+
+#include <common/gps_type.h>
+#include <decition/decition_type.h>
+#include<vector> 
+
+namespace iv {
+    namespace decition {
+        //根据传感器传输来的信息作出决策
+
+        double GetL0InDegree(double dLIn);
+
+        void BLH2XYZ(GPS_INS gps_ins);
+
+        ///大地转车体
+        Point2D Coordinate_Transfer(double x_path, double y_path, GPS_INS pos);
+
+        ///车体转大地
+        GPS_INS Coordinate_UnTransfer(double x_path, double y_path, GPS_INS pos);
+        double GetDistance(Point2D x1, Point2D x2);
+        double GetDistance(GPS_INS p1, GPS_INS p2);
+    }
+}
+
+#endif // ! _IV_DECITION_TRANSFER_