GM torque control: robust sig function (#32847)
tricky old-commit-hash: b7695c00e87819dd6aac49cfec78e438dfc15d16
This commit is contained in:
@@ -53,7 +53,12 @@ class CarInterface(CarInterfaceBase):
|
||||
friction = get_friction(lateral_accel_error, lateral_accel_deadzone, FRICTION_THRESHOLD, torque_params, friction_compensation)
|
||||
|
||||
def sig(val):
|
||||
return 1 / (1 + exp(-val)) - 0.5
|
||||
# https://timvieira.github.io/blog/post/2014/02/11/exp-normalize-trick
|
||||
if val >= 0:
|
||||
return 1 / (1 + exp(-val)) - 0.5
|
||||
else:
|
||||
z = exp(val)
|
||||
return z / (1 + z) - 0.5
|
||||
|
||||
# The "lat_accel vs torque" relationship is assumed to be the sum of "sigmoid + linear" curves
|
||||
# An important thing to consider is that the slope at 0 should be > 0 (ideally >1)
|
||||
|
||||
Reference in New Issue
Block a user