Skip to main content
Version: 3.5.x

Tutorials

Each tutorial is a standalone program that demonstrates one capability of the Inverse Service. Three language variants ship side-by-side so you can compare idioms and pick the stack that fits your project:

  • Python — the shortest, easiest entry point (websockets + json)
  • C++ (nlohmann/json) — portable C++11, runtime-parsed JSON
  • C++ (Glaze) — modern C++20 with compile-time reflection and zero-allocation parsing, recommended for real-time haptic loops

Source code is published in two public sample repositories:

Each release of the Inverse Service pins a matching tag on both repos: follow the release/<version> branch to stay on the version that matches this documentation.

Prerequisites

  • The Inverse Service is running (either via the Haply Hub or the standalone installer) on port 10001.
  • At least one Haply device is detected. The tutorials each target a specific device family — see the table below.
  • Python tutorials: pip install websockets (tutorials 04, 05, 06, 07 additionally need keyboard, which requires elevated privileges on Linux).
  • C++ tutorials: CMake 3.15+ and a C++11 compiler for the nlohmann variants, C++20 for the Glaze (-glz) variants. The sample repo's top-level CMakeLists.txt fetches libhv, nlohmann/json, and glaze via FetchContent — no manual dependency setup.

Tutorial list

#NameDevicesVariantsWhat you'll learn
00Device ListAnyPy · C++ · C++ GlazeHTTP device discovery, session-scoped queries
01Print Inverse3Inverse3Py · C++ · C++ GlazeWebSocket state streaming, zero-force keepalive, first-message handshake
02Print VerseGripWired VGPy · C++ · C++ GlazeOrientation streaming, probe_orientation keepalive, quaternion → Euler
03Print Wireless VGWVGPy · C++ · C++ GlazeButtons, battery, hall sensor
04Hello FloorInverse3Py · C++ · C++ GlazeFirst haptic effect — set_cursor_force penalty spring
05Position ControlInverse3Py · C++ · C++ Glazeset_cursor_position control, random targets (C++) or WASD hold-to-move (Python)
06CombinedInverse3 + WVGPy · C++ · C++ GlazeMulti-device loop, quaternion-to-direction cursor drive
07Basis & MountInverse3Py · C++ · C++ Glazeconfigure.basis, configure.preset, and runtime configure.mount overrides; mutual exclusion between preset and mount
08Remote Config (coming soon)AnyPyRemote device configuration over HTTP; session discovery by profile
10EventsPy · C++ · C++ GlazeEvent stream listener on port 10020, level/name filtering

Tip — benchmark the haptic loop

Tutorial 10 (Events) is designed to be run alongside any other tutorial. With --no-hide-rate enabled, it prints the service's system-rate-report event, which includes the effective device tick rate. Compare the rate across the Python / C++ (nlohmann) / C++ (Glaze) variants of the same tutorial to observe the serialization overhead impact on a ~4 kHz control loop.

# Terminal 1 — pick a tutorial variant
./04-haply-inverse-hello-floor # C++ nlohmann
./04-haply-inverse-hello-floor-glz # C++ Glaze
python 04-haply-inverse-hello-floor.py # Python

# Terminal 2 — watch the rate
./10-haply-inverse-events --no-hide-rate