Hardware interface, safety and runtime#
Running the system on a robot: a hardware interface, an independent safety filter and a fixed-rate control loop.
Nothing in this module has been run on real hardware. SimulatedHardware implements the interface on the simulator so
the loop, the safety filter and the failure handling are tested; a dev-kit driver has to implement MotorHardware (three
methods) and be validated on the bench.
The safety filter (SafetyLayer) sits between every command and the motor and does not depend on the learned model,
the agent, the supervisor or a language model: it clamps the command, limits its rate of change, refuses to drive past soft
position limits, and latches a stop that only a human releases. If the loop raises for any reason the runtime calls
hardware.stop() before the exception leaves it.
Sensors the agent needs: a position encoder (workspace units, -1..1) and an accelerometer on the moving part (a_mems,
m/s^2). A drive with an encoder only cannot run MotorAgent as it is;
ControlRuntime refuses to start rather than run degraded without saying so. The quantum accelerometer (a_q) is
optional, and no quantum accelerometer exists on a dev kit: it is simulated.
Classes
What a dev-kit driver must provide. |
|
The simulator behind the |
|
Last line of defence between any command and the motor; independent of the AI. |
|
Fixed-rate loop: read, estimate, control, supervise, filter for safety, write. |
- class MotorHardware(*args, **kwargs)[source]#
Bases:
ProtocolWhat a dev-kit driver must provide.
- read()[source]#
{'t': seconds, 'enc': position in -1..1 or None, 'a_mems': m/s^2 or None, 'a_q': m/s^2 or None}(latest values).- Return type:
- class SimulatedHardware(faults=(), seed=0, theta0=0.0, drop_telemetry_at=None, **kw)[source]#
Bases:
objectThe simulator behind the
MotorHardwareinterface.
- class SafetyLimits(u_max: 'float' = 0.8, slew: 'float' = 0.25, soft_limit: 'float' = 0.95)[source]#
Bases:
object
- class SafetyLayer(limits=None)[source]#
Bases:
objectLast line of defence between any command and the motor; independent of the AI.