4 from rose2.msg
import ROSEFeatures
5 from nav_msgs.msg
import OccupancyGrid
6 from visualization_msgs.msg
import MarkerArray
7 from skimage.util
import img_as_ubyte
8 from util
import MsgUtils
as mu
9 from PIL
import Image
as ImagePIL
10 from rose_v1_repo.fft_structure_extraction
import FFTStructureExtraction
as structure_extraction
14 Subscribers: /map (nav_msgs/OccupancyGrid)
15 Publishers: /features_ROSE (rose/ROSEFeatures)
16 /clean_map (nav_msgs/OccupancyGrid)
17 /direction_markers (visualization_msgs/MarkerArray)
18 Service: /features_roseSrv (rose2/ROSE)
19 params: /filter -> used for rose method (real number 0 to 1, 0 keeps all the pixels)
20 /pub_once -> publish once or keep publishing at a certain rate (True or False)
22 This node gets a map and applies ROSE method to it. This method is used to find the main directions of the map,
23 and to filter all the pixels which do not belong to the main structure.
24 After computing the result rose publishes ROSEFeatures: main_directions, originalMap and cleanMap
25 The cleanMap corresponds to the original map with non-structural pixels removed, that is, only what is considered to be
26 a wall or part of it is kept in the clean map.
30 rospy.init_node(
'ROSE')
31 rospy.loginfo(
'[ROSE] waiting for map...')
33 self.
pubOnce = rospy.get_param(
"ROSE/pub_once",
True)
34 self.
filter = rospy.get_param(
"ROSE/filter", 0.18)
49 rospy.Service(
'ROSESrv', rose2.srv.ROSE, self.
featuresSrv)
52 self.
pubFeatures = rospy.Publisher(
'features_ROSE', ROSEFeatures, queue_size=1)
53 self.
pubCleanMap = rospy.Publisher(
'clean_map', OccupancyGrid, queue_size=1)
54 self.
pubDirections = rospy.Publisher(
'direction_markers', MarkerArray, queue_size=1)
56 rospy.Subscriber(
'map', OccupancyGrid, self.
processMap, queue_size=1, buff_size=2**28)
60 while not rospy.is_shutdown():
69 self.
origin = occMap.info.origin
70 self.
res = occMap.info.resolution
71 self.
imgMap = mu.fromOccupancyGridToImg(occMap)
72 grid_map = img_as_ubyte(ImagePIL.fromarray(self.
imgMap))
73 self.
rose = structure_extraction(grid_map, peak_height=0.2, par=50)
74 self.
rose.process_map()
75 if len(self.
rose.main_directions) > 2:
77 self.
rose.generate_initial_hypothesis_simple()
79 self.
rose.find_walls_flood_filing()
81 rospy.loginfo(
"[ROSE] skipped data, can't find walls...")
87 rospy.loginfo(
"[ROSE] DONE.")
89 rospy.loginfo(
'[ROSE] publishing clean map and main directions')
91 rospy.loginfo(
'[ROSE] skipped data, not enough directions computed...')
103 if __name__ ==
'__main__':
105 warnings.filterwarnings(
"ignore")