feature/multi-robots-types #12

Merged
aqua3 merged 20 commits from feature/multi-robots-types into master 2024-12-05 11:36:57 -04:00
1 changed files with 13 additions and 3 deletions
Showing only changes of commit 9538f37c5b - Show all commits

View File

@ -92,6 +92,13 @@ for file in Path("/robots").glob("**/robot_plugins.py"):
spec.loader.exec_module(plugin) spec.loader.exec_module(plugin)
logger.info(f"Loaded plugin {file}") logger.info(f"Loaded plugin {file}")
async def topic_subscriber(element, topic_name):
while True:
with element:
element.clear()
ui.label(topic_name)
await asyncio.sleep(1)
class Spirimu(Robot): class Spirimu(Robot):
robot_type = "spiri_mu" robot_type = "spiri_mu"
@ -209,6 +216,9 @@ class Spirimu(Robot):
for topic in node_dummy.get_topic_names_and_types(): for topic in node_dummy.get_topic_names_and_types():
if self.robot_name in topic[0]: if self.robot_name in topic[0]:
ui.label(topic[0]) ui.label(topic[0])
# expander = ui.expansion(topic[0]).classes('w-full')
# topic_subscriber(expander, topic[0])
ui.button("Refresh topics", on_click=refresh_topics).classes("m-2") ui.button("Refresh topics", on_click=refresh_topics).classes("m-2")
async def ui_actions(self, element): async def ui_actions(self, element):
@ -248,14 +258,14 @@ class Spirimu(Robot):
with ui.tabs() as tabs: with ui.tabs() as tabs:
tab_containers = ui.tab("Containers") tab_containers = ui.tab("Containers")
tab_ros = ui.tab("ROS Topics") tab_ros = ui.tab("ROS Topics")
tab_actions = ui.tab("Actions") # tab_actions = ui.tab("Actions")
with ui.tab_panels(tabs, value=tab_containers): with ui.tab_panels(tabs, value=tab_containers):
tab = ui.tab_panel(tab_containers).classes("w-full") tab = ui.tab_panel(tab_containers).classes("w-full")
asyncio.create_task(self.ui_containers(tab)) asyncio.create_task(self.ui_containers(tab))
tab = ui.tab_panel(tab_ros).classes("w-full") tab = ui.tab_panel(tab_ros).classes("w-full")
asyncio.create_task(self.ui_ros(tab)) asyncio.create_task(self.ui_ros(tab))
tab = ui.tab_panel(tab_actions).classes("w-full") # tab = ui.tab_panel(tab_actions).classes("w-full")
asyncio.create_task(self.ui_actions(tab)) # asyncio.create_task(self.ui_actions(tab))
async def async_stop(self): async def async_stop(self):
return await run.io_bound(self.stop) return await run.io_bound(self.stop)