mit-acl / gym-collision-avoidance

MIT License
242 stars 74 forks source link

is the function world_coordinates_to_map_indices in Map is right? #9

Closed anlanxuan closed 2 years ago

anlanxuan commented 3 years ago

def world_coordinates_to_map_indices(self, pos):

for a single [px, py] -> [gx, gy]

    gx = int(np.floor(self.origin_coords[0]-pos[1]/self.grid_cell_size))
    gy = int(np.floor(self.origin_coords[1]+pos[0]/self.grid_cell_size))
    grid_coords = np.array([gx, gy])
    in_map = gx >= 0 and gy >= 0 and gx < self.map.shape[0] and gy < self.map.shape[1]
    return grid_coords, in_map

i think that the gx = int(np.floor(pos[0]/self.grid_cell_size-self.origin_coords[0])) the gy = int(np.floor(pos[1]/self.grid_cell_size-self.origin_coords[1])) is that right? or I don't understand the world_coordinates_to_map_indices?

mfe7 commented 3 years ago

good question, i don't remember exactly the thought process here. it's supposed to take in a (px, py) position in the xy-plane, and map that to the coordinates in the 2d gridmap, only necessary if you want to use the laserscan or occupancygrid sensors, which haven't been extensively debugged/tested (i typically only use the OtherAgentsStatesSensor). if your logic is indeed correct, i'd welcome a pull request :)