ivpark_simple.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #include "ivpark_simple.h"
  2. #include "gps_type.h"
  3. #include "adc_tools/compute_00.h"
  4. using namespace iv;
  5. ivpark_simple::ivpark_simple()
  6. {
  7. }
  8. bool ivpark_simple::IsBocheEnable(double fLon, double fLat, double fHeading)
  9. {
  10. GPS_INS nowgps,aimgps;
  11. std::vector<std::vector<GPS_INS>> xvectordTPoint;
  12. std::vector<double> xvectorRearDis;
  13. std::vector<double> xvectorAngle;
  14. std::vector<int> xvectortype;
  15. std::vector<iv::simpleparkspace> xvectorsimpleparkspace = GetParkSpace();
  16. xvectordTPoint.clear();
  17. xvectorRearDis.clear();
  18. xvectorAngle.clear();
  19. unsigned int i;
  20. unsigned int nsize = static_cast<unsigned int >(xvectorsimpleparkspace.size());
  21. nowgps.gps_lat = fLat;
  22. nowgps.gps_lng = fLon;
  23. nowgps.ins_heading_angle = fHeading;
  24. for(i=0;i<nsize;i++)
  25. {
  26. iv::simpleparkspace xpark = xvectorsimpleparkspace[i];
  27. iv::GPS_INS aimgps;
  28. aimgps.gps_lat = xpark.mfLat;
  29. aimgps.gps_lng = xpark.mfLon;
  30. aimgps.ins_heading_angle = xpark.mfHeading;
  31. std::vector<GPS_INS> TPoints;
  32. double fRearDis,fAngle;
  33. if(xpark.mnParkType == 1) //side park
  34. {
  35. if(iv::decition::Compute00().bocheDirectCompute(nowgps,aimgps,TPoints,fAngle,fRearDis) == 1)
  36. {
  37. xvectordTPoint.push_back(TPoints);
  38. xvectorAngle.push_back(fAngle);
  39. xvectorRearDis.push_back(fRearDis);
  40. xvectortype.push_back(1);
  41. }
  42. }
  43. if(xpark.mnParkType == 0)
  44. {
  45. }
  46. }
  47. nsize = static_cast<unsigned int >(xvectordTPoint.size());
  48. if(nsize<1)
  49. {
  50. return false;
  51. }
  52. unsigned int nsel = 0;
  53. //Select rear dis >1.0 and small
  54. for(i =1;i<nsize;i++)
  55. {
  56. if((xvectorRearDis[i] < xvectorRearDis[nsel])&&(xvectorRearDis[i]>1.0))
  57. {
  58. nsel = i;
  59. }
  60. else
  61. {
  62. if(xvectorRearDis[i]<1.0)
  63. {
  64. if(xvectorRearDis[nsel]>5.0)
  65. {
  66. nsel = i;
  67. }
  68. }
  69. else
  70. {
  71. if((xvectorRearDis[i]<3.0)&&(xvectorRearDis[nsel]<0.5))
  72. {
  73. nsel = i;
  74. }
  75. }
  76. }
  77. }
  78. if(xvectortype[nsel] == 0)
  79. {
  80. iv::decition::Compute00().nearTpoint = xvectordTPoint[nsel].at(0);
  81. iv::decition::Compute00().farTpoint = xvectordTPoint[nsel].at(1);
  82. iv::decition::Compute00().bocheAngle = xvectorAngle[nsel];
  83. iv::decition::Compute00().nParkType = 0;
  84. }
  85. if(xvectortype[nsel] == 1)
  86. {
  87. iv::decition::Compute00().dTpoint0 = xvectordTPoint[nsel].at(0);
  88. iv::decition::Compute00().dTpoint1 = xvectordTPoint[nsel].at(0);
  89. iv::decition::Compute00().dTpoint2 = xvectordTPoint[nsel].at(0);
  90. iv::decition::Compute00().dTpoint3 = xvectordTPoint[nsel].at(0);
  91. iv::decition::Compute00().bocheAngle = xvectorAngle[nsel];
  92. iv::decition::Compute00().nParkType = 1;
  93. }
  94. return true;
  95. }