ƒ

Connected Phone

Connectivity
Run the live example Free · no sign-up · runs in your browser

The RemoteSensor block is a hardware-in-the-loop (HIL) source that streams real-time 6-DOF inertial measurement unit (IMU) telemetry from a paired smartphone into the BlockWerk simulation canvas over a WebRTC peer-to-peer data channel.

Placing the block renders a QR code on the canvas. Scanning the code with a smartphone camera establishes a direct low-latency connection, streaming 3-axis linear acceleration (m/s2\text{m/s}^2), 3-axis rotational orientation (degrees), and playout buffer health metrics directly into simulation blocks.

Mathematical Model

The paired mobile device streams 3-axis linear acceleration and 3-axis Euler orientation angles:

a(tk)=[ax(tk),  ay(tk),  az(tk)]T∈R3(m/s2)θ(tk)=[α(tk),  β(tk),  γ(tk)]T∈[0,360)×[−180,180]×[−90,90](deg)\begin{aligned} \mathbf{a}(t_k) &= [a_x(t_k), \; a_y(t_k), \; a_z(t_k)]^T \in \mathbb{R}^3 \quad (\text{m/s}^2) \\ \boldsymbol{\theta}(t_k) &= [\alpha(t_k), \; \beta(t_k), \; \gamma(t_k)]^T \in [0, 360) \times [-180, 180] \times [-90, 90] \quad (\text{deg}) \end{aligned}

Signals are reconstructed continuously across solver steps with playout buffer latency τplayout=playoutDelay⋅10−3\tau_{\text{playout}} = \text{playoutDelay} \cdot 10^{-3} s:

yj(t)=interp({(tk,sj,k)},  t−τplayout)y_j(t) = \text{interp}\left( \{(t_k, s_{j,k})\}, \; t - \tau_{\text{playout}} \right)

The buffer health output indicates instantaneous lookahead buffer depth:

bufferLevel(t)=max⁡(0,  tlatest_packet−(t−τplayout))\text{bufferLevel}(t) = \max\left(0, \; t_{\text{latest\_packet}} - (t - \tau_{\text{playout}})\right)

Inputs & Outputs

Direction ID Label Type Status
← Out accelX Accel X number Output
← Out accelY Accel Y number Output
← Out accelZ Accel Z number Output
← Out gyroAlpha Rotation Alpha number Output
← Out gyroBeta Tilt Beta number Output
← Out gyroGamma Tilt Gamma number Output
← Out bufferLevel Buffer (ms) number Output

Parameters

Parameters Label Type Default Description
playoutDelay Playout Delay (ms) number 250
interpolation Interpolation select linear How to reconstruct signal values between received sensor packets. Linear is the best default. PCHIP is smoother but heavier.
outputLabels Output Labels vector accelX,accelY,accelZ,gyroAlpha,gyroBeta,gyroGamma,bufferLevel

Usage Examples

Example 1: Hardware-in-the-Loop Inverted Pendulum Balancing

Mounting a smartphone to an inverted pendulum cart. The phone's live tilt angle (gyroBeta) is ingested by RemoteSensor and routed into a state-feedback LQR controller to balance the physical cart in real time.

Example 2: 6-DOF Inertial Motion Analysis and Vibration Logging

Measuring hand tremor or physical structural vibration by streaming 3-axis accelerations (accelX, accelY, accelZ) into uPlotDisplay and FFTScope blocks to compute spectral frequency peaks.

Remarks & Best Practices

  • Peer-to-Peer WebRTC: Connects directly between smartphone and desktop browser using WebRTC DataChannels, eliminating cloud server latency after initial signaling.
  • Dynamic Port Generation: Automatically reveals additional output ports when connected phones report magnetometer, barometer, or GPS hardware.
  • Buffer Health Monitoring: The bufferLevel output provides a continuous readout of buffer health in milliseconds to detect wireless link degradation.
  • Raw Telemetry CSV Export: Clicking the record button on the block face captures raw packet telemetry (timestamps, jitter, all axes) and exports the data to CSV.

Related Components

  • PhoneController: Mobile controller featuring touch/tilt joystick and yaw slider.
  • MQTTSubscriber: Ingests sensor telemetry over an MQTT network broker.
  • Gimbal3D: Real-time 3D flight attitude visualizer.
  • uPlotDisplay: Multi-channel oscilloscope for live waveform display.