IQ.Pilot Release Commit @ 0babf78

This commit is contained in:
IQ.Lvbs CI [bot]
2026-07-27 01:40:11 -05:00
parent 6fb5c0141c
commit b39791a93f
425 changed files with 12180 additions and 6137 deletions

View File

@@ -1,3 +1,8 @@
from collections import deque
import numpy as np
class FirstOrderFilter:
def __init__(self, x0, rc, dt, initialized=True):
self.x = x0
@@ -32,3 +37,35 @@ class BounceFilter(FirstOrderFilter):
self.velocity.x = 0.0
self.x += self.velocity.x
return self.x
class MyMovingAverage:
def __init__(self, window_size, value=None):
self.window_size = window_size
if value is not None:
self.values = deque([value] * window_size, maxlen=window_size)
self.sum = value * window_size
self.result = value
else:
self.values = deque(maxlen=window_size)
self.sum = 0
self.result = 0
def set(self, value):
self.values.clear()
self.values.append(value)
self.sum = value
self.result = value
return value
def set_all(self, value):
self.values = deque([value] * self.window_size, maxlen=self.window_size)
self.sum = value * self.window_size
self.result = value
return value
def process(self, value, median=False):
self.values.append(value)
self.sum = sum(self.values)
self.result = float(np.median(self.values)) if median else float(self.sum) / len(self.values)
return self.result

View File

@@ -63,6 +63,14 @@ public:
inline bool getBool(const std::string &key, bool block = false) {
return get(key, block) == "1";
}
inline int getInt(const std::string &key, bool block = false) {
std::string value = get(key, block);
return value.empty() ? 0 : std::stoi(value);
}
inline float getFloat(const std::string &key, bool block = false) {
std::string value = get(key, block);
return value.empty() ? 0.0F : std::stof(value);
}
std::map<std::string, std::string> readAll();
// helpers for writing values
@@ -73,10 +81,24 @@ public:
inline int putBool(const std::string &key, bool val) {
return put(key.c_str(), val ? "1" : "0", 1);
}
inline int putInt(const std::string &key, int val) {
const std::string value = std::to_string(val);
return put(key.c_str(), value.c_str(), value.size());
}
inline int putFloat(const std::string &key, float val) {
const std::string value = std::to_string(val);
return put(key.c_str(), value.c_str(), value.size());
}
void putNonBlocking(const std::string &key, const std::string &val);
inline void putBoolNonBlocking(const std::string &key, bool val) {
putNonBlocking(key, val ? "1" : "0");
}
inline void putIntNonBlocking(const std::string &key, int val) {
putNonBlocking(key, std::to_string(val));
}
inline void putFloatNonBlocking(const std::string &key, float val) {
putNonBlocking(key, std::to_string(val));
}
private:
void asyncWriteThread();

View File

@@ -9,12 +9,14 @@ except ImportError:
pass
class ParamKeyFlag(IntFlag):
PERSISTENT = 1
CLEAR_ON_MANAGER_START = 2
CLEAR_ON_ONROAD_TRANSITION = 4
CLEAR_ON_OFFROAD_TRANSITION = 8
DONT_LOG = 16
DEVELOPMENT_ONLY = 32
# must stay in lockstep with enum ParamKeyFlag in common/params.h
PERSISTENT = 0x02
CLEAR_ON_MANAGER_START = 0x04
CLEAR_ON_ONROAD_TRANSITION = 0x08
CLEAR_ON_OFFROAD_TRANSITION = 0x10
DONT_LOG = 0x20
DEVELOPMENT_ONLY = 0x40
CLEAR_ON_IGNITION_ON = 0x80
ALL = 0xFFFFFFFF
class ParamKeyType(IntEnum):
@@ -62,6 +64,14 @@ except ImportError:
except (FileNotFoundError, NotADirectoryError, IsADirectoryError):
return False
def get_int(self, key, block: bool = False) -> int:
value = self.get(key, block=block)
return int(value) if value else 0
def get_float(self, key, block: bool = False) -> float:
value = self.get(key, block=block)
return float(value) if value else 0.0
def put(self, key, dat):
if isinstance(dat, str):
dat = dat.encode("utf-8")
@@ -78,12 +88,24 @@ except ImportError:
def put_bool(self, key, val: bool):
self.put(key, b"1" if val else b"0")
def put_int(self, key, val: int):
self.put(key, str(val))
def put_float(self, key, val: float):
self.put(key, str(val))
def put_nonblocking(self, key, dat):
self.put(key, dat)
def put_bool_nonblocking(self, key, val: bool):
self.put_bool(key, val)
def put_int_nonblocking(self, key, val: int):
self.put_int(key, val)
def put_float_nonblocking(self, key, val: float):
self.put_float(key, val)
def remove(self, key):
try:
os.remove(self._p(key))

