-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
brand new implementation: full numpy
- Loading branch information
Showing
7 changed files
with
203 additions
and
443 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,60 @@ | ||
# Rapidly-exploring Random Tree | ||
|
||
 | ||
 | ||
|
||
## Introduction | ||
|
||
In this repository, I propose a python implementation of the Rapidly-exploring Random Tree. | ||
In this repository, I propose a python implementation of the Rapidly-exploring Random Tree. It is a very powerful (brute-forcing) algorithm for navigating in cluttered environments. | ||
|
||
The development of this code was influenced by the following articles: | ||
* the original paper by Steven M. Lavalle named *Rapidly-Exploring Random Trees: A New Tool for Path Planning.* | ||
* [the original paper by Steven M. Lavalle](https://msl.cs.illinois.edu/~lavalle/papers/Lav98c.pdf): *Rapidly-Exploring Random Trees: A New Tool for Path Planning.* | ||
* the second paper by J.J. Kuffner and S.M. LaValle. *RRT-connect: An efficient approach to single-query path planning* | ||
* [the rrt article on wikipedia](https://en.wikipedia.org/wiki/Rapidly-exploring_random_tree) | ||
|
||
### Features | ||
|
||
This implementation features both the single and the dual RRT search. The results are nicely plotted with mathplotlib. | ||
Moreover, this RRT program has a "crude" path shortening function (named optimizedPath) and a smoothing function (smoothPath). | ||
The latter making use of the Bézier curve in order to find a infinitely differentiable path ! | ||
|
||
### Output | ||
|
||
The RRT computations are presented below for problems of dimension 2 and 3, respectively. | ||
|
||
 | ||
|
||
 | ||
## Requirements | ||
|
||
This implementation only requires 2 libraries: numpy and matplotlib! | ||
|
||
## How to use it | ||
|
||
* In an "out of the box" fashion | ||
|
||
```python | ||
import numpy as np | ||
from rrt import SingleRRT | ||
|
||
if __name__=='__main__': | ||
# 1. Choose dimension of the problem. | ||
# 1. Choose dimension of the problem, start and target configurations. | ||
N = 2 | ||
# 2. Instantiate the RRT object with N, you may indicate the start and the goal configurations. | ||
r = RRT(N, start=-0.75*np.ones(N), goal=0.75*np.ones(N)) | ||
# 3. Run the RRT planner (the default one uses bidirectional search) | ||
r.runRRT(mode='dual') | ||
# 4. Plot the results | ||
r.plot() | ||
start = np.random.rand(N) | ||
goal = np.random.rand(N) | ||
|
||
# 2. Instantiate the RRT object. | ||
r = SingleRRT(N, start, goal) | ||
r.run() | ||
|
||
# 3. Plot the results if in dimension 2 | ||
if N==2: | ||
r.plot() | ||
``` | ||
|
||
* In a more sophisticated fasion | ||
The code can easily be extended to more complex obstacles. For this, the user will need to override the obstacle generation method as well as the collision detection. | ||
|
||
## Use cases | ||
|
||
You'll have to set the collision detection function according to your need. In this implementation, I am using a random obstacle generator and for detecting a collision, the program loops over all obstacles. A faster and more reliable implementation of the collision detection can be achieved using a simulation like Pybullet. | ||
Many use cases exist for this planner: car parking, maze escaping. | ||
|
||
This planner can also be used with robotic manipulators. I successfully used it on a KUKA iiwa7 robot. For this, the RRT was conducted in the joint space of the robot while the collision detection was done in the task space. I used a pybullet simulator embedding the robot and the obstacles conduct the collision detection. | ||
|
||
The path processing functions (optimizePath, smoothPath) are not optimal yet and should definitely be improved. | ||
|
||
## Remarks | ||
|
||
I strongly recommend you to take a look at the papers cited above to get an intuition of the algorithm. | ||
I recommend to take a look at the papers cited above to get an intuition of the algorithm. | ||
|
||
As the output of RRT is very chaotic due to the random sampling in the search space, one needs to post-process it. In this implementation, I don't propose such post-processing function. Users can have a look at the Shortcutting algorithm (see [osrobotics](https://www.osrobotics.org/osr/planning/post_processing.html)). | ||
|
||
As the output of RRT is very chaotic due to the random sampling in the search space, one needs to post-process it. In this implementation, I am using a custom function to remove unnecessary points while taking care of the obstacle avoidance requirement. For a better result, one might want to make use of the Shortcutting algorithm (see [osrobotics](https://www.osrobotics.org/osr/planning/post_processing.html)). I also implemented a path-smoothing function using a Bézier curve of order n where n is the number of points in the path. | ||
All of this works well for high dimensional problems. However, the plotting function won't work anymore. | ||
|
||
All of this works well for high dimensional problems. However, the plotting function won't work anymore :) | ||
|
||
*Note : This planner can easily be used with robotic manipulators. I successfully used it on a KUKA iiwa7 robot. For this, the RRT was conducted in the joint space of the robot while the collision detection was done in the task space. I used the PyBullet simulator with an urdf file of my robot. The plotting function was slightly modified to project the Tool-Center-Point of the robot with the help of the forward kinematics.* | ||
## License | ||
|
||
Distributed under the MIT License. See the [license](LICENSE) for more information. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import numpy as np | ||
|
||
from rrt import SingleRRT | ||
|
||
|
||
if __name__ == "__main__": | ||
N = 2 | ||
start = 3 * (np.random.rand(2) - 0.5) | ||
goal = 3 * (np.random.rand(2) - 0.5) | ||
|
||
r = SingleRRT(N, start, goal) | ||
r.run() | ||
|
||
if N == 2: | ||
r.plot() |
Oops, something went wrong.