Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
adeebshihadeh committed Apr 14, 2022
1 parent cb62750 commit cb9be4a
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 35 deletions.
2 changes: 1 addition & 1 deletion panda
17 changes: 6 additions & 11 deletions selfdrive/car/ford/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,17 @@ def __init__(self, dbc_name, CP, VM):
self.main_on_last = False
self.lkas_enabled_last = False
self.steer_alert_last = False
self.generic_toggle_last = False

def update(self, CC, CS, frame):
can_sends = []

actuators = CC.actuators
pcm_cancel_cmd = CC.cruiseControl.cancel
hud_control = CC.hudControl
lkas_enabled = CC.latActive

main_on = CS.out.cruiseState.available
generic_toggle = CS.out.genericToggle
steer_alert = hud_control.visualAlert in (VisualAlert.steerRequired, VisualAlert.ldw)

if pcm_cancel_cmd:
if CC.cruiseControl.cancel:
# cancel stock ACC
can_sends.append(fordcan.spam_cancel_button(self.packer))

Expand All @@ -53,7 +49,7 @@ def update(self, CC, CS, frame):

# send steering commands at 20Hz
if (frame % CarControllerParams.LKAS_STEER_STEP) == 0:
lca_rq = 1 if lkas_enabled else 0
lca_rq = 1 if CC.latActive else 0

# use LatCtlPath_An_Actl to actuate steering for now until curvature control is implemented
path_angle = apply_steer
Expand All @@ -74,20 +70,19 @@ def update(self, CC, CS, frame):
path_offset, path_angle, curvature_rate, curvature))


send_ui = (self.main_on_last != main_on) or (self.lkas_enabled_last != lkas_enabled) or (self.steer_alert_last != steer_alert)
send_ui = (self.main_on_last != main_on) or (self.lkas_enabled_last != CC.latActive) or (self.steer_alert_last != steer_alert)

# send lkas ui command at 1Hz or if ui state changes
if (frame % CarControllerParams.LKAS_UI_STEP) == 0 or send_ui:
can_sends.append(fordcan.create_lkas_ui_command(self.packer, main_on, lkas_enabled, steer_alert, CS.lkas_status_stock_values))
can_sends.append(fordcan.create_lkas_ui_command(self.packer, main_on, CC.latActive, steer_alert, CS.lkas_status_stock_values))

# send acc ui command at 20Hz or if ui state changes
if (frame % CarControllerParams.ACC_UI_STEP) == 0 or send_ui:
can_sends.append(fordcan.create_acc_ui_command(self.packer, main_on, lkas_enabled, CS.acc_tja_status_stock_values))
can_sends.append(fordcan.create_acc_ui_command(self.packer, main_on, CC.latActive, CS.acc_tja_status_stock_values))

self.main_on_last = main_on
self.lkas_enabled_last = lkas_enabled
self.lkas_enabled_last = CC.latActive
self.steer_alert_last = steer_alert
self.generic_toggle_last = generic_toggle

new_actuators = actuators.copy()
new_actuators.steeringAngleDeg = apply_steer
Expand Down
10 changes: 3 additions & 7 deletions selfdrive/car/ford/interface.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
from cereal import car
from common.conversions import Conversions as CV
from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint, get_safety_config
from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint
from selfdrive.car.ford.values import TransmissionType, CAR
from selfdrive.car.interfaces import CarInterfaceBase

Expand All @@ -15,8 +15,8 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None, disa
ret = CarInterfaceBase.get_std_params(candidate, fingerprint)

ret.carName = "ford"
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.ford)]
ret.dashcamOnly = True # remove once port is completed
#ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.ford)]
ret.dashcamOnly = True

# Angle-based steering
# TODO: use curvature control when ready
Expand Down Expand Up @@ -73,15 +73,11 @@ def _update(self, c):

ret.steeringRateLimited = self.CC.steer_rate_limited if self.CC is not None else False

# events
events = self.create_common_events(ret)

ret.events = events.to_msg()

return ret

# pass in a car.CarControl
# to be called @ 100hz
def apply(self, c):
ret = self.CC.update(c, self.CS, self.frame)
self.frame += 1
Expand Down
Empty file modified selfdrive/car/ford/radar_interface.py
100755 → 100644
Empty file.
12 changes: 0 additions & 12 deletions selfdrive/car/fw_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ def p16(val):
SUBARU_VERSION_RESPONSE = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER + 0x40]) + \
p16(uds.DATA_IDENTIFIER_TYPE.APPLICATION_DATA_IDENTIFICATION)

FORD_VERSION_REQUEST = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \
p16(uds.DATA_IDENTIFIER_TYPE.VEHICLE_MANUFACTURER_ECU_SOFTWARE_NUMBER)
FORD_VERSION_RESPONSE = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER + 0x40]) + \
p16(uds.DATA_IDENTIFIER_TYPE.VEHICLE_MANUFACTURER_ECU_SOFTWARE_NUMBER)


@dataclass
class Request:
Expand Down Expand Up @@ -187,13 +182,6 @@ class Request:
[TESTER_PRESENT_RESPONSE, UDS_VERSION_RESPONSE],
bus=0,
),
# Ford
Request(
"ford",
[TESTER_PRESENT_REQUEST, FORD_VERSION_REQUEST],
[TESTER_PRESENT_RESPONSE, FORD_VERSION_RESPONSE],
bus=0,
),
]


Expand Down
3 changes: 0 additions & 3 deletions selfdrive/car/tests/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from collections import namedtuple

from selfdrive.car.chrysler.values import CAR as CHRYSLER
from selfdrive.car.ford.values import CAR as FORD
from selfdrive.car.gm.values import CAR as GM
from selfdrive.car.honda.values import CAR as HONDA
from selfdrive.car.hyundai.values import CAR as HYUNDAI
Expand All @@ -16,8 +15,6 @@

# TODO: add routes for these cars
non_tested_cars = [
FORD.ESCAPE_MK4,
FORD.FOCUS_MK4,
GM.CADILLAC_ATS,
GM.HOLDEN_ASTRA,
GM.MALIBU,
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/test/process_replay/test_processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
]

# dashcamOnly makes don't need to be tested until a full port is done
excluded_interfaces = ["mock", "mazda", "tesla", "ford"]
excluded_interfaces = ["mock", "ford", "mazda", "tesla"]

BASE_URL = "https://commadataci.blob.core.windows.net/openpilotci/"

Expand Down

0 comments on commit cb9be4a

Please sign in to comment.