Skip to content

Pulsar SDK

Lifecycle, safety, and recovery

Operating state, connection state, and health are distinct facts. Inspect Actuator.status and GroupStatus rather than relying on a single boolean.

Pulsar SDK lifecycle

Operating states

State (Python / Rust) Meaning
UNKNOWN / State::Unknown disconnected or unobserved; cannot be requested
INIT_CONFIG / State::InitConfig drive output and runtime telemetry inactive; configuration allowed
CONFIG_AND_TELEM / State::ConfigAndTelem telemetry active; drive output inactive
DRIVE_ACTIVE / State::DriveActive drive output active; commands affect output
  • connect() ends in INIT_CONFIG.
  • configure() and set_mode() are allowed in INIT_CONFIG or CONFIG_AND_TELEM and never enable output.
  • enable() validates configuration and diagnostics, synchronizes the domain when needed, and enters DRIVE_ACTIVE.
  • disable() quiesces active control callbacks cleanly and returns to CONFIG_AND_TELEM.
  • zero_position() works in CONFIG_AND_TELEM or DRIVE_ACTIVE (and resets the primary command to 0 in position and impedance modes to avoid sudden motion).

Status model

ActuatorStatus reports:

  • operating_state and last_operating_state;
  • connection_state;
  • health (HEALTHY, HOST_FAULT, or ACTUATOR_FAULT);
  • diagnostic (ActuatorDiagnostic with named flags, raw_bits, unknown_bits, bit_numbers, and error_bit_numbers);
  • host_error, safety_attempt (with per-member member_attempts), inhibited_by, recovery, and bounded can_reset_events.

Status and recovery model


Firmware-offloaded safety and watchdog (>= 2.2.5)

In SDK 3.1.0 (Python) / 1.1.0 (Rust) on actuator firmware >= 2.2.5, active error safety actions (DampedRelease, HoldPosition, LimitTorque) and the command freshness watchdog are offloaded directly to actuator firmware. Safety behavior executes on the actuator itself and persists across host crashes, panics, or unexpected disconnects.

Safe defaults applied automatically on connect

Connecting to a physical actuator (>= 2.2.5) automatically applies:

  • Error safety action: DampedRelease (with default damping 10.0 when ControllerErrorPolicy.damping is None);
  • Command freshness timeout: 500 ms.

Sizing the command freshness watchdog (control_rate_hz)

During configure(), passing control_rate_hz automatically sizes the firmware command freshness timeout (ceil(4000 / control_rate_hz) ms, floor 50 ms):

  • Closed-loop streaming (e.g. control_rate_hz=200.0): firmware expects fresh commands regularly and latches safety if the host stalls.
  • One-shot / non-streaming commands: pass control_rate_hz=0.0 (or commands_timeout_ms=0) to explicitly disable command-timeout latching.

Override per actuator at construction using commands_timeout_ms, commands_timeout_action, and auto_clear_faults (Python) or RealActuatorOptions (Rust):

from pulsar_sdk import (
    ControlConfiguration,
    ControllerErrorAction,
    DiagnosticFlag,
    Mode,
    PcpOverCan,
    PulsarActuatorReal,
)

can = PcpOverCan()
actuator = PulsarActuatorReal(
    can,
    address=16,
    commands_timeout_ms=250,
    commands_timeout_action=ControllerErrorAction.HOLD_POSITION,
    auto_clear_faults=False,
)

# Or configure uniform / per-flag safety before connect() or while inactive:
actuator.set_error_action(ControllerErrorAction.DAMPED_RELEASE)
actuator.set_diagnostic_action(
    DiagnosticFlag.OVERTEMPERATURE,
    ControllerErrorAction.LIMIT_TORQUE,
)
use pulsar_rs_sdk::{
    ControllerErrorAction, DiagnosticFlag, PcpOverCan, PulsarActuatorReal,
    RealActuatorOptions,
};

