selfdrive/controls/lib/dynamic_follow/__init__.py
def _relative_accel_mod(self):
    """
    Returns relative acceleration mod calculated from list of lead and ego velocities over time (longer than 1s)
    If min_consider_time has not been reached, uses lead accel and ego accel from openpilot (kalman filtered)
    """
    a_ego = self.car_data.a_ego
    a_lead = self.lead_data.a_lead
    min_consider_time = 0.75  # minimum amount of time required to consider calculation
    if len(self.df_data.v_rels) > 0:  # if not empty
      elapsed_time = self.df_data.v_rels[-1]['time'] - self.df_data.v_rels[0]['time']
      if elapsed_time > min_consider_time:
        a_ego = (self.df_data.v_rels[-1]['v_ego'] - self.df_data.v_rels[0]['v_ego']) / elapsed_time
        a_lead = (self.df_data.v_rels[-1]['v_lead'] - self.df_data.v_rels[0]['v_lead']) / elapsed_time

    mods_x = [-1.5, -.75, 0]
    mods_y = [1, 1.25, 1.3]
    if a_lead < 0:  # more weight to slight lead decel
      a_lead *= interp(a_lead, mods_x, mods_y)

    if a_lead - a_ego > 0:  # return only if adding distance
      return 0

    rel_x = [-2.6822, -1.7882, -0.8941, -0.447, -0.2235, 0.0, 0.2235, 0.447, 0.8941, 1.7882, 2.6822]
    mod_y = [0.3245 * 1.1, 0.277 * 1.08, 0.11075 * 1.06, 0.08106 * 1.045, 0.06325 * 1.035, 0.0, -0.09, -0.09375, -0.125, -0.3, -0.35]
    return interp(a_lead - a_ego, rel_x, mod_y)

    Returns relative acceleration mod calculated from list of lead and ego velocities over time (longer than 1s)
    If min_consider_time has not been reached, uses lead accel and ego accel from openpilot (kalman filtered)
    
Returns relative acceleration mod calculated from list of lead and ego velocities over time (longer than 1s)
If min_consider_time has not been reached, uses lead accel and ego accel from openpilot (kalman filtered)
Returns relative acceleration mod calculated from list of lead and ego velocities over time ( longer than 1s ) If min_consider_time has not been reached uses lead accel and ego accel from openpilot ( kalman filtered )
def _relative_accel_mod(self):
    a_ego = self.car_data.a_ego
    a_lead = self.lead_data.a_lead
    min_consider_time = 0.75  
    if len(self.df_data.v_rels) > 0:  
      elapsed_time = self.df_data.v_rels[-1]['time'] - self.df_data.v_rels[0]['time']
      if elapsed_time > min_consider_time:
        a_ego = (self.df_data.v_rels[-1]['v_ego'] - self.df_data.v_rels[0]['v_ego']) / elapsed_time
        a_lead = (self.df_data.v_rels[-1]['v_lead'] - self.df_data.v_rels[0]['v_lead']) / elapsed_time
    mods_x = [-1.5, -.75, 0]
    mods_y = [1, 1.25, 1.3]
    if a_lead < 0:  
      a_lead *= interp(a_lead, mods_x, mods_y)
    if a_lead - a_ego > 0:  
      return 0
    rel_x = [-2.6822, -1.7882, -0.8941, -0.447, -0.2235, 0.0, 0.2235, 0.447, 0.8941, 1.7882, 2.6822]
    mod_y = [0.3245 * 1.1, 0.277 * 1.08, 0.11075 * 1.06, 0.08106 * 1.045, 0.06325 * 1.035, 0.0, -0.09, -0.09375, -0.125, -0.3, -0.35]
    return interp(a_lead - a_ego, rel_x, mod_y)
def _relative_accel_mod ( self ) : a_ego = self . car_data . a_ego a_lead = self . lead_data . a_lead min_consider_time = 0.75 if len ( self . df_data . v_rels ) > 0 : elapsed_time = self . df_data . v_rels [ - 1 ] [ 'time' ] - self . df_data . v_rels [ 0 ] [ 'time' ] if elapsed_time > min_consider_time : a_ego = ( self . df_data . v_rels [ - 1 ] [ 'v_ego' ] - self . df_data . v_rels [ 0 ] [ 'v_ego' ] ) / elapsed_time a_lead = ( self . df_data . v_rels [ - 1 ] [ 'v_lead' ] - self . df_data . v_rels [ 0 ] [ 'v_lead' ] ) / elapsed_time mods_x = [ - 1.5 , - .75 , 0 ] mods_y = [ 1 , 1.25 , 1.3 ] if a_lead < 0 : a_lead *= interp ( a_lead , mods_x , mods_y ) if a_lead - a_ego > 0 : return 0 rel_x = [ - 2.6822 , - 1.7882 , - 0.8941 , - 0.447 , - 0.2235 , 0.0 , 0.2235 , 0.447 , 0.8941 , 1.7882 , 2.6822 ] mod_y = [ 0.3245 * 1.1 , 0.277 * 1.08 , 0.11075 * 1.06 , 0.08106 * 1.045 , 0.06325 * 1.035 , 0.0 , - 0.09 , - 0.09375 , - 0.125 , - 0.3 , - 0.35 ] return interp ( a_lead - a_ego , rel_x , mod_y )
Returns relative acceleration mod calculated from list of lead and ego velocities over time (longer than 1s)
If min_consider_time has not been reached, uses lead accel and ego accel from openpilot (kalman filtered)
Returns relative acceleration mod calculated from list of lead and ego velocities over time ( longer than 1s ) If min_consider_time has not been reached uses lead accel and ego accel from openpilot ( kalman filtered )
"""
    Returns relative acceleration mod calculated from list of lead and ego velocities over time (longer than 1s)
    If min_consider_time has not been reached, uses lead accel and ego accel from openpilot (kalman filtered)
    """ # minimum amount of time required to consider calculation # if not empty # more weight to slight lead decel # return only if adding distance
self