|
@@ -571,12 +571,13 @@ static double GetPoly3Dis(GeometryPoly3 * ppoly,double xnow,double ynow,double &
|
|
* @retval if == 0 successfull <0 fail.
|
|
* @retval if == 0 successfull <0 fail.
|
|
**/
|
|
**/
|
|
int GetNearPoint(const double x,const double y,OpenDrive * pxodr,Road ** pObjRoad,GeometryBlock ** pgeo, double & s,double & nearx,
|
|
int GetNearPoint(const double x,const double y,OpenDrive * pxodr,Road ** pObjRoad,GeometryBlock ** pgeo, double & s,double & nearx,
|
|
- double & neary,double & nearhead,const double nearthresh)
|
|
|
|
|
|
+ double & neary,double & nearhead,const double nearthresh,double &froads)
|
|
{
|
|
{
|
|
|
|
|
|
double dismin = std::numeric_limits<double>::infinity();
|
|
double dismin = std::numeric_limits<double>::infinity();
|
|
s = dismin;
|
|
s = dismin;
|
|
int i;
|
|
int i;
|
|
|
|
+ double frels;
|
|
for(i=0;i<pxodr->GetRoadCount();i++)
|
|
for(i=0;i<pxodr->GetRoadCount();i++)
|
|
{
|
|
{
|
|
int j;
|
|
int j;
|
|
@@ -592,20 +593,21 @@ int GetNearPoint(const double x,const double y,OpenDrive * pxodr,Road ** pObjRoa
|
|
|
|
|
|
switch (pg->GetGeomType()) {
|
|
switch (pg->GetGeomType()) {
|
|
case 0: //line
|
|
case 0: //line
|
|
- dis = GetLineDis((GeometryLine *) pg,x,y,nx,ny,nh);
|
|
|
|
|
|
+ dis = xodrfunc::GetLineDis((GeometryLine *) pg,x,y,nx,ny,nh,frels);
|
|
|
|
+ // dis = GetLineDis((GeometryLine *) pg,x,y,nx,ny,nh);
|
|
break;
|
|
break;
|
|
case 1:
|
|
case 1:
|
|
- dis = GetSpiralDis((GeometrySpiral *)pg,x,y,nx,ny,nh);
|
|
|
|
|
|
+ dis = xodrfunc::GetSpiralDis((GeometrySpiral *)pg,x,y,nx,ny,nh,frels);
|
|
break;
|
|
break;
|
|
case 2: //arc
|
|
case 2: //arc
|
|
- dis = GetArcDis((GeometryArc *)pg,x,y,nx,ny,nh);
|
|
|
|
|
|
+ dis = xodrfunc::GetArcDis((GeometryArc *)pg,x,y,nx,ny,nh,frels);
|
|
break;
|
|
break;
|
|
|
|
|
|
case 3:
|
|
case 3:
|
|
- dis = GetPoly3Dis((GeometryPoly3 *)pg,x,y,nx,ny,nh);
|
|
|
|
|
|
+ dis = xodrfunc::GetPoly3Dis((GeometryPoly3 *)pg,x,y,nx,ny,nh,frels);
|
|
break;
|
|
break;
|
|
case 4:
|
|
case 4:
|
|
- dis = GetParamPoly3Dis((GeometryParamPoly3 *)pg,x,y,nx,ny,nh);
|
|
|
|
|
|
+ dis = xodrfunc::GetParamPoly3Dis((GeometryParamPoly3 *)pg,x,y,nx,ny,nh,frels);
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
dis = 100000.0;
|
|
dis = 100000.0;
|
|
@@ -619,6 +621,7 @@ int GetNearPoint(const double x,const double y,OpenDrive * pxodr,Road ** pObjRoa
|
|
neary = ny;
|
|
neary = ny;
|
|
nearhead = nh;
|
|
nearhead = nh;
|
|
s = dis;
|
|
s = dis;
|
|
|
|
+ froads = frels;
|
|
*pObjRoad = proad;
|
|
*pObjRoad = proad;
|
|
*pgeo = pgb;
|
|
*pgeo = pgb;
|
|
}
|
|
}
|
|
@@ -688,12 +691,13 @@ int GetNearPoint(const double x,const double y,OpenDrive * pxodr,Road ** pObjRoa
|
|
|
|
|
|
|
|
|
|
int GetNearPointWithHead(const double x,const double y,const double hdg,OpenDrive * pxodr,Road ** pObjRoad,GeometryBlock ** pgeo, double & s,double & nearx,
|
|
int GetNearPointWithHead(const double x,const double y,const double hdg,OpenDrive * pxodr,Road ** pObjRoad,GeometryBlock ** pgeo, double & s,double & nearx,
|
|
- double & neary,double & nearhead,const double nearthresh)
|
|
|
|
|
|
+ double & neary,double & nearhead,const double nearthresh,double &froads)
|
|
{
|
|
{
|
|
|
|
|
|
double dismin = std::numeric_limits<double>::infinity();
|
|
double dismin = std::numeric_limits<double>::infinity();
|
|
s = dismin;
|
|
s = dismin;
|
|
int i;
|
|
int i;
|
|
|
|
+ double frels;
|
|
std::vector<Road * > xvectorroad;
|
|
std::vector<Road * > xvectorroad;
|
|
std::vector<double > xvectordismin;
|
|
std::vector<double > xvectordismin;
|
|
std::vector<double > xvecotrnearx;
|
|
std::vector<double > xvecotrnearx;
|
|
@@ -701,6 +705,7 @@ int GetNearPointWithHead(const double x,const double y,const double hdg,OpenDriv
|
|
std::vector<double > xvectornearhead;
|
|
std::vector<double > xvectornearhead;
|
|
std::vector<double > xvectors;
|
|
std::vector<double > xvectors;
|
|
std::vector<GeometryBlock *> xvectorgeob;
|
|
std::vector<GeometryBlock *> xvectorgeob;
|
|
|
|
+ std::vector<double > xvectorfrels;
|
|
double VECTORTHRESH = 5;
|
|
double VECTORTHRESH = 5;
|
|
for(i=0;i<pxodr->GetRoadCount();i++)
|
|
for(i=0;i<pxodr->GetRoadCount();i++)
|
|
{
|
|
{
|
|
@@ -715,6 +720,7 @@ int GetNearPointWithHead(const double x,const double y,const double hdg,OpenDriv
|
|
double localneary = 0;
|
|
double localneary = 0;
|
|
double localnearhead = 0;
|
|
double localnearhead = 0;
|
|
double locals = 0;
|
|
double locals = 0;
|
|
|
|
+ double localfrels = 0;
|
|
GeometryBlock * pgeolocal;
|
|
GeometryBlock * pgeolocal;
|
|
|
|
|
|
for(j=0;j<proad->GetGeometryBlockCount();j++)
|
|
for(j=0;j<proad->GetGeometryBlockCount();j++)
|
|
@@ -726,20 +732,20 @@ int GetNearPointWithHead(const double x,const double y,const double hdg,OpenDriv
|
|
|
|
|
|
switch (pg->GetGeomType()) {
|
|
switch (pg->GetGeomType()) {
|
|
case 0: //line
|
|
case 0: //line
|
|
- dis = GetLineDis((GeometryLine *) pg,x,y,nx,ny,nh);
|
|
|
|
|
|
+ dis = xodrfunc::GetLineDis((GeometryLine *) pg,x,y,nx,ny,nh,frels);
|
|
break;
|
|
break;
|
|
case 1:
|
|
case 1:
|
|
- dis = GetSpiralDis((GeometrySpiral *)pg,x,y,nx,ny,nh);
|
|
|
|
|
|
+ dis = xodrfunc::GetSpiralDis((GeometrySpiral *)pg,x,y,nx,ny,nh,frels);
|
|
break;
|
|
break;
|
|
case 2: //arc
|
|
case 2: //arc
|
|
- dis = GetArcDis((GeometryArc *)pg,x,y,nx,ny,nh);
|
|
|
|
|
|
+ dis = xodrfunc::GetArcDis((GeometryArc *)pg,x,y,nx,ny,nh,frels);
|
|
break;
|
|
break;
|
|
|
|
|
|
case 3:
|
|
case 3:
|
|
- dis = 100000.0;
|
|
|
|
|
|
+ dis = xodrfunc::GetPoly3Dis((GeometryPoly3 *)pg,x,y,nx,ny,nh,frels);
|
|
break;
|
|
break;
|
|
case 4:
|
|
case 4:
|
|
- dis = GetParamPoly3Dis((GeometryParamPoly3 *)pg,x,y,nx,ny,nh);
|
|
|
|
|
|
+ dis = xodrfunc::GetParamPoly3Dis((GeometryParamPoly3 *)pg,x,y,nx,ny,nh,frels);
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
dis = 100000.0;
|
|
dis = 100000.0;
|
|
@@ -753,6 +759,7 @@ int GetNearPointWithHead(const double x,const double y,const double hdg,OpenDriv
|
|
neary = ny;
|
|
neary = ny;
|
|
nearhead = nh;
|
|
nearhead = nh;
|
|
s = dis;
|
|
s = dis;
|
|
|
|
+ froads = frels;
|
|
*pObjRoad = proad;
|
|
*pObjRoad = proad;
|
|
*pgeo = pgb;
|
|
*pgeo = pgb;
|
|
|
|
|
|
@@ -765,6 +772,7 @@ int GetNearPointWithHead(const double x,const double y,const double hdg,OpenDriv
|
|
localneary = ny;
|
|
localneary = ny;
|
|
localnearhead = nh;
|
|
localnearhead = nh;
|
|
locals = dis;
|
|
locals = dis;
|
|
|
|
+ localfrels = frels;
|
|
pgeolocal = pgb;
|
|
pgeolocal = pgb;
|
|
bchange = true;
|
|
bchange = true;
|
|
}
|
|
}
|
|
@@ -783,6 +791,7 @@ int GetNearPointWithHead(const double x,const double y,const double hdg,OpenDriv
|
|
xvectors.push_back(locals);
|
|
xvectors.push_back(locals);
|
|
xvectorgeob.push_back(pgeolocal);
|
|
xvectorgeob.push_back(pgeolocal);
|
|
xvectornearhead.push_back(localnearhead);
|
|
xvectornearhead.push_back(localnearhead);
|
|
|
|
+ xvectorfrels.push_back(localfrels);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -847,6 +856,7 @@ int GetNearPointWithHead(const double x,const double y,const double hdg,OpenDriv
|
|
neary = xvectorneary[i];
|
|
neary = xvectorneary[i];
|
|
nearhead = xvectornearhead[i];
|
|
nearhead = xvectornearhead[i];
|
|
s = xvectors[i];
|
|
s = xvectors[i];
|
|
|
|
+ froads = xvectorfrels[i];
|
|
*pObjRoad = xvectorroad[i];
|
|
*pObjRoad = xvectorroad[i];
|
|
*pgeo = xvectorgeob[i];
|
|
*pgeo = xvectorgeob[i];
|
|
bHaveSame = true;
|
|
bHaveSame = true;
|
|
@@ -1015,30 +1025,31 @@ static int SelectRoadLeftRight(Road * pRoad,const double head1,const double hea
|
|
//}
|
|
//}
|
|
|
|
|
|
|
|
|
|
-static std::vector<PlanPoint> getlinepoint(GeometryLine * pline)
|
|
|
|
|
|
+static std::vector<PlanPoint> getlinepoint(GeometryLine * pline,const double fspace = 0.1)
|
|
{
|
|
{
|
|
std::vector<PlanPoint> xvectorPP;
|
|
std::vector<PlanPoint> xvectorPP;
|
|
int i;
|
|
int i;
|
|
double s = pline->GetLength();
|
|
double s = pline->GetLength();
|
|
- int nsize = s/0.1;
|
|
|
|
|
|
+ int nsize = s/fspace;
|
|
|
|
+ if(nsize ==0)nsize = 1;
|
|
|
|
|
|
for(i=0;i<nsize;i++)
|
|
for(i=0;i<nsize;i++)
|
|
{
|
|
{
|
|
double x,y;
|
|
double x,y;
|
|
- x = pline->GetX() + i *0.1 * cos(pline->GetHdg());
|
|
|
|
- y = pline->GetY() + i *0.1 * sin(pline->GetHdg());
|
|
|
|
|
|
+ x = pline->GetX() + i *fspace * cos(pline->GetHdg());
|
|
|
|
+ y = pline->GetY() + i *fspace * sin(pline->GetHdg());
|
|
PlanPoint pp;
|
|
PlanPoint pp;
|
|
pp.x = x;
|
|
pp.x = x;
|
|
pp.y = y;
|
|
pp.y = y;
|
|
pp.dis = i*0.1;
|
|
pp.dis = i*0.1;
|
|
pp.hdg = pline->GetHdg();
|
|
pp.hdg = pline->GetHdg();
|
|
- pp.mS = pline->GetS() + i*0.1;
|
|
|
|
|
|
+ pp.mS = pline->GetS() + i*fspace;
|
|
xvectorPP.push_back(pp);
|
|
xvectorPP.push_back(pp);
|
|
}
|
|
}
|
|
return xvectorPP;
|
|
return xvectorPP;
|
|
}
|
|
}
|
|
|
|
|
|
-static std::vector<PlanPoint> getarcpoint(GeometryArc * parc)
|
|
|
|
|
|
+static std::vector<PlanPoint> getarcpoint(GeometryArc * parc,const double fspace = 0.1)
|
|
{
|
|
{
|
|
std::vector<PlanPoint> xvectorPP;
|
|
std::vector<PlanPoint> xvectorPP;
|
|
|
|
|
|
@@ -1051,9 +1062,9 @@ static std::vector<PlanPoint> getarcpoint(GeometryArc * parc)
|
|
double x_center = parc->GetX() + (1.0/parc->GetCurvature()) * cos(parc->GetHdg() + M_PI/2.0);
|
|
double x_center = parc->GetX() + (1.0/parc->GetCurvature()) * cos(parc->GetHdg() + M_PI/2.0);
|
|
double y_center = parc->GetY() + (1.0/parc->GetCurvature()) * sin(parc->GetHdg()+ M_PI/2.0);
|
|
double y_center = parc->GetY() + (1.0/parc->GetCurvature()) * sin(parc->GetHdg()+ M_PI/2.0);
|
|
|
|
|
|
- double arcdiff = 0.1/R;
|
|
|
|
- int nsize = parc->GetLength()/0.1;
|
|
|
|
-
|
|
|
|
|
|
+ double arcdiff = fspace/R;
|
|
|
|
+ int nsize = parc->GetLength()/fspace;
|
|
|
|
+ if(nsize == 0)nsize = 1;
|
|
int i;
|
|
int i;
|
|
for(i=0;i<nsize;i++)
|
|
for(i=0;i<nsize;i++)
|
|
{
|
|
{
|
|
@@ -1082,7 +1093,7 @@ static std::vector<PlanPoint> getarcpoint(GeometryArc * parc)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-static std::vector<PlanPoint> getspiralpoint(GeometrySpiral * pspiral)
|
|
|
|
|
|
+static std::vector<PlanPoint> getspiralpoint(GeometrySpiral * pspiral,const double fspace = 0.1)
|
|
{
|
|
{
|
|
|
|
|
|
double x,y,hdg;
|
|
double x,y,hdg;
|
|
@@ -1103,13 +1114,13 @@ static std::vector<PlanPoint> getspiralpoint(GeometrySpiral * pspiral)
|
|
pp.mS = pspiral->GetS() + s;
|
|
pp.mS = pspiral->GetS() + s;
|
|
xvectorPP.push_back(pp);
|
|
xvectorPP.push_back(pp);
|
|
|
|
|
|
- s = s+0.1;
|
|
|
|
|
|
+ s = s+fspace;
|
|
|
|
|
|
}
|
|
}
|
|
return xvectorPP;
|
|
return xvectorPP;
|
|
}
|
|
}
|
|
|
|
|
|
-static std::vector<PlanPoint> getpoly3dpoint(GeometryPoly3 * ppoly)
|
|
|
|
|
|
+static std::vector<PlanPoint> getpoly3dpoint(GeometryPoly3 * ppoly,const double fspace = 0.1)
|
|
{
|
|
{
|
|
double x,y;
|
|
double x,y;
|
|
x = ppoly->GetX();
|
|
x = ppoly->GetX();
|
|
@@ -1119,7 +1130,7 @@ static std::vector<PlanPoint> getpoly3dpoint(GeometryPoly3 * ppoly)
|
|
B = ppoly->GetB();
|
|
B = ppoly->GetB();
|
|
C = ppoly->GetC();
|
|
C = ppoly->GetC();
|
|
D = ppoly->GetD();
|
|
D = ppoly->GetD();
|
|
- const double steplim = 0.1;
|
|
|
|
|
|
+ const double steplim = fspace;
|
|
double du = steplim;
|
|
double du = steplim;
|
|
double u = 0;
|
|
double u = 0;
|
|
double v = 0;
|
|
double v = 0;
|
|
@@ -1139,6 +1150,7 @@ static std::vector<PlanPoint> getpoly3dpoint(GeometryPoly3 * ppoly)
|
|
pp.dis = 0;
|
|
pp.dis = 0;
|
|
pp.mS = ppoly->GetS();
|
|
pp.mS = ppoly->GetS();
|
|
xvectorPP.push_back(pp);
|
|
xvectorPP.push_back(pp);
|
|
|
|
+ u = du;
|
|
while(flen < ppoly->GetLength())
|
|
while(flen < ppoly->GetLength())
|
|
{
|
|
{
|
|
double fdis = 0;
|
|
double fdis = 0;
|
|
@@ -1168,7 +1180,7 @@ static std::vector<PlanPoint> getpoly3dpoint(GeometryPoly3 * ppoly)
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-static std::vector<PlanPoint> getparampoly3dpoint(GeometryParamPoly3 * parc)
|
|
|
|
|
|
+static std::vector<PlanPoint> getparampoly3dpoint(GeometryParamPoly3 * parc,const double fspace = 0.1)
|
|
{
|
|
{
|
|
double s = 0.1;
|
|
double s = 0.1;
|
|
std::vector<PlanPoint> xvectorPP;
|
|
std::vector<PlanPoint> xvectorPP;
|
|
@@ -1228,7 +1240,7 @@ static std::vector<PlanPoint> getparampoly3dpoint(GeometryParamPoly3 * parc)
|
|
|
|
|
|
/* if(disx > 0.1)s = s+ disx;
|
|
/* if(disx > 0.1)s = s+ disx;
|
|
else s = s+ 0.5*/;
|
|
else s = s+ 0.5*/;
|
|
- s = s+ 0.1;
|
|
|
|
|
|
+ s = s+ fspace;
|
|
|
|
|
|
// s = s+ sqrt(pow(x-xold,2)+ pow(y-yold,2));
|
|
// s = s+ sqrt(pow(x-xold,2)+ pow(y-yold,2));
|
|
xold = x;
|
|
xold = x;
|
|
@@ -1242,6 +1254,116 @@ static std::vector<PlanPoint> getparampoly3dpoint(GeometryParamPoly3 * parc)
|
|
return xvectorPP;
|
|
return xvectorPP;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+std::vector<PlanPoint> GetPoint(pathsection xpath,const double fspace = 0.1)
|
|
|
|
+{
|
|
|
|
+ Road * pRoad = xpath.mpRoad;
|
|
|
|
+ double s_start,s_end;
|
|
|
|
+ LaneSection * pLS = pRoad->GetLaneSection(xpath.msectionid);
|
|
|
|
+ s_start = pLS->GetS();
|
|
|
|
+ if(xpath.msectionid == (pRoad->GetLaneSectionCount()-1))s_end = pRoad->GetRoadLength();
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ s_end = pRoad->GetLaneSection(xpath.msectionid+1)->GetS();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ std::vector<PlanPoint> xvectorPPS;
|
|
|
|
+ double s = 0;
|
|
|
|
+
|
|
|
|
+ int i;
|
|
|
|
+ for(i=0;i<pRoad->GetGeometryBlockCount();i++)
|
|
|
|
+ {
|
|
|
|
+ GeometryBlock * pgb = pRoad->GetGeometryBlock(i);
|
|
|
|
+ RoadGeometry * prg = pgb->GetGeometryAt(0);
|
|
|
|
+ std::vector<PlanPoint> xvectorPP;
|
|
|
|
+ if(i<(pRoad->GetGeometryBlockCount() -0))
|
|
|
|
+ {
|
|
|
|
+ if(prg->GetS()>s_end)
|
|
|
|
+ {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if((prg->GetS() + prg->GetLength())<s_start)
|
|
|
|
+ {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ double s1 = prg->GetLength();
|
|
|
|
+ switch (prg->GetGeomType()) {
|
|
|
|
+ case 0:
|
|
|
|
+ xvectorPP = getlinepoint((GeometryLine *)prg,fspace);
|
|
|
|
+ break;
|
|
|
|
+ case 1:
|
|
|
|
+ xvectorPP = getspiralpoint((GeometrySpiral *)prg,fspace);
|
|
|
|
+ break;
|
|
|
|
+ case 2:
|
|
|
|
+ xvectorPP = getarcpoint((GeometryArc *)prg,fspace);
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
+ case 3:
|
|
|
|
+
|
|
|
|
+ xvectorPP = getpoly3dpoint((GeometryPoly3 *)prg,fspace);
|
|
|
|
+ break;
|
|
|
|
+ case 4:
|
|
|
|
+ xvectorPP = getparampoly3dpoint((GeometryParamPoly3 *)prg,fspace);
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ int j;
|
|
|
|
+ if(prg->GetS()<s_start)
|
|
|
|
+ {
|
|
|
|
+ s1 = prg->GetLength() -(s_start - prg->GetS());
|
|
|
|
+ }
|
|
|
|
+ if((prg->GetS() + prg->GetLength())>s_end)
|
|
|
|
+ {
|
|
|
|
+ s1 = s_end - prg->GetS();
|
|
|
|
+ }
|
|
|
|
+ for(j=0;j<xvectorPP.size();j++)
|
|
|
|
+ {
|
|
|
|
+ PlanPoint pp = xvectorPP.at(j);
|
|
|
|
+ if(((pp.dis+prg->GetS()) >= s_start) &&((pp.dis+prg->GetS()) <= s_end))
|
|
|
|
+ {
|
|
|
|
+ if(s_start > prg->GetS())
|
|
|
|
+ {
|
|
|
|
+ pp.dis = s + pp.dis -(s_start - prg->GetS());
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ pp.dis = s+ pp.dis;
|
|
|
|
+ }
|
|
|
|
+ pp.nRoadID = atoi(pRoad->GetRoadId().data());
|
|
|
|
+ xvectorPPS.push_back(pp);
|
|
|
|
+ }
|
|
|
|
+// if((prg->GetS()>s_start)&&((prg->GetS() + prg->GetLength())<s_end))
|
|
|
|
+// {
|
|
|
|
+// pp.dis = s + pp.dis;
|
|
|
|
+// pp.nRoadID = atoi(pRoad->GetRoadId().data());
|
|
|
|
+// xvectorPPS.push_back(pp);
|
|
|
|
+// }
|
|
|
|
+// else
|
|
|
|
+// {
|
|
|
|
+// if(prg->GetS()<s_start)
|
|
|
|
+// {
|
|
|
|
+
|
|
|
|
+// }
|
|
|
|
+// else
|
|
|
|
+// {
|
|
|
|
+// if(pp.dis<(s_end -prg->GetS()))
|
|
|
|
+// {
|
|
|
|
+// pp.dis = s + pp.dis;
|
|
|
|
+// pp.nRoadID = atoi(pRoad->GetRoadId().data());
|
|
|
|
+// xvectorPPS.push_back(pp);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+ }
|
|
|
|
+ s = s+ s1;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return xvectorPPS;
|
|
|
|
+}
|
|
|
|
+
|
|
std::vector<PlanPoint> GetPoint(Road * pRoad)
|
|
std::vector<PlanPoint> GetPoint(Road * pRoad)
|
|
{
|
|
{
|
|
std::vector<PlanPoint> xvectorPPS;
|
|
std::vector<PlanPoint> xvectorPPS;
|
|
@@ -1877,16 +1999,40 @@ std::vector<PlanPoint> GetLanePoint(pathsection xps,std::vector<PlanPoint> xvPP,
|
|
int i;
|
|
int i;
|
|
if(xps.mainsel < 0)
|
|
if(xps.mainsel < 0)
|
|
{
|
|
{
|
|
- for(i=0;i<(nchange1- nchangepoint/2);i++)
|
|
|
|
- {
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+ for(i=0;i<nsize;i++)
|
|
|
|
+ {
|
|
PlanPoint pp = xvPP.at(i);
|
|
PlanPoint pp = xvPP.at(i);
|
|
-// off1 = getoff(nlane1,pp.mS,xvectorLWA,xvectorindex1);
|
|
|
|
|
|
+ // off1 = getoff(nlane1,pp.mS,xvectorLWA,xvectorindex1);
|
|
|
|
|
|
- off1 = getoff(xps.mpRoad,nlane1,pp.mS);
|
|
|
|
|
|
+ off1 = getoff(xps.mpRoad,nlane2,pp.mS);
|
|
pp.x = pp.x + off1 *cos(pp.hdg + M_PI/2.0);
|
|
pp.x = pp.x + off1 *cos(pp.hdg + M_PI/2.0);
|
|
pp.y = pp.y + off1 *sin(pp.hdg + M_PI/2.0);
|
|
pp.y = pp.y + off1 *sin(pp.hdg + M_PI/2.0);
|
|
|
|
|
|
|
|
+ pp.nlrchange = 1;
|
|
|
|
+
|
|
|
|
+ if(xps.mainsel != xps.secondsel)
|
|
|
|
+ {
|
|
|
|
+ off1 = getoff(xps.mpRoad,xps.secondsel,pp.mS);
|
|
|
|
+ pp.mfSecx = pp.x + off1 *cos(pp.hdg + M_PI/2.0);
|
|
|
|
+ pp.mfSecy = pp.y + off1 *sin(pp.hdg + M_PI/2.0);
|
|
|
|
+
|
|
|
|
+ if(xps.mainsel >xps.secondsel)
|
|
|
|
+ {
|
|
|
|
+ pp.nlrchange = 1;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ pp.nlrchange = 2;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ pp.mfSecx = pp.x ;
|
|
|
|
+ pp.mfSecy = pp.y ;
|
|
|
|
+ }
|
|
|
|
+
|
|
pp.mWidth = getwidth(xps.mpRoad,nlane1,xvectorLWA,pp.mS);
|
|
pp.mWidth = getwidth(xps.mpRoad,nlane1,xvectorLWA,pp.mS);
|
|
pp.mfDisToLaneLeft = pp.mWidth/2.0;
|
|
pp.mfDisToLaneLeft = pp.mWidth/2.0;
|
|
pp.lanmp = 0;
|
|
pp.lanmp = 0;
|
|
@@ -1895,159 +2041,179 @@ std::vector<PlanPoint> GetLanePoint(pathsection xps,std::vector<PlanPoint> xvPP,
|
|
GetLaneOriTotal(xps.mpRoad,nlane1,pp.mS,pp.mnLaneori,pp.mnLaneTotal,pp.speed);
|
|
GetLaneOriTotal(xps.mpRoad,nlane1,pp.mS,pp.mnLaneori,pp.mnLaneTotal,pp.speed);
|
|
|
|
|
|
xvectorPP.push_back(pp);
|
|
xvectorPP.push_back(pp);
|
|
-
|
|
|
|
}
|
|
}
|
|
- for(i=(nchange1 - nchangepoint/2);i<(nchange1+nchangepoint/2);i++)
|
|
|
|
- {
|
|
|
|
|
|
|
|
- PlanPoint pp = xvPP.at(i);
|
|
|
|
-// off1 = getoff(nlane1,pp.mS,xvectorLWA,xvectorindex1);
|
|
|
|
-// off2 = getoff(nlane2,pp.mS,xvectorLWA,xvectorindex2);
|
|
|
|
- off1 = getoff(xps.mpRoad,nlane1,pp.mS);
|
|
|
|
- off2 = getoff(xps.mpRoad,nlane2,pp.mS);
|
|
|
|
- double offx = off1 + (off2 - off1) *(i-nchange1 + nchangepoint/2)/nchangepoint;
|
|
|
|
- pp.x = pp.x + offx *cos(pp.hdg + M_PI/2.0);
|
|
|
|
- pp.y = pp.y + offx *sin(pp.hdg + M_PI/2.0);
|
|
|
|
|
|
+// for(i=0;i<(nchange1- nchangepoint/2);i++)
|
|
|
|
+// {
|
|
|
|
|
|
- double flanewidth1 = getwidth(xps.mpRoad,nlane1,xvectorLWA,pp.mS);
|
|
|
|
|
|
+// PlanPoint pp = xvPP.at(i);
|
|
|
|
+//// off1 = getoff(nlane1,pp.mS,xvectorLWA,xvectorindex1);
|
|
|
|
|
|
- pp.mfDisToRoadLeft = offx*(-1);
|
|
|
|
- pp.mfRoadWidth = GetRoadWidth(xvectorLWA,nlane1,pp.mS);
|
|
|
|
- if(nlane1 == nlane2)
|
|
|
|
- {
|
|
|
|
- pp.mWidth = flanewidth1;
|
|
|
|
- pp.mfDisToLaneLeft = pp.mWidth/2.0;
|
|
|
|
- pp.lanmp = 0;
|
|
|
|
- GetLaneOriTotal(xps.mpRoad,nlane1,pp.mS,pp.mnLaneori,pp.mnLaneTotal,pp.speed);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- if(nlane1 < nlane2)
|
|
|
|
- {
|
|
|
|
- pp.lanmp = 1;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- pp.lanmp = -1;
|
|
|
|
- }
|
|
|
|
|
|
+// off1 = getoff(xps.mpRoad,nlane1,pp.mS);
|
|
|
|
+// pp.x = pp.x + off1 *cos(pp.hdg + M_PI/2.0);
|
|
|
|
+// pp.y = pp.y + off1 *sin(pp.hdg + M_PI/2.0);
|
|
|
|
|
|
- if(i<nchange1)
|
|
|
|
- {
|
|
|
|
- pp.mWidth = getwidth(xps.mpRoad,nlane1,xvectorLWA,pp.mS);
|
|
|
|
- double fmove = pp.mWidth * (i-(nchange1 - nchangepoint/2))/nchangepoint;
|
|
|
|
- if(nlane1<nlane2)pp.mfDisToLaneLeft = pp.mWidth/2.0 - fmove;
|
|
|
|
- else pp.mfDisToLaneLeft = pp.mWidth/2.0 + fmove;
|
|
|
|
- GetLaneOriTotal(xps.mpRoad,nlane1,pp.mS,pp.mnLaneori,pp.mnLaneTotal,pp.speed);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- pp.mWidth = getwidth(xps.mpRoad,nlane2,xvectorLWA,pp.mS);
|
|
|
|
- double fmove = pp.mWidth * (nchange1+nchangepoint/2 -i)/nchangepoint;
|
|
|
|
- if(nlane1<nlane2)pp.mfDisToLaneLeft = pp.mWidth/2.0 + fmove;
|
|
|
|
- else pp.mfDisToLaneLeft = pp.mWidth/2.0 - fmove;
|
|
|
|
- GetLaneOriTotal(xps.mpRoad,nlane2,pp.mS,pp.mnLaneori,pp.mnLaneTotal,pp.speed);
|
|
|
|
- }
|
|
|
|
|
|
+// pp.mWidth = getwidth(xps.mpRoad,nlane1,xvectorLWA,pp.mS);
|
|
|
|
+// pp.mfDisToLaneLeft = pp.mWidth/2.0;
|
|
|
|
+// pp.lanmp = 0;
|
|
|
|
+// pp.mfDisToRoadLeft = off1*(-1);
|
|
|
|
+// pp.mfRoadWidth = GetRoadWidth(xvectorLWA,nlane1,pp.mS);
|
|
|
|
+// GetLaneOriTotal(xps.mpRoad,nlane1,pp.mS,pp.mnLaneori,pp.mnLaneTotal,pp.speed);
|
|
|
|
|
|
- }
|
|
|
|
|
|
+// xvectorPP.push_back(pp);
|
|
|
|
|
|
- xvectorPP.push_back(pp);
|
|
|
|
|
|
+// }
|
|
|
|
+// for(i=(nchange1 - nchangepoint/2);i<(nchange1+nchangepoint/2);i++)
|
|
|
|
+// {
|
|
|
|
|
|
- }
|
|
|
|
- for(i=(nchange1 + nchangepoint/2);i<(nchange2-nchangepoint/2);i++)
|
|
|
|
- {
|
|
|
|
- PlanPoint pp = xvPP.at(i);
|
|
|
|
- // off2 = getoff(nlane2,pp.mS,xvectorLWA,xvectorindex2);
|
|
|
|
|
|
+// PlanPoint pp = xvPP.at(i);
|
|
|
|
+//// off1 = getoff(nlane1,pp.mS,xvectorLWA,xvectorindex1);
|
|
|
|
+//// off2 = getoff(nlane2,pp.mS,xvectorLWA,xvectorindex2);
|
|
|
|
+// off1 = getoff(xps.mpRoad,nlane1,pp.mS);
|
|
|
|
+// off2 = getoff(xps.mpRoad,nlane2,pp.mS);
|
|
|
|
+// double offx = off1 + (off2 - off1) *(i-nchange1 + nchangepoint/2)/nchangepoint;
|
|
|
|
+// pp.x = pp.x + offx *cos(pp.hdg + M_PI/2.0);
|
|
|
|
+// pp.y = pp.y + offx *sin(pp.hdg + M_PI/2.0);
|
|
|
|
|
|
- off2 = getoff(xps.mpRoad,nlane2,pp.mS);
|
|
|
|
- pp.x = pp.x + off2 *cos(pp.hdg + M_PI/2.0);
|
|
|
|
- pp.y = pp.y + off2 *sin(pp.hdg + M_PI/2.0);
|
|
|
|
|
|
+// double flanewidth1 = getwidth(xps.mpRoad,nlane1,xvectorLWA,pp.mS);
|
|
|
|
|
|
- pp.mWidth = getwidth(xps.mpRoad,nlane2,xvectorLWA,pp.mS);
|
|
|
|
- pp.mfDisToLaneLeft = pp.mWidth/2.0;
|
|
|
|
- pp.lanmp = 0;
|
|
|
|
- pp.mfDisToRoadLeft = off2*(-1);
|
|
|
|
- pp.mfRoadWidth = GetRoadWidth(xvectorLWA,nlane2,pp.mS);
|
|
|
|
- GetLaneOriTotal(xps.mpRoad,nlane2,pp.mS,pp.mnLaneori,pp.mnLaneTotal,pp.speed);
|
|
|
|
|
|
+// pp.mfDisToRoadLeft = offx*(-1);
|
|
|
|
+// pp.mfRoadWidth = GetRoadWidth(xvectorLWA,nlane1,pp.mS);
|
|
|
|
+// if(nlane1 == nlane2)
|
|
|
|
+// {
|
|
|
|
+// pp.mWidth = flanewidth1;
|
|
|
|
+// pp.mfDisToLaneLeft = pp.mWidth/2.0;
|
|
|
|
+// pp.lanmp = 0;
|
|
|
|
+// GetLaneOriTotal(xps.mpRoad,nlane1,pp.mS,pp.mnLaneori,pp.mnLaneTotal,pp.speed);
|
|
|
|
+// }
|
|
|
|
+// else
|
|
|
|
+// {
|
|
|
|
+// if(nlane1 < nlane2)
|
|
|
|
+// {
|
|
|
|
+// pp.lanmp = 1;
|
|
|
|
+// }
|
|
|
|
+// else
|
|
|
|
+// {
|
|
|
|
+// pp.lanmp = -1;
|
|
|
|
+// }
|
|
|
|
|
|
- xvectorPP.push_back(pp);
|
|
|
|
|
|
+// if(i<nchange1)
|
|
|
|
+// {
|
|
|
|
+// pp.mWidth = getwidth(xps.mpRoad,nlane1,xvectorLWA,pp.mS);
|
|
|
|
+// double fmove = pp.mWidth * (i-(nchange1 - nchangepoint/2))/nchangepoint;
|
|
|
|
+// if(nlane1<nlane2)pp.mfDisToLaneLeft = pp.mWidth/2.0 - fmove;
|
|
|
|
+// else pp.mfDisToLaneLeft = pp.mWidth/2.0 + fmove;
|
|
|
|
+// GetLaneOriTotal(xps.mpRoad,nlane1,pp.mS,pp.mnLaneori,pp.mnLaneTotal,pp.speed);
|
|
|
|
+// }
|
|
|
|
+// else
|
|
|
|
+// {
|
|
|
|
+// pp.mWidth = getwidth(xps.mpRoad,nlane2,xvectorLWA,pp.mS);
|
|
|
|
+// double fmove = pp.mWidth * (nchange1+nchangepoint/2 -i)/nchangepoint;
|
|
|
|
+// if(nlane1<nlane2)pp.mfDisToLaneLeft = pp.mWidth/2.0 + fmove;
|
|
|
|
+// else pp.mfDisToLaneLeft = pp.mWidth/2.0 - fmove;
|
|
|
|
+// GetLaneOriTotal(xps.mpRoad,nlane2,pp.mS,pp.mnLaneori,pp.mnLaneTotal,pp.speed);
|
|
|
|
+// }
|
|
|
|
|
|
- }
|
|
|
|
- for(i=(nchange2 - nchangepoint/2);i<(nchange2+nchangepoint/2);i++)
|
|
|
|
- {
|
|
|
|
|
|
+// }
|
|
|
|
|
|
- PlanPoint pp = xvPP.at(i);
|
|
|
|
-// off2 = getoff(nlane2,pp.mS,xvectorLWA,xvectorindex2);
|
|
|
|
-// off3 = getoff(nlane3,pp.mS,xvectorLWA,xvectorindex3);
|
|
|
|
|
|
+// xvectorPP.push_back(pp);
|
|
|
|
|
|
- off2 = getoff(xps.mpRoad,nlane2,pp.mS);
|
|
|
|
- off3 = getoff(xps.mpRoad,nlane3,pp.mS);
|
|
|
|
- double offx = off2 + (off3 - off2) *(i-nchange2 + nchangepoint/2)/nchangepoint;
|
|
|
|
- pp.x = pp.x + offx *cos(pp.hdg + M_PI/2.0);
|
|
|
|
- pp.y = pp.y + offx *sin(pp.hdg + M_PI/2.0);
|
|
|
|
|
|
+// }
|
|
|
|
+// for(i=(nchange1 + nchangepoint/2);i<(nchange2-nchangepoint/2);i++)
|
|
|
|
+// {
|
|
|
|
+// PlanPoint pp = xvPP.at(i);
|
|
|
|
+// // off2 = getoff(nlane2,pp.mS,xvectorLWA,xvectorindex2);
|
|
|
|
|
|
- double flanewidth1 = getwidth(xps.mpRoad,nlane2,xvectorLWA,pp.mS);
|
|
|
|
|
|
+// off2 = getoff(xps.mpRoad,nlane2,pp.mS);
|
|
|
|
+// pp.x = pp.x + off2 *cos(pp.hdg + M_PI/2.0);
|
|
|
|
+// pp.y = pp.y + off2 *sin(pp.hdg + M_PI/2.0);
|
|
|
|
|
|
- pp.mfDisToRoadLeft = offx*(-1);
|
|
|
|
- pp.mfRoadWidth = GetRoadWidth(xvectorLWA,nlane2,pp.mS);
|
|
|
|
- if(nlane2 == nlane3)
|
|
|
|
- {
|
|
|
|
- pp.mWidth = flanewidth1;
|
|
|
|
- pp.mfDisToLaneLeft = pp.mWidth/2.0;
|
|
|
|
- pp.lanmp = 0;
|
|
|
|
- GetLaneOriTotal(xps.mpRoad,nlane2,pp.mS,pp.mnLaneori,pp.mnLaneTotal,pp.speed);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- if(nlane2 < nlane3)
|
|
|
|
- {
|
|
|
|
- pp.lanmp = 1;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- pp.lanmp = -1;
|
|
|
|
- }
|
|
|
|
|
|
+// pp.mWidth = getwidth(xps.mpRoad,nlane2,xvectorLWA,pp.mS);
|
|
|
|
+// pp.mfDisToLaneLeft = pp.mWidth/2.0;
|
|
|
|
+// pp.lanmp = 0;
|
|
|
|
+// pp.mfDisToRoadLeft = off2*(-1);
|
|
|
|
+// pp.mfRoadWidth = GetRoadWidth(xvectorLWA,nlane2,pp.mS);
|
|
|
|
+// GetLaneOriTotal(xps.mpRoad,nlane2,pp.mS,pp.mnLaneori,pp.mnLaneTotal,pp.speed);
|
|
|
|
|
|
- if(i<nchange2)
|
|
|
|
- {
|
|
|
|
- pp.mWidth = getwidth(xps.mpRoad,nlane2,xvectorLWA,pp.mS);
|
|
|
|
- double fmove = pp.mWidth * (i-(nchange2 - nchangepoint/2))/nchangepoint;
|
|
|
|
- if(nlane2<nlane3)pp.mfDisToLaneLeft = pp.mWidth/2.0 - fmove;
|
|
|
|
- else pp.mfDisToLaneLeft = pp.mWidth/2.0 + fmove;
|
|
|
|
- GetLaneOriTotal(xps.mpRoad,nlane2,pp.mS,pp.mnLaneori,pp.mnLaneTotal,pp.speed);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- pp.mWidth = getwidth(xps.mpRoad,nlane3,xvectorLWA,pp.mS);
|
|
|
|
- double fmove = pp.mWidth * (nchange2+nchangepoint/2 -i)/nchangepoint;
|
|
|
|
- if(nlane2<nlane3)pp.mfDisToLaneLeft = pp.mWidth/2.0 + fmove;
|
|
|
|
- else pp.mfDisToLaneLeft = pp.mWidth/2.0 - fmove;
|
|
|
|
- GetLaneOriTotal(xps.mpRoad,nlane3,pp.mS,pp.mnLaneori,pp.mnLaneTotal,pp.speed);
|
|
|
|
- }
|
|
|
|
|
|
+// xvectorPP.push_back(pp);
|
|
|
|
|
|
- }
|
|
|
|
|
|
+// }
|
|
|
|
+// for(i=(nchange2 - nchangepoint/2);i<(nchange2+nchangepoint/2);i++)
|
|
|
|
+// {
|
|
|
|
|
|
- xvectorPP.push_back(pp);
|
|
|
|
|
|
+// PlanPoint pp = xvPP.at(i);
|
|
|
|
+//// off2 = getoff(nlane2,pp.mS,xvectorLWA,xvectorindex2);
|
|
|
|
+//// off3 = getoff(nlane3,pp.mS,xvectorLWA,xvectorindex3);
|
|
|
|
|
|
- }
|
|
|
|
- for(i=(nchange2 + nchangepoint/2);i<nsize;i++)
|
|
|
|
- {
|
|
|
|
- PlanPoint pp = xvPP.at(i);
|
|
|
|
- // off3 = getoff(nlane3,pp.mS,xvectorLWA,xvectorindex3);
|
|
|
|
- off3 = getoff(xps.mpRoad,nlane3,pp.mS);
|
|
|
|
- pp.x = pp.x + off3 *cos(pp.hdg + M_PI/2.0);
|
|
|
|
- pp.y = pp.y + off3 *sin(pp.hdg + M_PI/2.0);
|
|
|
|
|
|
+// off2 = getoff(xps.mpRoad,nlane2,pp.mS);
|
|
|
|
+// off3 = getoff(xps.mpRoad,nlane3,pp.mS);
|
|
|
|
+// double offx = off2 + (off3 - off2) *(i-nchange2 + nchangepoint/2)/nchangepoint;
|
|
|
|
+// pp.x = pp.x + offx *cos(pp.hdg + M_PI/2.0);
|
|
|
|
+// pp.y = pp.y + offx *sin(pp.hdg + M_PI/2.0);
|
|
|
|
|
|
- pp.mWidth = getwidth(xps.mpRoad,nlane3,xvectorLWA,pp.mS);
|
|
|
|
- pp.mfDisToLaneLeft = pp.mWidth/2.0;
|
|
|
|
- pp.lanmp = 0;
|
|
|
|
- pp.mfDisToRoadLeft = off3*(-1);
|
|
|
|
- pp.mfRoadWidth = GetRoadWidth(xvectorLWA,nlane3,pp.mS);
|
|
|
|
- GetLaneOriTotal(xps.mpRoad,nlane3,pp.mS,pp.mnLaneori,pp.mnLaneTotal,pp.speed);
|
|
|
|
|
|
+// double flanewidth1 = getwidth(xps.mpRoad,nlane2,xvectorLWA,pp.mS);
|
|
|
|
+
|
|
|
|
+// pp.mfDisToRoadLeft = offx*(-1);
|
|
|
|
+// pp.mfRoadWidth = GetRoadWidth(xvectorLWA,nlane2,pp.mS);
|
|
|
|
+// if(nlane2 == nlane3)
|
|
|
|
+// {
|
|
|
|
+// pp.mWidth = flanewidth1;
|
|
|
|
+// pp.mfDisToLaneLeft = pp.mWidth/2.0;
|
|
|
|
+// pp.lanmp = 0;
|
|
|
|
+// GetLaneOriTotal(xps.mpRoad,nlane2,pp.mS,pp.mnLaneori,pp.mnLaneTotal,pp.speed);
|
|
|
|
+// }
|
|
|
|
+// else
|
|
|
|
+// {
|
|
|
|
+// if(nlane2 < nlane3)
|
|
|
|
+// {
|
|
|
|
+// pp.lanmp = 1;
|
|
|
|
+// }
|
|
|
|
+// else
|
|
|
|
+// {
|
|
|
|
+// pp.lanmp = -1;
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+// if(i<nchange2)
|
|
|
|
+// {
|
|
|
|
+// pp.mWidth = getwidth(xps.mpRoad,nlane2,xvectorLWA,pp.mS);
|
|
|
|
+// double fmove = pp.mWidth * (i-(nchange2 - nchangepoint/2))/nchangepoint;
|
|
|
|
+// if(nlane2<nlane3)pp.mfDisToLaneLeft = pp.mWidth/2.0 - fmove;
|
|
|
|
+// else pp.mfDisToLaneLeft = pp.mWidth/2.0 + fmove;
|
|
|
|
+// GetLaneOriTotal(xps.mpRoad,nlane2,pp.mS,pp.mnLaneori,pp.mnLaneTotal,pp.speed);
|
|
|
|
+// }
|
|
|
|
+// else
|
|
|
|
+// {
|
|
|
|
+// pp.mWidth = getwidth(xps.mpRoad,nlane3,xvectorLWA,pp.mS);
|
|
|
|
+// double fmove = pp.mWidth * (nchange2+nchangepoint/2 -i)/nchangepoint;
|
|
|
|
+// if(nlane2<nlane3)pp.mfDisToLaneLeft = pp.mWidth/2.0 + fmove;
|
|
|
|
+// else pp.mfDisToLaneLeft = pp.mWidth/2.0 - fmove;
|
|
|
|
+// GetLaneOriTotal(xps.mpRoad,nlane3,pp.mS,pp.mnLaneori,pp.mnLaneTotal,pp.speed);
|
|
|
|
+// }
|
|
|
|
|
|
|
|
+// }
|
|
|
|
|
|
- xvectorPP.push_back(pp);
|
|
|
|
|
|
+// xvectorPP.push_back(pp);
|
|
|
|
|
|
- }
|
|
|
|
|
|
+// }
|
|
|
|
+// for(i=(nchange2 + nchangepoint/2);i<nsize;i++)
|
|
|
|
+// {
|
|
|
|
+// PlanPoint pp = xvPP.at(i);
|
|
|
|
+// // off3 = getoff(nlane3,pp.mS,xvectorLWA,xvectorindex3);
|
|
|
|
+// off3 = getoff(xps.mpRoad,nlane3,pp.mS);
|
|
|
|
+// pp.x = pp.x + off3 *cos(pp.hdg + M_PI/2.0);
|
|
|
|
+// pp.y = pp.y + off3 *sin(pp.hdg + M_PI/2.0);
|
|
|
|
+
|
|
|
|
+// pp.mWidth = getwidth(xps.mpRoad,nlane3,xvectorLWA,pp.mS);
|
|
|
|
+// pp.mfDisToLaneLeft = pp.mWidth/2.0;
|
|
|
|
+// pp.lanmp = 0;
|
|
|
|
+// pp.mfDisToRoadLeft = off3*(-1);
|
|
|
|
+// pp.mfRoadWidth = GetRoadWidth(xvectorLWA,nlane3,pp.mS);
|
|
|
|
+// GetLaneOriTotal(xps.mpRoad,nlane3,pp.mS,pp.mnLaneori,pp.mnLaneTotal,pp.speed);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// xvectorPP.push_back(pp);
|
|
|
|
+
|
|
|
|
+// }
|
|
|
|
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -2296,15 +2462,34 @@ static std::vector<PlanPoint> GetPlanPoint(std::vector<pathsection> xpathsection
|
|
Road * pRoad_obj,GeometryBlock * pgeob_obj,
|
|
Road * pRoad_obj,GeometryBlock * pgeob_obj,
|
|
const double x_now,const double y_now,const double head,
|
|
const double x_now,const double y_now,const double head,
|
|
double nearx,double neary, double nearhead,
|
|
double nearx,double neary, double nearhead,
|
|
- double nearx_obj,double neary_obj,const double fvehiclewidth)
|
|
|
|
|
|
+ double nearx_obj,double neary_obj,const double fvehiclewidth,const double flen = 1000)
|
|
{
|
|
{
|
|
|
|
|
|
std::vector<PlanPoint> xvectorPPs;
|
|
std::vector<PlanPoint> xvectorPPs;
|
|
|
|
|
|
- std::vector<PlanPoint> xvectorPP = GetPoint( xpathsection[0].mpRoad);
|
|
|
|
|
|
+ double fspace = 0.1;
|
|
|
|
+
|
|
|
|
+ if(flen<2000)fspace = 0.1;
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if(flen<5000)fspace = 0.3;
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if(flen<10000)fspace = 0.5;
|
|
|
|
+ else
|
|
|
|
+ fspace = 1.0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- int indexstart = indexinroadpoint(xvectorPP,nearx,neary);
|
|
|
|
int i;
|
|
int i;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// std::vector<PlanPoint> xvectorPP = GetPoint( xpathsection[0].mpRoad);
|
|
|
|
+ std::vector<PlanPoint> xvectorPP = GetPoint( xpathsection[0],fspace);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ int indexstart = indexinroadpoint(xvectorPP,nearx,neary);
|
|
|
|
+
|
|
std::vector<PlanPoint> xvPP = GetLanePoint(xpathsection[0],xvectorPP,fvehiclewidth);
|
|
std::vector<PlanPoint> xvPP = GetLanePoint(xpathsection[0],xvectorPP,fvehiclewidth);
|
|
|
|
|
|
if(xpathsection[0].mainsel < 0)
|
|
if(xpathsection[0].mainsel < 0)
|
|
@@ -2334,22 +2519,25 @@ static std::vector<PlanPoint> GetPlanPoint(std::vector<pathsection> xpathsection
|
|
// }
|
|
// }
|
|
for(i=1;i<(npathlast);i++)
|
|
for(i=1;i<(npathlast);i++)
|
|
{
|
|
{
|
|
- if(xpathsection[i].mpRoad == xpathsection[i-1].mpRoad)
|
|
|
|
- {
|
|
|
|
- if(xpathsection[i].mainsel * xpathsection[i-1].mainsel >0)
|
|
|
|
- {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if(xpathsection[i].mpRoad == xpathsection[npathlast].mpRoad)
|
|
|
|
- {
|
|
|
|
- if(xpathsection[i].mainsel * xpathsection[npathlast].mainsel > 0)
|
|
|
|
- {
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- xvectorPP = GetPoint( xpathsection[i].mpRoad);
|
|
|
|
|
|
+// if(xpathsection[i].mpRoad == xpathsection[i-1].mpRoad)
|
|
|
|
+// {
|
|
|
|
+// if(xpathsection[i].mainsel * xpathsection[i-1].mainsel >0)
|
|
|
|
+// {
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// if(xpathsection[i].mpRoad == xpathsection[npathlast].mpRoad)
|
|
|
|
+// {
|
|
|
|
+// if(xpathsection[i].mainsel * xpathsection[npathlast].mainsel > 0)
|
|
|
|
+// {
|
|
|
|
+// break;
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+ // xvectorPP = GetPoint( xpathsection[i].mpRoad);
|
|
|
|
+ xvectorPP = GetPoint( xpathsection[i],fspace);
|
|
xvPP = GetLanePoint(xpathsection[i],xvectorPP,fvehiclewidth);
|
|
xvPP = GetLanePoint(xpathsection[i],xvectorPP,fvehiclewidth);
|
|
|
|
+// std::cout<<" road id: "<<xpathsection[i].mroadid<<" section: "
|
|
|
|
+// <<xpathsection[i].msectionid<<" size is "<<xvectorPP.size()<<std::endl;
|
|
// std::cout<<" road id is "<<xpathsection[i].mpRoad->GetRoadId().data()<<" size is "<<xvPP.size()<<std::endl;
|
|
// std::cout<<" road id is "<<xpathsection[i].mpRoad->GetRoadId().data()<<" size is "<<xvPP.size()<<std::endl;
|
|
int j;
|
|
int j;
|
|
for(j=0;j<xvPP.size();j++)
|
|
for(j=0;j<xvPP.size();j++)
|
|
@@ -2357,7 +2545,11 @@ static std::vector<PlanPoint> GetPlanPoint(std::vector<pathsection> xpathsection
|
|
xvectorPPs.push_back(xvPP.at(j));
|
|
xvectorPPs.push_back(xvPP.at(j));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- xvectorPP = GetPoint(xpathsection[npathlast].mpRoad);
|
|
|
|
|
|
+
|
|
|
|
+ xvectorPP = GetPoint(xpathsection[npathlast],fspace);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// xvectorPP = GetPoint(xpathsection[npathlast].mpRoad);
|
|
int indexend = indexinroadpoint(xvectorPP,nearx_obj,neary_obj);
|
|
int indexend = indexinroadpoint(xvectorPP,nearx_obj,neary_obj);
|
|
xvPP = GetLanePoint(xpathsection[npathlast],xvectorPP,fvehiclewidth);
|
|
xvPP = GetLanePoint(xpathsection[npathlast],xvectorPP,fvehiclewidth);
|
|
int nlastsize;
|
|
int nlastsize;
|
|
@@ -2536,6 +2728,66 @@ void checktrace(std::vector<PlanPoint> & xPlan)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+void ChangeLane(std::vector<PlanPoint> & xvectorPP)
|
|
|
|
+{
|
|
|
|
+ int i = 0;
|
|
|
|
+ int nsize = xvectorPP.size();
|
|
|
|
+ for(i=0;i<nsize;i++)
|
|
|
|
+ {
|
|
|
|
+ if((xvectorPP[i].mfSecx == xvectorPP[i].x)&&(xvectorPP[i].mfSecy == xvectorPP[i].y))
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ int k;
|
|
|
|
+ for(k=i;k<nsize;k++)
|
|
|
|
+ {
|
|
|
|
+ if((xvectorPP[k].mfSecx == xvectorPP[k].x)&&(xvectorPP[k].mfSecy == xvectorPP[k].y))
|
|
|
|
+ {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ int nnum = k-i;
|
|
|
|
+ const int nchangepoint = 300;
|
|
|
|
+ int nstart = i + nnum/2 -nchangepoint/2;
|
|
|
|
+ int nend = i+nnum/2 + nchangepoint/2;
|
|
|
|
+ if(nnum<300)
|
|
|
|
+ {
|
|
|
|
+ nstart = i;
|
|
|
|
+ nend = k;
|
|
|
|
+ }
|
|
|
|
+ int j;
|
|
|
|
+ for(j=i;j<nstart;j++)
|
|
|
|
+ {
|
|
|
|
+ xvectorPP[j].x = xvectorPP[j].mfSecx;
|
|
|
|
+ xvectorPP[j].y = xvectorPP[j].mfSecy;
|
|
|
|
+ }
|
|
|
|
+ nnum = nend - nstart;
|
|
|
|
+ for(j=nstart;j<nend;j++)
|
|
|
|
+ {
|
|
|
|
+ double fdis = sqrt(pow(xvectorPP[j].x - xvectorPP[j].mfSecx,2)
|
|
|
|
+ +pow(xvectorPP[j].y - xvectorPP[j].mfSecy,2));
|
|
|
|
+ double foff = fdis *(j-nstart)/nnum;
|
|
|
|
+ if(xvectorPP[j].nlrchange == 1)
|
|
|
|
+ {
|
|
|
|
+ std::cout<<"foff is "<<foff<<std::endl;
|
|
|
|
+ xvectorPP[j].x = xvectorPP[j].mfSecx + foff *cos(xvectorPP[j].hdg + M_PI/2.0);
|
|
|
|
+ xvectorPP[j].y = xvectorPP[j].mfSecy + foff *sin(xvectorPP[j].hdg + M_PI/2.0);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ xvectorPP[j].x = xvectorPP[j].mfSecx + foff *cos(xvectorPP[j].hdg - M_PI/2.0);
|
|
|
|
+ xvectorPP[j].y = xvectorPP[j].mfSecy + foff *sin(xvectorPP[j].hdg - M_PI/2.0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ i =k;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
#include <QFile>
|
|
#include <QFile>
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -2562,20 +2814,23 @@ int MakePlan(xodrdijkstra * pxd,OpenDrive * pxodr,const double x_now,const doubl
|
|
double s;double nearx;
|
|
double s;double nearx;
|
|
double neary;double nearhead;
|
|
double neary;double nearhead;
|
|
Road * pRoad;GeometryBlock * pgeob;
|
|
Road * pRoad;GeometryBlock * pgeob;
|
|
|
|
+ double fs1,fs2;
|
|
// int nfind = GetNearPoint(x_now,y_now,pxodr,&pRoad,&pgeob,s,nearx,neary,nearhead,srcnearthresh);
|
|
// int nfind = GetNearPoint(x_now,y_now,pxodr,&pRoad,&pgeob,s,nearx,neary,nearhead,srcnearthresh);
|
|
|
|
|
|
- int nfind = GetNearPointWithHead(x_now,y_now,head,pxodr,&pRoad,&pgeob,s,nearx,neary,nearhead,srcnearthresh);
|
|
|
|
|
|
+ int nfind = GetNearPointWithHead(x_now,y_now,head,pxodr,&pRoad,&pgeob,s,nearx,neary,nearhead,srcnearthresh,fs1);
|
|
|
|
|
|
if(nfind < 0)return -1;
|
|
if(nfind < 0)return -1;
|
|
|
|
+ fs1 =fs1 + pgeob->GetGeometryAt(0)->GetS();
|
|
|
|
|
|
double s_obj;double nearx_obj;
|
|
double s_obj;double nearx_obj;
|
|
double neary_obj;double nearhead_obj;
|
|
double neary_obj;double nearhead_obj;
|
|
Road * pRoad_obj;GeometryBlock * pgeob_obj;
|
|
Road * pRoad_obj;GeometryBlock * pgeob_obj;
|
|
int nfind_obj = GetNearPoint(x_obj,y_obj,pxodr,&pRoad_obj,&pgeob_obj,s_obj,nearx_obj,neary_obj,
|
|
int nfind_obj = GetNearPoint(x_obj,y_obj,pxodr,&pRoad_obj,&pgeob_obj,s_obj,nearx_obj,neary_obj,
|
|
- nearhead_obj,dstnearthresh);
|
|
|
|
|
|
+ nearhead_obj,dstnearthresh,fs2);
|
|
|
|
|
|
|
|
|
|
if(nfind_obj < 0)return -2;
|
|
if(nfind_obj < 0)return -2;
|
|
|
|
+ fs2 = fs2 + pgeob_obj->GetGeometryAt(0)->GetS();
|
|
|
|
|
|
|
|
|
|
//计算终点在道路的左侧还是右侧
|
|
//计算终点在道路的左侧还是右侧
|
|
@@ -2607,7 +2862,7 @@ int MakePlan(xodrdijkstra * pxd,OpenDrive * pxodr,const double x_now,const doubl
|
|
int lr_start = SelectRoadLeftRight(pRoad,head,nearhead);
|
|
int lr_start = SelectRoadLeftRight(pRoad,head,nearhead);
|
|
|
|
|
|
bool bNeedDikstra = true;
|
|
bool bNeedDikstra = true;
|
|
- if((atoi(pRoad->GetRoadId().data()) == atoi(pRoad_obj->GetRoadId().data()))&&(lr_start == lr_end))
|
|
|
|
|
|
+ if((atoi(pRoad->GetRoadId().data()) == atoi(pRoad_obj->GetRoadId().data()))&&(lr_start == lr_end) &&(pRoad->GetLaneSectionCount() == 1))
|
|
{
|
|
{
|
|
std::vector<PlanPoint> xvPP = GetPoint(pRoad);
|
|
std::vector<PlanPoint> xvPP = GetPoint(pRoad);
|
|
int nindexstart = indexinroadpoint(xvPP,nearx,neary);
|
|
int nindexstart = indexinroadpoint(xvPP,nearx,neary);
|
|
@@ -2678,7 +2933,7 @@ int MakePlan(xodrdijkstra * pxd,OpenDrive * pxodr,const double x_now,const doubl
|
|
pathsection xps;
|
|
pathsection xps;
|
|
xps.mbStartToMainChange = false;
|
|
xps.mbStartToMainChange = false;
|
|
xps.mbMainToEndChange = false;
|
|
xps.mbMainToEndChange = false;
|
|
- CalcInLaneAvoid(xps,xvectorPP,fvehiclewidth,0,0,0);
|
|
|
|
|
|
+ // CalcInLaneAvoid(xps,xvectorPP,fvehiclewidth,0,0,0);
|
|
xPlan = xvectorPP;
|
|
xPlan = xvectorPP;
|
|
|
|
|
|
}
|
|
}
|
|
@@ -2686,12 +2941,14 @@ int MakePlan(xodrdijkstra * pxd,OpenDrive * pxodr,const double x_now,const doubl
|
|
|
|
|
|
if(bNeedDikstra)
|
|
if(bNeedDikstra)
|
|
{
|
|
{
|
|
- std::vector<int> xpath = pxd->getpath(atoi(pRoad->GetRoadId().data()),lr_start,atoi(pRoad_obj->GetRoadId().data()),lr_end);
|
|
|
|
|
|
+ std::vector<int> xpath = pxd->getpath(atoi(pRoad->GetRoadId().data()),lr_start,atoi(pRoad_obj->GetRoadId().data()),lr_end,fs1,fs2);
|
|
|
|
+ double flen = pxd->getpathlength(xpath);
|
|
std::vector<pathsection> xpathsection = pxd->getgpspoint(atoi(pRoad->GetRoadId().data()),lr_start,atoi(pRoad_obj->GetRoadId().data()),lr_end,xpath,nlanesel);
|
|
std::vector<pathsection> xpathsection = pxd->getgpspoint(atoi(pRoad->GetRoadId().data()),lr_start,atoi(pRoad_obj->GetRoadId().data()),lr_end,xpath,nlanesel);
|
|
|
|
|
|
std::vector<PlanPoint> xvectorPP = GetPlanPoint(xpathsection,pRoad,pgeob,pRoad_obj,pgeob_obj,x_now,y_now,
|
|
std::vector<PlanPoint> xvectorPP = GetPlanPoint(xpathsection,pRoad,pgeob,pRoad_obj,pgeob_obj,x_now,y_now,
|
|
- head,nearx,neary,nearhead,nearx_obj,neary_obj,fvehiclewidth);
|
|
|
|
|
|
+ head,nearx,neary,nearhead,nearx_obj,neary_obj,fvehiclewidth,flen);
|
|
|
|
|
|
|
|
+ ChangeLane(xvectorPP);
|
|
xPlan = xvectorPP;
|
|
xPlan = xvectorPP;
|
|
|
|
|
|
}
|
|
}
|
|
@@ -2712,7 +2969,7 @@ int MakePlan(xodrdijkstra * pxd,OpenDrive * pxodr,const double x_now,const doubl
|
|
// }
|
|
// }
|
|
// xFile.close();
|
|
// xFile.close();
|
|
|
|
|
|
- checktrace(xPlan);
|
|
|
|
|
|
+ // checktrace(xPlan);
|
|
// std::cout<<"pp size is "<<xvectorPP.size()<<std::endl;
|
|
// std::cout<<"pp size is "<<xvectorPP.size()<<std::endl;
|
|
return 0;
|
|
return 0;
|
|
|
|
|