let can = PcpOverCan::new()?;
let actuator = PulsarActuatorReal::on_can_with_options(
    &can,
    16,
    RealActuatorOptions {
        commands_timeout_ms: Some(250),
        commands_timeout_action: Some(ControllerErrorAction::HoldPosition),
        auto_clear_faults: false,
    },
)?;

// Or configure uniform / per-flag safety before connect() or while inactive:
actuator.set_error_action(ControllerErrorAction::DampedRelease)?;
actuator.set_diagnostic_action(
    DiagnosticFlag::Overtemperature,
    ControllerErrorAction::LimitTorque,
)?;

set_error_action(...) and set_diagnostic_action(...) are also available on ActuatorGroup and Platform to configure all members consistently.

Default diagnostic behavior

Named DiagnosticFlag values cover warnings (bits 0–15, including CAN_RESET and COMMAND_TIMEOUT) and errors (bits 16–31, including CRITICAL_LATCHED). Unknown future firmware bits remain visible through raw_bits, unknown_bits, bit_numbers, and error_bit_numbers.

Default actions:

  • OVERTEMPERATURE → LIMIT_TORQUE
  • INTERNAL_ENCODER_ERROR / EXTERNAL_ENCODER_ERROR → INIT_CONFIG
  • other error-level diagnostics (including unknown bits 16–31) → configured error action (default DampedRelease)
  • unmapped warning-level diagnostics → reported and logged without stopping motion

An unexpected state change or group fault preserves ControllerState.FAULTED across propagated platform safety reports and records per-actuator outcomes in SafetyAttempt.member_attempts.

Danger

ControllerErrorAction.DO_NOTHING and override_diagnostic_safety() suppress automatic safety behavior. Use them only in controlled, reviewed setups with an independent hardware safety plan.


Recovery workflows

After a latched firmware safety fault (DiagnosticFlag.CRITICAL_LATCHED / DiagnosticFlag::CriticalLatched), the actuator holds its firmware safety response until explicitly recovered — the SDK never replays pre-fault commands or automatically re-energizes output.

Goal after fault Required sequence
Resume normal control Fix the cause → clear_faults() → resume() → send a fresh command
Disarm cleanly clear_faults() → disable()
Connection lost Reconnect (connect()) — previous physical state is reported as UNKNOWN
from pulsar_sdk import DiagnosticFlag

status = actuator.status
if status.diagnostic and DiagnosticFlag.CRITICAL_LATCHED in status.diagnostic.flags:
    # 1. Confirm physical cause is resolved, then clear latched fault:
    if actuator.clear_faults():
        # Option A: resume active control with a fresh safe command
        actuator.resume()
        actuator.set_command(0.0)
        # Option B: disarm cleanly instead
        # actuator.disable()
use pulsar_rs_sdk::DiagnosticFlag;

let status = actuator.status()?;
let latched = status
    .diagnostic
    .as_ref()
    .is_some_and(|d| d.flags.contains_key(&DiagnosticFlag::CriticalLatched));

if latched && actuator.clear_faults()? {
    // Option A: resume active control with a fresh safe command
    actuator.resume()?;
    actuator.set_command(0.0)?;
    // Option B: disarm cleanly instead
    // actuator.disable()?;
}

clear_faults() transmits CLEAR_ERRORS, verifies fresh diagnostics, and returns False (false) if an active error condition remains. recover() is kept as a compatibility alias for resume().


Disconnect and drop behavior

  • Normal shutdown: call disable(), then disconnect() (or exit a Python with block cleanly).
  • Dropping a connected handle (or exiting a Python with block on an exception) without calling disable() / disconnect() applies the configured firmware safety action while in DRIVE_ACTIVE (preserving any active safety latch) or transitions cleanly to INIT_CONFIG while in CONFIG_AND_TELEM.
  • After transport loss, status.operating_state becomes UNKNOWN while status.last_operating_state preserves the last confirmed state.