optimzie code
This commit is contained in:
@@ -22,6 +22,8 @@ from interfaces.action import ExecuteBtAction
|
||||
from interfaces.msg import SkillCall
|
||||
from interfaces.action import Arm
|
||||
from interfaces.srv import BtRebuild
|
||||
import time
|
||||
|
||||
|
||||
class CtrlGuiNode(Node):
|
||||
"""ROS2 node that publishes String messages to /led_cmd."""
|
||||
@@ -169,26 +171,28 @@ class CtrlGuiNode(Node):
|
||||
def build_ui(node: CtrlGuiNode) -> None:
|
||||
"""Build the NiceGUI UI."""
|
||||
# Add favicon and background image using custom HTML
|
||||
ui.add_head_html('''
|
||||
# Add timestamp to background image URL to prevent caching
|
||||
timestamp = int(time.time())
|
||||
ui.add_head_html(f'''
|
||||
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
|
||||
<style>
|
||||
body {
|
||||
background-image: url("/static/background.png");
|
||||
body {{
|
||||
background-image: url("/static/background.png?v={timestamp}");
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
background-attachment: fixed;
|
||||
}
|
||||
.card-container {
|
||||
}}
|
||||
.card-container {{
|
||||
background-color: rgba(255, 255, 255, 0.9);
|
||||
border-radius: 10px;
|
||||
}
|
||||
}}
|
||||
</style>
|
||||
''')
|
||||
|
||||
# --- build UI ---
|
||||
ui.label('HiveCore Robot Control Node').classes('text-2xl')
|
||||
ui.label('HiveCore Robot 2025').classes('text-2xl').classes('self-end')
|
||||
|
||||
ui.separator()
|
||||
# ui.separator()
|
||||
ui.label('Control Panel').classes('text-xl')
|
||||
# confirm dialog function
|
||||
def show_confirm_dialog(message: str, confirm_callback) -> None:
|
||||
@@ -389,14 +393,14 @@ def build_ui(node: CtrlGuiNode) -> None:
|
||||
)).classes('self-end')
|
||||
|
||||
# Add statistics display
|
||||
ui.separator()
|
||||
# ui.separator()
|
||||
ui.label('Node Statistics').classes('text-xl')
|
||||
with ui.card().classes('w-full card-container'):
|
||||
stats_label = ui.label()
|
||||
|
||||
# Display area for incoming /robot_work_info messages
|
||||
ui.separator()
|
||||
ui.label('Robot Work Information').classes('text-xl')
|
||||
# ui.separator()
|
||||
ui.label('Work Information').classes('text-xl')
|
||||
|
||||
# Create labels for all RobotWorkInfo fields
|
||||
with ui.card().classes('w-full card-container'):
|
||||
@@ -414,8 +418,8 @@ def build_ui(node: CtrlGuiNode) -> None:
|
||||
ui.label('Task Information').classes('text-lg font-bold')
|
||||
with ui.grid(columns=3).classes('w-full'):
|
||||
last_task_label = ui.label('Last Task: ')
|
||||
next_task_label = ui.label('Next Task: ')
|
||||
current_task_label = ui.label('Current Task: ')
|
||||
next_task_label = ui.label('Next Task: ')
|
||||
|
||||
ui.label('Skill Information').classes('text-lg font-bold')
|
||||
with ui.grid(columns=2).classes('w-full'):
|
||||
|
||||
BIN
static/background1.png
Normal file
BIN
static/background1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 72 KiB |
@@ -12,5 +12,5 @@ for i in range(0, height, 20):
|
||||
draw.line([(0, i), (width, i)], fill='#e0e0e0')
|
||||
|
||||
# Save the image
|
||||
image.save('/root/workspace/hivecore_ws/hivecore_robot_ctrlgui/static/background.png')
|
||||
image.save('/root/workspace/hivecore_ws/hivecore_robot_ctrlgui/static/background.new.png')
|
||||
print("Background image created successfully.")
|
||||
|
||||
Reference in New Issue
Block a user