|
@@ -8,6 +8,9 @@ SideParkCalc::SideParkCalc(double x,double y,double hdg)
|
|
|
mx = x;
|
|
|
my = y;
|
|
|
mhdg = hdg;
|
|
|
+ normalhdg(mhdg);
|
|
|
+
|
|
|
+ mSideParkType = SideParkType::NoSolution;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -17,6 +20,12 @@ void SideParkCalc::CalcPark()
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
+ if(fabs(mhdg) > M_PI/6.0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
SideParkMode parkmode = CalcParkMode();
|
|
|
|
|
|
if(parkmode == SideParkMode::ParkAtRight)
|
|
@@ -93,6 +102,50 @@ void SideParkCalc::ParkAtRightCalc_Model1()
|
|
|
|
|
|
std::cout<<" compute. "<<std::endl;
|
|
|
|
|
|
+ if(dx1>(-0.1)&&(dx4>(-0.1)))
|
|
|
+ {
|
|
|
+ mSideParkType = SideParkType::FiveStep;
|
|
|
+ mvectorWheel.push_back(0.0);
|
|
|
+ mvectorWheel.push_back(mfMaxWheel * (-1.0));
|
|
|
+ mvectorWheel.push_back(0.0);
|
|
|
+ mvectorWheel.push_back(mfMaxWheel);
|
|
|
+ mvectorWheel.push_back(0.0);
|
|
|
+
|
|
|
+ double x1,x2,y1,y2,x3,y3,x4,y4,hdg1,hdg2,hdg3,hdg4,flen1,flen2,flen3,flen4,flen5;
|
|
|
+ x4 = dx6;y4 = dy6;hdg4 = 0;flen5 = x4;
|
|
|
+ x3 = x4 + dx5;y3 = y4 + dy5;hdg3 = fang;flen4 = fabs(fang) *mfRaidus;
|
|
|
+ hdg2 = hdg3;
|
|
|
+ if(dx4>0.1)
|
|
|
+ {
|
|
|
+ x2 = x3 + dx4;y2 = y3 + dy4;
|
|
|
+ flen3 = sqrt(pow(x2 - x3,2) + pow(y2 - y3,2));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ x2 = x3;y2 = y3;flen3 = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ flen2 = mfRaidus * (fang - mhdg);
|
|
|
+ x1 = mx - dx1;
|
|
|
+ y1 = my - dy1;
|
|
|
+ hdg1 = mhdg;
|
|
|
+
|
|
|
+ flen1 = sqrt(pow(dx1,2) + pow(dy1,2));
|
|
|
+
|
|
|
+ mvectorlen.push_back(flen1);
|
|
|
+ mvectorlen.push_back(flen2);
|
|
|
+ mvectorlen.push_back(flen3);
|
|
|
+ mvectorlen.push_back(flen4);
|
|
|
+ mvectorlen.push_back(flen5);
|
|
|
+ mfTotalLen = flen1 + flen2 + flen3 + flen4 + flen5;
|
|
|
+ mvectorpoint.push_back(iv::SideParkPoint(x1,y1,hdg1));
|
|
|
+ mvectorpoint.push_back(iv::SideParkPoint(x2,y2,hdg2));
|
|
|
+ mvectorpoint.push_back(iv::SideParkPoint(x3,y3,hdg3));
|
|
|
+ mvectorpoint.push_back(iv::SideParkPoint(x4,y4,hdg4));
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
// if((my+dy2) > (2*fMaxdy3) )
|
|
|
// {
|
|
@@ -145,7 +198,7 @@ void SideParkCalc::ParkAtRightCalc_Model2()
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- fang = acos(1.0 - (my+dy2)/(2.0*mfRaidus)) ;
|
|
|
+ fang = acos(1.0 - (my+dy2fix)/(2.0*mfRaidus)) ;
|
|
|
}
|
|
|
|
|
|
dx4 = mfRaidus * sin(fang);
|
|
@@ -168,6 +221,10 @@ void SideParkCalc::ParkAtRightCalc_Model2()
|
|
|
{
|
|
|
dx3 = dy3/k3;
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dx3 = 0;
|
|
|
+ }
|
|
|
|
|
|
if(fabs(mx - dx1 - dx2 -dx3 -dx4 - dx5) > 0.1)
|
|
|
{
|
|
@@ -191,12 +248,61 @@ void SideParkCalc::ParkAtRightCalc_Model2()
|
|
|
double Rx = mx - fR*sin(mhdg);
|
|
|
if((Rx>0.3) && (fR >= mfRaidus))
|
|
|
{
|
|
|
+ mSideParkType = SideParkType::TwoStep;
|
|
|
+ mvectorWheel.push_back(mfMaxWheel * mfRaidus/fR);
|
|
|
+ mvectorWheel.push_back(0.0);
|
|
|
+
|
|
|
+ double flen1,flen2;
|
|
|
+ flen2 = Rx;
|
|
|
+ flen1 = fR*fabs(mhdg);
|
|
|
+ mvectorlen.push_back(flen1);
|
|
|
+ mvectorlen.push_back(flen2);
|
|
|
+ mfTotalLen = flen1 + flen2;
|
|
|
+ mvectorpoint.push_back(iv::SideParkPoint(Rx,0,0));
|
|
|
std::cout<<" Have One Step soluton."<<std::endl;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ mSideParkType = SideParkType::FiveStep;
|
|
|
+ mvectorWheel.push_back(0.0);
|
|
|
+ mvectorWheel.push_back(mfMaxWheel * (-1.0));
|
|
|
+ mvectorWheel.push_back(0.0);
|
|
|
+ mvectorWheel.push_back(mfMaxWheel);
|
|
|
+ mvectorWheel.push_back(0.0);
|
|
|
+
|
|
|
+ double x1,x2,y1,y2,x3,y3,x4,y4,hdg1,hdg2,hdg3,hdg4,flen1,flen2,flen3,flen4,flen5;
|
|
|
+ x4 = dx5;y4 = dy5;hdg4 = 0;flen5 = x4;
|
|
|
+ x3 = x4 + dx4;y3 = y4 + dy4;hdg3 = fang;flen4 = fabs(fang) *mfRaidus;
|
|
|
+ hdg2 = hdg3;
|
|
|
+ if(dx3>0.1)
|
|
|
+ {
|
|
|
+ x2 = x3 + dx3;y2 = y3 + dy3;
|
|
|
+ flen3 = sqrt(pow(x2 - x3,2) + pow(y2 - y3,2));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ x2 = x3;y2 = y3;flen3 = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ flen2 = mfRaidus * (fang - mhdg);
|
|
|
+ x1 = mx - dx1;
|
|
|
+ y1 = my - dy1;
|
|
|
+ hdg1 = mhdg;
|
|
|
+
|
|
|
+ flen1 = sqrt(pow(dx1,2) + pow(dy1,2));
|
|
|
+
|
|
|
+ mvectorlen.push_back(flen1);
|
|
|
+ mvectorlen.push_back(flen2);
|
|
|
+ mvectorlen.push_back(flen3);
|
|
|
+ mvectorlen.push_back(flen4);
|
|
|
+ mvectorlen.push_back(flen5);
|
|
|
+ mfTotalLen = flen1 + flen2 + flen3 + flen4 + flen5;
|
|
|
+ mvectorpoint.push_back(iv::SideParkPoint(x1,y1,hdg1));
|
|
|
+ mvectorpoint.push_back(iv::SideParkPoint(x2,y2,hdg2));
|
|
|
+ mvectorpoint.push_back(iv::SideParkPoint(x3,y3,hdg3));
|
|
|
+ mvectorpoint.push_back(iv::SideParkPoint(x4,y4,hdg4));
|
|
|
std::cout<<" have compute."<<std::endl;
|
|
|
}
|
|
|
|
|
@@ -260,6 +366,50 @@ void SideParkCalc::ParkAtLeftCalc_Model1()
|
|
|
|
|
|
std::cout<<" compute. "<<std::endl;
|
|
|
|
|
|
+ if(dx1>(-0.1)&&(dx4>(-0.1)))
|
|
|
+ {
|
|
|
+ mSideParkType = SideParkType::FiveStep;
|
|
|
+ mvectorWheel.push_back(0.0);
|
|
|
+ mvectorWheel.push_back(mfMaxWheel * (1.0));
|
|
|
+ mvectorWheel.push_back(0.0);
|
|
|
+ mvectorWheel.push_back(mfMaxWheel * (-1.0));
|
|
|
+ mvectorWheel.push_back(0.0);
|
|
|
+
|
|
|
+ double x1,x2,y1,y2,x3,y3,x4,y4,hdg1,hdg2,hdg3,hdg4,flen1,flen2,flen3,flen4,flen5;
|
|
|
+ x4 = dx6;y4 = dy6;hdg4 = 0;flen5 = x4;
|
|
|
+ x3 = x4 + dx5;y3 = y4 - dy5;hdg3 = fang * (-1);flen4 = fabs(fang) *mfRaidus;
|
|
|
+ hdg2 = hdg3;
|
|
|
+ if(dx4>0.1)
|
|
|
+ {
|
|
|
+ x2 = x3 + dx4;y2 = y3 - dy4;
|
|
|
+ flen3 = sqrt(pow(x2 - x3,2) + pow(y2 - y3,2));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ x2 = x3;y2 = y3;flen3 = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ flen2 = mfRaidus * (mhdg + fang);
|
|
|
+ x1 = mx - dx1;
|
|
|
+ y1 = my + dy1;
|
|
|
+ hdg1 = mhdg;
|
|
|
+
|
|
|
+ flen1 = sqrt(pow(dx1,2) + pow(dy1,2));
|
|
|
+
|
|
|
+ mvectorlen.push_back(flen1);
|
|
|
+ mvectorlen.push_back(flen2);
|
|
|
+ mvectorlen.push_back(flen3);
|
|
|
+ mvectorlen.push_back(flen4);
|
|
|
+ mvectorlen.push_back(flen5);
|
|
|
+ mfTotalLen = flen1 + flen2 + flen3 + flen4 + flen5;
|
|
|
+ mvectorpoint.push_back(iv::SideParkPoint(x1,y1,hdg1));
|
|
|
+ mvectorpoint.push_back(iv::SideParkPoint(x2,y2,hdg2));
|
|
|
+ mvectorpoint.push_back(iv::SideParkPoint(x3,y3,hdg3));
|
|
|
+ mvectorpoint.push_back(iv::SideParkPoint(x4,y4,hdg4));
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|
|
@@ -283,7 +433,7 @@ void SideParkCalc::ParkAtLeftCalc_Model2()
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- fang = acos(1.0 - (y+dy2)/(2.0*mfRaidus)) ;
|
|
|
+ fang = acos(1.0 - (y+dy2fix)/(2.0*mfRaidus)) ;
|
|
|
}
|
|
|
|
|
|
dx4 = mfRaidus * sin(fang);
|
|
@@ -306,8 +456,12 @@ void SideParkCalc::ParkAtLeftCalc_Model2()
|
|
|
{
|
|
|
dx3 = dy3/k3;
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dx3 = 0;
|
|
|
+ }
|
|
|
|
|
|
- if(fabs(mx - dx1 - dx2 -dx3 -dx4 - dx5) > 0.1)
|
|
|
+ if(fabs(mx - dx1 - dx2 - dx3 -dx4 - dx5) > 0.1)
|
|
|
{
|
|
|
std::cout<<" no solve"<<std::endl;
|
|
|
return;
|
|
@@ -330,13 +484,83 @@ void SideParkCalc::ParkAtLeftCalc_Model2()
|
|
|
if((Rx>0.3) && (fR >= mfRaidus))
|
|
|
{
|
|
|
std::cout<<" Have One Step soluton."<<std::endl;
|
|
|
+
|
|
|
+ mSideParkType = SideParkType::TwoStep;
|
|
|
+ mvectorWheel.push_back(mfMaxWheel * mfRaidus/fR);
|
|
|
+ mvectorWheel.push_back(0.0);
|
|
|
+ double flen1,flen2;
|
|
|
+ flen2 = Rx;
|
|
|
+ flen1 = fR*fabs(mhdg);
|
|
|
+ mvectorlen.push_back(flen1);
|
|
|
+ mvectorlen.push_back(flen2);
|
|
|
+ mfTotalLen = flen1 + flen2;
|
|
|
+ mvectorpoint.push_back(iv::SideParkPoint(Rx,0,0));
|
|
|
+ std::cout<<" Have One Step soluton."<<std::endl;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ mSideParkType = SideParkType::FiveStep;
|
|
|
+ mvectorWheel.push_back(0.0);
|
|
|
+ mvectorWheel.push_back(mfMaxWheel * (1.0));
|
|
|
+ mvectorWheel.push_back(0.0);
|
|
|
+ mvectorWheel.push_back(mfMaxWheel *(-1.0));
|
|
|
+ mvectorWheel.push_back(0.0);
|
|
|
+
|
|
|
+ double x1,x2,y1,y2,x3,y3,x4,y4,hdg1,hdg2,hdg3,hdg4,flen1,flen2,flen3,flen4,flen5;
|
|
|
+ x4 = dx5;y4 = dy5 * (-1.0);hdg4 = 0;flen5 = x4;
|
|
|
+ x3 = x4 + dx4;y3 = y4 - dy4;hdg3 = fang * (-1.0);flen4 = fabs(fang) *mfRaidus;
|
|
|
+ hdg2 = hdg3;
|
|
|
+ if(dx3>0.1)
|
|
|
+ {
|
|
|
+ x2 = x3 + dx3;y2 = y3 - dy3;
|
|
|
+ flen3 = sqrt(pow(x2 - x3,2) + pow(y2 - y3,2));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ x2 = x3;y2 = y3;flen3 = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ flen2 = mfRaidus * (fang + mhdg);
|
|
|
+ x1 = mx - dx1;
|
|
|
+ y1 = my + dy1;
|
|
|
+ hdg1 = mhdg;
|
|
|
+
|
|
|
+ flen1 = sqrt(pow(dx1,2) + pow(dy1,2));
|
|
|
+
|
|
|
+ mvectorlen.push_back(flen1);
|
|
|
+ mvectorlen.push_back(flen2);
|
|
|
+ mvectorlen.push_back(flen3);
|
|
|
+ mvectorlen.push_back(flen4);
|
|
|
+ mvectorlen.push_back(flen5);
|
|
|
+ mfTotalLen = flen1 + flen2 + flen3 + flen4 + flen5;
|
|
|
+ mvectorpoint.push_back(iv::SideParkPoint(x1,y1,hdg1));
|
|
|
+ mvectorpoint.push_back(iv::SideParkPoint(x2,y2,hdg2));
|
|
|
+ mvectorpoint.push_back(iv::SideParkPoint(x3,y3,hdg3));
|
|
|
+ mvectorpoint.push_back(iv::SideParkPoint(x4,y4,hdg4));
|
|
|
std::cout<<" have compute."<<std::endl;
|
|
|
}
|
|
|
|
|
|
std::cout<<" compute. "<<std::endl;
|
|
|
}
|
|
|
+
|
|
|
+void SideParkCalc::normalhdg(double & fhdg)
|
|
|
+{
|
|
|
+ while(fhdg > M_PI)fhdg = fhdg - 2.0*M_PI;
|
|
|
+ while(fhdg <= (-M_PI))fhdg = fhdg + 2.0*M_PI;
|
|
|
+}
|
|
|
+
|
|
|
+SideParkType SideParkCalc::GetSolution(std::vector<iv::SideParkPoint> & xvectorpoint,std::vector<double> & xvectorWheel,std::vector<double> & xvectorlen,double & fTotalLen)
|
|
|
+{
|
|
|
+ if(mSideParkType == SideParkType::NoSolution)
|
|
|
+ {
|
|
|
+ return SideParkType::NoSolution;
|
|
|
+ }
|
|
|
+
|
|
|
+ xvectorpoint = mvectorpoint;
|
|
|
+ xvectorWheel = mvectorWheel;
|
|
|
+ xvectorlen = mvectorlen;
|
|
|
+ fTotalLen = mfTotalLen;
|
|
|
+ return mSideParkType;
|
|
|
+}
|