|
@@ -1,7 +1,10 @@
|
|
#include "ivpark_simple.h"
|
|
#include "ivpark_simple.h"
|
|
|
|
|
|
-#include "gps_type.h"
|
|
|
|
|
|
+
|
|
#include "adc_tools/compute_00.h"
|
|
#include "adc_tools/compute_00.h"
|
|
|
|
+#include "adc_tools/transfer.h"
|
|
|
|
+
|
|
|
|
+#include <chrono>
|
|
|
|
|
|
using namespace iv;
|
|
using namespace iv;
|
|
|
|
|
|
@@ -17,6 +20,7 @@ bool ivpark_simple::IsBocheEnable(double fLon, double fLat, double fHeading)
|
|
std::vector<double> xvectorRearDis;
|
|
std::vector<double> xvectorRearDis;
|
|
std::vector<double> xvectorAngle;
|
|
std::vector<double> xvectorAngle;
|
|
std::vector<int> xvectortype;
|
|
std::vector<int> xvectortype;
|
|
|
|
+ std::vector<GPS_INS> xvectoraimgps;
|
|
std::vector<iv::simpleparkspace> xvectorsimpleparkspace = GetParkSpace();
|
|
std::vector<iv::simpleparkspace> xvectorsimpleparkspace = GetParkSpace();
|
|
xvectordTPoint.clear();
|
|
xvectordTPoint.clear();
|
|
xvectorRearDis.clear();
|
|
xvectorRearDis.clear();
|
|
@@ -42,12 +46,20 @@ bool ivpark_simple::IsBocheEnable(double fLon, double fLat, double fHeading)
|
|
xvectordTPoint.push_back(TPoints);
|
|
xvectordTPoint.push_back(TPoints);
|
|
xvectorAngle.push_back(fAngle);
|
|
xvectorAngle.push_back(fAngle);
|
|
xvectorRearDis.push_back(fRearDis);
|
|
xvectorRearDis.push_back(fRearDis);
|
|
|
|
+ xvectoraimgps.push_back(aimgps);
|
|
xvectortype.push_back(1);
|
|
xvectortype.push_back(1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(xpark.mnParkType == 0)
|
|
if(xpark.mnParkType == 0)
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+ if(iv::decition::Compute00().bocheCompute(nowgps,aimgps,TPoints,fAngle,fRearDis) == 1)
|
|
|
|
+ {
|
|
|
|
+ xvectordTPoint.push_back(TPoints);
|
|
|
|
+ xvectorAngle.push_back(fAngle);
|
|
|
|
+ xvectorRearDis.push_back(fRearDis);
|
|
|
|
+ xvectoraimgps.push_back(aimgps);
|
|
|
|
+ xvectortype.push_back(0);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -91,6 +103,7 @@ bool ivpark_simple::IsBocheEnable(double fLon, double fLat, double fHeading)
|
|
iv::decition::Compute00().farTpoint = xvectordTPoint[nsel].at(1);
|
|
iv::decition::Compute00().farTpoint = xvectordTPoint[nsel].at(1);
|
|
iv::decition::Compute00().bocheAngle = xvectorAngle[nsel];
|
|
iv::decition::Compute00().bocheAngle = xvectorAngle[nsel];
|
|
iv::decition::Compute00().nParkType = 0;
|
|
iv::decition::Compute00().nParkType = 0;
|
|
|
|
+ maimgps = xvectoraimgps[nsel];
|
|
}
|
|
}
|
|
|
|
|
|
if(xvectortype[nsel] == 1)
|
|
if(xvectortype[nsel] == 1)
|
|
@@ -101,9 +114,265 @@ bool ivpark_simple::IsBocheEnable(double fLon, double fLat, double fHeading)
|
|
iv::decition::Compute00().dTpoint3 = xvectordTPoint[nsel].at(0);
|
|
iv::decition::Compute00().dTpoint3 = xvectordTPoint[nsel].at(0);
|
|
iv::decition::Compute00().bocheAngle = xvectorAngle[nsel];
|
|
iv::decition::Compute00().bocheAngle = xvectorAngle[nsel];
|
|
iv::decition::Compute00().nParkType = 1;
|
|
iv::decition::Compute00().nParkType = 1;
|
|
|
|
+ maimgps = xvectoraimgps[nsel];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ GaussProjCal(maimgps.gps_lng,maimgps.gps_lat,&maimgps.gps_x,&maimgps.gps_y);
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+int ivpark_simple::GetBocheDecision(double fLon,double fLat,double fHeading,double fSpeed,double & fAcc,double & fWheel,int & nshift,double & fdSpeed,double & fdSecSpeed,VehState & xvehstate,bool bbocheMode)
|
|
|
|
+{
|
|
|
|
+ if(bbocheMode == false)
|
|
|
|
+ {
|
|
|
|
+ return 0; //Not in boche mode
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static int64_t nstoptiming_ms = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
|
|
|
|
+
|
|
|
|
+ int64_t nstoptime_ms = 1000; //every stop time is 3
|
|
|
|
+
|
|
|
|
+ if(xvehstate!=dRever && xvehstate!=dRever0 && xvehstate!=dRever1 && xvehstate!=dRever2
|
|
|
|
+ && xvehstate!=dRever3 && xvehstate!=dRever4 && xvehstate!=reverseArr
|
|
|
|
+ && xvehstate!=reverseCar && xvehstate!=reversing && xvehstate!=reverseCircle && xvehstate!=reverseDirect)
|
|
|
|
+ {
|
|
|
|
+ if(fSpeed>0.3)
|
|
|
|
+ {
|
|
|
|
+ fdSpeed = 0;fdSecSpeed = fdSpeed/3.6;
|
|
|
|
+ fAcc = -0.5;
|
|
|
|
+ fWheel = 0.0;
|
|
|
|
+ nstoptiming_ms = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ fdSpeed = 0;fdSecSpeed = fdSpeed/3.6;
|
|
|
|
+ fAcc = -0.5;
|
|
|
|
+ fWheel = 0.0;
|
|
|
|
+ nshift = 2; //rear
|
|
|
|
+ int64_t nnow = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
|
|
|
|
+ if(abs(nnow - nstoptiming_ms) >= nstoptime_ms)
|
|
|
|
+ {
|
|
|
|
+ if(iv::decition::Compute00().nParkType == 0)
|
|
|
|
+ {
|
|
|
|
+ xvehstate = reversing;
|
|
|
|
+ mlastvehstate = xvehstate;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ xvehstate = dRever;
|
|
|
|
+ mlastvehstate = xvehstate;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ iv::GPS_INS nowgps;
|
|
|
|
+ nowgps.gps_lat = fLat;
|
|
|
|
+ nowgps.gps_lng = fLon;
|
|
|
|
+ GaussProjCal(nowgps.gps_lng,nowgps.gps_lat,&nowgps.gps_x,&nowgps.gps_y);
|
|
|
|
+
|
|
|
|
+ switch (xvehstate) {
|
|
|
|
+ case reversing:
|
|
|
|
+ reversingcarFun(nowgps,fSpeed,fAcc,fWheel,nshift,fdSpeed,fdSecSpeed,xvehstate);
|
|
|
|
+ break;
|
|
|
|
+ case reverseCircle:
|
|
|
|
+ reverseCircleFun(nowgps,fSpeed,fAcc,fWheel,nshift,fdSpeed,fdSecSpeed,xvehstate);
|
|
|
|
+ break;
|
|
|
|
+ case reverseDirect:
|
|
|
|
+ reverseDirectFun(nowgps,fSpeed,fAcc,fWheel,nshift,fdSpeed,fdSecSpeed,xvehstate);
|
|
|
|
+ break;
|
|
|
|
+ case reverseArr:
|
|
|
|
+ reverseArrFun(nowgps,fSpeed,fAcc,fWheel,nshift,fdSpeed,fdSecSpeed,xvehstate);
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void ivpark_simple::reversingcarFun(iv::GPS_INS nowgps,double fSpeed,double & fAcc,double & fWheel,int & nshift,double & fdSpeed,double & fdSecSpeed,VehState & xvehstate)
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ mlastvehstate = xvehstate;
|
|
|
|
+
|
|
|
|
+ double fdistonear = sqrt(pow(nowgps.gps_x - iv::decition::Compute00().nearTpoint.gps_x,2)+pow(nowgps.gps_y - iv::decition::Compute00().nearTpoint.gps_y,2));
|
|
|
|
+
|
|
|
|
+ Point2D pt = iv::decition::Coordinate_Transfer(nowgps.gps_x,nowgps.gps_y, maimgps);
|
|
|
|
+
|
|
|
|
+ Point2D ptnear = iv::decition::Coordinate_Transfer(iv::decition::Compute00().nearTpoint.gps_x,iv::decition::Compute00().nearTpoint.gps_y, maimgps);
|
|
|
|
+
|
|
|
|
+ fdistonear = fabs(pt.x - ptnear.x);
|
|
|
|
+
|
|
|
|
+ nshift = 2;
|
|
|
|
+ if(fdistonear>1.0)
|
|
|
|
+ {
|
|
|
|
+ fAcc = 0.0; //acc calcutale by pid
|
|
|
|
+ fWheel = 0.0;
|
|
|
|
+ fdSpeed = 2.0; fdSecSpeed = fdSpeed/3.6;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if((fSpeed>0.3)&&(fdistonear>0.3))
|
|
|
|
+ {
|
|
|
|
+ fAcc = (-1.0)*pow(fSpeed/3.6,2)/(2.0*fdistonear);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ fAcc = -0.5;
|
|
|
|
+ xvehstate = reverseCircle;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void ivpark_simple::reverseCircleFun(iv::GPS_INS nowgps,double fSpeed,double & fAcc,double & fWheel,int & nshift,double & fdSpeed,double & fdSecSpeed,VehState & xvehstate)
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ static int64_t nstoptiming_ms = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
|
|
|
|
+
|
|
|
|
+ int64_t nstoptime_ms = 1000; //every stop time is 3
|
|
|
|
+
|
|
|
|
+ if(mlastvehstate != xvehstate)
|
|
|
|
+ {
|
|
|
|
+ nstoptiming_ms = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ mlastvehstate = xvehstate;
|
|
|
|
+
|
|
|
|
+ int64_t nnow = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ nshift = 2;
|
|
|
|
+
|
|
|
|
+ if(abs(nnow - nstoptiming_ms) < nstoptime_ms) //stop 3s, change wheel when stop
|
|
|
|
+ {
|
|
|
|
+ fdSpeed = 0;
|
|
|
|
+ fdSecSpeed = 0;
|
|
|
|
+ fAcc = -0.5;
|
|
|
|
+ fWheel = iv::decition::Compute00().bocheAngle*16.5 *(-1.05);
|
|
|
|
+ mCircleWheel = fWheel;
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ fWheel = mCircleWheel;
|
|
|
|
+
|
|
|
|
+ Point2D pt = iv::decition::Coordinate_Transfer(nowgps.gps_x,nowgps.gps_y, maimgps);
|
|
|
|
+ double angdis =fabs(nowgps.ins_heading_angle - maimgps.ins_heading_angle);
|
|
|
|
+
|
|
|
|
+ if((fabs(pt.x)<2.0)&&(((angdis<5)||(angdis>355))))
|
|
|
|
+ {
|
|
|
|
+ xvehstate = reverseDirect;
|
|
|
|
+ fAcc = -0.5;
|
|
|
|
+ fdSpeed = 0.0;
|
|
|
|
+ fWheel = 0.0;
|
|
|
|
+ fdSecSpeed = 0.0;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ fAcc = 0.0;
|
|
|
|
+ fdSpeed = 2;
|
|
|
|
+ fdSecSpeed = fdSecSpeed / 3.6;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void ivpark_simple::reverseDirectFun(iv::GPS_INS nowgps,double fSpeed,double & fAcc,double & fWheel,int & nshift,double & fdSpeed,double & fdSecSpeed,VehState & xvehstate)
|
|
|
|
+{
|
|
|
|
+ static int64_t nstoptiming_ms = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
|
|
|
|
+
|
|
|
|
+ int64_t nstoptime_ms = 1000; //every stop time is 3
|
|
|
|
+
|
|
|
|
+ if(mlastvehstate != xvehstate)
|
|
|
|
+ {
|
|
|
|
+ nstoptiming_ms = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ mlastvehstate = xvehstate;
|
|
|
|
+
|
|
|
|
+ int64_t nnow = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ nshift = 2;
|
|
|
|
+
|
|
|
|
+ if(abs(nnow - nstoptiming_ms) < nstoptime_ms) //stop 3s, change wheel when stop
|
|
|
|
+ {
|
|
|
|
+ fdSpeed = 0;
|
|
|
|
+ fdSecSpeed = 0;
|
|
|
|
+ fAcc = -0.5;
|
|
|
|
+ fWheel = 0.0;
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Point2D pt = iv::decition::Coordinate_Transfer(nowgps.gps_x,nowgps.gps_y, maimgps);
|
|
|
|
+
|
|
|
|
+ if(pt.y<0.5)
|
|
|
|
+ {
|
|
|
|
+ xvehstate = reverseArr;
|
|
|
|
+ fAcc = -0.5;
|
|
|
|
+ fdSpeed = 0.0;
|
|
|
|
+ fWheel = 0.0;
|
|
|
|
+ fdSecSpeed = 0.0;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ fAcc = 0.0;
|
|
|
|
+ fdSpeed = 2;
|
|
|
|
+ fdSecSpeed = fdSecSpeed / 3.6;
|
|
|
|
+ fWheel = 0.0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void ivpark_simple::reverseArrFun(iv::GPS_INS nowgps,double fSpeed,double & fAcc,double & fWheel,int & nshift,double & fdSpeed,double & fdSecSpeed,VehState & xvehstate)
|
|
|
|
+{
|
|
|
|
+ static int64_t nstoptiming_ms = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
|
|
|
|
+
|
|
|
|
+ int64_t nstoptime_ms = 1000; //every stop time is 3
|
|
|
|
+
|
|
|
|
+ if(mlastvehstate != xvehstate)
|
|
|
|
+ {
|
|
|
|
+ nstoptiming_ms = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ mlastvehstate = xvehstate;
|
|
|
|
+
|
|
|
|
+ int64_t nnow = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ nshift = 2;
|
|
|
|
+
|
|
|
|
+ if(abs(nnow - nstoptiming_ms) < nstoptime_ms) //stop 3s, change wheel when stop
|
|
|
|
+ {
|
|
|
|
+ fdSpeed = 0;
|
|
|
|
+ fdSecSpeed = 0;
|
|
|
|
+ fAcc = -0.5;
|
|
|
|
+ fWheel = 0.0;
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ nshift = 1; //P shift
|
|
|
|
+
|
|
|
|
+ fdSpeed = 0;
|
|
|
|
+ fdSecSpeed = 0;
|
|
|
|
+ fAcc = -0.5;
|
|
|
|
+ fWheel = 0.0;
|
|
|
|
+
|
|
|
|
+ xvehstate = reverseComplete;
|
|
|
|
+}
|