mirror of
https://gitlab.ewi.tudelft.nl/ee2l1/2025-2026/A.K.03.git
synced 2025-12-12 16:00:56 +01:00
35 lines
1012 B
Python
35 lines
1012 B
Python
import time
|
|
from kitt import KITT
|
|
|
|
def process(recording_duration):
|
|
|
|
# Record data for a specified duration (e.g., 10 seconds)
|
|
start_time = time.time()
|
|
|
|
while time.time() - start_time < recording_duration:
|
|
|
|
status = KITT.get_distance_report()
|
|
lines = status.splitlines()
|
|
|
|
# Initialize variables to hold distance values
|
|
dist_L = None
|
|
dist_R = None
|
|
|
|
# Initialize a list to store recorded data
|
|
data = []
|
|
|
|
# Iterate over each line to find distance data
|
|
for line in lines:
|
|
if "Dist." in line:
|
|
words = line.split()
|
|
# Extract distance values based on their positions
|
|
|
|
# Assign dist_L and dist_R accordingly
|
|
dist_L = words[3]
|
|
dist_R = words[5]
|
|
break # Exit the loop after finding the distances
|
|
|
|
current_time = time.time() - start_time
|
|
data.append([current_time, dist_L, dist_R])
|
|
|
|
return data, dist_L, dist_R |