Skip to content

Commit 0240106

Browse files
committed
use np to sample points
1 parent be24df9 commit 0240106

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

PathPlanning/TimeBasedPathPlanning/TimeBaseAStar.py

Whitespace-only changes.

PathPlanning/TimeBasedPathPlanning/moving_obstacles.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ def generate_dynamic_obstacle(self, obs_idx: int) -> list[np.ndarray[int, int]]:
4747
print("Obstacle initial position: ", initial_position)
4848

4949
diffs = [np.array([0, 1]), np.array([0, -1]), np.array([1, 0]), np.array([-1, 0]), np.array([0, 0])]
50+
weights = [0.125, 0.125, 0.125, 0.125, 0.5]
5051

5152
for t in range(1, self.time_limit-1):
52-
random.shuffle(diffs)
53+
rand_diffs = random.sample(diffs, k=5)
54+
5355
valid_position = None
54-
for diff in diffs:
56+
for diff in rand_diffs:
5557
new_position = positions[-1] + diff
5658

5759
if not self.valid_position(new_position, t):
@@ -119,7 +121,7 @@ def main():
119121
def get_frame(i):
120122
obs_x_points = []
121123
obs_y_points = []
122-
for (_obs_idx, obs_path) in enumerate(grid.obstacle_paths):
124+
for obs_path in grid.obstacle_paths:
123125
obs_pos = obs_path[i]
124126
obs_x_points.append(obs_pos[0])
125127
obs_y_points.append(obs_pos[1])

0 commit comments

Comments
 (0)