Go to the documentation of this file.00001
00002
00003
00004
00005 import rospy
00006 from visualization_msgs.msg import Marker
00007 from nav_msgs.msg import OccupancyGrid
00008 from geometry_msgs.msg import PointStamped
00009 from getfrontier import getfrontier
00010
00011
00012
00013 mapData=OccupancyGrid()
00014
00015
00016 def mapCallBack(data):
00017 global mapData
00018 mapData=data
00019
00020
00021
00022
00023
00024 def node():
00025 global mapData
00026 exploration_goal=PointStamped()
00027 map_topic= rospy.get_param('~map_topic','/robot_1/map')
00028 rospy.Subscriber(map_topic, OccupancyGrid, mapCallBack)
00029 targetspub = rospy.Publisher('/detected_points', PointStamped, queue_size=10)
00030 pub = rospy.Publisher('shapes', Marker, queue_size=10)
00031 rospy.init_node('detector', anonymous=False)
00032
00033 while mapData.header.seq<1 or len(mapData.data)<1:
00034 pass
00035
00036 rate = rospy.Rate(50)
00037 points=Marker()
00038
00039
00040 points.header.frame_id=mapData.header.frame_id
00041 points.header.stamp=rospy.Time.now()
00042
00043 points.ns= "markers"
00044 points.id = 0
00045
00046 points.type = Marker.POINTS
00047
00048 points.action = Marker.ADD;
00049
00050 points.pose.orientation.w = 1.0;
00051 points.scale.x=points.scale.y=0.3;
00052 points.color.r = 255.0/255.0
00053 points.color.g = 0.0/255.0
00054 points.color.b = 0.0/255.0
00055 points.color.a=1;
00056 points.lifetime == rospy.Duration();
00057
00058
00059 while not rospy.is_shutdown():
00060 frontiers=getfrontier(mapData)
00061 for i in range(len(frontiers)):
00062 x=frontiers[i]
00063 exploration_goal.header.frame_id= mapData.header.frame_id
00064 exploration_goal.header.stamp=rospy.Time(0)
00065 exploration_goal.point.x=x[0]
00066 exploration_goal.point.y=x[1]
00067 exploration_goal.point.z=0
00068
00069
00070 targetspub.publish(exploration_goal)
00071 points.points=[exploration_goal.point]
00072 pub.publish(points)
00073 rate.sleep()
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 if __name__ == '__main__':
00084 try:
00085 node()
00086 except rospy.ROSInterruptException:
00087 pass
00088
00089
00090
00091