11 float Norm(std::vector<float> x1,std::vector<float> x2)
13 return pow( (pow((x2[0]-x1[0]),2)+pow((x2[1]-x1[1]),2)) ,0.5);
20 if (n<0.0){
return -1.0;}
26 std::vector<float>
Nearest( std::vector< std::vector<float> > V, std::vector<float> x){
32 for (
int j=0;j<V.size();j++)
47 std::vector<float>
Steer( std::vector<float> x_nearest , std::vector<float> x_rand,
float eta){
48 std::vector<float> x_new;
50 if (
Norm(x_nearest,x_rand)<=eta){
56 float m=(x_rand[1]-x_nearest[1])/(x_rand[0]-x_nearest[0]);
58 x_new.push_back( (
sign(x_rand[0]-x_nearest[0]))* ( sqrt( (pow(eta,2)) / ((pow(m,2))+1) ) )+x_nearest[0] );
59 x_new.push_back( m*(x_new[0]-x_nearest[0])+x_nearest[1] );
61 if(x_rand[0]==x_nearest[0]){
62 x_new[0]=x_nearest[0];
63 x_new[1]=x_nearest[1]+eta;
80 float Xstartx=mapData.info.origin.position.x;
81 float Xstarty=mapData.info.origin.position.y;
83 float width=mapData.info.width;
84 std::vector<signed char> Data=mapData.data;
88 float indx=( floor((Xp[1]-Xstarty)/resolution)*width)+( floor((Xp[0]-Xstartx)/resolution) );
99 char ObstacleFree(std::vector<float> xnear, std::vector<float> &xnew, nav_msgs::OccupancyGrid mapsub){
100 float rez=float(mapsub.info.resolution)*.2;
101 float stepz=int(ceil(
Norm(xnew,xnear))/rez);
102 std::vector<float> xi=xnear;
103 char obs=0;
char unk=0;
105 geometry_msgs::Point p;
106 for (
int c=0;c<stepz;c++){
107 xi=
Steer(xi,xnew,rez);
110 if (
gridValue(mapsub,xi) ==100){ obs=1; }
112 if (
gridValue(mapsub,xi) ==-1){ unk=1;
break;}
116 if (unk==1){ out=-1;}
120 if (obs!=1 && unk!=1){ out=1;}
std::vector< float > Steer(std::vector< float > x_nearest, std::vector< float > x_rand, float eta)
std::vector< float > Nearest(std::vector< std::vector< float > > V, std::vector< float > x)
float Norm(std::vector< float > x1, std::vector< float > x2)
int gridValue(nav_msgs::OccupancyGrid &mapData, std::vector< float > Xp)
char ObstacleFree(std::vector< float > xnear, std::vector< float > &xnew, nav_msgs::OccupancyGrid mapsub)