def METHOD_NAME(self, speed, x, y, h):
    lookahead = max(5.0, 1.2 * speed)  # look ahead some distance proportional to speed
    # Lateral position on the trajectory
    y_target = self.trajectory_function(x+lookahead)  # look ahead 10 m
    # Calculate angle to target point from current location
    angle = math.atan((y_target - y) / ((x+lookahead) - x))
    # Subtract current heading/yaw of the vehicle and apply some scaling factor
    self.steering = 0.5 * (angle - h)
    # Give throttle or brake to reach target_speed
    if self.target_speed - speed > 0:
        self.throttle =  0.05 * (self.target_speed - speed)
        self.brake = 0.0
    else:
        self.throttle =  0.0
        self.brake = 0.05 * (speed - self.target_speed)
    # slow down with increased steering angle
    self.throttle -= 0.4 * abs(self.steering)
    self.brake += 0.4 * abs(self.steering)