diff --git a/global_planner/src/grid_path.cpp b/global_planner/src/grid_path.cpp index 3bf49e4d90..3b1a2eabcf 100644 --- a/global_planner/src/grid_path.cpp +++ b/global_planner/src/grid_path.cpp @@ -59,6 +59,8 @@ bool GridPath::getPath(float* potential, double start_x, double start_y, double if (xd == 0 && yd == 0) continue; int x = current.first + xd, y = current.second + yd; + if (x > xs_ || y > ys_ || x < 0 || y < 0) + continue; int index = getIndex(x, y); if (potential[index] < min_val) { min_val = potential[index];