Skip to content
Closed
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
fc56a30
Without equals sign, sometimes get points that are in the wrong direc…
SchwartzCode Jun 29, 2021
64ca35e
Created test script for dubins path generator
SchwartzCode Jun 29, 2021
e02ec7d
Made len == 0 it's own case, also changed 'l' to 'len' to appease tra…
SchwartzCode Jun 30, 2021
1f179f0
Merge branch 'AtsushiSakai:master' into dubins_path_bug_fix
Jun 30, 2021
80991d0
More variable renaming to appease CI
SchwartzCode Jun 30, 2021
f6b99fd
Broke == 0 into its own case in dubins planner, also Renaming files t…
SchwartzCode Jun 30, 2021
f0b8fda
Merge branch 'dubins_path_bug_fix' of https://github.com/SchwartzCode…
SchwartzCode Jun 30, 2021
eddba93
Reverting some naming changes
SchwartzCode Jun 30, 2021
30df7e8
Turns out theres already a test for dubins.. not sure how I missed that
SchwartzCode Jun 30, 2021
5977869
Note to self: run the test cases on your own before throwing them at CI
SchwartzCode Jun 30, 2021
b5405b7
Merged commits incorrectly
SchwartzCode Jul 1, 2021
ba86afd
Added handling of length=0 case in generate_local_course()
SchwartzCode Jul 1, 2021
3765bb1
Silly merge conflict
SchwartzCode Jul 1, 2021
1c7038a
Merge branch 'AtsushiSakai-master'
SchwartzCode Jul 1, 2021
c0d3d36
Missed reverting 'mode' back to 'm' in one spot
SchwartzCode Jul 1, 2021
831c2aa
Addressing style issues (line length)
SchwartzCode Jul 1, 2021
d5b4361
Mostly works, now just need to setup linear regression to solve for w…
SchwartzCode Jul 7, 2021
e3f9a9d
Re-arranged class
SchwartzCode Jul 7, 2021
dd94aaf
Wrote DMP program and added tests file
SchwartzCode Jul 8, 2021
00319b3
Merge branch 'AtsushiSakai:master' into master
Jul 8, 2021
732560b
Styling fixes
SchwartzCode Jul 8, 2021
a366216
Merge branch 'master' of https://github.com/SchwartzCode/PythonRobotics
SchwartzCode Jul 8, 2021
a7b5e25
More styling
SchwartzCode Jul 8, 2021
c2ca3f0
Missed one indent
SchwartzCode Jul 8, 2021
4372e74
Multi-dimension path learning (e.g. in x and y instead of just x)
SchwartzCode Jul 18, 2021
3ca74cb
Added potential field obstacle avoidance
SchwartzCode Jul 18, 2021
29bdb15
Potential field working much better but has issues with reaching goal…
SchwartzCode Jul 19, 2021
9e63e6d
Path ending to short not a result of obstacles, should be fix-able
SchwartzCode Jul 20, 2021
d99c34a
Mostly working! end won't go to goal
SchwartzCode Jul 22, 2021
910498b
split DMP and path following
SchwartzCode Jul 22, 2021
85d9528
pretty close
SchwartzCode Jul 23, 2021
6afbcf7
Okay this is working pretty well
SchwartzCode Jul 25, 2021
5f0aeed
looks.. okay. was using the wrong vector before
SchwartzCode Jul 26, 2021
1439b4e
a plan to fix this mess
SchwartzCode Jul 26, 2021
2defd14
Okay seriously going to pivot to the dubins approach im done with pot…
SchwartzCode Jul 27, 2021
db79626
Finished obstacle circle handling (and merging circles that are close…
SchwartzCode Jul 30, 2021
28fbc08
Finished circle event finder function
SchwartzCode Aug 5, 2021
d3b1694
Some progress in preparing for dubins curves
SchwartzCode Aug 11, 2021
b00812c
Finished angle finding algo, need to test
SchwartzCode Aug 12, 2021
6ab4a42
Okay getting back to this, going to ignore the navigation and just fo…
SchwartzCode Sep 14, 2021
43a3f65
Moved DMP files to path planning
SchwartzCode Oct 1, 2021
dc75fa7
changed folder name
SchwartzCode Oct 1, 2021
846fc47
Made demo path cooler
SchwartzCode Oct 1, 2021
5ad64e0
All working and added visualization tools (will remove
SchwartzCode Oct 8, 2021
74c0dd6
Fixed unit test and handled TODOs
SchwartzCode Oct 8, 2021
4d92252
not gonna handle this one
SchwartzCode Oct 8, 2021
6848da5
Merge branch 'AtsushiSakai:master' into master
Oct 25, 2021
300ff13
Merge branch 'master' of github.com:SchwartzCode/PythonRobotics
SchwartzCode Oct 25, 2021
3fab1d9
demo now scales with data
SchwartzCode Oct 25, 2021
c18242e
CI errors
SchwartzCode Oct 25, 2021
9fefe20
CI errors
SchwartzCode Oct 25, 2021
ae50183
Fixing code style issues
SchwartzCode Oct 25, 2021
c61b9b0
more styling
SchwartzCode Oct 25, 2021
342dc25
fixing CI errors
SchwartzCode Oct 25, 2021
fc6f5b0
formatting
SchwartzCode Oct 25, 2021
4b1eca4
Removed dead code
SchwartzCode Oct 30, 2021
4255d32
removed unused imports
SchwartzCode Oct 30, 2021
0457c61
removed uneccesary initialization
SchwartzCode Oct 30, 2021
342eb03
Applying PR feedback
SchwartzCode Nov 3, 2021
70a495d
fixing CI errors
SchwartzCode Nov 3, 2021
63333d3
Merge branch 'AtsushiSakai:master' into master
Nov 10, 2021
c2ac3ab
added description to header and removed unused variable
SchwartzCode Nov 11, 2021
1a22999
Merge branch 'master' of github.com:SchwartzCode/PythonRobotics
SchwartzCode Nov 11, 2021
38d5f45
Merge branch 'AtsushiSakai:master' into master
Apr 23, 2022
aceabb1
wip - sketch out obstacles
SchwartzCode Feb 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions TimeBasedPathPlanning/moving_obstacles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import numpy as np
import random
import matplotlib.pyplot as plt

class Grid():

# Set in constructor
grid_size = None
grid = None
obstacle_paths = []

# Problem definition
time_limit = 100
num_obstacles = 2

def __init__(self, grid_size: np.ndarray[int, int]):
self.grid_size = grid_size
self.grid = np.zeros((grid_size[0], grid_size[1], self.time_limit))

for i in range(1, self.num_obstacles+1):
self.obstacle_paths.append(self.generate_dynamic_obstacle(i))

def generate_dynamic_obstacle(self, obs_idx: int) -> list[np.ndarray[int, int]]:
# TODO: dont spawn on another obstacle
initial_position = (np.random.randint(0, self.grid_size[0]), np.random.randint(0, self.grid_size[1]))
positions = [initial_position]
print("Initial position: ", initial_position)

diffs = [np.array([0, 1]), np.array([0, -1]), np.array([1, 0]), np.array([-1, 0]), np.array([0, 0])]

for t in range(1, self.time_limit-1):
random.shuffle(diffs)
for diff in diffs:
new_position = positions[-1] + diff

# Check if new position is in grid
if new_position[0] < 0 or new_position[0] >= self.grid_size[0] or new_position[1] < 0 or new_position[1] >= self.grid_size[1]:
continue

# Check if new position occupied by another obstacle
if self.grid[new_position[0], new_position[1], t] == 0:
positions.append(new_position)
self.grid[new_position[0], new_position[1], t] = obs_idx
break

# Impossible situation for obstacle - stay in place
print("Impossible situation for obstacle!")
positions.append(positions[-1])

return positions

show_animation = True

def main():
grid = Grid(np.array([10, 10]))

plt.figure()

for t in range(0, grid.time_limit):
plt.clf()

if show_animation: # pragma: no cover
# TODO: iter is clunky. Should use np array
ax = plt.axes()
ax.set_xlim(0, grid.grid_size[0])
ax.set_ylim(0, grid.grid_size[1])

for (obs_idx, obs_path) in enumerate(grid.obstacle_paths):
obs_pos = obs_path[t]
# plt.plot(obs_pos[0], obs_pos[1], "xr")
circle = plt.Circle((obs_pos[0], obs_pos[1]), 0.2)
ax.add_patch(circle)
plt.grid(True)
plt.pause(0.3)

# TODO: better animation closing
# fig, ax = plt.subplots()
# line, = ax.plot([], [])
# ax.set_xlim(0, 10)
# ax.set_ylim(-1, 1)

# def init():
# line.set_data([], [])
# return line,

# def animate(i):
# x = [0, 10]
# y = [0, i % 2 * 2 - 1]
# line.set_data(x, y)
# return line,
Comment on lines +82 to +90

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

# ani = animation.FuncAnimation(fig, animate, init_func=init, frames=100, interval=20, blit=True)

# def close_event(evt):
# ani.event_source.stop()
# plt.close(fig)
Comment on lines +94 to +96

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

if __name__ == '__main__':
main()