Skip to content

Conversation

guilyx
Copy link
Contributor

@guilyx guilyx commented Apr 10, 2020

Implement Bidirectional A* algorithm. (two A* searching for the last node added to the other's closed set).

Copy link
Owner

@AtsushiSakai AtsushiSakai left a comment

Choose a reason for hiding this comment

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

Thanks great example. PTAL


c_id_A = min(
open_set_A,
key=lambda o: open_set_A[o].cost + self.calc_heuristic(current_B,
Copy link
Owner

Choose a reason for hiding this comment

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

Readability is not good a little bit, can you make a function to calc a final cost?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it okay ?


c_id_B = min(
open_set_B,
key=lambda o: open_set_B[o].cost + self.calc_heuristic(current_A,
Copy link
Owner

Choose a reason for hiding this comment

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

Same upper comment.


child_node_B = self.Node(current_B.x + self.motion[i][0],
current_B.y + self.motion[i][1],
current_B.cost + self.motion[i][2], c_id_B)
Copy link
Owner

Choose a reason for hiding this comment

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

Same upper comment.

if n_id_B in closed_set_B:
continue_B = True

if not(continue_A):
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
if not(continue_A):
if not continue_A:


if not(continue_A):
if n_id_A not in open_set_A:
open_set_A[n_id_A] = child_node_A # discovered a new node
Copy link
Owner

Choose a reason for hiding this comment

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

pep8 too long line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops forgot to parse with autopep8, done now.

# This path is the best until now. record it
open_set_A[n_id_A] = child_node_A

if not(continue_B):
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
if not(continue_B):
if not continue_B:


if not(continue_B):
if n_id_B not in open_set_B:
open_set_B[n_id_B] = child_node_B # discovered a new node
Copy link
Owner

Choose a reason for hiding this comment

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

pep8 too long line.

Copy link
Owner

@AtsushiSakai AtsushiSakai left a comment

Choose a reason for hiding this comment

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

PTAL

grid_size = 2.0 # [m]
robot_radius = 1.0 # [m]

# set obstable positions
Copy link
Owner

Choose a reason for hiding this comment

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

obstacle?


child_node_A = self.Node(current_A.x + self.motion[i][0],
current_A.y + self.motion[i][1],
current_A.cost + self.motion[i][2], c_id_A)
Copy link
Owner

Choose a reason for hiding this comment

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

pep8 error.

Could you move the the last "c_id_A" to the next line?


child_node_B = self.Node(current_B.x + self.motion[i][0],
current_B.y + self.motion[i][1],
current_B.cost + self.motion[i][2], c_id_B)
Copy link
Owner

Choose a reason for hiding this comment

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

Same as upper comment.


return rx, ry

def calc_final_path_bidir(self, meetnode_A, meetnode_B, closed_set_A, closed_set_B):
Copy link
Owner

Choose a reason for hiding this comment

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

calc_final_bidirectional_path?

@AtsushiSakai
Copy link
Owner

@guilyx Thank you so much!! LGTM. I will merge it.

@AtsushiSakai AtsushiSakai merged commit 084c862 into AtsushiSakai:master Apr 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants