Files
2026-02-20 20:45:19 +08:00

34 lines
1.6 KiB
Python

"""
Copyright (c) 2025, Rick Lan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, and/or sublicense,
for non-commercial purposes only, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
- Commercial use (e.g. use in a product, service, or activity intended to
generate revenue) is prohibited without explicit written permission from
the copyright holder.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
import numpy as np
# Dynamic accel slew rate - how fast accel bounds can change per frame
SLEW_RATE_BP = [5.56, 11.12, 16.67] # m/s (~40-60 km/h)
SLEW_RATE_V = [0.15, 0.10, 0.05] # faster response at lower speeds, smoother at highway
class DASR:
def __init__(self):
self.slew_rate = SLEW_RATE_V[-1]
def update(self, v_ego):
# Speed-dependent slew rate: 0.10/frame at ~40 km/h, 0.05/frame at ~60 km/h+
self.slew_rate = float(np.interp(v_ego, SLEW_RATE_BP, SLEW_RATE_V))