Skip to content

Commit

Permalink
Ford: remove ramp type param
Browse files Browse the repository at this point in the history
  • Loading branch information
incognitojam committed Jan 11, 2022
1 parent 979692e commit c8696e4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
14 changes: 1 addition & 13 deletions selfdrive/car/ford/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
from selfdrive.car.ford.values import CarControllerParams
from opendbc.can.packer import CANPacker

DEBUG_RAMP_TYPE = False

VisualAlert = car.CarControl.HUDControl.VisualAlert


Expand Down Expand Up @@ -38,8 +36,6 @@ def __init__(self, dbc_name, CP, VM):
self.steer_alert_last = False
self.generic_toggle_last = False

self.ramp_type = 1

def update(self, enabled, CS, frame, actuators, cruise_cancel, visual_alert):
can_sends = []
main_on = CS.out.cruiseState.available
Expand All @@ -57,14 +53,6 @@ def update(self, enabled, CS, frame, actuators, cruise_cancel, visual_alert):
# cancel stock ACC
can_sends.append(fordcan.spam_cancel_button(self.packer))

if CS.out.genericToggle and not self.generic_toggle_last:
# ramp type experiment
if DEBUG_RAMP_TYPE:
# TODO: stock varies this with distance from center
self.ramp_type += 1
if self.ramp_type > 3:
self.ramp_type = 0

if (frame % self.params.LKAS_STEER_STEP) == 0:
lca_rq = 1 if enabled else 0
apply_steer_rad = apply_steer * CV.DEG_TO_RAD
Expand All @@ -74,7 +62,7 @@ def update(self, enabled, CS, frame, actuators, cruise_cancel, visual_alert):

# send steering commands
can_sends.append(fordcan.create_steer_command(self.packer, apply_steer, curvature))
can_sends.append(fordcan.create_steer2_command(self.packer, lca_rq, self.ramp_type, apply_steer_rad, curvature))
can_sends.append(fordcan.create_steer2_command(self.packer, lca_rq, apply_steer_rad, curvature))

# TODO: do we need to send when values change? is 1hz acceptable?
if (frame % self.params.LKAS_UI_STEP) == 0 or (self.main_on_last != main_on) or (self.enabled_last != enabled) or \
Expand Down
10 changes: 5 additions & 5 deletions selfdrive/car/ford/fordcan.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ def create_steer_command(packer, angle_deg: float, curvature: float):
"LkaDrvOvrrd_D_Rq": 0, # driver override level? [0|3]
"LkaActvStats_D2_Req": 0, # action [0|7]
"LaRefAng_No_Req": angle_deg, # angle [-102.4|102.3] degrees
"LaRampType_B_Req": 0, # ramp type [0|1]
"LaRampType_B_Req": 0, # Ramp speed: 0=Smooth, 1=Quick
"LaCurvature_No_Calc": curvature, # curvature [-0.01024|0.01023] 1/meter
"LdwActvStats_D_Req": 0, # LDW status [0|7]
"LdwActvIntns_D_Req": 0, # LDW intensity [0|3]
"LdwActvIntns_D_Req": 0, # LDW intensity [0|3], shake alert strength
}
return packer.make_can_msg("Lane_Assist_Data1", 0, values)


def create_steer2_command(packer, lca_rq: int, ramp_type: int, angle_rad: float, curvature: float):
def create_steer2_command(packer, lca_rq: int, angle_rad: float, curvature: float):
"""
Creates a CAN message for the Ford LCA Command.
Expand All @@ -44,8 +44,8 @@ def create_steer2_command(packer, lca_rq: int, ramp_type: int, angle_rad: float,
"LatCtlRng_L_Max": 0, # [0|126] meter
"HandsOffCnfm_B_Rq": 0, # [0|1]
"LatCtl_D_Rq": lca_rq, # Mode: 0=None, 1=Continuous [0|7]
"LatCtlRampType_D_Rq": ramp_type, # Ramp speed: 0=Slow, 1=Medium, 2=Fast, 3=Immediate
"LatCtlPrecision_D_Rq": 0, # Precision: 0=Comfortable, 1=Precise [0|3]
"LatCtlRampType_D_Rq": 3, # Ramp speed: 0=Slow, 1=Medium, 2=Fast, 3=Immediate
"LatCtlPrecision_D_Rq": 1, # Precision: 0=Comfortable, 1=Precise [0|3]
"LatCtlPathOffst_L_Actl": 0, # Path offset [-5.12|5.11] meter
"LatCtlPath_An_Actl": angle_rad, # Path angle [-0.5|0.5235] radians
"LatCtlCurv_NoRate_Actl": 0, # Curvature rate [-0.001024|0.00102375] 1/meter
Expand Down

0 comments on commit c8696e4

Please sign in to comment.