wip
This commit is contained in:
@@ -376,30 +376,33 @@ def main() -> NoReturn:
|
|||||||
stop_download_event.set()
|
stop_download_event.set()
|
||||||
pm.send('gpsLocation', msg)
|
pm.send('gpsLocation', msg)
|
||||||
|
|
||||||
# Custom GPS tracking by brian
|
try:
|
||||||
current_time = time.time()
|
# Custom GPS tracking by brian
|
||||||
time_since_last_report = current_time - last_reported_time
|
current_time = time.time()
|
||||||
# Calculate the distance change
|
time_since_last_report = current_time - last_reported_time
|
||||||
distance_change = math.sqrt((gps.latitude - (last_reported_latitude or 0))**2 +
|
# Calculate the distance change
|
||||||
(gps.longitude - (last_reported_longitude or 0))**2)
|
distance_change = math.sqrt((gps.latitude - (last_reported_latitude or 0))**2 +
|
||||||
# Check for position update and time conditions
|
(gps.longitude - (last_reported_longitude or 0))**2)
|
||||||
should_report = False
|
|
||||||
if gps.speed < 2:
|
|
||||||
if time_since_last_report >= 1 and distance_change >= MIN_DISTANCE_CHANGE:
|
|
||||||
should_report = True
|
|
||||||
else:
|
|
||||||
if time_since_last_report >= 30 and distance_change >= MIN_DISTANCE_CHANGE:
|
|
||||||
should_report = True
|
|
||||||
|
|
||||||
# Execute reporting if conditions are met
|
# Check for position update and time conditions
|
||||||
if should_report:
|
should_report = False
|
||||||
|
if gps.speed < 2:
|
||||||
|
if time_since_last_report >= 1 and distance_change >= MIN_DISTANCE_CHANGE:
|
||||||
|
should_report = True
|
||||||
|
else:
|
||||||
|
if time_since_last_report >= 30 and distance_change >= MIN_DISTANCE_CHANGE:
|
||||||
|
should_report = True
|
||||||
|
|
||||||
|
# Execute reporting if conditions are met
|
||||||
|
if should_report:
|
||||||
last_reported_time = current_time
|
last_reported_time = current_time
|
||||||
last_reported_latitude = gps.latitude
|
last_reported_latitude = gps.latitude
|
||||||
last_reported_longitude = gps.longitude
|
last_reported_longitude = gps.longitude
|
||||||
if os.path.exists("/data/brian/gps_tracking.sh"):
|
if os.path.exists("/data/brian/gps_tracking.sh"):
|
||||||
# Update the last reported time and location
|
# Update the last reported time and location
|
||||||
subprocess.run(["bash", "/data/brian/gps_tracking.sh", str(gps.latitude), str(gps.longitude)])
|
subprocess.run(["bash", "/data/brian/gps_tracking.sh", str(gps.latitude), str(gps.longitude)])
|
||||||
|
except:
|
||||||
|
nothing = None
|
||||||
|
|
||||||
elif log_type == LOG_GNSS_OEMDRE_SVPOLY_REPORT:
|
elif log_type == LOG_GNSS_OEMDRE_SVPOLY_REPORT:
|
||||||
msg = messaging.new_message('qcomGnss', valid=True)
|
msg = messaging.new_message('qcomGnss', valid=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user