1

I have a particular **Grid ** for robot navigation showing as so:

enter image description here

I have scaled this by a factor of 10 to create my Environment. This is given in Cartesian coordinates

enter image description here

I would like to map a point in the Environment (x,y) into Grid index (row, col)

The obstacle format is given in the form:

[[(60.0, 0.0), (70.0, 0.0), (70.0, 10.0), (60.0, 10.0)],

[(70.0, 0.0), (80.0, 0.0), (80.0, 10.0), (70.0, 10.0)],

[(60.0, 10.0), (70.0, 10.0), (70.0, 20.0), (60.0, 20.0)],

[(70.0, 10.0), (80.0, 10.0), (80.0, 20.0), (70.0, 20.0)],

However when i try to plot these using the following code:

fig, ax = plt.subplots()
        for obs_corner in self.obstacle_vertices:
            ox=obs_corner[0][0]
            oy=obs_corner[0][1]
            w=self.planner.scaling_factor
            h=self.planner.scaling_factor
            ax.add_patch(patches.Rectangle((ox,oy),w,h,edgecolor='black',facecolor='black',fill=True))

The graph generated is :

enter image description here

I think i am making a basic mistake in mapping matrix into a 2d environemnt

1
  • Please provide the data as code/text, not images.
    – jared
    Commented Mar 4 at 7:10

1 Answer 1

1

Your drawing has the origin in the top left but your code produces a plot with the origin in the bottom left. If you want it in the top left then you should flip (invert) the y-axis.

ax.invert_yaxis()
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.