Tafy Studio Teleoperation Guide
This guide covers the teleoperation (remote control) capabilities of Tafy Studio RDOS.
Overview
Tafy Studio provides multiple methods for controlling robots remotely:
- Gamepad/Controller - Physical game controllers (Xbox, PlayStation, etc.)
- Virtual Joystick - On-screen touch/mouse control
- Keyboard - WASD or arrow key control
All control methods output standardized differential drive commands that work with any robot using the Tafy HAL.
Control Methods
Gamepad Control
The gamepad node supports standard game controllers using the browser's Gamepad API.
Features:
- Auto-detection of connected controllers
- Configurable deadzone for analog sticks
- Multiple output modes (differential drive, normalized, raw)
- Support for up to 4 controllers
- Button mapping for common actions
Standard Layout:
Left Stick Y: Forward/Backward
Left Stick X: Turn Left/Right
Right Trigger: Boost
A Button: Action 1
B Button: Action 2
Virtual Joystick
The on-screen joystick provides touch and mouse control for devices without physical controllers.
Features:
- Responsive touch controls
- Visual feedback
- Auto-centering option
- Adjustable size
- Deadzone visualization
Keyboard Control
Keyboard input provides quick control using standard key layouts.
WASD Layout:
- W: Forward
- S: Backward
- A: Turn Left
- D: Turn Right
- Shift: Boost (2x speed)
- Space: Emergency Stop
Arrow Key Layout:
- ↑: Forward
- ↓: Backward
- ←: Turn Left
- →: Turn Right
- Shift: Boost
- Space: Emergency Stop
Node-RED Integration
Basic Teleop Flow
[Gamepad Input] → [Motor Command] → [NATS Publish] → Robot
Example Implementation
-
Import the teleop example flow:
cd ~/.node-red
npm install @tafystudio/node-red-contrib-tafy
# Import examples/teleop-control.json -
Configure NATS connection:
- Double-click the NATS config node
- Set URL to your NATS server (default:
nats://localhost:4222) - Add authentication if required
-
Deploy and test:
- Deploy the flow
- Open the dashboard
- Connect a gamepad or use keyboard/joystick
Output Formats
Differential Drive Mode
Standard output for two-wheeled robots:
{
"left": -1.0, // Left wheel speed (-1 to 1)
"right": 0.5, // Right wheel speed (-1 to 1)
"forward": -0.25, // Forward component
"turn": 0.5 // Turn component
}
HAL Motor Command
Commands are wrapped in HAL format for transmission:
{
"hal_major": 1,
"hal_minor": 0,
"schema": "tafylabs/hal/motor/differential/1.0",
"device_id": "robot-main",
"caps": ["motor.differential:v1.0"],
"ts": "2024-03-14T10:30:00.000Z",
"payload": {
"left_speed": -1.0,
"right_speed": 0.5,
"duration_ms": 100
}
}
Configuration Options
Deadzone
Prevents drift from analog stick center position:
- Range: 0.0 to 1.0
- Default: 0.1 (10% of stick range)
- Higher values = larger center dead area
Speed Limiting
Controls maximum output speed:
- Range: 0.0 to 1.0
- Default: 1.0 (full speed)
- Lower values for safer operation
Acceleration
Smooths speed changes:
- Range: 0.0 to 1.0
- Default: 0.1
- 0 = instant speed changes
- Higher = smoother ramping
Advanced Features
Multi-Input Priority
When multiple inputs are active, priority is:
- Emergency stop (always highest)
- Gamepad
- Keyboard
- Virtual joystick
Recording & Playback
Record control sequences for autonomous playback:
- Enable recording in the flow
- Perform control actions
- Save recording to file
- Replay using the playback node
Custom Control Mapping
Define custom control schemes:
{
"forward": "i",
"backward": "k",
"left": "j",
"right": "l",
"boost": "u",
"stop": "space"
}
Safety Considerations
- Timeout Protection - Commands auto-expire after 100ms
- Emergency Stop - Space bar stops all motors immediately
- Connection Monitoring - Auto-stop on connection loss
- Speed Limiting - Configurable maximum speeds
- Deadzone - Prevents accidental movement
Troubleshooting
Gamepad Not Detected
- Ensure gamepad is connected before opening browser
- Press any button to activate
- Check browser console for errors
- Try different USB port
High Latency
- Check network connection to robot
- Reduce command frequency if needed
- Use wired connection when possible
- Monitor NATS message queue
Erratic Movement
- Increase deadzone setting
- Check for electromagnetic interference
- Calibrate gamepad in OS settings
- Reduce acceleration for smoother control
API Reference
Gamepad Input Node
Inputs:
msg.payload= "start" | "stop" | true | false
Outputs:
msg.payload= control datamsg.topic= "gamepad/input" | "gamepad/connected" | "gamepad/disconnected"
Keyboard Input Node
Inputs:
msg.payload= "start" | "stop" | true | false
Outputs:
msg.payload= control datamsg.topic= "keyboard/input" | "keyboard/stop"msg.keys= array of pressed keys
Joystick UI Node
Outputs:
msg.payload= position datamsg.topic= "joystick/input"
Best Practices
- Start with low speeds during initial testing
- Implement timeouts in motor controllers
- Add visual feedback for connection status
- Test emergency stops before full operation
- Log commands for debugging
- Use secure connections for remote operation