diff --git a/opendbc b/opendbc index 83d4cb9fd..e95ed311c 160000 --- a/opendbc +++ b/opendbc @@ -1 +1 @@ -Subproject commit 83d4cb9fd871a563f4a0af0102992c0b52c94310 +Subproject commit e95ed311c10547026143b539a33341425cbec9ea diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index 586d215ff..db80bcdf4 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -1,6 +1,6 @@ from cereal import car from common.conversions import Conversions as CV -from common.numpy_fast import clip, interp +from common.numpy_fast import clip from common.realtime import DT_CTRL from opendbc.can.packer import CANPacker from selfdrive.car import apply_std_steer_torque_limits @@ -123,12 +123,9 @@ class CarController: if self.frame % 2 == 0 and self.CP.openpilotLongitudinalControl: accel = actuators.accel - jerk = 0 - if CC.longActive: - jerk = clip(2.0 * (accel - CS.out.aEgo), -12.7, 12.7) - if accel < 0: - accel = interp(accel - CS.out.aEgo, [-1.0, -0.5], [2 * accel, accel]) + #TODO unclear if this is needed + jerk = 3.0 if actuators.longControlState == LongCtrlState.pid else 1.0 accel = clip(accel, CarControllerParams.ACCEL_MIN, CarControllerParams.ACCEL_MAX) diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index f94cc508a..df5cb6ae6 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -94,7 +94,7 @@ def create_lfahda_mfc(packer, enabled, hda_set_speed=0): } return packer.make_can_msg("LFAHDA_MFC", 0, values) -def create_acc_commands(packer, enabled, accel, jerk, idx, lead_visible, set_speed, stopping, gas_pressed): +def create_acc_commands(packer, enabled, accel, upper_jerk, idx, lead_visible, set_speed, stopping, gas_pressed): commands = [] scc11_values = { @@ -102,12 +102,12 @@ def create_acc_commands(packer, enabled, accel, jerk, idx, lead_visible, set_spe "TauGapSet": 4, "VSetDis": set_speed if enabled else 0, "AliveCounterACC": idx % 0x10, - "ObjValid": 0, # TODO: these two bits may allow for better longitudinal control - "ACC_ObjStatus": 0, + "ObjValid": 1, # close lead makes controls tighter + "ACC_ObjStatus": 1, # close lead makes controls tighter "ACC_ObjLatPos": 0, "ACC_ObjRelSpd": 0, - "ACC_ObjDist": 0, - } + "ACC_ObjDist": 1, # close lead makes controls tighter + } commands.append(packer.make_can_msg("SCC11", 0, scc11_values)) scc12_values = { @@ -125,8 +125,8 @@ def create_acc_commands(packer, enabled, accel, jerk, idx, lead_visible, set_spe scc14_values = { "ComfortBandUpper": 0.0, # stock usually is 0 but sometimes uses higher values "ComfortBandLower": 0.0, # stock usually is 0 but sometimes uses higher values - "JerkUpperLimit": max(jerk, 1.0) if not stopping else 0, # stock usually is 1.0 but sometimes uses higher values - "JerkLowerLimit": max(-jerk, 1.0), # stock usually is 0.5 but sometimes uses higher values + "JerkUpperLimit": upper_jerk, # stock usually is 1.0 but sometimes uses higher values + "JerkLowerLimit": 5.0, # stock usually is 0.5 but sometimes uses higher values "ACCMode": 2 if enabled and gas_pressed else 1 if enabled else 4, # stock will always be 4 instead of 0 after first disengage "ObjGap": 2 if lead_visible else 0, # 5: >30, m, 4: 25-30 m, 3: 20-25 m, 2: < 20 m, 0: no lead } diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index 97b8b30dc..f905586fb 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -43,13 +43,15 @@ class CarInterface(CarInterfaceBase): tire_stiffness_factor = 1. ret.stoppingControl = True - ret.vEgoStopping = 1.0 + ret.startingState = True + ret.vEgoStarting = 0.1 + ret.startAccel = 2.0 - ret.longitudinalTuning.kpV = [0.1] + ret.longitudinalTuning.kpV = [0.5] ret.longitudinalTuning.kiV = [0.0] - ret.stopAccel = 0.0 - ret.longitudinalActuatorDelayUpperBound = 1.0 # s + ret.longitudinalActuatorDelayLowerBound = 0.5 # s + ret.longitudinalActuatorDelayUpperBound = 0.5 # s if candidate in (CAR.SANTA_FE, CAR.SANTA_FE_2022, CAR.SANTA_FE_HEV_2022, CAR.SANTA_FE_PHEV_2022): ret.lateralTuning.pid.kf = 0.00005 ret.mass = 3982. * CV.LB_TO_KG + STD_CARGO_KG diff --git a/selfdrive/controls/lib/longitudinal_planner.py b/selfdrive/controls/lib/longitudinal_planner.py index 8162d1007..b9b16e34f 100755 --- a/selfdrive/controls/lib/longitudinal_planner.py +++ b/selfdrive/controls/lib/longitudinal_planner.py @@ -66,7 +66,8 @@ class LongitudinalPlanner: self.solverExecutionTime = 0.0 def read_param(self): - self.mpc.mode = 'blended' if self.params.get_bool('EndToEndLong') else 'acc' + e2e = self.params.get_bool('EndToEndLong') and self.CP.openpilotLongitudinalControl + self.mpc.mode = 'blended' if e2e else 'acc' def parse_model(self, model_msg): if (len(model_msg.position.x) == 33 and diff --git a/selfdrive/test/process_replay/ref_commit b/selfdrive/test/process_replay/ref_commit index 8878e0e1f..2821f957e 100644 --- a/selfdrive/test/process_replay/ref_commit +++ b/selfdrive/test/process_replay/ref_commit @@ -1 +1 @@ -8137b41a0520d2b4a0ca223f9934957ae21695e5 +bd712b78c1ef351343b60e7ea527d09583e8acb7 diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index 33b16b105..e5e563454 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -65,6 +65,12 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) { "", "../assets/offroad/icon_road.png", }, + { + "ExperimentalLongitudinalEnabled", + tr("Experimental openpilot longitudinal control"), + tr("WARNING: openpilot longitudinal control is experimental for this car and will disable AEB."), + "../assets/offroad/icon_speed_limit.png", + }, #ifdef ENABLE_MAPS { "NavSettingTime24h", @@ -92,23 +98,7 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) { toggles[param.toStdString()] = toggle; } - QObject::connect(toggles["EndToEndLong"], &ParamControl::toggleFlipped, [=](bool state) { - auto cp_bytes = params.get("CarParamsPersistent"); - if (!cp_bytes.empty()) { - AlignedBuffer aligned_buf; - capnp::FlatArrayMessageReader cmsg(aligned_buf.align(cp_bytes.data(), cp_bytes.size())); - cereal::CarParams::Reader CP = cmsg.getRoot(); - if (CP.getExperimentalLongitudinalAvailable()) { - params.putBool("ExperimentalLongitudinalEnabled", state); - } else { - params.remove("ExperimentalLongitudinalEnabled"); - } - } else { - params.remove("ExperimentalLongitudinalEnabled"); - } - }); - - connect(uiState(), &UIState::offroadTransition, [=]() { + connect(toggles["ExperimentalLongitudinalEnabled"], &ToggleControl::toggleFlipped, [=]() { updateToggles(); }); } @@ -118,8 +108,8 @@ void TogglesPanel::showEvent(QShowEvent *event) { } void TogglesPanel::updateToggles() { - // update e2e toggle - auto toggle = toggles["EndToEndLong"]; + auto e2e_toggle = toggles["EndToEndLong"]; + auto op_long_toggle = toggles["ExperimentalLongitudinalEnabled"]; const QString e2e_description = tr("Let the driving model control the gas and brakes. openpilot will drive as it thinks a human would. Super experimental."); auto cp_bytes = params.get("CarParamsPersistent"); @@ -128,29 +118,31 @@ void TogglesPanel::updateToggles() { capnp::FlatArrayMessageReader cmsg(aligned_buf.align(cp_bytes.data(), cp_bytes.size())); cereal::CarParams::Reader CP = cmsg.getRoot(); - const bool exp_long = CP.getExperimentalLongitudinalAvailable(); - const bool op_long = CP.getOpenpilotLongitudinalControl() && !CP.getExperimentalLongitudinalAvailable(); + if (!CP.getExperimentalLongitudinalAvailable()) { + params.remove("ExperimentalLongitudinalEnabled"); + } + op_long_toggle->setVisible(CP.getExperimentalLongitudinalAvailable()); - if (op_long) { + const bool op_long = CP.getOpenpilotLongitudinalControl() && !CP.getExperimentalLongitudinalAvailable(); + const bool exp_long_enabled = CP.getExperimentalLongitudinalAvailable() && params.getBool("ExperimentalLongitudinalEnabled"); + if (op_long || exp_long_enabled) { // normal description and toggle - params.remove("ExperimentalLongitudinalEnabled"); - toggle->setDescription(e2e_description); - } else if (exp_long) { - toggle->setDescription("WARNING: openpilot longitudinal control is experimental for this car and will disable AEB.

