Quickstart
Physical actuator over direct USB with Pulsar SDK
Control one physical actuator connected directly by USB using either Pulsar Python SDK (3.1.0) or Pulsar Rust SDK (1.1.0).
Prerequisites
- the actuator is securely mounted and powered;
- it is connected directly to the computer by USB;
- its firmware is
2.2.5or newer (see Firmware compatibility); - Linux (
x86_64/aarch64) or Windows (x86_64) with Python 3.10–3.13 or Rust 1.85+.
Read Safety and prerequisites before sending a command.
Install with Pixi
pixi init pulsar-quickstart
cd pulsar-quickstart
pixi workspace channel add --prepend https://prefix.dev/pulsarhri/pulsar-forge
pixi add pulsar-rs-sdk
Then add pulsar-rs-sdk to your project's Cargo.toml (see Install for Linux, Windows, and standalone Cargo archive paths):
Run a short velocity command
On firmware >= 2.2.5, the SDK enables a firmware command freshness watchdog (500 ms default, DampedRelease fallback) on connect. Stream commands periodically at your configured control_rate_hz (recommended for closed-loop hardware), or pass control_rate_hz = 0.0 when sending one-shot commands.
Create quickstart.py:
from time import sleep
from pulsar_sdk import (
ControlConfiguration,
Mode,
PcpOverUsb,
PulsarActuatorReal,
TelemetryItems,
)
usb = PcpOverUsb()
actuator = PulsarActuatorReal(usb, address=0)
with actuator:
actuator.configure(
ControlConfiguration(
mode=Mode.VELOCITY,
telemetry_items=(
TelemetryItems.POSITION,
TelemetryItems.VELOCITY,
),
telemetry_rate_hz=100,
control_rate_hz=50.0, # sizes the firmware watchdog automatically
)
)
actuator.enable()
# Stream at 50 Hz for 2 seconds
for _ in range(100):
actuator.set_command(1.0) # rad/s
sleep(0.02)
print(
actuator.read_telemetry((
TelemetryItems.POSITION,
TelemetryItems.VELOCITY,
))
)
actuator.disable()
Run it:
In src/main.rs:
use std::thread::sleep;
use std::time::Duration;
use pulsar_rs_sdk::{
ControlConfiguration, Mode, PcpOverUsb, PulsarActuatorReal, TelemetryItem,
};
fn main() -> pulsar_rs_sdk::Result<()> {
let usb = PcpOverUsb::new()?;
let actuator = PulsarActuatorReal::on_usb(&usb)?;
actuator.connect()?;
let config = ControlConfiguration::new(
Mode::Velocity,
[TelemetryItem::Position, TelemetryItem::Velocity],
100.0,
)?
.with_control_rate_hz(50.0)?; // sizes the firmware watchdog automatically
actuator.configure(&config)?;
actuator.enable()?;
// Stream at 50 Hz for 2 seconds
for _ in 0..100 {
actuator.set_command(1.0)?; // rad/s
sleep(Duration::from_millis(20));
}
let telem = actuator.read_telemetry(&[
TelemetryItem::Position,
TelemetryItem::Velocity,
])?;
println!(
"pos={:.3} rad, vel={:.3} rad/s",
telem[&TelemetryItem::Position].as_f64(),
telem[&TelemetryItem::Velocity].as_f64(),
);
actuator.disable()?;
actuator.disconnect()?;
Ok(())
}
Run it:
disable() turns drive output off while keeping runtime telemetry available until disconnect(). Always call disable() and disconnect() explicitly (or use a Python with block); if a handle is dropped while in DRIVE_ACTIVE, firmware safety applies the configured error action (default DampedRelease).