mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-03 16:49:33 +08:00
FrogPilot community - Moving Average Calculator
Co-Authored-By: Efini <19368997+efini@users.noreply.github.com> Co-Authored-By: Kumar <36933347+rav4kumar@users.noreply.github.com>
This commit is contained in:
@@ -182,3 +182,22 @@ def uninstall_frogpilot():
|
||||
run_cmd(copy_cmd, "Successfully restored the original boot logo.", "Failed to restore the original boot logo.")
|
||||
|
||||
HARDWARE.uninstall()
|
||||
|
||||
class MovingAverageCalculator:
|
||||
def __init__(self):
|
||||
self.reset_data()
|
||||
|
||||
def add_data(self, value):
|
||||
if len(self.data) == 5:
|
||||
self.total -= self.data.pop(0)
|
||||
self.data.append(value)
|
||||
self.total += value
|
||||
|
||||
def get_moving_average(self):
|
||||
if len(self.data) == 0:
|
||||
return None
|
||||
return self.total / len(self.data)
|
||||
|
||||
def reset_data(self):
|
||||
self.data = []
|
||||
self.total = 0
|
||||
|
||||
@@ -8,6 +8,7 @@ from openpilot.system.version import get_build_metadata
|
||||
|
||||
CITY_SPEED_LIMIT = 25 # 55mph is typically the minimum speed for highways
|
||||
CRUISING_SPEED = 5 # Roughly the speed cars go when not touching the gas while in drive
|
||||
PROBABILITY = 0.6 # 60% chance of condition being true
|
||||
|
||||
class FrogPilotVariables:
|
||||
def __init__(self):
|
||||
|
||||
Reference in New Issue
Block a user