" + e2e_description); - if (params.getBool("EndToEndLong") && !params.getBool("ExperimentalLongitudinalEnabled")) { - params.remove("EndToEndLong"); - } + e2e_toggle->setEnabled(true); + e2e_toggle->setDescription(e2e_description); } else { // no long for now + e2e_toggle->setEnabled(false); params.remove("EndToEndLong"); - params.remove("ExperimentalLongitudinalEnabled"); - toggle->setDescription("openpilot longitudinal control is not currently available for this car.

" + e2e_description); + + const QString no_long = "openpilot longitudinal control is not currently available for this car."; + const QString exp_long = "Enable experimental longitudinal control to enable this."; + e2e_toggle->setDescription("" + (CP.getExperimentalLongitudinalAvailable() ? exp_long : no_long) + "

" + e2e_description); } - toggle->refresh(); - toggle->setEnabled(op_long || (exp_long && !uiState()->scene.started)); + e2e_toggle->refresh(); } else { - toggle->setDescription(e2e_description); + e2e_toggle->setDescription(e2e_description); + op_long_toggle->setVisible(false); } } diff --git a/selfdrive/ui/qt/widgets/controls.h b/selfdrive/ui/qt/widgets/controls.h index 183fbff04..1ab7df717 100644 --- a/selfdrive/ui/qt/widgets/controls.h +++ b/selfdrive/ui/qt/widgets/controls.h @@ -164,9 +164,12 @@ private: QPainter p(this); p.setPen(Qt::gray); for (int i = 0; i < inner_layout.count() - 1; ++i) { - QRect r = inner_layout.itemAt(i)->geometry(); - int bottom = r.bottom() + inner_layout.spacing() / 2; - p.drawLine(r.left() + 40, bottom, r.right() - 40, bottom); + QWidget *widget = inner_layout.itemAt(i)->widget(); + if (widget->isVisible()) { + QRect r = inner_layout.itemAt(i)->geometry(); + int bottom = r.bottom() + inner_layout.spacing() / 2; + p.drawLine(r.left() + 40, bottom, r.right() - 40, bottom); + } } } QVBoxLayout outer_layout; diff --git a/selfdrive/ui/translations/main_ja.ts b/selfdrive/ui/translations/main_ja.ts index 4ce5b7b8d..d6bd9e74e 100644 --- a/selfdrive/ui/translations/main_ja.ts +++ b/selfdrive/ui/translations/main_ja.ts @@ -108,7 +108,7 @@ DevicePanel - + Dongle ID ドングル番号 (Dongle ID) @@ -1153,7 +1153,7 @@ location set TogglesPanel - + Enable openpilot openpilot を有効化 @@ -1198,12 +1198,22 @@ location set - + + Experimental openpilot longitudinal control + + + + + <b>WARNING: openpilot longitudinal control is experimental for this car and will disable AEB.</b> + + + + Let the driving model control the gas and brakes. openpilot will drive as it thinks a human would. Super experimental. - + Disengage On Accelerator Pedal アクセル踏むと openpilot をキャンセル @@ -1213,7 +1223,7 @@ location set 有効な場合は、アクセルを踏むと openpilot をキャンセルします。 - + Show ETA in 24h Format 24時間表示 diff --git a/selfdrive/ui/translations/main_ko.ts b/selfdrive/ui/translations/main_ko.ts index a38cfaf94..cc60ba7c8 100644 --- a/selfdrive/ui/translations/main_ko.ts +++ b/selfdrive/ui/translations/main_ko.ts @@ -108,7 +108,7 @@ DevicePanel - + Dongle ID Dongle ID @@ -1153,7 +1153,7 @@ location set TogglesPanel - + Enable openpilot openpilot 사용 @@ -1198,12 +1198,22 @@ location set 🌮 e2e long 사용 (매우 실험적) 🌮 - + + Experimental openpilot longitudinal control + + + + + <b>WARNING: openpilot longitudinal control is experimental for this car and will disable AEB.</b> + + + + Let the driving model control the gas and brakes. openpilot will drive as it thinks a human would. Super experimental. - + Disengage On Accelerator Pedal 가속페달 조작시 해제 @@ -1213,7 +1223,7 @@ location set 활성화된 경우 가속 페달을 누르면 openpilot이 해제됩니다. - + Show ETA in 24h Format 24시간 형식으로 도착예정시간 표시 diff --git a/selfdrive/ui/translations/main_pt-BR.ts b/selfdrive/ui/translations/main_pt-BR.ts index 9f3bd5982..2b3acb369 100644 --- a/selfdrive/ui/translations/main_pt-BR.ts +++ b/selfdrive/ui/translations/main_pt-BR.ts @@ -108,7 +108,7 @@ DevicePanel - + Dongle ID Dongle ID @@ -1157,7 +1157,7 @@ trabalho definido TogglesPanel - + Enable openpilot Ativar openpilot @@ -1202,12 +1202,22 @@ trabalho definido 🌮 End-to-end longitudinal (experimental) 🌮 - + + Experimental openpilot longitudinal control + + + + + <b>WARNING: openpilot longitudinal control is experimental for this car and will disable AEB.</b> + + + + Let the driving model control the gas and brakes. openpilot will drive as it thinks a human would. Super experimental. - + Disengage On Accelerator Pedal Desacionar Com Pedal Do Acelerador @@ -1217,7 +1227,7 @@ trabalho definido Quando ativado, pressionar o pedal do acelerador desacionará o openpilot. - + Show ETA in 24h Format Mostrar ETA em formato 24h diff --git a/selfdrive/ui/translations/main_zh-CHS.ts b/selfdrive/ui/translations/main_zh-CHS.ts index 94ed83211..a00bf2830 100644 --- a/selfdrive/ui/translations/main_zh-CHS.ts +++ b/selfdrive/ui/translations/main_zh-CHS.ts @@ -108,7 +108,7 @@ DevicePanel - + Dongle ID 设备ID(Dongle ID) @@ -1151,7 +1151,7 @@ location set TogglesPanel - + Enable openpilot 启用openpilot @@ -1196,12 +1196,22 @@ location set - + + Experimental openpilot longitudinal control + + + + + <b>WARNING: openpilot longitudinal control is experimental for this car and will disable AEB.</b> + + + + Let the driving model control the gas and brakes. openpilot will drive as it thinks a human would. Super experimental. - + Disengage On Accelerator Pedal 踩油门时取消控制 @@ -1211,7 +1221,7 @@ location set 启用后,踩下油门踏板将取消openpilot。 - + Show ETA in 24h Format 以24小时格式显示预计到达时间 diff --git a/selfdrive/ui/translations/main_zh-CHT.ts b/selfdrive/ui/translations/main_zh-CHT.ts index 754d41bbd..52bd30136 100644 --- a/selfdrive/ui/translations/main_zh-CHT.ts +++ b/selfdrive/ui/translations/main_zh-CHT.ts @@ -108,7 +108,7 @@ DevicePanel - + Dongle ID Dongle ID @@ -1153,7 +1153,7 @@ location set TogglesPanel - + Enable openpilot 啟用 openpilot @@ -1198,12 +1198,22 @@ location set - + + Experimental openpilot longitudinal control + + + + + <b>WARNING: openpilot longitudinal control is experimental for this car and will disable AEB.</b> + + + + Let the driving model control the gas and brakes. openpilot will drive as it thinks a human would. Super experimental. - + Disengage On Accelerator Pedal 油門取消控車 @@ -1213,7 +1223,7 @@ location set 啟用後,踩踏油門將會取消 openpilot 控制。 - + Show ETA in 24h Format 預計到達時間單位改用 24 小時制