3 from numpy
import array
5 from move_base_msgs.msg
import MoveBaseAction, MoveBaseGoal
6 from nav_msgs.srv
import GetPlan
7 from geometry_msgs.msg
import PoseStamped
8 from numpy
import floor
9 from numpy.linalg
import norm
22 self.listener.waitForTransform(self.
global_frame, name+
'/base_link', rospy.Time(0),rospy.Duration(10.0))
26 (trans,rot) = self.listener.lookupTransform(self.
global_frame, self.
name+
'/base_link', rospy.Time(0))
33 self.client.wait_for_server()
35 robot.goal.target_pose.header.stamp=rospy.Time.now()
37 rospy.wait_for_service(self.
name+
'/move_base_node/NavfnROS/make_plan')
38 self.
make_plan = rospy.ServiceProxy(self.
name+
'/move_base_node/NavfnROS/make_plan', GetPlan)
46 (trans,rot) = self.listener.lookupTransform(self.
global_frame, self.
name+
'/base_link', rospy.Time(0))
50 self.
position=array([trans[0],trans[1]])
54 robot.goal.target_pose.pose.position.x=point[0]
55 robot.goal.target_pose.pose.position.y=point[1]
56 robot.goal.target_pose.pose.orientation.w = 1.0
57 self.client.send_goal(robot.goal)
61 self.client.cancel_goal()
65 return self.client.get_state()
68 robot.start.pose.position.x=start[0]
69 robot.start.pose.position.y=start[1]
70 robot.end.pose.position.x=end[0]
71 robot.end.pose.position.y=end[1]
72 start=self.listener.transformPose(self.
name+
'/map', robot.start)
73 end=self.listener.transformPose(self.
name+
'/map', robot.end)
74 plan=self.
make_plan(start = start, goal = end, tolerance = 0.0)
75 return plan.plan.poses
79 resolution=mapData.info.resolution
80 Xstartx=mapData.info.origin.position.x
81 Xstarty=mapData.info.origin.position.y
82 width=mapData.info.width
84 index=int( ( floor((Xp[1]-Xstarty)/resolution)*width)+( floor((Xp[0]-Xstartx)/resolution) ))
88 y=mapData.info.origin.position.y+(i/mapData.info.width)*mapData.info.resolution
89 x=mapData.info.origin.position.x+(i-(i/mapData.info.width)*(mapData.info.width))*mapData.info.resolution
96 r_region=int(r/mapData.info.resolution)
97 init_index=index-r_region*(mapData.info.width+1)
98 for n
in range(0,2*r_region+1):
99 start=n*mapData.info.width+init_index
101 limit=((start/mapData.info.width)+2)*mapData.info.width
102 for i
in range(start,end+1):
103 if (i>=0
and i<limit
and i<len(mapData.data)):
104 if(mapData.data[i]==-1
and norm(array(point)-
point_of_index(mapData,i))<=r):
106 return infoGain*(mapData.info.resolution**2)
109 def discount(mapData,assigned_pt,centroids,infoGain,r):
111 r_region=int(r/mapData.info.resolution)
112 init_index=index-r_region*(mapData.info.width+1)
113 for n
in range(0,2*r_region+1):
114 start=n*mapData.info.width+init_index
116 limit=((start/mapData.info.width)+2)*mapData.info.width
117 for i
in range(start,end+1):
118 if (i>=0
and i<limit
and i<len(mapData.data)):
119 for j
in range(0,len(centroids)):
120 current_pt=centroids[j]
129 p1=array([path[i-1].pose.position.x,path[i-1].pose.position.y])
130 p2=array([path[i].pose.position.x,path[i].pose.position.y])
131 return norm(p1-p2)*(len(path)-1)
139 init_index=index-r_region*(mapData.info.width+1)
140 for n
in range(0,2*r_region+1):
141 start=n*mapData.info.width+init_index
143 limit=((start/mapData.info.width)+2)*mapData.info.width
144 for i
in range(start,end+1):
145 if (i>=0
and i<limit
and i<len(mapData.data)):
146 if(mapData.data[i]==1):
153 for i
in range(0,V.shape[0]):
164 for i
in range(0,len(V)):
172 resolution=mapData.info.resolution
173 Xstartx=mapData.info.origin.position.x
174 Xstarty=mapData.info.origin.position.y
176 width=mapData.info.width
180 index=( floor((Xp[1]-Xstarty)/resolution)*width)+( floor((Xp[0]-Xstartx)/resolution) )
182 if int(index) < len(Data):
183 return Data[int(index)]
def discount(mapData, assigned_pt, centroids, infoGain, r)
def makePlan(self, start, end)
def point_of_index(mapData, i)
def informationGain(mapData, point, r)
def index_of_point(mapData, Xp)
def sendGoal(self, point)
def gridValue(mapData, Xp)