rebot_control.arm

The Arm facade: one object for the real arm and the simulator.

Layers (bottom up, see docs/developer/architecture.md):

Arm (this file)        modes, joint / Cartesian commands, slow moves, stall check, recording
JointTargetFilter      soft limits, jump guard, rate limit, low-pass           (control rate, 30 Hz)
ServoLoop              interpolation, torque cap, gravity / friction feedforward (servo rate, 150 Hz)
Backend                RobStride over CAN (motorbridge) | MuJoCo simulation

Life cycle:

arm = Arm.from_config("b601_rs", tool="pusher_ip17", backend="real")
with arm:                   # connect(): look at the arm without changing what the motors do
    arm.enable()            # torque on, holds the measured pose (gains ramp in over ramp_s)
    arm.move_home()         # unfold in stages to the tool's home pose
    ...
# leaving the block normally: fold back to the zero pose in stages, then torque off

Torque is switched off only on purpose: at the normal end of the block (after folding), by Arm.release() / Arm.disable_torque(), or by an over-temperature stop (safety.on_overtemp). When the block is left by an exception or Ctrl-C the arm holds where it is and stays enabled (Arm.detach()), and the motors keep executing that last frame after the program is gone. The next program finds them enabled in Arm.connect() and takes over the hold without a jump (arm.taken_over); the operator ends it with rebot-control release. See docs/user/safety.md.

Timing: the caller runs its loop at control_hz and calls Arm.sleep() once per cycle. On the real arm the servo thread streams frames in the background and sleep just keeps the rate; in simulation sleep advances the physics (and the servo loop) by one control period, so scripts run unchanged in both.

Module Contents

Classes

Arm

Functions

Data

log

API

rebot_control.arm.log = 'getLogger(...)'
rebot_control.arm.make_backend(kind: str, cfg: rebot_control.config.ArmConfig, tool: rebot_control.config.ToolConfig, calibration: rebot_control.config.Calibration | None, **kwargs) → rebot_control.backends.base.Backend
class rebot_control.arm.Arm(cfg: rebot_control.config.ArmConfig, tool: rebot_control.config.ToolConfig | None = None, calibration: rebot_control.config.Calibration | None = None, backend: str | rebot_control.backends.base.Backend = 'real', **backend_kwargs)

Initialization

classmethod from_config(arm: str | pathlib.Path = 'b601_rs', tool: str | pathlib.Path | rebot_control.config.ToolConfig | None = 'none', calibration: str | pathlib.Path | rebot_control.config.Calibration | None = None, backend: str = 'real', overrides: dict | None = None, **backend_kwargs) → rebot_control.arm.Arm

Build from config names or YAML paths (arm: configs/arms, tool: configs/tools).

connect() → rebot_control.arm.Arm

Open the bus (or build the simulation) and start streaming feedback, without changing what the motors do.

The motors may still be enabled and holding the arm from a program that ended abnormally (see detach()). So nothing here sends a zero-gain frame before the state of the motors is known:

  1. read the joint angles without any command frame (Backend.read_positions());

  2. send one full-gain frame that holds exactly those angles: an enabled motor keeps holding, a disabled one ignores it, and both answer with their state;

  3. motors enabled: take over the hold (taken_over, enabled); all disabled: torque stays off.

enable() → None

Torque on and hold the measured pose; gains and feedforward ramp in over gains.ramp_s.

is_enabled_known() → bool
hold() → None

Hold the measured pose with the PD gains (from gravity mode or after a stall in ‘hold’ mode).

gravity_mode() → None

Gravity (+ friction) compensation only, kp = 0: the arm floats and can be moved by hand.

disable_torque() → None

Torque off immediately. The arm falls unless it is supported (or folded at zero).

release(fold: bool = False) → None

The operator’s explicit torque-off. fold=True folds to the zero pose first; otherwise the arm goes limp where it is and must be supported by hand.

freeze() → None

Hold the measured pose with the PD gains, from any mode, and stay enabled.

detach() → None

Stop commanding and release the bus without switching torque off.

If torque is on, the arm first holds the measured pose (zero target velocity); the motors then keep executing that frame for as long as they have power (the drivers’ CAN timeout must be 0). Nobody watches the arm after this: no stall check, no temperature guard. The next connect() takes the hold over.

close(fold: bool = True) → None

Normal end: fold back to the zero pose (if torque is on and fold), torque off, release the bus.

An arm that was found enabled and never commanded by this program is left as found (detach()).

__enter__() → rebot_control.arm.Arm
__exit__(exc_type, exc, tb) → None
now() → float
state() → rebot_control.backends.base.JointState
q() → numpy.ndarray

Measured joint angles (rad).

tcp_pose(q: numpy.ndarray | None = None) → tuple[numpy.ndarray, numpy.ndarray]

TCP pose (p, R) at the measured (or given) joint angles.

joint_target() → numpy.ndarray | None

Last rate-limited joint target (None when not holding).

lag() → float

Largest |target - measured| over the joints (rad); 0 when not holding.

check() → None

Raise the servo thread’s error, if any (temperature stop, bus failure).

check_stall() → None

Safety stop when a joint lags more than safety.lag for stall_time_s without making progress (collision, blocked joint, not enough torque). safety.on_stall: disable (torque off) or hold.

command_joint(q: numpy.ndarray) → numpy.ndarray

Stream one joint target (rad) for this control cycle. Returns the filtered target sent to the servo.

Raises CommandRejected for a target more than safety.max_jump from the previous one.

sleep(dt: float | None = None) → None

Wait until the next control cycle (real) or advance the simulation by one cycle (sim).

wait(seconds: float) → None

Keep streaming the current target for seconds (holds the pose; checks for stalls).

move_to_joint(q: numpy.ndarray, speed: float | None = None, settle: float = 0.5) → None

Slow joint-space move from the current target (or measured pose) to q (rad).

Smoothstep profile (zero velocity at both ends); speed (rad/s) is the average speed of the joint that moves most (default poses.move_speed). Checks for stalls on the way.

move_to_joint_staged(q: numpy.ndarray, first: list[int] | None = None, speed: float | None = None) → None

Move the first joints (default poses.unfold_first: shoulder + elbow) before the others.

From the folded zero pose a straight joint-space line flexes the wrist while the arm is still closed and rubs the upper arm; lifting shoulder and elbow first avoids it.

is_folded(tol: float = math.radians(15.0)) → bool
move_home(speed: float | None = None) → None

Go to the tool’s home pose (staged when starting from the folded pose).

fold(speed: float | None = None) → None

Return to the zero pose in poses.fold_stages order (base + wrist first, then shoulder + elbow).

move_to_pose(pos: numpy.ndarray, rot: numpy.ndarray | None = None, speed: float | None = None, tol: float = 0.001, timeout: float = 20.0) → bool

Straight-line TCP move (Cartesian controller) to (pos, rot); speed in m/s (default: the limit).

Returns False when the target is not reached within timeout (e.g. outside the workspace limits).

cartesian(limits=None)

A CartesianController starting at the current target pose.

set_tool(tool: str | pathlib.Path | rebot_control.config.ToolConfig) → None

Swap the tool (TCP + payload) without reconnecting; takes effect at the next servo tick.

set_gains(kp: numpy.ndarray | None = None, kd: numpy.ndarray | None = None) → None
start_recording() → None
stop_recording() → dict[str, numpy.ndarray]
recording()

with arm.recording() as rec: ... then rec["q"] etc. (filled when the block exits).