From 0884b35b9029f97495951d075aeeafa32fb2c951 Mon Sep 17 00:00:00 2001 From: TangYu Date: Wed, 6 Jul 2022 20:22:27 +0800 Subject: [PATCH 1/2] gradient_path: the gradx_ and grady_ can be negative, so we check the sum value gt 0 is meaningless --- global_planner/src/gradient_path.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From da3526043c791bf51a9630b93248b095a09d3d03 Mon Sep 17 00:00:00 2001 From: TangYu Date: Wed, 6 Jul 2022 21:11:09 +0800 Subject: [PATCH 2/2] navfn: see commit 0884b35 gradx_ and grady_ can be negative --- navfn/src/navfn.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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