@@ -279,10 +279,11 @@ def publish_map(self, key: str) -> None:
279279 return
280280 gm = GridMap ()
281281 gm .header .frame_id = self .map_frame
282- gm .header .stamp = self .get_clock ().now ().to_msg ()
282+ gm .header .stamp = self ._last_t if self . _last_t is not None else self . get_clock ().now ().to_msg ()
283283 gm .info .resolution = self ._map .resolution
284- gm .info .length_x = self ._map .map_length
285- gm .info .length_y = self ._map .map_length
284+ actual_map_length = (self ._map .cell_n - 2 ) * self ._map .resolution
285+ gm .info .length_x = actual_map_length
286+ gm .info .length_y = actual_map_length
286287 gm .info .pose .position .x = self ._map_t .x
287288 gm .info .pose .position .y = self ._map_t .y
288289 gm .info .pose .position .z = 0.0
@@ -296,12 +297,12 @@ def publish_map(self, key: str) -> None:
296297 for layer in self .my_publishers [key ].get ("layers" , []):
297298 gm .layers .append (layer )
298299 self ._map .get_map_with_name_ref (layer , self ._map_data )
300+ map_data_for_gridmap = np .flip (self ._map_data , axis = 1 )
299301 arr = Float32MultiArray ()
300302 arr .layout = MAL ()
301- N = self ._map_data .shape [0 ]
302- arr .layout .dim .append (MAD (label = "column_index" , size = N , stride = int (N * N )))
303- arr .layout .dim .append (MAD (label = "row_index" , size = N , stride = N ))
304- arr .data = self ._map_data .T .flatten ().tolist ()
303+ arr .layout .dim .append (MAD (label = "column_index" , size = map_data_for_gridmap .shape [1 ], stride = map_data_for_gridmap .shape [0 ] * map_data_for_gridmap .shape [1 ]))
304+ arr .layout .dim .append (MAD (label = "row_index" , size = map_data_for_gridmap .shape [0 ], stride = map_data_for_gridmap .shape [0 ]))
305+ arr .data = map_data_for_gridmap .flatten ().tolist ()
305306 gm .data .append (arr )
306307
307308 gm .outer_start_index = 0
0 commit comments