Skip to content

Commit

Permalink
GAC: allow profile changes in Experimental Mode (commaai#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnyhaibin authored Jun 6, 2023
1 parent 955926a commit 65de8af
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion selfdrive/car/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ def get_sp_distance(self, gac_tr, gac_max, gac_dict=None):
return next((key for key, value in gac_dict.items() if value == gac_tr), gac_max)

def toggle_gac(self, cs_out, CS, gac_button, gac_min, gac_max, gac_default, inc_dec):
if (not (self.CP.openpilotLongitudinalControl or self.gac)) or (self.experimental_mode and self.CP.openpilotLongitudinalControl):
if not (self.CP.openpilotLongitudinalControl or self.gac):
cs_out.gapAdjustCruiseTr = 4
CS.gac_tr = gac_default
return
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/toyota/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def _update(self, c):
(self.CS.prev_lkas_enabled == 1 and not self.CS.lkas_enabled):
self.CS.madsEnabled = not self.CS.madsEnabled
self.CS.madsEnabled = self.get_acc_mads(ret.cruiseState.enabled, self.CS.accEnabled, self.CS.madsEnabled)
if (not (self.CP.openpilotLongitudinalControl or self.gac)) or (self.experimental_mode and self.CP.openpilotLongitudinalControl):
if not (self.CP.openpilotLongitudinalControl or self.gac):
ret.gapAdjustCruiseTr = 3
else:
if self.gac_min != 1:
Expand Down
4 changes: 1 addition & 3 deletions selfdrive/controls/lib/longitudinal_mpc_lib/long_mpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,7 @@ def update(self, carstate, radarstate, v_cruise, x, v, a, j):

self.params[:,2] = np.min(x_obstacles, axis=1)
self.params[:,3] = np.copy(self.prev_a)
self.params[:,4] = T_FOLLOW
if self.mode == 'acc':
self.params[:,4] = self.desired_TF
self.params[:,4] = self.desired_TF

self.run()
if (np.any(lead_xv_0[FCW_IDXS,0] - self.x_sol[FCW_IDXS,0] < CRASH_DISTANCE) and
Expand Down
7 changes: 3 additions & 4 deletions selfdrive/ui/qt/onroad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ void OnroadWindow::mousePressEvent(QMouseEvent* e) {
SubMaster &sm = *(uiState()->sm);
auto longitudinal_plan = sm["longitudinalPlan"].getLongitudinalPlan();
auto car_state = sm["carState"].getCarState();
auto controls_state = sm["controlsState"].getControlsState();

QRect dlp_btn_rect = QRect(bdr_s * 2 + 220, (rect().bottom() - footer_h / 2 - 75) - scene.rn_offset, 150, 150);
QRect gac_btn_rect = QRect(bdr_s * 2 + 220 + 180, (rect().bottom() - footer_h / 2 - 75) - scene.rn_offset, 150, 150);
Expand All @@ -165,8 +164,8 @@ void OnroadWindow::mousePressEvent(QMouseEvent* e) {
scene.dynamic_lane_profile = scene.dynamic_lane_profile > 2 ? 0 : scene.dynamic_lane_profile;
params.put("DynamicLaneProfile", std::to_string(scene.dynamic_lane_profile));
propagate_event = false;
} else if (scene.gac && scene.gac_mode != 0 && scene.longitudinal_control && !controls_state.getExperimentalMode() &&
car_state.getCruiseState().getAvailable() && scene.sleep_btn_opacity == 20 && gac_btn_rect.contains(e->x(), e->y())) {
} else if (scene.gac && scene.gac_mode != 0 && scene.longitudinal_control && car_state.getCruiseState().getAvailable() &&
scene.sleep_btn_opacity == 20 && gac_btn_rect.contains(e->x(), e->y())) {
scene.gac_tr--;
scene.gac_tr = scene.gac_tr < scene.gac_min ? scene.gac_max : scene.gac_tr;
params.put("GapAdjustCruiseTr", std::to_string(scene.gac_tr));
Expand Down Expand Up @@ -445,7 +444,7 @@ void AnnotatedCameraWidget::updateState(const UIState &s) {

setProperty("hideVEgoUi", s.scene.hide_vego_ui);

setProperty("gac", s.scene.gac && s.scene.gac_mode != 0 && s.scene.longitudinal_control && !cs.getExperimentalMode() &&
setProperty("gac", s.scene.gac && s.scene.gac_mode != 0 && s.scene.longitudinal_control &&
car_state.getCruiseState().getAvailable());
setProperty("gacTr", s.scene.gac_tr);

Expand Down

0 comments on commit 65de8af

Please sign in to comment.