Complete Restructered Robot Code
Robot into its own Class instead of lose Global Variables that cause circular imports StateClass usage instead of the old RobotState.py New Input Class for Controller and randome intputs
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
"""
|
||||
inputs/InputProvider.py - Abstraction layer for robot control inputs
|
||||
"""
|
||||
from abc import ABC, abstractmethod
|
||||
from dataclasses import dataclass, field
|
||||
from typing import List
|
||||
|
||||
|
||||
@dataclass
|
||||
class CommandFrame:
|
||||
"""Represents a snapshot of control inputs at a single tick."""
|
||||
state: str = "idle"
|
||||
vector_dirmov: List[float] = field(default_factory=lambda: [0.0, 0.0, 0.0]) # [vx, vy, omega]
|
||||
emote: str = ""
|
||||
|
||||
|
||||
class InputProvider(ABC):
|
||||
"""Abstract Base Class for input providers (Joystick, Random/RL, Scripted, etc.)."""
|
||||
|
||||
@abstractmethod
|
||||
def get_command(self) -> CommandFrame:
|
||||
"""Polls or generates the latest input command frame."""
|
||||
pass
|
||||
|
||||
def stop(self) -> None:
|
||||
"""Optional cleanup when shutting down input loop."""
|
||||
pass
|
||||
Reference in New Issue
Block a user