Skip to content

Commit d5461f8

Browse files
committed
.
1 parent fa9d21d commit d5461f8

12 files changed

Lines changed: 80 additions & 80 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "python-motion-planning"
7-
version = "2.0"
7+
version = "2.0.1"
88
description = "Motion planning algorithms for Python"
99
maintainers = [
1010
{name = "Wu Maojia", email = "omige@mail.nwpu.edu.cn"},

src/python_motion_planning/path_planner/sample_search/rrt_star.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class RRTStar(RRT):
4646
>>> print(path_info['success'])
4747
True
4848
49-
>>> planner = RRTStar(map_=map_, start=(5, 5), goal=(10, 10), max_sample_step=100000, stop_func=lambda cur, fss, mss: (cur >= fss * 10 if fss is not None else False) or (cur >= mss))
49+
>>> planner = RRTStar(map_=map_, start=(5, 5), goal=(10, 10), max_sample_step=100000, stop_func=lambda current_step, first_success_step, max_step: (first_success_step is not None) or (current_step >= max_step))
5050
>>> path, path_info = planner.plan()
5151
>>> print(path_info['success'])
5252
True
@@ -55,7 +55,7 @@ class RRTStar(RRT):
5555
def __init__(self, *args,
5656
rewire_radius: float = None,
5757
gamma: float = 50.0,
58-
stop_func: callable = lambda cur, fs, sn: (fs is not None) or (cur >= sn),
58+
stop_func: callable = lambda current_step, first_success_step, max_step: (first_success_step is not None) or (current_step >= max_step),
5959
propagate_cost_to_children: bool = True,
6060
**kwargs) -> None:
6161
super().__init__(*args, **kwargs)

tutorials/2d/controller/path_tracker.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,18 @@ from python_motion_planning.controller import *
9292
map_ = Grid(bounds=[[0, 51], [0, 31]])
9393

9494
map_.fill_boundary_with_obstacles()
95-
map_.type_map[10:21, 15] = TYPES.OBSTACLE
96-
map_.type_map[20, :15] = TYPES.OBSTACLE
97-
map_.type_map[30, 15:] = TYPES.OBSTACLE
98-
map_.type_map[40, :16] = TYPES.OBSTACLE
95+
map_[10:21, 15] = TYPES.OBSTACLE
96+
map_[20, :15] = TYPES.OBSTACLE
97+
map_[30, 15:] = TYPES.OBSTACLE
98+
map_[40, :16] = TYPES.OBSTACLE
9999

100100
map_.inflate_obstacles(radius=3)
101101

102102
start = (5, 5)
103103
goal = (45, 25)
104104

105-
map_.type_map[start] = TYPES.START
106-
map_.type_map[goal] = TYPES.GOAL
105+
map_[start] = TYPES.START
106+
map_[goal] = TYPES.GOAL
107107

108108
planner = AStar(map_=map_, start=start, goal=goal)
109109
path, path_info = planner.plan()
@@ -159,18 +159,18 @@ from python_motion_planning.controller import *
159159
map_ = Grid(bounds=[[0, 51], [0, 31]])
160160

161161
map_.fill_boundary_with_obstacles()
162-
map_.type_map[10:21, 15] = TYPES.OBSTACLE
163-
map_.type_map[20, :15] = TYPES.OBSTACLE
164-
map_.type_map[30, 15:] = TYPES.OBSTACLE
165-
map_.type_map[40, :16] = TYPES.OBSTACLE
162+
map_[10:21, 15] = TYPES.OBSTACLE
163+
map_[20, :15] = TYPES.OBSTACLE
164+
map_[30, 15:] = TYPES.OBSTACLE
165+
map_[40, :16] = TYPES.OBSTACLE
166166

167167
map_.inflate_obstacles(radius=3)
168168

169169
start = (5, 5)
170170
goal = (45, 25)
171171

172-
map_.type_map[start] = TYPES.START
173-
map_.type_map[goal] = TYPES.GOAL
172+
map_[start] = TYPES.START
173+
map_[goal] = TYPES.GOAL
174174

175175
planner = AStar(map_=map_, start=start, goal=goal)
176176
path, path_info = planner.plan()

tutorials/2d/map/grid.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ After creating the grid map, we add some obstacles to it for testing the path pl
2727
```python
2828
map_ = Grid(bounds=[[0, 51], [0, 31]])
2929
map_.fill_boundary_with_obstacles()
30-
map_.type_map[10:21, 15] = TYPES.OBSTACLE
31-
map_.type_map[20, :15] = TYPES.OBSTACLE
32-
map_.type_map[30, 15:] = TYPES.OBSTACLE
33-
map_.type_map[40, :16] = TYPES.OBSTACLE
30+
map_[10:21, 15] = TYPES.OBSTACLE
31+
map_[20, :15] = TYPES.OBSTACLE
32+
map_[30, 15:] = TYPES.OBSTACLE
33+
map_[40, :16] = TYPES.OBSTACLE
3434
```
3535

3636
Visualize to check the map.
@@ -76,10 +76,10 @@ from python_motion_planning.controller import *
7676
map_ = Grid(bounds=[[0, 51], [0, 31]])
7777

7878
map_.fill_boundary_with_obstacles()
79-
map_.type_map[10:21, 15] = TYPES.OBSTACLE
80-
map_.type_map[20, :15] = TYPES.OBSTACLE
81-
map_.type_map[30, 15:] = TYPES.OBSTACLE
82-
map_.type_map[40, :16] = TYPES.OBSTACLE
79+
map_[10:21, 15] = TYPES.OBSTACLE
80+
map_[20, :15] = TYPES.OBSTACLE
81+
map_[30, 15:] = TYPES.OBSTACLE
82+
map_[40, :16] = TYPES.OBSTACLE
8383

8484
map_.inflate_obstacles(radius=3)
8585

tutorials/2d/path_planner/graph_search.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ goal = (45, 25)
88
Add the start and goal points to the map. This is to help the visualization of the start and goal points, and to clear obstacles at corresponding points to prevent planning failures.
99

1010
```python
11-
map_.type_map[start] = TYPES.START
12-
map_.type_map[goal] = TYPES.GOAL
11+
map_[start] = TYPES.START
12+
map_[goal] = TYPES.GOAL
1313
```
1414

1515
Create the path-planner and plan the path. Here, the A\* algorithm is taken as an example. The planning function returns the path in map frame along with detailed planning information, including whether it was successful, the length of the path, the cost of the path, expanded nodes, and so on.
@@ -55,18 +55,18 @@ from python_motion_planning.controller import *
5555
map_ = Grid(bounds=[[0, 51], [0, 31]])
5656

5757
map_.fill_boundary_with_obstacles()
58-
map_.type_map[10:21, 15] = TYPES.OBSTACLE
59-
map_.type_map[20, :15] = TYPES.OBSTACLE
60-
map_.type_map[30, 15:] = TYPES.OBSTACLE
61-
map_.type_map[40, :16] = TYPES.OBSTACLE
58+
map_[10:21, 15] = TYPES.OBSTACLE
59+
map_[20, :15] = TYPES.OBSTACLE
60+
map_[30, 15:] = TYPES.OBSTACLE
61+
map_[40, :16] = TYPES.OBSTACLE
6262

6363
map_.inflate_obstacles(radius=3)
6464

6565
start = (5, 5)
6666
goal = (45, 25)
6767

68-
map_.type_map[start] = TYPES.START
69-
map_.type_map[goal] = TYPES.GOAL
68+
map_[start] = TYPES.START
69+
map_[goal] = TYPES.GOAL
7070

7171
planner = AStar(map_=map_, start=start, goal=goal)
7272
path, path_info = planner.plan()

tutorials/2d/path_planner/hybrid_search.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ Print results:
1616
Visualize.
1717
```python
1818
if "voronoi_candidates" in path_info:
19-
map_.type_map[path_info["voronoi_candidates"]] = TYPES.CUSTOM
20-
map_.type_map[start] = TYPES.START
21-
map_.type_map[goal] = TYPES.GOAL
19+
map_[path_info["voronoi_candidates"]] = TYPES.CUSTOM
20+
map_[start] = TYPES.START
21+
map_[goal] = TYPES.GOAL
2222

2323
vis = Visualizer2D()
2424
vis.plot_grid_map(map_)
@@ -45,27 +45,27 @@ from python_motion_planning.controller import *
4545
map_ = Grid(bounds=[[0, 51], [0, 31]])
4646

4747
map_.fill_boundary_with_obstacles()
48-
map_.type_map[10:21, 15] = TYPES.OBSTACLE
49-
map_.type_map[20, :15] = TYPES.OBSTACLE
50-
map_.type_map[30, 15:] = TYPES.OBSTACLE
51-
map_.type_map[40, :16] = TYPES.OBSTACLE
48+
map_[10:21, 15] = TYPES.OBSTACLE
49+
map_[20, :15] = TYPES.OBSTACLE
50+
map_[30, 15:] = TYPES.OBSTACLE
51+
map_[40, :16] = TYPES.OBSTACLE
5252

5353
map_.inflate_obstacles(radius=3)
5454

5555
start = (5, 5)
5656
goal = (45, 25)
5757

58-
map_.type_map[start] = TYPES.START
59-
map_.type_map[goal] = TYPES.GOAL
58+
map_[start] = TYPES.START
59+
map_[goal] = TYPES.GOAL
6060

6161
planner = VoronoiPlanner(map_=map_, start=start, goal=goal, base_planner=AStar)
6262
path, path_info = planner.plan()
6363
print(path)
6464
print(path_info)
6565
if "voronoi_candidates" in path_info:
66-
map_.type_map[path_info["voronoi_candidates"]] = TYPES.CUSTOM
67-
map_.type_map[start] = TYPES.START
68-
map_.type_map[goal] = TYPES.GOAL
66+
map_[path_info["voronoi_candidates"]] = TYPES.CUSTOM
67+
map_[start] = TYPES.START
68+
map_[goal] = TYPES.GOAL
6969

7070
vis = Visualizer2D()
7171
vis.plot_grid_map(map_)

tutorials/2d/path_planner/sample_search.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ from python_motion_planning.controller import *
4141
map_ = Grid(bounds=[[0, 51], [0, 31]])
4242

4343
map_.fill_boundary_with_obstacles()
44-
map_.type_map[10:21, 15] = TYPES.OBSTACLE
45-
map_.type_map[20, :15] = TYPES.OBSTACLE
46-
map_.type_map[30, 15:] = TYPES.OBSTACLE
47-
map_.type_map[40, :16] = TYPES.OBSTACLE
44+
map_[10:21, 15] = TYPES.OBSTACLE
45+
map_[20, :15] = TYPES.OBSTACLE
46+
map_[30, 15:] = TYPES.OBSTACLE
47+
map_[40, :16] = TYPES.OBSTACLE
4848

4949
map_.inflate_obstacles(radius=3)
5050

5151
start = (5, 5)
5252
goal = (45, 25)
5353

54-
map_.type_map[start] = TYPES.START
55-
map_.type_map[goal] = TYPES.GOAL
54+
map_[start] = TYPES.START
55+
map_[goal] = TYPES.GOAL
5656

5757
planner = RRT(map_=map_, start=start, goal=goal)
5858
path, path_info = planner.plan()
@@ -84,10 +84,10 @@ Print results:
8484
For asymptoticaly optimal sample search planners like **RRT\***, you can pass a callable function to argument `stop_func` to determine when to stop sampling. For example:
8585

8686
```python
87-
planner = RRTStar(map_=map_, start=start, goal=goal, stop_func=lambda cur, fss, mss: (cur >= fss * 10 if fss is not None else False) or (cur >= mss))
87+
planner = RRTStar(map_=map_, start=start, goal=goal, stop_func=lambda current_step, first_success_step, max_step: (current_step >= first_success_step * 10 if first_success_step is not None else False) or (current_step >= max_step))
8888
```
8989

90-
For the arguments of `stop_func`, `cur` means the **cur**rent step iteration, `fss` means the **f**irst **s**uccessful **s**tep to find the feasible path, and `mss` means the **m**aximum **s**ampling **s**tep number determined by `max_sample_step` argument. This lambda function means to stop sampling when the number of sampling steps reaches 10 times the number of steps successfully found a feasible path for the first time.
90+
For the arguments of `stop_func`, `current_step` means the current step iteration, `first_success_step` means the first successful step to find the feasible path, and `max_step` means the maximum sampling step number determined by `max_sample_step` argument. This lambda function means to stop sampling when the number of sampling steps reaches 10 times the number of steps successfully found a feasible path for the first time.
9191

9292
![rrt_star_2d.svg](../../../assets/rrt_star_2d.svg)
9393

tutorials/2d/traj_optimizer/curve_generator.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,18 @@ from python_motion_planning.traj_optimizer import *
7070
map_ = Grid(bounds=[[0, 51], [0, 31]])
7171

7272
map_.fill_boundary_with_obstacles()
73-
map_.type_map[10:21, 15] = TYPES.OBSTACLE
74-
map_.type_map[20, :15] = TYPES.OBSTACLE
75-
map_.type_map[30, 15:] = TYPES.OBSTACLE
76-
map_.type_map[40, :16] = TYPES.OBSTACLE
73+
map_[10:21, 15] = TYPES.OBSTACLE
74+
map_[20, :15] = TYPES.OBSTACLE
75+
map_[30, 15:] = TYPES.OBSTACLE
76+
map_[40, :16] = TYPES.OBSTACLE
7777

7878
map_.inflate_obstacles(radius=3)
7979

8080
start = (5, 5)
8181
goal = (45, 25)
8282

83-
map_.type_map[start] = TYPES.START
84-
map_.type_map[goal] = TYPES.GOAL
83+
map_[start] = TYPES.START
84+
map_[goal] = TYPES.GOAL
8585

8686
planner = ThetaStar(map_=map_, start=start, goal=goal)
8787
path, path_info = planner.plan()
@@ -162,18 +162,18 @@ from python_motion_planning.traj_optimizer import *
162162
map_ = Grid(bounds=[[0, 51], [0, 31]])
163163

164164
map_.fill_boundary_with_obstacles()
165-
map_.type_map[10:21, 15] = TYPES.OBSTACLE
166-
map_.type_map[20, :15] = TYPES.OBSTACLE
167-
map_.type_map[30, 15:] = TYPES.OBSTACLE
168-
map_.type_map[40, :16] = TYPES.OBSTACLE
165+
map_[10:21, 15] = TYPES.OBSTACLE
166+
map_[20, :15] = TYPES.OBSTACLE
167+
map_[30, 15:] = TYPES.OBSTACLE
168+
map_[40, :16] = TYPES.OBSTACLE
169169

170170
map_.inflate_obstacles(radius=3)
171171

172172
start = (5, 5)
173173
goal = (45, 25)
174174

175-
map_.type_map[start] = TYPES.START
176-
map_.type_map[goal] = TYPES.GOAL
175+
map_[start] = TYPES.START
176+
map_[goal] = TYPES.GOAL
177177

178178
planner = ThetaStar(map_=map_, start=start, goal=goal)
179179
path, path_info = planner.plan()

tutorials/3d/map/grid.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ After creating the grid map, we add some obstacles to it for testing the path pl
2828
map_ = Grid(bounds=[[0, 31], [0, 31], [0, 31]], resolution=1.0)
2929
for i in range(75): # 75 random obstacles
3030
rd_p = tuple(np.random.randint(0, 30, size=3))
31-
map_.type_map[rd_p[0], rd_p[1], :rd_p[2]] = TYPES.OBSTACLE
31+
map_[rd_p[0], rd_p[1], :rd_p[2]] = TYPES.OBSTACLE
3232
map_.inflate_obstacles(radius=3)
3333
```
3434

@@ -59,7 +59,7 @@ from python_motion_planning.controller import *
5959
map_ = Grid(bounds=[[0, 31], [0, 31], [0, 31]], resolution=1.0)
6060
for i in range(75):
6161
rd_p = tuple(np.random.randint(0, 30, size=3))
62-
map_.type_map[rd_p[0], rd_p[1], :rd_p[2]] = TYPES.OBSTACLE
62+
map_[rd_p[0], rd_p[1], :rd_p[2]] = TYPES.OBSTACLE
6363
map_.inflate_obstacles(radius=3)
6464

6565
vis = Visualizer3D()

tutorials/3d/path_planner/graph_search.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ goal = (5, 25, 25)
77

88
Add the start and goal points to the map. This is to help the visualization of the start and goal points, and to clear obstacles at corresponding points to prevent planning failures.
99
```python
10-
map_.type_map[start] = TYPES.START
11-
map_.type_map[goal] = TYPES.GOAL
10+
map_[start] = TYPES.START
11+
map_[goal] = TYPES.GOAL
1212
```
1313

1414
Create the path-planner and plan the path. Here, the A\* algorithm is taken as an example. The planning function returns the path in map frame along with detailed planning information, including whether it was successful, the length of the path, the cost of the path, expanded nodes, and so on.
@@ -54,14 +54,14 @@ from python_motion_planning.controller import *
5454
map_ = Grid(bounds=[[0, 31], [0, 31], [0, 31]], resolution=1.0)
5555
for i in range(75):
5656
rd_p = tuple(np.random.randint(0, 30, size=3))
57-
map_.type_map[rd_p[0], rd_p[1], :rd_p[2]] = TYPES.OBSTACLE
57+
map_[rd_p[0], rd_p[1], :rd_p[2]] = TYPES.OBSTACLE
5858
map_.inflate_obstacles(radius=3)
5959

6060
start = (25, 5, 5)
6161
goal = (5, 25, 25)
6262

63-
map_.type_map[start] = TYPES.START
64-
map_.type_map[goal] = TYPES.GOAL
63+
map_[start] = TYPES.START
64+
map_[goal] = TYPES.GOAL
6565

6666
planner = AStar(map_=map_, start=start, goal=goal)
6767
path, path_info = planner.plan()

0 commit comments

Comments
 (0)