zm0612 / Hybrid_A_Star

Hybrid A Star algorithm C++ implementation
Other
670 stars 139 forks source link

Current implementation only starts planning a new path once old path is complete #12

Closed jashshah999 closed 4 months ago

jashshah999 commented 1 year ago

Hi,

The current implementation only starts planning the next path once the previous path is complete. In my implementation, I want to make sure that if I give a start and goal; it should plan from that start to the goal. Then, if in between I give another start and goal, the car should jump to the new start and then start planning to the new goal and so on. It should not do it from the start position and only when the previous path is complete. Is it possible with the current implementation? Please reply.

Thank you.

zm0612 commented 1 year ago

Hello, Let me repeat your question. You want real-time trajectory planning during the actual movement of the robot. The robot starts from point A and goes to point B. Maybe on the way to point B, you change the target point. At this time, plan the trajectory from the current position of the robot to the new target point.

My code cannot directly support this requirement. You need to make some changes, but I can guarantee that this change is not much. First, you need an additional positioning program, which can feedback the robot's position in real time, and then my hybrid a star receives The real-time position of the robot and the target point of movement. The code you need to modify is all in https://github.com/zm0612/Hybrid_A_Star/blob/777a2237be86b01e4e5ae2a79ed4630de7a0285b/src/hybrid_a_star_flow.cpp#L113C30-L113C41.

jashshah999 commented 1 year ago

Hi,

Thank you for your prompt response. That makes sense. I think the question you repeated is correct. Could you guide me more on what exactly I need to change for this? I get the robot pose on a certain topic. Lets assume this topic is of type PosewithCovariance. How do I incorporate this and what exactly do I have to change in the Hybrid A Star flow code?

zm0612 commented 1 year ago

After you have the topic of the robot's real-time position, you first need to write a callback function to subscribe to the robot's position, and then you also need to write a callback function to subscribe to the target position you want the robot to reach, and then put the robot Fill in the current position in this line https://github.com/zm0612/Hybrid_A_Star/blob/777a2237be86b01e4e5ae2a79ed4630de7a0285b/src/hybrid_a_star_flow.cpp#L119 and the target position in this line https://github.com/zm0612/Hybrid_A_Star/blob/777a2237be86b01e4e5ae2a79ed4630de7a0285b/src/hybrid_a_star_flow.cpp#L124 In addition, you may need to make some minor modifications, for example, you need to load your own map. Modify here https://github.com/zm0612/Hybrid_A_Star/blob/777a2237be86b01e4e5ae2a79ed4630de7a0285b/src/hybrid_a_star_flow.cpp#L77

In general, you don't need to modify the core search algorithm of hybrid a star. You only need to modify the calling method according to your own needs.

jashshah999 commented 1 year ago

Cool, I will try this and get back to you. Are there any other specific changes that you think might be required to do the real-time start and goal point update?

dhaneshpamnani commented 1 year ago

Hi, I am on the same team, I have created the new map and found that in hybrid_a_star_flow.cpp if we do not comment out line 136 to line 175, then the visualization of the car moving from point A to B acts as a blocker to kinodynamic_astar_searcherptr->Reset(); Is this understanding correct to be able to run this real time ?

Also, I wanted to understand why the subscriber is written in hybrid_a_star_flow.cpp and not in run_hybrid_astar.cpp> I want to run the planner only when it receives the current and goal points and not at a constant 10Hz rate. What modifications would be required for that? Would the run_hybrid_astar.cpp need to be changed and the kinodynamic_astar_flow.Run() function to take in arguments for the current and goal pose to fill it in the lines you suggested above ?

Thank you for the help

jashshah999 commented 1 year ago

Hi @zm0612. Please ignore the previous questions; we are able to do it in real-time. One other question we had was - can we remove the reverse function. We tried increasing the reversing penalty a lot but the car still takes reverse. We want to make sure that whenever a reverse path is given, either a flag is raised or the car stops. If this is possible in the current implementation, please let me know, thank you.

Regards, Jash Shah

zm0612 commented 1 year ago

hello, my friend.

If you want to turn off the reverse function, first you need to comment out the code for backward search. https://github.com/zm0612/Hybrid_A_Star/blob/777a2237be86b01e4e5ae2a79ed4630de7a0285b/src/hybrid_a_star.cpp#L389C1-L413C10

In addition, you also need to comment out the backward search function of the reed sheep curve to degenerate it into a dubin curve. https://github.com/zm0612/Hybrid_A_Star/blob/777a2237be86b01e4e5ae2a79ed4630de7a0285b/src/rs_path.cpp#L133C1-L135C28

The above two-step operation can make the vehicle have no reversing function at all.

jashshah999 commented 1 year ago

Hi,

I did comment the above but the car is still moving in reverse. I can share screen recordings if necessary but it is still moving backwards. Is there something else I am missing to remove this backward functionality?

zm0612 commented 1 year ago

After testing, I did find that there is reversing. This is mainly because the reed sheep algorithm includes reversing, but this algorithm has been written for a long time. I can’t remember the details of the reed sheep algorithm. I tried to let You commented out lines:

https://github.com/zm0612/Hybrid_A_Star/blob/777a2237be86b01e4e5ae2a79ed4630de7a0285b/src/rs_path.cpp#L133C1-L135C28

but it seems that it still contains the reverse situation. Maybe you can try to comment out part of the code in the function of lines 131-132 first, which can degenerate it into a dubin curve, but I can't remember exactly which lines to comment. I need some time to re-familiarize myself with the reed sheep algorithm.