upper = index - width
if upper > 0:
if costmap[upper] < lethal_cost:
step_cost = orthogonal_step_cost + costmap[upper]/255
neighbors.append([upper, step_cost])
It doesn’t set upper = index + 1 ; instead, it calculates the upper index based on the width of the grid and after checks whether the calculated upper index is greater than 0. It ensures that the upper cell is within the bounds of the grid (assuming the index starts from 0).
I thought if index = 5, the upper shoud be 6, the left should be 12, top-left is 13, bottom left is 11, and do not have right, top-right and bottom-right?
Hi @NguyenDuyDuc,
Can you post the full code or the location in the course ? It would be easier to explain/understand with more context on the application.