|
@@ -123,9 +123,16 @@ bool ivpark_simple::IsBocheEnable(double fLon, double fLat, double fHeading)
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+double ivpark_simple::GetDistance(iv::GPS_INS p1,iv::GPS_INS p2)
|
|
|
+{
|
|
|
+ return sqrt(pow(p1.gps_x - p2.gps_x,2)+pow(p1.gps_y-p2.gps_y,2));
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
|
|
|
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)
|
|
|
{
|
|
|
+ (void)fHeading;
|
|
|
if(bbocheMode == false)
|
|
|
{
|
|
|
return 0; //Not in boche mode
|
|
@@ -195,6 +202,8 @@ int ivpark_simple::GetBocheDecision(double fLon,double fLat,double fHeading,doub
|
|
|
|
|
|
}
|
|
|
|
|
|
+ return 0;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
void ivpark_simple::reversingcarFun(iv::GPS_INS nowgps,double fSpeed,double & fAcc,double & fWheel,int & nshift,double & fdSpeed,double & fdSecSpeed,VehState & xvehstate)
|
|
@@ -239,9 +248,10 @@ void ivpark_simple::reversingcarFun(iv::GPS_INS nowgps,double fSpeed,double & fA
|
|
|
void ivpark_simple::reverseCircleFun(iv::GPS_INS nowgps,double fSpeed,double & fAcc,double & fWheel,int & nshift,double & fdSpeed,double & fdSecSpeed,VehState & xvehstate)
|
|
|
{
|
|
|
|
|
|
+ (void)fSpeed;
|
|
|
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
|
|
|
+ int64_t nstoptime_ms = 3000; //every stop time is 3
|
|
|
|
|
|
if(mlastvehstate != xvehstate)
|
|
|
{
|
|
@@ -292,9 +302,10 @@ void ivpark_simple::reverseCircleFun(iv::GPS_INS nowgps,double fSpeed,double & f
|
|
|
|
|
|
void ivpark_simple::reverseDirectFun(iv::GPS_INS nowgps,double fSpeed,double & fAcc,double & fWheel,int & nshift,double & fdSpeed,double & fdSecSpeed,VehState & xvehstate)
|
|
|
{
|
|
|
+ (void)fSpeed;
|
|
|
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
|
|
|
+ int64_t nstoptime_ms = 3000; //every stop time is 3
|
|
|
|
|
|
if(mlastvehstate != xvehstate)
|
|
|
{
|
|
@@ -341,9 +352,11 @@ void ivpark_simple::reverseDirectFun(iv::GPS_INS nowgps,double fSpeed,double & f
|
|
|
|
|
|
void ivpark_simple::reverseArrFun(iv::GPS_INS nowgps,double fSpeed,double & fAcc,double & fWheel,int & nshift,double & fdSpeed,double & fdSecSpeed,VehState & xvehstate)
|
|
|
{
|
|
|
+ (void)nowgps;
|
|
|
+ (void)fSpeed;
|
|
|
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
|
|
|
+ int64_t nstoptime_ms = 3000; //every stop time is 3
|
|
|
|
|
|
if(mlastvehstate != xvehstate)
|
|
|
{
|
|
@@ -374,5 +387,228 @@ void ivpark_simple::reverseArrFun(iv::GPS_INS nowgps,double fSpeed,double & fAcc
|
|
|
fAcc = -0.5;
|
|
|
fWheel = 0.0;
|
|
|
|
|
|
- xvehstate = reverseComplete;
|
|
|
+ xvehstate = normalRun;
|
|
|
}
|
|
|
+
|
|
|
+void ivpark_simple::dRever0Fun(iv::GPS_INS nowgps,double fSpeed,double & fAcc,double & fWheel,int & nshift,double & fdSpeed,double & fdSecSpeed,VehState & xvehstate)
|
|
|
+{
|
|
|
+
|
|
|
+ mlastvehstate = xvehstate;
|
|
|
+
|
|
|
+ Point2D pt = iv::decition::Coordinate_Transfer(nowgps.gps_x,nowgps.gps_y, maimgps);
|
|
|
+
|
|
|
+ Point2D ptnear = iv::decition::Coordinate_Transfer(iv::decition::Compute00().dTpoint1.gps_x,iv::decition::Compute00().dTpoint1.gps_y, maimgps);
|
|
|
+
|
|
|
+ double fdistonear = fabs(pt.y - ptnear.y);
|
|
|
+
|
|
|
+ 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);
|
|
|
+ fdSpeed = 0.0;
|
|
|
+ fdSecSpeed = fdSpeed/3.6;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ fAcc = -0.5;
|
|
|
+ xvehstate = dRever2;
|
|
|
+ fdSpeed = 0.0;
|
|
|
+ fdSecSpeed = fdSpeed/3.6;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+void ivpark_simple::dRever1Fun(iv::GPS_INS nowgps,double fSpeed,double & fAcc,double & fWheel,int & nshift,double & fdSpeed,double & fdSecSpeed,VehState & xvehstate)
|
|
|
+{
|
|
|
+ (void)fSpeed;
|
|
|
+ static int64_t nstoptiming_ms = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
|
|
|
+
|
|
|
+ int64_t nstoptime_ms = 3000; //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.0);
|
|
|
+ mCircleWheel = fWheel;
|
|
|
+ return;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ Point2D pt1 = iv::decition::Coordinate_Transfer(nowgps.gps_x,nowgps.gps_y, maimgps);
|
|
|
+ Point2D pt2 = iv::decition::Coordinate_Transfer(iv::decition::Compute00().dTpoint1.gps_x,iv::decition::Compute00().dTpoint1.gps_y, maimgps);
|
|
|
+
|
|
|
+ double fdis = fabs(pt1.x - pt2.x);
|
|
|
+
|
|
|
+ if(fdis>1.0)
|
|
|
+ {
|
|
|
+ fAcc = 0.0; //acc calcutale by pid
|
|
|
+
|
|
|
+ fdSpeed = 2.0; fdSecSpeed = fdSpeed/3.6;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if((fSpeed>0.3)&&(fdis>0.3))
|
|
|
+ {
|
|
|
+ fAcc = (-1.0)*pow(fSpeed/3.6,2)/(2.0*fdis);
|
|
|
+ fdSpeed = 0.0;
|
|
|
+ fdSecSpeed = fdSpeed/3.6;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ fAcc = -0.5;
|
|
|
+ fdSpeed = 0.0;
|
|
|
+ fdSecSpeed = fdSpeed/3.6;
|
|
|
+ xvehstate = dRever2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fWheel = mCircleWheel;
|
|
|
+}
|
|
|
+
|
|
|
+void ivpark_simple::dRever2Fun(iv::GPS_INS nowgps,double fSpeed,double & fAcc,double & fWheel,int & nshift,double & fdSpeed,double & fdSecSpeed,VehState & xvehstate)
|
|
|
+{
|
|
|
+ (void)fSpeed;
|
|
|
+ static int64_t nstoptiming_ms = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
|
|
|
+
|
|
|
+ int64_t nstoptime_ms = 3000; //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;
|
|
|
+ return;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ Point2D pt1 = iv::decition::Coordinate_Transfer(nowgps.gps_x,nowgps.gps_y, maimgps);
|
|
|
+ Point2D pt2 = iv::decition::Coordinate_Transfer(iv::decition::Compute00().dTpoint2.gps_x,iv::decition::Compute00().dTpoint2.gps_y, maimgps);
|
|
|
+
|
|
|
+ double fdis = pt1.x - pt2.x;
|
|
|
+
|
|
|
+ if(fdis>-1.0)
|
|
|
+ {
|
|
|
+ fAcc = 0.0; //acc calcutale by pid
|
|
|
+
|
|
|
+ fdSpeed = 2.0; fdSecSpeed = fdSpeed/3.6;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if((fSpeed>0.3)&&(fabs(fdis)>0.3))
|
|
|
+ {
|
|
|
+ fAcc = (-1.0)*pow(fSpeed/3.6,2)/(2.0*fabs(fdis));
|
|
|
+ fdSpeed = 0.0;
|
|
|
+ fdSecSpeed = fdSpeed/3.6;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ fAcc = -0.5;
|
|
|
+ fdSpeed = 0.0;
|
|
|
+ fdSecSpeed = fdSpeed/3.6;
|
|
|
+ xvehstate = dRever3;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fWheel = 0;
|
|
|
+}
|
|
|
+
|
|
|
+void ivpark_simple::dRever3Fun(iv::GPS_INS nowgps,double fSpeed,double & fAcc,double & fWheel,int & nshift,double & fdSpeed,double & fdSecSpeed,VehState & xvehstate)
|
|
|
+{
|
|
|
+ (void)fSpeed;
|
|
|
+ static int64_t nstoptiming_ms = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
|
|
|
+
|
|
|
+ int64_t nstoptime_ms = 3000; //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.0;
|
|
|
+ mCircleWheel = fWheel;
|
|
|
+ return;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ Point2D pt1 = iv::decition::Coordinate_Transfer(nowgps.gps_x,nowgps.gps_y, maimgps);
|
|
|
+ Point2D pt2 = iv::decition::Coordinate_Transfer(iv::decition::Compute00().dTpoint3.gps_x,iv::decition::Compute00().dTpoint3.gps_y, maimgps);
|
|
|
+
|
|
|
+ double fdis = fabs(pt1.x - pt2.x);
|
|
|
+
|
|
|
+ if(fdis>1.0)
|
|
|
+ {
|
|
|
+ fAcc = 0.0; //acc calcutale by pid
|
|
|
+
|
|
|
+ fdSpeed = 2.0; fdSecSpeed = fdSpeed/3.6;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if((fSpeed>0.3)&&(fabs(fdis)>0.3))
|
|
|
+ {
|
|
|
+ fAcc = (-1.0)*pow(fSpeed/3.6,2)/(2.0*fabs(fdis));
|
|
|
+ fdSpeed = 0.0;
|
|
|
+ fdSecSpeed = fdSpeed/3.6;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ fAcc = -0.5;
|
|
|
+ fdSpeed = 0.0;
|
|
|
+ fdSecSpeed = fdSpeed/3.6;
|
|
|
+ xvehstate = reverseDirect;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fWheel = mCircleWheel;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|