2
2
from openpilot .common .numpy_fast import clip
3
3
from opendbc .can .packer import CANPacker
4
4
from openpilot .selfdrive .car import apply_std_steer_angle_limits
5
- from openpilot .selfdrive .car .ford .fordcan import CanBus , create_acc_msg , create_acc_ui_msg , create_button_msg , \
6
- create_lat_ctl_msg , create_lat_ctl2_msg , create_lka_msg , create_lkas_ui_msg
5
+ from openpilot .selfdrive .car .ford import fordcan
7
6
from openpilot .selfdrive .car .ford .values import CANFD_CAR , CarControllerParams
8
7
9
8
LongCtrlState = car .CarControl .Actuators .LongControlState
@@ -27,7 +26,7 @@ def __init__(self, dbc_name, CP, VM):
27
26
self .CP = CP
28
27
self .VM = VM
29
28
self .packer = CANPacker (dbc_name )
30
- self .CAN = CanBus (CP )
29
+ self .CAN = fordcan . CanBus (CP )
31
30
self .frame = 0
32
31
33
32
self .apply_curvature_last = 0
@@ -47,15 +46,15 @@ def update(self, CC, CS, now_nanos):
47
46
48
47
### acc buttons ###
49
48
if CC .cruiseControl .cancel :
50
- can_sends .append (create_button_msg (self .packer , self .CAN .camera , CS .buttons_stock_values , cancel = True ))
51
- can_sends .append (create_button_msg (self .packer , self .CAN .main , CS .buttons_stock_values , cancel = True ))
49
+ can_sends .append (fordcan . create_button_msg (self .packer , self .CAN .camera , CS .buttons_stock_values , cancel = True ))
50
+ can_sends .append (fordcan . create_button_msg (self .packer , self .CAN .main , CS .buttons_stock_values , cancel = True ))
52
51
elif CC .cruiseControl .resume and (self .frame % CarControllerParams .BUTTONS_STEP ) == 0 :
53
- can_sends .append (create_button_msg (self .packer , self .CAN .camera , CS .buttons_stock_values , resume = True ))
54
- can_sends .append (create_button_msg (self .packer , self .CAN .main , CS .buttons_stock_values , resume = True ))
52
+ can_sends .append (fordcan . create_button_msg (self .packer , self .CAN .camera , CS .buttons_stock_values , resume = True ))
53
+ can_sends .append (fordcan . create_button_msg (self .packer , self .CAN .main , CS .buttons_stock_values , resume = True ))
55
54
# if stock lane centering isn't off, send a button press to toggle it off
56
55
# the stock system checks for steering pressed, and eventually disengages cruise control
57
56
elif CS .acc_tja_status_stock_values ["Tja_D_Stat" ] != 0 and (self .frame % CarControllerParams .ACC_UI_STEP ) == 0 :
58
- can_sends .append (create_button_msg (self .packer , self .CAN .camera , CS .buttons_stock_values , tja_toggle = True ))
57
+ can_sends .append (fordcan . create_button_msg (self .packer , self .CAN .camera , CS .buttons_stock_values , tja_toggle = True ))
59
58
60
59
### lateral control ###
61
60
# send steer msg at 20Hz
@@ -73,13 +72,13 @@ def update(self, CC, CS, now_nanos):
73
72
# TODO: extended mode
74
73
mode = 1 if CC .latActive else 0
75
74
counter = (self .frame // CarControllerParams .STEER_STEP ) % 0xF
76
- can_sends .append (create_lat_ctl2_msg (self .packer , self .CAN , mode , 0. , 0. , - apply_curvature , 0. , counter ))
75
+ can_sends .append (fordcan . create_lat_ctl2_msg (self .packer , self .CAN , mode , 0. , 0. , - apply_curvature , 0. , counter ))
77
76
else :
78
- can_sends .append (create_lat_ctl_msg (self .packer , self .CAN , CC .latActive , 0. , 0. , - apply_curvature , 0. ))
77
+ can_sends .append (fordcan . create_lat_ctl_msg (self .packer , self .CAN , CC .latActive , 0. , 0. , - apply_curvature , 0. ))
79
78
80
79
# send lka msg at 33Hz
81
80
if (self .frame % CarControllerParams .LKA_STEP ) == 0 :
82
- can_sends .append (create_lka_msg (self .packer , self .CAN ))
81
+ can_sends .append (fordcan . create_lka_msg (self .packer , self .CAN ))
83
82
84
83
### longitudinal control ###
85
84
# send acc msg at 50Hz
@@ -91,16 +90,16 @@ def update(self, CC, CS, now_nanos):
91
90
gas = CarControllerParams .INACTIVE_GAS
92
91
93
92
stopping = CC .actuators .longControlState == LongCtrlState .stopping
94
- can_sends .append (create_acc_msg (self .packer , self .CAN , CC .longActive , gas , accel , stopping ))
93
+ can_sends .append (fordcan . create_acc_msg (self .packer , self .CAN , CC .longActive , gas , accel , stopping ))
95
94
96
95
### ui ###
97
96
send_ui = (self .main_on_last != main_on ) or (self .lkas_enabled_last != CC .latActive ) or (self .steer_alert_last != steer_alert )
98
97
# send lkas ui msg at 1Hz or if ui state changes
99
98
if (self .frame % CarControllerParams .LKAS_UI_STEP ) == 0 or send_ui :
100
- can_sends .append (create_lkas_ui_msg (self .packer , self .CAN , main_on , CC .latActive , steer_alert , hud_control , CS .lkas_status_stock_values ))
99
+ can_sends .append (fordcan . create_lkas_ui_msg (self .packer , self .CAN , main_on , CC .latActive , steer_alert , hud_control , CS .lkas_status_stock_values ))
101
100
# send acc ui msg at 5Hz or if ui state changes
102
101
if (self .frame % CarControllerParams .ACC_UI_STEP ) == 0 or send_ui :
103
- can_sends .append (create_acc_ui_msg (self .packer , self .CAN , self .CP , main_on , CC .latActive ,
102
+ can_sends .append (fordcan . create_acc_ui_msg (self .packer , self .CAN , self .CP , main_on , CC .latActive ,
104
103
fcw_alert , CS .out .cruiseState .standstill , hud_control ,
105
104
CS .acc_tja_status_stock_values ))
106
105
0 commit comments