diff --git a/selfdrive/modeld/modeld.py b/selfdrive/modeld/modeld.py index 9107cc6228..c8b3b25499 100755 --- a/selfdrive/modeld/modeld.py +++ b/selfdrive/modeld/modeld.py @@ -28,6 +28,7 @@ from openpilot.selfdrive.modeld.helpers import usbgpu_present, modeld_pkl_path, from openpilot.sunnypilot.livedelay.helpers import get_lat_delay from openpilot.sunnypilot.modeld_v2.modeld_base import ModelStateBase +from openpilot.sunnypilot.selfdrive.controls.lib.relc import RoadEdgeLaneChangeController PROCESS_NAME = "selfdrive.modeld.modeld" SEND_RAW_PRED = os.getenv('SEND_RAW_PRED') @@ -223,6 +224,7 @@ def main(demo=False): prev_action = log.ModelDataV2.Action() DH = DesireHelper() + RELC = RoadEdgeLaneChangeController(DH) while True: # Keep receiving frames until we are at least 1 frame ahead of previous extra frame @@ -325,7 +327,10 @@ def main(demo=False): l_lane_change_prob = desire_state[log.Desire.laneChangeLeft] r_lane_change_prob = desire_state[log.Desire.laneChangeRight] lane_change_prob = l_lane_change_prob + r_lane_change_prob - DH.update(sm['carState'], sm['carControl'].latActive, lane_change_prob) + RELC.update(modelv2_send.modelV2.roadEdgeStds, modelv2_send.modelV2.laneLineProbs, v_ego) + mdv2sp_send.modelDataV2SP.leftLaneChangeEdgeBlock = RELC.left_edge_detected + mdv2sp_send.modelDataV2SP.rightLaneChangeEdgeBlock = RELC.right_edge_detected + DH.update(sm['carState'], sm['carControl'].latActive, lane_change_prob, RELC.left_edge_detected, RELC.right_edge_detected) modelv2_send.modelV2.meta.laneChangeState = DH.lane_change_state modelv2_send.modelV2.meta.laneChangeDirection = DH.lane_change_direction mdv2sp_send.modelDataV2SP.laneTurnDirection = DH.lane_turn_direction diff --git a/sunnypilot/sunnylink/params_metadata.json b/sunnypilot/sunnylink/params_metadata.json index 639ee74127..d7087bb653 100644 --- a/sunnypilot/sunnylink/params_metadata.json +++ b/sunnypilot/sunnylink/params_metadata.json @@ -1132,7 +1132,7 @@ }, "RoadEdgeLaneChangeEnabled": { "title": "Block Lane Change: Road Edge Detection", - "description": "" + "description": "Blocks lane changes when the model sees a road edge on the signaled side." }, "RoadName": { "title": "Road Name", diff --git a/sunnypilot/sunnylink/settings_ui.json b/sunnypilot/sunnylink/settings_ui.json index 3b2716515c..1b02a2aa6c 100644 --- a/sunnypilot/sunnylink/settings_ui.json +++ b/sunnypilot/sunnylink/settings_ui.json @@ -537,6 +537,12 @@ "value": 0 } ] + }, + { + "key": "RoadEdgeLaneChangeEnabled", + "widget": "toggle", + "title": "Block Lane Change: Road Edge Detection", + "description": "Blocks the lane change if the model sees a road edge on your signaled side." } ] } diff --git a/sunnypilot/sunnylink/settings_ui_src/pages/steering.yaml b/sunnypilot/sunnylink/settings_ui_src/pages/steering.yaml index 697c5f4f21..03f648d8e5 100644 --- a/sunnypilot/sunnylink/settings_ui_src/pages/steering.yaml +++ b/sunnypilot/sunnylink/settings_ui_src/pages/steering.yaml @@ -255,3 +255,7 @@ sections: key: AutoLaneChangeTimer op: '>' value: 0 + - key: RoadEdgeLaneChangeEnabled + widget: toggle + title: 'Block Lane Change: Road Edge Detection' + description: Blocks the lane change if the model sees a road edge on your signaled side.