mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-04 07:03:44 +08:00
Remove blending
This commit is contained in:
@@ -114,28 +114,12 @@ class CarController(CarControllerBase):
|
||||
# Compute raw pedal gas
|
||||
raw_pedal_gas = clip((pedaloffset + (accel / gain) * 0.6), 0.0, 1.0) if press_regen_paddle else clip((pedaloffset + accel * 0.6), 0.0, 1.0)
|
||||
|
||||
# --- Blending logic: keep endpoints constant during blend ---
|
||||
# Initialize blend endpoints if not present
|
||||
if not hasattr(self, 'blend_start_gas'):
|
||||
self.blend_start_gas = raw_pedal_gas
|
||||
self.blend_target_gas = raw_pedal_gas
|
||||
|
||||
if self.regen_paddle_pressed_changed:
|
||||
# start 200-frame blend: capture fixed endpoints
|
||||
self.blend_start_gas = self.prev_pedal_gas # last output
|
||||
self.blend_target_gas = raw_pedal_gas # new raw value
|
||||
self.regen_paddle_pressed_changed_counter = 200
|
||||
|
||||
if self.regen_paddle_pressed_changed_counter > 0:
|
||||
ratio = interp(self.regen_paddle_pressed_changed_counter, [200, 0], [0.0, 1.0])
|
||||
pedal_gas = self.blend_target_gas * ratio + self.blend_start_gas * (1.0 - ratio)
|
||||
self.regen_paddle_pressed_changed_counter -= 1
|
||||
else:
|
||||
pedal_gas = raw_pedal_gas
|
||||
self.prev_pedal_gas = pedal_gas
|
||||
# --- Immediate application of raw pedal gas, no blending ---
|
||||
pedal_gas = raw_pedal_gas
|
||||
# Safety cap on initial takeoff: limit pedal_gas based on vehicle speed
|
||||
pedal_gas_max = interp(car_velocity, [0.0, 5, 30], [0.22, 0.3275, 0.3725])
|
||||
pedal_gas = clip(pedal_gas, 0.0, pedal_gas_max)
|
||||
self.prev_pedal_gas = pedal_gas
|
||||
return pedal_gas, press_regen_paddle
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user