""" Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos """ import numpy as np from iqdbc.car import structs from iqdbc.car.lateral import apply_center_deadzone def get_friction(lateral_accel_error: float, lateral_accel_deadzone: float, friction_threshold: float, torque_params: structs.CarParams.LateralTorqueTuning) -> float: # TODO torque params' friction should be in lataxel space, not torque space friction_interp = np.interp( apply_center_deadzone(lateral_accel_error, lateral_accel_deadzone), [-friction_threshold, friction_threshold], [-torque_params.friction, torque_params.friction] ) return float(friction_interp)