Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
db-guided-mrmp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rmoan2
db-guided-mrmp
Commits
ea94736d
Commit
ea94736d
authored
3 months ago
by
Adam Sitabkhan
Browse files
Options
Downloads
Patches
Plain Diff
Random generation of obstacle/robot/subgoals for testcases
parent
de7fd548
No related branches found
Branches containing commit
No related tags found
1 merge request
!2
Updated place grid
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
guided_mrmp/controllers/place_grid.py
+55
-28
55 additions, 28 deletions
guided_mrmp/controllers/place_grid.py
with
55 additions
and
28 deletions
guided_mrmp/controllers/place_grid.py
+
55
−
28
View file @
ea94736d
...
@@ -122,7 +122,7 @@ def place_grid(robot_locations, cell_size, grid_size=5, subgoals=[], obstacles=[
...
@@ -122,7 +122,7 @@ def place_grid(robot_locations, cell_size, grid_size=5, subgoals=[], obstacles=[
prob_init_start_time
=
time
.
time
()
prob_init_start_time
=
time
.
time
()
prob
=
cp
.
Problem
(
cp
.
Minimize
(
cost
),
constraints
)
prob
=
cp
.
Problem
(
cp
.
Minimize
(
cost
),
constraints
)
solve_start_time
=
time
.
time
()
solve_start_time
=
time
.
time
()
prob
.
solve
(
solver
=
cp
.
SCIP
,
verbose
=
True
)
prob
.
solve
(
solver
=
cp
.
SCIP
)
solve_end_time
=
time
.
time
()
solve_end_time
=
time
.
time
()
print
(
"
Time to add vars/constraints:
"
,
prob_init_start_time
-
start_time
)
print
(
"
Time to add vars/constraints:
"
,
prob_init_start_time
-
start_time
)
...
@@ -296,26 +296,57 @@ def plot_grid(bottom_left, top_right, grid_size):
...
@@ -296,26 +296,57 @@ def plot_grid(bottom_left, top_right, grid_size):
[(
bottom_left
+
i
*
y_prime_hat
)[
1
],
(
bottom_right
+
i
*
y_prime_hat
)[
1
]],
'
k-
'
)
[(
bottom_left
+
i
*
y_prime_hat
)[
1
],
(
bottom_right
+
i
*
y_prime_hat
)[
1
]],
'
k-
'
)
def
get_
roomba_loc
s
(
low
,
high
,
num_robots
,
radius
=
0.5
,
obstacle
s
=
[]
):
def
get_
location
s
(
low
,
high
,
num_robots
,
robot_
radius
=
0.5
,
obstacle
_radii
=
[
0.5
,
1
,
0.3
],
max_iter
=
500
):
"""
"""
Generates a list of roomba locations within the box bounded by points (low, low), (high, low), (high, high), (low, high).
Generates a list of roomba locations within the box bounded by points (low, low), (high, low), (high, high), (low, high).
The roombas must be separated by at least 2 * radius
The roombas must be separated by at least 2 * radius
"""
"""
locs
=
[]
num_obst
=
len
(
obstacle_radii
)
while
len
(
locs
)
<
num_robots
:
locs
.
append
(
np
.
random
.
uniform
(
low
,
high
,
2
))
queue
=
[]
invalid
=
False
for
i
in
range
(
num_robots
):
for
(
obst_x
,
obst_y
,
obst_r
)
in
obstacles
:
queue
.
append
((
robot_radius
,
"
robot
"
))
if
np
.
linalg
.
norm
(
np
.
array
(
locs
[
-
1
])
-
np
.
array
([
obst_x
,
obst_y
]))
<=
radius
+
obst_r
:
queue
.
append
((
robot_radius
,
"
subgoal
"
))
invalid
=
True
for
i
in
range
(
num_obst
):
break
queue
.
append
((
obstacle_radii
[
i
],
"
obstacle
"
))
for
other_loc
in
locs
[:
-
1
]:
queue
=
sorted
(
queue
,
key
=
lambda
x
:
x
[
0
])
if
np
.
linalg
.
norm
(
np
.
array
(
locs
[
-
1
])
-
np
.
array
(
other_loc
))
<=
2
*
radius
:
invalid
=
True
robot_locs
=
[]
break
subgoal_locs
=
[]
if
invalid
:
obst_locs
=
[]
locs
=
locs
[:
-
1
]
while
len
(
queue
)
>
0
:
return
np
.
array
(
locs
)
curr_r
,
curr_type
=
queue
[
-
1
]
curr_loc
=
np
.
random
.
uniform
(
low
,
high
,
2
)
# match type:
# case "robot":
# robot_locs.append()
# case "subgoal":
# case "obstacle":
valid
=
True
for
obst
in
obst_locs
:
if
np
.
linalg
.
norm
(
curr_loc
-
obst
[:
2
])
<=
curr_r
+
obst
[
2
]:
valid
=
False
break
if
curr_type
!=
"
subgoal
"
:
for
robot
in
robot_locs
:
if
np
.
linalg
.
norm
(
curr_loc
-
robot
)
<=
curr_r
+
robot_radius
:
valid
=
False
break
for
subgoal
in
subgoal_locs
:
if
np
.
linalg
.
norm
(
curr_loc
-
subgoal
)
<=
curr_r
+
robot_radius
:
valid
=
False
break
if
valid
:
match
curr_type
:
case
"
robot
"
:
robot_locs
.
append
(
curr_loc
)
case
"
subgoal
"
:
subgoal_locs
.
append
(
curr_loc
)
case
"
obstacle
"
:
obst_locs
.
append
(
np
.
array
([
*
curr_loc
,
curr_r
]))
queue
=
queue
[:
-
1
]
return
robot_locs
,
subgoal_locs
,
obst_locs
def
main
(
seed
,
num_robots
,
plot
,
two_corner
):
def
main
(
seed
,
num_robots
,
plot
,
two_corner
):
...
@@ -328,18 +359,14 @@ def main(seed, num_robots, plot, two_corner):
...
@@ -328,18 +359,14 @@ def main(seed, num_robots, plot, two_corner):
roomba_radius
=
0.5
roomba_radius
=
0.5
cell_size
=
2.5
*
roomba_radius
cell_size
=
2.5
*
roomba_radius
grid_size
=
5
grid_size
=
5
obstacle_radii
=
[
1
/
3
,
1
,
0.5
]
robot_locations
,
subgoals
,
obstacles
=
get_locations
(
low
=
0
,
obstacles
=
np
.
array
([[
2
,
2
,
0.75
],
[
4
,
4
,
0.5
]])
high
=
5
,
# robot_locations = np.random.uniform(low=0, high=5, size=(num_robots, 2))
num_robots
=
3
,
robot_locations
=
get_roomba_locs
(
low
=
0
,
high
=
6
,
num_robots
=
num_robots
,
radius
=
roomba_radius
,
obstacles
=
obstacles
)
robot_radius
=
roomba_radius
,
# subgoals = np.array([[0, 0], [0, 6], [6, 6], [6, 0]])
obstacle_radii
=
obstacle_radii
)
subgoals
=
get_roomba_locs
(
low
=
0
,
high
=
6
,
num_robots
=
num_robots
,
radius
=
roomba_radius
,
obstacles
=
obstacles
)
# bottom_left, cell_centers = place_grid(robot_locations=robot_locations,
# cell_size=cell_size,
# grid_size=grid_size,
# subgoals=subgoals)
bottom_left
,
cell_centers
=
place_grid
(
robot_locations
=
robot_locations
,
bottom_left
,
cell_centers
=
place_grid
(
robot_locations
=
robot_locations
,
cell_size
=
cell_size
,
cell_size
=
cell_size
,
grid_size
=
grid_size
,
grid_size
=
grid_size
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment