Skip to content

Commit 64d6ce2

Browse files
committed
revert debugging code
revert debugging code
1 parent f4850ce commit 64d6ce2

File tree

3 files changed

+63
-79
lines changed

3 files changed

+63
-79
lines changed

selfdrive/test/longitudinal_maneuvers/maneuver.py

-16
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import numpy as np
22
from selfdrive.test.longitudinal_maneuvers.plant import Plant
3-
import matplotlib
4-
matplotlib.rcParams['figure.raise_window'] = False
5-
import matplotlib.pyplot as plt
6-
import time
73

84

95
class Maneuver():
@@ -35,9 +31,7 @@ def evaluate(self):
3531

3632
valid = True
3733
logs = []
38-
i = 0
3934
while plant.current_time() < self.duration:
40-
i += 1
4135
speed_lead = np.interp(plant.current_time(), self.breakpoints, self.speed_lead_values)
4236
prob = np.interp(plant.current_time(), self.breakpoints, self.prob_lead_values)
4337
cruise = np.interp(plant.current_time(), self.breakpoints, self.cruise_values)
@@ -53,20 +47,10 @@ def evaluate(self):
5347
log['speed'],
5448
speed_lead,
5549
log['acceleration']]))
56-
if i % 20 == 0:
57-
plt.clf()
58-
plt.title('rel dist: {} m'.format(round(logs[-1][2] - logs[-1][1], 3)))
59-
plt.plot([i[1] for i in logs], label='ego')
60-
plt.plot([i[2] for i in logs], label='lead')
61-
plt.legend()
62-
plt.pause(0.01)
63-
# plt.show()
6450

6551
if d_rel < .4 and (self.only_radar or prob > 0.5):
6652
print("Crashed!!!!")
6753
valid = False
6854

6955
print("maneuver end", valid)
70-
# time.sleep(3)
71-
input()
7256
return valid, np.array(logs)

selfdrive/test/longitudinal_maneuvers/plant.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ def step(self, v_lead=0.0, prob=1.0, v_cruise=50.):
119119
v_rel = 0.
120120

