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
749fe7df
Commit
749fe7df
authored
6 months ago
by
rachelmoan
Browse files
Options
Downloads
Patches
Plain Diff
update single agent path tracker
parent
0da2cd08
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
guided_mrmp/controllers/path_tracker.py
+13
-10
13 additions, 10 deletions
guided_mrmp/controllers/path_tracker.py
with
13 additions
and
10 deletions
guided_mrmp/controllers/path_tracker.py
+
13
−
10
View file @
749fe7df
#! /usr/bin/env python
import
numpy
as
np
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
...
@@ -137,7 +135,7 @@ class PathTracker:
...
@@ -137,7 +135,7 @@ class PathTracker:
target
,
target
,
self
.
control
self
.
control
)
)
# print("CVXPY Optimization Time: {:.4f}s".format(time.time()-start))
# only the first one is used to advance the simulation
# only the first one is used to advance the simulation
self
.
control
[:]
=
[
u_mpc
.
value
[
0
,
0
],
u_mpc
.
value
[
1
,
0
]]
self
.
control
[:]
=
[
u_mpc
.
value
[
0
,
0
],
u_mpc
.
value
[
1
,
0
]]
# self.state = self.predict_next_state(
# self.state = self.predict_next_state(
...
@@ -146,20 +144,21 @@ class PathTracker:
...
@@ -146,20 +144,21 @@ class PathTracker:
return
x_mpc
,
self
.
control
return
x_mpc
,
self
.
control
def
run
(
self
,
show_plots
=
False
):
def
run
(
self
,
show_plots
=
False
):
"""
"""
[TODO:summary]
Run the path tracker algorithm.
Parameters:
[TODO:description]
- show_plots (bool): Flag indicating whether to show plots during the simulation. Default is False.
Returns:
- numpy.ndarray: Array containing the history of x, y, and h coordinates.
"""
"""
# Add the initial state to the histories
self
.
x_history
.
append
(
self
.
state
[
0
])
self
.
x_history
.
append
(
self
.
state
[
0
])
self
.
y_history
.
append
(
self
.
state
[
1
])
self
.
y_history
.
append
(
self
.
state
[
1
])
self
.
h_history
.
append
(
self
.
state
[
2
])
self
.
h_history
.
append
(
self
.
state
[
2
])
if
show_plots
:
self
.
plot_sim
()
if
show_plots
:
self
.
plot_sim
()
while
1
:
while
1
:
if
(
np
.
sqrt
((
self
.
state
[
0
]
-
self
.
path
[
0
,
-
1
])
**
2
+
(
self
.
state
[
1
]
-
self
.
path
[
1
,
-
1
])
**
2
)
<
0.1
):
if
(
np
.
sqrt
((
self
.
state
[
0
]
-
self
.
path
[
0
,
-
1
])
**
2
+
(
self
.
state
[
1
]
-
self
.
path
[
1
,
-
1
])
**
2
)
<
0.1
):
print
(
"
Success! Goal Reached
"
)
print
(
"
Success! Goal Reached
"
)
...
@@ -263,6 +262,10 @@ class PathTracker:
...
@@ -263,6 +262,10 @@ class PathTracker:
plt
.
tight_layout
()
plt
.
tight_layout
()
ax
=
plt
.
gca
()
ax
.
set_xlim
([
0
,
10
])
ax
.
set_ylim
([
0
,
10
])
plt
.
draw
()
plt
.
draw
()
plt
.
pause
(
0.1
)
plt
.
pause
(
0.1
)
...
@@ -303,4 +306,4 @@ if __name__ == "__main__":
...
@@ -303,4 +306,4 @@ if __name__ == "__main__":
wp
=
[[
0
,
3
,
4
,
6
,
10
,
12
,
13
,
13
,
6
,
1
,
0
],
wp
=
[[
0
,
3
,
4
,
6
,
10
,
12
,
13
,
13
,
6
,
1
,
0
],
[
0
,
0
,
2
,
4
,
3
,
3
,
-
1
,
-
2
,
-
6
,
-
2
,
-
2
]]
[
0
,
0
,
2
,
4
,
3
,
3
,
-
1
,
-
2
,
-
6
,
-
2
,
-
2
]]
sim
=
PathTracker
(
initial_position
=
initial_pos
,
dynamics
=
dynamics
,
target_v
=
target_vocity
,
T
=
T
,
DT
=
DT
,
waypoints
=
wp
)
sim
=
PathTracker
(
initial_position
=
initial_pos
,
dynamics
=
dynamics
,
target_v
=
target_vocity
,
T
=
T
,
DT
=
DT
,
waypoints
=
wp
)
x
,
y
,
h
=
sim
.
run
(
show_plots
=
False
)
x
,
y
,
h
=
sim
.
run
(
show_plots
=
True
)
\ No newline at end of file
\ No newline at end of file
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