Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

planner_3d: fix cost calculation bug on in-place turning #725

Merged
merged 4 commits into from
Oct 31, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions planner_cspace/src/grid_astar_model_3dof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ float GridAstarModel3D::euclidCostRough(const Vec& v) const
float GridAstarModel3D::cost(
const Vec& cur, const Vec& next, const std::vector<VecWithCost>& start, const Vec& goal) const
{
if ((cm_[cur] > 99) || (cm_[next] > 99))
{
return -1;
}
Vec d_raw = next - cur;
d_raw.cycle(map_info_.angle);
const Vec d = d_raw;
Expand All @@ -168,18 +172,18 @@ float GridAstarModel3D::cost(
Vec pos = cur;
for (int i = 0; i < std::abs(d[2]); i++)
{
pos[2] += dir;
if (pos[2] < 0)
pos[2] += map_info_.angle;
else if (pos[2] >= static_cast<int>(map_info_.angle))
pos[2] -= map_info_.angle;
const auto c = cm_[pos];
if (c > 99)
return -1;
if (c >= cc_.turn_penalty_cost_threshold_)
{
sum += c;
}
pos[2] += dir;
if (pos[2] < 0)
pos[2] += map_info_.angle;
else if (pos[2] >= static_cast<int>(map_info_.angle))
pos[2] -= map_info_.angle;
}
const float turn_cost_ratio = cc_.weight_costmap_turn_ / 100.0;
const float turn_heuristic_cost_ratio =
Expand Down