Getting Started
A Python SDK to drive Hapbeat over Wi-Fi UDP. For research (PsychoPy / Jupyter / ROS), media art, and prototyping. It separates the fire side (when / where to play) from the tuning side (what / how to play), linking them only by event id.
Install
Section titled “Install”pip install hapbeat-python-sdk # library + CLIpipx install hapbeat-python-sdk # CLI / launchpad only, in an isolated environment
pipxis for installing the CLI (hapbeat scan/launchpad, etc.) in an isolated environment. Toimport hapbeatfrom your own scripts, usepip installinside a venv.
Your first event
Section titled “Your first event”import hapbeat
hb = hapbeat.connect(app_name="MyApp")hb.play("sample-kit.sine_100hz", gain=0.5)hb.close()connect()opens a UDP broadcast socket and sends a keep-alive so the app name appears on the device OLED.play(event_id, gain)sends a play instruction.gainis 0..1; if omitted, the EventMap described below supplies the default (the kit’s intensity).
"sample-kit.sine_100hz" must be an event id present in the kit deployed to the
device (flashed via Hapbeat Studio). The SDK
sends only the instruction; the waveform lives in the kit on the device
(command mode; for the separate clip mode, see
Choosing between command and clip).
Find devices
Section titled “Find devices”with hapbeat.connect() as hb: for d in hb.discover(timeout=1.5): print(d.ip, d.address, d.firmware_version)Separating the fire side from the tuning side (EventMap)
Section titled “Separating the fire side from the tuning side (EventMap)”Instead of writing “haptic tuning values” such as intensity into your firing code,
collect them in a haptic file (kit manifest = EventMap). play("id") resolves
the defaults from there.
em = hapbeat.EventMap.from_manifest("kits/my-kit/my-kit-manifest.json")with hapbeat.connect(event_map=em) as hb: hb.play("sample-kit.sine_100hz") # fires at the kit manifest's intensityThis lets you swap “when to play (code)” and “how strong (kit)” independently. For details, see EventMap Reference.
Specify a target
Section titled “Specify a target”hb.play("sample-kit.sine_100hz", target="player_1/chest") # one devicehb.play("sample-kit.sine_100hz", target="*/chest") # all chest deviceshb.play("sample-kit.sine_100hz") # broadcast to allHand it to an AI coding agent
Section titled “Hand it to an AI coding agent”To have Claude / Cursor / Copilot, etc. use this SDK, hand it the AGENTS.md
bundled with the SDK. It packs the specification, usage, and pitfalls into a
single file — enough on its own to grasp the whole picture.
- Location:
AGENTS.mdat the root of the SDK repository - Example of what to hand over (paste as-is to the agent):
Use the Hapbeat Python SDK. Read AGENTS.md and follow its specification and best practices.What to read next
Section titled “What to read next”- Choosing between command and clip — Choosing between command and clip
- Project structure — Laying out the kit and haptic file in your project
- Navigating the Examples — A walkthrough of the runnable samples
hapbeat --help— CLI (scan/play/stop-all/osc-bridge/launchpad)