121121
# print at 5hz
122-
# if (self.rk.frame % (self.rate // 5)) == 0:
123-
# print("%2.2f sec %6.2f m %6.2f m/s %6.2f m/s2 lead_rel: %6.2f m %6.2f m/s"
124-
# % (self.current_time(), self.distance, self.speed, self.acceleration, d_rel, v_rel))
122+
if (self.rk.frame % (self.rate // 5)) == 0:
123+
print("%2.2f sec %6.2f m %6.2f m/s %6.2f m/s2 lead_rel: %6.2f m %6.2f m/s"
124+
% (self.current_time(), self.distance, self.speed, self.acceleration, d_rel, v_rel))
125125

126126

127127
# ******** update prevs ********

selfdrive/test/longitudinal_maneuvers/test_longitudinal.py

+60-60
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@
88

99
# TODO: make new FCW tests
1010
maneuvers = [
11-
# Maneuver(
12-
# 'approach stopped car at 20m/s',
13-
# duration=20.,
14-
# initial_speed=25.,
15-
# lead_relevancy=True,
16-
# initial_distance_lead=120.,
17-
# speed_lead_values=[30., 0.],
18-
# breakpoints=[0., 1.],
19-
# ),
20-
# Maneuver(
21-
# 'approach stopped car at 20m/s',
22-
# duration=20.,
23-
# initial_speed=20.,
24-
# lead_relevancy=True,
25-
# initial_distance_lead=90.,
26-
# speed_lead_values=[20., 0.],
27-
# breakpoints=[0., 1.],
28-
# ),
11+
Maneuver(
12+
'approach stopped car at 20m/s',
13+
duration=20.,
14+
initial_speed=25.,
15+
lead_relevancy=True,
16+
initial_distance_lead=120.,
17+
speed_lead_values=[30., 0.],
18+
breakpoints=[0., 1.],
19+
),
20+
Maneuver(
21+
'approach stopped car at 20m/s',
22+
duration=20.,
23+
initial_speed=20.,
24+
lead_relevancy=True,
25+
initial_distance_lead=90.,
26+
speed_lead_values=[20., 0.],
27+
breakpoints=[0., 1.],
28+
),
2929
Maneuver(
3030
'steady state following a car at 20m/s, then lead decel to 0mph at 1m/s^2',
3131
duration=50.,
@@ -64,48 +64,48 @@
6464
cruise_values=[20., 20., 20.],
6565
breakpoints=[2., 2.01, 8.51],
6666
),
67-
# Maneuver(
68-
# "approach stopped car at 20m/s",
69-
# duration=30.,
70-
# initial_speed=20.,
71-
# lead_relevancy=True,
72-
# initial_distance_lead=120.,
73-
# speed_lead_values=[0.0, 0., 0.],
74-
# prob_lead_values=[0.0, 0., 1.],
75-
# cruise_values=[20., 20., 20.],
76-
# breakpoints=[0.0, 2., 2.01],
77-
# ),
78-
# Maneuver(
79-
# "approach slower cut-in car at 20m/s",
80-
# duration=20.,
81-
# initial_speed=20.,
82-
# lead_relevancy=True,
83-
# initial_distance_lead=50.,
84-
# speed_lead_values=[15., 15.],
85-
# breakpoints=[1., 11.],
86-
# only_lead2=True,
87-
# ),
88-
# Maneuver(
89-
# "stay stopped behind radar override lead",
90-
# duration=20.,
91-
# initial_speed=0.,
92-
# lead_relevancy=True,
93-
# initial_distance_lead=10.,
94-
# speed_lead_values=[0., 0.],
95-
# prob_lead_values=[0., 0.],
96-
# breakpoints=[1., 11.],
97-
# only_radar=True,
98-
# ),
99-
# Maneuver(
100-
# "NaN recovery",
101-
# duration=30.,
102-
# initial_speed=15.,
103-
# lead_relevancy=True,
104-
# initial_distance_lead=60.,
105-
# speed_lead_values=[0., 0., 0.0],
106-
# breakpoints=[1., 1.01, 11.],
107-
# cruise_values=[float("nan"), 15., 15.],
108-
# ),
67+
Maneuver(
68+
"approach stopped car at 20m/s",
69+
duration=30.,
70+
initial_speed=20.,
71+
lead_relevancy=True,
72+
initial_distance_lead=120.,
73+
speed_lead_values=[0.0, 0., 0.],
74+
prob_lead_values=[0.0, 0., 1.],
75+
cruise_values=[20., 20., 20.],
76+
breakpoints=[0.0, 2., 2.01],
77+
),
78+
Maneuver(
79+
"approach slower cut-in car at 20m/s",
80+
duration=20.,
81+
initial_speed=20.,
82+
lead_relevancy=True,
83+
initial_distance_lead=50.,
84+
speed_lead_values=[15., 15.],
85+
breakpoints=[1., 11.],
86+
only_lead2=True,
87+
),
88+
Maneuver(
89+
"stay stopped behind radar override lead",
90+
duration=20.,
91+
initial_speed=0.,
92+
lead_relevancy=True,
93+
initial_distance_lead=10.,
94+
speed_lead_values=[0., 0.],
95+
prob_lead_values=[0., 0.],
96+
breakpoints=[1., 11.],
97+
only_radar=True,
98+
),
99+
Maneuver(
100+
"NaN recovery",
101+
duration=30.,
102+
initial_speed=15.,
103+
lead_relevancy=True,
104+
initial_distance_lead=60.,
105+
speed_lead_values=[0., 0., 0.0],
106+
breakpoints=[1., 1.01, 11.],
107+
cruise_values=[float("nan"), 15., 15.],
108+
),
109109
]
110110

111111

0 commit comments

Comments
 (0)