rebot_control.backends.base

Backend interface: the motors (real or simulated), in joint units.

A backend only moves MIT frames and feedback; all control logic (interpolation, feedforward, safety) lives above it in rebot_control.servo.ServoLoop, so the real arm and the simulation run the same code.

Units: rad, rad/s, N*m, N*m/rad, N*m*s/rad, deg C. Sign conventions (motor direction / offset) are handled inside the backend: everything crossing this interface is in URDF joint coordinates.

Module Contents

Classes

API

class rebot_control.backends.base.JointState
t: float = None
q: numpy.ndarray = None
dq: numpy.ndarray = None
tau: numpy.ndarray = None
temp: numpy.ndarray = None
valid: numpy.ndarray = None
enabled: numpy.ndarray = 'field(...)'
__post_init__() → None
copy() → rebot_control.backends.base.JointState
class rebot_control.backends.base.Backend

Bases: abc.ABC

is_sim: bool = False
n: int = None
abstractmethod connect() → None

Open the bus / build the simulation. Sends nothing that changes what the motors are doing: motors left enabled by an earlier program keep executing their last frame.

abstractmethod close(disable: bool = True) → None

Release the bus. disable=True: torque off first. disable=False: leave the motors exactly as they are, so enabled motors keep executing the last frame they received (see Arm.detach).

abstractmethod read_positions() → numpy.ndarray

Joint angles read without sending any command frame, so a motor that is holding keeps holding.

This is how a new program looks at an arm before it knows whether the motors are enabled.

abstractmethod enable() → None

Switch the motors that are not enabled yet to MIT mode and enable them. Motors that are already enabled are not touched. Newly enabled motors produce no torque until they receive a frame with gains.

abstractmethod disable() → None

Torque off (motors coast; the arm falls unless supported).

abstractmethod send_mit(q: numpy.ndarray, dq: numpy.ndarray, kp: numpy.ndarray, kd: numpy.ndarray, tau: numpy.ndarray) → None

One MIT frame per motor: tau_out = kp (q - q_meas) + kd (dq - dq_meas) + tau.

send_passive() → None

Zero-gain frames: no output torque, but every motor replies with its state (RobStride feedback trick).

abstractmethod read() → rebot_control.backends.base.JointState

Latest feedback (processes pending replies first).

abstractmethod now() → float

Backend clock (s).

abstractmethod set_zero(joints: list[int]) → None

Store the current position as zero in the given motors (real arm only).

abstractmethod advance(dt: float) → None

Simulation only: advance physics by dt seconds.