๐Ÿ•น๏ธ

Phone Controller

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

The PhoneController block turns any smartphone into a wireless 3-axis simulation joystick. When placed on the canvas, it renders a pairing QR code; scanning it with a mobile browser opens an on-screen touch joystick (or tilt controller) along with an independent horizontal yaw slider.

The phone streams normalized control signals across X, Y, and Yaw axes (โˆ’1.0โ‹ฏ+1.0-1.0\dots +1.0) at approximately 30 Hz over a low-latency WebRTC peer-to-peer data channel. Its X and Y ports match the interface of Joystick2D, making it a drop-in wireless replacement for interactive vehicle and robotics demos.

Mathematical Model

The mobile device transmits 3-axis normalized control vectors:

u(tk)=[ux(tk),โ€…โ€Šuy(tk),โ€…โ€Šuyaw(tk)]Tโˆˆ[โˆ’1,1]3\mathbf{u}(t_k) = [u_x(t_k), \; u_y(t_k), \; u_{\text{yaw}}(t_k)]^T \in [-1, 1]^3

A deadband threshold ฮดdead=0.02\delta_{\text{dead}} = 0.02 suppresses resting thumb jitter:

ui(t)={0,โˆฃri(t)โˆฃโ‰คฮดdeadsign(ri(t))โˆฃri(t)โˆฃโˆ’ฮดdead1โˆ’ฮดdead,โˆฃri(t)โˆฃ>ฮดdeadu_i(t) = \begin{cases} 0, & |r_i(t)| \le \delta_{\text{dead}} \\[6pt] \text{sign}(r_i(t)) \dfrac{|r_i(t)| - \delta_{\text{dead}}}{1 - \delta_{\text{dead}}}, & |r_i(t)| > \delta_{\text{dead}} \end{cases}

Signals are reconstructed continuously across simulation solver steps with playout buffer latency ฯ„playout=playoutDelayโ‹…10โˆ’3\tau_{\text{playout}} = \text{playoutDelay} \cdot 10^{-3} s:

yi(t)=interp({(tk,ui,k)},โ€…โ€Štโˆ’ฯ„playout)y_i(t) = \text{interp}\left( \{(t_k, u_{i,k})\}, \; t - \tau_{\text{playout}} \right)

Inputs & Outputs

Direction ID Label Type Status
← Out x X number Output
← Out y Y number Output
← Out yaw Yaw number Output

Parameters

Parameters Label Type Default Description
playoutDelay Playout Delay (ms) number 80 Network jitter buffer. Lower = more responsive control, higher = smoother signal on flaky connections.
interpolation Interpolation select linear How to reconstruct the control signal between received joystick packets.
outputLabels Output Labels vector x,y,yaw

Usage Examples

Example 1: Wireless Quadcopter Attitude Flight Control

Steering a simulated drone flight model. Connecting x to a roll angle setpoint, y to a pitch setpoint, and yaw to heading rate, feeding through attitude PIDs to a Gimbal3D visualization sink. The drone responds directly to thumb movements on the phone.

Example 2: Mobile Tilt Steering for Mobile Robotics

Controlling a differential-drive ground robot. Enabling the phone's tilt mode maps device orientation into left/right steering and forward/reverse speed commands, allowing intuitive physical vehicle navigation.

Remarks & Best Practices

  • Three Independent Control Axes: Exposes X (left/right, โˆ’1โ‹ฏ+1-1\dots +1), Y (backward/forward, โˆ’1โ‹ฏ+1-1\dots +1), and Yaw (horizontal slider, โˆ’1โ‹ฏ+1-1\dots +1) on three dedicated output ports.
  • Zero-Install WebRTC Pairing: Operates directly in standard mobile browsers without requiring native mobile app installations.
  • Dual Touch and Tilt Modes: The phone interface toggles seamlessly between touch thumbpad and device accelerometer tilt steering.
  • Hardware Simulation Gating: In hardware-in-the-loop templates, simulation execution is gated until the phone establishes a WebRTC connection.

Related Components

  • Joystick2D: On-canvas mouse-driven 2D joystick.
  • RemoteSensor: Ingests raw phone accelerometer, gyroscope, and orientation sensors.
  • Gimbal3D: Real-time 3D flight attitude visualization sink.
  • Slider: Single-axis continuous variable input.