FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
PythonLinearNonlinearControl/scripts/show_result.py at develop · yangwangaaa/PythonLinearNonlinearControl · GitHub
yangwangaaa
PythonLinearNonlinearControl
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
PythonLinearNonlinearControl
/
scripts
/
show_result.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
55 lines (40 loc) · 1.67 KB
Breadcrumbs
PythonLinearNonlinearControl
/
scripts
/
show_result.py
Copy path
File metadata and controls
55 lines (40 loc) · 1.67 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import
os
import
argparse
import
pickle
import
numpy
as
np
import
matplotlib
.
pyplot
as
plt
from
PythonLinearNonlinearControl
.
plotters
.
plot_func
import
load_plot_data
, \
plot_multi_result
def
run
(
args
):
controllers
=
[
"iLQR"
,
"DDP"
,
"CEM"
,
"MPPI"
]
history_xs
=
None
history_us
=
None
history_gs
=
None
# load data
for
controller
in
controllers
:
history_x
,
history_u
,
history_g
=
\
load_plot_data
(
args
.
env
,
controller
,
result_dir
=
args
.
result_dir
)
if
history_xs
is
None
:
history_xs
=
history_x
[
np
.
newaxis
, :]
history_us
=
history_u
[
np
.
newaxis
, :]
history_gs
=
history_g
[
np
.
newaxis
, :]
continue
history_xs
=
np
.
concatenate
((
history_xs
,
history_x
[
np
.
newaxis
, :]),
axis
=
0
)
history_us
=
np
.
concatenate
((
history_us
,
history_u
[
np
.
newaxis
, :]),
axis
=
0
)
history_gs
=
np
.
concatenate
((
history_gs
,
history_g
[
np
.
newaxis
, :]),
axis
=
0
)
plot_multi_result
(
history_xs
,
histories_g
=
history_gs
,
labels
=
controllers
,
ylabel
=
"x"
)
plot_multi_result
(
history_us
,
histories_g
=
np
.
zeros_like
(
history_us
),
labels
=
controllers
,
ylabel
=
"u"
,
name
=
"input_history"
)
def
main
():
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"--env"
,
type
=
str
,
default
=
"FirstOrderLag"
)
parser
.
add_argument
(
"--result_dir"
,
type
=
str
,
default
=
"./result"
)
args
=
parser
.
parse_args
()
run
(
args
)
if
__name__
==
"__main__"
:
main
()
Back
|
FazBrowse Home
|
New Git URL