View File

@@ -153,8 +153,8 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
// --- iqpilot params --- //
{"ApiCache_DriveStats", {PERSISTENT, JSON}},
{"AutoLaneChangeBsmDelay", {PERSISTENT, BOOL, "0"}},
{"AutoLaneChangeTimer", {PERSISTENT, INT, "0"}},
{"IQLaneChangeBsmDelay", {PERSISTENT, BOOL, "0"}},
{"IQLaneChangeTimer", {PERSISTENT, INT, "0"}},
{"NavExitLaneChange", {PERSISTENT, BOOL, "0"}},
{"IQBlinkerMinLateralSpeed", {PERSISTENT, INT, "20"}}, // MPH or km/h
{"IQBlinkerPauseLateral", {PERSISTENT, INT, "0"}},
@@ -165,28 +165,31 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
{"IQCarParamsPersistent", {PERSISTENT, BYTES}},
{"IQCarParamsPersistentV2", {PERSISTENT, BYTES}},
{"CarPlatformBundle", {PERSISTENT, JSON}},
{"Konn3ktVwOdometers", {PERSISTENT, JSON}},
{"Konn3ktVehicleOdometers", {PERSISTENT, JSON}},
{"ChevronInfo", {PERSISTENT, INT, "4"}},
{"DeviceBootMode", {PERSISTENT, INT, "0"}},
{"IQDevUIInfo", {PERSISTENT, INT, "0"}},
{"EnableEsimProvisioning", {PERSISTENT, BOOL, "1"}},
{"GreenLightAlert", {PERSISTENT, BOOL, "0"}},
{"EndToEndAlert", {PERSISTENT, BOOL, "0"}},
{"InteractivityTimeout", {PERSISTENT, INT, "0"}},
{"IsDevelopmentBranch", {CLEAR_ON_MANAGER_START, BOOL}},
{"IsReleaseIqBranch", {CLEAR_ON_MANAGER_START, BOOL}},
{"LastGPSPositionIQLoc", {PERSISTENT, STRING}},
{"LeadDepartAlert", {PERSISTENT, BOOL, "0"}},
{"EndToEndLeadAlert", {PERSISTENT, BOOL, "0"}},
{"LongIncrementsEnabled", {PERSISTENT, BOOL, "0"}},
{"LongIncrementTapStep", {PERSISTENT, INT, "1"}},
{"LongIncrementHoldStep", {PERSISTENT, INT, "5"}},
{"IQE2ESetSpeedMode", {PERSISTENT, INT, "0"}},
{"IQE2ESetSpeedUseCurrent", {PERSISTENT, BOOL, "0"}},
{"IQE2ESetSpeedMph", {PERSISTENT, INT, "65"}},
{"expSpeedConv", {PERSISTENT, BOOL, "0"}},
{"MaxTimeOffroad", {PERSISTENT, INT, "1800"}},
{"NightMode", {PERSISTENT, BOOL, "0"}},
{"newLeadMpc", {PERSISTENT, BOOL, "1"}},
{"ModelRunnerTypeCache", {CLEAR_ON_ONROAD_TRANSITION, INT}},
{"ForceOnroadUntil", {CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION, INT, "0"}},
{"OffroadMode", {CLEAR_ON_MANAGER_START, BOOL}},
{"IQAlwaysOffroad", {CLEAR_ON_MANAGER_START, BOOL}},
{"Offroad_TiciSupport", {CLEAR_ON_MANAGER_START, JSON}},
{"OnroadScreenOffBrightness", {PERSISTENT, INT, "0"}},
{"OnroadScreenOffTimer", {PERSISTENT, INT, "15"}},
@@ -225,6 +228,32 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
// iqpilot car specific params
{"HyundaiLongitudinalTuning", {PERSISTENT, INT, "0"}},
{"AutoCruiseControl", {PERSISTENT, INT, "0"}},
{"AutoEngage", {PERSISTENT, INT, "0"}},
{"CanfdDebug", {PERSISTENT, INT, "0"}},
{"CanfdHDA2", {PERSISTENT, INT, "0"}},
{"CarrotCruiseAtcDecel", {PERSISTENT, INT, "-1"}},
{"CarrotCruiseDecel", {PERSISTENT, INT, "-1"}},
{"CruiseButtonTest1", {PERSISTENT, INT, "8"}},
{"CruiseButtonTest2", {PERSISTENT, INT, "30"}},
{"CruiseButtonTest3", {PERSISTENT, INT, "1"}},
{"CustomSteerDeltaDown", {PERSISTENT, INT, "0"}},
{"CustomSteerDeltaDownLC", {PERSISTENT, INT, "0"}},
{"CustomSteerDeltaUp", {PERSISTENT, INT, "0"}},
{"CustomSteerDeltaUpLC", {PERSISTENT, INT, "0"}},
{"CustomSteerMax", {PERSISTENT, INT, "0"}},
{"EnableCornerRadar", {PERSISTENT, INT, "0"}},
{"EnableRadarTracks", {PERSISTENT, INT, "0"}},
{"EnableRadarTracksResult", {PERSISTENT | CLEAR_ON_MANAGER_START, INT}},
{"FingerPrints", {PERSISTENT | CLEAR_ON_MANAGER_START, STRING}},
{"HDPuse", {PERSISTENT, INT, "0"}},
{"HapticFeedbackWhenSpeedCamera", {PERSISTENT, INT, "0"}},
{"HyundaiCameraSCC", {PERSISTENT, INT, "0"}},
{"IsLdwsCar", {PERSISTENT, INT, "0"}},
{"LaneLineCheck", {PERSISTENT, INT, "0"}},
{"LongitudinalPersonalityMax", {PERSISTENT, INT, "3"}},
{"MaxAngleFrames", {PERSISTENT, INT, "89"}},
{"SpeedFromPCM", {PERSISTENT, INT, "2"}},
{"SubaruStopAndGo", {PERSISTENT, BOOL, "0"}},
{"SubaruStopAndGoManualParkingBrake", {PERSISTENT, BOOL, "0"}},
{"TeslaCoopSteering", {PERSISTENT, BOOL, "0"}},
@@ -255,9 +284,9 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
// iqpilot model params
{"CameraOffset", {PERSISTENT, FLOAT, "0.0"}},
{"LagdToggle", {PERSISTENT, BOOL, "1"}},
{"LagdToggleDelay", {PERSISTENT, FLOAT, "0.2"}},
{"LagdValueCache", {PERSISTENT, FLOAT, "0.2"}},
{"IQLiveSteerDelay", {PERSISTENT, BOOL, "1"}},
{"IQSoftwareSteerDelay", {PERSISTENT, FLOAT, "0.2"}},
{"IQSteerDelayCache", {PERSISTENT, FLOAT, "0.2"}},
{"LaneChangeBsd", {PERSISTENT, INT, "0"}}, // -1 ignore BSD, 0 default, 1 block lane change on BSD
{"LaneChangeContinuous", {PERSISTENT, BOOL, "0"}}, // 0 one-shot per blinker, 1 chain on held blinker (torque-gated)
{"LaneChangeDelay", {PERSISTENT, FLOAT, "0.0"}}, // tenths of a second; scaled by 0.1 in desire_helper

