Skip to content
Open
Changes from all commits
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
9 changes: 3 additions & 6 deletions nav2_smac_planner/src/node_hybrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,6 @@ float NodeHybrid::getTraversalCost(const NodePtr & child)
"cost without a known SE2 collision cost!");
}

// this is the first node
if (getMotionPrimitiveIndex() == std::numeric_limits<unsigned int>::max()) {
return NodeHybrid::travel_distance_cost;
}

const TurnDirection & child_turn_dir = child->getTurnDirection();
float travel_cost_raw = motion_table.travel_costs[child->getMotionPrimitiveIndex()];
float travel_cost = 0.0;
Expand All @@ -419,7 +414,9 @@ float NodeHybrid::getTraversalCost(const NodePtr & child)
// New motion is a straight motion, no additional costs to be applied
travel_cost = travel_cost_raw;
} else {
if (getTurnDirection() == child_turn_dir) {
if (getTurnDirection() == child_turn_dir ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should implement this as Matt suggested in

Otherwise we could move the first node check to https://github.com/ros-navigation/navigation2/blob/main/nav2_smac_planner/src/node_hybrid.cpp#L418 so that we don't apply any turning or change penalties on the first expansion.

getMotionPrimitiveIndex() == std::numeric_limits<unsigned int>::max())
{
// Turning motion but keeps in same direction: encourages to commit to turning if starting it
travel_cost = travel_cost_raw * motion_table.non_straight_penalty;
} else {
Expand Down
Loading