3 from rose2.msg
import ROSEFeatures
4 from rose2.msg
import ROSE2Features
5 from jsk_recognition_msgs.msg
import PolygonArray
7 from util
import MsgUtils
as mu
8 from rose_v2_repo
import minibatch, parameters
9 from visualization_msgs.msg
import Marker
10 from visualization_msgs.msg
import MarkerArray
13 Subscribers: /features_ROSE (rose2/ROSEFeatures)
14 Publishers: /features_ROSE2 (rose2/ROSE2Features)
15 /extended_lines (visualization_msgs/Marker)
16 /edges (visualization_msgs/MarkerArray)
17 /rooms (jsk_recognition_msgs/PolygonArray)
18 Service: /features_ROSESrv (nav_msgs/ROSE2Features)
19 params: /pub_once -> publish once or or keep publishing at a certain rate
21 /spatialClusteringLineSegmentsThreshold
22 /lines_th1 #real number 0 to 1 (0 keeps all the lines)
24 /edges_th #real number 0 to 1
26 #find more rooms with voronoi method (slower)
27 /rooms_voronoi -> True if you want to use this method
33 This node has to be started after ROSE node (with param pub_once=True) which gives a filtered map and its main directions.
34 ROSE2 node applies ROSE2 method to the filtered map, finds walls and rooms of the map.
35 After computing the result, ROSE2 publishes ROSE2Features: edges, extended lines, rooms and contours
40 rospy.init_node(
'ROSE2')
41 rospy.loginfo(
"[ROSE2] waiting for features...")
44 self.
pubOnce = rospy.get_param(
"ROSE/pub_once2",
True)
47 self.
lines_th1 = rospy.get_param(
"ROSE/lines_th1", 0.1)
53 self.
filepath = rospy.get_param(
"ROSE/filepath",
None)
55 self.
blur = rospy.get_param(
"ROSE/voronoi_blur", 8)
56 self.
iterations = rospy.get_param(
"ROSE/voronoi_iterations", 5)
82 rospy.Subscriber(
'features_ROSE', ROSEFeatures, self.
processMap, queue_size=1, buff_size=2 ** 29)
85 self.
pubFeatures = rospy.Publisher(
'features_ROSE2', ROSE2Features, queue_size=1)
86 self.
pubLines = rospy.Publisher(
'extended_lines', Marker, queue_size=1)
87 self.
pubEdges = rospy.Publisher(
'edges', MarkerArray, queue_size=1)
88 self.
pubRooms = rospy.Publisher(
'rooms', PolygonArray, queue_size=1)
91 rospy.Service(
'ROSE2Srv', rose2.srv.ROSE2, self.
featuresSrv)
97 while not rospy.is_shutdown():
107 self.
cleanMap = mu.fromOccupancyGridRawToImg(features.cleanMap)
108 self.
originalMap = mu.fromOccupancyGridToImg(features.originalMap)
115 rospy.loginfo(
'[ROSE2] publishing edges, lines, contour and rooms')
134 self.
res = self.
features.originalMap.info.resolution
135 extended_lines = self.
rose2.extended_segments_th1_merged.copy()
136 edges = self.
rose2.edges_th1.copy()
139 for l
in self.
rose2.extended_segments_th1_merged:
140 linesMsg.append(mu.make_extendedline_msg(l))
144 edgesRviz.append(mu.make_edge_marker(e, i, self.
origin, self.
res))
145 edgesMsg.append(mu.make_edge_msg(e))
148 if self.
rose2.rooms_th1
is not None:
150 for r
in self.
rose2.rooms_th1:
151 roomsMsg.append(mu.make_room_msg(r))
152 roomsRviz.append(mu.make_room_polygon(r, self.
origin, self.
res))
154 contourMsg = mu.make_contour_msg(self.
rose2.vertices)
171 if __name__ ==
'__main__':
173 warnings.filterwarnings(
"ignore")