View File

@@ -33,11 +33,17 @@ cdef extern from "common/params.h":
c_Params(string) except + nogil
string get(string, bool) nogil
bool getBool(string, bool) nogil
int getInt(string, bool) nogil
float getFloat(string, bool) nogil
int remove(string) nogil
int put(string, string) nogil
void putNonBlocking(string, string) nogil
void putBoolNonBlocking(string, bool) nogil
int putBool(string, bool) nogil
int putInt(string, int) nogil
int putFloat(string, float) nogil
void putIntNonBlocking(string, int) nogil
void putFloatNonBlocking(string, float) nogil
bool checkKey(string) nogil
ParamKeyType getKeyType(string) nogil
optional[string] getKeyDefaultValue(string) nogil
@@ -136,6 +142,20 @@ cdef class Params:
r = self.p.getBool(k, block)
return r
def get_int(self, key, bool block=False):
cdef string k = self.check_key(key)
cdef int r
with nogil:
r = self.p.getInt(k, block)
return r
def get_float(self, key, bool block=False):
cdef string k = self.check_key(key)
cdef float r
with nogil:
r = self.p.getFloat(k, block)
return r
def _put_cast(self, key, dat):
cdef string k = self.check_key(key)
cdef ParamKeyType t = self.p.getKeyType(k)
@@ -158,6 +178,16 @@ cdef class Params:
with nogil:
self.p.putBool(k, val)
def put_int(self, key, int val):
cdef string k = self.check_key(key)
with nogil:
self.p.putInt(k, val)
def put_float(self, key, float val):
cdef string k = self.check_key(key)
with nogil:
self.p.putFloat(k, val)
def put_nonblocking(self, key, dat):
cdef string k = self.check_key(key)
cdef string dat_bytes = self._put_cast(key, dat)
@@ -169,6 +199,16 @@ cdef class Params:
with nogil:
self.p.putBoolNonBlocking(k, val)
def put_int_nonblocking(self, key, int val):
cdef string k = self.check_key(key)
with nogil:
self.p.putIntNonBlocking(k, val)
def put_float_nonblocking(self, key, float val):
cdef string k = self.check_key(key)
with nogil:
self.p.putFloatNonBlocking(k, val)
def remove(self, key):
cdef string k = self.check_key(key)
with nogil: