|
@@ -1513,8 +1513,99 @@ std::vector<int> GetLWIndex(std::vector<iv::lanewidthabcd> xvectorLWA,int nlane)
|
|
|
return xvectorindex;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+void CalcInLaneAvoid(pathsection xps,std::vector<PlanPoint> & xvectorPP,const double fvehiclewidth,
|
|
|
+ const int nchang1,const int nchang2,const int nchangpoint)
|
|
|
+{
|
|
|
+ if(xvectorPP.size()<2)return;
|
|
|
+ bool bInlaneavoid = false;
|
|
|
+ int i;
|
|
|
+ if((xps.mbStartToMainChange == false) && (xps.mbMainToEndChange == false))
|
|
|
+ {
|
|
|
+ if(xps.mpRoad->GetRoadLength()<30)
|
|
|
+ {
|
|
|
+ double hdgdiff = xvectorPP.at(xvectorPP.size()-1).hdg - xvectorPP.at(0).hdg;
|
|
|
+ if(hdgdiff<0)hdgdiff = hdgdiff + 2.0*M_PI;
|
|
|
+ if(hdgdiff>(M_PI/3.0)&&(hdgdiff<(5.0*M_PI/3.0)))
|
|
|
+ bInlaneavoid = false;
|
|
|
+ else
|
|
|
+ bInlaneavoid = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ bInlaneavoid = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(xps.mpRoad->GetRoadLength()>100)bInlaneavoid = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(bInlaneavoid == false)
|
|
|
+ {
|
|
|
+ int nvpsize = xvectorPP.size();
|
|
|
+ for(i=0;i<nvpsize;i++)
|
|
|
+ {
|
|
|
+ xvectorPP.at(i).bInlaneAvoid = false;
|
|
|
+ xvectorPP.at(i).mx_left = xvectorPP.at(i).x;
|
|
|
+ xvectorPP.at(i).my_left = xvectorPP.at(i).y;
|
|
|
+ xvectorPP.at(i).mx_right = xvectorPP.at(i).x;
|
|
|
+ xvectorPP.at(i).my_right = xvectorPP.at(i).y;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ int nvpsize = xvectorPP.size();
|
|
|
+ for(i=0;i<nvpsize;i++)xvectorPP.at(i).bInlaneAvoid = true;
|
|
|
+ if((xps.mbStartToMainChange == true)||(xps.mbMainToEndChange == true))
|
|
|
+ {
|
|
|
+ if(xps.mbStartToMainChange == true)
|
|
|
+ {
|
|
|
+ for(i=(nchang1 - nchangpoint/2);i<(nchang1 + nchangpoint/2);i++)
|
|
|
+ {
|
|
|
+ if((i>=0)&&(i<nvpsize))
|
|
|
+ xvectorPP.at(i).bInlaneAvoid = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if(xps.mbMainToEndChange)
|
|
|
+ {
|
|
|
+ for(i=(nchang2 - nchangpoint/2);i<(nchang2 + nchangpoint/2);i++)
|
|
|
+ {
|
|
|
+ if((i>=0)&&(i<nvpsize))
|
|
|
+ xvectorPP.at(i).bInlaneAvoid = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for(i=0;i<nvpsize;i++)
|
|
|
+ {
|
|
|
+ if(xvectorPP.at(i).bInlaneAvoid)
|
|
|
+ {
|
|
|
+ double foff = xvectorPP.at(i).mfDisToLaneLeft -0.3-fvehiclewidth*0.5; //30cm + 0.5vehcilewidth
|
|
|
+ if(foff < 0.3)
|
|
|
+ {
|
|
|
+ xvectorPP.at(i).bInlaneAvoid = false;
|
|
|
+ xvectorPP.at(i).mx_left = xvectorPP.at(i).x;
|
|
|
+ xvectorPP.at(i).my_left = xvectorPP.at(i).y;
|
|
|
+ xvectorPP.at(i).mx_right = xvectorPP.at(i).x;
|
|
|
+ xvectorPP.at(i).my_right = xvectorPP.at(i).y;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ xvectorPP.at(i).mx_left = xvectorPP.at(i).x + foff * cos(xvectorPP.at(i).hdg + M_PI/2.0);
|
|
|
+ xvectorPP.at(i).my_left = xvectorPP.at(i).y + foff * sin(xvectorPP.at(i).hdg + M_PI/2.0);
|
|
|
+ xvectorPP.at(i).mx_right = xvectorPP.at(i).x + foff * cos(xvectorPP.at(i).hdg - M_PI/2.0);
|
|
|
+ xvectorPP.at(i).my_right = xvectorPP.at(i).y + foff * sin(xvectorPP.at(i).hdg - M_PI/2.0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
//暂不考虑多个LaneSection的情况,不考虑车道宽度变化
|
|
|
-std::vector<PlanPoint> GetLanePoint(pathsection xps,std::vector<PlanPoint> xvPP)
|
|
|
+std::vector<PlanPoint> GetLanePoint(pathsection xps,std::vector<PlanPoint> xvPP,const double fvehiclewidth)
|
|
|
{
|
|
|
std::vector<PlanPoint> xvectorPP;
|
|
|
|
|
@@ -1920,7 +2011,7 @@ std::vector<PlanPoint> GetLanePoint(pathsection xps,std::vector<PlanPoint> xvPP)
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+ CalcInLaneAvoid(xps,xvectorPP,fvehiclewidth,nchange1,nchange2,nchangepoint);
|
|
|
|
|
|
|
|
|
if(xps.mnStartLaneSel > 0)
|
|
@@ -1993,7 +2084,7 @@ static std::vector<PlanPoint> GetPlanPoint(std::vector<pathsection> xpathsection
|
|
|
Road * pRoad_obj,GeometryBlock * pgeob_obj,
|
|
|
const double x_now,const double y_now,const double head,
|
|
|
double nearx,double neary, double nearhead,
|
|
|
- double nearx_obj,double neary_obj)
|
|
|
+ double nearx_obj,double neary_obj,const double fvehiclewidth)
|
|
|
{
|
|
|
|
|
|
std::vector<PlanPoint> xvectorPPs;
|
|
@@ -2002,7 +2093,7 @@ static std::vector<PlanPoint> GetPlanPoint(std::vector<pathsection> xpathsection
|
|
|
|
|
|
int indexstart = indexinroadpoint(xvectorPP,nearx,neary);
|
|
|
int i;
|
|
|
- std::vector<PlanPoint> xvPP = GetLanePoint(xpathsection[0],xvectorPP);
|
|
|
+ std::vector<PlanPoint> xvPP = GetLanePoint(xpathsection[0],xvectorPP,fvehiclewidth);
|
|
|
|
|
|
if(xpathsection[0].mainsel < 0)
|
|
|
{
|
|
@@ -2046,7 +2137,7 @@ static std::vector<PlanPoint> GetPlanPoint(std::vector<pathsection> xpathsection
|
|
|
}
|
|
|
}
|
|
|
xvectorPP = GetPoint( xpathsection[i].mpRoad);
|
|
|
- xvPP = GetLanePoint(xpathsection[i],xvectorPP);
|
|
|
+ xvPP = GetLanePoint(xpathsection[i],xvectorPP,fvehiclewidth);
|
|
|
// std::cout<<" road id is "<<xpathsection[i].mpRoad->GetRoadId().data()<<" size is "<<xvPP.size()<<std::endl;
|
|
|
int j;
|
|
|
for(j=0;j<xvPP.size();j++)
|
|
@@ -2056,7 +2147,7 @@ static std::vector<PlanPoint> GetPlanPoint(std::vector<pathsection> xpathsection
|
|
|
}
|
|
|
xvectorPP = GetPoint(xpathsection[npathlast].mpRoad);
|
|
|
int indexend = indexinroadpoint(xvectorPP,nearx_obj,neary_obj);
|
|
|
- xvPP = GetLanePoint(xpathsection[npathlast],xvectorPP);
|
|
|
+ xvPP = GetLanePoint(xpathsection[npathlast],xvectorPP,fvehiclewidth);
|
|
|
int nlastsize;
|
|
|
if(xpathsection[npathlast].mainsel<0)
|
|
|
{
|
|
@@ -2254,7 +2345,7 @@ void checktrace(std::vector<PlanPoint> & xPlan)
|
|
|
int MakePlan(xodrdijkstra * pxd,OpenDrive * pxodr,const double x_now,const double y_now,const double head,
|
|
|
const double x_obj,const double y_obj,const double & obj_dis,
|
|
|
const double srcnearthresh,const double dstnearthresh,
|
|
|
- const int nlanesel,std::vector<PlanPoint> & xPlan)
|
|
|
+ const int nlanesel,std::vector<PlanPoint> & xPlan,const double fvehiclewidth )
|
|
|
{
|
|
|
double s;double nearx;
|
|
|
double neary;double nearhead;
|
|
@@ -2371,6 +2462,11 @@ int MakePlan(xodrdijkstra * pxd,OpenDrive * pxodr,const double x_now,const doubl
|
|
|
i--;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ pathsection xps;
|
|
|
+ xps.mbStartToMainChange = false;
|
|
|
+ xps.mbMainToEndChange = false;
|
|
|
+ CalcInLaneAvoid(xps,xvectorPP,fvehiclewidth,0,0,0);
|
|
|
xPlan = xvectorPP;
|
|
|
|
|
|
}
|
|
@@ -2382,7 +2478,7 @@ int MakePlan(xodrdijkstra * pxd,OpenDrive * pxodr,const double x_now,const doubl
|
|
|
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,
|
|
|
- head,nearx,neary,nearhead,nearx_obj,neary_obj);
|
|
|
+ head,nearx,neary,nearhead,nearx_obj,neary_obj,fvehiclewidth);
|
|
|
|
|
|
xPlan = xvectorPP;
|
|
|
|