mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-03-02 07:53:51 +08:00
Merge pull request #4 from eFiniLan/dragonpilot-dev-lkmod
加入 honda 的 Lane Keeping 模式開關
This commit is contained in:
@@ -76,6 +76,8 @@ struct CarEvent @0x9b1657f34caf3ad3 {
|
||||
controlsFailed @51;
|
||||
sensorDataInvalid @52;
|
||||
commIssue @53;
|
||||
manualSteeringRequired @54;
|
||||
manualSteeringRequiredBlinkersOn @55;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ def process_hud_alert(hud_alert):
|
||||
|
||||
HUDData = namedtuple("HUDData",
|
||||
["pcm_accel", "v_cruise", "mini_car", "car", "X4",
|
||||
"lanes", "beep", "chime", "fcw", "acc_alert", "steer_required"])
|
||||
"lanes", "beep", "chime", "fcw", "acc_alert", "steer_required", "dashed_lanes"])
|
||||
|
||||
|
||||
class CarController(object):
|
||||
@@ -126,7 +126,7 @@ class CarController(object):
|
||||
fcw_display, steer_required, acc_alert = process_hud_alert(hud_alert)
|
||||
|
||||
hud = HUDData(int(pcm_accel), int(round(hud_v_cruise)), 1, hud_car,
|
||||
0xc1, hud_lanes, int(snd_beep), snd_chime, fcw_display, acc_alert, steer_required)
|
||||
0xc1, hud_lanes, int(snd_beep), snd_chime, fcw_display, acc_alert, steer_required, CS.lkMode)
|
||||
|
||||
# **** process the car messages ****
|
||||
|
||||
@@ -146,7 +146,7 @@ class CarController(object):
|
||||
apply_brake = int(clip(self.brake_last * BRAKE_MAX, 0, BRAKE_MAX - 1))
|
||||
apply_steer = int(clip(-actuators.steer * STEER_MAX, -STEER_MAX, STEER_MAX))
|
||||
|
||||
lkas_active = enabled and not CS.steer_not_allowed
|
||||
lkas_active = enabled and not CS.steer_not_allowed and CS.lkMode
|
||||
|
||||
# Send CAN commands.
|
||||
can_sends = []
|
||||
|
||||
@@ -198,6 +198,8 @@ class CarState(object):
|
||||
K=[[0.12287673], [0.29666309]])
|
||||
self.v_ego = 0.0
|
||||
|
||||
self.lkMode = True
|
||||
|
||||
def update(self, cp, cp_cam):
|
||||
|
||||
# car params
|
||||
@@ -268,6 +270,13 @@ class CarState(object):
|
||||
self.angle_steers = cp.vl["STEERING_SENSORS"]['STEER_ANGLE']
|
||||
self.angle_steers_rate = cp.vl["STEERING_SENSORS"]['STEER_ANGLE_RATE']
|
||||
|
||||
# when user presses LKAS button on steering wheel
|
||||
if self.cruise_setting == 1:
|
||||
if cp.vl["SCM_BUTTONS"]["CRUISE_SETTING"] == 0:
|
||||
if self.lkMode:
|
||||
self.lkMode = False
|
||||
else:
|
||||
self.lkMode = True
|
||||
self.cruise_setting = cp.vl["SCM_BUTTONS"]['CRUISE_SETTING']
|
||||
self.cruise_buttons = cp.vl["SCM_BUTTONS"]['CRUISE_BUTTONS']
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ def create_ui_commands(packer, pcm_speed, hud, car_fingerprint, is_metric, idx):
|
||||
'SET_ME_X48': 0x48,
|
||||
'STEERING_REQUIRED': hud.steer_required,
|
||||
'SOLID_LANES': hud.lanes,
|
||||
'DASHED_LANES': hud.dashed_lanes,
|
||||
'BEEP': hud.beep,
|
||||
}
|
||||
commands.append(packer.make_can_msg('LKAS_HUD', bus, lkas_hud_values, idx))
|
||||
|
||||
@@ -473,7 +473,11 @@ class CarInterface(object):
|
||||
# wait 1.0s before throwing the alert to avoid it popping when you turn off the car
|
||||
if self.cp_cam.can_invalid_cnt >= 100 and self.CS.CP.carFingerprint not in HONDA_BOSCH and self.CP.enableCamera:
|
||||
events.append(create_event('invalidGiraffeHonda', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT]))
|
||||
if self.CS.steer_error:
|
||||
if not self.CS.lkMode:
|
||||
events.append(create_event('manualSteeringRequired', [ET.WARNING]))
|
||||
elif self.CS.lkMode and (self.CS.left_blinker_on or self.CS.right_blinker_on):
|
||||
events.append(create_event('manualSteeringRequiredBlinkersOn', [ET.WARNING]))
|
||||
elif self.CS.steer_error:
|
||||
events.append(create_event('steerUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT]))
|
||||
elif self.CS.steer_warning:
|
||||
events.append(create_event('steerTempUnavailable', [ET.WARNING]))
|
||||
|
||||
@@ -661,4 +661,18 @@ ALERTS = [
|
||||
"",
|
||||
AlertStatus.normal, AlertSize.small,
|
||||
Priority.LOWEST, VisualAlert.steerRequired, AudibleAlert.none, .0, .0, .1),
|
||||
|
||||
Alert(
|
||||
"manualSteeringRequired",
|
||||
"STEERING REQUIRED: Lane Keeping OFF",
|
||||
"",
|
||||
AlertStatus.normal, AlertSize.small,
|
||||
Priority.LOW, VisualAlert.none, AudibleAlert.none, .0, .1, .1, alert_rate=0.25),
|
||||
|
||||
Alert(
|
||||
"manualSteeringRequiredBlinkersOn",
|
||||
"STEERING REQUIRED: Blinkers ON",
|
||||
"",
|
||||
AlertStatus.normal, AlertSize.small,
|
||||
Priority.LOW, VisualAlert.none, AudibleAlert.none, .0, .1, .1, alert_rate=0.25),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user