|
@@ -90,34 +90,74 @@ int service_roi_xodr::GetROI(std::shared_ptr<iv::roi::request> xreq_ptr, std::sh
|
|
|
return -1; //grid size is error
|
|
|
}
|
|
|
|
|
|
- unsigned int xarea = (unsigned int)(xreq_ptr->range()*2.0/xreq_ptr->gridsize()) + 1;
|
|
|
- unsigned int yarea = (unsigned int)(xreq_ptr->range()*2.0/xreq_ptr->gridsize()) + 1;
|
|
|
+ double fgridsize = xreq_ptr->gridsize()/2.0;
|
|
|
|
|
|
std::vector<iv::roi::Point> xvectorpoint;
|
|
|
- for(i=0;i<xarea;i++)
|
|
|
+ unsigned int nareasize = xvectorarea.size();
|
|
|
+ double fgpsyaw = (90-xreq_ptr->heading())*M_PI/180.0;
|
|
|
+ for(i=0;i<nareasize;i++)
|
|
|
{
|
|
|
- for(j=0;j<yarea;j++)
|
|
|
+ int ix,iy;
|
|
|
+ unsigned int ny = xvectorarea[i].fsteplen/fgridsize;
|
|
|
+ unsigned int nxl = 0;
|
|
|
+ unsigned int nxr = 0;
|
|
|
+ if(xvectorarea[i].fleftwidth>0)nxl = xvectorarea[i].fleftwidth/fgridsize;
|
|
|
+ if(xvectorarea[i].frightwidth>0)nxr = xvectorarea[i].frightwidth/fgridsize;
|
|
|
+ double fyaw = xvectorarea[i].fhdg - fgpsyaw;
|
|
|
+ double flaneoff = xvectorarea[i].flaneoff;
|
|
|
+ if(fyaw < 0)fyaw = fyaw + 2.0*M_PI;
|
|
|
+ double frelxraw = xvectorarea[i].refPoint.x - x;
|
|
|
+ double frelyraw = xvectorarea[i].refPoint.y - y;
|
|
|
+ double fxrel,fyrel;
|
|
|
+ fxrel = frelxraw * cos(-fgpsyaw) - frelyraw * sin(-fgpsyaw);
|
|
|
+ fyrel = frelxraw * sin(-fgpsyaw) - frelyraw * cos(-fgpsyaw);
|
|
|
+ double fxbase = fxrel + flaneoff * cos(fyaw + M_PI/2.0);
|
|
|
+ double fybase = fyrel + flaneoff * sin(fyaw + M_PI/2.0);
|
|
|
+ if((nxl == 0)&&(nxr== 0)&&(ny <= 1))
|
|
|
{
|
|
|
- double xr = i*xreq_ptr->gridsize() - xreq_ptr->range();
|
|
|
- double yr = j*xreq_ptr->gridsize() - xreq_ptr->range();
|
|
|
- double hdg_o = (90-xreq_ptr->heading())*M_PI/180.0;
|
|
|
- double rel_x = xr * cos(hdg_o) - yr * sin(hdg_o);
|
|
|
- double rel_y = xr * sin(hdg_o) + yr * cos(hdg_o);
|
|
|
- if(CheckPointInROI(rel_x,rel_y,xvectorarea))
|
|
|
+ iv::roi::Point xpoint;
|
|
|
+ xpoint.x = fxbase;
|
|
|
+ xpoint.y = fybase;
|
|
|
+ xvectorpoint.push_back(xpoint);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if((nxl == 0)&&(nxr== 0))
|
|
|
{
|
|
|
- iv::roi::Point xpoint;
|
|
|
- xpoint.x = rel_x;
|
|
|
- xpoint.y = rel_y;
|
|
|
- xvectorpoint.push_back(xpoint);
|
|
|
+ for(iy=(-ny);iy<=0;iy++)
|
|
|
+ {
|
|
|
+ iv::roi::Point xpoint;
|
|
|
+ xpoint.x = fxbase +(iy*fgridsize)*cos(fyaw);
|
|
|
+ xpoint.y = fybase +(iy*fgridsize)*sin(fyaw);
|
|
|
+ xvectorpoint.push_back(xpoint);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ for(ix=(-nxl);ix<=nxr;ix++)
|
|
|
+ {
|
|
|
+ for(iy=(-ny);iy<=0;iy++)
|
|
|
+ {
|
|
|
+ double fxlocal,fylocal;
|
|
|
+ fxlocal = ix*fgridsize;
|
|
|
+ fylocal = iy*fgridsize;
|
|
|
+ iv::roi::Point xpoint;
|
|
|
+ xpoint.x = fxbase +fxlocal*cos(fyaw) - fylocal * sin(fyaw);
|
|
|
+ xpoint.y = fybase +fxlocal*sin(fyaw) - fylocal * cos(fyaw);
|
|
|
+ xvectorpoint.push_back(xpoint);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- std::cout<<"xTime: "<<xTime.elapsed()<<std::endl;
|
|
|
+
|
|
|
+ std::cout<<"xTime: "<<xTime.elapsed()<<" size : "<<xvectorpoint.size()<< std::endl;
|
|
|
|
|
|
for(i=0;i<xvectorpoint.size();i++)
|
|
|
{
|
|
|
iv::roi::resultunit * padd = xres_ptr->add_res();
|
|
|
+// std::cout<<" x: "<<xvectorpoint[i].x<<" y: "<<xvectorpoint[i].y<<std::endl;
|
|
|
padd->set_x(xvectorpoint[i].x);
|
|
|
padd->set_y(xvectorpoint[i].y);
|
|
|
}
|
|
@@ -131,7 +171,7 @@ void service_roi_xodr::updateroadarea()
|
|
|
mvectorarea.clear();
|
|
|
unsigned int nroadcount = pxodr->GetRoadCount();
|
|
|
unsigned int i;
|
|
|
- const double fstep = 0.1;
|
|
|
+ double fstep = GEOSAMPLESTEP;
|
|
|
for(i=0;i<nroadcount;i++)
|
|
|
{
|
|
|
Road * pRoad = pxodr->GetRoad(i);
|
|
@@ -211,6 +251,11 @@ iv::roi::roadarea service_roi_xodr::GetRoadArea(Road *pRoad, const double fstep)
|
|
|
xarea.refPoint.y = y;
|
|
|
xarea.s = snow;
|
|
|
xarea.fmaxlen = fleftwidth + frigthwidth;
|
|
|
+ xarea.fhdg = yaw;
|
|
|
+ xarea.fleftwidth = fleftwidth;
|
|
|
+ xarea.frightwidth = frigthwidth;
|
|
|
+ xarea.flaneoff = flaneoff;
|
|
|
+ xarea.fsteplen = fstep;
|
|
|
xroadarea.mvectorarea.push_back(xarea);
|
|
|
// double fleftwidth = pRoad->GetRoadLeftWidth(snow);
|
|
|
// double frigthwidth = pRoad->GetRoadRightWidth(snow);
|
|
@@ -221,8 +266,9 @@ iv::roi::roadarea service_roi_xodr::GetRoadArea(Road *pRoad, const double fstep)
|
|
|
snow = snow + fstep;
|
|
|
|
|
|
}
|
|
|
- if(snow < (endS - 0.000001))
|
|
|
+ if((snow-fstep) < (endS - 0.000001))
|
|
|
{
|
|
|
+ double foldsnow = snow - fstep;
|
|
|
snow = endS - 0.000001;
|
|
|
fleftwidth = pRoad->GetRoadLeftWidth(snow);
|
|
|
frigthwidth = pRoad->GetRoadRightWidth(snow);
|
|
@@ -240,6 +286,11 @@ iv::roi::roadarea service_roi_xodr::GetRoadArea(Road *pRoad, const double fstep)
|
|
|
xarea.refPoint.x = x;
|
|
|
xarea.refPoint.y = y;
|
|
|
xarea.s = snow;
|
|
|
+ xarea.fhdg = yaw;
|
|
|
+ xarea.fleftwidth = fleftwidth;
|
|
|
+ xarea.frightwidth = frigthwidth;
|
|
|
+ xarea.flaneoff = flaneoff;
|
|
|
+ xarea.fsteplen = endS - foldsnow;
|
|
|
xroadarea.mvectorarea.push_back(xarea);
|
|
|
}
|
|
|
}
|