Skip to content
martinl edited this page Apr 17, 2020 · 59 revisions

Openpilot longitudinal control

Subaru global platform

Openpilot longitudinal control for Subaru global platform works by controlling engine power request (rpm), cruise throttle and cruise brake signals:

  • [ES_Status][Cruise_RPM] - (0...4000) Cruise RPM output for ECM/TCM
  • [ES_Distance][Cruise_Throttle] - (0..4000) input for [Throttle][Throttle_Cruise]
  • [ES_Brake][Brake_Pressure] (0..400) - Cruise brake pressure

Eyesight remains active but not engaged, so PCB/AEB, FCW, LDW and other safety features are passed through. It is possible to do basic acceleration and braking control by linearly scaling openpilot gas and brake actuators outputs but engine torque curve based output signals would be needed to accelerate and run the engine more efficiently, similar to stock Eyesight system.

Openpilot model acceleration outputs (m/s2)

  • actuators.gas (0..1)
  • actuators.brake (0..1)

Related brake signals

  • [Brake_Pedal][Brake_Lights] (0/1) - 1 when brake pedal is pressed or cruise brake active

  • [Brake_Pedal][Brake_Pedal] (0..500) - brake pedal pressure

  • [ES_Brake][Brake_Pressure] - (0..400) Hold: 394 - electric brake pressure

  • [ES_Brake][Cruise_Brake_Lights] - switch on brake lights

  • [ES_Brake][Cruise_Brake_Active] - cruise brake on

  • [ES_Brake][Cruise_Activated] - cruise control activated

  • [ES_Status][Brake_Lights] (0/1) - 1 when brake pedal or electronic brake on

  • [ES_DashStatus][Brake_Lights] (0/1) - 1 when brake pedal or electronic brake on

Related gas/acceleration signals

  • [Throttle][Throttle_Cruise] (0..140)

  • [Throttle][Throttle_Pedal]

  • [Throttle][Throttle_Combo]

  • [Throttle][Engine_RPM]

  • [Transmission][RPM]

  • [ES_Distance][Cruise_Throttle] (0..4000) input for [Throttle][Throttle_Cruise]

  • [ES_Status][Cruise_RPM] - Eyesight RPM output for ECM/TCM

  • [ES_DashStatus][Cruise_State] (0 = normal, 1 = hold+driver brake, 2 = ready, 3 = hold)

Related Eyesight distance outputs

  • [ES_DashStatus][Far_Distance] (0..15) medium distance to object in front @ 10Hz
  • [ES_Distance][Close_Distance] (0..255) 20Hz close distance to object in front (0..255 = 0..6m) @ 20Hz
  • [ES_Distance][Distance_Swap] (0/1) close distance trigger

TODO

  • Test long control

    • Emulate Eyesight engaged state for car ECU-s
      • Keep Eyesight in ready state - DONE
        • rewrite CruiseControl Cruise_Activated = 0 to keep ES in ready state
        • rewrite Brake_Status ES_Brake = 0 to keep ES from faulting on ES_Brake
        • set ES_Status Cruise_Activated = 1, Cruise_RPM = 0
        • set ES_Distance Cruise_Throttle = 808
        • set ES_Brake Cruise_Activated = 1
      • Control throttle and brake using openpilot
        • create Cruise_RPM and Cruise_Throttle output functions for openpilot actuators.gas / actuators.brake
      • Allow Pre-Collision Braking and other stock safety functions passthrough - DONE
        • ES faults when PCB is activated - DONE
      • Test if long control works without faked ES enabled state (CruiseControl rewrite is disabled) - DONE
        • works but stop and go goes to hold
    • test slow down before turns - DONE
    • engineering ui for long tuning - DONE
    • longitudinal PID tuning (how to measure results?)
  • Test stop and go - DONE, POC implemented

    • when in Hold and Car in front moved:
      • send Cruise_Cancel to cancel ACC to get out of Hold (Engaged > Enabled)

      • send Cruise_Resume to reengage ACC (Enabled > Engaged)?

        • DONE, does not work, sending cruise_cancel when in hold sets handbrake
      • when in Hold and Car in front moved:

        • send Brake or Throttle to cancel ACC / standstill (Engaged > Enabled) - DONE
        • send ACC Resume to engage ACC (Enabled > Engaged)
          • sending Brake_Pedal cancels and ACC Resume engages, quite slow (2-3sec) but works - DONE
          • Fix msg sending logic (70x brake, 5x acc resume) - DONE
          • use Close_Distance as faster trigger instead of lead car moved alert - DONE
          • test SNG on level ground - DONE
          • test uphill SNG - DONE
          • test downhill SNG - DONE
      • test ACC Resume reliability improvements (ES_Brake State/ES_DashStatus Cruise_State) - DONE

        • working sample
          • ES_Brake State changes 12 > 8 on Cruse_Resume, ES_DashStatus Cruise_State changes 0>2>0
        • non-working sample
          • ES_Brake State changes 12 > 0 on Cruise_Resume
      • send ACC Resume and Set when ES is not engaged (using wipers) - DONE

        • Set and Resume works for enabled > engaged and changing ACC max speed, button press signal needs to be min 5ms (5 cycles in carcontroller 100Hz loop)
  • Test and log using Conventional Cruise Control - DONE

    • no difference in ES signals vs ACC, added icon signal to ES_DashStatus
  • Document the ES can messages frequency - DONE

  • Document the signals ES requires/checks from car

    • filter messages using panda and document which missing msgs create ES fault
  • Filter stock LKAS off message and chime

    • visual notification (10sec):
      • [ES_LKAS_State][LKAS_STATE] = 2
    • alert beeps after visual (1sec):
      • [ES_LKAS_State][FCW_Cont_Beep] = 1
      • [ES_LKAS_State][FCW_Repeated_Beep] = 1
    • Solution
      • rewrite lkas_state = 0 when incoming lkas_state = 2
      • record last frame when lkas_state changes to 2 > 0 and rewrite beeps = 0 for 100 frames (1 sec)

