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

perf(freespace_planning_algorithms): update the astar search algorithm #6526

Closed
wants to merge 3 commits into from

Conversation

4swinv
Copy link
Contributor

@4swinv 4swinv commented Mar 1, 2024

Description

The current A start implementation does not account for exploring opened nodes and only explores those with node status: None. Open nodes need to be explored based on a lower move_cost (gc+hc) than the gc cost of next node. A cost for turning move_cost_is_turn is also introduced to penalize turning over going straight in addition to cost for reversing.

A Priority Queue is used to store open nodes in the algorithm, but std::priority_queue does not give you the ability to update node parameters and it automatically resorts the queue. Queue resorting only happens on queue.push(node), when a new node is pushed into the queue. So as a work around instead of updating nodes (when algo wants to revisit open nodes), a new reference to the same node is instead pushed into the queue. This new reference pushed will always get popped out of the queue first due to its lesser cost, here its NodeStatus will be set to Closed. When the algorithm pops the old duplicate node left in the queue, a flag check whether its NodeStatus is Closed or not. If closed the node is discarded without processing.

Tests performed

The freespace_planning_algorithms/test/src/test_freespace_planning_algorithms.cpp tests were run to gauge the new astar trajectories generated. The new trajectories are found to be shorter, uses less fwd, back segments and were more smoother than previous ones. The algorithm now explores all open nodes, this leads to increased computation time but optimal paths are generated.

It was further found that by using curve weights, the amount of explored nodes drastically increases. But a smoother and much straighter optimal path is generated. To allow user to switch between using curve weights or not, also to switch between new complete astar and the old astar that only uses unexplored nodes, the following search configurations are introduced in freespace_planner.param.yaml:

use_curve_weight: true
use_complete_astar: true

The user can modify these parameters to balance path optimality and run time.
Comparison images between different configs are shown below for the tests:

image
image
image
image

Effects on system behavior

The astart search takes longer but finds the optimal path.

Pre-review checklist for the PR author

The PR author must check the checkboxes below when creating the PR.

In-review checklist for the PR reviewers

The PR reviewers must check the checkboxes below before approval.

Post-review checklist for the PR author

The PR author must check the checkboxes below before merging.

  • There are no open discussions or they are tracked via tickets.

After all checkboxes are checked, anyone who has write access can merge the PR.

@github-actions github-actions bot added the component:planning Route planning, decision-making, and navigation. (auto-assigned) label Mar 1, 2024
@4swinv 4swinv changed the title (perf): Update to astar search algorithm perf(astar search): Update to astar search algorithm Mar 1, 2024
@4swinv 4swinv changed the title perf(astar search): Update to astar search algorithm perf(astar_search): Update to astar search algorithm Mar 1, 2024
@maxime-clem maxime-clem changed the title perf(astar_search): Update to astar search algorithm perf(freespace_planning_algorithms): update the astar search algorithm Mar 1, 2024
@4swinv 4swinv force-pushed the update-astar-search branch from 4e9c5da to 77e3e4d Compare March 8, 2024 06:24
@github-actions github-actions bot added the type:documentation Creating or refining documentation. (auto-assigned) label Mar 8, 2024
Copy link

stale bot commented May 14, 2024

This pull request has been automatically marked as stale because it has not had recent activity.

@stale stale bot added the status:stale Inactive or outdated issues. (auto-assigned) label May 14, 2024
@stale stale bot removed the status:stale Inactive or outdated issues. (auto-assigned) label Dec 10, 2024
@xmfcx
Copy link
Contributor

xmfcx commented Dec 10, 2024

@takayuki5168 @mkquda hello,

@NorahXiong from AutoCore will take over this task, do you have anything to share on this PR?

@xmfcx
Copy link
Contributor

xmfcx commented Dec 11, 2024

@mkquda thanks for letting us know, I will close this PR then ✅

@xmfcx xmfcx closed this Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:planning Route planning, decision-making, and navigation. (auto-assigned) type:documentation Creating or refining documentation. (auto-assigned)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants