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 10 additions and 0 deletions
Showing only changes of commit a5207c6b28 - Show all commits

View File

@ -13,6 +13,7 @@ import aiodocker
import asyncio
from spiri_sdk_guitools.video_button import EnableStreamingButton
from collections import defaultdict
import importlib.util
docker_client = docker.from_env()
@ -81,8 +82,17 @@ robot_types = {}
class Robot:
def __init_subclass__(self):
#Register sub-classes as plugins
robot_types[self.robot_type] = self
for file in Path("/robots").glob("**/robot_plugins.py"):
logger.info(f"Loading plugin {file}")
spec = importlib.util.spec_from_file_location("robot_plugins", file)
plugin = importlib.util.module_from_spec(spec)
spec.loader.exec_module(plugin)
logger.info(f"Loaded plugin {file}")
class Spirimu(Robot):
robot_type = "spiri_mu"