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
819ca091
Commit
819ca091
authored
3 months ago
by
Adam Sitabkhan
Browse files
Options
Downloads
Patches
Plain Diff
Fixed error with zero obstacles, main.py works
parent
73b4e600
No related branches found
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
+9
-12
9 additions, 12 deletions
guided_mrmp/controllers/place_grid.py
with
9 additions
and
12 deletions
guided_mrmp/controllers/place_grid.py
+
9
−
12
View file @
819ca091
...
...
@@ -16,8 +16,6 @@ def place_grid(robot_locations, cell_size, grid_size=5, subgoals=[], obstacles=[
- origin (tuple): bottom-left corner of the grid in continuous space
- cell_centers (list): centers of grid cells for each robot (same order as robot_locations)
"""
start_time
=
time
.
time
()
robot_locations
=
np
.
array
(
robot_locations
)
subgoals
=
np
.
array
(
subgoals
)
num_robots
=
len
(
robot_locations
)
...
...
@@ -37,11 +35,15 @@ def place_grid(robot_locations, cell_size, grid_size=5, subgoals=[], obstacles=[
cell_centers
=
cp
.
reshape
(
bottom_left
,
(
1
,
2
),
order
=
'
C
'
)
+
grid_indices
*
cell_size
+
cell_size
/
2
# Existence of overlap between each obstacle and each robot
overlaps
=
cp
.
Variable
((
num_obst
,
num_robots
),
boolean
=
True
)
if
num_obst
>
0
:
overlaps
=
cp
.
Variable
((
num_obst
,
num_robots
),
boolean
=
True
)
# Objective: Minimize the sum of squared distances and number of robot cell / obstacle overlaps
alpha
=
1
cost
=
cp
.
sum_squares
(
robot_locations
-
cell_centers
)
+
alpha
*
cp
.
sum
(
overlaps
)
if
num_obst
>
0
:
alpha
=
1
cost
=
cp
.
sum_squares
(
robot_locations
-
cell_centers
)
+
alpha
*
cp
.
sum
(
overlaps
)
else
:
cost
=
cp
.
sum_squares
(
robot_locations
-
cell_centers
)
# Constraints
constraints
=
[]
...
...
@@ -131,23 +133,18 @@ def place_grid(robot_locations, cell_size, grid_size=5, subgoals=[], obstacles=[
constraints
.
append
(
overlaps
[
obst_idx
,
i
]
>=
temp_x_sep
+
temp_y_sep
-
1
)
# Solve the optimization problem
prob_init_start_time
=
time
.
time
()
prob
=
cp
.
Problem
(
cp
.
Minimize
(
cost
),
constraints
)
solve_start_time
=
time
.
time
()
prob
.
solve
(
solver
=
cp
.
SCIP
)
solve_end_time
=
time
.
time
()
print
(
"
Time to add vars/constraints:
"
,
prob_init_start_time
-
start_time
)
print
(
"
Time to parse:
"
,
solve_start_time
-
prob_init_start_time
)
print
(
"
Time to solve:
"
,
solve_end_time
-
solve_start_time
)
print
(
"
Solve time:
"
,
solve_end_time
-
solve_start_time
)
if
prob
.
status
!=
"
optimal
"
:
print
(
"
Problem could not be solved to optimality.
"
)
return
None
print
(
f
"
Number of obstacle/robot-cell overlaps:
{
int
(
np
.
sum
(
overlaps
.
value
))
}
"
)
print
(
f
"
Cost:
{
cost
.
value
}
"
)
return
bottom_left
.
value
,
cell_centers
.
value
...
...
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