Pulsar SDK
Telemetry and callbacks
Pulsar SDK supports on-demand snapshot reads, per-actuator telemetry callbacks, synchronized group control callbacks, and platform-wide callback registration.
Configure periodic telemetry
from pulsar_sdk import ControlConfiguration, Mode, TelemetryItems
configuration = ControlConfiguration(
mode=Mode.POSITION,
telemetry_items=(
TelemetryItems.POSITION,
TelemetryItems.VELOCITY,
TelemetryItems.TORQUE_ESTIMATE,
TelemetryItems.TIMESTAMP_MS,
),
telemetry_rate_hz=500,
control_rate_hz=500,
)
- Configure at most 12 unique telemetry items.
- Check
actual_telemetry_rate_hzfor the exact firmware 20 kHz divider rate. - Use canonical telemetry names (
POSITION/TelemetryItem::Position,VELOCITY/TelemetryItem::Velocity); duplicate*_ACTUALaliases were removed in3.1.0/1.1.0.
Read a snapshot
Snapshot reads work in CONFIG_AND_TELEM or DRIVE_ACTIVE:
Standalone actuator telemetry callback
One worker per execution domain invokes user callbacks off the transport reader thread. At most one callback runs while one newest pending packet waits; inspect dropped_telemetry_packets if your callback runs slower than the telemetry rate.
Group control callback
A group control callback executes once one fresh sample has arrived from every actuator in the group, and its returned command batch is validated and transmitted immediately:
use std::collections::BTreeMap;
use std::sync::Arc;
use pulsar_rs_sdk::{ControlParam, TelemetryItem};
arm.set_control_callback(Some(Arc::new(|_metadata, telemetry| {
let mut batch = BTreeMap::new();
for (name, values) in telemetry {
if let Some(pos) = values.get(&TelemetryItem::Position) {
batch.insert(name, BTreeMap::from([(ControlParam::Command, pos.as_f64())]));
}
}
Some(batch)
})))?;

In Rust, cross-thread callbacks require Send + Sync + 'static, so share mutable state across the main thread and callback via Arc<Mutex<_>> or atomics.
Platform control callback
Platform.set_control_callback registers the same callback on every group. Each group still invokes the callback independently on its own domain worker — inspect metadata.group_name to distinguish groups (for example "left_arm" vs "right_arm").
Performance & control-loop best practices
- Keep callbacks short and non-blocking: avoid file I/O, plotting, or sleeping inside control callbacks. Push samples into a bounded queue / ring buffer and log or render on another thread.
- Request only the telemetry items you use: smaller telemetry packets reduce CAN FD bus utilization and allow higher control rates.
- Callback-driven vs. external loop:
- Use
set_control_callbackfor low-jitter closed-loop control synchronized to incoming telemetry (the SDK automatically collects complete group batches and enforces stale-telemetry and deadline watchdogs). - Use separate telemetry callback + timed host loop (calling
set_commands) when your control cadence is driven by an external clock (e.g. a planner, GUI, or simulator loop). Always setcontrol_rate_hzinControlConfigurationto match your actual command rate.
Timeouts and removal
ActuatorGroup enforces two independent host-side watchdogs during active callback control:
telemetry_timeout_s(default0.1 s): triggersSTALE_TELEMETRYif a member stops reporting.controller_timeout_s(default1.0 s, orNoneto disable): triggersCONTROLLER_TIMEOUTif the callback exceeds its deadline.
Removing a callback from another thread waits cleanly for the currently executing invocation to finish. A diagnostic callback cannot replace itself while running (ResourceBusyError).