Eyesight Features

ACC

  • ES_Distance contains acceleration and buttons status

    • Cruise_Throttle
    • Cruise_Brake_Active
    • Cruise_EPB
    • Cruise_Cancel
    • Cruise_Set
    • Cruise_Resume
  • ES_Brake

    • Brake_Pressure
    • State (8 = cruise active, 12/13 = braking)
  • ES_Status

    • Cruise_RPM
    • Brake_Lights

LKAS

  • ES_LKAS controls steering

    • LKAS_Output - steering torque request
  • ES_LKAS_State controls dash display and notifications

    • Keep_Hands_On_Wheel
    • LKAS_ACTIVE (0..3)
    • Backward_Speed_Limit_Menu?
    • LKAS_Left_Line_Visible
    • LKAS_Right_Line_Visible
    • FCW_Cont_Beep
    • FCW_Repeated_Beep
    • Vehicle_In_Front_Has_Moved
    • Throttle_Management_Activated (object in front detected)

ES CAN messages

  • 50Hz ES_LKAS - LKAS steering control
  • 20Hz ES_Brake - ACC brake pressure and status
  • 20Hz ES_Distance - ACC state (Throttle and buttons)
  • 20Hz ES_Status
  • 20Hz ES_Blank
  • 10Hz ES_DashStatus
  • 10Hz ES_LKAS_State - LKAS and FCW dash status and notifications
  • 10Hz ES_NEW_MSG_22

States

  • Enabled
  • Ready
  • Engaged
  • Hold

Buttons

  • Resume
  • Set
  • Cancel
  • Increase follow distance
  • Decrease follow distance

Openpilot message frequencies

  • CarState = 100Hz

CAR CAN messages frequencies

  • 100Hz Steering
  • 100Hz Throttle
  • 100Hz NEW_MSG_1
  • 100Hz Transmission
  • 100Hz NEW_MSG_5
  • 50Hz NEW_MSG_6
  • 50Hz Steering_Torque
  • 50Hz Brake_Pressure_L_R
  • 50Hz Brake_Pedal
  • 50Hz Wheel_Speeds
  • 50Hz G_Sensor
  • 50Hz NEW_MSG_3
  • 50Hz Cruise_Buttons
  • 50Hz NEW_MSG_4
  • 33Hz NEW_MSG_10
  • 20Hz CruiseControl
  • 20Hz NEW_MSG_16
  • 11Hz BodyInfo
  • 10Hz NEW_MSG_23
  • 10Hz NEW_MSG_2 (0:32b)
  • 10Hz NEW_MSG_24
  • 10Hz NEW_MSG_25
  • 10Hz NEW_MSG_26
  • 10Hz Dashlights
  • 10Hz NEW_MSG_27
  • 10Hz NEW_MSG_28
  • 8Hz NEW_MSG_30
  • 8Hz NEW_MSG_31
  • 2Hz NEW_MSG_36
  • 1Hz NEW_MSG_38
  • 1Hz NEW_MSG_39
  • 1Hz NEW_MSG_7
  • 1Hz NEW_MSG_44
  • 1Hz NEW_MSG_45
  • 0.8Hz NEW_MSG_34
  • 0.8Hz NEW_MSG_35
  • 0.8Hz NEW_MSG_37
  • 0.8Hz Dash_State
  • 0.8Hz NEW_MSG_43