Browse Source

fix namespace error

neozhaoliang 3 years ago
parent
commit
21de9fdc5b
100 changed files with 16112 additions and 423 deletions
  1. 24 0
      src/decition/build-decition_brain-unknown-Debug/.qmake.stash
  2. BIN
      src/decition/build-decition_brain-unknown-Debug/decition_brain
  3. 24 0
      src/decition/build-decition_brain_sf-unknown-Debug/.qmake.stash
  4. BIN
      src/decition/build-decition_brain_sf-unknown-Debug/decition_brain_sf
  5. 2 2
      src/decition/common/main.cpp
  6. 3 3
      src/decition/decition_brain/decision/adc_adapter/base_adapter.cpp
  7. 3 3
      src/decition/decition_brain/decision/adc_adapter/base_adapter.h
  8. 5 5
      src/decition/decition_brain/decision/adc_adapter/bus_adapter.cpp
  9. 3 3
      src/decition/decition_brain/decision/adc_adapter/bus_adapter.h
  10. 5 5
      src/decition/decition_brain/decision/adc_adapter/ge3_adapter.cpp
  11. 3 3
      src/decition/decition_brain/decision/adc_adapter/ge3_adapter.h
  12. 5 5
      src/decition/decition_brain/decision/adc_adapter/hapo_adapter.cpp
  13. 3 3
      src/decition/decition_brain/decision/adc_adapter/hapo_adapter.h
  14. 5 5
      src/decition/decition_brain/decision/adc_adapter/qingyuan_adapter.cpp
  15. 3 3
      src/decition/decition_brain/decision/adc_adapter/qingyuan_adapter.h
  16. 5 5
      src/decition/decition_brain/decision/adc_adapter/vv7_adapter.cpp
  17. 3 3
      src/decition/decition_brain/decision/adc_adapter/vv7_adapter.h
  18. 5 5
      src/decition/decition_brain/decision/adc_adapter/yuhesen_adapter.cpp
  19. 3 3
      src/decition/decition_brain/decision/adc_adapter/yuhesen_adapter.h
  20. 3 3
      src/decition/decition_brain/decision/adc_adapter/zhongche_adapter.cpp
  21. 3 3
      src/decition/decition_brain/decision/adc_adapter/zhongche_adapter.h
  22. 3 3
      src/decition/decition_brain/decision/adc_controller/base_controller.cpp
  23. 3 3
      src/decition/decition_brain/decision/adc_controller/base_controller.h
  24. 8 8
      src/decition/decition_brain/decision/adc_controller/pid_controller.cpp
  25. 3 3
      src/decition/decition_brain/decision/adc_controller/pid_controller.h
  26. 3 3
      src/decition/decition_brain/decision/adc_planner/base_planner.cpp
  27. 1 1
      src/decition/decition_brain/decision/adc_planner/base_planner.h
  28. 5 5
      src/decition/decition_brain/decision/adc_planner/dubins_planner.cpp
  29. 1 1
      src/decition/decition_brain/decision/adc_planner/dubins_planner.h
  30. 35 35
      src/decition/decition_brain/decision/adc_planner/frenet_planner.cpp
  31. 5 5
      src/decition/decition_brain/decision/adc_planner/frenet_planner.h
  32. 6 6
      src/decition/decition_brain/decision/adc_planner/lane_change_planner.cpp
  33. 1 1
      src/decition/decition_brain/decision/adc_planner/lane_change_planner.h
  34. 51 51
      src/decition/decition_brain/decision/adc_tools/compute_00.cpp
  35. 1 1
      src/decition/decition_brain/decision/adc_tools/compute_00.h
  36. 4 4
      src/decition/decition_brain/decision/adc_tools/gps_distance.cpp
  37. 1 1
      src/decition/decition_brain/decision/adc_tools/gps_distance.h
  38. 3 3
      src/decition/decition_brain/decision/adc_tools/parameter_status.h
  39. 6 6
      src/decition/decition_brain/decision/adc_tools/transfer.cpp
  40. 1 1
      src/decition/decition_brain/decision/adc_tools/transfer.h
  41. 46 46
      src/decition/decition_brain/decision/brain.cpp
  42. 6 6
      src/decition/decition_brain/decision/brain.h
  43. 1 1
      src/decition/decition_brain/decision/compute_00.h
  44. 104 104
      src/decition/decition_brain/decision/decide_gps_00.cpp
  45. 5 5
      src/decition/decition_brain/decision/decide_gps_00.h
  46. 4 4
      src/decition/decition_brain/decision/decide_line_00.h
  47. 42 42
      src/decition/decition_brain/decision/decide_line_00_.cpp
  48. 2 2
      src/decition/decition_brain/decision/decition_maker.h
  49. 1 1
      src/decition/decition_brain/decision/decition_type.h
  50. 2 2
      src/decition/decition_brain/decision/decition_voter.h
  51. 1 1
      src/decition/decition_brain/decision/gps_distance.h
  52. 5 5
      src/decition/decition_brain/decision/obs_predict.cpp
  53. 1 1
      src/decition/decition_brain/decision/obs_predict.h
  54. 26 0
      src/decition/decition_brain/decition/adc_adapter/base_adapter.cpp
  55. 42 0
      src/decition/decition_brain/decition/adc_adapter/base_adapter.h
  56. 325 0
      src/decition/decition_brain/decition/adc_adapter/bus_adapter.cpp
  57. 43 0
      src/decition/decition_brain/decition/adc_adapter/bus_adapter.h
  58. 193 0
      src/decition/decition_brain/decition/adc_adapter/ge3_adapter.cpp
  59. 60 0
      src/decition/decition_brain/decition/adc_adapter/ge3_adapter.h
  60. 357 0
      src/decition/decition_brain/decition/adc_adapter/hapo_adapter.cpp
  61. 43 0
      src/decition/decition_brain/decition/adc_adapter/hapo_adapter.h
  62. 312 0
      src/decition/decition_brain/decition/adc_adapter/qingyuan_adapter.cpp
  63. 41 0
      src/decition/decition_brain/decition/adc_adapter/qingyuan_adapter.h
  64. 150 0
      src/decition/decition_brain/decition/adc_adapter/vv7_adapter.cpp
  65. 44 0
      src/decition/decition_brain/decition/adc_adapter/vv7_adapter.h
  66. 153 0
      src/decition/decition_brain/decition/adc_adapter/yuhesen_adapter.cpp
  67. 44 0
      src/decition/decition_brain/decition/adc_adapter/yuhesen_adapter.h
  68. 179 0
      src/decition/decition_brain/decition/adc_adapter/zhongche_adapter.cpp
  69. 42 0
      src/decition/decition_brain/decition/adc_adapter/zhongche_adapter.h
  70. 39 0
      src/decition/decition_brain/decition/adc_controller/base_controller.cpp
  71. 67 0
      src/decition/decition_brain/decition/adc_controller/base_controller.h
  72. 352 0
      src/decition/decition_brain/decition/adc_controller/pid_controller.cpp
  73. 76 0
      src/decition/decition_brain/decition/adc_controller/pid_controller.h
  74. 40 0
      src/decition/decition_brain/decition/adc_planner/base_planner.cpp
  75. 48 0
      src/decition/decition_brain/decition/adc_planner/base_planner.h
  76. 57 0
      src/decition/decition_brain/decition/adc_planner/dubins_planner.cpp
  77. 44 0
      src/decition/decition_brain/decition/adc_planner/dubins_planner.h
  78. 643 0
      src/decition/decition_brain/decition/adc_planner/frenet_planner.cpp
  79. 159 0
      src/decition/decition_brain/decition/adc_planner/frenet_planner.h
  80. 196 0
      src/decition/decition_brain/decition/adc_planner/lane_change_planner.cpp
  81. 38 0
      src/decition/decition_brain/decition/adc_planner/lane_change_planner.h
  82. 2075 0
      src/decition/decition_brain/decition/adc_tools/compute_00.cpp
  83. 101 0
      src/decition/decition_brain/decition/adc_tools/compute_00.h
  84. 439 0
      src/decition/decition_brain/decition/adc_tools/dubins.cpp
  85. 149 0
      src/decition/decition_brain/decition/adc_tools/dubins.h
  86. 154 0
      src/decition/decition_brain/decition/adc_tools/gnss_coordinate_convert.cpp
  87. 26 0
      src/decition/decition_brain/decition/adc_tools/gnss_coordinate_convert.h
  88. 45 0
      src/decition/decition_brain/decition/adc_tools/gps_distance.cpp
  89. 26 0
      src/decition/decition_brain/decition/adc_tools/gps_distance.h
  90. 109 0
      src/decition/decition_brain/decition/adc_tools/parameter_status.h
  91. 138 0
      src/decition/decition_brain/decition/adc_tools/transfer.cpp
  92. 27 0
      src/decition/decition_brain/decition/adc_tools/transfer.h
  93. 1404 0
      src/decition/decition_brain/decition/brain.cpp
  94. 176 0
      src/decition/decition_brain/decition/brain.h
  95. 1843 0
      src/decition/decition_brain/decition/compute_00.cpp
  96. 96 0
      src/decition/decition_brain/decition/compute_00.h
  97. 605 0
      src/decition/decition_brain/decition/decide_from_gps.cpp
  98. 3902 0
      src/decition/decition_brain/decition/decide_gps_00.cpp
  99. 261 0
      src/decition/decition_brain/decition/decide_gps_00.h
  100. 252 0
      src/decition/decition_brain/decition/decide_line_00.h

+ 24 - 0
src/decition/build-decition_brain-unknown-Debug/.qmake.stash

@@ -0,0 +1,24 @@
+QMAKE_CXX.INCDIRS = \
+    /usr/include/c++/7 \
+    /usr/include/x86_64-linux-gnu/c++/7 \
+    /usr/include/c++/7/backward \
+    /usr/lib/gcc/x86_64-linux-gnu/7/include \
+    /usr/local/include \
+    /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed \
+    /usr/include/x86_64-linux-gnu \
+    /usr/include
+QMAKE_CXX.LIBDIRS = \
+    /usr/lib/gcc/x86_64-linux-gnu/7 \
+    /usr/lib/x86_64-linux-gnu \
+    /usr/lib \
+    /lib/x86_64-linux-gnu \
+    /lib
+QMAKE_CXX.QT_COMPILER_STDCXX = 201402L
+QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 7
+QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 5
+QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0
+QMAKE_CXX.COMPILER_MACROS = \
+    QT_COMPILER_STDCXX \
+    QMAKE_GCC_MAJOR_VERSION \
+    QMAKE_GCC_MINOR_VERSION \
+    QMAKE_GCC_PATCH_VERSION

BIN
src/decition/build-decition_brain-unknown-Debug/decition_brain


+ 24 - 0
src/decition/build-decition_brain_sf-unknown-Debug/.qmake.stash

@@ -0,0 +1,24 @@
+QMAKE_CXX.INCDIRS = \
+    /usr/include/c++/7 \
+    /usr/include/x86_64-linux-gnu/c++/7 \
+    /usr/include/c++/7/backward \
+    /usr/lib/gcc/x86_64-linux-gnu/7/include \
+    /usr/local/include \
+    /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed \
+    /usr/include/x86_64-linux-gnu \
+    /usr/include
+QMAKE_CXX.LIBDIRS = \
+    /usr/lib/gcc/x86_64-linux-gnu/7 \
+    /usr/lib/x86_64-linux-gnu \
+    /usr/lib \
+    /lib/x86_64-linux-gnu \
+    /lib
+QMAKE_CXX.QT_COMPILER_STDCXX = 201402L
+QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 7
+QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 5
+QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0
+QMAKE_CXX.COMPILER_MACROS = \
+    QT_COMPILER_STDCXX \
+    QMAKE_GCC_MAJOR_VERSION \
+    QMAKE_GCC_MINOR_VERSION \
+    QMAKE_GCC_PATCH_VERSION

BIN
src/decition/build-decition_brain_sf-unknown-Debug/decition_brain_sf


+ 2 - 2
src/decition/common/main.cpp

@@ -2,7 +2,7 @@
 
 #include "ivlog.h"
 
-#include "decision/brain.h"
+#include "decition/brain.h"
 
 #include "xmlparam.h"
 #include "ivversion.h"
@@ -42,7 +42,7 @@ int main(int argc, char *argv[])
     gstrmembrainstate = xp.GetParam("brainstate","brainstate");
     gstrmemchassis = xp.GetParam("chassismsgname","chassis");
 
-    iv::decision::BrainDecition brain;
+    iv::decition::BrainDecition brain;
     brain.inialize();
     brain.start();
     return a.exec();

+ 3 - 3
src/decition/decition_brain/decision/adc_adapter/base_adapter.cpp

@@ -8,16 +8,16 @@
 
 
 
-iv::decision::BaseAdapter::BaseAdapter(){
+iv::decition::BaseAdapter::BaseAdapter(){
 
 }
-iv::decision::BaseAdapter::~BaseAdapter(){
+iv::decition::BaseAdapter::~BaseAdapter(){
 
 }
 
 
 
- iv::decision::Decition  iv::decision::BaseAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  path , float dSpeed, float obsDistacne ,
+ iv::decition::Decition  iv::decition::BaseAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  path , float dSpeed, float obsDistacne ,
                                                                       float  obsSpeed,float accAim,float accNow  , bool changingDangWei, Decition *decition){
 
 

+ 3 - 3
src/decition/decition_brain/decision/adc_adapter/base_adapter.h

@@ -10,7 +10,7 @@
 #include <decision/adc_tools/gnss_coordinate_convert.h>
 
 namespace iv {
-namespace decision {
+namespace decition {
 
         class BaseAdapter {
         public:
@@ -23,8 +23,8 @@ namespace decision {
 
 
 
-        virtual  iv::decision::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
-                                                          float  obsSpeed,float accAim,float accNow, bool changingDangWei,Decition *decision);
+        virtual  iv::decition::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                          float  obsSpeed,float accAim,float accNow, bool changingDangWei,Decition *decition);
 
 
         private:

+ 5 - 5
src/decition/decition_brain/decision/adc_adapter/bus_adapter.cpp

@@ -9,17 +9,17 @@
 using namespace std;
 
 
-iv::decision::BusAdapter::BusAdapter(){
+iv::decition::BusAdapter::BusAdapter(){
     adapter_id=4;
     adapter_name="bus";
 }
-iv::decision::BusAdapter::~BusAdapter(){
+iv::decition::BusAdapter::~BusAdapter(){
 
 }
 
 
 
-iv::decision::Decition iv::decision::BusAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
+iv::decition::Decition iv::decition::BusAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
                                                                         float  obsSpeed,float accAim,float accNow  ,bool changingDangWei,Decition *decition){
     accAim=min(0.7f,accAim);
 
@@ -279,7 +279,7 @@ std::cout<<"========================================="<<std::endl;
 
 
 
-float iv::decision::BusAdapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
+float iv::decition::BusAdapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
 
     //刹车限制
 
@@ -315,7 +315,7 @@ float iv::decision::BusAdapter::limitBrake(float realSpeed, float controlBrake,f
 
 }
 
-float iv::decision::BusAdapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
+float iv::decition::BusAdapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
 
     controlSpeed=min((float)100.0,controlSpeed);
     controlSpeed=max((float)0.0,controlSpeed);

+ 3 - 3
src/decition/decition_brain/decision/adc_adapter/bus_adapter.h

@@ -13,7 +13,7 @@
 
 
 namespace iv {
-     namespace decision {
+     namespace decition {
          class BusAdapter: public BaseAdapter {
                     public:
 
@@ -25,8 +25,8 @@ namespace iv {
                         BusAdapter();
                         ~BusAdapter();
 
-                        iv::decision::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
-                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decision);
+                        iv::decition::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decition);
 
                         float limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc);
                         float limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed );

+ 5 - 5
src/decition/decition_brain/decision/adc_adapter/ge3_adapter.cpp

@@ -9,17 +9,17 @@
 using namespace std;
 
 
-iv::decision::Ge3Adapter::Ge3Adapter(){
+iv::decition::Ge3Adapter::Ge3Adapter(){
     adapter_id=0;
     adapter_name="ge3";
 }
-iv::decision::Ge3Adapter::~Ge3Adapter(){
+iv::decition::Ge3Adapter::~Ge3Adapter(){
 
 }
 
 
 
-iv::decision::Decition iv::decision::Ge3Adapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
+iv::decition::Decition iv::decition::Ge3Adapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
                                                                    float  obsSpeed,float accAim,float accNow  ,bool changingDangWei,Decition *decition){
 
 
@@ -123,7 +123,7 @@ iv::decision::Decition iv::decision::Ge3Adapter::getAdapterDeciton(GPS_INS now_g
 
 
 
-float iv::decision::Ge3Adapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
+float iv::decition::Ge3Adapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
 
     //刹车限制
 
@@ -165,7 +165,7 @@ float iv::decision::Ge3Adapter::limitBrake(float realSpeed, float controlBrake,f
 
 }
 
-float iv::decision::Ge3Adapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
+float iv::decition::Ge3Adapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
     if(controlBrake>0){
         controlSpeed=0;
     }

+ 3 - 3
src/decition/decition_brain/decision/adc_adapter/ge3_adapter.h

@@ -14,7 +14,7 @@
 
 
 namespace iv {
-     namespace decision {
+     namespace decition {
          class Ge3Adapter: public BaseAdapter {
                     public:
 
@@ -24,8 +24,8 @@ namespace iv {
                         Ge3Adapter();
                         ~Ge3Adapter();
 
-                        iv::decision::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
-                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decision);
+                        iv::decition::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decition);
 
                         float limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc);
                         float limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed );

+ 5 - 5
src/decition/decition_brain/decision/adc_adapter/hapo_adapter.cpp

@@ -10,18 +10,18 @@ QTime doorOpenTime;
 
 using namespace std;
 
-iv::decision::HapoAdapter::HapoAdapter(){
+iv::decition::HapoAdapter::HapoAdapter(){
     adapter_id=5;
     adapter_name="hapo";
 }
-iv::decision::HapoAdapter::~HapoAdapter(){
+iv::decition::HapoAdapter::~HapoAdapter(){
 
 }
 
 #include "ivlog.h"
 extern iv::Ivlog * givlog;
 
-iv::decision::Decition iv::decision::HapoAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
+iv::decition::Decition iv::decition::HapoAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
                                                                         float  obsSpeed,float accAim,float accNow  ,bool changingDangWei,Decition *decition){
     accAim=min(0.7f,accAim);
 
@@ -311,7 +311,7 @@ givlog->debug("obs_distance","dSpeed: %f, realSpeed: %f, brake: %f",
 
 
 
-float iv::decision::HapoAdapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
+float iv::decition::HapoAdapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
 
     //刹车限制
 
@@ -347,7 +347,7 @@ float iv::decision::HapoAdapter::limitBrake(float realSpeed, float controlBrake,
 
 }
 
-float iv::decision::HapoAdapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
+float iv::decition::HapoAdapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
 
     controlSpeed=min((float)100.0,controlSpeed);
     controlSpeed=max((float)0.0,controlSpeed);

+ 3 - 3
src/decition/decition_brain/decision/adc_adapter/hapo_adapter.h

@@ -13,7 +13,7 @@
 
 
 namespace iv {
-     namespace decision {
+     namespace decition {
          class HapoAdapter: public BaseAdapter {
                     public:
 
@@ -25,8 +25,8 @@ namespace iv {
                         HapoAdapter();
                         ~HapoAdapter();
 
-                        iv::decision::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
-                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decision);
+                        iv::decition::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decition);
 
                         float limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc);
                         float limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed );

+ 5 - 5
src/decition/decition_brain/decision/adc_adapter/qingyuan_adapter.cpp

@@ -9,17 +9,17 @@
 using namespace std;
 
 
-iv::decision::QingYuanAdapter::QingYuanAdapter(){
+iv::decition::QingYuanAdapter::QingYuanAdapter(){
     adapter_id=1;
     adapter_name="qingyuan";
 }
-iv::decision::QingYuanAdapter::~QingYuanAdapter(){
+iv::decition::QingYuanAdapter::~QingYuanAdapter(){
 
 }
 
 
 
-iv::decision::Decition iv::decision::QingYuanAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
+iv::decition::Decition iv::decition::QingYuanAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
                                                                         float  obsSpeed,float accAim,float accNow  ,bool changingDangWei,Decition *decition){
 
 
@@ -262,7 +262,7 @@ std::cout<<"========================================="<<std::endl;
 
 
 
-float iv::decision::QingYuanAdapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
+float iv::decition::QingYuanAdapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
 
     //刹车限制
 
@@ -302,7 +302,7 @@ float iv::decision::QingYuanAdapter::limitBrake(float realSpeed, float controlBr
 
 }
 
-float iv::decision::QingYuanAdapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
+float iv::decition::QingYuanAdapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
 
     controlSpeed=min((float)100.0,controlSpeed);
     controlSpeed=max((float)0.0,controlSpeed);

+ 3 - 3
src/decition/decition_brain/decision/adc_adapter/qingyuan_adapter.h

@@ -12,7 +12,7 @@
 
 
 namespace iv {
-     namespace decision {
+     namespace decition {
          class QingYuanAdapter: public BaseAdapter {
                     public:
 
@@ -24,8 +24,8 @@ namespace iv {
                         QingYuanAdapter();
                         ~QingYuanAdapter();
 
-                        iv::decision::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
-                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decision);
+                        iv::decition::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decition);
 
                         float limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc);
                         float limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed );

+ 5 - 5
src/decition/decition_brain/decision/adc_adapter/vv7_adapter.cpp

@@ -9,17 +9,17 @@
 using namespace std;
 
 
-iv::decision::VV7Adapter::VV7Adapter(){
+iv::decition::VV7Adapter::VV7Adapter(){
     adapter_id= 2;
     adapter_name="vv7";
 }
-iv::decision::VV7Adapter::~VV7Adapter(){
+iv::decition::VV7Adapter::~VV7Adapter(){
 
 }
 
 
 
-iv::decision::Decition iv::decision::VV7Adapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
+iv::decition::Decition iv::decition::VV7Adapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
                                                                         float  obsSpeed,float accAim,float accNow  ,bool changingDangWei,Decition *decition){
 
 
@@ -100,7 +100,7 @@ std::cout<<"========================================="<<std::endl;
 
 
 
-float iv::decision::VV7Adapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
+float iv::decition::VV7Adapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
 
     //刹车限制
 
@@ -140,7 +140,7 @@ float iv::decision::VV7Adapter::limitBrake(float realSpeed, float controlBrake,f
 
 }
 
-float iv::decision::VV7Adapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
+float iv::decition::VV7Adapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
 
     controlSpeed=min((float)5.0,controlSpeed);
     controlSpeed=max((float)-7.0,controlSpeed);

+ 3 - 3
src/decition/decition_brain/decision/adc_adapter/vv7_adapter.h

@@ -12,7 +12,7 @@
 
 
 namespace iv {
-     namespace decision {
+     namespace decition {
          class VV7Adapter: public BaseAdapter {
                     public:
 
@@ -24,8 +24,8 @@ namespace iv {
                         VV7Adapter();
                         ~VV7Adapter();
 
-                        iv::decision::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
-                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decision);
+                        iv::decition::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decition);
 
                         float limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc);
                         float limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed );

+ 5 - 5
src/decition/decition_brain/decision/adc_adapter/yuhesen_adapter.cpp

@@ -9,17 +9,17 @@
 using namespace std;
 
 
-iv::decision::YuHeSenAdapter::YuHeSenAdapter(){
+iv::decition::YuHeSenAdapter::YuHeSenAdapter(){
     adapter_id= 7;
     adapter_name="yuhesen";
 }
-iv::decision::YuHeSenAdapter::~YuHeSenAdapter(){
+iv::decition::YuHeSenAdapter::~YuHeSenAdapter(){
 
 }
 
 
 
-iv::decision::Decition iv::decision::YuHeSenAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
+iv::decition::Decition iv::decition::YuHeSenAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
                                                                         float  obsSpeed,float accAim,float accNow  ,bool changingDangWei,Decition *decition){
 
 
@@ -103,7 +103,7 @@ if((*decition)->brake>0){
 
 
 
-float iv::decision::YuHeSenAdapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
+float iv::decition::YuHeSenAdapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
 
     //刹车限制
 
@@ -143,7 +143,7 @@ float iv::decision::YuHeSenAdapter::limitBrake(float realSpeed, float controlBra
 
 }
 
-float iv::decision::YuHeSenAdapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
+float iv::decition::YuHeSenAdapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
 
     controlSpeed=min((float)5.0,controlSpeed);
     controlSpeed=max((float)-7.0,controlSpeed);

+ 3 - 3
src/decition/decition_brain/decision/adc_adapter/yuhesen_adapter.h

@@ -12,7 +12,7 @@
 
 
 namespace iv {
-     namespace decision {
+     namespace decition {
          class YuHeSenAdapter: public BaseAdapter {
                     public:
 
@@ -24,8 +24,8 @@ namespace iv {
                         YuHeSenAdapter();
                         ~YuHeSenAdapter();
 
-                        iv::decision::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
-                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decision);
+                        iv::decition::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decition);
 
                         float limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc);
                         float limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed );

+ 3 - 3
src/decition/decition_brain/decision/adc_adapter/zhongche_adapter.cpp

@@ -9,16 +9,16 @@
 using namespace std;
 
 
-iv::decision::ZhongcheAdapter::ZhongcheAdapter(){
+iv::decition::ZhongcheAdapter::ZhongcheAdapter(){
     adapter_id= 3;
     adapter_name="zhongche";
 }
-iv::decision::ZhongcheAdapter::~ZhongcheAdapter(){
+iv::decition::ZhongcheAdapter::~ZhongcheAdapter(){
 
 }
 
 
-iv::decision::Decition iv::decision::ZhongcheAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
+iv::decition::Decition iv::decition::ZhongcheAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
                                                                         float  obsSpeed,float accAim,float accNow  ,bool changingDangWei,Decition *decition){
 
 

+ 3 - 3
src/decition/decition_brain/decision/adc_adapter/zhongche_adapter.h

@@ -11,7 +11,7 @@
 #include <decision/decide_gps_00.h>
 
 namespace iv {
-     namespace decision {
+     namespace decition {
          class ZhongcheAdapter: public BaseAdapter {
                     public:
 
@@ -23,8 +23,8 @@ namespace iv {
                         ZhongcheAdapter();
                         ~ZhongcheAdapter();
 
-                        iv::decision::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
-                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decision);
+                        iv::decition::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decition);
 
                         float limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc);
                         float limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed );

+ 3 - 3
src/decition/decition_brain/decision/adc_controller/base_controller.cpp

@@ -8,10 +8,10 @@
 
 
 
-iv::decision::BaseController::BaseController(){
+iv::decition::BaseController::BaseController(){
 
 }
-iv::decision::BaseController::~BaseController(){
+iv::decition::BaseController::~BaseController(){
 
 }
 
@@ -30,7 +30,7 @@ iv::decision::BaseController::~BaseController(){
   * @return                     iv::decition::Decition
   */
 
- iv::decision::Decition  iv::decision::BaseController::getControlDecition(GPS_INS now_gps_ins, std::vector<Point2D> path, float dSpeed, float obsDistacne,
+ iv::decition::Decition  iv::decition::BaseController::getControlDecition(GPS_INS now_gps_ins, std::vector<Point2D> path, float dSpeed, float obsDistacne,
                                                                           float obsSpeed,bool computeAngle, bool computeAcc,Decition *decition){
 
 }

+ 3 - 3
src/decition/decition_brain/decision/adc_controller/base_controller.h

@@ -9,7 +9,7 @@
 #include <decision/adc_tools/gnss_coordinate_convert.h>
 
 namespace iv {
-namespace decision {
+namespace decition {
 //根据传感器传输来的信息作出决策
 class BaseController {
 public:
@@ -35,8 +35,8 @@ public:
       * @param decition             决策信息结构体的指针
       * @return                     iv::decition::Decition
       */
-    virtual  iv::decision::Decition getControlDecition(GPS_INS now_gps_ins, std::vector<Point2D>  path , float dSpeed, float obsDistacne , float  obsSpeed,
-                                                       bool computeAngle, bool computeAcc, Decition *decision);
+    virtual  iv::decition::Decition getControlDecition(GPS_INS now_gps_ins, std::vector<Point2D>  path , float dSpeed, float obsDistacne , float  obsSpeed,
+                                                       bool computeAngle, bool computeAcc, Decition *decition);
 
 
 private:

+ 8 - 8
src/decition/decition_brain/decision/adc_controller/pid_controller.cpp

@@ -9,11 +9,11 @@
 using namespace std;
 
 
-iv::decision::PIDController::PIDController(){
+iv::decition::PIDController::PIDController(){
     controller_id = 0;
     controller_name="pid";
 }
-iv::decision::PIDController::~PIDController(){
+iv::decition::PIDController::~PIDController(){
 
 }
 
@@ -34,7 +34,7 @@ iv::decision::PIDController::~PIDController(){
  * @return                     iv::decition::Decition
  */
 
-iv::decision::Decition iv::decision::PIDController::getControlDecition(GPS_INS now_gps_ins, std::vector<Point2D> path, float dSpeed, float obsDistacne, float obsSpeed,
+iv::decition::Decition iv::decition::PIDController::getControlDecition(GPS_INS now_gps_ins, std::vector<Point2D> path, float dSpeed, float obsDistacne, float obsSpeed,
                                                                        bool computeAngle, bool computeAcc, Decition *decition){
 
     float realSpeed= now_gps_ins.speed;
@@ -51,7 +51,7 @@ iv::decision::Decition iv::decision::PIDController::getControlDecition(GPS_INS n
 
 
 
-float iv::decision::PIDController::getPidAngle(float realSpeed, std::vector<Point2D> trace, int roadMode){
+float iv::decition::PIDController::getPidAngle(float realSpeed, std::vector<Point2D> trace, int roadMode){
     double ang = 0;
     double EPos = 0, EAng = 0;
 
@@ -147,7 +147,7 @@ float iv::decision::PIDController::getPidAngle(float realSpeed, std::vector<Poin
 
 
 
-float iv::decision::PIDController::getAveDef(std::vector<Point2D> farTrace){
+float iv::decition::PIDController::getAveDef(std::vector<Point2D> farTrace){
     double sum_x = 0;
     double sum_y = 0;
     for (int i = 0; i < min(5, (int)farTrace.size()); i++)
@@ -162,7 +162,7 @@ float iv::decision::PIDController::getAveDef(std::vector<Point2D> farTrace){
 
 
 
-float iv::decision::PIDController::getPidAcc (GPS_INS gpsIns,float dSpeed, float obsDistance, float obsSpeed){
+float iv::decition::PIDController::getPidAcc (GPS_INS gpsIns,float dSpeed, float obsDistance, float obsSpeed){
 
     std::cout << "\n计算用obs速度:%f\n" << obsSpeed << std::endl;
     std::cout << "\n计算用obs距离:%f\n" << obsDistance << std::endl;
@@ -256,7 +256,7 @@ float iv::decision::PIDController::getPidAcc (GPS_INS gpsIns,float dSpeed, float
 }
 
 
-float iv::decision::PIDController::computeU(float obsDistance, float ds,float vs,float vt,float vh,float vl,float ttc,float ttcr){
+float iv::decition::PIDController::computeU(float obsDistance, float ds,float vs,float vt,float vh,float vl,float ttc,float ttcr){
 
     double Id = 0;
     double ed = ds - obsDistance;
@@ -318,7 +318,7 @@ float iv::decision::PIDController::computeU(float obsDistance, float ds,float vs
 }
 
 
-float iv::decision::PIDController::limiteU(float u,float ttc){
+float iv::decition::PIDController::limiteU(float u,float ttc){
     if(ttc<3 && u<-0.2){
         u=-0.2;
     }

+ 3 - 3
src/decition/decition_brain/decision/adc_controller/pid_controller.h

@@ -10,7 +10,7 @@
 #include <decision/adc_tools/transfer.h>
 
 namespace iv {
-        namespace decision {
+        namespace decition {
         //根据传感器传输来的信息作出决策
                     class PIDController: public BaseController {
                     public:
@@ -46,8 +46,8 @@ namespace iv {
                            */
 
 
-                        iv::decision::Decition getControlDecition(GPS_INS now_gps_ins, std::vector<Point2D> path,float dSpeed, float obsDistacne,float  obsSpeed,
-                                                                  bool computeAngle, bool computeAcc, Decition *decision);
+                        iv::decition::Decition getControlDecition(GPS_INS now_gps_ins, std::vector<Point2D> path,float dSpeed, float obsDistacne,float  obsSpeed,
+                                                                  bool computeAngle, bool computeAcc, Decition *decition);
                         float  getPidAngle (float realSpeed, std::vector<Point2D> trace,int roadMode);
                         float  getAveDef (std::vector<Point2D> farTrace);
                         float  getPidAcc (GPS_INS gpsIns,float dSpeed, float obsDistacne, float obsSpeed);

+ 3 - 3
src/decition/decition_brain/decision/adc_planner/base_planner.cpp

@@ -12,10 +12,10 @@
 
 
 
-iv::decision::BasePlanner::BasePlanner(){
+iv::decition::BasePlanner::BasePlanner(){
 
 }
-iv::decision::BasePlanner::~BasePlanner(){
+iv::decition::BasePlanner::~BasePlanner(){
 
 }
 
@@ -31,7 +31,7 @@ iv::decision::BasePlanner::~BasePlanner(){
  * @param lidarGridPtr         激光雷达信息网格
  * @return                     返回一条车辆坐标系下的路径
  */
-std::vector<iv::Point2D> iv::decision::BasePlanner::getPath(GPS_INS now_gps_ins,const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr){
+std::vector<iv::Point2D> iv::decition::BasePlanner::getPath(GPS_INS now_gps_ins,const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr){
 
 }
 

+ 1 - 1
src/decition/decition_brain/decision/adc_planner/base_planner.h

@@ -9,7 +9,7 @@
 #include "perception/perceptionoutput.h"
 
 namespace iv {
-namespace decision {
+namespace decition {
 //根据传感器传输来的信息作出决策
     class BasePlanner {
     public:

+ 5 - 5
src/decition/decition_brain/decision/adc_planner/dubins_planner.cpp

@@ -5,14 +5,14 @@
 
 #include <math.h>
 
-std::vector<iv::GPSData> iv::decision::DubinsPlanner::gpsMap;
+std::vector<iv::GPSData> iv::decition::DubinsPlanner::gpsMap;
 
-iv::decision::DubinsPlanner::DubinsPlanner(){
+iv::decition::DubinsPlanner::DubinsPlanner(){
     this->planner_id = 2;
     this->planner_name = "Dubins";
 }
 
-iv::decision::DubinsPlanner::~DubinsPlanner(){
+iv::decition::DubinsPlanner::~DubinsPlanner(){
 }
 
 /**
@@ -26,7 +26,7 @@ iv::decision::DubinsPlanner::~DubinsPlanner(){
  * @param lidarGridPtr         激光雷达信息网格
  * @return                     返回一条车辆坐标系下的路径
  */
-std::vector<iv::Point2D> iv::decision::DubinsPlanner::getPath(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr){
+std::vector<iv::Point2D> iv::decition::DubinsPlanner::getPath(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr){
     std::vector<iv::Point2D> trace;
 
     double L = 2.6;
@@ -46,7 +46,7 @@ std::vector<iv::Point2D> iv::decision::DubinsPlanner::getPath(GPS_INS now_gps_in
 
 }
 
-int  iv::decision::DubinsPlanner::printConfiguration(double q[3], double x, void* user_data) {
+int  iv::decition::DubinsPlanner::printConfiguration(double q[3], double x, void* user_data) {
     GPSData gps;
     gps->roadMode=5;
     gps->gps_x=q[0];

+ 1 - 1
src/decition/decition_brain/decision/adc_planner/dubins_planner.h

@@ -13,7 +13,7 @@
 #include <string.h>
 
 namespace iv{
-namespace decision{
+namespace decition{
     class DubinsPlanner : public BasePlanner{
     public:
         DubinsPlanner();

+ 35 - 35
src/decition/decition_brain/decision/adc_planner/frenet_planner.cpp

@@ -11,13 +11,13 @@
 using namespace std;
 using namespace Eigen;
 
-iv::decision::FrenetPlanner::FrenetPlanner(){
+iv::decition::FrenetPlanner::FrenetPlanner(){
     this->planner_id = 1;
     this->planner_name = "Frenet";
     this->lidarGridPtr = NULL;
 }
 
-iv::decision::FrenetPlanner::~FrenetPlanner(){
+iv::decition::FrenetPlanner::~FrenetPlanner(){
     free(this->lidarGridPtr);
 }
 
@@ -34,7 +34,7 @@ iv::decision::FrenetPlanner::~FrenetPlanner(){
  * @param lidarGridPtr         激光雷达信息网格
  * @return                     返回一条车辆坐标系下的路径
  */
-std::vector<iv::Point2D> iv::decision::FrenetPlanner::getPath(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr){
+std::vector<iv::Point2D> iv::decition::FrenetPlanner::getPath(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr){
     this->roadNow = -1;
     this->now_gps_ins = now_gps_ins;
     this->gpsMapLine = gpsMapLine;
@@ -61,7 +61,7 @@ std::vector<iv::Point2D> iv::decision::FrenetPlanner::getPath(GPS_INS now_gps_in
  * @param lidarGridPtr         激光雷达信息网格
  * @return
  */
-int iv::decision::FrenetPlanner::chooseRoadByFrenet(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offsetL, double offsetR, iv::LidarGridPtr lidarGridPtr,int roadNow){
+int iv::decition::FrenetPlanner::chooseRoadByFrenet(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offsetL, double offsetR, iv::LidarGridPtr lidarGridPtr,int roadNow){
     this->roadNow = roadNow;
     this->aimRoadByFrenet = -1;
     this->now_gps_ins = now_gps_ins;
@@ -87,7 +87,7 @@ int iv::decision::FrenetPlanner::chooseRoadByFrenet(GPS_INS now_gps_ins, const s
  * @param realsecSpeed         实时车速 [m/s]
  * @return                     返回一条frenet规划后并转换到车辆坐标系下的路径
  */
-std::vector<iv::Point2D> iv::decision::FrenetPlanner::getGpsTrace_AfterCalcFrenetTrace(const std::vector<iv::Point2D>& gpsTrace,double realsecSpeed){
+std::vector<iv::Point2D> iv::decition::FrenetPlanner::getGpsTrace_AfterCalcFrenetTrace(const std::vector<iv::Point2D>& gpsTrace,double realsecSpeed){
     vector<Point2D> trace;
     vector<FrenetPoint> frenet_s;
     double stp=0.0;
@@ -95,7 +95,7 @@ std::vector<iv::Point2D> iv::decision::FrenetPlanner::getGpsTrace_AfterCalcFrene
     FrenetPoint tmp={.x=gpsTrace[0].x,.y=gpsTrace[0].y,.s=0.0,.d=0.0};
     frenet_s.push_back(tmp);
     for(int i=1; i<gpsTrace.size(); ++i){
-        stp+=iv::decision::GetDistance(gpsTrace[i-1],gpsTrace[i]);
+        stp+=iv::decition::GetDistance(gpsTrace[i-1],gpsTrace[i]);
         tmp={.x=gpsTrace[i].x,.y=gpsTrace[i].y,.s=stp,.d=0.0};
         frenet_s.push_back(tmp);
     }
@@ -126,7 +126,7 @@ std::vector<iv::Point2D> iv::decision::FrenetPlanner::getGpsTrace_AfterCalcFrene
  * @param c_d_dd               车辆沿d方向的加速度。
  * @return                     返回一条frenet规划的最优路径
  */
-vector<iv::Point2D> iv::decision::FrenetPlanner::frenet_optimal_planning(iv::decision::FrenetPoint car_now_frenet_point,
+vector<iv::Point2D> iv::decition::FrenetPlanner::frenet_optimal_planning(iv::decition::FrenetPoint car_now_frenet_point,
                                                           const std::vector<FrenetPoint>& frenet_s, double c_speed, double c_d_d, double c_d_dd){
     double s0 = car_now_frenet_point.s;
     double c_d = car_now_frenet_point.d;
@@ -173,8 +173,8 @@ vector<iv::Point2D> iv::decision::FrenetPlanner::frenet_optimal_planning(iv::dec
  * @param s0                   车辆沿s方向的坐标
  * @return                     返回多条frenet路径
  */
-vector<iv::decision::Frenet_path> iv::decision::FrenetPlanner::calc_frenet_paths(double c_speed, double c_d, double c_d_d, double c_d_dd, double s0){
-    vector<iv::decision::Frenet_path> frenet_paths;
+vector<iv::decition::Frenet_path> iv::decition::FrenetPlanner::calc_frenet_paths(double c_speed, double c_d, double c_d_d, double c_d_dd, double s0){
+    vector<iv::decition::Frenet_path> frenet_paths;
     int roadNum = round(abs((leftWidth-rightWidth)/ServiceParameterStatus.D_ROAD_W));   //roadNum为frenet算法的起始道路序号
     //采样,并对每一个目标配置生成轨迹
     for(double di=leftWidth; di<=rightWidth; di+=ServiceParameterStatus.D_ROAD_W,roadNum--){
@@ -241,7 +241,7 @@ vector<iv::decision::Frenet_path> iv::decision::FrenetPlanner::calc_frenet_paths
  * @param frenet_s             frenet坐标系的s轴
  * @return                     通过引用传递返回带有x,y值的多条frenet路径
  */
-void iv::decision::FrenetPlanner::calc_global_paths(vector<Frenet_path>& fplist,const std::vector<FrenetPoint>& frenet_s){
+void iv::decition::FrenetPlanner::calc_global_paths(vector<Frenet_path>& fplist,const std::vector<FrenetPoint>& frenet_s){
 
     for(auto& fp:fplist){
         for(int i=0; i<fp.s.size(); ++i){
@@ -269,7 +269,7 @@ void iv::decision::FrenetPlanner::calc_global_paths(vector<Frenet_path>& fplist,
     }
 }
 
-void iv::decision::FrenetPlanner::calc_global_single_path(Frenet_path &fp, const std::vector<FrenetPoint> &frenet_s){
+void iv::decition::FrenetPlanner::calc_global_single_path(Frenet_path &fp, const std::vector<FrenetPoint> &frenet_s){
     for(int i=0; i<fp.s.size(); ++i){
         double ix,iy;
         //            Frenet2XY(&ix,&iy,fp.s[i],fp.d[i],frenet_s);  //第一种方法
@@ -301,7 +301,7 @@ void iv::decision::FrenetPlanner::calc_global_single_path(Frenet_path &fp, const
  * @param fplist               多条frenet路径
  * @return                     排除部分路径后的多条frenet路径
  */
-vector<iv::decision::Frenet_path> iv::decision::FrenetPlanner::check_paths(const vector<Frenet_path>& fplist){
+vector<iv::decition::Frenet_path> iv::decition::FrenetPlanner::check_paths(const vector<Frenet_path>& fplist){
     vector<Frenet_path> okind;
     int i=0;
     int j=0;
@@ -329,7 +329,7 @@ vector<iv::decision::Frenet_path> iv::decision::FrenetPlanner::check_paths(const
 }
 
 
-bool iv::decision::FrenetPlanner::check_single_path(const iv::decision::Frenet_path &fp){
+bool iv::decition::FrenetPlanner::check_single_path(const iv::decition::Frenet_path &fp){
     int j=0;
 
     cout<<"&&&&&&&&&&fp.roadflag: "<<fp.roadflag<<endl;
@@ -359,10 +359,10 @@ bool iv::decision::FrenetPlanner::check_single_path(const iv::decision::Frenet_p
  * @param car_now_frenet_point 车辆当前位置在frenet坐标系下的坐标
  * @return                     在路径上有障碍物返回false,否则返回true。
  */
-bool iv::decision::FrenetPlanner::check_collision(const iv::decision::Frenet_path &frenet_path){
+bool iv::decition::FrenetPlanner::check_collision(const iv::decition::Frenet_path &frenet_path){
     std::vector<Point2D> gpsTrace = frenet_path_to_gpsTrace(frenet_path);
     double obs=-1;
-    iv::decision::DecideGps00().computeObsOnRoadByFrenet(this->lidarGridPtr,gpsTrace,obs,this->gpsMapLine,this->PathPoint,this->now_gps_ins);
+    iv::decition::DecideGps00().computeObsOnRoadByFrenet(this->lidarGridPtr,gpsTrace,obs,this->gpsMapLine,this->PathPoint,this->now_gps_ins);
     if(obs > 0 && obs < 30)
         return false;
     else
@@ -376,7 +376,7 @@ bool iv::decision::FrenetPlanner::check_collision(const iv::decision::Frenet_pat
  * @param frenet_path          一条frenet路径
  * @return                     一条车辆坐标系下的路径
  */
-vector<iv::Point2D> iv::decision::FrenetPlanner::frenet_path_to_gpsTrace(const Frenet_path& frenet_path){
+vector<iv::Point2D> iv::decition::FrenetPlanner::frenet_path_to_gpsTrace(const Frenet_path& frenet_path){
     vector<iv::Point2D> gpsTrace;
     for (int i=0; i<frenet_path.x.size(); ++i) {
         gpsTrace.push_back(Point2D(frenet_path.x[i],frenet_path.y[i]));
@@ -386,14 +386,14 @@ vector<iv::Point2D> iv::decision::FrenetPlanner::frenet_path_to_gpsTrace(const F
 }
 
 
-double iv::decision::FrenetPlanner::distance(double x1, double y1, double x2, double y2)
+double iv::decition::FrenetPlanner::distance(double x1, double y1, double x2, double y2)
 {
     return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
 }
 
 
 //找出gpsTrace中距离(x,y)最近的一个点
-int iv::decision::FrenetPlanner::ClosestWaypoint(double x, double y, const std::vector<Point2D>& gpsTrace)
+int iv::decition::FrenetPlanner::ClosestWaypoint(double x, double y, const std::vector<Point2D>& gpsTrace)
 {
 
     double closestLen = 100000; //large number
@@ -420,7 +420,7 @@ int iv::decision::FrenetPlanner::ClosestWaypoint(double x, double y, const std::
   * |==========================================================| */
  // 车体坐标转frenet坐标。frenet坐标原点是 gpsTrace 中序号为0的点。
  // Transform from Cartesian x,y coordinates to Frenet s,d coordinates
-iv::decision::FrenetPoint iv::decision::FrenetPlanner::XY2Frenet(double x, double y, const std::vector<iv::Point2D>& gpsTrace){
+iv::decition::FrenetPoint iv::decition::FrenetPlanner::XY2Frenet(double x, double y, const std::vector<iv::Point2D>& gpsTrace){
     int next_wp=ClosestWaypoint( x,  y,  gpsTrace);
     int prev_wp = next_wp-1;  //prev_wp代表在next_wp的前一个点计算坐标,能够保证frenet_s都是依次相加的。避免在next_wp计算frenet_s的话,可能出现减的情况。
 //    if(next_wp == 0){
@@ -468,7 +468,7 @@ iv::decision::FrenetPoint iv::decision::FrenetPlanner::XY2Frenet(double x, doubl
 
  // frenet坐标转车体坐标。
  // Transform from Frenet s,d coordinates to Cartesian x,y
-void iv::decision::FrenetPlanner::Frenet2XY(double *res_x, double *res_y, double s, double d, const vector<iv::decision::FrenetPoint>& frenetTrace){
+void iv::decition::FrenetPlanner::Frenet2XY(double *res_x, double *res_y, double s, double d, const vector<iv::decition::FrenetPoint>& frenetTrace){
     int prev_wp = 0;
     //退出循环时,prev_wp 最大是等于 frenetTrace.size()-2。
     while(s > frenetTrace[prev_wp+1].s && (prev_wp < (int)(frenetTrace.size()-2) )){
@@ -490,7 +490,7 @@ void iv::decision::FrenetPlanner::Frenet2XY(double *res_x, double *res_y, double
  * |         车辆坐标系与 frenet 坐标系互转的第二种方法。           |
  * |==========================================================| */
 // 车体坐标转frenet坐标。frenet坐标原点是 gpsTrace 中序号为0的点。
-iv::decision::FrenetPoint iv::decision::FrenetPlanner::getFrenetfromXY(double x, double y, const std::vector<iv::Point2D>& gpsTrace,const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps){
+iv::decition::FrenetPoint iv::decition::FrenetPlanner::getFrenetfromXY(double x, double y, const std::vector<iv::Point2D>& gpsTrace,const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps){
     int next_wp=ClosestWaypoint( x,  y,  gpsTrace);
     int prev_wp = next_wp-1;  //prev_wp代表在next_wp的前一个点计算坐标,能够保证frenet_s都是依次相加的。避免在next_wp计算frenet_s的话,可能出现减的情况。
     //    if(next_wp == 0){
@@ -514,7 +514,7 @@ iv::decision::FrenetPoint iv::decision::FrenetPlanner::getFrenetfromXY(double x,
     return {x:x,y:y,s:frenet_s,d:pt.x,tangent_Ang:tmp_Angle};
 }
 
-void iv::decision::FrenetPlanner::getXYfromFrenet(double *res_x, double *res_y, double s, double d, const vector<iv::decision::FrenetPoint>& frenetTrace,const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps)
+void iv::decition::FrenetPlanner::getXYfromFrenet(double *res_x, double *res_y, double s, double d, const vector<iv::decition::FrenetPoint>& frenetTrace,const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps)
 {
     int prev_wp = -1;
 
@@ -534,7 +534,7 @@ void iv::decision::FrenetPlanner::getXYfromFrenet(double *res_x, double *res_y,
 }
 
 
-iv::decision::Quintic_polynomial::Quintic_polynomial(double xs, double vxs, double axs, double xe, double vxe, double axe, double T){
+iv::decition::Quintic_polynomial::Quintic_polynomial(double xs, double vxs, double axs, double xe, double vxe, double axe, double T){
     //计算五次多项式系数
     this->xs = xs;
     this->vxs = vxs;
@@ -564,32 +564,32 @@ iv::decision::Quintic_polynomial::Quintic_polynomial(double xs, double vxs, doub
     this->a5 = x(2,0);
 }
 
-iv::decision::Quintic_polynomial::~Quintic_polynomial(){
+iv::decition::Quintic_polynomial::~Quintic_polynomial(){
 }
 
-double iv::decision::Quintic_polynomial::calc_point(double t){
+double iv::decition::Quintic_polynomial::calc_point(double t){
     double xt = this->a0 + this->a1 * t + this->a2 * t*t + this->a3 * t*t*t + this->a4 * t*t*t*t + this->a5 * t*t*t*t*t;
     return xt;
 }
 
-double iv::decision::Quintic_polynomial::calc_first_derivative(double t){
+double iv::decition::Quintic_polynomial::calc_first_derivative(double t){
     double xt = this->a1 + 2*this->a2 * t + 3*this->a3 * t*t + 4*this->a4 * t*t*t + 5*this->a5 * t*t*t*t;
     return xt;
 }
 
-double iv::decision::Quintic_polynomial::calc_second_derivative(double t){
+double iv::decition::Quintic_polynomial::calc_second_derivative(double t){
     double xt = 2*this->a2 + 6*this->a3 * t + 12*this->a4 * t*t + 20*this->a5 * t*t*t;
     return xt;
 }
 
-double iv::decision::Quintic_polynomial::calc_third_derivative(double t){
+double iv::decition::Quintic_polynomial::calc_third_derivative(double t){
     double xt = 6*this->a3 + 24*this->a4 * t + 60*this->a5 * t*t;
     return xt;
 }
 
 
 
-iv::decision::Quartic_polynomial::Quartic_polynomial(double xs, double vxs, double axs, double vxe, double axe, double T){
+iv::decition::Quartic_polynomial::Quartic_polynomial(double xs, double vxs, double axs, double vxe, double axe, double T){
     //计算四次多项式系数
     this->xs = xs;
     this->vxs = vxs;
@@ -615,29 +615,29 @@ iv::decision::Quartic_polynomial::Quartic_polynomial(double xs, double vxs, doub
     this->a4 = x(1,0);
 }
 
-iv::decision::Quartic_polynomial::~Quartic_polynomial(){
+iv::decition::Quartic_polynomial::~Quartic_polynomial(){
 }
 
-double iv::decision::Quartic_polynomial::calc_point(double t){
+double iv::decition::Quartic_polynomial::calc_point(double t){
     double xt = this->a0 + this->a1*t + this->a2*t*t + this->a3*t*t*t + this->a4*t*t*t*t;
     return xt;
 }
 
-double iv::decision::Quartic_polynomial::calc_first_derivative(double t){
+double iv::decition::Quartic_polynomial::calc_first_derivative(double t){
     double xt = this->a1 + 2*this->a2*t + 3*this->a3*t*t + 4*this->a4*t*t*t;
     return xt;
 }
 
-double iv::decision::Quartic_polynomial::calc_second_derivative(double t){
+double iv::decition::Quartic_polynomial::calc_second_derivative(double t){
     double xt = 2*this->a2 + 6*this->a3*t + 12*this->a4*t*t;
     return xt;
 }
 
-double iv::decision::Quartic_polynomial::calc_third_derivative(double t){
+double iv::decition::Quartic_polynomial::calc_third_derivative(double t){
     double xt = 6*this->a3 + 24*this->a4*t;
     return xt;
 }
 
-bool iv::decision::FrenetPlanner::comp(const iv::decision::Frenet_path &a, const iv::decision::Frenet_path &b){
+bool iv::decition::FrenetPlanner::comp(const iv::decition::Frenet_path &a, const iv::decition::Frenet_path &b){
     return a.cf < b.cf;
 }

+ 5 - 5
src/decition/decition_brain/decision/adc_planner/frenet_planner.h

@@ -4,7 +4,7 @@
 #include "base_planner.h"
 
 namespace iv{
-namespace decision{
+namespace decition{
 
     //x,y分别为frenet轨迹点相对于车辆的x,y轴坐标
     //s,d分别为frenet轨迹点相对于frenet坐标系的s,d轴坐标值
@@ -130,13 +130,13 @@ namespace decision{
          */
         std::vector<iv::Point2D> getPath(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr);
         int chooseRoadByFrenet(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offsetL, double offsetR, iv::LidarGridPtr lidarGridPtr,int roadNow);
-        static iv::decision::FrenetPoint XY2Frenet(double x, double y, const std::vector<Point2D>& gpsTracet);
-        static void Frenet2XY(double *x, double *y, double s, double d, const std::vector<iv::decision::FrenetPoint>& frenetTrace);
+        static iv::decition::FrenetPoint XY2Frenet(double x, double y, const std::vector<Point2D>& gpsTracet);
+        static void Frenet2XY(double *x, double *y, double s, double d, const std::vector<iv::decition::FrenetPoint>& frenetTrace);
         static double distance(double x1, double y1, double x2, double y2);
         static int ClosestWaypoint(double x, double y, const std::vector<Point2D>& gpsTrace);
         static FrenetPoint getFrenetfromXY(double x, double y, const std::vector<iv::Point2D>& gpsTrace,const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps);
-        static void getXYfromFrenet(double *res_x, double *res_y, double s, double d, const std::vector<iv::decision::FrenetPoint>& frenetTrace,const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps);
-        static bool comp(const iv::decision::Frenet_path &a,const iv::decision::Frenet_path &b);
+        static void getXYfromFrenet(double *res_x, double *res_y, double s, double d, const std::vector<iv::decition::FrenetPoint>& frenetTrace,const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps);
+        static bool comp(const iv::decition::Frenet_path &a,const iv::decition::Frenet_path &b);
 
     private:
         std::vector<iv::Point2D> getGpsTrace_AfterCalcFrenetTrace(const std::vector<iv::Point2D>& gpsTrace,double realsecSpeed);

+ 6 - 6
src/decition/decition_brain/decision/adc_planner/lane_change_planner.cpp

@@ -5,12 +5,12 @@
 
 #include <math.h>
 
-iv::decision::LaneChangePlanner::LaneChangePlanner(){
+iv::decition::LaneChangePlanner::LaneChangePlanner(){
     this->planner_id = 0;
     this->planner_name = "LaneChange";
 }
 
-iv::decision::LaneChangePlanner::~LaneChangePlanner(){
+iv::decition::LaneChangePlanner::~LaneChangePlanner(){
 }
 
 /**
@@ -24,7 +24,7 @@ iv::decision::LaneChangePlanner::~LaneChangePlanner(){
  * @param lidarGridPtr         激光雷达信息网格
  * @return                     返回一条车辆坐标系下的路径
  */
-std::vector<iv::Point2D> iv::decision::LaneChangePlanner::getPath(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr){
+std::vector<iv::Point2D> iv::decition::LaneChangePlanner::getPath(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr){
     std::vector<iv::Point2D> trace;
     trace = this->getGpsTrace(now_gps_ins,gpsMapLine,PathPoint);
     if(offset!=0){
@@ -33,7 +33,7 @@ std::vector<iv::Point2D> iv::decision::LaneChangePlanner::getPath(GPS_INS now_gp
     return trace;
 }
 
-bool iv::decision::LaneChangePlanner::checkAvoidEnable(const std::vector<double>& obsDisVector, int roadAim){
+bool iv::decition::LaneChangePlanner::checkAvoidEnable(const std::vector<double>& obsDisVector, int roadAim){
     int roadNow = ServiceParameterStatus.now_road_num;
     if ((obsDisVector[roadAim]>0 && obsDisVector[roadAim]<obsDisVector[roadNow]+ServiceCarStatus.msysparam.vehLenth)||
             (obsDisVector[roadAim]>0 && obsDisVector[roadAim]<15))
@@ -64,7 +64,7 @@ bool iv::decision::LaneChangePlanner::checkAvoidEnable(const std::vector<double>
     return true;
 }
 
-std::vector<iv::Point2D> iv::decision::LaneChangePlanner::getGpsTrace(iv::GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint){
+std::vector<iv::Point2D> iv::decition::LaneChangePlanner::getGpsTrace(iv::GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint){
     std::vector<iv::Point2D> trace;
 
     if (gpsMapLine.size() > 400 && PathPoint >= 0) {
@@ -137,7 +137,7 @@ std::vector<iv::Point2D> iv::decision::LaneChangePlanner::getGpsTrace(iv::GPS_IN
     return trace;
 }
 
-std::vector<iv::Point2D> iv::decision::LaneChangePlanner::getGpsTraceOffset(const std::vector<Point2D>& gpsTrace, double offset){
+std::vector<iv::Point2D> iv::decition::LaneChangePlanner::getGpsTraceOffset(const std::vector<Point2D>& gpsTrace, double offset){
     if (offset==0)
     {
         return gpsTrace;

+ 1 - 1
src/decition/decition_brain/decision/adc_planner/lane_change_planner.h

@@ -4,7 +4,7 @@
 #include "base_planner.h"
 
 namespace iv{
-namespace decision{
+namespace decition{
     class LaneChangePlanner : public BasePlanner{
     public:
         LaneChangePlanner();

+ 51 - 51
src/decition/decition_brain/decision/adc_tools/compute_00.cpp

@@ -12,35 +12,35 @@ using namespace std;
 
 #define PI (3.1415926535897932384626433832795)
 
-iv::decision::Compute00::Compute00() {
+iv::decition::Compute00::Compute00() {
 
 }
-iv::decision::Compute00::~Compute00() {
+iv::decition::Compute00::~Compute00() {
 
 }
 
 
-double iv::decision::Compute00::angleLimit = 700;
-double iv::decision::Compute00::lastEA = 0;
-double iv::decision::Compute00::lastEP = 0;
-double iv::decision::Compute00::decision_Angle = 0;
-double iv::decision::Compute00::lastAng = 0;
-int iv::decision::Compute00::lastEsrID = -1;
-int  iv::decision::Compute00::lastEsrCount = 0;
-int iv::decision::Compute00::lastEsrIDAvoid = -1;
-int  iv::decision::Compute00::lastEsrCountAvoid = 0;
+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::decision::Compute00::nearTpoint;
-iv::GPS_INS  iv::decision::Compute00::farTpoint;
-double  iv::decision::Compute00::bocheAngle;
+iv::GPS_INS  iv::decition::Compute00::nearTpoint;
+iv::GPS_INS  iv::decition::Compute00::farTpoint;
+double  iv::decition::Compute00::bocheAngle;
 
 
 
-iv::GPS_INS  iv::decision::Compute00::dTpoint0;
-iv::GPS_INS  iv::decision::Compute00::dTpoint1;
-iv::GPS_INS  iv::decision::Compute00::dTpoint2;
-iv::GPS_INS  iv::decision::Compute00::dTpoint3;
-double  iv::decision::Compute00::dBocheAngle;
+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;
@@ -48,7 +48,7 @@ std::vector<int> lastEsrCountVector;
 
 
 
-int iv::decision::Compute00::getDesiredSpeed(std::vector<GPSData> gpsMap)
+int iv::decition::Compute00::getDesiredSpeed(std::vector<GPSData> gpsMap)
 {
     int startIndex = 0;     // startIndex = 0 则每一次都是遍历整条地图路线
     int endIndex = gpsMap.size() - 1;
@@ -192,7 +192,7 @@ int iv::decision::Compute00::getDesiredSpeed(std::vector<GPSData> gpsMap)
 
 //首次找点
 
-int iv::decision::Compute00::getFirstNearestPointIndex(GPS_INS rp, std::vector<GPSData> gpsMap, int lastIndex, double mindis, double maxAngle)
+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;
@@ -225,7 +225,7 @@ int iv::decision::Compute00::getFirstNearestPointIndex(GPS_INS rp, std::vector<G
 }
 
 //search pathpoint
-int iv::decision::Compute00::getNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap, int lastIndex, double mindis, double maxAngle)
+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;
@@ -262,7 +262,7 @@ int iv::decision::Compute00::getNearestPointIndex(GPS_INS rp, const std::vector<
 }
 
 
-double iv::decision::Compute00::getAveDef(std::vector<Point2D> farTrace)
+double iv::decition::Compute00::getAveDef(std::vector<Point2D> farTrace)
 {
     double sum_x = 0;
     double sum_y = 0;
@@ -281,7 +281,7 @@ double iv::decision::Compute00::getAveDef(std::vector<Point2D> farTrace)
 
 
 
-double iv::decision::Compute00::getAvoidAveDef(std::vector<Point2D> farTrace, double avoidX)
+double iv::decition::Compute00::getAvoidAveDef(std::vector<Point2D> farTrace, double avoidX)
 {
     double sum_x = 0;
     double sum_y = 0;
@@ -303,7 +303,7 @@ double iv::decision::Compute00::getAvoidAveDef(std::vector<Point2D> farTrace, do
 
 
 
-double iv::decision::Compute00::getDecideAngle(std::vector<Point2D>  gpsTrace, double realSpeed) {
+double iv::decition::Compute00::getDecideAngle(std::vector<Point2D>  gpsTrace, double realSpeed) {
 
     double ang = 0;
     double EPos = 0, EAng = 0;
@@ -408,7 +408,7 @@ double iv::decision::Compute00::getDecideAngle(std::vector<Point2D>  gpsTrace, d
 
 
 
-int  iv::decision::Compute00::getSpeedPointIndex(std::vector<Point2D> gpsTrace, double realSpeed)
+int  iv::decition::Compute00::getSpeedPointIndex(std::vector<Point2D> gpsTrace, double realSpeed)
 {
     int index = 1;
     double sumdis = 0;
@@ -423,7 +423,7 @@ int  iv::decision::Compute00::getSpeedPointIndex(std::vector<Point2D> gpsTrace,
     return index;
 }
 
-iv::Point2D iv::decision::Compute00::getLidarObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
+iv::Point2D iv::decition::Compute00::getLidarObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
 
     iv::Point2D obsPoint(-1, -1);
     vector<Point2D> gpsTraceLeft;
@@ -547,7 +547,7 @@ iv::Point2D iv::decision::Compute00::getLidarObsPoint(std::vector<Point2D> gpsTr
 }
 
 //1220
-iv::Point2D iv::decision::Compute00::getLidarRearObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
+iv::Point2D iv::decition::Compute00::getLidarRearObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
 
     iv::Point2D obsPoint(-1, -1);
     vector<Point2D> gpsTraceLeft;
@@ -664,7 +664,7 @@ iv::Point2D iv::decision::Compute00::getLidarRearObsPoint(std::vector<Point2D> g
 }
 
 
-iv::Point2D iv::decision::Compute00::getLidarObsPointAvoid(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
+iv::Point2D iv::decition::Compute00::getLidarObsPointAvoid(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
 
     iv::Point2D obsPoint(-1, -1);
     vector<Point2D> gpsTraceLeft;
@@ -810,7 +810,7 @@ iv::Point2D iv::decision::Compute00::getLidarObsPointAvoid(std::vector<Point2D>
 
 
 
-int  iv::decision::Compute00::getEsrIndex(std::vector<Point2D> gpsTrace,int roadNum,int *esrPathpoint) {
+int  iv::decition::Compute00::getEsrIndex(std::vector<Point2D> gpsTrace,int roadNum,int *esrPathpoint) {
     bool isRemove = false;
 
     float xiuzheng=0;
@@ -874,7 +874,7 @@ int  iv::decision::Compute00::getEsrIndex(std::vector<Point2D> gpsTrace,int road
 
 
 
-int  iv::decision::Compute00::getRearEsrIndex(std::vector<Point2D> gpsTrace,int roadNum) {
+int  iv::decition::Compute00::getRearEsrIndex(std::vector<Point2D> gpsTrace,int roadNum) {
     bool isRemove = false;
 
     float xiuzheng = ServiceCarStatus.msysparam.rearRadarGpsXiuzheng;
@@ -977,7 +977,7 @@ int  iv::decision::Compute00::getRearEsrIndex(std::vector<Point2D> gpsTrace,int
 
 
 
-int  iv::decision::Compute00::getEsrIndexAvoid(std::vector<Point2D> gpsTrace) {
+int  iv::decition::Compute00::getEsrIndexAvoid(std::vector<Point2D> gpsTrace) {
     bool isRemove = false;
 
     for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
@@ -1047,7 +1047,7 @@ int  iv::decision::Compute00::getEsrIndexAvoid(std::vector<Point2D> gpsTrace) {
 
 
 
-double iv::decision::Compute00::getObsSpeed(Point2D obsPoint, double realSecSpeed) {
+double iv::decition::Compute00::getObsSpeed(Point2D obsPoint, double realSecSpeed) {
     double obsSpeed = 0 - realSecSpeed;
     double minDis = iv::MaxValue;
     for (int i = 0; i < 64; i++)
@@ -1073,7 +1073,7 @@ double iv::decision::Compute00::getObsSpeed(Point2D obsPoint, double realSecSpee
 
 
 
-double iv::decision::Compute00::getDecideAvoidAngle(std::vector<Point2D>  gpsTrace, double realSpeed, float avoidX) {
+double iv::decition::Compute00::getDecideAvoidAngle(std::vector<Point2D>  gpsTrace, double realSpeed, float avoidX) {
 
     double ang = 0;
     double EPos = 0, EAng = 0;
@@ -1165,7 +1165,7 @@ double iv::decision::Compute00::getDecideAvoidAngle(std::vector<Point2D>  gpsTra
 }
 
 
-std::vector<iv::GPSData>   iv::decision::Compute00::getBesideGpsMapLine(iv::GPS_INS now_gps_ins, vector<iv::GPSData>gpsMapLine, float avoidX) {
+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;
@@ -1267,7 +1267,7 @@ std::vector<iv::GPSData>   iv::decision::Compute00::getBesideGpsMapLine(iv::GPS_
 double IEPos = 0, IEang = 0;
 
 
-double iv::decision::Compute00::getDecideAngleByLanePID(double realSpeed) {
+double iv::decition::Compute00::getDecideAngleByLanePID(double realSpeed) {
 
     double ang = 0;
     double EPos = 0, EAng = 0;
@@ -1355,7 +1355,7 @@ double iv::decision::Compute00::getDecideAngleByLanePID(double realSpeed) {
 
 
 
-double iv::decision::Compute00::bocheCompute(GPS_INS nowGps, GPS_INS aimGps) {
+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);
@@ -1531,7 +1531,7 @@ double iv::decision::Compute00::bocheCompute(GPS_INS nowGps, GPS_INS aimGps) {
 
 
 //返回垂直平分线的斜率
-double iv::decision::Compute00::pingfenxian_xielv(double x_1, double y_1, double x_2, double y_2, double angle_1) {
+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))
     {
@@ -1589,7 +1589,7 @@ double iv::decision::Compute00::pingfenxian_xielv(double x_1, double y_1, double
 
 
 
-double iv::decision::Compute00::getQieXianAngle(GPS_INS nowGps, GPS_INS aimGps) {
+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;
@@ -1624,7 +1624,7 @@ double iv::decision::Compute00::getQieXianAngle(GPS_INS nowGps, GPS_INS aimGps)
   */
 
 
-int iv::decision::Compute00::bocheDirectCompute(GPS_INS nowGps, GPS_INS aimGps)
+int iv::decition::Compute00::bocheDirectCompute(GPS_INS nowGps, GPS_INS aimGps)
 {
 
 
@@ -1711,7 +1711,7 @@ int iv::decision::Compute00::bocheDirectCompute(GPS_INS nowGps, GPS_INS aimGps)
 }
 
 
-double iv::decision::Compute00::min_rad_zhuanxiang(double *R_M, double *min_rad) {
+double iv::decition::Compute00::min_rad_zhuanxiang(double *R_M, double *min_rad) {
     double L_c = 4.749;//车长
     double rad_1;
     double rad_2;
@@ -1728,7 +1728,7 @@ double iv::decision::Compute00::min_rad_zhuanxiang(double *R_M, double *min_rad)
 }
 
 
-double iv::decision::Compute00::qiedian_n(double x_1, double y_1, double R_M,double min_rad, double *x_2, double *y_2, double *real_rad ) {
+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)
     {
@@ -1747,7 +1747,7 @@ double iv::decision::Compute00::qiedian_n(double x_1, double y_1, double R_M,dou
 }
 
 
-double iv::decision::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 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))
@@ -1770,7 +1770,7 @@ double iv::decision::Compute00::liangzhixian_jiaodian(double x_1,double y_1,doub
 }
 
 
-double iv::decision::Compute00::chuizhipingfenxian_xielv(double x_1,double y_1,double ange1,double real_rad,double min_rad,double *angle_3) {
+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);
@@ -1804,7 +1804,7 @@ double iv::decision::Compute00::chuizhipingfenxian_xielv(double x_1,double y_1,d
 }
 
 
-double iv::decision::Compute00::yuanxin(double x_2,double y_2,double x_3,double y_3,double real_rad,double angle_3,double R_M,
+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;
@@ -1820,7 +1820,7 @@ double iv::decision::Compute00::yuanxin(double x_2,double y_2,double x_3,double
 }
 
 
-double iv::decision::Compute00::yuanxin_qiedian(double ange1,double x_o_1,double y_o_1, double x_o_2,double y_o_2,
+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)
 {
@@ -1983,7 +1983,7 @@ double iv::decision::Compute00::yuanxin_qiedian(double ange1,double x_o_1,double
 }
 
 
-int iv::decision::Compute00::getNoAngleNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap)
+int iv::decition::Compute00::getNoAngleNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap)
 {
     int index = -1;
     int startIndex = 0;     // startIndex = 0 则每一次都是遍历整条地图路线
@@ -2005,7 +2005,7 @@ int iv::decision::Compute00::getNoAngleNearestPointIndex(GPS_INS rp, const std::
 }
 
 
-double iv::decision::Compute00::getObsSpeedByFrenet(Point2D obsPoint, double realSecSpeed,const vector<Point2D> gpsTrace, std::vector<iv::GPSData> gpsMap,int pathpoint,GPS_INS nowGps) {
+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;
@@ -2022,7 +2022,7 @@ double iv::decision::Compute00::getObsSpeedByFrenet(Point2D obsPoint, double rea
                 {
                     minDis = tmpDis;
 //                    esr_obs_F_point = iv::decition::FrenetPlanner::XY2Frenet(xxx, yyy, gpsTrace);
-                    esr_obs_F_point = iv::decision::FrenetPlanner::getFrenetfromXY(xxx, yyy, gpsTrace,gpsMap,pathpoint,nowGps);
+                    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轴的速度
@@ -2040,7 +2040,7 @@ double iv::decision::Compute00::getObsSpeedByFrenet(Point2D obsPoint, double rea
 }
 
 
-int iv::decision::Compute00::getEsrIndexByFrenet(std::vector<Point2D> gpsTrace, FrenetPoint &esrObsPoint, std::vector<iv::GPSData> gpsMap,int pathpoint,GPS_INS nowGps){
+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;
 
@@ -2052,7 +2052,7 @@ int iv::decision::Compute00::getEsrIndexByFrenet(std::vector<Point2D> gpsTrace,
 
             //将毫米波障碍物位置转换到frenet坐标系下
 //            esrObsPoint = iv::decition::FrenetPlanner::XY2Frenet(xxx,yyy,gpsTrace);
-            esrObsPoint = iv::decision::FrenetPlanner::getFrenetfromXY(xxx,yyy,gpsTrace,gpsMap,pathpoint,nowGps);
+            esrObsPoint = iv::decition::FrenetPlanner::getFrenetfromXY(xxx,yyy,gpsTrace,gpsMap,pathpoint,nowGps);
 
             //如果障碍物与道路的横向距离d<=3.0*ServiceCarStatus.msysparam.vehWidth / 4.0,则认为道路上有障碍物。
             //s则可理解为障碍物距离。为障碍物与车辆沿着道路方向的距离,而不是空间上的x或y坐标或者直线距离。

+ 1 - 1
src/decition/decition_brain/decision/adc_tools/compute_00.h

@@ -9,7 +9,7 @@
 #include <decision/decide_gps_00.h>
 
 namespace iv {
-    namespace decision {
+    namespace decition {
     //根据传感器传输来的信息作出决策
         class Compute00 {
         public:

+ 4 - 4
src/decition/decition_brain/decision/adc_tools/gps_distance.cpp

@@ -3,14 +3,14 @@
 #define M_PI (3.1415926535897932384626433832795)
 
 // 计算弧度
-double iv::decision::rad(double d)
+double iv::decition::rad(double d)
 {
     const double PI = 3.1415926535898;
     return d * PI / 180.0;
 }
 
 // 从两个gps坐标点(经纬度)获得两点的直线距离,单位是米
-double iv::decision::CalcDistance(double fLati1, double fLong1, double fLati2, double fLong2)
+double iv::decition::CalcDistance(double fLati1, double fLong1, double fLati2, double fLong2)
 {
     const float EARTH_RADIUS = 6378.137;
     double radLat1 = rad(fLati1);
@@ -26,7 +26,7 @@ double iv::decision::CalcDistance(double fLati1, double fLong1, double fLati2, d
 
 
 // 从直角坐标两点的直线距离,单位是米
-double iv::decision::DirectDistance(double x1, double y1, double x2, double y2)
+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;
@@ -34,7 +34,7 @@ double iv::decision::DirectDistance(double x1, double y1, double x2, double y2)
 
 
 // 从直角坐标计算两点的夹角
-double iv::decision::DirectAngle(double x1, double y1, double x2, double y2)
+double iv::decition::DirectAngle(double x1, double y1, double x2, double y2)
 {
     double angle = atan((y2 - y1) / (x2 - x1)) * 180 / M_PI;
     return angle;

+ 1 - 1
src/decition/decition_brain/decision/adc_tools/gps_distance.h

@@ -3,7 +3,7 @@
 #define _IV_DECITION_GPS_DISTANCE_
 
 namespace iv {
-	namespace decision {
+	namespace decition {
         // 计算弧度
 		double rad(double d);
 

+ 3 - 3
src/decition/decition_brain/decision/adc_tools/parameter_status.h

@@ -10,7 +10,7 @@
 #include <control/vv7.h>
 
 namespace iv {
-    namespace decision {
+    namespace decition {
         class ParameterStatus : public boost::noncopyable
         {
         public:
@@ -99,9 +99,9 @@ namespace iv {
 
 
     };
-        typedef boost::serialization::singleton<iv::decision::ParameterStatus> ParameterStatusSingleton;
+        typedef boost::serialization::singleton<iv::decition::ParameterStatus> ParameterStatusSingleton;
 }
-#define ServiceParameterStatus iv::decision::ParameterStatusSingleton::get_mutable_instance()
+#define ServiceParameterStatus iv::decition::ParameterStatusSingleton::get_mutable_instance()
 
 }
 

+ 6 - 6
src/decition/decition_brain/decision/adc_tools/transfer.cpp

@@ -9,7 +9,7 @@ using namespace std;
 
 
 ///大地转车体
-iv::Point2D iv::decision::Coordinate_Transfer(double x_path, double y_path, iv::GPS_INS pos)
+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);
@@ -23,7 +23,7 @@ iv::Point2D iv::decision::Coordinate_Transfer(double x_path, double y_path, iv::
 }
 
 ///车体转大地
-iv::GPS_INS iv::decision::Coordinate_UnTransfer(double x_path, double y_path, iv::GPS_INS pos)
+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;
@@ -40,12 +40,12 @@ iv::GPS_INS iv::decision::Coordinate_UnTransfer(double x_path, double y_path, iv
     return  gps_ins;
 }
 
-double iv::decision::GetDistance(iv::Point2D x1, iv::Point2D x2)
+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::decision::GetDistance(iv::GPS_INS p1, iv::GPS_INS p2)
+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));
 }
@@ -54,7 +54,7 @@ double iv::decision::GetDistance(iv::GPS_INS p1, iv::GPS_INS p2)
 
 
 //GPS转大地坐标
-void iv::decision::BLH2XYZ(iv::GPS_INS gp)
+void iv::decition::BLH2XYZ(iv::GPS_INS gp)
 {
     int nFlag = 2;
 
@@ -126,7 +126,7 @@ void iv::decision::BLH2XYZ(iv::GPS_INS gp)
 }
 
 
-double iv::decision::GetL0InDegree(double dLIn)
+double iv::decition::GetL0InDegree(double dLIn)
 {
     //3°带求带号及中央子午线经度(d的形式)
     //具体公式请参阅《常用大地坐标系及其变换》朱华统,解放军出版社138页

+ 1 - 1
src/decition/decition_brain/decision/adc_tools/transfer.h

@@ -7,7 +7,7 @@
 #include<vector> 
 
 namespace iv {
-    namespace decision {
+    namespace decition {
         //根据传感器传输来的信息作出决策
 
         double GetL0InDegree(double dLIn);

+ 46 - 46
src/decition/decition_brain/decision/brain.cpp

@@ -21,8 +21,8 @@ extern std::string gstrmemchassis;
 #define LOG_ENABLE
 
 namespace iv {
-namespace decision {
-iv::decision::BrainDecition * gbrain;
+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)
@@ -110,7 +110,7 @@ iv::decision::BrainDecition * gbrain;
 
 
 
-iv::decision::BrainDecition::BrainDecition()
+iv::decition::BrainDecition::BrainDecition()
 {
     //    mpasd = new Adcivstatedb();
     look1 = 0.0;
@@ -129,40 +129,40 @@ iv::decision::BrainDecition::BrainDecition()
     eyes = new iv::perception::Eyes();
     //	decitionMaker = new iv::decition::DecitionMaker();
 
-    decitionGps00 = new iv::decision::DecideGps00();
-    decitionLine00=new iv::decision::DecideLine00();
+    decitionGps00 = new iv::decition::DecideGps00();
+    decitionLine00=new iv::decition::DecideLine00();
 
     //	decitionGpsUnit = new iv::decition::DecideGpsUnit();
 
     //	decitionExecuter = new iv::decition::DecitionExecuter(controller);
 
-    iv::decision::gbrain = this;
+    iv::decition::gbrain = this;
 
 
-    mpa = iv::modulecomm::RegisterRecv("tracemap",iv::decision::ListenTraceMap);
+    mpa = iv::modulecomm::RegisterRecv("tracemap",iv::decition::ListenTraceMap);
 
-    mpvbox = iv::modulecomm::RegisterRecv("vbox",iv::decision::ListenVbox);
+    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::decision::DecitionBasic),1);
+    mpaDecition = iv::modulecomm::RegisterSend(gstrmemdecition.data(),10*sizeof(iv::decition::DecitionBasic),1);
 
-    mpaPAD = iv::modulecomm::RegisterRecv("pad",iv::decision::ListenPAD);
-    mpaHMI = iv::modulecomm::RegisterRecv("hmi",iv::decision::ListenHMI);
+    mpaPAD = iv::modulecomm::RegisterRecv("pad",iv::decition::ListenPAD);
+    mpaHMI = iv::modulecomm::RegisterRecv("hmi",iv::decition::ListenHMI);
 
-    mpaPlatform = iv::modulecomm::RegisterRecv("platformfrom",iv::decision::ListenPlatform);
+    mpaPlatform = iv::modulecomm::RegisterRecv("platformfrom",iv::decition::ListenPlatform);
 
-    mpaGroup = iv::modulecomm::RegisterRecv("p900_send",iv::decision::ListenGroup);
+    mpaGroup = iv::modulecomm::RegisterRecv("p900_send",iv::decition::ListenGroup);
  //   iv::modulecomm::RegisterRecv("map_index",ListenMap_change_req);
 
-    v2x = iv::modulecomm::RegisterRecv("v2x",iv::decision::Listenv2x);
-    ultra = iv::modulecomm::RegisterRecv("ultra",iv::decision::Listenultra);
+    v2x = iv::modulecomm::RegisterRecv("v2x",iv::decition::Listenv2x);
+    ultra = iv::modulecomm::RegisterRecv("ultra",iv::decition::Listenultra);
 
     mpamapreq = iv::modulecomm::RegisterSend("mapreq",1000,1);
 
-    ModuleFun funchassis =std::bind(&iv::decision::BrainDecition::UpdateChassis,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
+    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);
@@ -174,29 +174,29 @@ iv::decision::BrainDecition::BrainDecition()
 
 }
 
-iv::decision::BrainDecition::~BrainDecition()
+iv::decition::BrainDecition::~BrainDecition()
 {
 }
 
 
-void iv::decision::BrainDecition::inialize() {
+void iv::decition::BrainDecition::inialize() {
     //	controller->inialize();
     eyes->inialize();
     //    carcall->start();
 }
 
 
-void iv::decision::BrainDecition::run() {
+void iv::decition::BrainDecition::run() {
 
     double last = 0;
 
-    iv::decision::Decition decition_gps = NULL;
-    iv::decision::Decition decition_lidar = NULL;
-    iv::decision::Decition decition_radar = NULL;
-    iv::decision::Decition decition_camera = NULL;
-    iv::decision::Decition decition_localmap = NULL;
+    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::decision::Decition dgtemp(new iv::decision::DecitionBasic);
+    iv::decition::Decition dgtemp(new iv::decition::DecitionBasic);
     decition_gps = dgtemp;
     decition_gps->brake = 0;
     decition_gps->accelerator = 0;
@@ -556,7 +556,7 @@ void iv::decision::BrainDecition::run() {
 
         iv::ObsLiDAR obs_lidar_tmp(new std::vector<iv::ObstacleBasic>);
         iv::ObsRadar obs_radar_tmp(new std::vector<iv::ObstacleBasic>);
-        iv::decision::Decition decition_final(new iv::decision::DecitionBasic);
+        iv::decition::Decition decition_final(new iv::decition::DecitionBasic);
 
         if (obs_lidar_) {	//激光雷达有障碍物
             //          std::cout<<"obs lidar size = "<<obs_lidar_->size()<<std::endl;
@@ -806,7 +806,7 @@ void iv::decision::BrainDecition::run() {
     std::cout << "\n\n\n\n\n\n\n\n\n\n\nbrain线程退出\n" << std::endl;
 }
 
-bool iv::decision::BrainDecition::loadMapFromFile(std::string fileName) {
+bool iv::decition::BrainDecition::loadMapFromFile(std::string fileName) {
     std::ifstream fis(fileName);//获取文件
     std::string line;
     std::vector<std::string> des;
@@ -856,7 +856,7 @@ bool iv::decision::BrainDecition::loadMapFromFile(std::string fileName) {
     return true;
 }
 
-bool iv::decision::BrainDecition::loadMapFromFile2(std::string fileName) {
+bool iv::decition::BrainDecition::loadMapFromFile2(std::string fileName) {
     std::ifstream fis(fileName);//获取文件
     std::string line;
     std::vector<std::string> des;
@@ -892,7 +892,7 @@ bool iv::decision::BrainDecition::loadMapFromFile2(std::string fileName) {
     return true;
 }
 
-bool iv::decision::BrainDecition::loadMapFromFile3(std::string fileName) {
+bool iv::decition::BrainDecition::loadMapFromFile3(std::string fileName) {
     std::ifstream fis(fileName);//获取文件
     std::string line;
     std::vector<std::string> des;
@@ -928,7 +928,7 @@ bool iv::decision::BrainDecition::loadMapFromFile3(std::string fileName) {
     return true;
 }
 
-bool iv::decision::BrainDecition::loadMapFromFile4(std::string fileName) {
+bool iv::decition::BrainDecition::loadMapFromFile4(std::string fileName) {
     std::ifstream fis(fileName);//获取文件
     std::string line;
     std::vector<std::string> des;
@@ -964,17 +964,17 @@ bool iv::decision::BrainDecition::loadMapFromFile4(std::string fileName) {
     return true;
 }
 
-void iv::decision::BrainDecition::start() {
-    thread_run = new boost::thread(boost::bind(&iv::decision::BrainDecition::run, this));
+void iv::decition::BrainDecition::start() {
+    thread_run = new boost::thread(boost::bind(&iv::decition::BrainDecition::run, this));
 }
 
-void iv::decision::BrainDecition::stop() {
+void iv::decition::BrainDecition::stop() {
     //    carcall->stop();
     thread_run->interrupt();
     thread_run->join();
 }
 
-void iv::decision::BrainDecition::UpdateMap(const char *mapdata, const int mapdatasize)
+void iv::decition::BrainDecition::UpdateMap(const char *mapdata, const int mapdatasize)
 {
     //    std::cout<<"update map "<<std::endl;
     int gpsunitsize = sizeof(iv::GPS_INS);
@@ -1036,7 +1036,7 @@ void iv::decision::BrainDecition::UpdateMap(const char *mapdata, const int mapda
     }
 }
 
-void iv::decision::BrainDecition::ShareDecition(iv::decision::Decition decition)
+void iv::decition::BrainDecition::ShareDecition(iv::decition::Decition decition)
 {
     iv::brain::decition xdecition;
     xdecition.set_accelerator(decition->accelerator);
@@ -1111,7 +1111,7 @@ void iv::decision::BrainDecition::ShareDecition(iv::decision::Decition decition)
     }
 }
 
-void iv::decision::BrainDecition::ShareBrainstate(iv::brain::brainstate xbs)
+void iv::decition::BrainDecition::ShareBrainstate(iv::brain::brainstate xbs)
 {
     int nsize = xbs.ByteSize();
     char * str = new char[nsize];
@@ -1127,7 +1127,7 @@ void iv::decision::BrainDecition::ShareBrainstate(iv::brain::brainstate xbs)
     }
 }
 
-void iv::decision::BrainDecition::UpdateHMI(const char *pdata, const int ndatasize)
+void iv::decition::BrainDecition::UpdateHMI(const char *pdata, const int ndatasize)
 {
     if(ndatasize < sizeof(iv::hmi::HMIBasic))return;
 
@@ -1156,7 +1156,7 @@ void iv::decision::BrainDecition::UpdateHMI(const char *pdata, const int ndatasi
 
 }
 
-void iv::decision::BrainDecition::UpdatePAD(const char *pdata, const int ndatasize)
+void iv::decition::BrainDecition::UpdatePAD(const char *pdata, const int ndatasize)
 {
 //    if(ndatasize < sizeof(iv::hmi::HMIBasic))return;
 
@@ -1185,7 +1185,7 @@ void iv::decision::BrainDecition::UpdatePAD(const char *pdata, const int ndatasi
 
 }
 
-void iv::decision::BrainDecition::UpdatePlatform(const char *pdata, const int ndatasize)
+void iv::decition::BrainDecition::UpdatePlatform(const char *pdata, const int ndatasize)
 {
     if(ndatasize < sizeof(iv::platform::PlatFormMsg))return;
 
@@ -1201,7 +1201,7 @@ void iv::decision::BrainDecition::UpdatePlatform(const char *pdata, const int nd
 
 }
 
-void iv::decision::BrainDecition::UpdateChassis(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
+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;
@@ -1253,7 +1253,7 @@ void iv::decision::BrainDecition::UpdateChassis(const char *strdata, const unsig
     //    }
 }
 
-void iv::decision::BrainDecition::UpdateGroupInfo(const char *pdata, const int ndatasize){
+void iv::decition::BrainDecition::UpdateGroupInfo(const char *pdata, const int ndatasize){
 
     iv::radio::radio_send group_message;
     if(false == group_message.ParseFromArray(pdata,ndatasize))
@@ -1274,7 +1274,7 @@ void iv::decision::BrainDecition::UpdateGroupInfo(const char *pdata, const int n
 
 }
 
-void iv::decision::BrainDecition::UpdateVbox(const char *pdata, const int ndatasize){
+void iv::decition::BrainDecition::UpdateVbox(const char *pdata, const int ndatasize){
 
     iv::vbox::vbox group_message;
     if(false == group_message.ParseFromArray(pdata,ndatasize))
@@ -1302,7 +1302,7 @@ void iv::decision::BrainDecition::UpdateVbox(const char *pdata, const int ndatas
 
 }
 
-void iv::decision::BrainDecition::Updatev2x(const char *pdata, const int ndatasize){
+void iv::decition::BrainDecition::Updatev2x(const char *pdata, const int ndatasize){
 
     iv::v2x::v2x v2x_message;
     if(false == v2x_message.ParseFromArray(pdata,ndatasize))
@@ -1365,7 +1365,7 @@ void iv::decision::BrainDecition::Updatev2x(const char *pdata, const int ndatasi
 
 }
 
-void iv::decision::BrainDecition::Updateultra(const char *pdata, const int ndatasize)
+void iv::decition::BrainDecition::Updateultra(const char *pdata, const int ndatasize)
 {
     iv::ultrasonic::ultrasonic ultraarry;
     if(false == ultraarry.ParseFromArray(pdata,ndatasize))
@@ -1389,11 +1389,11 @@ void iv::decision::BrainDecition::Updateultra(const char *pdata, const int ndata
 }
 
 
-void iv::decision::BrainDecition::UpdateSate(){
+void iv::decition::BrainDecition::UpdateSate(){
      decitionGps00->isFirstRun=true;
 }
 
-void iv::decision::BrainDecition::adjuseGpsLidarPosition(){
+void iv::decition::BrainDecition::adjuseGpsLidarPosition(){
 
     ServiceCarStatus.msysparam.lidarGpsXiuzheng -=  ServiceCarStatus.msysparam.gpsOffset_y;
     ServiceCarStatus.msysparam.radarGpsXiuzheng -=  ServiceCarStatus.msysparam.gpsOffset_y;

+ 6 - 6
src/decition/decition_brain/decision/brain.h

@@ -49,7 +49,7 @@
 #include "fanyaapi.h"
 
 namespace iv {
-	namespace decision {
+    namespace decition {
 		class BrainDecition
 		{
 		public:
@@ -93,12 +93,12 @@ namespace iv {
 		//	iv::perception::Eyes* eyes;							//眼睛
  //           iv::carcalling::carcalling* carcall;
 			iv::perception::Eyes* eyes;
-			iv::decision::DecitionMaker* decitionMaker;			//决策器
-			iv::decision::DecitionVoter* decitionVoter;			//决策仲裁 判断器
+            iv::decition::DecitionMaker* decitionMaker;			//决策器
+            iv::decition::DecitionVoter* decitionVoter;			//决策仲裁 判断器
 //			iv::decition::DecitionExecuter* decitionExecuter;	//决策执行器
 
-            iv::decision::DecideGps00* decitionGps00;			//决策器
-              iv::decision::DecideLine00* decitionLine00;
+            iv::decition::DecideGps00* decitionGps00;			//决策器
+              iv::decition::DecideLine00* decitionLine00;
 
 //			boost::shared_ptr<iv::control::Controller> controller;	//实际车辆控制器
 
@@ -131,7 +131,7 @@ namespace iv {
             void * mpaObsTraceRight;
 
 
-            void ShareDecition(iv::decision::Decition decision);
+            void ShareDecition(iv::decition::Decition decition);
             void ShareBrainstate(iv::brain::brainstate xbs);
 
         private:

+ 1 - 1
src/decition/decition_brain/decision/compute_00.h

@@ -9,7 +9,7 @@
 #include <decision/decide_gps_00.h>
 
 namespace iv {
-    namespace decision {
+    namespace decition {
     //根据传感器传输来的信息作出决策
         class Compute00 {
         public:

+ 104 - 104
src/decition/decition_brain/decision/decide_gps_00.cpp

@@ -24,59 +24,59 @@ extern iv::Ivlog * givlog;
 
 #define PI (3.1415926535897932384626433832795)
 
-iv::decision::DecideGps00::DecideGps00() {
+iv::decition::DecideGps00::DecideGps00() {
 
 }
-iv::decision::DecideGps00::~DecideGps00() {
+iv::decition::DecideGps00::~DecideGps00() {
 
 }
 
-float iv::decision::DecideGps00::xiuzhengCs=0;
+float iv::decition::DecideGps00::xiuzhengCs=0;
 
-int iv::decision::DecideGps00::PathPoint = -1;
-double iv::decision::DecideGps00::minDis = iv::MaxValue;
-double iv::decision::DecideGps00::maxAngle = iv::MinValue;
+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::decision::DecideGps00::lastGpsIndex = 0;
-double iv::decision::DecideGps00::controlSpeed = 0;
-double iv::decision::DecideGps00::controlBrake = 0;
-double iv::decision::DecideGps00::controlAng = 0;
-double iv::decision::DecideGps00::Iv = 0;
-double iv::decision::DecideGps00::lastU = 0;
-double iv::decision::DecideGps00::lastVt = 0;
-double iv::decision::DecideGps00::lastEv = 0;
-
-int iv::decision::DecideGps00::gpsLineParkIndex = 0;
-int iv::decision::DecideGps00::gpsMapParkIndex = 0;
-double iv::decision::DecideGps00::lastDistance = MaxValue;
-double iv::decision::DecideGps00::lastPreObsDistance = MaxValue;
-double iv::decision::DecideGps00::obsDistance = -1;
-double iv::decision::DecideGps00::obsSpeed=0;
-double iv::decision::DecideGps00::obsDistanceAvoid = -1;
-double iv::decision::DecideGps00::lastDistanceAvoid = -1;
-
-double iv::decision::DecideGps00::lidarDistance = -1;
-double iv::decision::DecideGps00::myesrDistance = -1;
-double iv::decision::DecideGps00::lastLidarDis = -1;
-
-bool iv::decision::DecideGps00::parkMode = false;
-bool iv::decision::DecideGps00::readyParkMode = false;
-
-bool iv::decision::DecideGps00::zhucheMode = false;
-bool iv::decision::DecideGps00::readyZhucheMode = false;
-bool iv::decision::DecideGps00::hasZhuched = false;
-
-double iv::decision::DecideGps00::lastLidarDisAvoid = -1;
-double iv::decision::DecideGps00::lidarDistanceAvoid = -1;
-
-int iv::decision::DecideGps00::finishPointNum = -1;
-int iv::decision::DecideGps00::zhuchePointNum = 0;
+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::decision::DecideGps00::isFirstRun = true;
+bool iv::decition::DecideGps00::isFirstRun = true;
 //////////////////////////////////////////////
 
-float iv::decision::DecideGps00::minDecelerate=0;
+float iv::decition::DecideGps00::minDecelerate=0;
 //bool iv::decition::DecideGps00::startingFlag = true;//起步标志,在起步时需要进行frenet规划。
 
 double offset_real = 0;
@@ -185,7 +185,7 @@ std::vector<double> lastDistanceVector(roadSum, -1);
 bool qiedianCount = false;
 //日常展示
 
-iv::decision::Decition iv::decision::DecideGps00::getDecideFromGPS(GPS_INS now_gps_ins,
+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,
@@ -1996,7 +1996,7 @@ iv::decision::Decition iv::decision::DecideGps00::getDecideFromGPS(GPS_INS now_g
     return gps_decition;
 }
 
-iv::Station iv::decision::DecideGps00::getNearestStation(iv::GPS_INS now_gps_ins,std::vector<Station> station_n,std::vector<GPSData> gpsMap){
+iv::Station iv::decition::DecideGps00::getNearestStation(iv::GPS_INS now_gps_ins,std::vector<Station> station_n,std::vector<GPSData> gpsMap){
 
     int now_index=0,front_index=0;
     int station_size=station_n.size();
@@ -2052,7 +2052,7 @@ iv::Station iv::decision::DecideGps00::getNearestStation(iv::GPS_INS now_gps_ins
 
 }
 
-void iv::decision::DecideGps00::initMethods(){
+void iv::decition::DecideGps00::initMethods(){
 
     pid_Controller= new PIDController();
     ge3_Adapter = new Ge3Adapter();
@@ -2078,7 +2078,7 @@ void iv::decision::DecideGps00::initMethods(){
 }
 
 
-void iv::decision::DecideGps00::phaseSpeedDecition(iv::decision::Decition  decition, double secSpeed, double obsDis, double obsSpeed, GPS_INS gpsIns ) {
+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);
 
@@ -2102,7 +2102,7 @@ void iv::decision::DecideGps00::phaseSpeedDecition(iv::decision::Decition  decit
 
 
 
-std::vector<iv::Point2D> iv::decision::DecideGps00::getGpsTrace(iv::GPS_INS now_gps_ins, const std::vector<GPSData> gpsMapLine, int lastIndex, bool circleMode) {
+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)
@@ -2190,7 +2190,7 @@ std::vector<iv::Point2D> iv::decision::DecideGps00::getGpsTrace(iv::GPS_INS now_
     return trace;
 }
 
-std::vector<iv::Point2D>  iv::decision::DecideGps00::getGpsTraceOffset(std::vector<Point2D> gpsTrace, double offset) {
+std::vector<iv::Point2D>  iv::decition::DecideGps00::getGpsTraceOffset(std::vector<Point2D> gpsTrace, double offset) {
 
     if (offset==0)
     {
@@ -2248,9 +2248,9 @@ std::vector<iv::Point2D>  iv::decision::DecideGps00::getGpsTraceOffset(std::vect
 }
 
 
-double iv::decision::DecideGps00::getAngle(std::vector<Point2D> gpsTrace,GPS_INS gpsIns,iv::decision::Decition decition) {
+double iv::decition::DecideGps00::getAngle(std::vector<Point2D> gpsTrace,GPS_INS gpsIns,iv::decition::Decition decition) {
     double angle=0;
-    if ( abs(iv::decision::DecideGps00().minDis) < 20 && abs(iv::decision::DecideGps00().maxAngle) < 100)
+    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);
@@ -2259,9 +2259,9 @@ double iv::decision::DecideGps00::getAngle(std::vector<Point2D> gpsTrace,GPS_INS
     return angle;
 }
 
-double iv::decision::DecideGps00::getSpeed(std::vector<Point2D> gpsTrace) {
+double iv::decition::DecideGps00::getSpeed(std::vector<Point2D> gpsTrace) {
     double speed=0;
-    int speedPoint = iv::decision::Compute00().getSpeedPointIndex(gpsTrace, max(10.0, realspeed));
+    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);
@@ -2309,12 +2309,12 @@ double iv::decision::DecideGps00::getSpeed(std::vector<Point2D> gpsTrace) {
 
 
 
-void iv::decision::DecideGps00::getEsrObsDistance(std::vector<Point2D> gpsTrace, int roadNum) {
+void iv::decition::DecideGps00::getEsrObsDistance(std::vector<Point2D> gpsTrace, int roadNum) {
 
 
     int esrPathpoint;
 
-    esrIndex = iv::decision::Compute00().getEsrIndex(gpsTrace, roadNum, &esrPathpoint);
+    esrIndex = iv::decition::Compute00().getEsrIndex(gpsTrace, roadNum, &esrPathpoint);
 
     if (esrIndex != -1)
     {
@@ -2341,9 +2341,9 @@ void iv::decision::DecideGps00::getEsrObsDistance(std::vector<Point2D> gpsTrace,
 
 
 
-void iv::decision::DecideGps00::getEsrObsDistanceAvoid() {
+void iv::decition::DecideGps00::getEsrObsDistanceAvoid() {
 
-    esrIndexAvoid = iv::decision::Compute00().getEsrIndexAvoid(gpsTraceAvoid);
+    esrIndexAvoid = iv::decition::Compute00().getEsrIndexAvoid(gpsTraceAvoid);
 
     if (esrIndexAvoid != -1)
     {
@@ -2368,7 +2368,7 @@ void iv::decision::DecideGps00::getEsrObsDistanceAvoid() {
 
 
 
-double iv::decision::DecideGps00::limitAngle(double speed, double angle) {
+double iv::decition::DecideGps00::limitAngle(double speed, double angle) {
     double preAngle = angle;
 
     if (speed > 15)
@@ -2431,7 +2431,7 @@ double iv::decision::DecideGps00::limitAngle(double speed, double angle) {
 
 
 
-double iv::decision::DecideGps00::limitSpeed(double angle, double speed) {
+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;
@@ -2443,7 +2443,7 @@ double iv::decision::DecideGps00::limitSpeed(double angle, double speed) {
 }
 
 
-bool iv::decision::DecideGps00::checkAvoidEnable(double avoidX, iv::LidarGridPtr lidarGridPtr,int roadNum) {
+bool iv::decition::DecideGps00::checkAvoidEnable(double avoidX, iv::LidarGridPtr lidarGridPtr,int roadNum) {
 
     if ((obsDisVector[roadNum]>0 && obsDisVector[roadNum]<obsDisVector[roadNow]+ServiceCarStatus.msysparam.vehLenth)||
             (obsDisVector[roadNum]>0 && obsDisVector[roadNum]<15))
@@ -2476,7 +2476,7 @@ bool iv::decision::DecideGps00::checkAvoidEnable(double avoidX, iv::LidarGridPtr
 
 
 
-bool iv::decision::DecideGps00::checkReturnEnable(double avoidX, iv::LidarGridPtr lidarGridPtr, int roadNum) {
+bool iv::decition::DecideGps00::checkReturnEnable(double avoidX, iv::LidarGridPtr lidarGridPtr, int roadNum) {
     //lsn
     if (obsDisVector[roadNum]>0 && obsDisVector[roadNum]<20)
     {
@@ -2513,39 +2513,39 @@ bool iv::decision::DecideGps00::checkReturnEnable(double avoidX, iv::LidarGridPt
 }
 
 
-void iv::decision::DecideGps00::getObsAvoid(iv::LidarGridPtr lidarGridPtr) {
+void iv::decition::DecideGps00::getObsAvoid(iv::LidarGridPtr lidarGridPtr) {
 
 
 
     if (lidarGridPtr == NULL)
     {
-        iv::decision::DecideGps00::lidarDistanceAvoid = iv::decision::DecideGps00::lastLidarDisAvoid;
+        iv::decition::DecideGps00::lidarDistanceAvoid = iv::decition::DecideGps00::lastLidarDisAvoid;
     }
     else {
         obsPointAvoid = Compute00().getLidarObsPointAvoid(gpsTraceAvoid, lidarGridPtr);
-        iv::decision::DecideGps00::lastLidarDisAvoid = iv::decision::DecideGps00::lidarDistanceAvoid;
+        iv::decition::DecideGps00::lastLidarDisAvoid = iv::decition::DecideGps00::lidarDistanceAvoid;
     }
-    std::cout << "\nLidarAvoid距离:%f\n" << iv::decision::DecideGps00::lidarDistanceAvoid << std::endl;
+    std::cout << "\nLidarAvoid距离:%f\n" << iv::decition::DecideGps00::lidarDistanceAvoid << std::endl;
     getEsrObsDistanceAvoid();
 
     //lidarDistanceAvoid = -1;   //20200103 apollo_fu
 
-    if (esrDistanceAvoid>0 && iv::decision::DecideGps00::lidarDistanceAvoid > 0)
+    if (esrDistanceAvoid>0 && iv::decition::DecideGps00::lidarDistanceAvoid > 0)
     {
-        if (iv::decision::DecideGps00::lidarDistanceAvoid >= esrDistanceAvoid)
+        if (iv::decition::DecideGps00::lidarDistanceAvoid >= esrDistanceAvoid)
         {
             obsDistanceAvoid = esrDistanceAvoid;
             obsSpeedAvoid = ServiceCarStatus.obs_radar[esrIndexAvoid].speed_y;
         }
         else if (!ServiceCarStatus.obs_radar.empty())
         {
-            obsDistanceAvoid = iv::decision::DecideGps00::lidarDistanceAvoid;
+            obsDistanceAvoid = iv::decition::DecideGps00::lidarDistanceAvoid;
             obsSpeedAvoid = Compute00().getObsSpeed(obsPointAvoid, secSpeed);
             std::cout << "\n计算obsSpeed:%f\n" << obsSpeedAvoid << std::endl;
         }
         else
         {
-            obsDistanceAvoid = iv::decision::DecideGps00::lidarDistanceAvoid;
+            obsDistanceAvoid = iv::decition::DecideGps00::lidarDistanceAvoid;
             obsSpeedAvoid = obsSpeedAvoid = 0 - secSpeed;;
             std::cout << "\n毫米波无数据,计算obsSpeed:%f\n" << obsSpeedAvoid << std::endl;
         }
@@ -2555,9 +2555,9 @@ void iv::decision::DecideGps00::getObsAvoid(iv::LidarGridPtr lidarGridPtr) {
         obsDistanceAvoid = esrDistanceAvoid;
         obsSpeedAvoid = ServiceCarStatus.obs_radar[esrIndexAvoid].speed_y;
     }
-    else if (iv::decision::DecideGps00::lidarDistanceAvoid > 0)
+    else if (iv::decition::DecideGps00::lidarDistanceAvoid > 0)
     {
-        obsDistanceAvoid = iv::decision::DecideGps00::lidarDistanceAvoid;
+        obsDistanceAvoid = iv::decition::DecideGps00::lidarDistanceAvoid;
         obsSpeedAvoid = Compute00().getObsSpeed(obsPointAvoid, secSpeed);
         std::cout << "\n计算obsSpeed:%f\n" << obsSpeedAvoid << std::endl;
     }
@@ -2572,15 +2572,15 @@ void iv::decision::DecideGps00::getObsAvoid(iv::LidarGridPtr lidarGridPtr) {
 
 
 
-    if (iv::decision::DecideGps00::obsDistanceAvoid <0 && obsLostTimeAvoid<4)
+    if (iv::decition::DecideGps00::obsDistanceAvoid <0 && obsLostTimeAvoid<4)
     {
-        iv::decision::DecideGps00::obsDistanceAvoid = iv::decision::DecideGps00::lastDistanceAvoid;
+        iv::decition::DecideGps00::obsDistanceAvoid = iv::decition::DecideGps00::lastDistanceAvoid;
         obsLostTimeAvoid++;
     }
     else
     {
         obsLostTimeAvoid = 0;
-        iv::decision::DecideGps00::lastDistanceAvoid = -1;
+        iv::decition::DecideGps00::lastDistanceAvoid = -1;
     }
 
 
@@ -2588,13 +2588,13 @@ void iv::decision::DecideGps00::getObsAvoid(iv::LidarGridPtr lidarGridPtr) {
 
     if (obsDistanceAvoid>0)
     {
-        iv::decision::DecideGps00::lastDistanceAvoid = obsDistanceAvoid;
+        iv::decition::DecideGps00::lastDistanceAvoid = obsDistanceAvoid;
     }
 
-    std::cout << "\nODSAvoid距离:%f\n" << iv::decision::DecideGps00::obsDistanceAvoid << std::endl;
+    std::cout << "\nODSAvoid距离:%f\n" << iv::decition::DecideGps00::obsDistanceAvoid << std::endl;
 }
 
-void iv::decision::DecideGps00::init() {
+void iv::decition::DecideGps00::init() {
     for (int i = 0; i < roadSum; i++)
     {
         lastEsrIdVector.push_back(-1);
@@ -2611,7 +2611,7 @@ void iv::decision::DecideGps00::init() {
 
 #include <QTime>
 
-void iv::decision::DecideGps00::computeObsOnRoad(iv::LidarGridPtr lidarGridPtr, std::vector<Point2D> gpsTrace, int roadNum,
+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;
@@ -2843,7 +2843,7 @@ void iv::decision::DecideGps00::computeObsOnRoad(iv::LidarGridPtr lidarGridPtr,
 
 
 //1220
-void iv::decision::DecideGps00::computeRearObsOnRoad(iv::LidarGridPtr lidarGridPtr, std::vector<Point2D> gpsTrace, int roadNum,
+void iv::decition::DecideGps00::computeRearObsOnRoad(iv::LidarGridPtr lidarGridPtr, std::vector<Point2D> gpsTrace, int roadNum,
                                                      const std::vector<GPSData> gpsMapLine) {
 
     double obs,obsSd;
@@ -3041,7 +3041,7 @@ void iv::decision::DecideGps00::computeRearObsOnRoad(iv::LidarGridPtr lidarGridP
 
 
 
-void iv::decision::DecideGps00::predictObsOnRoad(std::vector<iv::Perception::PerceptionOutput> lidar_per,std::vector<Point2D> gpsTrace,double realSpeed){
+void iv::decition::DecideGps00::predictObsOnRoad(std::vector<iv::Perception::PerceptionOutput> lidar_per,std::vector<Point2D> gpsTrace,double realSpeed){
     double preObsDis;
 
     if(!lidar_per.empty()){
@@ -3057,7 +3057,7 @@ void iv::decision::DecideGps00::predictObsOnRoad(std::vector<iv::Perception::Per
     }
 }
 
-int iv::decision::DecideGps00::chooseAvoidRoad(iv::LidarGridPtr lidarGridPtr, GPS_INS now_gps_ins, const std::vector<GPSData> gpsMapLine,std::vector<iv::Perception::PerceptionOutput> lidar_per) {
+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)
@@ -3199,7 +3199,7 @@ int iv::decision::DecideGps00::chooseAvoidRoad(iv::LidarGridPtr lidarGridPtr, GP
     return roadPre;
 }
 
-int iv::decision::DecideGps00::chooseBackRoad(iv::LidarGridPtr lidarGridPtr, GPS_INS now_gps_ins, std::vector<GPSData> gpsMapLine,std::vector<iv::Perception::PerceptionOutput> lidar_per) {
+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);
@@ -3302,7 +3302,7 @@ int iv::decision::DecideGps00::chooseBackRoad(iv::LidarGridPtr lidarGridPtr, GPS
 }
 
 
-double iv::decision::DecideGps00::trumpet() {
+double iv::decition::DecideGps00::trumpet() {
     if (trumpetFirstCount)
     {
         trumpetFirstCount = false;
@@ -3322,7 +3322,7 @@ double iv::decision::DecideGps00::trumpet() {
 
 
 
-double iv::decision::DecideGps00::transferP() {
+double iv::decition::DecideGps00::transferP() {
     if (transferFirstCount)
     {
         transferFirstCount = false;
@@ -3341,7 +3341,7 @@ double iv::decision::DecideGps00::transferP() {
 
 
 
-void  iv::decision::DecideGps00::handBrakePark(iv::decision::Decition  decition, long duringTime, GPS_INS now_gps_ins) {
+void  iv::decition::DecideGps00::handBrakePark(iv::decition::Decition  decition, long duringTime, GPS_INS now_gps_ins) {
 
     if (abs(now_gps_ins.speed)>0.1)
     {
@@ -3365,14 +3365,14 @@ void  iv::decision::DecideGps00::handBrakePark(iv::decision::Decition  decition,
 
 
 
-void iv::decision::DecideGps00::getMapBeside(std::vector<iv::GPSData> navigation_data, iv::GPS_INS now_gps_ins) {
+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::decision::Compute00().getBesideGpsMapLine(now_gps_ins, navigation_data, -0.5*i);
+        gpsMapLineBeside = iv::decition::Compute00().getBesideGpsMapLine(now_gps_ins, navigation_data, -0.5*i);
 
         gmapsL.push_back(gpsMapLineBeside);
     }
@@ -3382,7 +3382,7 @@ void iv::decision::DecideGps00::getMapBeside(std::vector<iv::GPSData> navigation
     {
         std::vector<iv::GPSData> gpsMapLineBeside;
         //		gpsMapLineBeside = iv::decition::ComputeUnit().getBesideGpsMapLine(*ServiceCarStatus.location, navigation_data, 0.5*i);
-        gpsMapLineBeside = iv::decision::Compute00().getBesideGpsMapLine(now_gps_ins, navigation_data, 0.5*i);
+        gpsMapLineBeside = iv::decition::Compute00().getBesideGpsMapLine(now_gps_ins, navigation_data, 0.5*i);
 
         gmapsR.push_back(gpsMapLineBeside);
     }
@@ -3390,7 +3390,7 @@ void iv::decision::DecideGps00::getMapBeside(std::vector<iv::GPSData> navigation
 }
 
 
-bool iv::decision::DecideGps00::checkChaoCheBack(iv::LidarGridPtr lidarGridPtr) {
+bool iv::decition::DecideGps00::checkChaoCheBack(iv::LidarGridPtr lidarGridPtr) {
 
     if (lidarGridPtr == NULL)
     {
@@ -3425,7 +3425,7 @@ bool iv::decision::DecideGps00::checkChaoCheBack(iv::LidarGridPtr lidarGridPtr)
 
 }
 
-void iv::decision::DecideGps00::updateGroupDate(GPS_INS now_gps_ins,float realspeed,float theta,float s){
+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;
@@ -3446,7 +3446,7 @@ void iv::decision::DecideGps00::updateGroupDate(GPS_INS now_gps_ins,float realsp
 
 
 
-float  iv::decision::DecideGps00::ComputeTrafficLightSpeed(int traffic_light_color, int traffic_light_time,  const std::vector<GPSData> gpsMapLine,int traffic_light_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;
@@ -3540,10 +3540,10 @@ float  iv::decision::DecideGps00::ComputeTrafficLightSpeed(int traffic_light_col
 
 }
 
-void iv::decision::DecideGps00::computeObsOnRoadByFrenet(iv::LidarGridPtr lidarGridPtr, const std::vector<Point2D>& gpsTrace, double & obs, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps)
+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::decision::FrenetPoint car_now_frenet_point = iv::decision::FrenetPlanner::getFrenetfromXY(0,0,gpsTrace,gpsMap,pathpoint,nowGps);
+    iv::decition::FrenetPoint car_now_frenet_point = iv::decition::FrenetPlanner::getFrenetfromXY(0,0,gpsTrace,gpsMap,pathpoint,nowGps);
     double obsSd;
     if (lidarGridPtr == NULL)
     {
@@ -3553,7 +3553,7 @@ void iv::decision::DecideGps00::computeObsOnRoadByFrenet(iv::LidarGridPtr lidarG
     else {
         obsPoint = Compute00().getLidarObsPoint(gpsTrace, lidarGridPtr);
         //        lidarDistance = obsPoint.y-2.5;   //激光距离推到车头
-        iv::decision::FrenetPoint lidarFPointTmp = iv::decision::FrenetPlanner::getFrenetfromXY(this->obsPoint.x,this->obsPoint.y,gpsTrace,gpsMap,pathpoint,nowGps);
+        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;
@@ -3663,10 +3663,10 @@ void iv::decision::DecideGps00::computeObsOnRoadByFrenet(iv::LidarGridPtr lidarG
     }
 }
 
-void iv::decision::DecideGps00::getRearEsrObsDistance(std::vector<Point2D> gpsTrace, int roadNum) {
+void iv::decition::DecideGps00::getRearEsrObsDistance(std::vector<Point2D> gpsTrace, int roadNum) {
 
 
-    esrIndex = iv::decision::Compute00().getRearEsrIndex(gpsTrace, roadNum);
+    esrIndex = iv::decition::Compute00().getRearEsrIndex(gpsTrace, roadNum);
 
     if (esrIndex != -1)
     {
@@ -3679,9 +3679,9 @@ void iv::decision::DecideGps00::getRearEsrObsDistance(std::vector<Point2D> gpsTr
     }
 }
 
-void iv::decision::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) {
+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::decision::Compute00().getEsrIndexByFrenet(gpsTrace,esrObs_F_Point,gpsMap,pathpoint,nowGps);
+    esrIndex = iv::decition::Compute00().getEsrIndexByFrenet(gpsTrace,esrObs_F_Point,gpsMap,pathpoint,nowGps);
 
     if (esrIndex != -1)
     {
@@ -3703,7 +3703,7 @@ void iv::decision::DecideGps00::getEsrObsDistanceByFrenet(const std::vector<Poin
     }
 }
 
-void iv::decision::DecideGps00::getV2XTrafficPositionVector(const std::vector<GPSData> gpsMapLine){
+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 || gpsMapLine[var]->mode2==1000001){
@@ -3712,7 +3712,7 @@ void iv::decision::DecideGps00::getV2XTrafficPositionVector(const std::vector<GP
     }
 }
 
-float iv::decision::DecideGps00::ComputeV2XTrafficLightSpeed(iv::TrafficLight trafficLight, const std::vector<GPSData> gpsMapLine,std::vector<int> v2xTrafficVector,
+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;
@@ -3789,7 +3789,7 @@ float iv::decision::DecideGps00::ComputeV2XTrafficLightSpeed(iv::TrafficLight tr
     return trafficSpeed;
 }
 
-bool iv::decision::DecideGps00::computeTrafficPass(float trafficDis,int trafficColor,float trafficTime,float realSecSpeed,float dSecSpeed){
+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;
@@ -3807,7 +3807,7 @@ bool iv::decision::DecideGps00::computeTrafficPass(float trafficDis,int trafficC
 
 }
 
-float iv::decision::DecideGps00::computeTrafficSpeedLimt(float trafficDis){
+float iv::decition::DecideGps00::computeTrafficSpeedLimt(float trafficDis){
     float limit=200;
     if(trafficDis<10){
         limit = 0;
@@ -3823,7 +3823,7 @@ float iv::decision::DecideGps00::computeTrafficSpeedLimt(float trafficDis){
 
 
 
-bool iv::decision::DecideGps00::adjuseultra(){
+bool iv::decition::DecideGps00::adjuseultra(){
     bool front=false,back=false,left=false,right=false;
     for(int i=1;i<=13;i++)
     {
@@ -3855,7 +3855,7 @@ bool iv::decision::DecideGps00::adjuseultra(){
 
 }
 
-void iv::decision::DecideGps00::transferGpsMode2( const std::vector<GPSData> gpsMapLine){
+void iv::decition::DecideGps00::transferGpsMode2( const std::vector<GPSData> gpsMapLine){
     if(  gpsMapLine[PathPoint]->mode2==3000){
         if(obsDistance>5){
             obsDistance=200;
@@ -3863,7 +3863,7 @@ void iv::decision::DecideGps00::transferGpsMode2( const std::vector<GPSData> gps
         dSpeed=min(dSpeed,5.0);
     }
 }
-float iv::decision::DecideGps00::computeAvoidX(int roadAim,int roadOri,GPSData gps,float vehWidth){
+float iv::decition::DecideGps00::computeAvoidX(int roadAim,int roadOri,GPSData gps,float vehWidth){
     if(roadAim==roadOri){
         return 0;
     }

+ 5 - 5
src/decition/decition_brain/decision/decide_gps_00.h

@@ -24,7 +24,7 @@
 #include "obs_mobieye.h"
 
 namespace iv {
-namespace decision {
+namespace decition {
 //根据传感器传输来的信息作出决策
 class DecideGps00 {
 public:
@@ -155,7 +155,7 @@ public:
 
 
     static double getAngle(std::vector<Point2D> gpsTrace);
-    double getAngle(std::vector<Point2D> gpsTrace, GPS_INS gpsIns,iv::decision::Decition decision);
+    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);
@@ -163,7 +163,7 @@ public:
     static void getEsrObsDistanceAvoid();
 
     void getObsAvoid(iv::LidarGridPtr lidarGridPtr);
-    void phaseSpeedDecition(iv::decision::Decition decision, double secSpeed, double obsDis, double obsSpeed, GPS_INS gpsIns );
+    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);
@@ -172,7 +172,7 @@ public:
     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::decision::FrenetPoint car_now_frenet_point,iv::decision::FrenetPoint &esrObs_F_Point, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps);
+    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);
@@ -184,7 +184,7 @@ public:
 
     void getMapBeside(std::vector<iv::GPSData> navigation_data, iv::GPS_INS now_gps_ins);
 
-    void  handBrakePark(iv::decision::Decition  decision, long duringTime, GPS_INS now_gps_ins);
+    void  handBrakePark(iv::decition::Decition  decition, long duringTime, GPS_INS now_gps_ins);
 
     bool checkChaoCheBack(iv::LidarGridPtr);
     double trumpet();

+ 4 - 4
src/decition/decition_brain/decision/decide_line_00.h

@@ -12,7 +12,7 @@
 
 
 namespace iv {
-	namespace decision {
+	namespace decition {
 		//根据传感器传输来的信息作出决策
         class DecideLine00 {
 		public:
@@ -115,7 +115,7 @@ namespace iv {
 
 			void getObsAvoid(iv::LidarGridPtr lidarGridPtr);
 
-            void phaseSpeedDecition(iv::decision::Decition decision, double secSpeed, double obsDistance, double obsSpeed, GPS_INS gpsIns );
+            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);
@@ -131,7 +131,7 @@ namespace iv {
 
 			void getMapBeside(std::vector<iv::GPSData> navigation_data, iv::GPS_INS now_gps_ins);
 
-			void  handBrakePark(iv::decision::Decition  decision, long duringTime, GPS_INS now_gps_ins);
+			void  handBrakePark(iv::decition::Decition  decition, long duringTime, GPS_INS now_gps_ins);
 
 
 			double trumpet();
@@ -236,7 +236,7 @@ namespace iv {
 
 
 		private:
-               iv::decision::DecideGps00* decitionGpstool ;			//决策器
+               iv::decition::DecideGps00* decitionGpstool ;			//决策器
                std::shared_ptr<DecideGps00> mdecitionGpstool;
 		};
 

+ 42 - 42
src/decition/decition_brain/decision/decide_line_00_.cpp

@@ -14,51 +14,51 @@ using namespace std;
 
 #define PI (3.1415926535897932384626433832795)
 
-iv::decision::DecideLine00::DecideLine00() {
-      decitionGpstool = new iv::decision::DecideGps00();
+iv::decition::DecideLine00::DecideLine00() {
+      decitionGpstool = new iv::decition::DecideGps00();
       mdecitionGpstool.reset(decitionGpstool);
 }
-iv::decision::DecideLine00::~DecideLine00() {
+iv::decition::DecideLine00::~DecideLine00() {
 
 }
 
 
-int iv::decision::DecideLine00::PathPoint = -1;
-double iv::decision::DecideLine00::minDis = iv::MaxValue;
-double iv::decision::DecideLine00::maxAngle = iv::MinValue;
+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::decision::DecideLine00::lastGpsIndex = 0;
-double iv::decision::DecideLine00::controlSpeed = 0;
-double iv::decision::DecideLine00::controlBrake = 0;
-double iv::decision::DecideLine00::controlAng = 0;
-double iv::decision::DecideLine00::Iv = 0;
-double iv::decision::DecideLine00::lastU = 0;
-double iv::decision::DecideLine00::lastVt = 0;
-double iv::decision::DecideLine00::lastEv = 0;
+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::decision::DecideLine00::gpsLineParkIndex = 0;
-int iv::decision::DecideLine00::gpsMapParkIndex = 0;
-double iv::decision::DecideLine00::lastDistance = MaxValue;
-double iv::decision::DecideLine00::obsDistance = -1;
-double iv::decision::DecideLine00::obsDistanceAvoid = -1;
-double iv::decision::DecideLine00::lastDistanceAvoid = -1;
+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::decision::DecideLine00::lidarDistance = -1;
-double iv::decision::DecideLine00::myesrDistance = -1;
-double iv::decision::DecideLine00::lastLidarDis = -1;
+double iv::decition::DecideLine00::lidarDistance = -1;
+double iv::decition::DecideLine00::myesrDistance = -1;
+double iv::decition::DecideLine00::lastLidarDis = -1;
 
-bool iv::decision::DecideLine00::parkMode = false;
-bool iv::decision::DecideLine00::readyParkMode = false;
+bool iv::decition::DecideLine00::parkMode = false;
+bool iv::decition::DecideLine00::readyParkMode = false;
 
-bool iv::decision::DecideLine00::zhucheMode = false;
-bool iv::decision::DecideLine00::readyZhucheMode = false;
-bool iv::decision::DecideLine00::hasZhuched = false;
+bool iv::decition::DecideLine00::zhucheMode = false;
+bool iv::decition::DecideLine00::readyZhucheMode = false;
+bool iv::decition::DecideLine00::hasZhuched = false;
 
-double iv::decision::DecideLine00::lastLidarDisAvoid = -1;
-double iv::decision::DecideLine00::lidarDistanceAvoid = -1;
+double iv::decition::DecideLine00::lastLidarDisAvoid = -1;
+double iv::decition::DecideLine00::lidarDistanceAvoid = -1;
 
-int iv::decision::DecideLine00::finishPointNum = 0;
-int iv::decision::DecideLine00::zhuchePointNum = 0;
+int iv::decition::DecideLine00::finishPointNum = 0;
+int iv::decition::DecideLine00::zhuchePointNum = 0;
 
 
 
@@ -66,7 +66,7 @@ int iv::decision::DecideLine00::zhuchePointNum = 0;
 
 //日常展示
 
-iv::decision::Decition    iv::decision::DecideLine00::getDecideFromGPS(GPS_INS now_gps_ins, const std::vector<GPSData> gpsMapLine, iv::LidarGridPtr lidarGridPtr,
+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);
@@ -169,7 +169,7 @@ iv::decision::Decition    iv::decision::DecideLine00::getDecideFromGPS(GPS_INS n
 
     gpsTraceOri=getGpsTraceByMobileEye(ServiceCarStatus.Lane.curvature,ServiceCarStatus.Lane.heading,
                                        (ServiceCarStatus.aftermarketLane.dist_to_lane_l+ServiceCarStatus.aftermarketLane.dist_to_lane_r)*0.5);
-     controlAng = iv::decision::Compute00().getDecideAngleByLanePID(realspeed);
+     controlAng = iv::decition::Compute00().getDecideAngleByLanePID(realspeed);
   //  controlAng = iv::decition::Compute00().getDecideAngle(gpsTraceOri, realspeed);
     if(outGarageTimeLast!=-1){
         outGarageTimeNow=GetTickCount();
@@ -428,7 +428,7 @@ iv::decision::Decition    iv::decision::DecideLine00::getDecideFromGPS(GPS_INS n
 
 
 
-void iv::decision::DecideLine00::phaseSpeedDecition(iv::decision::Decition  decition, double secSpeed, double obsDistance, double obsSpeed, GPS_INS gpsIns) {
+void iv::decition::DecideLine00::phaseSpeedDecition(iv::decition::Decition  decition, double secSpeed, double obsDistance, double obsSpeed, GPS_INS gpsIns) {
 
     //      obsDistance = -1;
 
@@ -777,11 +777,11 @@ void iv::decision::DecideLine00::phaseSpeedDecition(iv::decision::Decition  deci
 
     if (obsDistance>0)
     {
-        iv::decision::DecideGps00::lastDistance = obsDistance;
+        iv::decition::DecideGps00::lastDistance = obsDistance;
     }
     else
     {
-        iv::decision::DecideGps00::lastDistance = 200;
+        iv::decition::DecideGps00::lastDistance = 200;
     }
 
 
@@ -833,7 +833,7 @@ void iv::decision::DecideLine00::phaseSpeedDecition(iv::decision::Decition  deci
 
 
 
-double iv::decision::DecideLine00::limitAngle(double speed, double angle) {
+double iv::decition::DecideLine00::limitAngle(double speed, double angle) {
 	double preAngle = angle;
 
 	if (speed > 15)
@@ -896,7 +896,7 @@ double iv::decision::DecideLine00::limitAngle(double speed, double angle) {
 
 
 
-double iv::decision::DecideLine00::limitSpeed(double angle, double speed) {
+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;
@@ -923,7 +923,7 @@ double iv::decision::DecideLine00::limitSpeed(double angle, double speed) {
 
 
 
-double iv::decision::DecideLine00::trumpet() {
+double iv::decition::DecideLine00::trumpet() {
 	if (trumpetFirstCount)
 	{
 		trumpetFirstCount = false;
@@ -941,7 +941,7 @@ double iv::decision::DecideLine00::trumpet() {
 }
 
 
-void  iv::decision::DecideLine00::handBrakePark(iv::decision::Decition  decition, long duringTime, GPS_INS now_gps_ins) {
+void  iv::decition::DecideLine00::handBrakePark(iv::decition::Decition  decition, long duringTime, GPS_INS now_gps_ins) {
 
 	if (abs(now_gps_ins.speed)>0.1)
 	{
@@ -964,7 +964,7 @@ void  iv::decision::DecideLine00::handBrakePark(iv::decision::Decition  decition
 
 
 
-std::vector<iv::Point2D> iv::decision::DecideLine00::getGpsTraceByMobileEye(float a,float b, float c){
+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;

+ 2 - 2
src/decition/decition_brain/decision/decition_maker.h

@@ -7,7 +7,7 @@
 #include<vector> 
 
 namespace iv {
-	namespace decision {
+	namespace decition {
 		//根据传感器传输来的信息作出决策
 		class DecitionMaker
 		{
@@ -34,7 +34,7 @@ namespace iv {
 
 			GPS_INS getNearestGpsIns(iv::GPS_INS gps_ins, const std::vector<iv::GPSData> navigation_data);
 
-			iv::decision::Decition getDecideForGPS(iv::GPS_INS gpsIns, 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);
 

+ 1 - 1
src/decition/decition_brain/decision/decition_type.h

@@ -3,7 +3,7 @@
 #define _IV_DECITION_DECITION_TYPE_
 #include <common/boost.h>
 namespace iv {
-namespace decision {
+namespace decition {
 struct DecitionBasic {
     float speed;				//车速
     float wheel_angle;			//转向角度

+ 2 - 2
src/decition/decition_brain/decision/decition_voter.h

@@ -11,14 +11,14 @@
 #include <decision/decition_type.h>
 
 namespace iv {
-	namespace decision {
+	namespace decition {
 		class DecitionVoter
 		{
 		public:
 			DecitionVoter();
 			~DecitionVoter();
 
-			void decideFromAll(iv::decision::Decition & decition_final,iv::decision::Decition & decition_lidar, iv::decision::Decition & decition_radar, iv::decision::Decition & decition_camera, iv::decision::Decition & decition_gps, iv::decision::Decition & decition_localmap);
+			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:
 

+ 1 - 1
src/decition/decition_brain/decision/gps_distance.h

@@ -3,7 +3,7 @@
 #define _IV_DECITION_GPS_DISTANCE_
 
 namespace iv {
-	namespace decision {
+	namespace decition {
         // 计算弧度
 		double rad(double d);
 

+ 5 - 5
src/decition/decition_brain/decision/obs_predict.cpp

@@ -12,7 +12,7 @@ using namespace std;
 #define PI (3.1415926535897932384626433832795)
 
 
-double iv::decision::PredictObsDistance( double realSpeed,std::vector<Point2D>  gpsTrace,std::vector<iv::Perception::PerceptionOutput> lidar_per){
+double iv::decition::PredictObsDistance( double realSpeed,std::vector<Point2D>  gpsTrace,std::vector<iv::Perception::PerceptionOutput> lidar_per){
 
     double crashDistance=200;
     for(int i=0;i<lidar_per.size();i++){
@@ -48,7 +48,7 @@ double iv::decision::PredictObsDistance( double realSpeed,std::vector<Point2D>
 
 }
 
-double iv::decision::getCrashDis(double realSpeed,std::vector<Point2D>  gpsTrace,iv::Perception::PerceptionOutput obs){
+double iv::decition::getCrashDis(double realSpeed,std::vector<Point2D>  gpsTrace,iv::Perception::PerceptionOutput obs){
     double dis=0;
     int length=min(300,(int)gpsTrace.size());
     int step=10;
@@ -71,7 +71,7 @@ double iv::decision::getCrashDis(double realSpeed,std::vector<Point2D>  gpsTrace
 
 
 
-int iv::decision::getFrameCount(double realSpeed,std::vector<Point2D>  gpsTrace){
+int iv::decition::getFrameCount(double realSpeed,std::vector<Point2D>  gpsTrace){
     double lenth=0;
     for(int i =0 ; i<gpsTrace.size()-1;i++){
         lenth +=GetDistance(gpsTrace[i],gpsTrace[i+1]);
@@ -83,7 +83,7 @@ int iv::decision::getFrameCount(double realSpeed,std::vector<Point2D>  gpsTrace)
     return frame;
 }
 
-int  iv::decision::getPoiIndex(double realSpeed,std::vector<Point2D>  gpsTrace,int frame){
+int  iv::decition::getPoiIndex(double realSpeed,std::vector<Point2D>  gpsTrace,int frame){
 
 
 
@@ -103,7 +103,7 @@ int  iv::decision::getPoiIndex(double realSpeed,std::vector<Point2D>  gpsTrace,i
     return index;
 }
 
-double iv::decision::getTime(double realSpeed,std::vector<Point2D>  gpsTrace,int frame ,double *dis){
+double iv::decition::getTime(double realSpeed,std::vector<Point2D>  gpsTrace,int frame ,double *dis){
     int size=gpsTrace.size()-1;
     int f=min(frame,size);
 

+ 1 - 1
src/decition/decition_brain/decision/obs_predict.h

@@ -9,7 +9,7 @@
 #include "perception/perceptionoutput.h"
 
 namespace iv {
-    namespace decision {
+    namespace decition {
     //根据传感器传输来的信息作出决策
     double PredictObsDistance(double realSpeed,std::vector<Point2D>  gpsTrace,std::vector<iv::Perception::PerceptionOutput> lidar_per);
     double getCrashDis(double realSpeed,std::vector<Point2D>  gpsTrace,iv::Perception::PerceptionOutput obs);

+ 26 - 0
src/decition/decition_brain/decition/adc_adapter/base_adapter.cpp

@@ -0,0 +1,26 @@
+#include <common/gps_type.h>
+#include <decision/decition_type.h>
+#include <common/obstacle_type.h>
+#include <vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_adapter/base_adapter.h>
+
+
+
+
+iv::decition::BaseAdapter::BaseAdapter(){
+
+}
+iv::decition::BaseAdapter::~BaseAdapter(){
+
+}
+
+
+
+ iv::decition::Decition  iv::decition::BaseAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  path , float dSpeed, float obsDistacne ,
+                                                                      float  obsSpeed,float accAim,float accNow  , bool changingDangWei, Decition *decition){
+
+
+
+
+}

+ 42 - 0
src/decition/decition_brain/decition/adc_adapter/base_adapter.h

@@ -0,0 +1,42 @@
+#ifndef BASE_ADAPTER_H
+#define BASE_ADAPTER_H
+
+
+
+#include <common/gps_type.h>
+#include <decision/decition_type.h>
+#include <common/obstacle_type.h>
+#include <vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+
+namespace iv {
+namespace decition {
+
+        class BaseAdapter {
+        public:
+
+            int adapter_id;
+            std::string adapter_name;
+
+            BaseAdapter();
+            ~BaseAdapter();
+
+
+
+        virtual  iv::decition::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                          float  obsSpeed,float accAim,float accNow, bool changingDangWei,Decition *decition);
+
+
+        private:
+
+
+        };
+
+    }
+}
+
+
+
+
+
+#endif // BASE_ADAPTER_H

+ 325 - 0
src/decition/decition_brain/decition/adc_adapter/bus_adapter.cpp

@@ -0,0 +1,325 @@
+#include <decision/adc_adapter/bus_adapter.h>
+#include <common/constants.h>
+#include <common/car_status.h>
+#include <math.h>
+#include <iostream>
+#include <fstream>
+
+
+using namespace std;
+
+
+iv::decition::BusAdapter::BusAdapter(){
+    adapter_id=4;
+    adapter_name="bus";
+}
+iv::decition::BusAdapter::~BusAdapter(){
+
+}
+
+
+
+iv::decition::Decition iv::decition::BusAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
+                                                                        float  obsSpeed,float accAim,float accNow  ,bool changingDangWei,Decition *decition){
+    accAim=min(0.7f,accAim);
+
+    float controlSpeed=0;
+    float controlBrake=0;
+    float u = 0- accAim;
+    float realSpeed = now_gps_ins.speed;
+    float ttc = 0-(obsDistance/obsSpeed);
+    bool turn_around=false;
+    if(now_gps_ins.roadMode==14||now_gps_ins.roadMode==15||now_gps_ins.roadMode==16||now_gps_ins.roadMode==17){
+        turn_around=true;
+    }
+
+    if(ttc<0){
+        ttc=15;
+    }
+    if (accAim < 0)
+    {
+        controlSpeed=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 && turn_around
+                 && dSpeed>0 && lastBrake==0){
+            controlBrake=0;
+            controlSpeed=0;
+        }else if(abs(realSpeed)<15 &&(obsDistance>40 || obsDistance<0)&&ttc>8 && dSpeed>0 && turn_around){
+            controlBrake=min(controlBrake,0.5f);
+            controlSpeed=0;
+        }
+
+       else if(abs(dSpeed-realSpeed)>=5 &&abs(dSpeed-realSpeed)<10&&(obsDistance>40 || obsDistance<0)&&ttc>8
+                  && !turn_around ){
+            controlBrake=min(controlBrake,0.3f);
+            controlSpeed=0;
+        }
+        else if(abs(dSpeed-realSpeed)>=10 &&abs(dSpeed-realSpeed)<15&&(obsDistance>40 || obsDistance<0)&&ttc>8
+                && dSpeed>0 && !turn_around ){
+            controlBrake=min(controlBrake,0.5f);
+            controlSpeed=0;
+        }
+
+
+        //0110
+        if(changingDangWei){
+            controlBrake=max(0.5f,controlBrake);
+        }
+
+        //斜坡刹车加大 lsn 0217
+        if (abs(now_gps_ins.ins_pitch_angle)>2.5 &&(controlBrake>0||dSpeed==0)){
+            controlBrake=max(2.0f,controlBrake);
+        }
+        //斜坡刹车加大 end
+
+
+
+
+
+    }
+    else
+    {
+        controlBrake = 0;
+
+        if(ServiceCarStatus.torque_st==0){
+            controlSpeed = (u*(-16)+((0-u)-ServiceCarStatus.mfCalAcc)*10)*0.7; //*1.0
+            controlSpeed =min( controlSpeed,2.0f);
+
+        }else{
+            controlSpeed= ServiceCarStatus.torque_st+((0-u)-ServiceCarStatus.mfCalAcc)*20;//1115    *10
+        }
+
+        //        if(((gpsIns.ins_pitch_angle>-2.5 && ServiceCarStatus.daocheMode)||
+        //            (gpsIns.ins_pitch_angle<2.5 && !ServiceCarStatus.daocheMode))){
+        //            if(realSpeed<5  ){
+        //                controlSpeed=min((float)25.0,controlSpeed); //youmenxianxiao  30
+        //            }else if(realSpeed<10){
+        //                controlSpeed=min((float)25.0,controlSpeed);  //40
+        //            }
+        //        }
+
+
+        //   controlSpeed = min((float)(ServiceCarStatus.torque_st+1.0),controlSpeed); //1115 5.0
+
+//        if(accAim>0 && ServiceCarStatus.mfCalAcc>0  && realSpeed>1 ){
+//            if(controlSpeed>0){
+//                controlSpeed = ServiceCarStatus.torque_st;
+//            }
+//        }else if(accAim<0 && ServiceCarStatus.mfCalAcc<0 && dSpeed>0){
+//            if(controlSpeed>0 ){
+//                controlSpeed = ServiceCarStatus.torque_st;
+//            }
+//        }
+
+
+        if(controlSpeed>ServiceCarStatus.torque_st){
+            controlSpeed = min(ServiceCarStatus.torque_st+1.0f,controlSpeed);
+        }else if(controlSpeed<ServiceCarStatus.torque_st){
+            controlSpeed = ServiceCarStatus.torque_st-1.0;
+        }
+
+
+
+
+        //Seizing
+        if((ServiceCarStatus.torque_st==controlSpeed-1)&&dSpeed>1){
+            seizingCount++;
+        }else{
+            seizingCount=0;
+        }
+        if(seizingCount>=10){
+            controlSpeed=ServiceCarStatus.torque_st+2;
+        }
+
+//        if(controlSpeed==2.0 && ServiceCarStatus.torque_st<2){
+//          controlSpeed=2.4;
+//        }
+        //seizing end
+
+
+
+
+
+
+        // 斜坡加大油门   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);
+        }
+        // 斜坡加大油门  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
+        }
+
+    }
+
+    if(controlSpeed>0){
+        controlSpeed=max(controlSpeed,2.4f);
+    }
+
+    //0227 10m nei xianzhi shache
+    if(obsDistance<10 &&obsDistance>0){
+        controlSpeed=0;
+        controlBrake=max(controlBrake,0.8f);
+    }
+
+
+    if(DecideGps00::minDecelerate<0){
+        controlBrake = max((0-DecideGps00::minDecelerate),controlBrake);
+        controlSpeed=0;
+    }
+
+    controlBrake=limitBrake(realSpeed,controlBrake,dSpeed,obsDistance,ttc);
+
+    controlSpeed = limitSpeed(realSpeed, controlBrake, dSpeed, controlSpeed);
+
+   // (*decition)->brake = controlBrake*10;
+      (*decition)->brake = controlBrake*9;
+
+    (*decition)->torque=controlSpeed;
+      lastBrake= (*decition)->brake;
+
+
+
+
+
+    lastTorque=(*decition)->torque;
+
+
+
+
+    (*decition)->grade=1;
+    (*decition)->mode=1;
+    (*decition)->speak=0;
+    (*decition)->handBrake=1;  // 0: laqi 1: shifang
+    (*decition)->bright=false;
+    (*decition)->engine=0;
+
+    (*decition)->dangweiEnable=true;
+    (*decition)->angleEnable=true;
+    (*decition)->speedEnable=true;
+    (*decition)-> brakeEnable=true;
+    (*decition)->driveMode=1;
+    (*decition)->brakeType=0;
+    (*decition)->angSpeed=60;
+    (*decition)->topLight=0;
+
+
+    if(ServiceCarStatus.bocheMode ||ServiceCarStatus.daocheMode){
+        (*decition)->dangWei=2;
+        (*decition)->backLight=1;
+    }
+    //1220
+    else{
+        (*decition)->dangWei=4;
+        (*decition)->backLight=0;
+    }
+
+
+
+    if((*decition)->brake>0){
+        (*decition)->brakeLight=1;
+    }else{
+        (*decition)->brakeLight=0;
+    }
+
+
+    if((*decition)->leftlamp){
+        (*decition)->directLight=1;
+    }else if((*decition)->rightlamp){
+         (*decition)->directLight=2;
+    }else{
+        (*decition)->directLight=0;
+    }
+
+    (*decition)->handBrake=false;
+    (*decition)->wheel_angle+=ServiceCarStatus.mfEPSOff;
+
+    (*decition)->wheel_angle=max((float)-870.0,(*decition)->wheel_angle);
+     (*decition)->wheel_angle=min((float)870.0,(*decition)->wheel_angle);
+
+
+
+
+        //dangweiTrasfer
+//             if((decition_gps->dangWei!=ServiceCarStatus.dangwei_st && ServiceCarStatus.dangwei_st!=0)){
+//                 decition_gps->dangWei=2;
+//                 decition_gps->torque=0;
+//             }
+     lastDangWei= (*decition)->dangWei;
+
+            (*decition)->topLight=0; //1116
+            (*decition)->nearLight=0;
+             (*decition)->farLight=0;
+
+
+
+       //(*decition)->door=3;
+
+std::cout<<"==========================================="<<std::endl;
+     std::cout<<"dSpeed:"<<dSpeed<<"   realSpeed:"<<realSpeed<<"   acc:"<<accAim<<"  torque_st:"<<ServiceCarStatus.torque_st
+             <<"  decideTorque:"<<(*decition)->torque <<"  decideBrake:"<<(*decition)->brake
+    <<std::endl;
+std::cout<<"========================================="<<std::endl;
+
+
+   (*decition)->accelerator=  (*decition)->torque ;
+    return *decition;
+}
+
+
+
+float iv::decition::BusAdapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
+
+    //刹车限制
+
+    //刹车限制
+
+    float vs =realSpeed*3.6;
+    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 {
+        BrakeIntMax = 5;
+    }
+    if(obsDistance>0 && obsDistance<10){
+        BrakeIntMax=max(BrakeIntMax,3);
+    }
+
+    if (controlBrake > BrakeIntMax) controlBrake = BrakeIntMax;
+
+
+
+
+    controlBrake=min(5.0f,controlBrake);
+    controlBrake=max(0.0f,controlBrake);
+    return controlBrake;
+
+}
+
+float iv::decition::BusAdapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
+
+    controlSpeed=min((float)100.0,controlSpeed);
+    controlSpeed=max((float)0.0,controlSpeed);
+    return controlSpeed;
+}
+
+

+ 43 - 0
src/decition/decition_brain/decition/adc_adapter/bus_adapter.h

@@ -0,0 +1,43 @@
+#ifndef BUS_ADAPTER_H
+#define BUS_ADAPTER_H
+
+
+#include <common/gps_type.h>
+#include <decision/decition_type.h>
+#include <common/obstacle_type.h>
+#include <vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_adapter/base_adapter.h>
+#include <decision/adc_tools/transfer.h>
+#include <decision/decide_gps_00.h>
+
+
+namespace iv {
+     namespace decition {
+         class BusAdapter: public BaseAdapter {
+                    public:
+
+                        float lastTorque;
+                        float lastBrake;
+                        int lastDangWei=0;
+
+
+                        BusAdapter();
+                        ~BusAdapter();
+
+                        iv::decition::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decition);
+
+                        float limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc);
+                        float limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed );
+
+                    private:
+                        int seizingCount=0;
+
+            };
+
+    }
+}
+
+
+#endif // BUS_ADAPTER_H

+ 193 - 0
src/decition/decition_brain/decition/adc_adapter/ge3_adapter.cpp

@@ -0,0 +1,193 @@
+#include <decision/adc_adapter/ge3_adapter.h>
+#include <common/constants.h>
+#include <common/car_status.h>
+#include <math.h>
+#include <iostream>
+#include <fstream>
+
+
+using namespace std;
+
+
+iv::decition::Ge3Adapter::Ge3Adapter(){
+    adapter_id=0;
+    adapter_name="ge3";
+}
+iv::decition::Ge3Adapter::~Ge3Adapter(){
+
+}
+
+
+
+iv::decition::Decition iv::decition::Ge3Adapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
+                                                                   float  obsSpeed,float accAim,float accNow  ,bool changingDangWei,Decition *decition){
+
+
+    float controlSpeed=0;
+    float controlBrake=0;
+    float realSpeed = now_gps_ins.speed;
+    float ttc = 0-(obsDistance/obsSpeed);
+    if(ttc<0){
+        ttc=15;
+    }
+    if (accAim < 0)
+    {
+        if(obsDistance<10 && obsDistance>0 ){
+            if(ttc>3){
+                controlBrake = (int)((0-accAim) * 40.0) + 1;  //(u * 14.0) + 1;
+            }else{
+                controlBrake = (int)((0-accAim) * 60.0) + 1;  //(u * 14.0) + 1;
+            }
+        } else{
+            if(ttc<5){
+                controlBrake = (int)((0-accAim) * 40.0) + 1;  //(u * 14.0) + 1;
+            }else {
+                controlBrake = (int)((0-accAim) * 20.0) + 1;  //(u * 14.0) + 1;
+            }
+        }
+        controlSpeed = 0;
+        if(obsDistance>50 && ttc>8 &&abs(realSpeed-dSpeed)<3){
+            controlBrake=0;
+            controlSpeed=max(lastTorque-10.0,0.0);
+        }
+    }
+    else
+    {
+        controlBrake = 0;
+        if(lastTorque==0){
+            controlSpeed=100;
+        }else{
+            controlSpeed = lastTorque+(accAim-accNow)*500*0.1;
+        }
+    }
+
+
+
+    if(ServiceCarStatus.bocheMode){
+        if(dSpeed<6){
+            controlSpeed=min(1.0f,controlSpeed);
+            controlBrake=min(5.0f,controlBrake);
+            if(abs(dSpeed-realSpeed)<2 && controlBrake>0){
+                controlBrake=0;
+            }
+        }
+    }
+
+
+    controlBrake=limitBrake(realSpeed,controlBrake,dSpeed,obsDistance,ttc);
+
+    controlSpeed = limitSpeed(realSpeed, controlBrake, dSpeed, controlSpeed);
+
+    if(DecideGps00::minDecelerate<0){
+        controlBrake = max((0-DecideGps00::minDecelerate)*30,controlBrake);
+        controlSpeed=0;
+    }
+    controlBrake=min(controlBrake,100.0f);
+    controlBrake=max(controlBrake,0.0f);
+
+    (*decition)->brake = controlBrake;
+
+    (*decition)->torque= controlSpeed;
+
+
+
+
+
+
+    lastTorque=(*decition)->torque;
+
+
+    (*decition)->grade=1;
+    (*decition)->mode=1;
+    (*decition)->speak=0;
+    (*decition)->handBrake=0;
+    (*decition)->bright=false;
+    (*decition)->engine=0;
+
+    if(ServiceCarStatus.bocheMode){
+        (*decition)->dangWei=2;
+    }else{
+        (*decition)->dangWei=1;
+    }
+
+
+    (*decition)->wheel_angle=max((float)-500.0,float((*decition)->wheel_angle+ServiceCarStatus.mfEPSOff));
+    (*decition)->wheel_angle=min((float)500.0,(*decition)->wheel_angle);
+
+    (*decition)->air_enable=true;
+
+
+
+    return *decition;
+}
+
+
+
+float iv::decition::Ge3Adapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
+
+    //刹车限制
+
+    int BrakeIntMax = 0;
+    if (realSpeed < 10.0 / 3.6) BrakeIntMax = 40;
+    else if (realSpeed < 20.0 / 3.6) BrakeIntMax = 60;
+    else BrakeIntMax = 100;
+
+    if (controlBrake > BrakeIntMax) controlBrake = BrakeIntMax;
+
+    if ((obsDistance>0 && obsDistance < 6) || dSpeed == 0)
+    {
+        controlBrake = max(30.0f, controlBrake);
+    }
+    if (obsDistance>0 && obsDistance<10&&obsDistance>0)
+    {
+        controlBrake = max(20.0f, controlBrake);
+    }
+    if (obsDistance<10&&obsDistance>0 &&ttc<8)
+    {
+        controlBrake = max(30.0f, controlBrake);
+    }
+    if (obsDistance<10&&obsDistance>0 &&ttc<5)
+    {
+        controlBrake = max(40.0f, controlBrake);
+    }
+    if (obsDistance<10&&obsDistance>0 &&ttc<1.6)
+    {
+        controlBrake = max(60.0f, controlBrake);
+    }
+    if(obsDistance<5 && obsDistance>0 ){
+        controlBrake = max(60.0f, controlBrake);
+    }
+    if(obsDistance<5 && obsDistance>0 &&ttc<8){
+        controlBrake = max(80.0f, controlBrake);
+    }
+    controlBrake=min(100.0f,controlBrake);
+    return controlBrake;
+
+}
+
+float iv::decition::Ge3Adapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
+    if(controlBrake>0){
+        controlSpeed=0;
+    }
+
+    if(realSpeed<10){
+        controlSpeed=min((float)400.0,controlSpeed);
+    }else if(realSpeed<30){
+        controlSpeed =min((float)600.0,controlSpeed);
+    }
+    if(controlSpeed>0){
+        if(controlSpeed>lastTorque){
+            controlSpeed=min(float(lastTorque+5.0),controlSpeed);
+        }
+    }
+    if(dSpeed <= 3)
+    {
+        controlSpeed = min(controlSpeed,20.0f);
+    }
+
+    controlSpeed=min((float)1200.0,controlSpeed);
+    controlSpeed=max((float)0.0,controlSpeed);
+    return controlSpeed;
+}
+
+

+ 60 - 0
src/decition/decition_brain/decition/adc_adapter/ge3_adapter.h

@@ -0,0 +1,60 @@
+#ifndef GE3_ADAPTER_H
+#define GE3_ADAPTER_H
+
+
+
+#include <common/gps_type.h>
+#include <decision/decition_type.h>
+#include <common/obstacle_type.h>
+#include <vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_adapter/base_adapter.h>
+#include <decision/adc_tools/transfer.h>
+#include <decision/decide_gps_00.h>
+
+
+namespace iv {
+     namespace decition {
+         class Ge3Adapter: public BaseAdapter {
+                    public:
+
+                        float lastTorque;
+                        float lastBrake;
+
+                        Ge3Adapter();
+                        ~Ge3Adapter();
+
+                        iv::decition::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decition);
+
+                        float limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc);
+                        float limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed );
+
+                    private:
+
+            };
+
+    }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#endif // GE3_ADAPTER_H

+ 357 - 0
src/decition/decition_brain/decition/adc_adapter/hapo_adapter.cpp

@@ -0,0 +1,357 @@
+#include <decision/adc_adapter/hapo_adapter.h>
+#include <common/constants.h>
+#include <common/car_status.h>
+#include <math.h>
+#include <iostream>
+#include <fstream>
+#include <QTime>
+
+QTime doorOpenTime;
+
+using namespace std;
+
+iv::decition::HapoAdapter::HapoAdapter(){
+    adapter_id=5;
+    adapter_name="hapo";
+}
+iv::decition::HapoAdapter::~HapoAdapter(){
+
+}
+
+#include "ivlog.h"
+extern iv::Ivlog * givlog;
+
+iv::decition::Decition iv::decition::HapoAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
+                                                                        float  obsSpeed,float accAim,float accNow  ,bool changingDangWei,Decition *decition){
+    accAim=min(0.7f,accAim);
+
+    float controlSpeed=0;
+    float controlBrake=0;
+    float u = 0- accAim;
+    float realSpeed = now_gps_ins.speed;
+    float ttc = 0-(obsDistance/obsSpeed);
+    bool turn_around=false;
+    if(now_gps_ins.roadMode==14||now_gps_ins.roadMode==15||now_gps_ins.roadMode==16||now_gps_ins.roadMode==17){
+        turn_around=true;
+    }
+
+    if(ttc<0){
+        ttc=15;
+    }
+    if (accAim < 0)
+    {
+        controlSpeed=0;
+        controlBrake=u; //102
+        if(obsDistance>0 && obsDistance<6){
+            controlBrake= u*1.5;
+        }
+         if(abs(dSpeed-realSpeed)<3 &&(obsDistance>40 || obsDistance<0)&&ttc>5 && dSpeed>0 && turn_around
+                 && dSpeed>0 && lastBrake==0){
+            controlBrake=0;
+            controlSpeed=0;
+        }else if(abs(realSpeed)<15 &&(obsDistance>40 || obsDistance<0)&&ttc>5 && dSpeed>0 && turn_around){
+            controlBrake=min(controlBrake,0.5f);
+            controlSpeed=0;
+        }
+
+       else if(abs(dSpeed-realSpeed)>=5 &&abs(dSpeed-realSpeed)<10&&(obsDistance>40 || obsDistance<0)&&ttc>5
+                  && !turn_around ){
+            controlBrake=min(controlBrake,0.3f);
+            controlSpeed=0;
+        }
+        else if(abs(dSpeed-realSpeed)>=10 &&abs(dSpeed-realSpeed)<15&&(obsDistance>40 || obsDistance<0)&&ttc>5
+                && dSpeed>0 && !turn_around ){
+            controlBrake=min(controlBrake,0.5f);
+            controlSpeed=0;
+        }
+
+
+        //0110
+        if(changingDangWei){
+            controlBrake=max(0.5f,controlBrake);
+        }
+
+        //斜坡刹车加大 lsn 0217
+        if (abs(now_gps_ins.ins_pitch_angle)>2.5 &&(controlBrake>0||dSpeed==0)){
+            controlBrake=max(2.0f,controlBrake);
+        }
+        //斜坡刹车加大 end
+
+
+
+
+
+    }
+    else
+    {
+        controlBrake = 0;
+
+        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
+        }
+
+        //        if(((gpsIns.ins_pitch_angle>-2.5 && ServiceCarStatus.daocheMode)||
+        //            (gpsIns.ins_pitch_angle<2.5 && !ServiceCarStatus.daocheMode))){
+        //            if(realSpeed<5  ){
+        //                controlSpeed=min((float)25.0,controlSpeed); //youmenxianxiao  30
+        //            }else if(realSpeed<10){
+        //                controlSpeed=min((float)25.0,controlSpeed);  //40
+        //            }
+        //        }
+
+
+        //   controlSpeed = min((float)(ServiceCarStatus.torque_st+1.0),controlSpeed); //1115 5.0
+
+//        if(accAim>0 && ServiceCarStatus.mfCalAcc>0  && realSpeed>1 ){
+//            if(controlSpeed>0){
+//                controlSpeed = ServiceCarStatus.torque_st;
+//            }
+//        }else if(accAim<0 && ServiceCarStatus.mfCalAcc<0 && dSpeed>0){
+//            if(controlSpeed>0 ){
+//                controlSpeed = ServiceCarStatus.torque_st;
+//            }
+//        }
+
+
+        if(controlSpeed>ServiceCarStatus.torque_st){
+            controlSpeed = min(ServiceCarStatus.torque_st+2.0f,controlSpeed);
+        }else if(controlSpeed<ServiceCarStatus.torque_st){
+            controlSpeed = ServiceCarStatus.torque_st-1.0f;
+        }
+
+
+
+
+        //Seizing
+        if((ServiceCarStatus.torque_st==controlSpeed-1)&&dSpeed>1){
+            seizingCount++;
+        }else{
+            seizingCount=0;
+        }
+        if(seizingCount>=10){
+            controlSpeed=ServiceCarStatus.torque_st+2;
+        }
+
+       if(controlSpeed==2.0 && ServiceCarStatus.torque_st<2){
+          controlSpeed=2.4;
+        }
+        //seizing end
+
+
+
+
+
+
+        // 斜坡加大油门   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);
+//        }
+        // 斜坡加大油门  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
+//        }
+
+    }
+//0125
+    if(controlSpeed>0){
+        controlSpeed=max(controlSpeed,2.4f);
+    }
+
+    //0227 10m nei xianzhi shache
+    if(obsDistance<6 &&obsDistance>0){
+        controlSpeed=0;
+        controlBrake=max(controlBrake,0.8f);
+    }
+
+
+    if(DecideGps00::minDecelerate<0){
+        controlBrake = max((0-DecideGps00::minDecelerate),controlBrake);
+        controlSpeed=0;
+    }
+
+    controlBrake=limitBrake(realSpeed,controlBrake,dSpeed,obsDistance,ttc);
+
+    controlSpeed = limitSpeed(realSpeed, controlBrake, dSpeed, controlSpeed);
+
+   // (*decition)->brake = controlBrake*10;
+      (*decition)->brake = controlBrake*6;
+
+    (*decition)->torque=controlSpeed;
+      lastBrake= (*decition)->brake;
+
+
+
+
+
+    lastTorque=(*decition)->torque;
+
+
+
+
+    (*decition)->grade=1;
+    (*decition)->mode=1;
+    (*decition)->speak=0;
+    (*decition)->handBrake=1;  // 0: laqi 1: shifang
+    (*decition)->bright=false;
+    (*decition)->engine=0;
+
+    (*decition)->dangweiEnable=true;
+    (*decition)->angleEnable=true;
+    (*decition)->speedEnable=true;
+    (*decition)-> brakeEnable=true;
+    (*decition)->air_enable=false;
+    (*decition)->driveMode=1;
+    (*decition)->brakeType=0;
+    (*decition)->angSpeed=60;
+    (*decition)->topLight=0;
+
+
+    if(ServiceCarStatus.bocheMode ||ServiceCarStatus.daocheMode){
+        (*decition)->dangWei=2;
+        (*decition)->backLight=1;
+    }
+    //1220
+    else{
+        (*decition)->dangWei=4;
+        (*decition)->backLight=0;
+    }
+
+
+
+    if((*decition)->brake>0){
+        (*decition)->brakeLight=1;
+    }else{
+        (*decition)->brakeLight=0;
+    }
+
+
+    if((*decition)->leftlamp){
+        (*decition)->directLight=1;
+    }else if((*decition)->rightlamp){
+         (*decition)->directLight=2;
+    }else{
+        (*decition)->directLight=0;
+    }
+
+    (*decition)->handBrake=false;
+    (*decition)->wheel_angle+=ServiceCarStatus.mfEPSOff;
+
+    (*decition)->wheel_angle=max((float)-870.0,(*decition)->wheel_angle);
+     (*decition)->wheel_angle=min((float)870.0,(*decition)->wheel_angle);
+
+
+
+
+        //dangweiTrasfer
+//             if((decition_gps->dangWei!=ServiceCarStatus.dangwei_st && ServiceCarStatus.dangwei_st!=0)){
+//                 decition_gps->dangWei=2;
+//                 decition_gps->torque=0;
+//             }
+     lastDangWei= (*decition)->dangWei;
+
+            (*decition)->topLight=0; //1116
+            (*decition)->nearLight=0;
+             (*decition)->farLight=0;
+
+     if(ServiceCarStatus.stationCmd.mode_manual_drive==true)
+     {
+          (*decition)->mode=0;
+     }
+
+
+     if(ServiceCarStatus.station_control_door==0)
+     {
+         (*decition)->door=false;      //CLOSE
+         doorOpenTime.start();
+         givlog->debug("DOOR","STATUS is: %d",5);
+
+     }else if((ServiceCarStatus.station_control_door==1)&&(ServiceCarStatus.station_control_door_option==false))
+     {
+         (*decition)->door=true;       //OPEN
+         (*decition)->brake =6;
+         (*decition)->torque=0;
+         if(doorOpenTime.elapsed()>6000)
+         {
+             ServiceCarStatus.station_control_door_option=true;
+             givlog->debug("DOOR","STATUS is: %d",8);
+         }
+     }
+
+givlog->debug("DOOR","door is: %d",(*decition)->door);
+givlog->debug("DOOR","station_control_door is: %d",ServiceCarStatus.station_control_door);
+
+std::cout<<"==========================================="<<std::endl;
+     std::cout<<"dSpeed:"<<dSpeed<<"   realSpeed:"<<realSpeed<<"   acc:"<<accAim<<"  torque_st:"<<ServiceCarStatus.torque_st
+             <<"  decideTorque:"<<(*decition)->torque <<"  decideBrake:"<<(*decition)->brake
+    <<std::endl;
+std::cout<<"========================================="<<std::endl;
+
+
+   (*decition)->accelerator=  (*decition)->torque ;
+
+
+givlog->debug("obs_distance","dSpeed: %f, realSpeed: %f, brake: %f",
+              dSpeed, realSpeed,(*decition)->brake);
+
+    return *decition;
+}
+
+
+
+float iv::decition::HapoAdapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
+
+    //刹车限制
+
+    //刹车限制
+
+    float vs =realSpeed*3.6;
+    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 {
+        BrakeIntMax = 5;
+    }
+    if(obsDistance>0 && obsDistance<10){
+        BrakeIntMax=max(BrakeIntMax,3);
+    }
+
+    if (controlBrake > BrakeIntMax) controlBrake = BrakeIntMax;
+
+
+
+
+    controlBrake=min(5.0f,controlBrake);
+    controlBrake=max(0.0f,controlBrake);
+    return controlBrake;
+
+}
+
+float iv::decition::HapoAdapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
+
+    controlSpeed=min((float)100.0,controlSpeed);
+    controlSpeed=max((float)0.0,controlSpeed);
+    return controlSpeed;
+}
+
+

+ 43 - 0
src/decition/decition_brain/decition/adc_adapter/hapo_adapter.h

@@ -0,0 +1,43 @@
+#ifndef HAPO_ADAPTER_H
+#define HAPO_ADAPTER_H
+
+
+#include <common/gps_type.h>
+#include <decision/decition_type.h>
+#include <common/obstacle_type.h>
+#include <vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_adapter/base_adapter.h>
+#include <decision/adc_tools/transfer.h>
+#include <decision/decide_gps_00.h>
+
+
+namespace iv {
+     namespace decition {
+         class HapoAdapter: public BaseAdapter {
+                    public:
+
+                        float lastTorque;
+                        float lastBrake;
+                        int lastDangWei=0;
+
+
+                        HapoAdapter();
+                        ~HapoAdapter();
+
+                        iv::decition::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decition);
+
+                        float limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc);
+                        float limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed );
+
+                    private:
+                        int seizingCount=0;
+
+            };
+
+    }
+}
+
+
+#endif // HAPO_ADAPTER_H

+ 312 - 0
src/decition/decition_brain/decition/adc_adapter/qingyuan_adapter.cpp

@@ -0,0 +1,312 @@
+#include <decision/adc_adapter/qingyuan_adapter.h>
+#include <common/constants.h>
+#include <common/car_status.h>
+#include <math.h>
+#include <iostream>
+#include <fstream>
+
+
+using namespace std;
+
+
+iv::decition::QingYuanAdapter::QingYuanAdapter(){
+    adapter_id=1;
+    adapter_name="qingyuan";
+}
+iv::decition::QingYuanAdapter::~QingYuanAdapter(){
+
+}
+
+
+
+iv::decition::Decition iv::decition::QingYuanAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
+                                                                        float  obsSpeed,float accAim,float accNow  ,bool changingDangWei,Decition *decition){
+
+
+    float controlSpeed=0;
+    float controlBrake=0;
+    float u = 0- accAim;
+    float realSpeed = now_gps_ins.speed;
+    float ttc = 0-(obsDistance/obsSpeed);
+    bool turn_around=false;
+    if(now_gps_ins.roadMode==14||now_gps_ins.roadMode==15||now_gps_ins.roadMode==16||now_gps_ins.roadMode==17){
+        turn_around=true;
+    }
+
+    if(ttc<0){
+        ttc=15;
+    }
+    if (accAim < 0)
+    {
+        controlSpeed=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 && !turn_around){
+            controlBrake=0;
+            controlSpeed=max(0.0,ServiceCarStatus.torque_st-10.0);
+        }else if(abs(dSpeed-realSpeed)<3 &&(obsDistance>40 || obsDistance<0)&&ttc>8 && dSpeed>0 && turn_around){
+            controlBrake=0;
+            controlSpeed=0;
+        }else if(abs(realSpeed)<15 &&(obsDistance>40 || obsDistance<0)&&ttc>8 && dSpeed>0 && turn_around){
+            controlBrake=min(controlBrake,0.5f);
+            controlSpeed=0;
+        }
+
+        else if(abs(dSpeed-realSpeed)>=3 &&abs(dSpeed-realSpeed)<5&&(obsDistance>40 || obsDistance<0)&&ttc>8
+                && dSpeed>0 && !turn_around ){
+            controlBrake=0;
+            controlSpeed=0;
+        }else if(abs(dSpeed-realSpeed)>=5 &&abs(dSpeed-realSpeed)<10&&(obsDistance>40 || obsDistance<0)&&ttc>8
+                 && dSpeed>0 && !turn_around ){
+            controlBrake=min(controlBrake,0.3f);
+            controlSpeed=0;
+        }
+        else if(abs(dSpeed-realSpeed)>=10 &&abs(dSpeed-realSpeed)<15&&(obsDistance>40 || obsDistance<0)&&ttc>8
+                && dSpeed>0 && !turn_around ){
+            controlBrake=min(controlBrake,0.5f);
+            controlSpeed=0;
+        }
+
+
+        //0110
+        if(changingDangWei){
+            controlBrake=max(0.5f,controlBrake);
+        }
+
+        //斜坡刹车加大 lsn 0217
+        if (abs(now_gps_ins.ins_pitch_angle)>2.5 &&(controlBrake>0||dSpeed==0)){
+            controlBrake=max(2.0f,controlBrake);
+        }
+        //斜坡刹车加大 end
+
+
+
+
+
+    }
+    else
+    {
+        controlBrake = 0;
+
+        if(ServiceCarStatus.torque_st==0){
+            controlSpeed = (u*(-16)+((0-u)-ServiceCarStatus.mfCalAcc)*10)*0.7; //*1.0
+            controlSpeed =min( controlSpeed,1.0f);
+
+        }else{
+            controlSpeed= ServiceCarStatus.torque_st+((0-u)-ServiceCarStatus.mfCalAcc)*10;//1115    *10
+        }
+
+        //        if(((gpsIns.ins_pitch_angle>-2.5 && ServiceCarStatus.daocheMode)||
+        //            (gpsIns.ins_pitch_angle<2.5 && !ServiceCarStatus.daocheMode))){
+        //            if(realSpeed<5  ){
+        //                controlSpeed=min((float)25.0,controlSpeed); //youmenxianxiao  30
+        //            }else if(realSpeed<10){
+        //                controlSpeed=min((float)25.0,controlSpeed);  //40
+        //            }
+        //        }
+
+
+        //   controlSpeed = min((float)(ServiceCarStatus.torque_st+1.0),controlSpeed); //1115 5.0
+        if(controlSpeed>ServiceCarStatus.torque_st){
+            controlSpeed = ServiceCarStatus.torque_st+1.0;
+        }else if(controlSpeed<ServiceCarStatus.torque_st){
+            controlSpeed = ServiceCarStatus.torque_st-1.0;
+        }
+
+
+
+
+
+
+        //Seizing
+        if((ServiceCarStatus.torque_st==controlSpeed-1)&&dSpeed>1&&realSpeed<0.5){
+            seizingCount++;
+        }else{
+            seizingCount=0;
+        }
+        if(seizingCount>=10){
+            controlSpeed=ServiceCarStatus.torque_st+2;
+        }
+        //seizing end
+
+
+
+
+        // 斜坡加大油门   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);
+        }
+        // 斜坡加大油门  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
+        }
+
+    }
+
+    //0227 10m nei xianzhi shache
+    if(obsDistance<10 &&obsDistance>0){
+        controlSpeed=0;
+        controlBrake=max(controlBrake,0.8f);
+    }
+
+
+    if(DecideGps00::minDecelerate<0){
+        controlBrake = max((0-DecideGps00::minDecelerate),controlBrake);
+        controlSpeed=0;
+    }
+
+    controlBrake=limitBrake(realSpeed,controlBrake,dSpeed,obsDistance,ttc);
+
+    controlSpeed = limitSpeed(realSpeed, controlBrake, dSpeed, controlSpeed);
+
+    (*decition)->brake = controlBrake;
+
+    (*decition)->torque=controlSpeed;
+
+
+
+
+
+
+    lastTorque=(*decition)->torque;
+
+
+
+
+    (*decition)->grade=1;
+    (*decition)->mode=1;
+    (*decition)->speak=0;
+    (*decition)->handBrake=1;  // 0: laqi 1: shifang
+    (*decition)->bright=false;
+    (*decition)->engine=0;
+
+    (*decition)->dangweiEnable=true;
+    (*decition)->angleEnable=true;
+    (*decition)->speedEnable=true;
+    (*decition)-> brakeEnable=true;
+    (*decition)->driveMode=1;
+    (*decition)->brakeType=0;
+    (*decition)->angSpeed=60;
+    (*decition)->topLight=0;
+
+
+    if(ServiceCarStatus.bocheMode ||ServiceCarStatus.daocheMode){
+        (*decition)->dangWei=3;
+        (*decition)->backLight=1;
+    }
+    //1220
+    else{
+        (*decition)->dangWei=4;
+        (*decition)->backLight=0;
+    }
+
+
+
+    if((*decition)->brake>0){
+        (*decition)->brakeLight=1;
+    }else{
+        (*decition)->brakeLight=0;
+    }
+
+
+    if((*decition)->leftlamp){
+        (*decition)->directLight=1;
+    }else if((*decition)->rightlamp){
+         (*decition)->directLight=2;
+    }else{
+        (*decition)->directLight=0;
+    }
+
+
+    (*decition)->wheel_angle+=ServiceCarStatus.mfEPSOff;
+
+    (*decition)->wheel_angle=max((float)-570.0,(*decition)->wheel_angle);
+     (*decition)->wheel_angle=min((float)570.0,(*decition)->wheel_angle);
+
+
+
+
+        //dangweiTrasfer
+//             if((decition_gps->dangWei!=ServiceCarStatus.dangwei_st && ServiceCarStatus.dangwei_st!=0)){
+//                 decition_gps->dangWei=2;
+//                 decition_gps->torque=0;
+//             }
+     lastDangWei= (*decition)->dangWei;
+
+            (*decition)->topLight=0; //1116
+            (*decition)->nearLight=0;
+             (*decition)->farLight=0;
+
+
+
+       //(*decition)->door=3;
+
+std::cout<<"==========================================="<<std::endl;
+     std::cout<<"dSpeed:"<<dSpeed<<"   realSpeed:"<<realSpeed<<"   acc:"<<accAim<<"  torque_st:"<<ServiceCarStatus.torque_st
+             <<"  decideTorque:"<<(*decition)->torque
+    <<std::endl;
+std::cout<<"========================================="<<std::endl;
+
+    return *decition;
+}
+
+
+
+float iv::decition::QingYuanAdapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
+
+    //刹车限制
+
+    //刹车限制
+
+    float vs =realSpeed*3.6;
+    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;
+
+
+
+
+    controlBrake=min(10.0f,controlBrake);
+    controlBrake=max(0.0f,controlBrake);
+    return controlBrake;
+
+}
+
+float iv::decition::QingYuanAdapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
+
+    controlSpeed=min((float)100.0,controlSpeed);
+    controlSpeed=max((float)0.0,controlSpeed);
+    return controlSpeed;
+}
+
+

+ 41 - 0
src/decition/decition_brain/decition/adc_adapter/qingyuan_adapter.h

@@ -0,0 +1,41 @@
+#ifndef QINGYUAN_ADAPTER_H
+#define QINGYUAN_ADAPTER_H
+
+#include <common/gps_type.h>
+#include <decision/decition_type.h>
+#include <common/obstacle_type.h>
+#include <vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_adapter/base_adapter.h>
+#include <decision/adc_tools/transfer.h>
+#include <decision/decide_gps_00.h>
+
+
+namespace iv {
+     namespace decition {
+         class QingYuanAdapter: public BaseAdapter {
+                    public:
+
+                        float lastTorque;
+                        float lastBrake;
+                        int lastDangWei=0;
+                        int seizingCount=0;
+
+                        QingYuanAdapter();
+                        ~QingYuanAdapter();
+
+                        iv::decition::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decition);
+
+                        float limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc);
+                        float limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed );
+
+                    private:
+
+            };
+
+    }
+}
+
+
+#endif // QINGYUAN_ADAPTER_H

+ 150 - 0
src/decition/decition_brain/decition/adc_adapter/vv7_adapter.cpp

@@ -0,0 +1,150 @@
+#include <decision/adc_adapter/vv7_adapter.h>
+#include <common/constants.h>
+#include <common/car_status.h>
+#include <math.h>
+#include <iostream>
+#include <fstream>
+
+
+using namespace std;
+
+
+iv::decition::VV7Adapter::VV7Adapter(){
+    adapter_id= 2;
+    adapter_name="vv7";
+}
+iv::decition::VV7Adapter::~VV7Adapter(){
+
+}
+
+
+
+iv::decition::Decition iv::decition::VV7Adapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
+                                                                        float  obsSpeed,float accAim,float accNow  ,bool changingDangWei,Decition *decition){
+
+
+    float controlSpeed=accAim;
+    float controlBrake=0;
+    float u = 0- accAim;
+    float realSpeed = now_gps_ins.speed;
+    float ttc = 0-(obsDistance/obsSpeed);
+    bool turn_around=false;
+    if(now_gps_ins.roadMode==14||now_gps_ins.roadMode==15||now_gps_ins.roadMode==16||now_gps_ins.roadMode==17){
+        turn_around=true;
+    }
+
+    if(ttc<0){
+        ttc=15;
+    }
+    if (accAim < 0)
+    {
+        //0110
+        if(changingDangWei){
+            controlSpeed=min(-0.5f,controlSpeed);
+        }
+//        else if((obsDistance<0 ||obsDistance>50)&&(abs(dSpeed-realSpeed)<3)){
+//             controlSpeed=max(-0.2f,controlSpeed);
+//        }
+    }
+    else
+    {
+        controlSpeed=min(1.0f,controlSpeed);
+
+    }
+
+    //0227 10m nei xianzhi shache
+    if(obsDistance<10 &&obsDistance>0){
+        controlSpeed=min(controlSpeed,-0.8f);
+    }
+
+
+    if(DecideGps00::minDecelerate<0){
+        controlSpeed = min(DecideGps00::minDecelerate, controlSpeed);
+    }
+    controlSpeed = limitSpeed(realSpeed, controlBrake, dSpeed, controlSpeed);
+
+    (*decition)->accelerator=controlSpeed;
+
+    if((*decition)->leftlamp){
+        (*decition)->directLight=1;
+    }else if((*decition)->rightlamp){
+         (*decition)->directLight=2;
+    }else{
+        (*decition)->directLight=0;
+    }
+
+
+    (*decition)->wheel_angle+=ServiceCarStatus.mfEPSOff;
+
+    (*decition)->wheel_angle=max((float)-500.0,(*decition)->wheel_angle);
+     (*decition)->wheel_angle=min((float)500.0,(*decition)->wheel_angle);
+
+    if((*decition)->accelerator>=0){
+        (*decition)->torque= (*decition)->accelerator;
+        (*decition)->brake=0;
+    }else{
+        (*decition)->torque=0;
+        (*decition)->brake=0-(*decition)->accelerator;
+    }
+
+
+
+
+std::cout<<"==========================================="<<std::endl;
+     std::cout<<"dSpeed:"<<dSpeed<<"   realSpeed:"<<realSpeed<<"   acc:"<<accAim
+    <<std::endl;
+std::cout<<"========================================="<<std::endl;
+
+    return *decition;
+}
+
+
+
+float iv::decition::VV7Adapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
+
+    //刹车限制
+
+    //刹车限制
+
+    float vs =realSpeed*3.6;
+    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;
+
+
+
+
+    controlBrake=min(10.0f,controlBrake);
+    controlBrake=max(0.0f,controlBrake);
+    return controlBrake;
+
+}
+
+float iv::decition::VV7Adapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
+
+    controlSpeed=min((float)5.0,controlSpeed);
+    controlSpeed=max((float)-7.0,controlSpeed);
+    return controlSpeed;
+}
+
+

+ 44 - 0
src/decition/decition_brain/decition/adc_adapter/vv7_adapter.h

@@ -0,0 +1,44 @@
+#ifndef VV7_ADAPTER_H
+#define VV7_ADAPTER_H
+
+#include <common/gps_type.h>
+#include <decision/decition_type.h>
+#include <common/obstacle_type.h>
+#include <vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_adapter/base_adapter.h>
+#include <decision/adc_tools/transfer.h>
+#include <decision/decide_gps_00.h>
+
+
+namespace iv {
+     namespace decition {
+         class VV7Adapter: public BaseAdapter {
+                    public:
+
+                        float lastTorque;
+                        float lastBrake;
+                        int lastDangWei=0;
+                        int seizingCount=0;
+
+                        VV7Adapter();
+                        ~VV7Adapter();
+
+                        iv::decition::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decition);
+
+                        float limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc);
+                        float limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed );
+
+                    private:
+
+            };
+
+    }
+}
+
+
+
+
+
+#endif // VV7_ADAPTER_H

+ 153 - 0
src/decition/decition_brain/decition/adc_adapter/yuhesen_adapter.cpp

@@ -0,0 +1,153 @@
+#include <decision/adc_adapter/yuhesen_adapter.h>
+#include <common/constants.h>
+#include <common/car_status.h>
+#include <math.h>
+#include <iostream>
+#include <fstream>
+
+
+using namespace std;
+
+
+iv::decition::YuHeSenAdapter::YuHeSenAdapter(){
+    adapter_id= 7;
+    adapter_name="yuhesen";
+}
+iv::decition::YuHeSenAdapter::~YuHeSenAdapter(){
+
+}
+
+
+
+iv::decition::Decition iv::decition::YuHeSenAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
+                                                                        float  obsSpeed,float accAim,float accNow  ,bool changingDangWei,Decition *decition){
+
+
+    float controlSpeed=accAim;
+    float controlBrake=0;
+    float u = 0- accAim;
+    float realSpeed = now_gps_ins.speed;
+    float ttc = 0-(obsDistance/obsSpeed);
+    bool turn_around=false;
+    if(now_gps_ins.roadMode==14||now_gps_ins.roadMode==15||now_gps_ins.roadMode==16||now_gps_ins.roadMode==17){
+        turn_around=true;
+    }
+
+    if(ttc<0){
+        ttc=15;
+    }
+    if (accAim < 0)
+    {
+        //0110
+        if(changingDangWei){
+            controlSpeed=min(-0.5f,controlSpeed);
+        }
+//        else if((obsDistance<0 ||obsDistance>50)&&(abs(dSpeed-realSpeed)<3)){
+//             controlSpeed=max(-0.2f,controlSpeed);
+//        }
+    }
+    else
+    {
+        controlSpeed=min(1.0f,controlSpeed);
+
+    }
+
+    //0227 10m nei xianzhi shache
+    if(obsDistance<10 &&obsDistance>0){
+        controlSpeed=min(controlSpeed,-0.8f);
+    }
+
+
+    if(DecideGps00::minDecelerate<0){
+        controlSpeed = min(DecideGps00::minDecelerate, controlSpeed);
+    }
+    controlSpeed = limitSpeed(realSpeed, controlBrake, dSpeed, controlSpeed);
+
+    (*decition)->accelerator=controlSpeed;
+
+    if((*decition)->leftlamp){
+        (*decition)->directLight=1;
+    }else if((*decition)->rightlamp){
+         (*decition)->directLight=2;
+    }else{
+        (*decition)->directLight=0;
+    }
+
+
+    (*decition)->wheel_angle+=ServiceCarStatus.mfEPSOff;
+
+    (*decition)->wheel_angle=max((float)-40.0,(*decition)->wheel_angle);
+     (*decition)->wheel_angle=min((float)40.0,(*decition)->wheel_angle);
+
+
+        (*decition)->brake=0;
+
+
+
+
+std::cout<<"==========================================="<<std::endl;
+     std::cout<<"dSpeed:"<<dSpeed<<"   realSpeed:"<<realSpeed<<"   acc:"<<accAim
+    <<std::endl;
+std::cout<<"========================================="<<std::endl;
+(*decition)->speed = dSpeed/3.6;
+(*decition)->wheel_angle=(*decition)->wheel_angle*0.1;
+(*decition)->wheel_angle=max((float)-40.0,(*decition)->wheel_angle);
+(*decition)->wheel_angle=min((float)40.0,(*decition)->wheel_angle);
+(*decition)->mode=1;
+(*decition)->dangWei=1;
+if((*decition)->brake>0){
+    (*decition)->speed=0;
+}
+    return *decition;
+}
+
+
+
+float iv::decition::YuHeSenAdapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
+
+    //刹车限制
+
+    //刹车限制
+
+    float vs =realSpeed*3.6;
+    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;
+
+
+
+
+    controlBrake=min(10.0f,controlBrake);
+    controlBrake=max(0.0f,controlBrake);
+    return controlBrake;
+
+}
+
+float iv::decition::YuHeSenAdapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
+
+    controlSpeed=min((float)5.0,controlSpeed);
+    controlSpeed=max((float)-7.0,controlSpeed);
+    return controlSpeed;
+}
+
+

+ 44 - 0
src/decition/decition_brain/decition/adc_adapter/yuhesen_adapter.h

@@ -0,0 +1,44 @@
+#ifndef YUHESEN_ADAPTER_H
+#define YUHESEN_ADAPTER_H
+
+#include <common/gps_type.h>
+#include <decision/decition_type.h>
+#include <common/obstacle_type.h>
+#include <vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_adapter/base_adapter.h>
+#include <decision/adc_tools/transfer.h>
+#include <decision/decide_gps_00.h>
+
+
+namespace iv {
+     namespace decition {
+         class YuHeSenAdapter: public BaseAdapter {
+                    public:
+
+                        float lastTorque;
+                        float lastBrake;
+                        int lastDangWei=0;
+                        int seizingCount=0;
+
+                        YuHeSenAdapter();
+                        ~YuHeSenAdapter();
+
+                        iv::decition::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decition);
+
+                        float limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc);
+                        float limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed );
+
+                    private:
+
+            };
+
+    }
+}
+
+
+
+
+
+#endif // VV7_ADAPTER_H

+ 179 - 0
src/decition/decition_brain/decition/adc_adapter/zhongche_adapter.cpp

@@ -0,0 +1,179 @@
+
+#include <decision/adc_adapter/zhongche_adapter.h>
+#include <common/constants.h>
+#include <common/car_status.h>
+#include <math.h>
+#include <iostream>
+#include <fstream>
+
+using namespace std;
+
+
+iv::decition::ZhongcheAdapter::ZhongcheAdapter(){
+    adapter_id= 3;
+    adapter_name="zhongche";
+}
+iv::decition::ZhongcheAdapter::~ZhongcheAdapter(){
+
+}
+
+
+iv::decition::Decition iv::decition::ZhongcheAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
+                                                                        float  obsSpeed,float accAim,float accNow  ,bool changingDangWei,Decition *decition){
+
+
+    float controlSpeed=accAim;
+    float controlBrake=0;
+    float u = 0- accAim;
+    float realSpeed = now_gps_ins.speed;
+    float ttc = 0-(obsDistance/obsSpeed);
+    bool turn_around=false;
+    if(now_gps_ins.roadMode==14||now_gps_ins.roadMode==15||now_gps_ins.roadMode==16||now_gps_ins.roadMode==17){
+        turn_around=true;
+    }
+
+    if(ttc<0){
+        ttc=15;
+    }
+
+
+
+
+
+     (*decition)->grade=1;
+     (*decition)->mode=1;
+     (*decition)->speak=0;
+     (*decition)->handBrake=0;
+     (*decition)->bright=false;
+     (*decition)->engine=0;
+     (*decition)->brakeLight=0;
+
+    if(ServiceCarStatus.bocheMode){
+        (*decition)->dangWei=2;
+    }else{
+        (*decition)->dangWei=1;
+    }
+
+
+    if(ttc>10 && (obsDistance>10||obsDistance<0)){
+
+
+
+
+
+        if(DecideGps00::minDecelerate<0){
+            (*decition)->torque = 0;
+            (*decition)->brake = max((0-DecideGps00::minDecelerate)*90, (*decition)->brake);
+             dSpeed=10.0;
+        }else{
+            (*decition)->torque=90;
+            (*decition)->brake=0;
+        }
+
+
+        dSpeed=max(0.0f,dSpeed);
+        dSpeed=min(10.0f, dSpeed);
+        (*decition)->speed=(int)dSpeed*10+5;
+
+        (*decition)->torque=min((float)100.0,(*decition)->torque);
+        (*decition)->torque=max((float)0.0,(*decition)->torque);
+        (*decition)->brake=min((float)100.0,(*decition)->brake);
+        (*decition)->brake=max((float)0.0,(*decition)->brake);
+
+        lastTorque=(*decition)->torque;
+
+        (*decition)->wheel_angle+=ServiceCarStatus.mfEPSOff;
+
+        (*decition)->wheel_angle=max((float)-550.0,(*decition)->wheel_angle);
+         (*decition)->wheel_angle=min((float)550.0,(*decition)->wheel_angle);
+        return *decition;
+    }
+
+
+
+    if (accAim < 0)
+    {
+        if(obsDistance<10 && obsDistance>0 &&ttc>3){
+            controlBrake = (int)(u * 40.0) + 1;  //(u * 14.0) + 1;
+        } else{
+            if(ttc<3){
+                controlBrake = (int)(u * 60.0) + 1;  //(u * 14.0) + 1;
+            }
+            else if(ttc<5){
+                controlBrake = (int)(u * 40.0) + 1;  //(u * 14.0) + 1;
+            }else {
+                controlBrake = (int)(u * 20.0) + 1;  //(u * 14.0) + 1;
+            }
+        }
+          (*decition)->brake = controlBrake;
+        (*decition)->torque=0;
+
+    }
+    else
+    {
+        controlBrake = 0;
+        (*decition)->brake=0;
+
+        if(lastTorque==0){
+             (*decition)->torque = u*(-30)+((0-u)-ServiceCarStatus.mfCalAcc)*1+
+                    now_gps_ins.ins_pitch_angle*10;
+        }else{
+             (*decition)->torque = lastTorque+((0-u)-ServiceCarStatus.mfCalAcc)*10;
+        }
+        if(realSpeed<10){
+             (*decition)->torque=min((float)40.0,(*decition)->torque);
+        }else if(realSpeed<30){
+             (*decition)->torque=min((float)60.0,(*decition)->torque);
+        }
+
+         (*decition)->torque=min((float)99.0,(*decition)->torque);
+         (*decition)->torque=max((float)0.0,(*decition)->torque);
+
+    }
+
+    //0227 10m nei xianzhi shache
+    if(obsDistance<10 &&obsDistance>0){
+        (*decition)->torque=0;
+        (*decition)->brake=max((float)30.0,(*decition)->brake);
+    }
+
+
+    if(DecideGps00::minDecelerate<0){
+        dSpeed=10;
+        (*decition)->torque = 0;
+        (*decition)->brake = min((0-DecideGps00::minDecelerate)*90, (*decition)->brake);
+    }
+
+
+    (*decition)->torque=min((float)100.0,(*decition)->torque);
+    (*decition)->torque=max((float)0.0,(*decition)->torque);
+    (*decition)->brake=min((float)100.0,(*decition)->brake);
+    (*decition)->brake=max((float)0.0,(*decition)->brake);
+
+    lastTorque=(*decition)->torque;
+
+    (*decition)->wheel_angle+=ServiceCarStatus.mfEPSOff;
+
+    (*decition)->wheel_angle=max((float)-550.0,(*decition)->wheel_angle);
+     (*decition)->wheel_angle=min((float)550.0,(*decition)->wheel_angle);
+
+
+
+    dSpeed=max(0.0f,dSpeed);
+    dSpeed=min(10.0f, dSpeed);
+    (*decition)->speed=(int)dSpeed*10+5;
+
+
+std::cout<<"==========================================="<<std::endl;
+     std::cout<<"dSpeed:"<<dSpeed<<"   realSpeed:"<<realSpeed<<"   acc:"<<accAim
+    <<std::endl;
+std::cout<<"========================================="<<std::endl;
+
+    return *decition;
+}
+
+
+
+
+
+

+ 42 - 0
src/decition/decition_brain/decition/adc_adapter/zhongche_adapter.h

@@ -0,0 +1,42 @@
+#ifndef ZHONGCHE_ADAPTER_H
+#define ZHONGCHE_ADAPTER_H
+
+#include <common/gps_type.h>
+#include <decision/decition_type.h>
+#include <common/obstacle_type.h>
+#include <vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_adapter/base_adapter.h>
+#include <decision/adc_tools/transfer.h>
+#include <decision/decide_gps_00.h>
+
+namespace iv {
+     namespace decition {
+         class ZhongcheAdapter: public BaseAdapter {
+                    public:
+
+                        float lastTorque;
+                        float lastBrake;
+                        int lastDangWei=0;
+                        int seizingCount=0;
+
+                        ZhongcheAdapter();
+                        ~ZhongcheAdapter();
+
+                        iv::decition::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decition);
+
+                        float limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc);
+                        float limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed );
+
+                    private:
+
+            };
+
+    }
+}
+
+
+
+
+#endif // ZHONGCHE_ADAPTER_H

+ 39 - 0
src/decition/decition_brain/decition/adc_controller/base_controller.cpp

@@ -0,0 +1,39 @@
+#include <common/gps_type.h>
+#include <decision/decition_type.h>
+#include <common/obstacle_type.h>
+#include <vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_controller/base_controller.h>
+
+
+
+
+iv::decition::BaseController::BaseController(){
+
+}
+iv::decition::BaseController::~BaseController(){
+
+}
+
+/**
+  * @brief iv::decition::BaseController::getControlDecition
+  * 基类BaseController的抽象方法 用于计算横向控制的方向盘和纵向控制的加速度
+  *
+  * @param now_gps_ins          实时gps信息
+  * @param path                 目标路径
+  * @param dSpeed               决策速度
+  * @param obsDistacne          障碍物距离
+  * @param obsSpeed             障碍物速度
+  * @param computeAngle         是否要计算方向盘角度
+  * @param computeAcc           是否要计算纵向加速度
+  * @param decition             决策信息结构体的指针
+  * @return                     iv::decition::Decition
+  */
+
+ iv::decition::Decition  iv::decition::BaseController::getControlDecition(GPS_INS now_gps_ins, std::vector<Point2D> path, float dSpeed, float obsDistacne,
+                                                                          float obsSpeed,bool computeAngle, bool computeAcc,Decition *decition){
+
+}
+
+
+

+ 67 - 0
src/decition/decition_brain/decition/adc_controller/base_controller.h

@@ -0,0 +1,67 @@
+#pragma once
+#ifndef _IV_DECITION__BASE_CONTROLLER_
+#define _IV_DECITION__BASE_CONTROLLER_
+
+#include <common/gps_type.h>
+#include <decision/decition_type.h>
+#include <common/obstacle_type.h>
+#include<vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+
+namespace iv {
+namespace decition {
+//根据传感器传输来的信息作出决策
+class BaseController {
+public:
+
+    int controller_id;
+    std::string  controller_name;
+
+    BaseController();
+    ~BaseController();
+
+
+    /**
+      * @brief iv::decition::BaseController::getControlDecition
+      * 基类BaseController的抽象方法 用于计算横向控制的方向盘和纵向控制的加速度
+      *
+      * @param now_gps_ins          实时gps信息
+      * @param path                 目标路径
+      * @param dSpeed               决策速度
+      * @param obsDistacne          障碍物距离
+      * @param obsSpeed             障碍物速度
+      * @param computeAngle         是否要计算方向盘角度
+      * @param computeAcc           是否要计算纵向加速度
+      * @param decition             决策信息结构体的指针
+      * @return                     iv::decition::Decition
+      */
+    virtual  iv::decition::Decition getControlDecition(GPS_INS now_gps_ins, std::vector<Point2D>  path , float dSpeed, float obsDistacne , float  obsSpeed,
+                                                       bool computeAngle, bool computeAcc, Decition *decition);
+
+
+private:
+
+
+};
+
+}
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#endif // ADC_CONTROLLER_H

+ 352 - 0
src/decition/decition_brain/decition/adc_controller/pid_controller.cpp

@@ -0,0 +1,352 @@
+#include <decision/adc_controller/pid_controller.h>
+#include <common/constants.h>
+#include <common/car_status.h>
+#include <math.h>
+#include <iostream>
+#include <fstream>
+
+
+using namespace std;
+
+
+iv::decition::PIDController::PIDController(){
+    controller_id = 0;
+    controller_name="pid";
+}
+iv::decition::PIDController::~PIDController(){
+
+}
+
+
+
+/**
+ * @brief getControlDecition
+ * pid方式计算横向方向盘和纵向加速度
+ *
+ * @param now_gps_ins          实时gps信息
+ * @param path                 目标路径
+ * @param dSpeed               决策速度
+ * @param ObsDistacne          障碍物距离
+ * @param ObsSpeed             障碍物速度
+ * @param computeAngle         是否要计算方向盘角度
+ * @param computeAcc           是否要计算纵向加速度
+ * @param decition             决策信息结构体的指针
+ * @return                     iv::decition::Decition
+ */
+
+iv::decition::Decition iv::decition::PIDController::getControlDecition(GPS_INS now_gps_ins, std::vector<Point2D> path, float dSpeed, float obsDistacne, float obsSpeed,
+                                                                       bool computeAngle, bool computeAcc, Decition *decition){
+
+    float realSpeed= now_gps_ins.speed;
+    int roadMode = now_gps_ins.roadMode;
+    if(computeAngle){
+        (*decition)->wheel_angle=getPidAngle( realSpeed,  path,roadMode);
+    }
+    if(computeAcc){
+        (*decition)->accelerator=getPidAcc( now_gps_ins, dSpeed,  obsDistacne,  obsSpeed);
+    }
+    return *decition;
+}
+
+
+
+
+float iv::decition::PIDController::getPidAngle(float realSpeed, std::vector<Point2D> trace, int roadMode){
+    double ang = 0;
+    double EPos = 0, EAng = 0;
+
+    double KEang = 14, KEPos = 10, DEang = 0, DEPos = 0,IEpos=0,IEang=0;
+
+    bool turning=false;
+    if(roadMode==14||roadMode==15||roadMode==16||roadMode==17){
+        turning=true;
+    }
+
+    double PreviewDistance;//预瞄距离
+
+    if(ServiceCarStatus.msysparam.mvehtype=="ge3" || ServiceCarStatus.msysparam.mvehtype=="vv7"){
+        realSpeed > 40 ? PreviewDistance = max(6.0, realSpeed *0.6) : PreviewDistance = max(4.0, realSpeed *0.3);
+    }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);
+    }
+
+    //    if(ServiceCarStatus.msysparam.mvehtype=="bus"){
+    //        KEang = 14, KEPos = 7, DEang = 0, DEPos = 0,IEpos=0,IEang=0;
+    //        realSpeed > 40 ? PreviewDistance = max(6.0, realSpeed *0.6) : PreviewDistance = max(6.0, realSpeed *0.5);
+
+    //    }
+    //   if(realSpeed <15){
+    //    PreviewDistance = max(4.0, realSpeed *0.4) ;
+    //   }
+    //    if(realSpeed <10){
+    //        PreviewDistance = max(3.0, realSpeed *0.3) ;
+    //    }
+    double sumdis = 0;
+    int gpsIndex = 0;
+    std::vector<Point2D> farTrace;
+
+    int nsize = trace.size();
+    for (int i = 1; i < nsize-1; i++)
+    {
+        sumdis += GetDistance(trace[i - 1], trace[i]);
+        if (sumdis > PreviewDistance)
+        {
+            gpsIndex = i;
+            break;
+        }
+    }
+
+    EPos = trace[gpsIndex].x;
+
+    for (unsigned int i = max(0, gpsIndex - 3); i < min((size_t)(gpsIndex + 3), trace.size()); i++) {
+        farTrace.push_back(trace[gpsIndex]);
+    }
+    if (farTrace.size() == 0) {
+        EAng = 0;
+    }
+    else {
+        EAng = getAveDef(farTrace);
+    }
+    if(abs(realSpeed)<3){
+        eAngSum=0;
+        ePosSum=0;
+    }else{
+        eAngSum=eAngSum*0.8+EAng;
+        ePosSum=ePosSum*0.8+EPos;
+    }
+
+    ang = KEang * EAng + KEPos * EPos + DEang * (EAng - lastEA) + DEPos * (EPos - lastEP)
+            +IEang*eAngSum + IEpos*ePosSum;
+
+    lastEA = EAng;
+    lastEP = EPos;
+
+    //    if (ang > angleLimit) {
+    //        ang = angleLimit;
+    //    }
+    //    else if (ang < -angleLimit) {
+    //        ang = -angleLimit;
+    //    }
+    if (lastAng >-3000&&lastAng<3000) {
+        ang = 0.2 * lastAng + 0.8 * ang;
+    }
+    if(ang >-3000&&ang<3000){
+        lastAng = ang;
+    }else{
+        ang=lastAng;
+    }
+    return ang;
+
+}
+
+
+
+float iv::decition::PIDController::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) / M_PI * 180;
+}
+
+
+
+float iv::decition::PIDController::getPidAcc (GPS_INS gpsIns,float dSpeed, float obsDistance, float obsSpeed){
+
+    std::cout << "\n计算用obs速度:%f\n" << obsSpeed << std::endl;
+    std::cout << "\n计算用obs距离:%f\n" << obsDistance << std::endl;
+
+    if(ServiceCarStatus.msysparam.mvehtype=="hapo")
+    {
+            static int obs_line=0;
+            if(obsDistance<6 && obsDistance>0){
+                dSpeed=0;
+                obs_line=1;
+            }
+            if(obs_line==1)
+            {
+                if(obsDistance<8 && obsDistance>0){
+                    dSpeed=0;
+                }else{
+                    obs_line=0;
+                }
+            }
+    }else if(obsDistance<10 && obsDistance>0){
+        dSpeed=0;
+    }
+
+    float dSecSpeed = dSpeed / 3.6;
+    float realSpeed=gpsIns.speed;
+    float secSpeed =realSpeed/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 > 150) vl = 25; //25m/s
+
+
+    //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);
+        }
+    }else{
+        vt=dSecSpeed;
+    }
+
+    vt=min((float)vt,dSecSpeed);
+    std::cout << "\nvt:%f\n" << vt << std::endl;
+
+    //计算加速度
+    float u =computeU(obsDistance,ds,vs,vt,vh,vl,ttc,ttcr);
+
+    //u 限值
+    u=limiteU(u,ttc);
+
+    lastVt = vt;
+    lastU = u;
+    float acc=0-u;
+    return acc;
+}
+
+
+float iv::decition::PIDController::computeU(float obsDistance, float ds,float vs,float vt,float vh,float vl,float ttc,float ttcr){
+
+    double Id = 0;
+    double ed = ds - obsDistance;
+    if (obsDistance > 150) ed = 0;
+    double ev = vs - vt;
+    double u = 0;
+    if (ttc>10)
+    {
+        double kp = 0.5;        //double kp = 0.5;
+        double kd = 0.5;       //kd = 0.5
+        //      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.0f);
+        }
+    }
+    if (abs(vl) < 1.0 && abs(vh) < 1.0
+            && obsDistance < 2 * ds)
+    {
+        u = 0.5;
+    }
+    lastEv = ev;
+    return u;
+}
+
+
+float iv::decition::PIDController::limiteU(float u,float ttc){
+    if(ttc<3 && u<-0.2){
+        u=-0.2;
+    }
+    else
+    {
+        if (u < -1.5) u = -1.5;
+    }
+    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;
+    }
+    return u;
+}
+
+
+
+
+
+

+ 76 - 0
src/decition/decition_brain/decition/adc_controller/pid_controller.h

@@ -0,0 +1,76 @@
+#ifndef _IV_DECITION__PID_CONTROLLER_
+#define _IV_DECITION__PID_CONTROLLER_
+
+#include <common/gps_type.h>
+#include <decision/decition_type.h>
+#include <common/obstacle_type.h>
+#include<vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_controller/base_controller.h>
+#include <decision/adc_tools/transfer.h>
+
+namespace iv {
+        namespace decition {
+        //根据传感器传输来的信息作出决策
+                    class PIDController: public BaseController {
+                    public:
+
+                        float lastEA;
+                        float lastEP;
+                        float lastAng;
+                        float angleLimit=600;
+                        float lastU ;
+                        float lastEv ;
+                        float lastVt ;
+
+                        float Iv;
+                        float eAngSum=0;
+                        float ePosSum=0;
+
+                        PIDController();
+                        ~PIDController();
+
+                        /**
+                           * @brief getControlDecition
+                           * pid方式计算横向方向盘和纵向加速度
+                           *
+                           * @param now_gps_ins          实时gps信息
+                           * @param path                 目标路径
+                           * @param dSpeed               决策速度
+                           * @param obsDistacne          障碍物距离
+                           * @param obsSpeed             障碍物速度
+                           * @param computeAngle         是否要计算方向盘角度
+                           * @param computeAcc           是否要计算纵向加速度
+                           * @param decition             决策信息结构体的指针
+                           * @return                     iv::decition::Decition
+                           */
+
+
+                        iv::decition::Decition getControlDecition(GPS_INS now_gps_ins, std::vector<Point2D> path,float dSpeed, float obsDistacne,float  obsSpeed,
+                                                                  bool computeAngle, bool computeAcc, Decition *decition);
+                        float  getPidAngle (float realSpeed, std::vector<Point2D> trace,int roadMode);
+                        float  getAveDef (std::vector<Point2D> farTrace);
+                        float  getPidAcc (GPS_INS gpsIns,float dSpeed, float obsDistacne, float obsSpeed);
+                        float  computeU(float obsDistance, float ds,float vs,float vt,float vh,float vl,float ttc,float ttcr);
+                        float  limiteU(float u ,float ttc);
+
+
+                    private:
+
+                    };
+
+        }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+#endif // PID_CONTROLLER_H

+ 40 - 0
src/decition/decition_brain/decition/adc_planner/base_planner.cpp

@@ -0,0 +1,40 @@
+#include <common/gps_type.h>
+#include <decision/decition_type.h>
+#include <common/obstacle_type.h>
+#include <vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_tools/transfer.h>
+#include "perception/perceptionoutput.h"
+#include <decision/adc_planner/base_planner.h>
+
+
+
+
+
+
+iv::decition::BasePlanner::BasePlanner(){
+
+}
+iv::decition::BasePlanner::~BasePlanner(){
+
+}
+
+
+/**
+ * @brief iv::decition::BasePlanner::getPath
+ * 基类BasePlanner的抽象方法,用于计算车辆行驶的路径。路径都已转换成车辆坐标系下的路径。
+ *
+ * @param now_gps_ins          实时gps信息
+ * @param gpsMapLine           地图数据点
+ * @param PathPoint            地图路线中距离车辆位置最近的一个点的序号
+ * @param offset               在车辆避障中,地图源路线所在车道 与 即将去往的车道 之间的距离差值。可以为负值。
+ * @param lidarGridPtr         激光雷达信息网格
+ * @return                     返回一条车辆坐标系下的路径
+ */
+std::vector<iv::Point2D> iv::decition::BasePlanner::getPath(GPS_INS now_gps_ins,const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr){
+
+}
+
+//std::vector<iv::Point2D> iv::decition::BasePlanner::getPath (GPS_INS now_gps_ins,  std::vector<GPSData> gpsMapLine,  LidarGridPtr lidarGridPtr, std::vector<iv::Perception::PerceptionOutput> lidar_per){
+
+//}

+ 48 - 0
src/decition/decition_brain/decition/adc_planner/base_planner.h

@@ -0,0 +1,48 @@
+#ifndef _IV_DECITION__BASE_PLANNER_
+#define _IV_DECITION__BASE_PLANNER_
+
+#include <common/gps_type.h>
+#include <decision/decition_type.h>
+#include <common/obstacle_type.h>
+#include<vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include "perception/perceptionoutput.h"
+
+namespace iv {
+namespace decition {
+//根据传感器传输来的信息作出决策
+    class BasePlanner {
+    public:
+        int planner_id;
+        std::string  planner_name;
+
+        BasePlanner();
+        virtual ~BasePlanner();
+
+        /**
+         * @brief iv::decition::BasePlanner::getPath
+         * 基类BasePlanner的抽象方法,用于计算车辆行驶的路径。路径都已转换成车辆坐标系下的路径。
+         *
+         * @param now_gps_ins          实时gps信息
+         * @param gpsMapLine           地图数据点
+         * @param PathPoint            地图路线中距离车辆位置最近的一个点的序号
+         * @param offset               在车辆避障中,地图源路线所在车道 与 即将去往的车道 之间的距离差值。可以为负值。
+         * @param lidarGridPtr         激光雷达信息网格
+         * @return                     返回一条车辆坐标系下的路径
+         */
+        virtual  std::vector<iv::Point2D> getPath (GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr);
+//        virtual  std::vector<iv::Point2D> getPath (GPS_INS now_gps_ins,  std::vector<GPSData> gpsMapLine,  LidarGridPtr lidarGridPtr, std::vector<iv::Perception::PerceptionOutput> lidar_per);
+
+    private:
+
+    };
+
+}
+}
+
+
+#endif // ADC_PLANNER_H
+
+
+
+

+ 57 - 0
src/decition/decition_brain/decition/adc_planner/dubins_planner.cpp

@@ -0,0 +1,57 @@
+#include <decision/adc_planner/dubins_planner.h>
+#include <decision/adc_tools/transfer.h>
+#include <decision/adc_tools/parameter_status.h>
+#include <common/constants.h>
+
+#include <math.h>
+
+std::vector<iv::GPSData> iv::decition::DubinsPlanner::gpsMap;
+
+iv::decition::DubinsPlanner::DubinsPlanner(){
+    this->planner_id = 2;
+    this->planner_name = "Dubins";
+}
+
+iv::decition::DubinsPlanner::~DubinsPlanner(){
+}
+
+/**
+ * @brief iv::decition::LaneChangePlanner::getPath
+ * 采用的车道变换的局部路径生成方法。计算原始地图路径偏移offset距离之后的路径。
+ *
+ * @param now_gps_ins          实时gps信息
+ * @param gpsMapLine           地图数据点
+ * @param PathPoint            地图路线中距离车辆位置最近的一个点的序号
+ * @param offset               在车辆避障中,地图源路线所在车道 与 即将去往的车道 之间的距离差值。可以为负值。
+ * @param lidarGridPtr         激光雷达信息网格
+ * @return                     返回一条车辆坐标系下的路径
+ */
+std::vector<iv::Point2D> iv::decition::DubinsPlanner::getPath(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr){
+    std::vector<iv::Point2D> trace;
+
+    double L = 2.6;
+    double R = L/sin(10.0*M_PI/180.0);
+    std::cout<<" R = "<<R<<std::endl;
+//    return a.exec();
+//    double q0[] = { 0,0,1.57};
+//    double q1[] = { 4,4,3.142 };
+    gpsMap.clear();
+    double q0[] = { now_gps_ins.gps_x, now_gps_ins.gps_y, now_gps_ins.ins_heading_angle};
+    double q1[] = { gpsMapLine[PathPoint]->gps_x, gpsMapLine[PathPoint]->gps_y ,gpsMapLine[PathPoint]->ins_heading_angle };
+    double turning_radius = 10.0;
+    DubinsPath path;
+    dubins_shortest_path( &path, q0, q1, turning_radius);
+    dubins_path_sample_many( &path, 0.1,  printConfiguration, NULL);
+
+
+}
+
+int  iv::decition::DubinsPlanner::printConfiguration(double q[3], double x, void* user_data) {
+    GPSData gps;
+    gps->roadMode=5;
+    gps->gps_x=q[0];
+    gps->gps_y=q[1];
+    gps->ins_heading_angle=q[3];
+    gpsMap.push_back(gps);
+    return 0;
+}

+ 44 - 0
src/decition/decition_brain/decition/adc_planner/dubins_planner.h

@@ -0,0 +1,44 @@
+#ifndef DUBINS_PLANNER_H
+#define DUBINS_PLANNER_H
+#include "base_planner.h"
+#include <decision/adc_tools/dubins.h>
+#include <QCoreApplication>
+
+#include <math.h>
+#include <iostream>
+
+
+
+#include <stdio.h>
+#include <string.h>
+
+namespace iv{
+namespace decition{
+    class DubinsPlanner : public BasePlanner{
+    public:
+        DubinsPlanner();
+        ~DubinsPlanner();
+
+         static std::vector<iv::GPSData>  gpsMap;
+
+        /**
+         * @brief iv::decition::LaneChangePlanner::getPath
+         * 采用的车道变换的局部路径生成方法。计算原始地图路径偏移offset距离之后的路径。
+         *
+         * @param now_gps_ins          实时gps信息
+         * @param gpsMapLine           地图数据点
+         * @param PathPoint            地图路线中距离车辆位置最近的一个点的序号
+         * @param offset               在车辆避障中,地图源路线所在车道 与 即将去往的车道 之间的距离差值。可以为负值。
+         * @param lidarGridPtr         激光雷达信息网格
+         * @return                     返回一条车辆坐标系下的路径
+         */
+        std::vector<iv::Point2D> getPath(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr);
+
+        int  static printConfiguration(double q[3], double x, void* user_data);
+
+        };
+    }
+}
+
+
+#endif // DUBINS_PLANNER_H

+ 643 - 0
src/decition/decition_brain/decition/adc_planner/frenet_planner.cpp

@@ -0,0 +1,643 @@
+#include "frenet_planner.h"
+
+#include <decision/adc_tools/transfer.h>
+#include <common/car_status.h>
+#include <decision/adc_tools/parameter_status.h>
+#include <decision/decide_gps_00.h>
+#include <decision/adc_planner/lane_change_planner.h>
+
+#include<Eigen/Dense>
+
+using namespace std;
+using namespace Eigen;
+
+iv::decition::FrenetPlanner::FrenetPlanner(){
+    this->planner_id = 1;
+    this->planner_name = "Frenet";
+    this->lidarGridPtr = NULL;
+}
+
+iv::decition::FrenetPlanner::~FrenetPlanner(){
+    free(this->lidarGridPtr);
+}
+
+
+/**
+ * @brief iv::decition::FrenetPlanner::getPath
+ * 采用的基于frenet坐标系的最优局部路径生成方法,可实现从当前车道变换到另一车道之间的路径生成。还可实现车辆在路线旁起步的“有迹可循”。
+ * 计算的是,在车辆到达 原始地图路径偏移offset距离的车道 之前,frenet下规划的路径。
+ *
+ * @param now_gps_ins          实时gps信息
+ * @param gpsMapLine           地图数据点
+ * @param PathPoint            地图路线中距离车辆位置最近的一个点的序号
+ * @param offset               在车辆避障中,地图源路线所在车道 与 即将去往的车道 之间的距离差值。可以为负值。offset = -(roadNow - roadOri)*roadWidth
+ * @param lidarGridPtr         激光雷达信息网格
+ * @return                     返回一条车辆坐标系下的路径
+ */
+std::vector<iv::Point2D> iv::decition::FrenetPlanner::getPath(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr){
+    this->roadNow = -1;
+    this->now_gps_ins = now_gps_ins;
+    this->gpsMapLine = gpsMapLine;
+    this->PathPoint = PathPoint;
+    this->lidarGridPtr = lidarGridPtr;
+    LaneChangePlanner *lcp = new LaneChangePlanner();
+    std::vector<iv::Point2D> gpsTrace = lcp->getPath(now_gps_ins,gpsMapLine,PathPoint,0,lidarGridPtr);
+    delete lcp;
+    double realSecSpeed = now_gps_ins.speed / 3.6;
+    leftWidth = offset;
+    rightWidth = offset;
+    std::vector<iv::Point2D> trace = getGpsTrace_AfterCalcFrenetTrace(gpsTrace,realSecSpeed);
+    return trace;
+}
+
+/**
+ * @brief iv::decition::FrenetPlanner::chooseRoadByFrenet
+ * 用frenet的方法对每条道路考察,选择一个最优的道路
+ * @param now_gps_ins          实时gps信息
+ * @param gpsMapLine           地图数据点
+ * @param PathPoint            地图路线中距离车辆位置最近的一个点的序号
+ * @param offsetL              在选择道路中,地图源路线左边的最大宽度。可以为负值。offsetL = -(roadSum - 1)*roadWidth
+ * @param offsetR              在选择道路中,地图源路线右边的最大宽度。可以为非负值。offsetR = (roadOri - 0)*roadWidth
+ * @param lidarGridPtr         激光雷达信息网格
+ * @return
+ */
+int iv::decition::FrenetPlanner::chooseRoadByFrenet(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offsetL, double offsetR, iv::LidarGridPtr lidarGridPtr,int roadNow){
+    this->roadNow = roadNow;
+    this->aimRoadByFrenet = -1;
+    this->now_gps_ins = now_gps_ins;
+    this->gpsMapLine = gpsMapLine;
+    this->PathPoint = PathPoint;
+    this->lidarGridPtr = lidarGridPtr;
+
+    LaneChangePlanner *lcp = new LaneChangePlanner();
+    std::vector<iv::Point2D> gpsTrace = lcp->getPath(now_gps_ins,gpsMapLine,PathPoint,0,lidarGridPtr);
+    delete lcp;
+    double realSecSpeed = now_gps_ins.speed / 3.6;
+    leftWidth = offsetL;
+    rightWidth = offsetR;
+    std::vector<iv::Point2D> trace = getGpsTrace_AfterCalcFrenetTrace(gpsTrace,realSecSpeed);
+    return aimRoadByFrenet;
+}
+
+
+/**
+ * @brief iv::decition::FrenetPlanner::getGpsTrace_AfterCalcFrenetTrace
+ * 进行frenet规划的总函数,还包括了规划前的一些准备工作,比如frenet坐标系建立、车辆起始状态等。
+ * @param gpsTrace             地图路线上从PathPoint开始的600个点
+ * @param realsecSpeed         实时车速 [m/s]
+ * @return                     返回一条frenet规划后并转换到车辆坐标系下的路径
+ */
+std::vector<iv::Point2D> iv::decition::FrenetPlanner::getGpsTrace_AfterCalcFrenetTrace(const std::vector<iv::Point2D>& gpsTrace,double realsecSpeed){
+    vector<Point2D> trace;
+    vector<FrenetPoint> frenet_s;
+    double stp=0.0;
+    //把gpsTrace里的点全部转为frenet坐标系下的点,存储在frenet_s中。相当于frenet坐标系的S轴。
+    FrenetPoint tmp={.x=gpsTrace[0].x,.y=gpsTrace[0].y,.s=0.0,.d=0.0};
+    frenet_s.push_back(tmp);
+    for(int i=1; i<gpsTrace.size(); ++i){
+        stp+=iv::decition::GetDistance(gpsTrace[i-1],gpsTrace[i]);
+        tmp={.x=gpsTrace[i].x,.y=gpsTrace[i].y,.s=stp,.d=0.0};
+        frenet_s.push_back(tmp);
+    }
+
+    //求出车辆当前位置在frenet坐标系下的坐标
+//    FrenetPoint car_now_at_frenet = XY2Frenet(0,0,gpsTrace);
+    FrenetPoint car_now_at_frenet = getFrenetfromXY(0,0,gpsTrace,this->gpsMapLine,this->PathPoint,this->now_gps_ins);
+
+    double c_s_speed = realsecSpeed * cos(car_now_at_frenet.tangent_Ang-M_PI/2);
+    double c_d_speed = realsecSpeed * sin(car_now_at_frenet.tangent_Ang-M_PI/2);
+    double realAcc = ServiceCarStatus.mfCalAcc;
+    double c_s_dd = realAcc * cos(car_now_at_frenet.tangent_Ang-M_PI/2);
+    double c_d_dd = realAcc * sin(car_now_at_frenet.tangent_Ang-M_PI/2);
+
+    vector<Point2D> path=frenet_optimal_planning(car_now_at_frenet,frenet_s,c_s_speed,c_d_speed,c_d_dd);
+
+    return path;
+}
+
+
+/**
+ * @brief iv::decition::FrenetPlanner::frenet_optimal_planning
+ * 对frenet规划出的路径进行后续操作,并选出损失最小的一条路径作为最优路径
+ * @param car_now_frenet_point 车辆当前位置在frenet坐标系下的坐标
+ * @param frenet_s             frenet坐标系的s轴
+ * @param c_speed              车辆的纵向速度。沿s轴方向的速度。
+ * @param c_d_d                车辆沿d方向的速度。
+ * @param c_d_dd               车辆沿d方向的加速度。
+ * @return                     返回一条frenet规划的最优路径
+ */
+vector<iv::Point2D> iv::decition::FrenetPlanner::frenet_optimal_planning(iv::decition::FrenetPoint car_now_frenet_point,
+                                                          const std::vector<FrenetPoint>& frenet_s, double c_speed, double c_d_d, double c_d_dd){
+    double s0 = car_now_frenet_point.s;
+    double c_d = car_now_frenet_point.d;
+    vector<iv::Point2D> gpsTrace;
+    vector<Frenet_path> fplist=calc_frenet_paths(c_speed, c_d, c_d_d, c_d_dd, s0);  //frenet规划
+
+    sort(fplist.begin(),fplist.end(),comp); //按损失度由小到大进行排序
+    for(int i=0; i<fplist.size(); ++i){
+        calc_global_single_path(fplist[i],frenet_s);
+        if(check_single_path(fplist[i])){
+            gpsTrace = frenet_path_to_gpsTrace(fplist[i]);
+            aimRoadByFrenet = fplist[i].roadflag;
+            return gpsTrace;
+        }
+    }
+    return gpsTrace;
+
+/*
+//    calc_global_paths(fplist, frenet_s);    //生成frenet路径中每个点在车辆坐标系下的坐标
+//    fplist = check_paths(fplist);  //检验计算出的每条路径
+//    //找到损失最小的轨迹
+//    double min_cost = (numeric_limits<double>::max)();
+//    Frenet_path bestpath;
+//    for(int i=0; i<fplist.size(); ++i){
+//        if(min_cost > fplist[i].cf){
+//            min_cost = fplist[i].cf;
+//            bestpath = fplist[i];
+//        }
+//    }
+//    gpsTrace = frenet_path_to_gpsTrace(bestpath);
+//    aimRoadByFrenet = bestpath.roadflag;
+//    return gpsTrace;
+*/
+}
+
+
+/**
+ * @brief iv::decition::FrenetPlanner::calc_frenet_paths
+ * 正式规划出不同的frenet路径,并统计相应的损失度。单从车辆行驶的平滑性计算而得,后续需检测是否有障碍物。
+ * @param c_speed              车辆的纵向速度。沿s轴方向的速度
+ * @param c_d                  车辆的横向(d方向)偏移距离
+ * @param c_d_d                车辆沿d方向的速度
+ * @param c_d_dd               车辆沿d方向的加速度
+ * @param s0                   车辆沿s方向的坐标
+ * @return                     返回多条frenet路径
+ */
+vector<iv::decition::Frenet_path> iv::decition::FrenetPlanner::calc_frenet_paths(double c_speed, double c_d, double c_d_d, double c_d_dd, double s0){
+    vector<iv::decition::Frenet_path> frenet_paths;
+    int roadNum = round(abs((leftWidth-rightWidth)/ServiceParameterStatus.D_ROAD_W));   //roadNum为frenet算法的起始道路序号
+    //采样,并对每一个目标配置生成轨迹
+    for(double di=leftWidth; di<=rightWidth; di+=ServiceParameterStatus.D_ROAD_W,roadNum--){
+        if(roadNum == this->roadNow)
+            continue;
+        //横向动作规划
+        for(double Ti=ServiceParameterStatus.MINT; Ti<ServiceParameterStatus.MAXT; Ti+=ServiceParameterStatus.DT){
+            Frenet_path fp;
+            fp.roadflag = roadNum;
+            //计算出关于目标配置di,Ti的横向多项式
+            Quintic_polynomial lat_qp = Quintic_polynomial(c_d, c_d_d, c_d_dd, di, 0.0, 0.0, Ti);
+
+            for(double i=0; i<Ti; i+=ServiceParameterStatus.D_POINT_T)
+                fp.t.push_back(i);
+
+            for(int i=0; i<fp.t.size(); ++i){
+                fp.d.push_back(lat_qp.calc_point(fp.t[i]));
+                fp.d_d.push_back(lat_qp.calc_first_derivative(fp.t[i]));
+                fp.d_dd.push_back(lat_qp.calc_second_derivative(fp.t[i]));
+                fp.d_ddd.push_back(lat_qp.calc_third_derivative(fp.t[i]));
+            }
+
+            //纵向速度规划 (速度保持)
+            for(double tv=ServiceParameterStatus.TARGET_SPEED - ServiceParameterStatus.D_T_S * ServiceParameterStatus.N_S_SAMPLE;
+                tv<(ServiceParameterStatus.TARGET_SPEED + ServiceParameterStatus.D_T_S * ServiceParameterStatus.N_S_SAMPLE);
+                tv+=ServiceParameterStatus.D_T_S){
+                Frenet_path tfp = fp;
+                Quartic_polynomial lon_qp = Quartic_polynomial(s0, c_speed, 0.0, tv, 0.0, Ti);
+
+                for(int i=0; i<fp.t.size(); ++i){
+                    tfp.s.push_back(lon_qp.calc_point(fp.t[i]));
+                    tfp.s_d.push_back(lon_qp.calc_first_derivative(fp.t[i]));
+                    tfp.s_dd.push_back(lon_qp.calc_second_derivative(fp.t[i]));
+                    tfp.s_ddd.push_back(lon_qp.calc_third_derivative(fp.t[i]));
+                }
+
+                //square of jerk
+                double Jp = inner_product(tfp.d_ddd.begin(), tfp.d_ddd.end(), tfp.d_ddd.begin(), 0);
+                //square of jerk
+                double Js = inner_product(tfp.s_ddd.begin(), tfp.s_ddd.end(), tfp.s_ddd.begin(), 0);
+
+                //square of diff from target speed
+                double ds = pow((ServiceParameterStatus.TARGET_SPEED - tfp.s_d.back()),2);
+                //横向的损失函数
+                tfp.cd = ServiceParameterStatus.KJ * Jp + ServiceParameterStatus.KT * Ti + ServiceParameterStatus.KD * tfp.d.back() * tfp.d.back();
+                //纵向的损失函数
+                tfp.cv = ServiceParameterStatus.KJ * Js + ServiceParameterStatus.KT * Ti + ServiceParameterStatus.KD * ds;
+                //总的损失函数为d 和 s方向的损失函数乘对应的系数相加
+                tfp.cf = ServiceParameterStatus.KLAT * tfp.cd + ServiceParameterStatus.KLON * tfp.cv;
+
+                frenet_paths.push_back(tfp);
+            }
+        }
+    }
+    return frenet_paths;
+}
+
+
+/**
+ * @brief iv::decition::FrenetPlanner::calc_global_paths
+ * 计算出每条frenet路径中轨迹点的x,y坐标。x,y坐标是轨迹点在车辆坐标系下的横纵坐标。
+ * 部分函数参数在第一种计算XY坐标的方法中没有使用,但在第二种方法中会用到。
+ * @param fplist               多条frenet路径
+ * @param frenet_s             frenet坐标系的s轴
+ * @return                     通过引用传递返回带有x,y值的多条frenet路径
+ */
+void iv::decition::FrenetPlanner::calc_global_paths(vector<Frenet_path>& fplist,const std::vector<FrenetPoint>& frenet_s){
+
+    for(auto& fp:fplist){
+        for(int i=0; i<fp.s.size(); ++i){
+            double ix,iy;
+//            Frenet2XY(&ix,&iy,fp.s[i],fp.d[i],frenet_s);  //第一种方法
+            getXYfromFrenet(&ix,&iy,fp.s[i],fp.d[i],frenet_s,this->gpsMapLine,this->PathPoint,this->now_gps_ins);   //第二种方法
+
+            fp.x.push_back(ix);
+            fp.y.push_back(iy);
+        }
+
+        for(int i=0; i<(fp.x.size()-1); ++i){
+            double dx = fp.x[i+1] - fp.x[i];
+            double dy = fp.y[i+1] - fp.y[i];
+            fp.yaw.push_back(atan2(dy,dx));
+            fp.ds.push_back(sqrt(dx*dx + dy*dy));
+        }
+
+        fp.ds.push_back(fp.ds.back());
+        fp.yaw.push_back(fp.yaw.back());
+
+        for(int i = 0; i < (fp.yaw.size() - 1); ++i){
+            fp.c.push_back((fp.yaw[i + 1] - fp.yaw[i]) / fp.ds[i]);
+        }
+    }
+}
+
+void iv::decition::FrenetPlanner::calc_global_single_path(Frenet_path &fp, const std::vector<FrenetPoint> &frenet_s){
+    for(int i=0; i<fp.s.size(); ++i){
+        double ix,iy;
+        //            Frenet2XY(&ix,&iy,fp.s[i],fp.d[i],frenet_s);  //第一种方法
+        getXYfromFrenet(&ix,&iy,fp.s[i],fp.d[i],frenet_s,this->gpsMapLine,this->PathPoint,this->now_gps_ins);   //第二种方法
+
+        fp.x.push_back(ix);
+        fp.y.push_back(iy);
+    }
+
+    for(int i=0; i<(fp.x.size()-1); ++i){
+        double dx = fp.x[i+1] - fp.x[i];
+        double dy = fp.y[i+1] - fp.y[i];
+        fp.yaw.push_back(atan2(dy,dx));
+        fp.ds.push_back(sqrt(dx*dx + dy*dy));
+    }
+
+    fp.ds.push_back(fp.ds.back());
+    fp.yaw.push_back(fp.yaw.back());
+
+    for(int i = 0; i < (fp.yaw.size() - 1); ++i){
+        fp.c.push_back((fp.yaw[i + 1] - fp.yaw[i]) / fp.ds[i]);
+    }
+}
+
+
+/**
+ * @brief iv::decition::FrenetPlanner::check_paths
+ * 对多条frenet路径进行检验,排除不符合要求的路径。
+ * @param fplist               多条frenet路径
+ * @return                     排除部分路径后的多条frenet路径
+ */
+vector<iv::decition::Frenet_path> iv::decition::FrenetPlanner::check_paths(const vector<Frenet_path>& fplist){
+    vector<Frenet_path> okind;
+    int i=0;
+    int j=0;
+
+    for(i=0; i<fplist.size(); ++i){
+        cout<<"&&&&&&&&&&fplist[i].roadflag: "<<fplist[i].roadflag<<endl;
+        for(j=0; j<fplist[i].s_d.size(); ++j){
+            if(fplist[i].s_d[j]>ServiceParameterStatus.MAX_SPEED)       //最大速度检查
+                goto ContinueFlag;
+        }
+        for(j=0; j<fplist[i].s_dd.size(); ++j){
+            if(abs(fplist[i].s_dd[j])>ServiceParameterStatus.MAX_ACCEL) //最大加速度检查
+                goto ContinueFlag;
+        }
+        for(j=30; j<fplist[i].c.size()-30; ++j){
+            if(abs(fplist[i].c[j])>ServiceParameterStatus.MAX_CURVATURE)//最大曲率检查
+                goto ContinueFlag;
+        }
+        if(!check_collision(fplist[i]))
+            continue;
+        okind.push_back(fplist[i]);
+        ContinueFlag:continue;
+    }
+    return okind;
+}
+
+
+bool iv::decition::FrenetPlanner::check_single_path(const iv::decition::Frenet_path &fp){
+    int j=0;
+
+    cout<<"&&&&&&&&&&fp.roadflag: "<<fp.roadflag<<endl;
+    for(j=0; j<fp.s_d.size(); ++j){
+        if(fp.s_d[j]>ServiceParameterStatus.MAX_SPEED)       //最大速度检查
+            return false;
+    }
+    for(j=0; j<fp.s_dd.size(); ++j){
+        if(abs(fp.s_dd[j])>ServiceParameterStatus.MAX_ACCEL) //最大加速度检查
+            return false;
+    }
+    for(j=30; j<fp.c.size()-30; ++j){
+        if(abs(fp.c[j])>ServiceParameterStatus.MAX_CURVATURE)//最大曲率检查
+            return false;
+    }
+    if(!check_collision(fp))
+        return false;
+
+    return true;
+}
+
+
+/**
+ * @brief iv::decition::FrenetPlanner::check_collision
+ * 检验frenet路径上是否有障碍物,调用的是改进的函数computeObsOnRoadByFrenet。
+ * @param frenet_path          一条frenet路径
+ * @param car_now_frenet_point 车辆当前位置在frenet坐标系下的坐标
+ * @return                     在路径上有障碍物返回false,否则返回true。
+ */
+bool iv::decition::FrenetPlanner::check_collision(const iv::decition::Frenet_path &frenet_path){
+    std::vector<Point2D> gpsTrace = frenet_path_to_gpsTrace(frenet_path);
+    double obs=-1;
+    iv::decition::DecideGps00().computeObsOnRoadByFrenet(this->lidarGridPtr,gpsTrace,obs,this->gpsMapLine,this->PathPoint,this->now_gps_ins);
+    if(obs > 0 && obs < 30)
+        return false;
+    else
+        return true;
+}
+
+
+/**
+ * @brief iv::decition::FrenetPlanner::frenet_path_to_gpsTrace
+ * 将frenet路径转换到车辆坐标系下。
+ * @param frenet_path          一条frenet路径
+ * @return                     一条车辆坐标系下的路径
+ */
+vector<iv::Point2D> iv::decition::FrenetPlanner::frenet_path_to_gpsTrace(const Frenet_path& frenet_path){
+    vector<iv::Point2D> gpsTrace;
+    for (int i=0; i<frenet_path.x.size(); ++i) {
+        gpsTrace.push_back(Point2D(frenet_path.x[i],frenet_path.y[i]));
+        gpsTrace[i].speed = sqrt(frenet_path.d_d[i]*frenet_path.d_d[i]+frenet_path.s_d[i]*frenet_path.s_d[i])*3.6;
+    }
+    return gpsTrace;
+}
+
+
+double iv::decition::FrenetPlanner::distance(double x1, double y1, double x2, double y2)
+{
+    return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
+}
+
+
+//找出gpsTrace中距离(x,y)最近的一个点
+int iv::decition::FrenetPlanner::ClosestWaypoint(double x, double y, const std::vector<Point2D>& gpsTrace)
+{
+
+    double closestLen = 100000; //large number
+    int closestWaypoint = 0;
+
+    for(int i = 1; i < gpsTrace.size(); i++)
+    {
+        double map_x = gpsTrace[i].x;
+        double map_y = gpsTrace[i].y;
+        double dist = distance(x,y,map_x,map_y);
+        if(dist < closestLen)
+        {
+            closestLen = dist;
+            closestWaypoint = i;
+        }
+
+    }
+    return closestWaypoint;
+}
+
+
+ /* |==========================================================|
+  * |         车辆坐标系与 frenet 坐标系互转的第一种方法。           |
+  * |==========================================================| */
+ // 车体坐标转frenet坐标。frenet坐标原点是 gpsTrace 中序号为0的点。
+ // Transform from Cartesian x,y coordinates to Frenet s,d coordinates
+iv::decition::FrenetPoint iv::decition::FrenetPlanner::XY2Frenet(double x, double y, const std::vector<iv::Point2D>& gpsTrace){
+    int next_wp=ClosestWaypoint( x,  y,  gpsTrace);
+    int prev_wp = next_wp-1;  //prev_wp代表在next_wp的前一个点计算坐标,能够保证frenet_s都是依次相加的。避免在next_wp计算frenet_s的话,可能出现减的情况。
+//    if(next_wp == 0){
+//        prev_wp  = gpsTrace.size()-1;
+//    }
+
+    double n_x = gpsTrace[next_wp].x-gpsTrace[prev_wp].x;
+    double n_y = gpsTrace[next_wp].y-gpsTrace[prev_wp].y;
+    double x_x = x - gpsTrace[prev_wp].x;
+    double x_y = y - gpsTrace[prev_wp].y;
+
+    // find the projection of x onto n
+    double proj_norm = (x_x*n_x+x_y*n_y)/(n_x*n_x+n_y*n_y);
+    double proj_x = proj_norm*n_x;
+    double proj_y = proj_norm*n_y;  //proj_x、proj_y应该为垂足的坐标
+
+    double frenet_d = sqrt((x_x - proj_x) * (x_x - proj_x) + (x_y - proj_y) * (x_y - proj_y));
+    //经手动推算frenet_d = abs(n_x * x_y - n_y * x_x) / sqrt(n_x * n_x + n_y * n_y)。
+    //即frenet_d,等于点(x,y)到 过prev_wp、next_wp两点的直线 的垂直距离。
+
+    //see if d value is positive or negative by comparing it to a center point
+    double center_x = 1000-gpsTrace[prev_wp].x;
+    double center_y = 2000-gpsTrace[prev_wp].y;
+    double centerToPos = distance(center_x,center_y,x_x,x_y);
+    double centerToRef = distance(center_x,center_y,proj_x,proj_y);
+    if(centerToPos <= centerToRef){
+        frenet_d *= -1;
+    }
+
+    // calculate s value
+    double frenet_s = 0;
+    for(int i = 0; i < prev_wp; i++){
+        frenet_s += distance(gpsTrace[i].x,gpsTrace[i].y,gpsTrace[i+1].x,gpsTrace[i+1].y);
+    }
+    if(prev_wp<=0){
+        frenet_s -= distance(0,0,proj_x,proj_y);
+    }else{
+        frenet_s += distance(0,0,proj_x,proj_y);
+    }
+
+    double tmp_Angle = atan2(n_y,n_x);
+
+    return {x:x,y:y,s:frenet_s,d:frenet_d,tangent_Ang:tmp_Angle};
+}
+
+ // frenet坐标转车体坐标。
+ // Transform from Frenet s,d coordinates to Cartesian x,y
+void iv::decition::FrenetPlanner::Frenet2XY(double *res_x, double *res_y, double s, double d, const vector<iv::decition::FrenetPoint>& frenetTrace){
+    int prev_wp = 0;
+    //退出循环时,prev_wp 最大是等于 frenetTrace.size()-2。
+    while(s > frenetTrace[prev_wp+1].s && (prev_wp < (int)(frenetTrace.size()-2) )){
+        prev_wp++;
+    }
+    int wp2 = prev_wp+1;
+    double heading = atan2((frenetTrace[wp2].y-frenetTrace[prev_wp].y),(frenetTrace[wp2].x-frenetTrace[prev_wp].x));
+
+    double seg_s = (s-frenetTrace[prev_wp].s);
+    double seg_x = frenetTrace[prev_wp].x+seg_s*cos(heading);
+    double seg_y = frenetTrace[prev_wp].y+seg_s*sin(heading);
+
+    double perp_heading = heading-M_PI*0.5;
+    *res_x = seg_x + d*cos(perp_heading);
+    *res_y = seg_y + d*sin(perp_heading);
+}
+
+/* |==========================================================|
+ * |         车辆坐标系与 frenet 坐标系互转的第二种方法。           |
+ * |==========================================================| */
+// 车体坐标转frenet坐标。frenet坐标原点是 gpsTrace 中序号为0的点。
+iv::decition::FrenetPoint iv::decition::FrenetPlanner::getFrenetfromXY(double x, double y, const std::vector<iv::Point2D>& gpsTrace,const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps){
+    int next_wp=ClosestWaypoint( x,  y,  gpsTrace);
+    int prev_wp = next_wp-1;  //prev_wp代表在next_wp的前一个点计算坐标,能够保证frenet_s都是依次相加的。避免在next_wp计算frenet_s的话,可能出现减的情况。
+    //    if(next_wp == 0){
+    //        prev_wp  = gpsTrace.size()-1;
+    //    }
+
+    GPS_INS gps = Coordinate_UnTransfer(x,y,nowGps);
+    Point2D pt = Coordinate_Transfer(gps.gps_x,gps.gps_y, *gpsMap[(pathpoint+prev_wp)%gpsMap.size()]);
+
+    // calculate s value
+    double frenet_s = 0;
+    for(int i = 0; i < prev_wp; i++){
+        frenet_s += distance(gpsTrace[i].x,gpsTrace[i].y,gpsTrace[i+1].x,gpsTrace[i+1].y);
+    }
+    frenet_s += pt.y;
+
+    //theta为prev_wp处车的航向角 与 nowGps处的车辆坐标系下x轴之间的夹角,逆时针为正。
+    double theta = (nowGps.ins_heading_angle - gpsMap[(pathpoint+prev_wp)%gpsMap.size()]->ins_heading_angle+90);
+    double tmp_Angle = theta * M_PI / 180;
+
+    return {x:x,y:y,s:frenet_s,d:pt.x,tangent_Ang:tmp_Angle};
+}
+
+void iv::decition::FrenetPlanner::getXYfromFrenet(double *res_x, double *res_y, double s, double d, const vector<iv::decition::FrenetPoint>& frenetTrace,const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps)
+{
+    int prev_wp = -1;
+
+    while((prev_wp < (int)(frenetTrace.size()-1) ) && s > frenetTrace[prev_wp+1].s)
+    {
+        prev_wp++;
+    }
+    if(prev_wp < 0){
+        prev_wp = 0;
+    }
+//    int wp2 =prev_wp+1;
+    GPS_INS gps=  Coordinate_UnTransfer( d, s-frenetTrace[prev_wp].s , *gpsMap[(pathpoint+prev_wp)%gpsMap.size()]);
+    Point2D pt =  Coordinate_Transfer( gps.gps_x, gps.gps_y, nowGps);
+
+    *res_x = pt.x;
+    *res_y = pt.y;
+}
+
+
+iv::decition::Quintic_polynomial::Quintic_polynomial(double xs, double vxs, double axs, double xe, double vxe, double axe, double T){
+    //计算五次多项式系数
+    this->xs = xs;
+    this->vxs = vxs;
+    this->axs = axs;
+    this->xe = xe;
+    this->vxe = vxe;
+    this->axe = axe;
+
+    this->a0 = xs;
+    this->a1 = vxs;
+    this->a2 = axs/ 2.0;
+
+    MatrixXd A(3, 3);
+    MatrixXd b(3, 1);
+    MatrixXd x(3, 1);
+
+    A << pow(T, 3),   pow(T, 4),   pow(T, 5),
+         3*pow(T, 2), 4*pow(T, 3), 5*pow(T, 4),
+         6*T,         12*T*T,      20*pow(T, 3);
+    b << xe - a0 - a1*T - a2*T*T,
+         vxe - a1 - 2*a2*T,
+         axe - 2*a2;
+    x=A.colPivHouseholderQr().solve(b);
+
+    this->a3 = x(0,0);
+    this->a4 = x(1,0);
+    this->a5 = x(2,0);
+}
+
+iv::decition::Quintic_polynomial::~Quintic_polynomial(){
+}
+
+double iv::decition::Quintic_polynomial::calc_point(double t){
+    double xt = this->a0 + this->a1 * t + this->a2 * t*t + this->a3 * t*t*t + this->a4 * t*t*t*t + this->a5 * t*t*t*t*t;
+    return xt;
+}
+
+double iv::decition::Quintic_polynomial::calc_first_derivative(double t){
+    double xt = this->a1 + 2*this->a2 * t + 3*this->a3 * t*t + 4*this->a4 * t*t*t + 5*this->a5 * t*t*t*t;
+    return xt;
+}
+
+double iv::decition::Quintic_polynomial::calc_second_derivative(double t){
+    double xt = 2*this->a2 + 6*this->a3 * t + 12*this->a4 * t*t + 20*this->a5 * t*t*t;
+    return xt;
+}
+
+double iv::decition::Quintic_polynomial::calc_third_derivative(double t){
+    double xt = 6*this->a3 + 24*this->a4 * t + 60*this->a5 * t*t;
+    return xt;
+}
+
+
+
+iv::decition::Quartic_polynomial::Quartic_polynomial(double xs, double vxs, double axs, double vxe, double axe, double T){
+    //计算四次多项式系数
+    this->xs = xs;
+    this->vxs = vxs;
+    this->axs = axs;
+    this->vxe = vxe;
+    this->axe = axe;
+
+    this->a0 = xs;
+    this->a1 = vxs;
+    this->a2 = axs / 2.0;
+
+    MatrixXd A(2, 2);
+    MatrixXd b(2, 1);
+    MatrixXd x(2, 1);
+
+    A << 3*pow(T, 2), 4*pow(T, 3),
+         6*T,         12*T*T ;
+    b << vxe - a1 - 2*a2*T,
+         axe - 2*a2;
+    x=A.colPivHouseholderQr().solve(b);
+
+    this->a3 = x(0,0);
+    this->a4 = x(1,0);
+}
+
+iv::decition::Quartic_polynomial::~Quartic_polynomial(){
+}
+
+double iv::decition::Quartic_polynomial::calc_point(double t){
+    double xt = this->a0 + this->a1*t + this->a2*t*t + this->a3*t*t*t + this->a4*t*t*t*t;
+    return xt;
+}
+
+double iv::decition::Quartic_polynomial::calc_first_derivative(double t){
+    double xt = this->a1 + 2*this->a2*t + 3*this->a3*t*t + 4*this->a4*t*t*t;
+    return xt;
+}
+
+double iv::decition::Quartic_polynomial::calc_second_derivative(double t){
+    double xt = 2*this->a2 + 6*this->a3*t + 12*this->a4*t*t;
+    return xt;
+}
+
+double iv::decition::Quartic_polynomial::calc_third_derivative(double t){
+    double xt = 6*this->a3 + 24*this->a4*t;
+    return xt;
+}
+
+bool iv::decition::FrenetPlanner::comp(const iv::decition::Frenet_path &a, const iv::decition::Frenet_path &b){
+    return a.cf < b.cf;
+}

+ 159 - 0
src/decition/decition_brain/decition/adc_planner/frenet_planner.h

@@ -0,0 +1,159 @@
+#ifndef FRENET_PLANNER_H
+#define FRENET_PLANNER_H
+
+#include "base_planner.h"
+
+namespace iv{
+namespace decition{
+
+    //x,y分别为frenet轨迹点相对于车辆的x,y轴坐标
+    //s,d分别为frenet轨迹点相对于frenet坐标系的s,d轴坐标值
+    //tangent_Ang为轨迹点在frenet坐标系的s轴的投影处的 切线 与车辆坐标系x轴之间的夹角。
+    //tangent_Ang用于分解计算车辆分别在s轴、d轴方向上的运动速度、加速度等。
+    struct FrenetPoint{
+        double x;
+        double y;
+        double s;
+        double d;
+        double tangent_Ang;
+    };
+
+
+
+    class Quintic_polynomial
+    {
+    public:
+        Quintic_polynomial(double xs, double vxs, double axs, double xe, double vxe, double axe, double T);
+        ~Quintic_polynomial();
+    private:
+        // 计算五次多项式系数
+        double xs;    //d0
+        double vxs;   //d.0
+        double axs;   //d..0
+        double xe;    //d1
+        double vxe;   //d.1
+        double axe;   //d..1
+
+        double a0;
+        double a1;
+        double a2;
+        double a3;
+        double a4;
+        double a5;
+
+    public:
+        double calc_point(double t);
+        double calc_first_derivative(double t);
+        double calc_second_derivative(double t);
+        double calc_third_derivative(double t);
+    };
+
+
+    class Quartic_polynomial
+    {
+    public:
+        Quartic_polynomial(double xs, double vxs, double axs, double vxe, double axe, double T);
+        ~Quartic_polynomial();
+
+    private:
+        //计算四次多项式系数
+        double xs;
+        double vxs;
+        double axs;
+        double vxe;
+        double axe;
+
+        double a0;
+        double a1;
+        double a2;
+        double a3;
+        double a4;
+
+    public:
+        double calc_point(double t);
+        double calc_first_derivative(double t);
+        double calc_second_derivative(double t);
+        double calc_third_derivative(double t);
+    };
+
+
+    class Frenet_path
+    {
+    public:
+        std::vector<double> t;
+        std::vector<double> d;
+        std::vector<double> d_d;
+        std::vector<double> d_dd;
+        std::vector<double> d_ddd;
+        std::vector<double> s;
+        std::vector<double> s_d;
+        std::vector<double> s_dd;
+        std::vector<double> s_ddd;
+        int roadflag = -1;  //标记每一条frenet路径,是以哪一条道路为目标道路的
+        double cd = 0.0;
+        double cv = 0.0;
+        double cf = 0.0;
+
+        std::vector<double> x;
+        std::vector<double> y;
+        std::vector<double> yaw;
+        std::vector<double> ds;
+        std::vector<double> c;
+    };
+
+    class FrenetPlanner : public BasePlanner{
+    public:
+        int aimRoadByFrenet = -1;          //记录由frenet规划选择出来的道路序号
+        int roadNow = -1;                  //记录避障时车辆当前道路序号,规划路径时,避开此条道路
+        double leftWidth = 0.0;            //中心线左边偏移距离,为负值
+        double rightWidth = 0.0;           //中心线右边偏移距离,为正值
+        GPS_INS now_gps_ins;               //实时gps信息
+        std::vector<GPSData> gpsMapLine;   //地图数据点
+        int PathPoint = 0;                 //地图路线中距离车辆位置最近的一个点的序号
+        iv::LidarGridPtr lidarGridPtr;     //激光雷达信息网格
+
+    public:
+        FrenetPlanner();
+        ~FrenetPlanner();
+
+        /**
+         * @brief iv::decition::FrenetPlanner::getPath
+         * 采用的基于frenet坐标系的最优局部路径生成方法,可实现从当前车道变换到另一车道之间的路径生成。还可实现车辆在路线旁起步的“有迹可循”。
+         * 计算的是,在车辆到达 原始地图路径偏移offset距离的车道 之前,frenet下规划的路径。
+         *
+         * @param now_gps_ins          实时gps信息
+         * @param gpsMapLine           地图数据点
+         * @param PathPoint            地图路线中距离车辆位置最近的一个点的序号
+         * @param offset               在车辆避障中,地图源路线所在车道 与 即将去往的车道 之间的距离差值。可以为负值。
+         * @param lidarGridPtr         激光雷达信息网格
+         * @return                     返回一条车辆坐标系下的路径
+         */
+        std::vector<iv::Point2D> getPath(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr);
+        int chooseRoadByFrenet(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offsetL, double offsetR, iv::LidarGridPtr lidarGridPtr,int roadNow);
+        static iv::decition::FrenetPoint XY2Frenet(double x, double y, const std::vector<Point2D>& gpsTracet);
+        static void Frenet2XY(double *x, double *y, double s, double d, const std::vector<iv::decition::FrenetPoint>& frenetTrace);
+        static double distance(double x1, double y1, double x2, double y2);
+        static int ClosestWaypoint(double x, double y, const std::vector<Point2D>& gpsTrace);
+        static FrenetPoint getFrenetfromXY(double x, double y, const std::vector<iv::Point2D>& gpsTrace,const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps);
+        static void getXYfromFrenet(double *res_x, double *res_y, double s, double d, const std::vector<iv::decition::FrenetPoint>& frenetTrace,const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps);
+        static bool comp(const iv::decition::Frenet_path &a,const iv::decition::Frenet_path &b);
+
+    private:
+        std::vector<iv::Point2D> getGpsTrace_AfterCalcFrenetTrace(const std::vector<iv::Point2D>& gpsTrace,double realsecSpeed);
+        std::vector<iv::Point2D> frenet_optimal_planning(FrenetPoint car_now_frenet_point,
+                                                         const std::vector<FrenetPoint>& frenet_s,
+                                                         double c_speed, double c_d_d, double c_d_dd);
+        std::vector<Frenet_path> calc_frenet_paths(double c_speed, double c_d, double c_d_d, double c_d_dd, double s0);
+        void calc_global_paths(std::vector<Frenet_path>& fplist,const std::vector<FrenetPoint>& frenet_s);
+        void calc_global_single_path(Frenet_path& fp,const std::vector<FrenetPoint>& frenet_s);
+        std::vector<Frenet_path> check_paths(const std::vector<Frenet_path>& fplist);
+        bool check_single_path(const Frenet_path &fp);
+        bool check_collision(const Frenet_path &frenet_path);
+
+        std::vector<Point2D> frenet_path_to_gpsTrace(const Frenet_path& frenet_path);
+    };
+
+}
+}
+
+#endif // FRENET_PLANNER_H

+ 196 - 0
src/decition/decition_brain/decition/adc_planner/lane_change_planner.cpp

@@ -0,0 +1,196 @@
+#include <decision/adc_planner/lane_change_planner.h>
+#include <decision/adc_tools/transfer.h>
+#include <decision/adc_tools/parameter_status.h>
+#include <common/constants.h>
+
+#include <math.h>
+
+iv::decition::LaneChangePlanner::LaneChangePlanner(){
+    this->planner_id = 0;
+    this->planner_name = "LaneChange";
+}
+
+iv::decition::LaneChangePlanner::~LaneChangePlanner(){
+}
+
+/**
+ * @brief iv::decition::LaneChangePlanner::getPath
+ * 采用的车道变换的局部路径生成方法。计算原始地图路径偏移offset距离之后的路径。
+ *
+ * @param now_gps_ins          实时gps信息
+ * @param gpsMapLine           地图数据点
+ * @param PathPoint            地图路线中距离车辆位置最近的一个点的序号
+ * @param offset               在车辆避障中,地图源路线所在车道 与 即将去往的车道 之间的距离差值。可以为负值。
+ * @param lidarGridPtr         激光雷达信息网格
+ * @return                     返回一条车辆坐标系下的路径
+ */
+std::vector<iv::Point2D> iv::decition::LaneChangePlanner::getPath(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr){
+    std::vector<iv::Point2D> trace;
+    trace = this->getGpsTrace(now_gps_ins,gpsMapLine,PathPoint);
+    if(offset!=0){
+        trace = this->getGpsTraceOffset(trace,offset);
+    }
+    return trace;
+}
+
+bool iv::decition::LaneChangePlanner::checkAvoidEnable(const std::vector<double>& obsDisVector, int roadAim){
+    int roadNow = ServiceParameterStatus.now_road_num;
+    if ((obsDisVector[roadAim]>0 && obsDisVector[roadAim]<obsDisVector[roadNow]+ServiceCarStatus.msysparam.vehLenth)||
+            (obsDisVector[roadAim]>0 && obsDisVector[roadAim]<15))
+    {
+        return false;
+    }
+
+    if (roadAim-roadNow>1)
+    {
+        for (int i = roadNow+1; i < roadAim; i++)
+        {
+            if (obsDisVector[i] < 8 + (i-roadNow) * 2 && obsDisVector[i]>0) {
+                return false;
+            }
+        }
+
+    }
+
+    else if (roadNow-roadAim>1)
+    {
+        for (int i = roadNow-1; i >roadAim; i--)
+        {
+            if (obsDisVector[i] < 8 + (roadNow-i) * 2 && obsDisVector[i]>0) {
+                return false;
+            }
+        }
+    }
+    return true;
+}
+
+std::vector<iv::Point2D> iv::decition::LaneChangePlanner::getGpsTrace(iv::GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint){
+    std::vector<iv::Point2D> trace;
+
+    if (gpsMapLine.size() > 400 && PathPoint >= 0) {
+        for (int i = PathPoint; i < PathPoint + 600; 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;
+//            }
+
+
+            switch (pt.v1)
+            {
+            case 0:
+                pt.speed = 36;
+                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::LaneChangePlanner::getGpsTraceOffset(const 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 = std::max(0, j - 4); k <= j; k++)
+        {
+            count1 = count1 + 1;
+            sumx1 += gpsTrace[k].x;
+            sumy1 += gpsTrace[k].y;
+        }
+        for (int k = j; k <= std::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 + M_PI / 2),
+                           carFronty + avoidLenth  * sin(anglevalue + M_PI / 2));
+            ptLeft.speed = gpsTrace[j].speed;
+            ptLeft.v1 = gpsTrace[j].v1;
+            ptLeft.v2 = gpsTrace[j].v2;
+            ptLeft.roadMode = gpsTrace[j].roadMode;
+            trace.push_back(ptLeft);
+        }
+        else
+        {
+            Point2D ptRight(carFrontx + avoidLenth  * cos(anglevalue - M_PI / 2),
+                            carFronty + avoidLenth  * sin(anglevalue - M_PI / 2));
+            ptRight.speed = gpsTrace[j].speed;
+            ptRight.v1 = gpsTrace[j].v1;
+            ptRight.v2 = gpsTrace[j].v2;
+            ptRight.roadMode = gpsTrace[j].roadMode;
+            trace.push_back(ptRight);
+        }
+    }
+    return trace;
+}
+
+

+ 38 - 0
src/decition/decition_brain/decition/adc_planner/lane_change_planner.h

@@ -0,0 +1,38 @@
+#ifndef LANE_CHANGE_PLANNER_H
+#define LANE_CHANGE_PLANNER_H
+
+#include "base_planner.h"
+
+namespace iv{
+namespace decition{
+    class LaneChangePlanner : public BasePlanner{
+    public:
+        LaneChangePlanner();
+        ~LaneChangePlanner();
+
+
+        /**
+         * @brief iv::decition::LaneChangePlanner::getPath
+         * 采用的车道变换的局部路径生成方法。计算原始地图路径偏移offset距离之后的路径。
+         *
+         * @param now_gps_ins          实时gps信息
+         * @param gpsMapLine           地图数据点
+         * @param PathPoint            地图路线中距离车辆位置最近的一个点的序号
+         * @param offset               在车辆避障中,地图源路线所在车道 与 即将去往的车道 之间的距离差值。可以为负值。
+         * @param lidarGridPtr         激光雷达信息网格
+         * @return                     返回一条车辆坐标系下的路径
+         */
+        std::vector<iv::Point2D> getPath(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr);
+
+        bool checkAvoidEnable(const std::vector<double>& obsDisVector, int roadAim);
+
+    private:
+        std::vector<iv::Point2D> getGpsTrace(iv::GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint);
+        std::vector<iv::Point2D> getGpsTraceOffset(const std::vector<Point2D>& gpsTrace, double offset);
+
+    };
+}
+}
+
+
+#endif // LANE_CHANGE_PLANNER_H

+ 2075 - 0
src/decition/decition_brain/decition/adc_tools/compute_00.cpp

@@ -0,0 +1,2075 @@
+#include <decision/adc_tools/compute_00.h>
+#include <decision/decide_gps_00.h>
+#include <decision/adc_tools/gps_distance.h>
+#include <decision/decition_type.h>
+#include <decision/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();
+        if((*gpsMap[i]).roadMode!=6)
+                (*gpsMap[i]).roadMode=5;
+    }
+    for (int j = startIndex; j < (endIndex-40); j+=40)
+    {
+        int i = (j + gpsMap.size()) % gpsMap.size();
+        for(int front_k=i;front_k<i+20;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+=20;
+        FrontAveFive=FrontTotalFive/FrontCount;
+        FrontTotalFive=0;
+        FrontCount=0;
+        for(int back_k=i;back_k<i+20;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+=20;
+        CurrentIndex=i-1;
+        BackAveFive=BackTotalFive/BackCount;
+        BackTotalFive=0;
+        BackCount=0;
+        if(fabs(FrontAveFive-BackAveFive)<50)
+        {
+                   if(fabs(FrontAveFive-BackAveFive)>4)
+                   {
+                        CurveContinue+=1;
+                        if(CurveContinue>=1)
+                        {
+                            MarkingCount=0;
+                            for(MarkingIndex=CurrentIndex;MarkingIndex>=MarkedIndex;MarkingIndex--)
+                            {
+                                if((*gpsMap[MarkingIndex]).roadMode!=6)
+                                {
+                                if(MarkingCount<150)
+                                {
+                                     if((BackAveFive-FrontAveFive)<=3.5)
+                                     {
+                                           (*gpsMap[MarkingIndex]).roadMode=14;   //弯道,2米,14
+                                     }
+                                     else if((BackAveFive-FrontAveFive)>3.5)
+                                     {
+                                           (*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)<=4)
+                   {
+                        CurveContinue=0;
+                   }
+        }
+        FrontAveFive=0;
+        BackAveFive=0;
+    }
+
+    if(MarkedIndex<endIndex)
+    {
+        MarkingCount=0;
+        for(MarkingIndex=endIndex;MarkingIndex>=MarkedIndex;MarkingIndex--)
+        {
+            if((*gpsMap[MarkingIndex]).roadMode!=6)
+            {
+            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;
+    }
+
+    ServiceCarStatus.obsTraceLeft.clear();
+    ServiceCarStatus.obsTraceRight.clear();
+
+    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 + ServiceCarStatus.msysparam.vehWidth / 2 * cos(anglevalue + PI / 2),
+                       carFronty + ServiceCarStatus.msysparam.vehWidth / 2 * sin(anglevalue + PI / 2));
+
+        Point2D ptRight(carFrontx + ServiceCarStatus.msysparam.vehWidth / 2 * cos(anglevalue - PI / 2),
+                        carFronty + ServiceCarStatus.msysparam.vehWidth / 2 * sin(anglevalue - PI / 2));
+
+        gpsTraceLeft.push_back(ptLeft);
+        gpsTraceRight.push_back(ptRight);
+
+
+        TracePoint obsptleft(ptLeft.x,ptLeft.y);
+        ServiceCarStatus.obsTraceLeft.push_back(obsptleft);
+
+        TracePoint obsptright(ptRight.x,ptRight.y);
+        ServiceCarStatus.obsTraceLeft.push_back(obsptright);
+
+
+    }
+
+
+    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 <= ServiceCarStatus.msysparam.vehWidth; length += 0.4)
+            {
+                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / ServiceCarStatus.msysparam.vehWidth * length;
+                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / ServiceCarStatus.msysparam.vehWidth * 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 <= ServiceCarStatus.msysparam.vehWidth; length += 0.4)
+            {
+                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / ServiceCarStatus.msysparam.vehWidth * length;
+                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / ServiceCarStatus.msysparam.vehWidth * 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 + (ServiceCarStatus.msysparam.vehWidth-0.3) / 2 * cos(anglevalue + PI / 2),
+                       carFronty + (ServiceCarStatus.msysparam.vehWidth-0.3) / 2 * sin(anglevalue + PI / 2));
+
+        Point2D ptRight(carFrontx + (ServiceCarStatus.msysparam.vehWidth-0.3) / 2 * cos(anglevalue - PI / 2),
+                        carFronty + (ServiceCarStatus.msysparam.vehWidth-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 <= ServiceCarStatus.msysparam.vehWidth; length += 0.4)
+            {
+                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / ServiceCarStatus.msysparam.vehWidth * length;
+                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / ServiceCarStatus.msysparam.vehWidth * 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 <= ServiceCarStatus.msysparam.vehWidth; length += 0.4)
+            {
+                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / ServiceCarStatus.msysparam.vehWidth * length;
+                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / ServiceCarStatus.msysparam.vehWidth * 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 + (ServiceCarStatus.msysparam.vehWidth+(buchang)*2) / 2 * cos(anglevalue + PI / 2),
+                       carFronty +  (ServiceCarStatus.msysparam.vehWidth+(buchang)*2) / 2 * sin(anglevalue + PI / 2));
+
+        Point2D ptRight(carFrontx +  (ServiceCarStatus.msysparam.vehWidth+(buchang)*2) / 2 * cos(anglevalue - PI / 2),
+                        carFronty +  (ServiceCarStatus.msysparam.vehWidth+(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 <= ServiceCarStatus.msysparam.vehWidth; length += 0.4)
+            {
+                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / ServiceCarStatus.msysparam.vehWidth * length;
+                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / ServiceCarStatus.msysparam.vehWidth * 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 <= ServiceCarStatus.msysparam.vehWidth; length += 0.4)
+            {
+                double ptx = gpsTraceLeft[j].x + (gpsTraceRight[j].x - gpsTraceLeft[j].x) / ServiceCarStatus.msysparam.vehWidth * length;
+                double pty = gpsTraceLeft[j].y + (gpsTraceRight[j].y - gpsTraceLeft[j].y) / ServiceCarStatus.msysparam.vehWidth * 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*ServiceCarStatus.msysparam.vehWidth / 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*ServiceCarStatus.msysparam.vehWidth / 2.0+DecideGps00().xiuzhengCs)){
+//                    *esrPathpoint = j;
+//                    return i;
+//                }
+
+
+                if (abs(xxx - gpsTrace[j].x) <= (3.0*ServiceCarStatus.msysparam.vehWidth / 4.0+fxiuzhengCs) && abs(yyy - (gpsTrace[j].y)) <= 1)
+                {
+                    return i;
+
+
+                    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*ServiceCarStatus.msysparam.vehWidth / 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*ServiceCarStatus.msysparam.vehWidth / 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*ServiceCarStatus.msysparam.vehWidth / 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*ServiceCarStatus.msysparam.vehWidth / 4.0,则认为道路上有障碍物。
+            //s则可理解为障碍物距离。为障碍物与车辆沿着道路方向的距离,而不是空间上的x或y坐标或者直线距离。
+            //minDistance、minDis_index用来统计最近的障碍物信息。
+            if(abs(esrObsPoint.d)<=(3.0*ServiceCarStatus.msysparam.vehWidth / 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 - 0
src/decition/decition_brain/decition/adc_tools/compute_00.h

@@ -0,0 +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 <decision/decition_type.h>
+#include <vector>
+#include <decision/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_
+

+ 439 - 0
src/decition/decition_brain/decition/adc_tools/dubins.cpp

@@ -0,0 +1,439 @@
+/*
+ * Copyright (c) 2008-2018, Andrew Walker
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#ifdef WIN32
+#define _USE_MATH_DEFINES
+#endif
+#include <math.h>
+#include "dubins.h"
+
+#define EPSILON (10e-10)
+
+typedef enum
+{
+    L_SEG = 0,
+    S_SEG = 1,
+    R_SEG = 2
+} SegmentType;
+
+/* The segment types for each of the Path types */
+const SegmentType DIRDATA[][3] = {
+    { L_SEG, S_SEG, L_SEG },
+    { L_SEG, S_SEG, R_SEG },
+    { R_SEG, S_SEG, L_SEG },
+    { R_SEG, S_SEG, R_SEG },
+    { R_SEG, L_SEG, R_SEG },
+    { L_SEG, R_SEG, L_SEG }
+};
+
+typedef struct
+{
+    double alpha;
+    double beta;
+    double d;
+    double sa;
+    double sb;
+    double ca;
+    double cb;
+    double c_ab;
+    double d_sq;
+} DubinsIntermediateResults;
+
+
+int dubins_word(DubinsIntermediateResults* in, DubinsPathType pathType, double out[3]);
+int dubins_intermediate_results(DubinsIntermediateResults* in, double q0[3], double q1[3], double rho);
+
+/**
+ * Floating point modulus suitable for rings
+ *
+ * fmod doesn't behave correctly for angular quantities, this function does
+ */
+double fmodr( double x, double y)
+{
+    return x - y*floor(x/y);
+}
+
+double mod2pi( double theta )
+{
+    return fmodr( theta, 2 * M_PI );
+}
+
+int dubins_shortest_path(DubinsPath* path, double q0[3], double q1[3], double rho)
+{
+    int i, errcode;
+    DubinsIntermediateResults in;
+    double params[3];
+    double cost;
+    double best_cost = INFINITY;
+    int best_word = -1;
+    errcode = dubins_intermediate_results(&in, q0, q1, rho);
+    if(errcode != EDUBOK) {
+        return errcode;
+    }
+
+
+    path->qi[0] = q0[0];
+    path->qi[1] = q0[1];
+    path->qi[2] = q0[2];
+    path->rho = rho;
+
+    for( i = 0; i < 6; i++ ) {
+        DubinsPathType pathType = (DubinsPathType)i;
+        errcode = dubins_word(&in, pathType, params);
+        if(errcode == EDUBOK) {
+            cost = params[0] + params[1] + params[2];
+            if(cost < best_cost) {
+                best_word = i;
+                best_cost = cost;
+                path->param[0] = params[0];
+                path->param[1] = params[1];
+                path->param[2] = params[2];
+                path->type = pathType;
+            }
+        }
+    }
+    if(best_word == -1) {
+        return EDUBNOPATH;
+    }
+    return EDUBOK;
+}
+
+int dubins_path(DubinsPath* path, double q0[3], double q1[3], double rho, DubinsPathType pathType)
+{
+    int errcode;
+    DubinsIntermediateResults in;
+    errcode = dubins_intermediate_results(&in, q0, q1, rho);
+    if(errcode == EDUBOK) {
+        double params[3];
+        errcode = dubins_word(&in, pathType, params);
+        if(errcode == EDUBOK) {
+            path->param[0] = params[0];
+            path->param[1] = params[1];
+            path->param[2] = params[2];
+            path->qi[0] = q0[0];
+            path->qi[1] = q0[1];
+            path->qi[2] = q0[2];
+            path->rho = rho;
+            path->type = pathType;
+        }
+    }
+    return errcode;
+}
+
+double dubins_path_length( DubinsPath* path )
+{
+    double length = 0.;
+    length += path->param[0];
+    length += path->param[1];
+    length += path->param[2];
+    length = length * path->rho;
+    return length;
+}
+
+double dubins_segment_length( DubinsPath* path, int i )
+{
+    if( (i < 0) || (i > 2) )
+    {
+        return INFINITY;
+    }
+    return path->param[i] * path->rho;
+}
+
+double dubins_segment_length_normalized( DubinsPath* path, int i )
+{
+    if( (i < 0) || (i > 2) )
+    {
+        return INFINITY;
+    }
+    return path->param[i];
+}
+
+DubinsPathType dubins_path_type( DubinsPath* path )
+{
+    return path->type;
+}
+
+void dubins_segment( double t, double qi[3], double qt[3], SegmentType type)
+{
+    double st = sin(qi[2]);
+    double ct = cos(qi[2]);
+    if( type == L_SEG ) {
+        qt[0] = +sin(qi[2]+t) - st;
+        qt[1] = -cos(qi[2]+t) + ct;
+        qt[2] = t;
+    }
+    else if( type == R_SEG ) {
+        qt[0] = -sin(qi[2]-t) + st;
+        qt[1] = +cos(qi[2]-t) - ct;
+        qt[2] = -t;
+    }
+    else if( type == S_SEG ) {
+        qt[0] = ct * t;
+        qt[1] = st * t;
+        qt[2] = 0.0;
+    }
+    qt[0] += qi[0];
+    qt[1] += qi[1];
+    qt[2] += qi[2];
+}
+
+int dubins_path_sample( DubinsPath* path, double t, double q[3] )
+{
+    /* tprime is the normalised variant of the parameter t */
+    double tprime = t / path->rho;
+    double qi[3]; /* The translated initial configuration */
+    double q1[3]; /* end-of segment 1 */
+    double q2[3]; /* end-of segment 2 */
+    const SegmentType* types = DIRDATA[path->type];
+    double p1, p2;
+
+    if( t < 0 || t > dubins_path_length(path) ) {
+        return EDUBPARAM;
+    }
+
+    /* initial configuration */
+    qi[0] = 0.0;
+    qi[1] = 0.0;
+    qi[2] = path->qi[2];
+
+    /* generate the target configuration */
+    p1 = path->param[0];
+    p2 = path->param[1];
+    dubins_segment( p1,      qi,    q1, types[0] );
+    dubins_segment( p2,      q1,    q2, types[1] );
+    if( tprime < p1 ) {
+        dubins_segment( tprime, qi, q, types[0] );
+    }
+    else if( tprime < (p1+p2) ) {
+        dubins_segment( tprime-p1, q1, q,  types[1] );
+    }
+    else {
+        dubins_segment( tprime-p1-p2, q2, q,  types[2] );
+    }
+
+    /* scale the target configuration, translate back to the original starting point */
+    q[0] = q[0] * path->rho + path->qi[0];
+    q[1] = q[1] * path->rho + path->qi[1];
+    q[2] = mod2pi(q[2]);
+
+    return EDUBOK;
+}
+
+int dubins_path_sample_many(DubinsPath* path, double stepSize,
+                            DubinsPathSamplingCallback cb, void* user_data)
+{
+    int retcode;
+    double q[3];
+    double x = 0.0;
+    double length = dubins_path_length(path);
+    while( x <  length ) {
+        dubins_path_sample( path, x, q );
+        retcode = cb(q, x, user_data);
+        if( retcode != 0 ) {
+            return retcode;
+        }
+        x += stepSize;
+    }
+    return 0;
+}
+
+int dubins_path_endpoint( DubinsPath* path, double q[3] )
+{
+    return dubins_path_sample( path, dubins_path_length(path) - EPSILON, q );
+}
+
+int dubins_extract_subpath( DubinsPath* path, double t, DubinsPath* newpath )
+{
+    /* calculate the true parameter */
+    double tprime = t / path->rho;
+
+    if((t < 0) || (t > dubins_path_length(path)))
+    {
+        return EDUBPARAM;
+    }
+
+    /* copy most of the data */
+    newpath->qi[0] = path->qi[0];
+    newpath->qi[1] = path->qi[1];
+    newpath->qi[2] = path->qi[2];
+    newpath->rho   = path->rho;
+    newpath->type  = path->type;
+
+    /* fix the parameters */
+    newpath->param[0] = fmin( path->param[0], tprime );
+    newpath->param[1] = fmin( path->param[1], tprime - newpath->param[0]);
+    newpath->param[2] = fmin( path->param[2], tprime - newpath->param[0] - newpath->param[1]);
+    return 0;
+}
+
+int dubins_intermediate_results(DubinsIntermediateResults* in, double q0[3], double q1[3], double rho)
+{
+    double dx, dy, D, d, theta, alpha, beta;
+    if( rho <= 0.0 ) {
+        return EDUBBADRHO;
+    }
+
+    dx = q1[0] - q0[0];
+    dy = q1[1] - q0[1];
+    D = sqrt( dx * dx + dy * dy );
+    d = D / rho;
+    theta = 0;
+
+    /* test required to prevent domain errors if dx=0 and dy=0 */
+    if(d > 0) {
+        theta = mod2pi(atan2( dy, dx ));
+    }
+    alpha = mod2pi(q0[2] - theta);
+    beta  = mod2pi(q1[2] - theta);
+
+    in->alpha = alpha;
+    in->beta  = beta;
+    in->d     = d;
+    in->sa    = sin(alpha);
+    in->sb    = sin(beta);
+    in->ca    = cos(alpha);
+    in->cb    = cos(beta);
+    in->c_ab  = cos(alpha - beta);
+    in->d_sq  = d * d;
+
+    return EDUBOK;
+}
+
+int dubins_LSL(DubinsIntermediateResults* in, double out[3])
+{
+    double tmp0, tmp1, p_sq;
+
+    tmp0 = in->d + in->sa - in->sb;
+    p_sq = 2 + in->d_sq - (2*in->c_ab) + (2 * in->d * (in->sa - in->sb));
+
+    if(p_sq >= 0) {
+        tmp1 = atan2( (in->cb - in->ca), tmp0 );
+        out[0] = mod2pi(tmp1 - in->alpha);
+        out[1] = sqrt(p_sq);
+        out[2] = mod2pi(in->beta - tmp1);
+        return EDUBOK;
+    }
+    return EDUBNOPATH;
+}
+
+
+int dubins_RSR(DubinsIntermediateResults* in, double out[3])
+{
+    double tmp0 = in->d - in->sa + in->sb;
+    double p_sq = 2 + in->d_sq - (2 * in->c_ab) + (2 * in->d * (in->sb - in->sa));
+    if( p_sq >= 0 ) {
+        double tmp1 = atan2( (in->ca - in->cb), tmp0 );
+        out[0] = mod2pi(in->alpha - tmp1);
+        out[1] = sqrt(p_sq);
+        out[2] = mod2pi(tmp1 -in->beta);
+        return EDUBOK;
+    }
+    return EDUBNOPATH;
+}
+
+int dubins_LSR(DubinsIntermediateResults* in, double out[3])
+{
+    double p_sq = -2 + (in->d_sq) + (2 * in->c_ab) + (2 * in->d * (in->sa + in->sb));
+    if( p_sq >= 0 ) {
+        double p    = sqrt(p_sq);
+        double tmp0 = atan2( (-in->ca - in->cb), (in->d + in->sa + in->sb) ) - atan2(-2.0, p);
+        out[0] = mod2pi(tmp0 - in->alpha);
+        out[1] = p;
+        out[2] = mod2pi(tmp0 - mod2pi(in->beta));
+        return EDUBOK;
+    }
+    return EDUBNOPATH;
+}
+
+int dubins_RSL(DubinsIntermediateResults* in, double out[3])
+{
+    double p_sq = -2 + in->d_sq + (2 * in->c_ab) - (2 * in->d * (in->sa + in->sb));
+    if( p_sq >= 0 ) {
+        double p    = sqrt(p_sq);
+        double tmp0 = atan2( (in->ca + in->cb), (in->d - in->sa - in->sb) ) - atan2(2.0, p);
+        out[0] = mod2pi(in->alpha - tmp0);
+        out[1] = p;
+        out[2] = mod2pi(in->beta - tmp0);
+        return EDUBOK;
+    }
+    return EDUBNOPATH;
+}
+
+int dubins_RLR(DubinsIntermediateResults* in, double out[3])
+{
+    double tmp0 = (6. - in->d_sq + 2*in->c_ab + 2*in->d*(in->sa - in->sb)) / 8.;
+    double phi  = atan2( in->ca - in->cb, in->d - in->sa + in->sb );
+    if( fabs(tmp0) <= 1) {
+        double p = mod2pi((2*M_PI) - acos(tmp0) );
+        double t = mod2pi(in->alpha - phi + mod2pi(p/2.));
+        out[0] = t;
+        out[1] = p;
+        out[2] = mod2pi(in->alpha - in->beta - t + mod2pi(p));
+        return EDUBOK;
+    }
+    return EDUBNOPATH;
+}
+
+int dubins_LRL(DubinsIntermediateResults* in, double out[3])
+{
+    double tmp0 = (6. - in->d_sq + 2*in->c_ab + 2*in->d*(in->sb - in->sa)) / 8.;
+    double phi = atan2( in->ca - in->cb, in->d + in->sa - in->sb );
+    if( fabs(tmp0) <= 1) {
+        double p = mod2pi( 2*M_PI - acos( tmp0) );
+        double t = mod2pi(-in->alpha - phi + p/2.);
+        out[0] = t;
+        out[1] = p;
+        out[2] = mod2pi(mod2pi(in->beta) - in->alpha -t + mod2pi(p));
+        return EDUBOK;
+    }
+    return EDUBNOPATH;
+}
+
+int dubins_word(DubinsIntermediateResults* in, DubinsPathType pathType, double out[3])
+{
+    int result;
+    switch(pathType)
+    {
+    case LSL:
+        result = dubins_LSL(in, out);
+        break;
+    case RSL:
+        result = dubins_RSL(in, out);
+        break;
+    case LSR:
+        result = dubins_LSR(in, out);
+        break;
+    case RSR:
+        result = dubins_RSR(in, out);
+        break;
+    case LRL:
+        result = dubins_LRL(in, out);
+        break;
+    case RLR:
+        result = dubins_RLR(in, out);
+        break;
+    default:
+        result = EDUBNOPATH;
+    }
+    return result;
+}
+
+

+ 149 - 0
src/decition/decition_brain/decition/adc_tools/dubins.h

@@ -0,0 +1,149 @@
+#ifndef DUBINS_H
+#define DUBINS_H
+
+typedef enum
+{
+    LSL = 0,
+    LSR = 1,
+    RSL = 2,
+    RSR = 3,
+    RLR = 4,
+    LRL = 5
+} DubinsPathType;
+
+typedef struct
+{
+    /* the initial configuration */
+    double qi[3];
+    /* the lengths of the three segments */
+    double param[3];
+    /* model forward velocity / model angular velocity */
+    double rho;
+    /* the path type described */
+    DubinsPathType type;
+} DubinsPath;
+
+#define EDUBOK        (0)   /* No error */
+#define EDUBCOCONFIGS (1)   /* Colocated configurations */
+#define EDUBPARAM     (2)   /* Path parameterisitation error */
+#define EDUBBADRHO    (3)   /* the rho value is invalid */
+#define EDUBNOPATH    (4)   /* no connection between configurations with this word */
+
+/**
+ * Callback function for path sampling
+ *
+ * @note the q parameter is a configuration
+ * @note the t parameter is the distance along the path
+ * @note the user_data parameter is forwarded from the caller
+ * @note return non-zero to denote sampling should be stopped
+ */
+typedef int (*DubinsPathSamplingCallback)(double q[3], double t, void* user_data);
+
+/**
+ * Generate a path from an initial configuration to
+ * a target configuration, with a specified maximum turning
+ * radii
+ *
+ * A configuration is (x, y, theta), where theta is in radians, with zero
+ * along the line x = 0, and counter-clockwise is positive
+ *
+ * @param path  - the resultant path
+ * @param q0    - a configuration specified as an array of x, y, theta
+ * @param q1    - a configuration specified as an array of x, y, theta
+ * @param rho   - turning radius of the vehicle (forward velocity divided by maximum angular velocity)
+ * @return      - non-zero on error
+ */
+int dubins_shortest_path(DubinsPath* path, double q0[3], double q1[3], double rho);
+
+/**
+ * Generate a path with a specified word from an initial configuration to
+ * a target configuration, with a specified turning radius
+ *
+ * @param path     - the resultant path
+ * @param q0       - a configuration specified as an array of x, y, theta
+ * @param q1       - a configuration specified as an array of x, y, theta
+ * @param rho      - turning radius of the vehicle (forward velocity divided by maximum angular velocity)
+ * @param pathType - the specific path type to use
+ * @return         - non-zero on error
+ */
+int dubins_path(DubinsPath* path, double q0[3], double q1[3], double rho, DubinsPathType pathType);
+
+/**
+ * Calculate the length of an initialised path
+ *
+ * @param path - the path to find the length of
+ */
+double dubins_path_length(DubinsPath* path);
+
+/**
+ * Return the length of a specific segment in an initialized path
+ *
+ * @param path - the path to find the length of
+ * @param i    - the segment you to get the length of (0-2)
+ */
+double dubins_segment_length(DubinsPath* path, int i);
+
+/**
+ * Return the normalized length of a specific segment in an initialized path
+ *
+ * @param path - the path to find the length of
+ * @param i    - the segment you to get the length of (0-2)
+ */
+double dubins_segment_length_normalized( DubinsPath* path, int i );
+
+/**
+ * Extract an integer that represents which path type was used
+ *
+ * @param path    - an initialised path
+ * @return        - one of LSL, LSR, RSL, RSR, RLR or LRL
+ */
+DubinsPathType dubins_path_type(DubinsPath* path);
+
+/**
+ * Calculate the configuration along the path, using the parameter t
+ *
+ * @param path - an initialised path
+ * @param t    - a length measure, where 0 <= t < dubins_path_length(path)
+ * @param q    - the configuration result
+ * @returns    - non-zero if 't' is not in the correct range
+ */
+int dubins_path_sample(DubinsPath* path, double t, double q[3]);
+
+/**
+ * Walk along the path at a fixed sampling interval, calling the
+ * callback function at each interval
+ *
+ * The sampling process continues until the whole path is sampled, or the callback returns a non-zero value
+ *
+ * @param path      - the path to sample
+ * @param stepSize  - the distance along the path for subsequent samples
+ * @param cb        - the callback function to call for each sample
+ * @param user_data - optional information to pass on to the callback
+ *
+ * @returns - zero on successful completion, or the result of the callback
+ */
+int dubins_path_sample_many(DubinsPath* path,
+                            double stepSize,
+                            DubinsPathSamplingCallback cb,
+                            void* user_data);
+
+/**
+ * Convenience function to identify the endpoint of a path
+ *
+ * @param path - an initialised path
+ * @param q    - the configuration result
+ */
+int dubins_path_endpoint(DubinsPath* path, double q[3]);
+
+/**
+ * Convenience function to extract a subset of a path
+ *
+ * @param path    - an initialised path
+ * @param t       - a length measure, where 0 < t < dubins_path_length(path)
+ * @param newpath - the resultant path
+ */
+int dubins_extract_subpath(DubinsPath* path, double t, DubinsPath* newpath);
+
+
+
+#endif // DUBINS_H

+ 154 - 0
src/decition/decition_brain/decition/adc_tools/gnss_coordinate_convert.cpp

@@ -0,0 +1,154 @@
+#include <decision/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 - 0
src/decition/decition_brain/decition/adc_tools/gnss_coordinate_convert.h

@@ -0,0 +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_

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

@@ -0,0 +1,45 @@
+#include <decision/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 - 0
src/decition/decition_brain/decition/adc_tools/gps_distance.h

@@ -0,0 +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_

+ 109 - 0
src/decition/decition_brain/decition/adc_tools/parameter_status.h

@@ -0,0 +1,109 @@
+#ifndef PARAMETER_STATUS_H
+#define PARAMETER_STATUS_H
+
+
+
+
+#include <common/boost.h>
+#include <cstdint>
+#include <boost/serialization/singleton.hpp>
+#include <control/vv7.h>
+
+namespace iv {
+    namespace decition {
+        class ParameterStatus : public boost::noncopyable
+        {
+        public:
+            /*****************
+             * **** speed control *****
+             * ***************/
+
+
+
+
+                    float speed_kp=0.5;
+                    float speed_kd=0.3;
+                    float speed_ki=0;
+
+                    float speed_kp_t=10;
+                    float speed_kd_t=0;
+                    float speed_ki_t=0;
+
+                    float speed_increase_limite_switch=1;
+                    float speed_decline_limite_switch=1;
+                    float speed_max_increase=5;
+                    float speed_max_decline=10;
+
+
+
+
+            /*****************
+             * **** ttc control *****
+             * ***************/
+
+                float ttc_emc=0.8;
+                float ttc_urgent=1.6;
+                float ttc_early=10;
+                float brakeIntMax_emc=10;
+                float brakeIntMax_urgent=5;
+                float brakeIntMax_early=3;
+
+
+            /*****************
+             * **** wheel control *****
+             * ***************/
+
+                float wheel_p_eang=14;
+                float wheel_p_epos=10;
+                float wheel_d_eang=5;
+                float wheel_d_epos=5;
+                float wheel_i_eang=0;
+                float wheel_i_epos=0;
+
+                float  wheel_previewDistance_coefficient=0.6;
+                float  wheel_previewDistance_min=5;
+                float  wheel_change_limit_switch=0;
+                float  wheel_max_change=10;
+
+            /*****************
+             * **** path planning *****
+             * ***************/
+                float road_width = 3.5; //道路宽度
+                int now_road_num = 0;  //车辆当前所在道路编号
+
+
+            /*****************
+             * **** frenet path planning *****
+             * ***************/
+                double MAX_SPEED = 50.0 / 3.6;     // 最大速度 [m/s]
+                double MAX_ACCEL = 10;            // 最大加速度[m/ss]
+                double MAX_CURVATURE = 10;        // 最大曲率 [1/m]
+                double MIN_ROAD_OFFSET = -3.5;     // 最小道路偏移度 [m]。可以为负数。
+                double MAX_ROAD_WIDTH = 3.5;       // 最大道路宽度 [m]。过小可能不具有避障功能。
+                double D_ROAD_W = 3.5;             // 道路宽度采样间隔 [m]
+                double DT = 0.2;                   // Delta T [s]。总的预测时间的增量。
+                double MAXT = 4.0;                 // 最大预测时间 [s]
+                double MINT = 2.0;                 // 最小预测时间 [s]
+                double D_POINT_T = 0.04;           // 时间增量 [s]。用于控制每条轨迹生成轨迹点的密度。
+                double TARGET_SPEED = 30.0 / 3.6;  // 目标速度(即纵向的速度保持) [m/s]
+                double D_T_S = 5.0 / 3.6;          // 目标速度采样间隔 [m/s]
+                double N_S_SAMPLE = 1;             // sampling number of target speed
+                double ROBOT_RADIUS = 2.0;         // robot radius [m]
+
+                // 损失函数权重
+                double KJ = 0.1;
+                double KT = 0.1;
+                double KD = 1.0;
+                double KLAT = 1.0;
+                double KLON = 1.0;
+
+
+    };
+        typedef boost::serialization::singleton<iv::decition::ParameterStatus> ParameterStatusSingleton;
+}
+#define ServiceParameterStatus iv::decition::ParameterStatusSingleton::get_mutable_instance()
+
+}
+
+
+#endif // PARAMETER_STATUS_H

+ 138 - 0
src/decition/decition_brain/decition/adc_tools/transfer.cpp

@@ -0,0 +1,138 @@
+#include <decision/adc_tools/transfer.h>
+#include <decision/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 - 0
src/decition/decition_brain/decition/adc_tools/transfer.h

@@ -0,0 +1,27 @@
+#pragma once
+#ifndef _IV_DECITION_TRANSFER_
+#define _IV_DECITION_TRANSFER_
+
+#include <common/gps_type.h>
+#include <decision/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_

+ 1404 - 0
src/decition/decition_brain/decition/brain.cpp

@@ -0,0 +1,1404 @@
+#include <decision/brain.h>
+#include <fstream>
+#include <time.h>
+#include <exception>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <common/logout.h>
+#include <decision/adc_tools/transfer.h>
+
+#include <iostream>
+#include "xmlparam.h"
+#include "qcoreapplication.h"
+#include <QTime>
+
+QTime  gps_update_times,gps_last_to_current;
+
+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 Listenv2x(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
+        {
+            (void)&index;
+            (void)dt;
+            (void)strmemname;
+            gbrain->Updatev2x(strdata,nSize);
+        }
+
+        void Listenultra(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
+        {
+            (void)&index;
+            (void)dt;
+            (void)strmemname;
+            gbrain->Updateultra(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);
+
+    v2x = iv::modulecomm::RegisterRecv("v2x",iv::decition::Listenv2x);
+    ultra = iv::modulecomm::RegisterRecv("ultra",iv::decition::Listenultra);
+
+    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);
+    mpaObsTraceLeft = iv::modulecomm::RegisterSend("obstraceleft",100000,1);
+    mpaObsTraceRight = iv::modulecomm::RegisterSend("obstraceright",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","yuhesen");
+
+    ServiceCarStatus.msysparam.vehWidth = atof(xp.GetParam("vehWidth","2.1").data());
+    ServiceCarStatus.msysparam.vehLenth = atof(xp.GetParam("vehLenth","4.6").data());
+
+
+    /*=============     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
+
+
+    adjuseGpsLidarPosition();
+
+    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;
+    }
+
+    std::string inRoadAvoid = xp.GetParam("inRoadAvoid","false");  //If Use MPC set true
+    if(inRoadAvoid == "true")
+    {
+        ServiceCarStatus.inRoadAvoid = true;
+    }else{
+        ServiceCarStatus.inRoadAvoid = false;
+    }
+
+    std::string avoidObs = xp.GetParam("avoidObs","false");  //If Use MPC set true
+    if(avoidObs == "true")
+    {
+        ServiceCarStatus.avoidObs = true;
+    }else{
+        ServiceCarStatus.avoidObs = false;
+    }
+
+    //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;
+
+        int gps_update_period=0,gps_last_to_current_times=0;
+
+        gps_update_times.start();
+        eyes->getSensorObstacle(obs_radar_, obs_camera_,gps_data_, obs_lidar_grid_);	//从传感器线程临界区交换数据
+        if(gps_data_!=NULL)
+        {
+           gps_update_period=gps_update_times.elapsed();
+           gps_last_to_current.start();
+        }
+        gps_last_to_current_times=gps_last_to_current.elapsed();
+
+
+
+
+
+
+        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 (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;
+
+        givlog->debug("GPS","gps_data_ is: %d,gps_update_period is: %d,gps_last_to_current_times is: %d",gps_data_,gps_update_period,gps_last_to_current_times);
+
+        if (gps_data_  &&!handPark && !ServiceCarStatus.m_bOutGarage){// && obs_lidar_grid_) {	//处理GPS数据
+
+            double start = GetTickCount();
+
+            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::TracePoint));
+
+            iv::modulecomm::ModuleSendMsg(mpaObsTraceLeft,(char *)(ServiceCarStatus.obsTraceLeft.data()),ServiceCarStatus.obsTraceLeft.size()*sizeof(iv::TracePoint));
+            iv::modulecomm::ModuleSendMsg(mpaObsTraceRight,(char *)(ServiceCarStatus.obsTraceRight.data()),ServiceCarStatus.obsTraceRight.size()*sizeof(iv::TracePoint));
+            //      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);
+    xdecition.set_door(decition->door);
+
+
+
+    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.has_engine_speed())
+    {
+         ServiceCarStatus.engine_speed = xchassis.engine_speed();
+
+         std::cout<<"******* xchassis.engine_speed:"<< xchassis.engine_speed()<<std::endl;
+
+
+    }
+    //    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::Updatev2x(const char *pdata, const int ndatasize){
+
+    iv::v2x::v2x v2x_message;
+    if(false == v2x_message.ParseFromArray(pdata,ndatasize))
+    {
+        std::cout<<"Listenv2x fail."<<std::endl;
+        return;
+    }
+
+//  解析v2x信息
+    ServiceCarStatus.stationCmd.received=true;
+
+    ServiceCarStatus.stationCmd.has_carID=v2x_message.has_carid();
+    if(ServiceCarStatus.stationCmd.has_carID)
+    {
+            ServiceCarStatus.stationCmd.carID=v2x_message.carid();
+    }
+
+    ServiceCarStatus.stationCmd.has_carMode=v2x_message.has_carmode();
+    if(ServiceCarStatus.stationCmd.has_carMode)
+    {
+            ServiceCarStatus.stationCmd.carMode=v2x_message.carmode();
+
+            qDebug("ServiceCarStatus.stationCmd.carMode:",ServiceCarStatus.stationCmd.carMode);
+            givlog->debug("brain_v2x","ServiceCarStatus.stationCmd.carMode:%d",ServiceCarStatus.stationCmd.carMode);
+    }
+
+    ServiceCarStatus.stationCmd.has_emergencyStop=v2x_message.has_emergencystop();
+    if(ServiceCarStatus.stationCmd.has_emergencyStop)
+    {
+            ServiceCarStatus.stationCmd.emergencyStop=v2x_message.emergencystop();
+
+            qDebug("ServiceCarStatus.stationCmd.emergencyStop:",ServiceCarStatus.stationCmd.emergencyStop);
+            givlog->debug("brain_v2x","ServiceCarStatus.stationCmd.emergencyStop:%d",ServiceCarStatus.stationCmd.emergencyStop);
+    }
+
+    ServiceCarStatus.stationCmd.has_stationStop=v2x_message.has_stationstop();
+    if(ServiceCarStatus.stationCmd.has_stationStop)
+    {
+            ServiceCarStatus.stationCmd.stationStop=v2x_message.stationstop();
+
+            qDebug("ServiceCarStatus.stationCmd.stationStop:",ServiceCarStatus.stationCmd.stationStop);
+            givlog->debug("brain_v2x","ServiceCarStatus.stationCmd.stationStop:%d",ServiceCarStatus.stationCmd.stationStop);
+    }
+    int num=v2x_message.stationid_size();
+    if(num>0)
+    {
+        ServiceCarStatus.stationCmd.stationTotalNum=num;
+        for(int i=0;i<ServiceCarStatus.stationCmd.stationTotalNum;i++)
+        {
+            ServiceCarStatus.stationCmd.stationGps[i].gps_lat=v2x_message.stgps(i).lat();
+            ServiceCarStatus.stationCmd.stationGps[i].gps_lng=v2x_message.stgps(i).lon();
+
+            qDebug("stationGps: %d, lat: %.7f, lon: %.7f", v2x_message.stationid(i), ServiceCarStatus.stationCmd.stationGps[i].gps_lat, ServiceCarStatus.stationCmd.stationGps[i].gps_lng);
+            givlog->debug("brain_v2x","stationGps: %d, lat: %.7f, lon: %.7f",
+                           v2x_message.stationid(i),ServiceCarStatus.stationCmd.stationGps[i].gps_lat,
+                          ServiceCarStatus.stationCmd.stationGps[i].gps_lng);
+        }
+        ServiceCarStatus.mbRunPause=false;
+    }
+
+}
+
+void iv::decition::BrainDecition::Updateultra(const char *pdata, const int ndatasize)
+{
+    iv::ultrasonic::ultrasonic ultraarry;
+    if(false == ultraarry.ParseFromArray(pdata,ndatasize))
+    {
+        std::cout<<"Listenultra fail."<<std::endl;
+        return;
+    }
+
+    ServiceCarStatus.ultraDistance[1]=ultraarry.sigobjdist_flcorner();
+    ServiceCarStatus.ultraDistance[2]=ultraarry.sigobjdist_flmiddle();
+    ServiceCarStatus.ultraDistance[3]=ultraarry.sigobjdist_flside();
+    ServiceCarStatus.ultraDistance[4]=ultraarry.sigobjdist_frcorner();
+    ServiceCarStatus.ultraDistance[5]=ultraarry.sigobjdist_frmiddle();
+    ServiceCarStatus.ultraDistance[6]=ultraarry.sigobjdist_frside();
+    ServiceCarStatus.ultraDistance[7]=ultraarry.sigobjdist_rlcorner();
+    ServiceCarStatus.ultraDistance[8]=ultraarry.sigobjdist_rlmiddle();
+    ServiceCarStatus.ultraDistance[9]=ultraarry.sigobjdist_rlside();
+    ServiceCarStatus.ultraDistance[10]=ultraarry.sigobjdist_rrcorner();
+    ServiceCarStatus.ultraDistance[11]=ultraarry.sigobjdist_rrmiddle();
+    ServiceCarStatus.ultraDistance[12]=ultraarry.sigobjdist_rrside();
+}
+
+
+void iv::decition::BrainDecition::UpdateSate(){
+     decitionGps00->isFirstRun=true;
+}
+
+void iv::decition::BrainDecition::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;
+}

+ 176 - 0
src/decition/decition_brain/decition/brain.h

@@ -0,0 +1,176 @@
+#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 <decision/decition_maker.h>
+//#include <decition/decition_executer.h>
+#include <decision/decition_voter.h>
+#include <decision/decide_gps_00.h>
+#include <decision/decide_line_00.h>
+#include <decision/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 "v2x.pb.h"
+#include "ultrasonic.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;
+            //iv::StationCmd   stationCmd;
+            int lastMode;
+            bool lastPause;
+
+			void run();	//实际执行逻辑
+
+            void * mpamapreq;
+            void * mpa;
+            void * mpvbox;
+            QMutex mMutexMap;
+
+            void * mpaDecition;
+            void * mpaVechicleState;
+            void * mpaToPlatform;
+            void * mpaPlanTrace;
+            void * mpaObsTraceLeft;
+            void * mpaObsTraceRight;
+
+
+            void ShareDecition(iv::decition::Decition decition);
+            void ShareBrainstate(iv::brain::brainstate xbs);
+
+        private:
+            void * mpaPAD;
+            void * mpaHMI;
+            void * mpaPlatform;
+            void *mpaGroup;
+            void * mpmapChangeSig;
+            void * v2x;
+            void * ultra;
+            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);
+            void Updatev2x(const char * pdata,const int ndatasize);
+            void Updateultra(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);
+            void adjuseGpsLidarPosition();
+
+            fanyaapi mmpcapi;
+
+            bool mbUseExternMPC = false;
+        };
+
+    }
+}
+
+#endif // !_IV_DECITION_BRAIN_

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

@@ -0,0 +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;

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

@@ -0,0 +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 <decision/decition_type.h>
+#include <vector>
+#include <decision/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 - 0
src/decition/decition_brain/decition/decide_from_gps.cpp

@@ -0,0 +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();
+}*/
+
+
+
+

+ 3902 - 0
src/decition/decition_brain/decition/decide_gps_00.cpp

@@ -0,0 +1,3902 @@
+#include <decision/decide_gps_00.h>
+#include <decision/adc_tools/compute_00.h>
+#include <decision/adc_tools/gps_distance.h>
+#include <decision/decition_type.h>
+#include <decision/adc_tools/transfer.h>
+#include <decision/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 <decision/adc_controller/base_controller.h>
+#include <decision/adc_controller/pid_controller.h>
+#include <decision/adc_planner/lane_change_planner.h>
+#include <decision/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;
+
+        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;
+
+
+
+
+
+
+
+
+
+
+
+    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;
+    }
+
+
+
+    if(!ServiceCarStatus.inRoadAvoid){
+        roadOri = gpsMapLine[PathPoint]->roadOri;
+        roadSum = gpsMapLine[PathPoint]->roadSum;
+    }else{
+        roadOri=gpsMapLine[PathPoint]->roadOri*3+1;
+        roadSum = gpsMapLine[PathPoint]->roadSum*3;
+    }
+
+    if(ServiceCarStatus.avoidObs){
+         gpsMapLine[PathPoint]->runMode=1;
+    }else{
+         gpsMapLine[PathPoint]->runMode=0;
+    }
+
+    if(roadNowStart){
+        roadNow=roadOri;
+        roadNowStart=false;
+    }
+
+ //   avoidX = (roadOri-roadNow)*roadWidth;
+    avoidX=computeAvoidX(roadNow,roadOri,gpsMapLine[PathPoint],ServiceCarStatus.msysparam.vehWidth);
+
+
+    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;
+             avoidX=computeAvoidX(roadNow,roadOri,gpsMapLine[PathPoint],ServiceCarStatus.msysparam.vehWidth);
+            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
+
+    planTrace.clear();
+    for(int i=0;i<gpsTraceNow.size();i++){
+        TracePoint pt(gpsTraceNow[i].x,gpsTraceNow[i].y);
+        planTrace.push_back(pt);
+    }
+
+
+    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 >= 12.5 && parkDis<20)
+            {
+                dSpeed = min(dSpeed, 8.0);
+            }else if (parkDistance < 12.5 && parkDistance >= 8.5 && parkDis<15.0){
+                dSpeed = min(dSpeed, 5.0);
+            }else if (parkDistance < 8.5 && parkDistance >= 5.5 && parkDis<9.0){
+                dSpeed = min(dSpeed, 3.0);
+            }else if(parkDistance < 5.5 && parkDis<6.0){
+                dSpeed = min(dSpeed, 1.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);
+        gps_decition->leftlamp = false;
+        gps_decition->rightlamp = false;
+
+    }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);
+        gps_decition->leftlamp = false;
+        gps_decition->rightlamp = false;
+
+        /*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);
+
+    }else{
+        dSpeed = min(ServiceCarStatus.mroadmode_vel.mfmode0,dSpeed);
+        gps_decition->leftlamp = false;
+        gps_decition->rightlamp = false;
+
+    }
+
+
+
+
+
+    if (gpsMapLine[PathPoint]->speed_mode == 2)
+    {
+        dSpeed = min(25.0,dSpeed);
+
+    }
+
+    if((gpsMapLine[PathPoint]->speed)>0.001)
+    {
+        dSpeed = min((gpsMapLine[PathPoint]->speed*3.6),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
+             avoidX=computeAvoidX(roadNow,roadOri,gpsMapLine[PathPoint],ServiceCarStatus.msysparam.vehWidth);
+        }
+    }
+    if (roadNow != roadOri && roadPre!=-1)
+    {
+
+        roadNow = roadPre;
+     //   avoidX = (roadOri - roadNow)*roadWidth;
+         avoidX=computeAvoidX(roadNow,roadOri,gpsMapLine[PathPoint],ServiceCarStatus.msysparam.vehWidth);
+        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
+                 avoidX=computeAvoidX(roadNow,roadOri,gpsMapLine[PathPoint],ServiceCarStatus.msysparam.vehWidth);
+            }
+            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;
+                     avoidX=computeAvoidX(roadNow,roadOri,gpsMapLine[PathPoint],ServiceCarStatus.msysparam.vehWidth);
+                    gpsTraceNow.clear();
+                    gpsTraceNow = getGpsTraceOffset(gpsTraceOri, avoidX);
+                }
+                else if(useFrenet){
+                    if(roadPre != roadNow){
+                        avoidMinDistanceVector[roadNow] = obsDisVector[roadNow] + ServiceCarStatus.msysparam.vehLenth;
+                        startAvoidGpsInsVector[roadNow] = now_gps_ins;
+                    }
+                    roadNow = roadPre;
+                 //   avoidX = (roadOri - roadNow)*roadWidth;
+                     avoidX=computeAvoidX(roadNow,roadOri,gpsMapLine[PathPoint],ServiceCarStatus.msysparam.vehWidth);
+                    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=-0.4;
+
+        if(finishPointNum<0||finishPointNum>=gpsMapLine.size()){
+            parkMode=false;
+        }else if(GetDistance(now_gps_ins, *gpsMapLine[finishPointNum])>4){
+            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.stationCmd.received==true)
+    {
+        std::vector<Station>  station_received;
+        Station station_aa,station_nearest;
+
+        if(ServiceCarStatus.stationCmd.has_emergencyStop)
+        {
+            if(ServiceCarStatus.stationCmd.emergencyStop==0x01)
+            {
+                //ServiceCarStatus.carState = 0;
+                //busMode=true;
+                ServiceCarStatus.emergencyStop=1;
+            }
+            else
+            {
+                //ServiceCarStatus.carState = 1;
+                //busMode=false;
+                ServiceCarStatus.emergencyStop=0;
+            }
+        }
+
+        if(ServiceCarStatus.stationCmd.has_stationStop)
+        {
+            //寻找最近站点
+            station_received.clear();
+            for(int i=0;i<ServiceCarStatus.stationCmd.stationTotalNum;i++)
+            {
+                station_aa.index=i;
+                station_aa.station_location.gps_lat=ServiceCarStatus.stationCmd.stationGps[i].gps_lat;
+                station_aa.station_location.gps_lng=ServiceCarStatus.stationCmd.stationGps[i].gps_lng;
+                GaussProjCal(station_aa.station_location.gps_lng,station_aa.station_location.gps_lat, &station_aa.station_location.gps_x, &station_aa.station_location.gps_y);
+                station_received.push_back(station_aa);
+            }
+            station_nearest=getNearestStation(now_gps_ins,station_received,gpsMapLine);
+
+            qDebug("station_nearest: %d, lat: %.7f, lon: %.7f", station_nearest.map_index, station_nearest.station_location.gps_lat, ServiceCarStatus.amilng=station_nearest.station_location.gps_lng);
+            givlog->debug("brain_v2x","station_nearest: %d, lat: %.7f, lon: %.7f",
+                          station_nearest.map_index, station_nearest.station_location.gps_lat,
+                          station_nearest.station_location.gps_lng);
+            //进入站点模式
+            if((ServiceCarStatus.stationCmd.stationStop==0x00))
+            {
+                ServiceCarStatus.carState = 2;
+                ServiceCarStatus.amilat=station_nearest.station_location.gps_lat;
+                ServiceCarStatus.amilng=station_nearest.station_location.gps_lng;
+                busMode=true;
+            }else
+            {
+                ServiceCarStatus.carState = 1;
+                busMode=false;
+                ServiceCarStatus.station_control_door=0;
+                ServiceCarStatus.station_control_door_option=false;
+            }
+        }
+        if(ServiceCarStatus.stationCmd.has_carMode)
+        {
+            if(ServiceCarStatus.stationCmd.carMode==0x00)
+            {
+                ServiceCarStatus.stationCmd.mode_manual_drive=true;
+            }else
+            {
+                ServiceCarStatus.stationCmd.mode_manual_drive=false;
+            }
+        }
+
+        ServiceCarStatus.stationCmd.received=false;
+    }
+
+
+
+
+    //carState == 0,紧急停车
+    if ((ServiceCarStatus.emergencyStop==1))  //||(adjuseultra()==true))
+    {
+        minDecelerate=-1.0;
+    }
+
+    if (ServiceCarStatus.carState == 3 && busMode)
+    {
+
+        if(realspeed<0.1){
+            ServiceCarStatus.carState=0;
+            minDecelerate=-1.0;
+        }else{
+            nearStation=true;
+            dSpeed=0;
+        }
+
+    }
+
+    //carState==2,站点停车
+    if ((ServiceCarStatus.carState==2)&&busMode)
+    {
+
+        aim_gps_ins.gps_lat=ServiceCarStatus.amilat;
+        aim_gps_ins.gps_lng=ServiceCarStatus.amilng;
+
+        GaussProjCal( aim_gps_ins.gps_lng, aim_gps_ins.gps_lat,  &aim_gps_ins.gps_x, &aim_gps_ins.gps_y);
+        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);
+
+        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);
+        }
+
+        if((pt.y<5)&&(abs(realspeed)<0.1)&&(ServiceCarStatus.station_control_door==0))
+        {
+            ServiceCarStatus.station_control_door=1;   //open door
+        }
+
+        //站点停车log
+        givlog->debug("brain_v2x","aim_gps_ins.gps_lat: %.7f, aim_gps_ins.gps_lng: %.7f, dis: %.2f, dSpeed: %.1f",
+                      aim_gps_ins.gps_lat, aim_gps_ins.gps_lng,
+                      dis,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--------------------------------------------------------------------------------------
+
+
+    transferGpsMode2(gpsMapLine);
+
+
+
+    if((ServiceCarStatus.msysparam.mvehtype=="hapo")&&(abs(realspeed)<18)){
+        if(obsDistance>0 && obsDistance<6){
+            dSpeed=0;
+        }
+    }else 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);
+    gps_decition->wheel_angle = 0.0 - controlAng;
+    phaseSpeedDecition(gps_decition, secSpeed, obsDistance, obsSpeed,now_gps_ins);
+
+
+
+    lastAngle=gps_decition->wheel_angle;
+
+    //   qDebug("decide1 time is %d",xTime.elapsed());
+
+    for(int i=0;i<ServiceCarStatus.obsTraceLeft.size();i++){
+        givlog->debug("obs_distance","obsTraceLeftX: %f, obsTraceLeftY: %f",
+                      ServiceCarStatus.obsTraceLeft.at(i).x, ServiceCarStatus.obsTraceLeft.at(i).y);
+    }
+
+
+    return gps_decition;
+}
+
+iv::Station iv::decition::DecideGps00::getNearestStation(iv::GPS_INS now_gps_ins,std::vector<Station> station_n,std::vector<GPSData> gpsMap){
+
+    int now_index=0,front_index=0;
+    int station_size=station_n.size();
+
+    for(int i=0;i<station_size;i++)
+    {
+        int minDistance=10;
+        for (int j = 0; j < gpsMap.size(); j++)
+        {
+            double tmpdis = GetDistance(station_n[i].station_location, (*gpsMap[j]));
+            if (tmpdis < minDistance )
+            {
+                minDistance = tmpdis;
+                station_n[i].map_index=j;
+            }
+        }
+        givlog->debug("brain_v2x","stationi: %d, map_index: %d",
+                      i,station_n[i].map_index);
+
+    }
+    int minDistance=10;
+    for (int j = 0; j < gpsMap.size(); j++)
+    {
+        double tmpdis = GetDistance(now_gps_ins, (*gpsMap[j]));
+        if (tmpdis < minDistance )
+        {
+            minDistance = tmpdis;
+            now_index=j;
+        }
+    }
+
+    givlog->debug("brain_v2x","now_index: %d",
+                  now_index);
+
+    int min_index=gpsMap.size()-1;
+    int station_index=0;
+    for(int i=0;i<station_size;i++)
+    {
+        if(station_n[i].map_index>now_index)
+        {
+            front_index=station_n[i].map_index;
+            if(front_index<min_index)
+            {
+                min_index=front_index;
+                station_index=i;
+            }
+        }
+    }
+
+    qDebug("station_index:%d",station_index);
+
+    return station_n[station_index];
+
+}
+
+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();
+    yuhesen_Adapter = new YuHeSenAdapter();
+
+
+    mpid_Controller.reset(pid_Controller);
+    mbus_Adapter.reset(bus_Adapter);
+    mhapo_Adapter.reset(hapo_Adapter);
+    myuhesen_Adapter.reset(yuhesen_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);
+    }
+    else if(ServiceCarStatus.msysparam.mvehtype=="yuhesen"){
+        yuhesen_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]+ServiceCarStatus.msysparam.vehLenth)||
+            (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);
+
+    double mobieye_ttc,mobieye_obsid,mobieye_speed,mobieye_distance;
+
+    double fveh_width = 2.0;
+//    MobieyeInst.GetObsFromMobieye(&gpsTrace,mobieye_distance,mobieye_speed,mobieye_ttc,mobieye_obsid,fveh_width);
+
+    //   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;
+    }
+
+    givlog->debug("obs_distance","obs: %f, lidar_obs: %f, Radar_obs: %f, lidar_obs_x: %f, lidar_obs_y: %f",
+                  ServiceCarStatus.mObs, ServiceCarStatus.mLidarObs,
+                  ServiceCarStatus.mRadarObs,obsPoint.x,lidarDistance);
+
+    //   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, gpsTraceAvoid, i,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, gpsTraceAvoid, i,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, gpsTraceAvoid, i,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);
+    //        }
+
+    //    }
+
+    for (int i =  0; i < roadSum; i++)
+    {
+        gpsTraceAvoid.clear();
+        //		gpsTraceAvoid = getGpsTrace(now_gps_ins, gmapsL[int(abs(roadWidth * 2)*(i - roadOri))], lastGpsIndex);
+     //   avoidX = (roadWidth)*(roadOri - i);
+         avoidX=computeAvoidX(i,roadOri,gpsMapLine[PathPoint],ServiceCarStatus.msysparam.vehWidth);
+        gpsTraceAvoid = getGpsTraceOffset(gpsTraceOri, avoidX);
+        //	computeObsOnRoad(lidarGridPtr, gpsTraceAvoid, roadNow + i);
+        computeObsOnRoad(lidarGridPtr, gpsTraceAvoid, i,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;
+             avoidX=computeAvoidX(roadNow+i,roadOri,gpsMapLine[PathPoint],ServiceCarStatus.msysparam.vehWidth);
+            if (checkAvoidEnable(avoidX, lidarGridPtr, roadNow+i))
+            {
+                /*if (roadNow==roadOri)
+                {
+                    avoidRunDistance = obsDisVector[roadNow] + ServiceCarStatus.msysparam.vehLenth;
+                    startAvoid_gps_ins = now_gps_ins;
+                }	*/
+                avoidMinDistanceVector[roadNow]= obsDisVector[roadNow] + ServiceCarStatus.msysparam.vehLenth;
+                startAvoidGpsInsVector[roadNow] = now_gps_ins;
+                roadPre = roadNow + i;
+                return roadPre;
+            }
+        }
+
+        if (roadNow - i >= 0)
+        {
+         //   avoidX = (roadOri - roadNow+i)*roadWidth;
+             avoidX=computeAvoidX(roadNow-i,roadOri,gpsMapLine[PathPoint],ServiceCarStatus.msysparam.vehWidth);
+            if (checkAvoidEnable(avoidX, lidarGridPtr, roadNow - i))
+            {
+                /*if (roadNow == roadOri)
+                {
+                    avoidRunDistance = obsDisVector[roadNow] + ServiceCarStatus.msysparam.vehLenth;
+                    startAvoid_gps_ins = now_gps_ins;
+                }*/
+                avoidMinDistanceVector[roadNow] = obsDisVector[roadNow] + ServiceCarStatus.msysparam.vehLenth;
+                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);
+    //        }
+
+    //    }
+
+
+
+    for (int i =  0; i <roadSum; i++)
+    {
+        gpsTraceBack.clear();
+        //	gpsTraceBack = getGpsTrace(now_gps_ins, gmapsR[int(abs(roadWidth * 2)*(roadOri-i))], lastGpsIndex);
+     //   avoidX = (roadWidth)*(roadOri - i);
+         avoidX=computeAvoidX(i,roadOri,gpsMapLine[PathPoint],ServiceCarStatus.msysparam.vehWidth);
+        gpsTraceBack = getGpsTraceOffset(gpsTraceOri, avoidX);
+        computeObsOnRoad(lidarGridPtr, gpsTraceBack, i,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 || gpsMapLine[var]->mode2==1000001){
+            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;
+}
+
+
+
+bool iv::decition::DecideGps00::adjuseultra(){
+    bool front=false,back=false,left=false,right=false;
+    for(int i=1;i<=13;i++)
+    {
+        if((i==2)||(i==3)||(i==4)||(i==5))   //front
+        {
+            if(ServiceCarStatus.ultraDistance[i]<100)
+            {
+                front=true;
+            }
+        }else if((i==1)||(i==12)||(i==6)||(i==7))   //left,right
+        {
+            if(ServiceCarStatus.ultraDistance[i]<30)
+            {
+                left=true;
+            }
+        }else if((i==8)||(i==9)||(i==10)||(i==11))   //back
+        {
+            if(ServiceCarStatus.ultraDistance[i]<10)
+            {
+                back=true;
+            }
+        }
+    }
+
+    if(front||left||back)
+        return true;
+    else
+        return false;
+
+}
+
+void iv::decition::DecideGps00::transferGpsMode2( const std::vector<GPSData> gpsMapLine){
+    if(  gpsMapLine[PathPoint]->mode2==3000){
+        if(obsDistance>5){
+            obsDistance=200;
+        }
+        dSpeed=min(dSpeed,5.0);
+    }
+}
+float iv::decition::DecideGps00::computeAvoidX(int roadAim,int roadOri,GPSData gps,float vehWidth){
+    if(roadAim==roadOri){
+        return 0;
+    }
+    float x=0;
+    float veh_to_roadSide=(gps->mfRoadWidth- ServiceCarStatus.msysparam.vehWidth)*0.5;
+    float roadSide_to_roadSide=ServiceCarStatus.msysparam.vehWidth;
+    if(!ServiceCarStatus.inRoadAvoid){
+        x= (roadOri-roadAim)*gps->mfRoadWidth;
+    }else{
+        int num=roadOri-roadAim;
+        switch (abs(num%3)) {
+        case 0:
+            x=(num/3)*gps->mfRoadWidth;
+            break;
+        case 1:
+            if(num>0){
+                x=(num/3)*gps->mfRoadWidth +veh_to_roadSide;
+            }else{
+                x=(num/3)*gps->mfRoadWidth -veh_to_roadSide;
+            }
+            break;
+        case 2:
+            if(num>0){
+                x=(num/3)*gps->mfRoadWidth +veh_to_roadSide+roadSide_to_roadSide;
+            }else{
+                x=(num/3)*gps->mfRoadWidth -veh_to_roadSide-roadSide_to_roadSide;
+            }
+
+            break;
+        default:
+            break;
+        }
+    }
+
+    return x;
+}

+ 261 - 0
src/decition/decition_brain/decition/decide_gps_00.h

@@ -0,0 +1,261 @@
+#pragma once
+#ifndef _IV_DECITION__DECIDE_GPS_00_
+#define _IV_DECITION__DECIDE_GPS_00_
+
+#include <common/gps_type.h>
+#include <decision/decition_type.h>
+#include <common/obstacle_type.h>
+#include <vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_planner/frenet_planner.h>
+#include <decision/adc_controller/pid_controller.h>
+#include <decision/adc_adapter/ge3_adapter.h>
+#include <decision/adc_adapter/qingyuan_adapter.h>
+#include <decision/adc_adapter/vv7_adapter.h>
+#include <decision/adc_adapter/zhongche_adapter.h>
+#include <decision/adc_adapter/bus_adapter.h>
+#include <decision/adc_adapter/hapo_adapter.h>
+#include <decision/adc_adapter/zhongche_adapter.h>
+#include <decision/adc_adapter/yuhesen_adapter.h>
+#include "perception/perceptionoutput.h"
+#include "ivlog.h"
+#include <memory>
+
+#include "obs_mobieye.h"
+
+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;
+    BaseAdapter *yuhesen_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;
+    std::shared_ptr<BaseAdapter> myuhesen_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);
+
+    float computeAvoidX(int roadAim,int roadOri,GPSData gps,float vehWidth);
+
+    bool adjuseultra();
+
+    iv::Station getNearestStation(iv::GPS_INS now_gps_ins,std::vector<Station> station_n,std::vector<GPSData> gpsMap);
+
+    void transferGpsMode2( const std::vector<GPSData> gpsMapLine);
+    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::TracePoint> planTrace;
+    bool roadNowStart=true;
+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 - 0
src/decition/decition_brain/decition/decide_line_00.h

@@ -0,0 +1,252 @@
+#pragma once
+#ifndef _IV_DECITION__DECIDE_LINE_00_
+#define _IV_DECITION__DECIDE_LINE_00_
+
+#include <common/gps_type.h>
+#include <decision/decition_type.h>
+#include <common/obstacle_type.h>
+#include <vector>
+#include <decision/gnss_coordinate_convert.h>
+#include <decision/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_
+
+

Some files were not shown because too many files changed in this diff