def config_ui_buttons(self, pedalPresent): if pedalPresent: self.btns_init[1] = [PCCModes.BUTTON_NAME, PCCModes.BUTTON_ABREVIATION, PCCModes.labels()] else: # we don't have pedal interceptor self.btns_init[1] = [ACCMode.BUTTON_NAME, ACCMode.BUTTON_ABREVIATION, ACCMode.labels()] btn = self.cstm_btns.btns[1] btn.btn_name = self.btns_init[1][0] btn.btn_label = self.btns_init[1][1] btn.btn_label2 = self.btns_init[1][2][0] btn.btn_status = 1 self.cstm_btns.update_ui_buttons(1, 1)
def config_ui_buttons(self, pcc_available, pcc_blocked_by_acc_mode): if pcc_available: self.btns_init[1] = [ PCCModes.BUTTON_NAME, PCCModes.BUTTON_ABREVIATION, PCCModes.labels() ] else: self.btns_init[1] = [ ACCMode.BUTTON_NAME, ACCMode.BUTTON_ABREVIATION, ACCMode.labels() ] btn = self.cstm_btns.btns[1] btn.btn_name = self.btns_init[1][0] btn.btn_label = self.btns_init[1][1] btn.btn_label2 = self.btns_init[1][2][0] btn.btn_status = 1 if (not pcc_available) and pcc_blocked_by_acc_mode: btn.btn_label2 = self.btns_init[1][2][1] self.cstm_btns.update_ui_buttons(1, 1)
def __init__(self, CP): super().__init__(CP) self.params = Params() self.CL_MIN_V = 8.9 self.CL_MAX_A = 20.0 # labels for buttons self.btns_init = [ ["alca", "ALC", [""]], [ ACCMode.BUTTON_NAME, ACCMode.BUTTON_ABREVIATION, ACCMode.labels() ], ["dsp", "DSP", ["OP", "MIN", "OFF", "GYRO"]], ["", "", [""]], ["msg", "MSG", [""]], ["sound", "SND", [""]], ] ### START OF MAIN CONFIG OPTIONS ### ### Do NOT modify here, modify in /data/bb_openpilot.cfg and reboot self.forcePedalOverCC = True self.usesApillarHarness = False self.enableHSO = True self.enableALCA = True self.enableDasEmulation = True self.enableRadarEmulation = True self.enableDriverMonitor = True self.enableShowCar = True self.enableShowLogo = True self.hasNoctuaFan = False self.limitBatteryMinMax = False self.limitBattery_Min = 60 self.limitBattery_Max = 70 self.doAutoUpdate = True self.blockUploadWhileTethering = False self.tetherIP = "127.0.0." self.useTeslaGPS = False self.useTeslaMapData = False self.hasTeslaIcIntegration = False self.useTeslaRadar = False self.useWithoutHarness = False self.radarVIN = " " self.enableLdw = True self.radarOffset = 0.0 self.radarPosition = 0 self.radarEpasType = 0 self.fix1916 = False self.forceFingerprintTesla = False self.spinnerText = "" self.hsoNumbPeriod = 1.5 self.ldwNumbPeriod = 1.5 self.tapBlinkerExtension = 2 self.ahbOffDuration = 5 self.roadCameraID = "" self.driverCameraID = "" self.roadCameraFx = 0.73 self.driverCameraFx = 0.75 self.roadCameraFlip = 0 self.driverCameraFlip = 0 self.monitorForcedRes = "" # read config file read_config_file(self) ### END OF MAIN CONFIG OPTIONS ### self.apEnabled = True self.apFollowTimeInS = 2.5 # time in seconds to follow self.keepEonOff = False self.alcaEnabled = True self.mapAwareSpeed = False # Tesla Model self.teslaModelDetected = 1 self.teslaModel = self.params.get("TeslaModel") if self.teslaModel: self.teslaModel = self.teslaModel.decode() if self.teslaModel is None: self.teslaModel = "S" self.teslaModelDetected = 0 # for map integration self.csaRoadCurvC3 = 0.0 self.csaRoadCurvC2 = 0.0 self.csaRoadCurvRange = 0.0 self.csaRoadCurvUsingTspline = 0 self.csaOfframpCurvC3 = 0.0 self.csaOfframpCurvC2 = 0.0 self.csaOfframpCurvRange = 0.0 self.csaOfframpCurvUsingTspline = 0 self.roadCurvHealth = 0 self.roadCurvRange = 0.0 self.roadCurvC0 = 0.0 self.roadCurvC1 = 0.0 self.roadCurvC2 = 0.0 self.roadCurvC3 = 0.0 self.meanFleetSplineSpeedMPS = 0.0 self.UI_splineID = 0 self.meanFleetSplineAccelMPS2 = 0.0 self.medianFleetSpeedMPS = 0.0 self.topQrtlFleetSplineSpeedMPS = 0.0 self.splineLocConfidence = 0 self.baseMapSpeedLimitMPS = 0.0 self.bottomQrtlFleetSpeedMPS = 0.0 self.rampType = 0 self.mapBasedSuggestedSpeed = 0.0 self.splineBasedSuggestedSpeed = 0.0 self.map_suggested_speed = 0.0 self.gpsLongitude = 0.0 self.gpsLatitude = 0.0 self.gpsAccuracy = 0.0 self.gpsElevation = 0.0 self.gpsHeading = 0.0 self.gpsVehicleSpeed = 0.0 self.speed_limit_ms = 0.0 self.userSpeedLimitOffsetKph = 0.0 self.DAS_fusedSpeedLimit = 0 self.brake_only = CP.enableCruise self.last_cruise_stalk_pull_time = 0 self.CP = CP self.user_gas = 0.0 self.user_gas_pressed = False self.pedal_interceptor_state = self.prev_pedal_interceptor_state = 0 self.pedal_interceptor_value = 0.0 self.pedal_interceptor_value2 = 0.0 self.pedal_idx = self.prev_pedal_idx = 0 self.brake_switch_prev = 0 self.brake_switch_ts = 0 self.cruise_buttons = 0 self.turn_signal_state_left = ( 0 # 0 = off, 1 = on (blinking), 2 = failed, 3 = default ) self.turn_signal_state_right = ( 0 # 0 = off, 1 = on (blinking), 2 = failed, 3 = default ) self.prev_turn_signal_blinking = False self.turn_signal_blinking = False self.prev_turn_signal_stalk_state = 0 self.turn_signal_stalk_state = ( 0 # 0 = off, 1 = indicate left (stalk down), 2 = indicate right (stalk up) ) self.steer_warning = 0 self.stopped = 0 # variables used for the fake DAS creation self.DAS_info_frm = -1 self.DAS_info_msg = 0 self.DAS_status_frm = 0 self.DAS_status_idx = 0 self.DAS_status2_frm = 0 self.DAS_status2_idx = 0 self.DAS_bodyControls_frm = 0 self.DAS_bodyControls_idx = 0 self.DAS_lanes_frm = 0 self.DAS_lanes_idx = 0 self.DAS_objects_frm = 0 self.DAS_objects_idx = 0 self.DAS_pscControl_frm = 0 self.DAS_pscControl_idx = 0 self.DAS_warningMatrix0_idx = 0 self.DAS_warningMatrix1_idx = 0 self.DAS_warningMatrix3_idx = 0 self.DAS_telemetryPeriodic1_idx = 0 self.DAS_telemetryPeriodic2_idx = 0 self.DAS_telemetryEvent1_idx = 0 self.DAS_telemetryEvent2_idx = 0 self.DAS_control_idx = 0 # BB notification messages for DAS self.DAS_canErrors = 0 self.DAS_plannerErrors = 0 self.DAS_doorOpen = 0 self.DAS_notInDrive = 0 self.summonButton = 0 # BB variables for pedal CC self.pedal_speed_kph = 0.0 # BB UIEvents self.UE = UIEvents(self) # BB PCC self.regenLight = 0 self.torqueLevel = 0.0 # BB variable for custom buttons self.cstm_btns = UIButtons(self, "Tesla Model S", "tesla", self.enableShowLogo, self.enableShowCar) # BB custom message counter self.custom_alert_counter = ( -1 ) # set to 100 for 1 second display; carcontroller will take down to zero # BB steering_wheel_stalk last position, used by ACC and ALCA self.steering_wheel_stalk = None # BB carConfig data used to change IC info self.real_carConfig = None self.real_dasHw = 0 # BB visiond last type self.last_visiond = self.cstm_btns.btns[3].btn_label2 # vEgo kalman filter dt = 0.01 # Q = np.matrix([[10.0, 0.0], [0.0, 100.0]]) # R = 1e3 self.v_ego_kf = KF1D( x0=[[0.0], [0.0]], A=[[1.0, dt], [0.0, 1.0]], C=[1.0, 0.0], K=[[0.12287673], [0.29666309]], ) self.v_ego = 0.0 self.imperial_speed_units = True # The current max allowed cruise speed. Actual cruise speed sent to the car # may be lower, depending on traffic. self.v_cruise_pcm = 0.0 # Actual cruise speed currently active on the car. self.v_cruise_actual = 0.0 # ALCA params self.ALCA_enabled = False self.ALCA_total_steps = 100 self.ALCA_direction = 0 self.ALCA_error = False self.angle_offset = 0.0 self.init_angle_offset = False # AHB params self.ahbHighBeamStalkPosition = 0 self.ahbEnabled = 0 self.ahbLoBeamOn = 0 self.ahbHiBeamOn = 0 self.ahbNightMode = 0
def __init__(self, CP): # labels for buttons self.btns_init = [["alca", "ALC", ["MadMax", "Normal", "Calm"]], [ACCMode.BUTTON_NAME, ACCMode.BUTTON_ABREVIATION, ACCMode.labels()], ["steer", "STR", [""]], ["brake", "BRK", [""]], ["msg", "MSG", [""]], ["sound", "SND", [""]]] if (CP.carFingerprint == CAR.MODELS): # ALCA PARAMS # max REAL delta angle for correction vs actuator self.CL_MAX_ANGLE_DELTA_BP = [10., 44.] self.CL_MAX_ANGLE_DELTA = [2.2, .3] # adjustment factor for merging steer angle to actuator; should be over 4; the higher the smoother self.CL_ADJUST_FACTOR_BP = [10., 44.] self.CL_ADJUST_FACTOR = [16. , 8.] # reenrey angle when to let go self.CL_REENTRY_ANGLE_BP = [10., 44.] self.CL_REENTRY_ANGLE = [5. , 5.] # a jump in angle above the CL_LANE_DETECT_FACTOR means we crossed the line self.CL_LANE_DETECT_BP = [10., 44.] self.CL_LANE_DETECT_FACTOR = [1.5, 1.5] self.CL_LANE_PASS_BP = [10., 20., 44.] self.CL_LANE_PASS_TIME = [40.,10., 3.] # change lane delta angles and other params self.CL_MAXD_BP = [10., 32., 44.] self.CL_MAXD_A = [.358, 0.084, 0.042] #delta angle based on speed; needs fine tune, based on Tesla steer ratio of 16.75 self.CL_MIN_V = 8.9 # do not turn if speed less than x m/2; 20 mph = 8.9 m/s # do not turn if actuator wants more than x deg for going straight; this should be interp based on speed self.CL_MAX_A_BP = [10., 44.] self.CL_MAX_A = [10., 10.] # define limits for angle change every 0.1 s # we need to force correction above 10 deg but less than 20 # anything more means we are going to steep or not enough in a turn self.CL_MAX_ACTUATOR_DELTA = 2. self.CL_MIN_ACTUATOR_DELTA = 0. self.CL_CORRECTION_FACTOR = 1. #duration after we cross the line until we release is a factor of speed self.CL_TIMEA_BP = [10., 32., 44.] self.CL_TIMEA_T = [0.7 ,0.50, 0.40] #duration to wait (in seconds) with blinkers on before starting to turn self.CL_WAIT_BEFORE_START = 1 #END OF ALCA PARAMS self.brake_only = CP.enableCruise self.last_cruise_stalk_pull_time = 0 self.CP = CP self.user_gas = 0. self.user_gas_pressed = False self.pedal_interceptor_state = 0 self.pedal_interceptor_value = 0. self.pedal_interceptor_value2 = 0. self.pedal_interceptor_missed_counter = 0 self.brake_switch_prev = 0 self.brake_switch_ts = 0 self.cruise_buttons = 0 self.blinker_on = 0 self.left_blinker_on = 0 self.right_blinker_on = 0 self.steer_warning = 0 self.stopped = 0 self.frame_humanSteered = 0 # Last frame human steered # variables used for the fake DAS creation self.DAS_info_frm = -1 self.DAS_info_msg = 0 self.DAS_status_frm = 0 self.DAS_status_idx = 0 self.DAS_status2_frm = 0 self.DAS_status2_idx = 0 self.DAS_bodyControls_frm = 0 self.DAS_bodyControls_idx = 0 self.DAS_lanes_frm = 0 self.DAS_lanes_idx = 0 self.DAS_objects_frm = 0 self.DAS_objects_idx = 0 self.DAS_pscControl_frm = 0 self.DAS_pscControl_idx = 0 self.DAS_warningMatrix0_idx = 0 self.DAS_warningMatrix1_idx = 0 self.DAS_warningMatrix3_idx = 0 self.DAS_telemetryPeriodic1_idx = 0 self.DAS_telemetryPeriodic2_idx = 0 self.DAS_telemetryEvent1_idx = 0 self.DAS_telemetryEvent2_idx = 0 self.DAS_control_idx = 0 #BB variables for pedal CC self.pedal_speed_kph = 0. # Pedal mode is ready, i.e. hardware is present and normal cruise is off. self.pedal_interceptor_available = False self.prev_pedal_interceptor_available = False #BB UIEvents self.UE = UIEvents(self) #BB PCC self.regenLight = 0 self.torqueLevel = 0. #BB variable for custom buttons self.cstm_btns = UIButtons(self,"Tesla Model S","tesla") #BB custom message counter self.custom_alert_counter = -1 #set to 100 for 1 second display; carcontroller will take down to zero #BB steering_wheel_stalk last position, used by ACC and ALCA self.steering_wheel_stalk = None #BB carConfig data used to change IC info self.real_carConfig = None self.real_dasHw = 0 # vEgo kalman filter dt = 0.01 # Q = np.matrix([[10.0, 0.0], [0.0, 100.0]]) # R = 1e3 self.v_ego_kf = KF1D(x0=np.matrix([[0.0], [0.0]]), A=np.matrix([[1.0, dt], [0.0, 1.0]]), C=np.matrix([1.0, 0.0]), K=np.matrix([[0.12287673], [0.29666309]])) self.v_ego = 0.0 self.imperial_speed_units = True # The current max allowed cruise speed. Actual cruise speed sent to the car # may be lower, depending on traffic. self.v_cruise_pcm = 0.0 # Actual cruise speed currently active on the car. self.v_cruise_actual = 0.0