Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cs598mp-fall2021-proj
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
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
chsieh16
cs598mp-fall2021-proj
Commits
04dd969b
Commit
04dd969b
authored
2 years ago
by
chsieh16
Browse files
Options
Downloads
Patches
Plain Diff
Refactor for readability and consistency
parent
68c86728
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
data/filter_data.py
+4
-5
4 additions, 5 deletions
data/filter_data.py
with
4 additions
and
5 deletions
data/filter_data.py
+
4
−
5
View file @
04dd969b
import
pickle
import
numpy
as
np
from
numpy.lib.function_base
import
diff
import
matplotlib.pyplot
as
plt
# Constants for Stanley controller for GEM
...
...
@@ -26,7 +25,7 @@ def f(x, y, theta, steer):
def
v
(
x
,
y
,
theta
)
->
float
:
return
y
**
2
+
theta
**
2
return
np
.
linalg
.
norm
([
y
,
theta
],
ord
=
2
)
def
in_circle
(
x
,
y
,
theta
,
d
,
phi
)
->
bool
:
...
...
@@ -36,8 +35,8 @@ def in_circle(x, y, theta, d, phi) -> bool:
state_vec
=
np
.
array
([
x
,
y
,
theta
])
perc_vec
=
np
.
array
([
d
,
phi
])
diff_vec
=
perc_vec
-
(
np
.
dot
(
state_vec
,
a_mat
.
T
)
+
b_vec
)
return
np
.
dot
(
diff_vec
,
diff_vec
)
<=
0.03
diff_vec
=
perc_vec
-
(
a_mat
@
state_vec
+
b_vec
)
return
np
.
linalg
.
norm
(
diff_vec
,
ord
=
2
)
<=
np
.
sqrt
(
0.03
)
def
pred
(
sample
)
->
bool
:
...
...
@@ -61,7 +60,7 @@ for truth, samples in truth_samples_seq:
filtered_samples
=
[
s
for
s
in
samples
if
pred
(
s
)]
if
abs
(
len
(
samples
)
-
len
(
filtered_samples
))
<
200
and
\
abs
(
cte
-
0.967823751
)
<=
0.001
and
abs
(
phi
-
-
0.211146388
)
<=
0.001
:
print
(
"
#Original:
"
,
len
(
samples
),
"
#Filtered:
"
,
len
(
filtered_samples
))
print
(
"
#Original:
"
,
len
(
samples
),
"
#Filtered:
"
,
len
(
filtered_samples
))
filtered_truth_samples
.
append
((
truth
,
filtered_samples
))
else
:
# print("Skip partition. #Original:", len(samples), "#Filtered:", len(filtered_samples))
...
...
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