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

Added option to build package when saving configuration file #351

Merged
merged 3 commits into from
May 28, 2024
Merged
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
34 changes: 28 additions & 6 deletions ariac_gui/ariac_gui/trial_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import yaml
from copy import copy, deepcopy
from datetime import datetime
import subprocess
from time import sleep

from ariac_msgs.msg import (
Part as PartMsg,
Expand Down Expand Up @@ -410,17 +412,22 @@ def __init__(self):
self.notebook.add(self.map_frame, text="Full Map")
self.notebook_frames.append(self.map_frame)

# Map elements
# Map elements
self.map_canvas_bin_elements = []
self.map_canvas_conveyor_elements = []
self.map_canvas_conveyor_lines = []
self.map_canvas_assembly_station_elements = []
self.map_canvas_agv_elements = []
self.bin_parts_counter.trace_add('write',self.add_bin_parts_to_map)
self.add_map_to_frame()

# Build package variable
self.build_package_var = ctk.StringVar()
self.build_package_var.set("1")

self.save_file_button = ctk.CTkButton(self, text="Save file", command=self.choose_save_location, state = tk.DISABLED)
ToolTip(self.save_file_button, msg = self.update_save_file_msg, delay=0.2)
self.build_package_cb = ctk.CTkCheckBox(self, text="Build ariac_gazebo pkg after saving",variable=self.build_package_var, onvalue="1", offvalue="0", height=1, width=20)
self.light_dark_button = ctk.CTkButton(self, text="", image=ctk.CTkImage(MENU_IMAGES["dark_icon"],size=(50,50)), command = self.switch_light_dark, fg_color="#ebebeb", bg_color="#ebebeb", hover_color="#ebebeb")
self._build_assembly_parts_pose_direction()

Expand All @@ -444,8 +451,9 @@ def open_main_window(self):
self.initial_label.grid_forget()
self.load_file_button.grid_forget()
self.new_file_button.grid_forget()
self.notebook.grid(pady=10,column=LEFT_COLUMN, columnspan=2,sticky=tk.E+tk.W+tk.N+tk.S)
self.save_file_button.grid(pady=10,column=MIDDLE_COLUMN,row=4)
self.notebook.grid(pady=10,column=LEFT_COLUMN, columnspan=3,sticky=tk.E+tk.W+tk.N+tk.S)
self.save_file_button.grid(pady=10,column=RIGHT_COLUMN,row=4)
self.build_package_cb.grid(pady=10, column=MIDDLE_COLUMN, row=4)
self.light_dark_button.grid(pady=10, column=LEFT_COLUMN, row=4)


Expand Down Expand Up @@ -2250,7 +2258,7 @@ def orders_to_dict(self):
temp_order_dict["id"] = order.id
temp_order_dict["type"] = ORDER_TYPES[order.type]
temp_order_dict["announcement"] = self.announcement_to_dict(order.condition)
temp_order_dict["priority"] = order.priority == "1"
temp_order_dict["priority"] = order.priority == True
if order.type == 0:
temp_order_dict["kitting_task"] = {}
temp_order_dict["kitting_task"]["agv_number"] = order.kitting_task.agv_number
Expand Down Expand Up @@ -3024,8 +3032,22 @@ def save_file(self, original_trial_name = False):
f.write(f"# CHALLENGES INFORMATION\n")
challenges_data = yaml.dump(self.challenges_dict,sort_keys=False,Dumper=NoAliasDumper)
f.write(f"\n{challenges_data}\n")

self.build_package = self.build_package_var.get() == "1"

self.destroy()


if self.build_package:
try:
ws_path = os.path.join(*[str(item) for item in get_package_prefix("ariac_gazebo").split("/")[:-2]])

os.chdir("/" + ws_path)

build_cmd = "colcon build --packages-select ariac_gazebo"
subprocess.run(build_cmd, shell=True)
except:
print("ERROR: Workspace not able to be found. Cannot build.")

# =======================================================
# Current File
# =======================================================
Expand Down Expand Up @@ -3438,4 +3460,4 @@ def update_save_file_msg(self):
msg = "There must be at least one order to save"
else:
msg = f"There {'is' if num_orders == 1 else 'are'} currently {num_orders} order{'' if num_orders == 1 else 's'}"
return msg
return msg