Files
StarPilot/openpilot/starpilot/longitudinal/lead_takeoff_preferences.py
T
firestar5683 e4f3d6661c Longitudinal
Implement acceleration profiles, FollowJerk, force-stop and lead-departure owners. Keep selected acceleration limits and hazard arbitration explicit at their shared boundaries.

Co-authored-by: whoisdomi <dcantu83@gmail.com>
2026-10-14 20:02:39 -05:00

27 lines
847 B
Python

"""Persistent, default-off lead takeoff preference; invalid bytes never activate it."""
from openpilot.starpilot.saved_source import read_saved
KEY = 'FasterLeadTakeoff'
class TakeoffPreferences:
def __init__(self, params):
self.params = params
self.enabled = False
self.next_ns = 0
self.last_ns = 0
def sample(self, now_ns):
if now_ns < self.last_ns:
self.next_ns = 0
self.last_ns = now_ns
if now_ns >= self.next_ns:
self.next_ns = now_ns + 1_000_000_000
try:
raw, readable = read_saved(self.params, KEY, 16)
safe, safe_readable = read_saved(self.params, 'SafeMode', 16)
self.enabled = readable and safe_readable and raw == b'1' and safe in (None, b'0')
except (OSError, RuntimeError, TypeError, ValueError):
self.enabled = False
return self.enabled