selfdrive/controls/lib/dynamic_follow/__init__.py
def global_profile_mod(self, profile_mod_x, profile_mod_pos, profile_mod_neg, x_vel, y_dist):
    """
    This function modifies the y_dist list used by dynamic follow in accordance with global_df_mod
    It also intelligently adjusts the profile mods at each breakpoint based on the change in TR
    """
    if self.global_df_mod == 1.:
      return profile_mod_pos, profile_mod_neg, y_dist
    global_df_mod = 1 - self.global_df_mod

    # Calculate new TRs
    speeds = [0, self.sng_speed, 18, x_vel[-1]]  # [0, 18 mph, ~40 mph, highest profile mod speed (~78 mph)]
    mods = [0, 0.1, 0.7, 1]  # how much to limit global_df_mod at each speed, 1 is full effect
    y_dist_new = [y - (y * global_df_mod * interp(x, speeds, mods)) for x, y in zip(x_vel, y_dist)]

    # Calculate how to change profile mods based on change in TR
    # eg. if df mod is 0.7, then increase positive mod and decrease negative mod
    calc_profile_mods = [(interp(mod_x, x_vel, y_dist) - interp(mod_x, x_vel, y_dist_new) + 1) for mod_x in profile_mod_x]
    profile_mod_pos = [mod_pos * mod for mod_pos, mod in zip(profile_mod_pos, calc_profile_mods)]
    profile_mod_neg = [mod_neg * ((1 - mod) + 1) for mod_neg, mod in zip(profile_mod_neg, calc_profile_mods)]

    return profile_mod_pos, profile_mod_neg, y_dist_new

    This function modifies the y_dist list used by dynamic follow in accordance with global_df_mod
    It also intelligently adjusts the profile mods at each breakpoint based on the change in TR
    
This function modifies the y_dist list used by dynamic follow in accordance with global_df_mod
It also intelligently adjusts the profile mods at each breakpoint based on the change in TR
This function modifies the y_dist list used by dynamic follow in accordance with global_df_mod It also intelligently adjusts the profile mods at each breakpoint based on the change in TR
def global_profile_mod(self, profile_mod_x, profile_mod_pos, profile_mod_neg, x_vel, y_dist):
    if self.global_df_mod == 1.:
      return profile_mod_pos, profile_mod_neg, y_dist
    global_df_mod = 1 - self.global_df_mod
    speeds = [0, self.sng_speed, 18, x_vel[-1]]  
    mods = [0, 0.1, 0.7, 1]  
    y_dist_new = [y - (y * global_df_mod * interp(x, speeds, mods)) for x, y in zip(x_vel, y_dist)]
    calc_profile_mods = [(interp(mod_x, x_vel, y_dist) - interp(mod_x, x_vel, y_dist_new) + 1) for mod_x in profile_mod_x]
    profile_mod_pos = [mod_pos * mod for mod_pos, mod in zip(profile_mod_pos, calc_profile_mods)]
    profile_mod_neg = [mod_neg * ((1 - mod) + 1) for mod_neg, mod in zip(profile_mod_neg, calc_profile_mods)]
    return profile_mod_pos, profile_mod_neg, y_dist_new
def global_profile_mod ( self , profile_mod_x , profile_mod_pos , profile_mod_neg , x_vel , y_dist ) : if self . global_df_mod == 1. : return profile_mod_pos , profile_mod_neg , y_dist global_df_mod = 1 - self . global_df_mod speeds = [ 0 , self . sng_speed , 18 , x_vel [ - 1 ] ] mods = [ 0 , 0.1 , 0.7 , 1 ] y_dist_new = [ y - ( y * global_df_mod * interp ( x , speeds , mods ) ) for x , y in zip ( x_vel , y_dist ) ] calc_profile_mods = [ ( interp ( mod_x , x_vel , y_dist ) - interp ( mod_x , x_vel , y_dist_new ) + 1 ) for mod_x in profile_mod_x ] profile_mod_pos = [ mod_pos * mod for mod_pos , mod in zip ( profile_mod_pos , calc_profile_mods ) ] profile_mod_neg = [ mod_neg * ( ( 1 - mod ) + 1 ) for mod_neg , mod in zip ( profile_mod_neg , calc_profile_mods ) ] return profile_mod_pos , profile_mod_neg , y_dist_new
This function modifies the y_dist list used by dynamic follow in accordance with global_df_mod
It also intelligently adjusts the profile mods at each breakpoint based on the change in TR
This function modifies the y_dist list used by dynamic follow in accordance with global_df_mod It also intelligently adjusts the profile mods at each breakpoint based on the change in TR
"""
    This function modifies the y_dist list used by dynamic follow in accordance with global_df_mod
    It also intelligently adjusts the profile mods at each breakpoint based on the change in TR
    """ # Calculate new TRs # [0, 18 mph, ~40 mph, highest profile mod speed (~78 mph)] # how much to limit global_df_mod at each speed, 1 is full effect # Calculate how to change profile mods based on change in TR # eg. if df mod is 0.7, then increase positive mod and decrease negative mod
self
profile_mod_x
profile_mod_pos
profile_mod_neg
x_vel
y_dist