Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5f32cd1
always log leads, we hide them in ui
sshane Jun 15, 2022
3dc51f6
only spam resume when future is > vEgoStarting
sshane Jun 15, 2022
2c90610
do rest but vw
sshane Jun 16, 2022
325ea9b
vw
sshane Jun 16, 2022
00b1df6
remove comments
sshane Jun 16, 2022
6c1fe06
rename to resume
sshane Jun 16, 2022
5771cde
maintain original button msg rate
sshane Jun 21, 2022
6a63bd6
mazda: ensure no resume if cancelling
sshane Jun 21, 2022
d2f51ee
same for non-HDA2
sshane Jun 21, 2022
13997c5
Merge remote-tracking branch 'upstream/master' into enable-planner
sshane Jun 21, 2022
ff0597e
Always run planner if not opLong
sshane Jun 21, 2022
e7dc396
try 0.2
sshane Jun 21, 2022
e23b37d
0.1 should be pretty safe
sshane Jun 21, 2022
04db5f8
Merge remote-tracking branch 'upstream/master' into enable-planner
sshane Jun 23, 2022
0520c7f
add test for resuming
sshane Jun 25, 2022
e6c4106
fix test
sshane Jun 25, 2022
c9e446a
Merge remote-tracking branch 'upstream/master' into enable-planner
sshane Jun 29, 2022
f863426
stricter test, speeds[-1] is 0.14 when starting here
sshane Jun 29, 2022
b7b425e
Merge remote-tracking branch 'upstream/master' into enable-planner
sshane Jun 30, 2022
e088fde
no walrus
sshane Jun 30, 2022
246207e
Merge remote-tracking branch 'upstream/master' into enable-planner
sshane Jul 6, 2022
e0dc141
Merge remote-tracking branch 'upstream/master' into enable-planner
sshane Jul 7, 2022
998d7e9
fixup mazda cc
sshane Jul 7, 2022
742ff3f
Merge remote-tracking branch 'upstream/master' into enable-planner
sshane Jul 7, 2022
aa6fb52
remove extra import
sshane Jul 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion selfdrive/car/honda/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def update(self, CC, CS):
# If using stock ACC, spam cancel command to kill gas when OP disengages.
if pcm_cancel_cmd:
can_sends.append(hondacan.spam_buttons_command(self.packer, CruiseButtons.CANCEL, idx, self.CP.carFingerprint))
elif CS.out.cruiseState.standstill:
elif CC.cruiseControl.resume:
can_sends.append(hondacan.spam_buttons_command(self.packer, CruiseButtons.RES_ACCEL, idx, self.CP.carFingerprint))

else:
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/car/hyundai/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def update(self, CC, CS):
self.last_button_frame = self.frame

# cruise standstill resume
elif CC.enabled and CS.out.cruiseState.standstill:
elif CC.cruiseControl.resume:
can_sends.append(hda2can.create_buttons(self.packer, CS.buttons_counter+1, False, True))
self.last_button_frame = self.frame
else:
Expand All @@ -96,7 +96,7 @@ def update(self, CC, CS):
if not self.CP.openpilotLongitudinalControl:
if CC.cruiseControl.cancel:
can_sends.append(hyundaican.create_clu11(self.packer, self.frame, CS.clu11, Buttons.CANCEL))
elif CS.out.cruiseState.standstill:
elif CC.cruiseControl.resume:
# send resume at a max freq of 10Hz
if (self.frame - self.last_button_frame) * DT_CTRL > 0.1:
# send 25 messages at a time to increases the likelihood of resume being accepted
Expand Down
11 changes: 4 additions & 7 deletions selfdrive/car/mazda/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ def update(self, CC, CS):
CS.out.steeringTorque, CarControllerParams)
self.steer_rate_limited = new_steer != apply_steer

if CC.enabled:
if CS.out.standstill and self.frame % 5 == 0:
# Mazda Stop and Go requires a RES button (or gas) press if the car stops more than 3 seconds
# Send Resume button at 20hz if we're engaged at standstill to support full stop and go!
# TODO: improve the resume trigger logic by looking at actual radar data
can_sends.append(mazdacan.create_button_cmd(self.packer, self.CP.carFingerprint, CS.crz_btns_counter, Buttons.RESUME))

