PythonRobotics
PythonRobotics copied to clipboard
RRT* with reeds-sheep seems to produce illegal paths
Describe the bug Sometimes the path produced by RRT* with reeds-sheep script rrt_star_reeds_shepp.py seems not allowed: there are sharp corners in the path.
Expected behavior allowed path
Screenshots
Desktop (please complete the following information):
- Python version 3.8.10
Thank you. Can you share your code to reproduce the issue?
the code is rrt_star_reeds_shepp.py unmodified. However, this issue does not always appears, given the randomness of RRT, so I have to see if I manage to put a seed to the randomness to reproduce the problem. I'll let you know if I manage to do this.
so I managed to reproduce the issue using the script rrt_star_reeds_shepp.py and setting seed 8 after random import:
import random
random.seed(8)
I get this:
a detail
if you find a way to fix it let me know, thanks!
Please let me take this issue as part of my course project on SUSTech EEE5058.
I found that the direct reason for this unexpected result is the difference between the length of the node's x_list and yaw_list. So when you zip() lists with different lengths, the longer parts of the longer lists was discarded.
Noticed that in this random.seed(8) case, RRTStarReedsShepp.planning() gives 101 nodes (in self.node_list), and 21 of these nodes have different lengths on the node.x_list (or y_list) and the node.yaw_list. Some of these nodes' yaw_lists are longer than the corresponding x_lists, and in this case, it's fine since all the x and y can be zipped and plotted correctly. However, when the yaw_lists are shorter than the x_lists, some x and y are discarded by zip() so some points on the curve are missed in the final plot.
A simple way to get a good figure is to add elements to the yaw_list to make it as long as the x and y lists.
![Snipaste_2023-04-01_17-29-33](https://user-images.githubusercontent.com/39330401/229278795-7367266f-ffcd-486b-8595-d7b27b62717c.png)
![Snipaste_2023-04-01_17-38-51](https://user-images.githubusercontent.com/39330401/229278911-bbd484b2-0c05-47d5-bd67-219f6a9f191a.png)
Now I'm working on what makes the lengths of these lists different, and I will fix it soon.
Thank you. Your PR is welcome.