-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Jbs/time based planners #1137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
SchwartzCode
wants to merge
65
commits into
AtsushiSakai:master
from
SchwartzCode:jbs/time_based_planners
Closed
Jbs/time based planners #1137
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 64ca35e
Created test script for dubins path generator
SchwartzCode e02ec7d
Made len == 0 it's own case, also changed 'l' to 'len' to appease tra…
SchwartzCode 1f179f0
Merge branch 'AtsushiSakai:master' into dubins_path_bug_fix
80991d0
More variable renaming to appease CI
SchwartzCode f6b99fd
Broke == 0 into its own case in dubins planner, also Renaming files t…
SchwartzCode f0b8fda
Merge branch 'dubins_path_bug_fix' of https://github.com/SchwartzCode…
SchwartzCode eddba93
Reverting some naming changes
SchwartzCode 30df7e8
Turns out theres already a test for dubins.. not sure how I missed that
SchwartzCode 5977869
Note to self: run the test cases on your own before throwing them at CI
SchwartzCode b5405b7
Merged commits incorrectly
SchwartzCode ba86afd
Added handling of length=0 case in generate_local_course()
SchwartzCode 3765bb1
Silly merge conflict
SchwartzCode 1c7038a
Merge branch 'AtsushiSakai-master'
SchwartzCode c0d3d36
Missed reverting 'mode' back to 'm' in one spot
SchwartzCode 831c2aa
Addressing style issues (line length)
SchwartzCode d5b4361
Mostly works, now just need to setup linear regression to solve for w…
SchwartzCode e3f9a9d
Re-arranged class
SchwartzCode dd94aaf
Wrote DMP program and added tests file
SchwartzCode 00319b3
Merge branch 'AtsushiSakai:master' into master
732560b
Styling fixes
SchwartzCode a366216
Merge branch 'master' of https://github.com/SchwartzCode/PythonRobotics
SchwartzCode a7b5e25
More styling
SchwartzCode c2ca3f0
Missed one indent
SchwartzCode 4372e74
Multi-dimension path learning (e.g. in x and y instead of just x)
SchwartzCode 3ca74cb
Added potential field obstacle avoidance
SchwartzCode 29bdb15
Potential field working much better but has issues with reaching goal…
SchwartzCode 9e63e6d
Path ending to short not a result of obstacles, should be fix-able
SchwartzCode d99c34a
Mostly working! end won't go to goal
SchwartzCode 910498b
split DMP and path following
SchwartzCode 85d9528
pretty close
SchwartzCode 6afbcf7
Okay this is working pretty well
SchwartzCode 5f0aeed
looks.. okay. was using the wrong vector before
SchwartzCode 1439b4e
a plan to fix this mess
SchwartzCode 2defd14
Okay seriously going to pivot to the dubins approach im done with pot…
SchwartzCode db79626
Finished obstacle circle handling (and merging circles that are close…
SchwartzCode 28fbc08
Finished circle event finder function
SchwartzCode d3b1694
Some progress in preparing for dubins curves
SchwartzCode b00812c
Finished angle finding algo, need to test
SchwartzCode 6ab4a42
Okay getting back to this, going to ignore the navigation and just fo…
SchwartzCode 43a3f65
Moved DMP files to path planning
SchwartzCode dc75fa7
changed folder name
SchwartzCode 846fc47
Made demo path cooler
SchwartzCode 5ad64e0
All working and added visualization tools (will remove
SchwartzCode 74c0dd6
Fixed unit test and handled TODOs
SchwartzCode 4d92252
not gonna handle this one
SchwartzCode 6848da5
Merge branch 'AtsushiSakai:master' into master
300ff13
Merge branch 'master' of github.com:SchwartzCode/PythonRobotics
SchwartzCode 3fab1d9
demo now scales with data
SchwartzCode c18242e
CI errors
SchwartzCode 9fefe20
CI errors
SchwartzCode ae50183
Fixing code style issues
SchwartzCode c61b9b0
more styling
SchwartzCode 342dc25
fixing CI errors
SchwartzCode fc6f5b0
formatting
SchwartzCode 4b1eca4
Removed dead code
SchwartzCode 4255d32
removed unused imports
SchwartzCode 0457c61
removed uneccesary initialization
SchwartzCode 342eb03
Applying PR feedback
SchwartzCode 70a495d
fixing CI errors
SchwartzCode 63333d3
Merge branch 'AtsushiSakai:master' into master
c2ac3ab
added description to header and removed unused variable
SchwartzCode 1a22999
Merge branch 'master' of github.com:SchwartzCode/PythonRobotics
SchwartzCode 38d5f45
Merge branch 'AtsushiSakai:master' into master
aceabb1
wip - sketch out obstacles
SchwartzCode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,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, | ||
|
||
# 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 noticeCode scanning / CodeQL Commented-out code Note
This comment appears to contain commented-out code.
|
||
|
||
if __name__ == '__main__': | ||
main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / CodeQL
Commented-out code Note