if CC.cruiseControl.cancel:
# If brake is pressed, let us wait >70ms before trying to disable crz to avoid
# a race condition with the stock system, where the second cancel from openpilot
Expand All @@ -48,6 +41,10 @@ def update(self, CC, CS):
can_sends.append(mazdacan.create_button_cmd(self.packer, self.CP.carFingerprint, CS.crz_btns_counter, Buttons.CANCEL))
else:
self.brake_counter = 0
if CC.cruiseControl.resume and self.frame % 5 == 0:
# Mazda Stop and Go requires a RES button (or gas) press if the car stops more than 3 seconds
# Send Resume button when planner wants car to move
can_sends.append(mazdacan.create_button_cmd(self.packer, self.CP.carFingerprint, CS.crz_btns_counter, Buttons.RESUME))

self.apply_steer_last = apply_steer

Expand Down
5 changes: 2 additions & 3 deletions selfdrive/car/volkswagen/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ def update(self, CC, CS, ext_bus):
# Cancel ACC if it's engaged with OP disengaged.
self.graButtonStatesToSend = BUTTON_STATES.copy()
self.graButtonStatesToSend["cancel"] = True
elif CC.enabled and CS.out.cruiseState.standstill:
# Blip the Resume button if we're engaged at standstill.
# FIXME: This is a naive implementation, improve with visiond or radar input.
elif CC.cruiseControl.resume:
# Send Resume button when planner wants car to move
self.graButtonStatesToSend = BUTTON_STATES.copy()
self.graButtonStatesToSend["resumeCruise"] = True

Expand Down
4 changes: 4 additions & 0 deletions selfdrive/controls/controlsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,10 @@ def publish_logs(self, CS, start_time, CC, lac_log):
if self.joystick_mode and self.sm.rcv_frame['testJoystick'] > 0 and self.sm['testJoystick'].buttons[0]:
CC.cruiseControl.cancel = True

speeds = self.sm['longitudinalPlan'].speeds
if len(speeds):
CC.cruiseControl.resume = self.enabled and CS.cruiseState.standstill and speeds[-1] > 0.1

hudControl = CC.hudControl
hudControl.setSpeed = float(self.v_cruise_kph * CV.KPH_TO_MS)
hudControl.speedVisible = self.enabled
Expand Down
5 changes: 5 additions & 0 deletions selfdrive/test/longitudinal_maneuvers/maneuver.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(self, title, duration, **kwargs):

self.only_lead2 = kwargs.get("only_lead2", False)
self.only_radar = kwargs.get("only_radar", False)
self.ensure_start = kwargs.get("ensure_start", False)

self.duration = duration
self.title = title
Expand Down Expand Up @@ -52,5 +53,9 @@ def evaluate(self):
print("Crashed!!!!")
valid = False

if self.ensure_start and log['v_rel'] > 0 and log['speeds'][-1] <= 0.1:
print('Planner not starting!')
valid = False

print("maneuver end", valid)
return valid, np.array(logs)
3 changes: 3 additions & 0 deletions selfdrive/test/longitudinal_maneuvers/plant.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(self, lead_relevancy=False, speed=0.0, distance_lead=2.0,
self.distance = 0.
self.speed = speed
self.acceleration = 0.0
self.speeds = []

# lead car
self.distance_lead = distance_lead
Expand Down Expand Up @@ -98,6 +99,7 @@ def step(self, v_lead=0.0, prob=1.0, v_cruise=50.):
self.planner.update(sm)
self.speed = self.planner.v_desired_filter.x
self.acceleration = self.planner.a_desired
self.speeds = self.planner.v_desired_trajectory.tolist()
fcw = self.planner.fcw
self.distance_lead = self.distance_lead + v_lead * self.ts

Expand Down Expand Up @@ -129,6 +131,7 @@ def step(self, v_lead=0.0, prob=1.0, v_cruise=50.):
"distance": self.distance,
"speed": self.speed,
"acceleration": self.acceleration,
"speeds": self.speeds,
"distance_lead": self.distance_lead,
"fcw": fcw,
}
Expand Down
12 changes: 12 additions & 0 deletions selfdrive/test/longitudinal_maneuvers/test_longitudinal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import unittest

from common.params import Params
from selfdrive.controls.lib.longitudinal_mpc_lib.long_mpc import STOP_DISTANCE
from selfdrive.test.longitudinal_maneuvers.maneuver import Maneuver


Expand Down Expand Up @@ -106,6 +107,17 @@
breakpoints=[1., 1.01, 11.],
cruise_values=[float("nan"), 15., 15.],
),
# controls relies on planner commanding to move for stock-ACC resume spamming
Maneuver(
"resume from a stop",
duration=20.,
initial_speed=0.,
lead_relevancy=True,
initial_distance_lead=STOP_DISTANCE,
speed_lead_values=[0., 0., 2.],
breakpoints=[1., 10., 15.],
ensure_start=True,
),
]


Expand Down