Skip to content

Commit 26c5edc

Browse files
Added functionality for setting your own curvature limits and general improvement in binaries
1 parent 3e1e162 commit 26c5edc

File tree

3 files changed

+84
-16
lines changed

3 files changed

+84
-16
lines changed

GUI_supporting_pages/modeling.py

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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.")

GUI_supporting_pages/planning_controls.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,14 @@ def update_ui_control_topic_select(self):
286286
if int(widget.grid_info()['row']) > 6:
287287
widget.grid_forget() # Remove widgets from previous selection
288288

289-
# Label for state estimation rostopic selection
290-
self.rostopic_controls_selection_label = ctk.CTkLabel(self.topic_selection_frame,
291-
text="Select rostopic for control: The script publishes a Twist msg with command velocity (m/s) and steering angle (rad)", anchor="w")
292-
self.rostopic_controls_selection_label.grid(row=6, column=0, padx=(0, 20), pady=(10, 10), sticky="ew")
289+
293290

294291
if selection == 0:
292+
# Label for state estimation rostopic selection
293+
self.rostopic_controls_selection_label = ctk.CTkLabel(self.topic_selection_frame,
294+
text="Select rostopic for control: The script publishes a Twist msg with command velocity (m/s) and steering angle (rad)",
295+
anchor="w")
296+
self.rostopic_controls_selection_label.grid(row=6, column=0, padx=(0, 20), pady=(10, 10), sticky="ew")
295297
# Label for velocity topic
296298
self.rostopic_control_label = ctk.CTkLabel(self.topic_selection_frame, text="Combined control topic", anchor="w")
297299
self.rostopic_control_label.grid(row=7, column=0, columnspan=2, sticky="ew")
@@ -304,21 +306,21 @@ def update_ui_control_topic_select(self):
304306
else:
305307
# Label for velocity topic
306308
self.rostopic_velocity_label = ctk.CTkLabel(self.topic_selection_frame, text="Throttle topic: The script with publish a percentage throttle (v/v_max set for the platform)", anchor="w")
307-
self.rostopic_velocity_label.grid(row=7, column=0, columnspan=2, sticky="ew")
309+
self.rostopic_velocity_label.grid(row=6, column=0, columnspan=2, sticky="ew")
308310
# Select velocity topic
309311
self.selected_velocity_topic = ctk.StringVar(value=self.available_topics[0]) # Initialize variable
310312
self.velocity_topic_dropdown = ctk.CTkOptionMenu(self.topic_selection_frame, variable=self.selected_velocity_topic,
311313
values=self.available_topics,command=self.save_control_topic_vel)
312-
self.velocity_topic_dropdown.grid(row=8, column=0, padx=(0, 10), pady=(10, 10), sticky="ew")
314+
self.velocity_topic_dropdown.grid(row=7, column=0, padx=(0, 10), pady=(10, 10), sticky="ew")
313315

314316
# Label for steering topic
315317
self.rostopic_steering_label = ctk.CTkLabel(self.topic_selection_frame, text="Steering topic: The script with publish a percentage steering \u00B1 (delta/delta_max set for the platform)", anchor="w")
316-
self.rostopic_steering_label.grid(row=9, column=0, columnspan=2, sticky="ew")
318+
self.rostopic_steering_label.grid(row=8, column=0, columnspan=2, sticky="ew")
317319
# Select steering topic
318320
self.selected_steering_topic = ctk.StringVar(value=self.available_topics[0]) # Initialize variable
319321
self.steering_topic_dropdown = ctk.CTkOptionMenu(self.topic_selection_frame, variable=self.selected_steering_topic,
320322
values=self.available_topics,command=self.save_control_topic_steering)
321-
self.steering_topic_dropdown.grid(row=10, column=0, padx=(0, 10), pady=(10, 10), sticky="ew")
323+
self.steering_topic_dropdown.grid(row=9, column=0, padx=(0, 10), pady=(10, 10), sticky="ew")
322324

323325
def update_ui_motion_planner_type(self,mmpk_type):
324326
# create radiobutton frame for type of planer

Update_notes.txt

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
1-
12/02/23
1+
01/21/25
2+
***Modeling***
3+
Added new functionality to provide curvature limits
4+
***Minor bug fixes and improvements ***
5+
6+
01/20/25
7+
***Modeling***
8+
Added new functionality to provide curvature limits
9+
***Minor bug fixes and improvements ***
10+
***Project Vaurna 1.2.1 binary***
11+
12+
12/20/24
13+
***Deploy***
14+
Added dedicated dev mode for rapid debugging and feature updates
15+
***Minor bug fixes and improvements ***
16+
***Project Varuna 1.2 binary***
17+
18+
12/10/24
19+
***Modeling,Planning,Deploy***
20+
Removed the print statements kept for debugging
21+
***Minor bug fixes and improvements ***
22+
*** Passed the curvature limit in polar_representation_2_state.py in the process for curvature limits
23+
<-Project Varuna binary updates: Soon to release in v1.3->
24+
*** Changed the curvature processing util to fit a quadratic spline across the segment and get curvature of the spline (Experimental --works)
25+
*** Made changes in the controls scripts to reflect the additional parameter for curvture calculation
26+
27+
12/02/24
228
***Modeling,Planning,Deploy***
329
Removed the print statements kept for debugging
430
***Deploy***

0 commit comments

Comments
 (0)