Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI functional upgrade #72

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 93 additions & 3 deletions Phase 2/filter_py_lib_test/GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
def RunProgram():
try:
val_1 = int(sample_size.get())
kf_algorithm.main(val_1)
n_mean = float(mean_noise.get())
n_std = float(noise_std.get())
initial_P = [int(x_pos_err.get()),int(y_pos_err.get()), int(x_vel_err.get()), int(y_vel_err.get())]
R_matrix =[int(x_pos_obs_err.get()),int(y_pos_obs_err.get()), int(x_vel_obs_err.get()), int(y_vel_obs_err.get())]
kf_algorithm.main(val_1, n_mean, n_std, initial_P,R_matrix)
except ValueError:
tkinter.messagebox.showerror('Error','Please Enter a valid number')

Expand All @@ -39,13 +43,99 @@ def RunProgram():

sample_size = ctk.CTkEntry(app,width=200, height=30)
sample_size.pack(padx=10,pady=10)
sample_size.place(relx=0.3,rely=0.1,anchor=tkinter.CENTER)
sample_size.place(relx=0.35,rely=0.1,anchor=tkinter.CENTER)

# Noise Mean
# label_2 = ctk.CTkLabel(app,text='Mean value of Noise')
label_2 = ctk.CTkLabel(app,text='Mean value of Noise', font=font_1)
label_2.pack(padx=10,pady=10)
label_2.place(relx=0.1,rely=0.2,anchor=tkinter.CENTER)

mean_noise = ctk.CTkEntry(app,width=200, height=30)
mean_noise.pack(padx=10,pady=10)
mean_noise.place(relx=0.35,rely=0.2,anchor=tkinter.CENTER)

# Noise Standard Deviation
label_3 = ctk.CTkLabel(app,text='Nosie Standard Deviation', font=font_1)
label_3.pack(padx=10,pady=10)
label_3.place(relx=0.1,rely=0.3,anchor=tkinter.CENTER)

noise_std = ctk.CTkEntry(app,width=200, height=30)
noise_std.pack(padx=10,pady=10)
noise_std.place(relx=0.35,rely=0.3,anchor=tkinter.CENTER)

# Process Covariance Matrix
label_4 = ctk.CTkLabel(app,text='Initial Process Covariance Matrix', font=font_1)
label_4.pack(padx=10,pady=10)
label_4.place(relx=0.75,rely=0.1,anchor=tkinter.CENTER)

label_5 = ctk.CTkLabel(app,text='x-position error', font=font_1)
label_5.pack(padx=10,pady=10)
label_5.place(relx=0.7,rely=0.2,anchor=tkinter.CENTER)

x_pos_err = ctk.CTkEntry(app,width=100, height=30)
x_pos_err.pack(padx=10,pady=10)
x_pos_err.place(relx=0.85,rely=0.2,anchor=tkinter.CENTER)

label_6 = ctk.CTkLabel(app,text='y-position error', font=font_1)
label_6.pack(padx=10,pady=10)
label_6.place(relx=0.7,rely=0.3,anchor=tkinter.CENTER)

y_pos_err = ctk.CTkEntry(app,width=100, height=30)
y_pos_err.pack(padx=10,pady=10)
y_pos_err.place(relx=0.85,rely=0.3,anchor=tkinter.CENTER)

label_7 = ctk.CTkLabel(app,text='x-velocity error', font=font_1)
label_7.pack(padx=10,pady=10)
label_7.place(relx=0.7,rely=0.4,anchor=tkinter.CENTER)

x_vel_err = ctk.CTkEntry(app,width=100, height=30)
x_vel_err.pack(padx=10,pady=10)
x_vel_err.place(relx=0.85,rely=0.4,anchor=tkinter.CENTER)

label_8 = ctk.CTkLabel(app,text='y-velocity error', font=font_1)
label_8.pack(padx=10,pady=10)
label_8.place(relx=0.7,rely=0.5,anchor=tkinter.CENTER)

y_vel_err = ctk.CTkEntry(app,width=100, height=30)
y_vel_err.pack(padx=10,pady=10)
y_vel_err.place(relx=0.85,rely=0.5,anchor=tkinter.CENTER)

