GM torque control: robust sig function (#32847)

tricky
old-commit-hash: b7695c00e8
pull/33029/head
Shane Smiskol 11 months ago committed by GitHub
parent ce34729c91
commit 33daa31301
  1. 5
      selfdrive/car/gm/interface.py

@ -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):
# 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)

Loading…
Cancel
Save