@@ -343,20 +343,33 @@ def update_ui_model_data(self):
343343 save_button = ctk .CTkButton (master = self .data_selection_frame , text = "Apply" , command = self .save_num_models )
344344 save_button .grid (row = 5 , column = 2 , pady = 10 )
345345
346+ # Add an entry for curvature limits
347+ self .curavture_limits_text = ctk .CTkLabel (self .data_selection_frame , text = "Curvature limits (1/min turning radius): \u00B1 " ,
348+ anchor = "w" )
349+ self .curavture_limits_text .grid (row = 6 , column = 0 , padx = (0 , 20 ), pady = (10 , 10 ), sticky = "ew" )
350+
351+ # Add Entry: Num models in MMPK
352+ self .entry_curvature_limits = ctk .CTkEntry (master = self .data_selection_frame )
353+ self .entry_curvature_limits .grid (row = 6 , column = 1 , padx = 10 , pady = 10 , sticky = "w" )
354+
355+ # Add a Button to trigger saving num of MMPK models
356+ save_button_curvature_lim = ctk .CTkButton (master = self .data_selection_frame , text = "Apply" , command = self .save_curvature_lim )
357+ save_button_curvature_lim .grid (row = 6 , column = 2 , pady = 10 )
358+
346359 self .save_model_text = ctk .CTkLabel (self .data_selection_frame , text = "Save the trained model?" ,
347360 anchor = "w" )
348- self .save_model_text .grid (row = 6 , column = 0 , padx = (0 , 20 ), pady = (10 , 10 ), sticky = "ew" )
361+ self .save_model_text .grid (row = 7 , column = 0 , padx = (0 , 20 ), pady = (10 , 10 ), sticky = "ew" )
349362
350363 self .radio_var_save_model = tk .IntVar (value = 0 )
351364 save_model_radio_button = ctk .CTkRadioButton (self .data_selection_frame , text = 'Yes' ,
352365 variable = self .radio_var_save_model , value = 0 ,
353366 command = self .update_ui_save_model )
354- save_model_radio_button .grid (row = 6 , column = 1 , padx = (0 , 10 ), sticky = "w" )
367+ save_model_radio_button .grid (row = 7 , column = 1 , padx = (0 , 10 ), sticky = "w" )
355368
356369 save_model_radio_button = ctk .CTkRadioButton (self .data_selection_frame , text = 'No' ,
357370 variable = self .radio_var_save_model , value = 1 ,
358371 command = self .update_ui_save_model )
359- save_model_radio_button .grid (row = 6 , column = 2 , padx = (10 , 0 ), sticky = "w" )
372+ save_model_radio_button .grid (row = 7 , column = 2 , padx = (10 , 0 ), sticky = "w" )
360373 self .update_ui_save_model ()
361374
362375 self .test_label = ctk .CTkLabel (self .data_selection_frame , text = "Test Data Directory" ,
@@ -373,19 +386,19 @@ def update_ui_save_model(self):
373386 save_model_map = {0 : True , 1 : False }
374387 for widget in self .data_selection_frame .grid_slaves ():
375388 # print(widget.grid_info())
376- if int (widget .grid_info ()['row' ]) > 6 :
389+ if int (widget .grid_info ()['row' ]) > 7 :
377390 widget .grid_forget () # Remove widgets from previous selection
378391 if self .radio_var_save_model .get () == 0 :
379392 self .controller .args_dict ['Modeling' ]['Save_Trained_Model' ] = save_model_map [int (self .radio_var_save_model .get ())]
380393 self .save_model_folder = ctk .CTkButton (self .data_selection_frame , text = "Select Folder" ,
381394 command = self .select_model_save_dir )
382- self .save_model_folder .grid (row = 7 , column = 0 , padx = (0 , 20 ), pady = (0 , 10 ), sticky = "ew" )
395+ self .save_model_folder .grid (row = 8 , column = 0 , padx = (0 , 20 ), pady = (0 , 10 ), sticky = "ew" )
383396 self .save_model_folder_text = ctk .CTkLabel (self .data_selection_frame , text = "No folder selected" , anchor = "w" )
384- self .save_model_folder_text .grid (row = 7 , column = 1 , padx = (10 , 10 ), pady = (0 , 10 ), sticky = "ew" )
397+ self .save_model_folder_text .grid (row = 8 , column = 1 , padx = (10 , 10 ), pady = (0 , 10 ), sticky = "ew" )
385398 else :
386399 self .controller .args_dict ['Modeling' ]['Save_Trained_Model' ] = save_model_map [int (self .radio_var_save_model .get ())]
387400 for widget in self .data_selection_frame .grid_slaves ():
388- if int (widget .grid_info ()['row' ]) > 6 :
401+ if int (widget .grid_info ()['row' ]) > 7 :
389402 widget .grid_forget () # Hide widgets by forgetting them
390403
391404
@@ -433,6 +446,15 @@ def save_num_models(self):
433446
434447 self .controller .args_dict ['Modeling' ]['Num_models' ] = num_models
435448
449+ def save_curvature_lim (self ):
450+ curvature_limits = self .entry_curvature_limits .get () # Get value from state penalty entry
451+ # Validation: Check if the input is two integers separated by a space
452+ if not self .validate_curvature_lim (curvature_limits ):
453+ self .show_warning_curvature_lim ("Curvature limits" )
454+ return
455+
456+ self .controller .args_dict ['Modeling' ]['Curvature_limits' ] = curvature_limits
457+
436458
437459 def save_custom_platform (self ):
438460 platform_name = self .entry_platform_name .get () # Get value from state penalty entry
@@ -510,6 +532,20 @@ def validate_num_models(self, input_str):
510532 # If conversion to integer fails, return False
511533 return False
512534
535+ def validate_curvature_lim (self , input_str ):
536+ try :
537+ # Attempt to convert the input string to a float
538+ float_val = float (input_str )
539+
540+ # Check if the float value is positive
541+ if float_val > 0 :
542+ return True
543+ else :
544+ return False
545+ except ValueError :
546+ # If conversion to float fails, return False
547+ return False
548+
513549 def validate_platform_name (self , input_str ):
514550 # Regular expression to check if the string contains only alphanumeric characters (no spaces, no special characters)
515551 if re .match ("^[a-zA-Z0-9]*$" , input_str ):
@@ -549,6 +585,10 @@ def show_warning_num_models(self,field_name):
549585 messagebox .showwarning ("Input Error" ,
550586 f"Invalid input for { field_name } . Please enter 1 integer value denoting number of models in MMPK setup." )
551587
588+ def show_warning_curvature_lim (self ,field_name ):
589+ messagebox .showwarning ("Input Error" ,
590+ f"Invalid input for { field_name } . Please enter a single int/float value denoting curvature limits of the platform." )
591+
552592 def show_warning_name (self ,field_name ):
553593 messagebox .showwarning ("Input Error" ,
554594 f"Invalid input for { field_name } . Please enter name of platform without spaces and special characters." )
0 commit comments