Commit b8606fa9 authored by ChristineC8's avatar ChristineC8
Browse files

fixed naming convention in testing script

parent 93566e82
......@@ -20,14 +20,15 @@ def extract_data(text_file, string_label) :
if not line:
break
# Find duty cycle data
duty_index = line.find(string_label)
# Find data cycle data
data_index = line.find(string_label)
# If found, extract duty data
# If found, extract data
# Our floats are printed with 5 decimal places
if duty_index != -1 :
if data_index != -1 :
# Go to actual index of the data rather than the label
float_start_index = duty_index + label_size
float_start_index = data_index + label_size
# Find decimal point index and add 5 decimal points to find size of floating point number
float_size = line[float_start_index:].find(".") + 5
......@@ -37,7 +38,7 @@ def extract_data(text_file, string_label) :
if data_point > 0.8 :
print(line)
print(data_point)
print(duty_index)
print(data_index)
data_list.append(float(line[float_start_index: float_start_index + float_size + 1]))
......@@ -54,9 +55,8 @@ def plot_data(y_data, x_label, y_label, title) :
plt.show()
# Main :
# find and print left duty data
text_file = "/Users/cc/Documents/School/ee185/software/firmware/circuitpython-main/ports/atmel-samd/common-hal/motor_control/PID_testing/pid_KI_0.0125_KP_0.0325.txt"
text_file = "/Users/cc/Documents/School/ee185/software/firmware/circuitpython-main/ports/atmel-samd/common-hal/motor_control/PID_testing/pid_KI=0.04375_KP_0.00625.txt"
# find and print data
text_file = "/Users/cc/Documents/School/ee185/software/firmware/circuitpython-main/ports/atmel-samd/common-hal/motor_control/PID_testing/pid_scripts/pid_KI_0.005_KP_0.005.txt"
data_label = "duty_left: "
data_list = extract_data(text_file, data_label)
title = "Calculated PID Left Wing Duty Cycles: KI = 0.04375 & KP = 0.00625"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment