Skip to content

Commit 45811d5

Browse files
committed
Fix missing cost consideration in first expansion of SmacPlannerHybrid (#5626)
Signed-off-by: wang-fire <[email protected]>
1 parent d536d33 commit 45811d5

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

nav2_smac_planner/src/node_hybrid.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,6 @@ float NodeHybrid::getTraversalCost(const NodePtr & child)
397397
"cost without a known SE2 collision cost!");
398398
}
399399

400-
// this is the first node
401-
if (getMotionPrimitiveIndex() == std::numeric_limits<unsigned int>::max()) {
402-
return NodeHybrid::travel_distance_cost;
403-
}
404-
405400
const TurnDirection & child_turn_dir = child->getTurnDirection();
406401
float travel_cost_raw = motion_table.travel_costs[child->getMotionPrimitiveIndex()];
407402
float travel_cost = 0.0;
@@ -419,7 +414,9 @@ float NodeHybrid::getTraversalCost(const NodePtr & child)
419414
// New motion is a straight motion, no additional costs to be applied
420415
travel_cost = travel_cost_raw;
421416
} else {
422-
if (getTurnDirection() == child_turn_dir) {
417+
if (getTurnDirection() == child_turn_dir ||
418+
getMotionPrimitiveIndex() == std::numeric_limits<unsigned int>::max())
419+
{
423420
// Turning motion but keeps in same direction: encourages to commit to turning if starting it
424421
travel_cost = travel_cost_raw * motion_table.non_straight_penalty;
425422
} else {

0 commit comments

Comments
 (0)