# R_matrix
label_9 = ctk.CTkLabel(app,text='Observation Error Matrix (R_matrix)', font=font_1)
label_9.pack(padx=10,pady=10)
label_9.place(relx=0.15,rely=0.4,anchor=tkinter.CENTER)

label_10 = ctk.CTkLabel(app,text='x-position observation error', font=font_1)
label_10.pack(padx=10,pady=10)
label_10.place(relx=0.15,rely=0.45,anchor=tkinter.CENTER)

x_pos_obs_err = ctk.CTkEntry(app,width=60, height=20)
x_pos_obs_err.pack(padx=10,pady=10)
x_pos_obs_err.place(relx=0.33,rely=0.45,anchor=tkinter.CENTER)

label_11 = ctk.CTkLabel(app,text='y-position observation error', font=font_1)
label_11.pack(padx=10,pady=10)
label_11.place(relx=0.15,rely=0.5,anchor=tkinter.CENTER)

y_pos_obs_err = ctk.CTkEntry(app,width=60, height=20)
y_pos_obs_err.pack(padx=10,pady=10)
y_pos_obs_err.place(relx=0.33,rely=0.5,anchor=tkinter.CENTER)

label_12 = ctk.CTkLabel(app,text='x-velocity observation error', font=font_1)
label_12.pack(padx=10,pady=10)
label_12.place(relx=0.15,rely=0.55,anchor=tkinter.CENTER)

x_vel_obs_err = ctk.CTkEntry(app,width=60, height=20)
x_vel_obs_err.pack(padx=10,pady=10)
x_vel_obs_err.place(relx=0.33,rely=0.55,anchor=tkinter.CENTER)

label_13 = ctk.CTkLabel(app,text='y-velocity observation error', font=font_1)
label_13.pack(padx=10,pady=10)
label_13.place(relx=0.15,rely=0.6,anchor=tkinter.CENTER)

y_vel_obs_err = ctk.CTkEntry(app,width=60, height=20)
y_vel_obs_err.pack(padx=10,pady=10)
y_vel_obs_err.place(relx=0.33,rely=0.6,anchor=tkinter.CENTER)



Expand Down
Binary file modified Phase 2/filter_py_lib_test/__pycache__/kf_algorithm.cpython-311.pyc
Binary file not shown.
11 changes: 7 additions & 4 deletions Phase 2/filter_py_lib_test/kf_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,24 @@ def visulaise_data(position, velocity, acceleration, noise):

data = {'Current State':[],'Predicted State':[],'Updated State':[]}

def main(val_1):
def main(val_1, n_mean, n_std, initial_P, R_matrix):
'''
The main function of the code.

It contains the high level logic.
'''
## Sensor data ##
sensor = sen.PositionSensor(noise_mean=1.0, noise_std=1.5, dt=dt ,sample_size=val_1) #input
# sensor = sen.PositionSensor(noise_mean=1.0, noise_std=1.5, dt=dt ,sample_size=val_1) #input
sensor = sen.PositionSensor(noise_mean=n_mean, noise_std=n_std, dt=dt ,sample_size=val_1)
position, velocity, acceleration, noise = sensor.data_set()

## Data Visualisation ##
visulaise_data(position, velocity, acceleration, noise)

## Initalisation ##
initialisation = kal_fil.kalman_initial(position,velocity, acceleration)
P_initial = initialisation.P_initial(2,1,8,7) #input
# P_initial = initialisation.P_initial(2,1,8,7) #input
P_initial = initialisation.P_initial(initial_P[0],initial_P[1],initial_P[2],initial_P[3])
X_initial = initialisation.X_initial()

P_prev = P_initial
Expand All @@ -121,7 +123,8 @@ def main(val_1):
predicted_process_covariance = predict.P_predicted()

# Kalman Gain
R = kal_fil.R_matrix(3,1,2,1) #input
# R = kal_fil.R_matrix(3,1,2,1) #input
R = kal_fil.R_matrix(R_matrix[0],R_matrix[1],R_matrix[2],R_matrix[3])
K = kal_fil.KalmanGain(predicted_process_covariance,R)

# Measurement input
Expand Down
Loading