-1

i had search through anywhere on google and forums but i couldnt found what i wanted. hope someone could help me here...

i had generated a 2d map from octomap using map_server map_saver from a pcd file it generated 2 file which is pgm and yaml file

however the generated pgm file does not have grid line on it.

my question is is it possible to show grid line on the image generated from map_saver? or is there any other way to generate an image with grid line from a 2D map?

4

1 回答 1

0

你可以试试这个,改变地图尺寸,如果你有不同的方向,相应地旋转地图。

  import pylab as plt
  import numpy as np
  # Load the image
  img =  np.array(plt.imread("g_map.pgm"))

  # assume dimension of map 20mx20m
  map_dim_x = 20 
  map_dim_y = 20 

  # relationship between pixel and map  
  dx, dy = int(img.shape[0]/map_dim_x),int(img.shape[1]/map_dim_y)

  grid_color = 0

  img[:,::dy,] = grid_color
  img[::dx,] = grid_color

  plt.imshow(img)
  plt.show()

在此处输入图像描述

于 2020-08-22T09:18:36.110 回答