34 #include <boost/tokenizer.hpp> 35 #include <boost/foreach.hpp> 41 #include <cuda_runtime.h> 55 void calling_device(
const int numstones,
const double *stonex,
const double *stoney,
56 const double startx,
const double starty,
57 const double *radius,
const double *sradius,
const double *eradius,
58 const unsigned int costsizex,
const unsigned int costsizey,
const double map_resolution,
59 const double origin_x,
const double origin_y,
const double *dist_from_centre,
60 const double centre_weight,
62 const int min_index_x,
const int max_index_x,
63 const int min_index_y,
const int max_index_y,
64 unsigned char *newCost,
70 const double *stonex,
const double *stoney,
const double *stonedev,
71 const unsigned int costsizex,
const unsigned int costsizey,
72 const double map_resolution,
const double origin_x,
const double origin_y,
73 double *dist_from_centre,
81 initialized_(NULL),costmap_(NULL),navfn_planner_(NULL),lethal_cost_(253),debug(false),tolerance_(0.001),willDisplay_(false)
108 std_msgs::Bool initialised;
109 initialised.data=
true;
122 ROS_WARN(
"This planner has already been initialized, you can't call it twice, doing nothing");
178 dsrv_=
new dynamic_reconfigure::Server<pipeline_planner::PipelinePlannerConfig>(nh1);
180 dsrv_->setCallback(cb);
186 for(
int i=0;i<10;i++){
189 ROS_INFO(
"Service /move_base/PipelinePlanner/receive_checkpoints has advertised.");
194 ROS_ERROR(
"Service /move_base/PipelinePlanner/receive_checkpoints preparation is not confirmed.");
213 setTorchArea(config.use_torch,config.torch_area_x,config.torch_area_y);
223 int endpoint=(
openclose_==1)?npoints:npoints-1;
229 if(flag==1){ legal=
false;}
else { legal=
true;};
240 ROS_ERROR_STREAM(
"The part of the route made by the check points is off the global costmap.");
272 if(!(req.radius==0||req.radius>=0.001&&req.radius<=50)){
284 int nsegments=(
openclose_==1)?ncheckpoints:ncheckpoints-1;
287 for(
int i=0;i<nsegments;i++){
291 if(req.ID>nsegments-1){
307 if(flag==1){ legal=
false;}
else { legal=
true;};
318 ROS_ERROR_STREAM(
"The part of the route made by the check points is off the global costmap.");
352 int nsegments=(
openclose_==1)?ncheckpoints:ncheckpoints-1;
355 for(
int i=0;i<nsegments;i++){
359 if(req.ID>nsegments-1){
378 const std::vector<geometry_msgs::PoseStamped> check_points){
380 int npoints=check_points.size();
381 double dbgPx,dbgPy,dbgQx,dbgQy,dbgRx,dbgRy,dbgSx,dbgSy;
382 for(
int i=0;i<endpoint;i++){
384 int ni=(i==npoints-1)?0:i+1;
385 double Px=check_points.at(ci).pose.position.x;
386 double Py=check_points.at(ci).pose.position.y;
387 double Qx=check_points.at(ni).pose.position.x;
388 double Qy=check_points.at(ni).pose.position.y;
389 for(
int j=0;j<endpoint;j++){
390 if((i==j)||abs(i-j)==1||abs(i-j)==npoints-1)
continue;
392 int nj=(j==npoints-1)?0:j+1;
393 double Rx=check_points.at(cj).pose.position.x;
394 double Ry=check_points.at(cj).pose.position.y;
395 double Sx=check_points.at(nj).pose.position.x;
396 double Sy=check_points.at(nj).pose.position.y;
400 double PQx=Qx-Px;
double PQy=Qy-Py;
401 double RSx=Sx-Rx;
double RSy=Sy-Ry;
402 double SQx=Qx-Sx;
double SQy=Qy-Sy;
403 if(PQx*RSy==PQy*RSx){
404 if(!(PQx*SQy==PQy*SQx))
continue;
407 double SQ=SQx*PQx+SQy*PQy;
408 double SP=(Px-Sx)*PQx+(Py-Sy)*PQy;
409 double RQ=(Qx-Rx)*PQx+(Qy-Ry)*PQy;
410 double RP=(Px-Rx)*PQx+(Py-Ry)*PQy;
411 double minX=std::min(std::min(SQ,SP),std::min(RQ,RP));
412 double maxX=std::max(std::max(SQ,SP),std::max(RQ,RP));
413 if((minX<=0.0)&&(0.0<=maxX)){
415 dbgPx=Px;dbgPy=Py;dbgQx=Qx;dbgQy=Qy;
416 dbgRx=Rx;dbgRy=Ry;dbgSx=Sx;dbgSy=Sy;
425 double ppdPQx=-PQy;
double ppdPQy=PQx;
426 double ppdRSx=-RSy;
double ppdRSy=RSx;
427 double tmps=(SQx*ppdPQx+SQy*ppdPQy)/(-RSx*ppdPQx-RSy*ppdPQy);
428 double tmpt=(-SQx*ppdRSx-SQy*ppdRSy)/(-PQx*ppdRSx-PQy*ppdRSy);
429 if((0.0<=tmps)&&(tmps<=1.0)&&(0.0<=tmpt)&&(tmpt<=1.0)){
431 dbgPx=Px;dbgPy=Py;dbgQx=Qx;dbgQy=Qy;
432 dbgRx=Rx;dbgRy=Ry;dbgSx=Sx;dbgSy=Sy;
440 ROS_ERROR_STREAM(
"SubscribeCheckpoints: received pipeline has a crossing ");
442 ROS_ERROR_STREAM(
"(" << dbgPx <<
"," << dbgPy <<
")-(" << dbgQx <<
"," << dbgQy <<
")");
443 ROS_ERROR_STREAM(
"(" << dbgRx <<
"," << dbgRy <<
")-(" << dbgSx <<
"," << dbgSy <<
")");
445 bool hasnoCross=!hasCross;
454 for(
int i=0;i<endpoint;i++){
456 int ni=(i==npoints-1)?0:i+1;
473 double minx=std::min(cx,nx)-pipe_radius;
474 double miny=std::min(cy,ny)-pipe_radius;
475 double maxx=std::max(cx,nx)+pipe_radius;
476 double maxy=std::max(cy,ny)+pipe_radius;
487 unsigned int minx_i,miny_i,maxx_i,maxy_i;
488 unsigned int uix1,uiy1,uix2,uiy2;
490 ROS_ERROR_STREAM(
"the point (" << minx <<
"," << miny <<
") is off the global costmap");
495 ROS_ERROR_STREAM(
"the point (" << maxx <<
"," << maxy <<
") is off the global costmap");
499 minx_i=std::min(uix1,uix2);
500 miny_i=std::min(uiy1,uiy2);
501 maxx_i=std::max(uix1,uix2);
502 maxy_i=std::max(uiy1,uiy2);
504 double normv=std::sqrt((nx-cx)*(nx-cx)+(ny-cy)*(ny-cy));
505 double invnormv=1.0/normv;
506 double refper=cx*(ny-cy)-cy*(nx-cx);
507 double difper=pipe_radius*invnormv*((ny-cy)*(ny-cy)-(-(nx-cx))*(nx-cx))
508 +map_resolution*(0.5* std::abs(ny-cy)+0.5* std::abs(nx-cx));
510 double refpll=(0.5*(nx+cx))*(nx-cx)+(0.5*(ny+cy))*(ny-cy);
512 double difpll=(0.5*(nx-cx))*(nx-cx)+(0.5*(ny-cy))*(ny-cy)
513 +map_resolution*(0.5*std::abs(nx-cx)+0.5*std::abs(ny-cy));
516 for(
int ix=minx_i;ix<maxx_i+1;ix++){
517 if((!
debug)&&(flag!=0))
break;
518 for(
int iy=miny_i;iy<maxy_i+1;iy++){
523 double curper=wx*(ny-cy)-wy*(nx-cx);
524 double curpll=wx*(nx-cx)+wy*(ny-cy);
528 if((std::abs(curper-refper)<difper)&&(std::abs(curpll-refpll)<difpll)&&(c>=
lethal_cost_)){
547 unsigned int costsize=costsizex*costsizey;
550 for(
unsigned int xi=0;xi<costsizex;xi++){
551 for(
unsigned int yi=0;yi<costsizey;yi++){
560 double tmpdist,mindist;
563 for(
int i=0;i<endpoint;i++){
565 int ni=(i==npoints-1)?0:i+1;
570 double cnx=nx-cx;
double cny=ny-cy;
571 double leng_cn=sqrt(cnx*cnx+cny*cny);
572 double dirx=cnx/leng_cn;
double diry=cny/leng_cn;
574 double dcomp_c=cx*dirx+cy*diry;
575 double dcomp_n=nx*dirx+ny*diry;
576 double dcomp_p=px*dirx+py*diry;
578 double ppcx=ny-cy;
double ppcy=-(nx-cx);
579 double leng_ppc=sqrt(ppcx*ppcx+ppcy*ppcy);
580 double perpx=ppcx/leng_ppc;
double perpy=ppcy/leng_ppc;
584 double npx=px-(nx+perpx*
check_points_.at(i).pose.orientation.y);
585 double npy=py-(nx+perpy*
check_points_.at(i).pose.orientation.y);
586 tmpdist=sqrt(npx*npx+npy*npy);
587 }
else if(dcomp_c>dcomp_p){
589 double cpx=px-(cx+perpx*
check_points_.at(i).pose.orientation.y);
590 double cpy=py-(cy+perpy*
check_points_.at(i).pose.orientation.y);
591 tmpdist=sqrt(cpx*cpx+cpy*cpy);
598 double pcomp_c=cx*perpx+cy*perpy+
check_points_.at(i).pose.orientation.y;
599 double pcomp_p=px*perpx+py*perpy;
600 tmpdist=fabs(pcomp_c-pcomp_p);
605 if(tmpdist<mindist)mindist=tmpdist;
620 cudaError_t error_allocation;
623 unsigned int costsize=costsizex*costsizey;
633 double *stonex,*stoney;
636 error_allocation=cudaMallocManaged(&stonex,(endpoint+1)*
sizeof(
double));
638 error_allocation=cudaMallocManaged(&stoney,(endpoint+1)*
sizeof(
double));
640 error_allocation=cudaMallocManaged(&stonedev,(endpoint+1)*
sizeof(
double));
643 cudaMallocManaged(&stonex,(endpoint+1)*
sizeof(
double));
644 cudaMallocManaged(&stoney,(endpoint+1)*
sizeof(
double));
645 cudaMallocManaged(&stonedev,(endpoint+1)*
sizeof(
double));
648 for(
int i=0;i<endpoint;i++){
650 int ni=(i==npoints-1)?0:i+1;
655 int lastindex=(i==npoints-1)?0:i+1;
658 stonedev[i+1]=
check_points_.at(lastindex).pose.orientation.y;
662 double *dist_from_centre;
664 error_allocation=cudaMallocManaged(&dist_from_centre,(costsize)*
sizeof(
double));
667 cudaMallocManaged(&dist_from_centre,(costsize)*
sizeof(
double));
671 for(
int i=0;i<costsize;i++){
673 dist_from_centre[i]=100.0;
675 dist_from_centre[i]=0.0;
681 map_resolution,origin_x,origin_y,dist_from_centre,
689 for(
int xi=0;xi<costsizex;xi++){
690 for(
int yi=0;yi<costsizey;yi++){
691 int index=yi*costsizex+xi;
695 cudaError_t error_free;
697 error_free=cudaFree(stonex);
699 error_free=cudaFree(stoney);
701 error_free=cudaFree(stonedev);
703 error_free=cudaFree(dist_from_centre);
709 cudaFree(dist_from_centre);
719 for(
int i=0;i<last;i++){
720 pipeline_planner::SegmentInfo si;
721 int id,previd,nextid;
740 double dist=sqrt(pow(nx-cx,2.0)+pow(ny-cy,2.0));
742 ROS_ERROR_STREAM(
"two check points " << cID <<
"(" << cx <<
"," << cy <<
")-(" << nx <<
"," << ny <<
") are too close");
748 si.ID=id; si.prevID=previd; si.nextID=nextid;
750 si.start=
false; si.end=
false;
765 pipeline_planner::SegmentInfo segmentinfo;
766 segmentinfo.ID=it->ID;
767 segmentinfo.prevID=it->prevID;
768 segmentinfo.nextID=it->nextID;
769 segmentinfo.length=it->length;
770 segmentinfo.start=it->start;
771 segmentinfo.end=it->end;
773 res.sinfo.push_back(segmentinfo);
787 if(req.checkpoints.poses.empty()){
796 int num_points=req.checkpoints.poses.size();
797 for(
int i=0;i<num_points;i++){
798 geometry_msgs::PoseStamped tmpStm;
800 tmpStm.pose.position.x = req.checkpoints.poses[i].position.x;
801 tmpStm.pose.position.y = req.checkpoints.poses[i].position.y;
822 double aradius=req.checkpoints.poses[i].position.z;
823 if(!(aradius==0.0||aradius>=0.001&&aradius<=50)){
824 ROS_ERROR_STREAM(
"ReceiveCheckpoints: a radius of " << i+1 <<
"-th check point is not valid");
832 tmpStm.pose.position.z=aradius;
835 tmpStm.pose.orientation.x = 0;
836 tmpStm.pose.orientation.y = req.checkpoints.poses[i].orientation.y;
837 tmpStm.pose.orientation.z = 0;
838 tmpStm.pose.orientation.w = 1;
857 int openclose=std::atoi(req.checkpoints.header.frame_id.c_str());
860 ROS_INFO_STREAM(
"req.checkpoints.header.frame_id: " << req.checkpoints.header.frame_id);
863 if(!((openclose_==1)||(openclose_==2))){
864 ROS_ERROR_STREAM(
"The value for openclose flag is starnge.: " << req.checkpoints.header.frame_id);
910 for(std::vector<geometry_msgs::PoseStamped>::iterator it=
check_points_.begin();
913 if((*it).pose.position.z==0.0){
916 radius=(*it).pose.position.z;
918 ROS_INFO(
"(%f , %f) : %f",(*it).pose.position.x, (*it).pose.position.y, radius);
921 endpoint=(openclose_==1)?npoints:npoints-1;
960 ROS_ERROR_STREAM(
"The part of the route made by the check points is off the global costmap.");
987 const geometry_msgs::PoseStamped& goal,
988 std::vector<geometry_msgs::PoseStamped>& plan){
995 ROS_ERROR(
"This planner has not been initialized yet, but it is being used," 996 " please call initialize() before use");
1013 std::vector<int> startids;
1015 for(
int i=0;i<lastpoint;i++){
1019 double pipe_radius,sradius,eradius;
1031 sradius=pipe_radius;
1034 sradius=std::min(pipe_radius,prad);
1037 eradius=pipe_radius;
1040 eradius=std::min(pipe_radius,nrad);
1045 startids.push_back(ci);
1052 ROS_ERROR_STREAM(
"start point: " << start.pose.position.x <<
"," << start.pose.position.y);
1063 std::vector<int> goalids;
1065 for(
int i=0;i<lastpoint;i++){
1069 double pipe_radius,sradius,eradius;
1081 sradius=pipe_radius;
1084 sradius=std::min(pipe_radius,prad);
1087 eradius=pipe_radius;
1090 eradius=std::min(pipe_radius,nrad);
1095 goalids.push_back(ci);
1102 ROS_ERROR_STREAM(
"goal point: " << goal.pose.position.x <<
"," << goal.pose.position.y);
1115 for(
int i=0;i<startids.size();i++){
1116 int idx=startids.at(i);
1123 for(
int i=0;i<goalids.size();i++){
1124 int idx=goalids.at(i);
1133 int nextindex,loopsize;
1134 startindex=startids.at(0);
1135 loopsize=startids.size();
1136 for(
int i=0;i<loopsize;i++){
1139 nextindex=(startindex==0)?
check_points_.size()-1:startindex-1;
1141 nextindex=(startindex==
check_points_.size()-1)?0:startindex+1;
1143 for(
int j=0;j<loopsize;j++){
1144 if(startids.at(j)==nextindex){
1149 startindex=nextindex;
1158 goalindex=goalids.at(0);
1159 loopsize=goalids.size();
1160 for(
int i=0;i<loopsize;i++){
1162 nextindex=(goalindex==
check_points_.size()-1)?0:goalindex+1;
1163 for(
int j=0;j<loopsize;j++){
1164 if(goalids.at(j)==nextindex){
1169 goalindex=nextindex;
1179 ROS_ERROR_STREAM(
"The goal point is behind a back position of the start point in the open route.");
1184 if(startindex==goalindex){
1187 ROS_ERROR_STREAM(
"The goal point is behind a back position of the start point in a pipe segment.");
1194 std::vector<int> segids;
1196 if(goalindex>=startindex){
1197 for(
int i=startindex;i<=goalindex;i++){
1198 segids.push_back(i);
1202 segids.push_back(i);
1204 for(
int i=0;i<=goalindex;i++){
1205 segids.push_back(i);
1210 for(
int i=0;i<segids.size();i++){
1211 int tmp01=segids.at(i);
1246 geometry_msgs::PoseStamped local_global_goal;
1258 bool resultGlobalPlanner;
1264 if(resultGlobalPlanner==
true){
1267 }
else if(resultGlobalPlanner==
false){
1278 return resultGlobalPlanner;
1283 double radius,
double sradius,
double eradius,
double tolerance,
int index){
1284 bool result; result=
false;
1291 double px=pose.pose.position.x;
1292 double py=pose.pose.position.y;
1293 double normv=sqrt((nx-cx)*(nx-cx)+(ny-cy)*(ny-cy));
1294 if(normv<tolerance){
1296 " length: " << normv);
1299 double invnormv=1.0/normv;
1301 double refper=cx*(ny-cy)-cy*(nx-cx);
1302 double difper=radius*invnormv*((ny-cy)*(ny-cy)-(-(nx-cx))*(nx-cx));
1303 double sttpll=cx*(nx-cx)+cy*(ny-cy);
1304 double endpll=nx*(nx-cx)+ny*(ny-cy);
1306 double pper=px*(ny-cy)-py*(nx-cx);
1307 double ppll=px*(nx-cx)+py*(ny-cy);
1308 if((std::abs(pper-refper)<difper)&&((sttpll-ppll)*(endpll-ppll)<=0)){
1317 double dist_from_start=sqrt((px-cx)*(px-cx)+(py-cy)*(py-cy));
1318 if(dist_from_start<sradius)result=
true;
1322 double dist_from_end=sqrt((px-nx)*(px-nx)+(py-ny)*(py-ny));
1323 if(dist_from_end<eradius)result=
true;
1329 int& ID,
double& distance){
1330 ID=-1; distance=0.0;
1332 int lastpoint=(
openclose_==1)?npoints:npoints-1;
1333 std::vector<double> radius,sradius,eradius;
1335 radius.resize(npoints);
1336 sradius.resize(npoints);
1337 eradius.resize(npoints);
1339 radius.resize(npoints-1);
1340 sradius.resize(npoints-1);
1341 eradius.resize(npoints-1);
1350 for(
int i=0;i<sradius.size();i++){
1352 int pi=(ci==0)?((
openclose_==2)?0:npoints-1):ci-1;
1353 int ni=(ci==npoints-1)?((
openclose_==2)?ci:0):ci+1;
1361 sradius.at(i)=std::min(cr,pr);
1362 eradius.at(i)=std::min(cr,nr);
1365 std::vector<int> insegments,nearsegments;
1366 std::vector<asegment> segments;
1367 insegments.clear(); nearsegments.clear(); segments.clear();
1368 for(
int i=0;i<lastpoint;i++){
1369 int part;
double dist;
1372 thesegment.
id=i; thesegment.part=part; thesegment.dist=dist;
1373 thesegment.in=inasegment;
1374 segments.push_back(thesegment);
1376 nearsegments.push_back(i);
1377 if(part==1)insegments.push_back(i);
1381 int nnseg=nearsegments.size();
1383 if(nearsegments.empty()){
1387 ROS_ERROR(
"All pipe segments include the robot position. Its strange.");
1391 int currentindex=nearsegments.at(0);
1393 for(
int i=0;i<nnseg;i++){
1395 nextindex=(currentindex==0)?
check_points_.size()-1:currentindex-1;
1396 for(
int j=0;j<nnseg;j++){
1397 if(nextindex==nearsegments.at(j)){
1402 currentindex=nextindex;
1407 mostfrontindex=currentindex;
1408 if(!insegments.empty()){
1409 int niseg=insegments.size();
1410 currentindex=mostfrontindex;
1412 if(segments.at(currentindex).part==1){
1418 mostfrontindex=currentindex;
1422 if(segments.at(ID).part==1){
1423 distance=segments.at(mostfrontindex).dist;
1424 }
else if(segments.at(ID).part==2){
1425 distance=-segments.at(mostfrontindex).dist;
1426 }
else if(segments.at(ID).part==3){
1434 distance=sqrt(pow(nx-cx,2.0)+pow(ny-cy,2.0))+segments.at(mostfrontindex).dist;
1441 const int id,
const double radius,
const double sradius,
const double eradius,
1442 int& part,
double &dist,
double tolerance){
1451 double px=pose.position.x;
1452 double py=pose.position.y;
1453 double normv=sqrt((nx-cx)*(nx-cx)+(ny-cy)*(ny-cy));
1454 if(normv<tolerance){
1456 " length: " << normv);
1459 double invnormv=1.0/normv;
1461 double refper=cx*(ny-cy)-cy*(nx-cx);
1462 double difper=radius*invnormv*((ny-cy)*(ny-cy)-(-(nx-cx))*(nx-cx));
1463 double sttpll=cx*(nx-cx)+cy*(ny-cy);
1464 double endpll=nx*(nx-cx)+ny*(ny-cy);
1466 double pper=px*(ny-cy)-py*(nx-cx);
1467 double ppll=px*(nx-cx)+py*(ny-cy);
1468 if((std::abs(pper-refper)<difper)&&((sttpll-ppll)*(endpll-ppll)<=0)){
1471 dist=(ppll-sttpll)*invnormv;
1477 if((sttpll-ppll)*(endpll-sttpll)>=0){
1478 double dist_from_start=sqrt((px-cx)*(px-cx)+(py-cy)*(py-cy));
1479 if(dist_from_start<sradius){
1482 dist=dist_from_start;
1487 if((endpll-sttpll)*(ppll-endpll)>=0){
1488 double dist_from_end=sqrt((px-nx)*(px-nx)+(py-ny)*(py-ny));
1489 if(dist_from_end<eradius){
1501 const geometry_msgs::PoseStamped& start,
1502 const geometry_msgs::PoseStamped& goal){
1504 double cx,cy,nx,ny;
double sx,sy,gx,gy;
1513 sx=start.pose.position.x;
1514 sy=start.pose.position.y;
1515 gx= goal.pose.position.x;
1516 gy= goal.pose.position.y;
1518 poss=(nx-cx)*sx+(ny-cy)*sy;
1519 posg=(nx-cx)*gx+(ny-cy)*gy;
1529 const int startindex,
const int goalindex,
const geometry_msgs::PoseStamped& start){
1532 int numsegids=segids.size();
1533 std::vector<int> daub;
1535 daub.insert(daub.begin(),costsizex*costsizey,1);
1540 const double robot_x=start.pose.position.x;
1541 const double robot_y=start.pose.position.y;
1542 int min_visible_x,min_visible_y,max_visible_x,max_visible_y;
1543 int min_index_x,max_index_x,min_index_y,max_index_y;
1545 min_visible_x=(int)((robot_x-
torch_area_x_-origin_x)/map_resolution);
1546 max_visible_x=(int)((robot_x+
torch_area_x_-origin_x)/map_resolution);
1547 min_visible_x=std::max(min_visible_x,0);
1548 max_visible_x=std::min(max_visible_x,(
int)costsizex);
1549 min_visible_y=(int)((robot_y-
torch_area_y_-origin_y)/map_resolution);
1550 max_visible_y=(int)((robot_y+
torch_area_y_-origin_y)/map_resolution);
1551 min_visible_y=std::max(min_visible_y,0);
1552 max_visible_y=std::min(max_visible_y,(
int)costsizey);
1553 min_index_x=min_visible_x; max_index_x=max_visible_x;
1554 min_index_y=min_visible_y; max_index_y=max_visible_y;
1556 min_index_x=0; max_index_x=costsizex;
1557 min_index_y=0; max_index_y=costsizey;
1560 for(
int i=0;i<numsegids;i++){
1561 double radius,sradius,eradius;
1562 int ci=segids.at(i);
1580 sradius=std::min(radius,pr);
1586 eradius=std::min(radius,nr);
1594 double normv=std::sqrt((nx-cx)*(nx-cx)+(ny-cy)*(ny-cy));
1595 double invnormv=1.0/normv;
1596 double refper=cx*(ny-cy)-cy*(nx-cx);
1597 double difper=radius*invnormv*((ny-cy)*(ny-cy)-(-(nx-cx))*(nx-cx))
1598 +map_resolution*(0.5* std::abs(ny-cy)+0.5* std::abs(nx-cx));
1599 double refpll=(0.5*(nx+cx))*(nx-cx)+(0.5*(ny+cy))*(ny-cy);
1601 double difpll=(0.5*(nx-cx))*(nx-cx)+(0.5*(ny-cy))*(ny-cy)
1602 +map_resolution*(0.5*std::abs(nx-cx)+0.5*std::abs(ny-cy));
1603 double sedgepll,eedgepll,startpll,respll;
1606 sedgepll=(cx)*(nx-cx)+(cy)*(ny-cy);
1607 eedgepll=(nx)*(nx-cx)+(ny)*(ny-cy);
1608 startpll=(start.pose.position.x)*(nx-cx)+(start.pose.position.y)*(ny-cy);
1610 if((sedgepll-startpll)*(eedgepll-sedgepll)>0){
1612 }
else if((startpll-sedgepll)*(eedgepll-startpll)>0){
1620 for(
unsigned int xi=min_index_x;xi<max_index_x;xi++){
1621 for(
unsigned int yi=min_index_y;yi<max_index_y;yi++){
1622 int index=yi*costsizex+xi;
1623 if(daub.at(index)==2)
continue;
1625 daub.at(index)=2;
continue;
1630 double curper=wx*(ny-cy)-wy*(nx-cx);
1631 double curpll=wx*(nx-cx)+wy*(ny-cy);
1632 if((std::abs(curper-refper) < difper)&&(std::abs(curpll-refpll) < difpll)){
1633 if((ci==startindex)&&((start_area==2
1634 &&((curpll-sedgepll)*(startpll-curpll)>0)
1635 &&(std::abs(curpll-startpll)>0.1))
1636 ||(start_area==3))){
1647 double distancefromconnection;
double startfromconnection;
1649 distancefromconnection=sqrt((wx-cx)*(wx-cx)+(wy-cy)*(wy-cy));
1650 if(distancefromconnection<sradius+map_resolution*(0.5*sqrt(2.0))){
1652 startfromconnection=sqrt((start.pose.position.x-cx)*(start.pose.position.x-cx)+
1653 (start.pose.position.y-cy)*(start.pose.position.y-cy));
1654 if((ci==startindex)&&start_area==1
1655 &&((sedgepll-curpll)*(eedgepll-sedgepll)>0)
1656 &&(distancefromconnection>(startfromconnection+sradius)*0.5)){
1665 distancefromconnection=sqrt((wx-nx)*(wx-nx)+(wy-ny)*(wy-ny));
1666 if(distancefromconnection<eradius+map_resolution*(0.5*sqrt(2.0))){
1674 for(
unsigned int xi=0;xi<costsizex;xi++){
1675 for(
unsigned int yi=0;yi<costsizey;yi++){
1678 bool notVisible=(xi<min_index_x)||(max_index_x<=xi)||(yi<min_index_y)||(max_index_y<=yi);
1681 }
else if((daub.at(idx)==1)||(daub.at(idx)==2)){
1684 unsigned char new_cost;
1685 if((curr_cost!=253)&&(curr_cost!=254)&&(curr_cost!=255)){
1688 new_cost=std::min(
lethal_cost_,(
unsigned char)(curr_cost
1702 const int startindex,
const int goalindex,
const geometry_msgs::PoseStamped& start){
1706 cudaError_t error_allocation;
1708 int numstones=segids.size();
1709 double *stonex,*stoney;
1713 error_allocation=cudaMallocManaged(&stonex,(numstones+1)*
sizeof(
double));
1715 error_allocation=cudaMallocManaged(&stoney,(numstones+1)*
sizeof(
double));
1718 cudaMallocManaged(&stonex,(numstones+1)*
sizeof(
double));
1719 cudaMallocManaged(&stoney,(numstones+1)*
sizeof(
double));
1721 for(
int i=0;i<numstones;i++){
1722 int index=segids.at(i);
1731 double *radius, *sradius, *eradius;
1733 error_allocation=cudaMallocManaged(&radius,(numstones)*
sizeof(
double));
1735 error_allocation=cudaMallocManaged(&sradius,(numstones)*
sizeof(
double));
1737 error_allocation=cudaMallocManaged(&eradius,(numstones)*
sizeof(
double));
1740 cudaMallocManaged(&radius,(numstones)*
sizeof(
double));
1741 cudaMallocManaged(&sradius,(numstones)*
sizeof(
double));
1742 cudaMallocManaged(&eradius,(numstones)*
sizeof(
double));
1751 for(
int i=0;i<numstones;i++){
1752 int ci=segids.at(i);
1765 radius[i]:std::min(radius[i],pr);
1767 radius[i]:std::min(radius[i],nr);
1771 double startx=start.pose.position.x;
1772 double starty=start.pose.position.y;
1784 int min_visible_x,min_visible_y,max_visible_x,max_visible_y;
1785 int min_index_x,max_index_x,min_index_y,max_index_y;
1787 min_visible_x=(int)((startx-
torch_area_x_-origin_x)/map_resolution);
1788 max_visible_x=(int)((startx+
torch_area_x_-origin_x)/map_resolution);
1789 min_visible_x=std::max(min_visible_x,0);
1790 max_visible_x=std::min(max_visible_x,(
int)costsizex);
1791 min_visible_y=(int)((starty-
torch_area_y_-origin_y)/map_resolution);
1792 max_visible_y=(int)((starty+
torch_area_y_-origin_y)/map_resolution);
1793 min_visible_y=std::max(min_visible_y,0);
1794 max_visible_y=std::min(max_visible_y,(
int)costsizey);
1795 min_index_x=min_visible_x; max_index_x=max_visible_x;
1796 min_index_y=min_visible_y; max_index_y=max_visible_y;
1798 min_index_x=0; max_index_x=costsizex;
1799 min_index_y=0; max_index_y=costsizey;
1803 unsigned char *newCost;
1805 error_allocation=cudaMallocManaged(&newCost,(costsizex*costsizey)*
sizeof(
unsigned char));
1809 cudaMallocManaged(&newCost,(costsizex*costsizey)*
sizeof(
unsigned char));
1811 for(
int xi=0;xi<costsizex;xi++){
1812 for(
int yi=0;yi<costsizey;yi++){
1813 int index=yi*costsizex+xi;
1819 double *dist_from_centre;
1821 error_allocation=cudaMallocManaged(&dist_from_centre,(costsizex*costsizey)*
sizeof(
double));
1824 cudaMallocManaged(&dist_from_centre,(costsizex*costsizey)*
sizeof(
double));
1828 for(
int xi=min_index_x;xi<max_index_x;xi++){
1829 for(
int yi=min_index_y;yi<max_index_y;yi++){
1830 int index=yi*costsizex+xi;
1836 calling_device(numstones,stonex,stoney,startx,starty,radius,sradius,eradius,
1837 costsizex,costsizey,map_resolution,origin_x,origin_y,dist_from_centre,
1842 for(
int xi=0;xi<costsizex;xi++){
1843 for(
int yi=0;yi<costsizey;yi++){
1845 int idx=yi*costsizex+xi;
1851 cudaError_t error_free;
1853 error_free=cudaFree(stonex);
1855 error_free=cudaFree(stoney);
1857 error_free=cudaFree(newCost);
1859 error_free=cudaFree(dist_from_centre);
1865 cudaFree(dist_from_centre);
1868 cudaError_t last_error;
1869 last_error=cudaGetLastError();
1870 if(last_error!=cudaSuccess){
1881 const geometry_msgs::PoseStamped& goal,
const std::vector<int> segids,
1882 std::vector<geometry_msgs::PoseStamped>& plan){
1883 geometry_msgs::PoseStamped astone;
1887 astone.header.stamp = plan_time;
1889 astone.pose.position.x=0.0;
1890 astone.pose.position.y=0.0;
1891 astone.pose.position.z=0.0;
1892 astone.pose.orientation.x=0.0;
1893 astone.pose.orientation.y=0.0;
1894 astone.pose.orientation.z=0.0;
1895 astone.pose.orientation.w=1.0;
1898 if(segids.size()==1){
1899 plan.push_back(start);
1901 plan.push_back(goal);
1904 plan.push_back(start);
1906 for(
int i=1;i<segids.size()-1;i++){
1910 astone.pose.position.x=
check_points_.at(segids.at(i)).pose.position.x;
1911 astone.pose.position.y=
check_points_.at(segids.at(i)).pose.position.y;
1913 plan.push_back(astone);
1920 astone.pose.position.x=
check_points_.at(segids.at(segids.size()-1)).pose.position.x;
1921 astone.pose.position.y=
check_points_.at(segids.at(segids.size()-1)).pose.position.y;
1923 plan.push_back(astone);
1925 goal, plan))){
return false;};
1926 plan.push_back(goal);
1932 const geometry_msgs::PoseStamped end_point,
1933 std::vector<geometry_msgs::PoseStamped>& plan){
1935 double l=map_resolution*2.0;
1936 double ix=init_point.pose.position.x;
1937 double iy=init_point.pose.position.y;
1938 double ex=end_point.pose.position.x;
1939 double ey=end_point.pose.position.y;
1941 double diff_ie=sqrt((ex-ix)*(ex-ix)+(ey-iy)*(ey-iy));
1942 int num=(int) (diff_ie/l);
1943 if(num==0)
return true;
1944 double dx=(ex-ix)/(num+1.0);
1945 double dy=(ey-iy)/(num+1.0);
1949 for(
int i=1;i<num+1;i++){
1950 geometry_msgs::PoseStamped astone;
1966 astone.header.stamp = plan_time;
1968 astone.pose.position.x=x;
1969 astone.pose.position.y=y;
1970 astone.pose.position.z=0.0;
1971 astone.pose.orientation.x=0.0;
1972 astone.pose.orientation.y=0.0;
1973 astone.pose.orientation.z=0.0;
1974 astone.pose.orientation.w=1.0;
1975 plan.push_back(astone);
1981 nav_msgs::Path path_publish;
1982 path_publish.poses.resize(path.size());
1985 path_publish.header.frame_id = path[0].header.frame_id;
1986 path_publish.header.stamp = path[0].header.stamp;
1988 for(
int i=0;i<path.size();i++){
1989 path_publish.poses[i]=path[i];
2010 pipeline_.info.resolution=map_resolution;
2013 pipeline_.info.origin.position.x=origin_x;
2014 pipeline_.info.origin.position.y=origin_y;
2016 pipeline_.info.origin.orientation.w=1.0;
2020 for(
int i=0;i<costsizex*costsizey;i++){
2028 int numsegids=(
openclose_==1)?numchecks:numchecks-1;
2031 for(
int i=0;i<costsizex*costsizey;i++){
2038 double *stonex,*stoney,*radii,*sradii,*eradii;
2050 stonex=
new double[numchecks];
2051 stoney=
new double[numchecks];
2052 radii=
new double[numsegids];
2053 sradii=
new double[numsegids];
2054 eradii=
new double[numsegids];
2055 data=
new int[costsizex*costsizey];
2057 for(
int i=0;i<numchecks;i++){
2066 for(
int i=0;i<numsegids;i++){
2068 int pi=(ci==0)?numchecks-1:ci-1;
2069 int ni=(ci==numchecks-1)?0:ci+1;
2076 sradii[ci]=radii[ci];
2079 sradii[ci]=std::min(radii[ci],pr);
2082 eradii[ci]=radii[ci];
2085 eradii[ci]=std::min(radii[ci],nr);
2093 calcPipeline(numchecks,stonex,stoney,isClose,radii,sradii,eradii,
2094 origin_x,origin_y,costsizex,costsizey,map_resolution,data);
2095 for(
int i=0;i<costsizex*costsizey;i++){
2118 const double *stonex,
const double *stoney,
const bool isClose,
2119 const double *radii,
const double *sradii,
const double *eradii,
2120 const double origin_x,
const double origin_y,
2121 const unsigned int costsizex,
const unsigned int costsizey,
2122 const double resolution,
int *data){
2124 for(
int i=0;i<costsizex*costsizey;i++){
2127 int numsegids=(isClose==
true)?numcheckpoints:numcheckpoints-1;
2129 for(
int i=0;i<numsegids;i++){
2131 int ni=(ci==numcheckpoints-1)?0:ci+1;
2132 const double cx=stonex[ci];
2133 const double cy=stoney[ci];
2134 const double nx=stonex[ni];
2135 const double ny=stoney[ni];
2136 const double normv=std::sqrt((nx-cx)*(nx-cx)+(ny-cy)*(ny-cy));
2137 const double invnormv=1.0/normv;
2138 const double refper=cx*(ny-cy)-cy*(nx-cx);
2139 const double difper=radii[i]*invnormv*((ny-cy)*(ny-cy)-(-(nx-cx))*(nx-cx))
2140 +resolution*(0.5* std::abs(ny-cy)+0.5* std::abs(nx-cx));
2141 const double refpll=(0.5*(nx+cx))*(nx-cx)+(0.5*(ny+cy))*(ny-cy);
2142 const double difpll=(0.5*(nx-cx))*(nx-cx)+(0.5*(ny-cy))*(ny-cy)
2143 +resolution*(0.5*std::abs(nx-cx)+0.5*std::abs(ny-cy));
2146 int min_index_x,min_index_y,max_index_x,max_index_y;
2147 double min_x,min_y,max_x,max_y;
2149 min_x=std::min(std::min(cx-radii[i],cx-sradii[i]),std::min(nx-radii[i],nx-eradii[i]));
2150 min_index_x=std::max(0,(
int)((min_x-origin_x)/resolution));
2151 max_x=std::max(std::max(cx+radii[i],cx+sradii[i]),std::max(nx+radii[i],nx+eradii[i]));
2152 max_index_x=std::min((
int)costsizex,(
int)((max_x-origin_x)/resolution));
2154 min_y=std::min(std::min(cy-radii[i],cy-sradii[i]),std::min(ny-radii[i],ny-eradii[i]));
2155 min_index_y=std::max(0,(
int)((min_y-origin_y)/resolution));
2156 max_y=std::max(std::max(cy+radii[i],cy+sradii[i]),std::max(ny+radii[i],ny+eradii[i]));
2157 max_index_y=std::min((
int)costsizey,(
int)((max_y-origin_y)/resolution));
2165 for(
int xi=min_index_x;xi<max_index_x;xi++){
2166 for(
int yi=min_index_y;yi<max_index_y;yi++){
2167 int index=yi*costsizex+xi;
2168 if(data[index]==0)
continue;
2169 const double wx=origin_x+(xi+0.5)*resolution;
2170 const double wy=origin_y+(yi+0.5)*resolution;
2171 const double curper=wx*(ny-cy)-wy*(nx-cx);
2172 const double curpll=wx*(nx-cx)+wy*(ny-cy);
2174 if((std::abs(curper-refper)<difper)&&(std::abs(curpll-refpll)<difpll)){
2179 const double distfromstart=sqrt(pow(wx-cx,2.0)+pow(wy-cy,2.0));
2180 if(distfromstart<sradii[i]+resolution*0.5*sqrt(2.0)){
2185 const double distfromend=sqrt(pow(wx-nx,2.0)+pow(wy-ny,2.0));
2186 if(distfromend<eradii[i]+resolution*0.5*sqrt(2.0)){
2208 ROS_INFO(
"Pipeline planner: informRobotPose loop started");
2211 pipeline_planner::RobotPosition position;
2216 position.startdist=distance;
2219 position.enddist=0.0;
2223 position.previd=it->prevID;
2224 position.nextid=it->nextID;
2225 position.enddist= it->length - distance;
2234 position.startdist=0.0;
2235 position.enddist=0.0;
2238 if(it->ID == position.id){it->start=
true;}
else{it->start=
false;};
2239 if(it->nextID == position.id){it->end=
true;}
else{it->end=
false;};
2260 const geometry_msgs::PoseStamped& goal,geometry_msgs::PoseStamped& local_goal,
2265 ROS_ERROR(
"we only use TakeLocalGoal function on torch model");
2270 bool in;
int sid,gid;
double sdistance,gdistance;
2271 geometry_msgs::Pose pose;
2274 sx=start.pose.position.x; sy=start.pose.position.y;
2275 gx=goal.pose.position.x; gy=goal.pose.position.y;
2276 double cx,cy,nx,ny;
double lenseg;
2277 double pseusx,pseusy,pseugx,pseugy;
2278 double crossx,crossy;
2287 ROS_ERROR(
"start position is out of pipeline");
2296 ROS_ERROR(
"goal position is out of pipeline");
2302 nextid=(sid+1)%numcp;
2307 lenseg=sqrt(pow(nx-cx,2)+pow(ny-cy,2));
2309 ROS_ERROR_STREAM(
"the length of pipe segment " << sid <<
" is too short: " << lenseg);
2313 pseusx=(nx-cx)*sdistance/lenseg+cx;
2314 pseusy=(ny-cy)*sdistance/lenseg+cy;
2315 nextid=(gid+1)%numcp;
2320 lenseg=sqrt(pow(nx-cx,2)+pow(ny-cy,2));
2322 ROS_ERROR_STREAM(
"the length of pipe segment " << sid <<
" is too short: " << lenseg);
2326 pseugx=(nx-cx)*gdistance/lenseg+cx;
2327 pseugy=(ny-cy)*gdistance/lenseg+cy;
2329 if(sid<=gid){ numid=gid-sid;}
else{numid=gid-sid+numcp;};
2330 for(
int i=sid;i<sid+numid+1;i++){
2331 int ID=i%numcp;
int nID=(i+1)%numcp;
2333 cx=pseusx; cy=pseusy;
2339 nx=pseugx; ny=pseugy;
2346 ROS_ERROR(
"unexpected error, torch area might be too narrow with respect to the pipeline radius");
2347 ROS_ERROR(
"please adjust torch_area_x and torch_area_y");
2350 }
else if(result==1){
2351 ROS_ERROR(
"pseudo-start position is out of torch area");
2354 }
else if(result==2){
2356 local_goal.header.seq=goal.header.seq;
2357 local_goal.header.stamp=goal.header.stamp;
2358 local_goal.header.frame_id=goal.header.frame_id;
2359 local_goal.pose.position.z=goal.pose.position.z;
2360 local_goal.pose.orientation.x=goal.pose.orientation.x;
2361 local_goal.pose.orientation.y=goal.pose.orientation.y;
2362 local_goal.pose.orientation.z=goal.pose.orientation.z;
2363 local_goal.pose.orientation.w=goal.pose.orientation.w;
2365 local_goal.pose.position.x=crossx;
2366 local_goal.pose.position.y=crossy;
2371 local_goal.header.seq=goal.header.seq;
2372 local_goal.header.stamp=goal.header.stamp;
2373 local_goal.header.frame_id=goal.header.frame_id;
2374 local_goal.pose.position.z=goal.pose.position.z;
2375 local_goal.pose.orientation.x=goal.pose.orientation.x;
2376 local_goal.pose.orientation.y=goal.pose.orientation.y;
2377 local_goal.pose.orientation.z=goal.pose.orientation.z;
2378 local_goal.pose.orientation.w=goal.pose.orientation.w;
2380 local_goal.pose.position.x=gx;
2381 local_goal.pose.position.y=gy;
2386 const double sx,
const double sy,
const double ex,
const double ey,
2387 double& bx,
double& by){
2398 double len=sqrt(pow(ex-sx,2)+pow(ey-sy,2));
2404 double uxp,uxm,uyp,uym;
double minu;
2409 if(uxp<0.0)uxp=2.0;
if(uxm<0.0)uxm=2.0;
2415 if(uyp<0.0)uyp=2.0;
if(uym<0.0)uym=2.0;
2417 minu=std::min(std::min(uxp,uxm),std::min(uyp,uym));
2421 bx=sx+(ex-sx)*minu; by=sy+(ey-sy)*minu;
2428 if(contained_radius==0.0){
2431 radius=contained_radius;
2438 cudaDeviceProp prop;
2440 cudaError_t device_property_error;
2441 device_property_error=cudaGetDeviceProperties(&prop,device);
2442 if(device_property_error!=cudaSuccess){
2443 ROS_ERROR_STREAM(
"cudaGetDeviceProperties error: " << device_property_error);
2449 ROS_WARN(
"the number of thead you set is larger than maximum thread size");
2451 ROS_WARN_STREAM(
"the maximum size of thread for this device: " << prop.maxThreadsPerBlock);
2456 nh.
setParam(
"/move_base/PipelinePlanner/num_threads",prop.maxThreadsPerBlock);
void makePipeline()
To make a pipeline and publish it as a topic Pipeline is constructed from check_points_. Validity of checkpoints_ must be checked in advance. Publication data values 0:in the pipeline, 100:out of the pipeline.
std::vector< pipeline_planner::SegmentInfo > segment_infos_
void setCost(unsigned int mx, unsigned int my, unsigned char cost)
bool ReceiveCheckpoints(pipeline_planner::ReceiveCheckpoints::Request &req, pipeline_planner::ReceiveCheckpoints::Response &res)
Reception of checkpoints.
bool DistanceFromCentre_cuda(int endpoint)
Calculation of cell's distance from pipe centre.
void initialize(std::string name, costmap_2d::Costmap2DROS *costmap_ros)
Initialisation function for the Planner.
bool VeilCostmap_cuda(const std::vector< int > segids, const int startindex, const int goalindex, const geometry_msgs::PoseStamped &start)
To veil costmap other than that in pipeline segments.
ros::Publisher pub_status_
bool InitSegInfo()
Initialisation of segment info.
void TimeDisplay(const bool time_display, const double duration)
Display consumed time on makePlan function.
bool getRobotStatus(pipeline_planner::GetRobotStatus::Request &req, pipeline_planner::GetRobotStatus::Response &res)
Get the status of a robot.
void publish(const boost::shared_ptr< M > &message) const
int CrossTorchArea(const double tx, const double ty, const double sx, const double sy, const double ex, const double ey, double &bx, double &by)
Whether the line segment crosses the torch area boundary or not.
void mapToWorld(unsigned int mx, unsigned int my, double &wx, double &wy) const
ros::ServiceServer set_a_radius_srv_
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
void setLethal(unsigned char lethal_cost)
void callbackgoal(const move_base_msgs::MoveBaseActionGoal::ConstPtr &goal)
Callback function for reception of actionlib goal.
nav_msgs::OccupancyGrid pipeline_
bool isBehindInaSegment(int idx, const geometry_msgs::PoseStamped &start, const geometry_msgs::PoseStamped &goal)
Whether the goal point is behind the start point in a pipe segment.
void setNumThread(float num_threads)
void setStraight(bool use_straight)
void informRobotPose()
loop for informing the robot position by a thread
ros::ServiceServer set_a_rightshift_srv_
std_msgs::UInt32 robot_status_
std::string getGlobalFrameID()
PLUGINLIB_EXPORT_CLASS(BAGReader, nodelet::Nodelet)
ros::ServiceServer receive_checkpoints_srv_
double getOriginX() const
ros::ServiceServer read_state_srv_
ros::ServiceServer get_checkpoints_srv_
std_msgs::Float32 consumed_time_
void callbackRobotPose(const geometry_msgs::Pose::ConstPtr &pose)
Callback function for reception of robot position.
unsigned char lethal_cost_
void publishPlan(const std::vector< geometry_msgs::PoseStamped > &path)
To publish a path.
ros::Publisher pub_result_
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
bool hasNoCross(const int endpoint, const std::vector< geometry_msgs::PoseStamped > check_points)
To check whether a sequence of checkpoints has a crossing or not.
Provides a global planner that will make a route along check points gained from topic. This planner uses global_planner.
bool makePlan(const geometry_msgs::PoseStamped &start, const geometry_msgs::PoseStamped &goal, std::vector< geometry_msgs::PoseStamped > &plan)
TFSIMD_FORCE_INLINE const tfScalar & y() const
ros::ServiceServer robot_state_srv_
ros::Publisher pub_robot_position_
unsigned char * getCharMap() const
std::string gained_frame_id_
navfn::NavfnROS * navfn_planner_
void reconfigureCB(pipeline_planner::PipelinePlannerConfig &config, uint32_t level)
Callback function for dynamic reconfiguration.
bool DrawOpenSegment(const geometry_msgs::PoseStamped init_point, const geometry_msgs::PoseStamped end_point, std::vector< geometry_msgs::PoseStamped > &plan)
To substitute the plan along two points.
bool InquireSegments(pipeline_planner::InquireSegments::Request &req, pipeline_planner::InquireSegments::Response &res)
Inquiring segments information.
void DistanceFromCentreCalling(const int numstones, const double *stonex, const double *stoney, const double *stonedev, const unsigned int costsizex, const unsigned int costsizey, const double map_resolution, const double origin_x, const double origin_y, double *dist_from_centre, const int nthreads, const bool debug)
costmap_2d::Costmap2D * navfn_costmap_
unsigned char getCost(unsigned int mx, unsigned int my) const
bool knowRobotPosition(const geometry_msgs::Pose pose, int &ID, double &distance)
To know the position of a robot in the pipeline.
double distance(double x0, double y0, double x1, double y1)
bool ConnectPoints(const geometry_msgs::PoseStamped &start, const geometry_msgs::PoseStamped &goal, const std::vector< int > segids, std::vector< geometry_msgs::PoseStamped > &plan)
To substitute plan by connecting start point, checkpoints and goal point.
void setPipeRadius(float radius)
substitute pipe_radius_ value when it is called from dynamic reconfigure
boost::thread * thread_robot_position_
ros::Publisher pub_initialised_
bool makePlan(const geometry_msgs::PoseStamped &start, const geometry_msgs::PoseStamped &goal, std::vector< geometry_msgs::PoseStamped > &plan)
Given a goal pose in the world, compute a plan.
ros::Publisher pub_pipeline_
int test_cuda(int a, int b)
PipelinePlanner()
Constructor for the PipelinePlanner.
ros::ServiceServer inquire_segments_srv_
void ThreadNumberAdjusment(bool debug)
void PublishCheckpointsResult(std_msgs::UInt32 result)
Callback function for subscription of checkpoints data from topic.
dynamic_reconfigure::Server< pipeline_planner::PipelinePlannerConfig > * dsrv_
geometry_msgs::Pose robot_position_
int costCheck(int endpoint)
To check received checkpoints whether it has a problem on costmap or not.
costmap_2d::Costmap2D * costmap_
bool getReadStatus(pipeline_planner::GetReadStatus::Request &req, pipeline_planner::GetReadStatus::Response &res)
Get the status of reading checkpoints.
TFSIMD_FORCE_INLINE const tfScalar & x() const
double getOriginY() const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void setCharge(bool charge)
unsigned int getSizeInCellsY() const
ros::Subscriber sub_movebase_goal_
#define ROS_WARN_STREAM(args)
std_msgs::UInt32 read_status_
void calcPipeline(const int numcheckpoints, const double *stonex, const double *stoney, const bool isClose, const double *radii, const double *sradii, const double *eradii, const double origin_x, const double origin_y, const unsigned int costsizex, const unsigned int costsizey, const double resolution, int *data)
To calculate the pipeline without GPU.
bool getNumofCheckpoints(pipeline_planner::GetNumofCheckpoints::Request &req, pipeline_planner::GetNumofCheckpoints::Response &res)
Get the status of reading checkpoints.
ros::ServiceServer get_numof_checkpoints_srv_
std::vector< geometry_msgs::PoseStamped > check_points_
unsigned int getSizeInCellsX() const
#define ROS_INFO_STREAM(args)
void setTorchArea(bool use_torch, float torch_area_x, float torch_area_y)
bool InPipeSegment(const geometry_msgs::PoseStamped &pose, double radius, double start_edge_radius, double end_edge_radius, double tolerance, int index)
Verification of whether the position is in the pipeline segment or not.
bool SetARadius(pipeline_planner::SetARadius::Request &req, pipeline_planner::SetARadius::Response &res)
Service to set a pipeline segment radius.
bool VeilCostmap(const std::vector< int > segids, const int startindex, const int goalindex, const geometry_msgs::PoseStamped &start)
To veil costmap other than that in pipeline segments.
bool DistanceFromCentre(int endpoint)
Calculation of cell's distance from pipe centre.
bool getCheckpoints(pipeline_planner::GetCheckpoints::Request &req, pipeline_planner::GetCheckpoints::Response &res)
Get check points.
bool whereInaPipeSegment(const geometry_msgs::Pose pose, const int id, const double radius, const double sradius, const double eradius, int &part, double &dist, double tolerance)
To know the position of a robot in a pipe segment.
double getResolution() const
#define ROS_ERROR_STREAM(args)
void setTimeDisplay(bool time_display)
double TakeSegmentRadius(const double contained_radius)
Taking pipline radius in a given pipeline segment.
bool TakeLocalGoal(const geometry_msgs::PoseStamped &start, const geometry_msgs::PoseStamped &goal, geometry_msgs::PoseStamped &local_goal, int &err)
To make local goal on torch model.
boost::mutex mutex_robot_position_
void setWeight(float centre_weight)
void setParam(const std::string &key, const XmlRpc::XmlRpcValue &v) const
bool worldToMap(double wx, double wy, unsigned int &mx, unsigned int &my) const
bool SetARightshift(pipeline_planner::SetARightshift::Request &req, pipeline_planner::SetARightshift::Response &res)
Service to set a right shift value for a pipeline segment.
ros::Subscriber sub_robot_pose_
std::vector< double > dist_from_pipe_centre_
unsigned int getIndex(unsigned int mx, unsigned int my) const
~PipelinePlanner()
Destructor for the planner.
ROSCPP_DECL bool waitForService(const std::string &service_name, int32_t timeout)
void calling_device(const int numstones, const double *stonex, const double *stoney, const double startx, const double starty, const double *radius, const double *sradius, const double *eradius, const unsigned int costsizex, const unsigned int costsizey, const double map_resolution, const double origin_x, const double origin_y, const double *dist_from_centre, const double centre_weight, unsigned char lethal, const int min_index_x, const int max_index_x, const int min_index_y, const int max_index_y, unsigned char *newCost, const int nthreads, const bool debug)