diff --git a/global_planner/src/gradient_path.cpp b/global_planner/src/gradient_path.cpp index 009febecfb..caf966c352 100644 --- a/global_planner/src/gradient_path.cpp +++ b/global_planner/src/gradient_path.cpp @@ -264,7 +264,7 @@ bool GradientPath::getPath(float* potential, double start_x, double start_y, dou // calculate gradient at a cell // positive value are to the right and down float GradientPath::gradCell(float* potential, int n) { - if (gradx_[n] + grady_[n] > 0.0) // check this cell + if (fabs(gradx_[n]) + fabs(grady_[n]) > 0.0) // check this cell return 1.0; if (n < xs_ || n > xs_ * ys_ - xs_) // would be out of bounds diff --git a/navfn/src/navfn.cpp b/navfn/src/navfn.cpp index 8b1fffcc3c..88e14b1be2 100644 --- a/navfn/src/navfn.cpp +++ b/navfn/src/navfn.cpp @@ -954,7 +954,7 @@ namespace navfn { float NavFn::gradCell(int n) { - if (gradx[n]+grady[n] > 0.0) // check this cell + if (fabs(gradx[n])+fabs(grady[n]) > 0.0) // check this cell return 1.0; if (n < nx || n > ns-nx) // would be out of bounds