| """Base controller interface for Spot robot.""" | |
| import numpy as np | |
| from abc import ABC, abstractmethod | |
| class BaseController(ABC): | |
| """Abstract base class for Spot controllers.""" | |
| def __init__(self, num_joints: int = 12): | |
| self.num_joints = num_joints | |
| self.time = 0.0 | |
| def compute_action(self, obs: np.ndarray, data) -> np.ndarray: | |
| """Compute control action given observation. | |
| Args: | |
| obs: Observation vector [base_pos(3), base_quat(4), base_lin_vel(3), | |
| base_ang_vel(3), joint_pos(12), joint_vel(12)] | |
| data: MuJoCo data object for additional state access | |
| Returns: | |
| Action vector (target joint positions for position actuators) | |
| """ | |
| pass | |
| def step(self, dt: float): | |
| """Update controller time.""" | |
| self.time += dt | |
| def reset(self): | |
| """Reset controller state.""" | |
| self.time = 0.0 | |
| def name(self) -> str: | |
| """Return controller name for display.""" | |
| pass | |