Controller Widget
Widget Type: rc-controller
The controller also supports a keyboard WASD
mode when enabled.
Configuration
The keys mapped are as follows:
Key | Command |
---|---|
W | Forward |
A | Turn Left |
S | Backward |
D | Turn Right |
Q | Strafe Left |
E | Strafe Right |
The controller can be configured in two modes: static and dynamic. In static mode, you map keys to specific commands. In dynamic mode, a single command is used, and values are dynamically passed based on key presses.
To map keys to a specific service, create your move
command and define the three parameters (vx
, vy
, slew
) that will be provided by the widget. Then, map them to a service call with the payload. In your payload, pass the template values, for example: "x": ${$params.vx}
.
Dynamic Mode
commandId The command to send when a key is pressed.
interval how often to send the command in milliseconds when the key is held down. Defaults to 100.
useStrafe This will enable strafe keys.
parameters.vxSpeed The forward/backward speed. Will send vxSpeed * 1 for forward, and vxSpeed * -1 for backward.
parameters.vySpeed The left/right speed. Will send vySpeed * 1 for left, and vySpeed * -1 for right.
parameters.slewSpeed The rotation speed. Will send slewSpeed * 1 for right, and slewSpeed * -1 for left.
If the vxSpeed set to 0.5 and vySpeed set to 1 then pushing up and strafe right will send:
{ vx: 0.5, vy: -1, slew: 0 }
stop.commandId (optional) The command to send when a key is released.
JSON Configuration example:
{
"elementName": "rc-controller",
"config": {
"interval": 100,
"useStrafe": true,
"commandId": "move",
"parameters": {
"vxSpeed": 0.5,
"vySpeed": 0.5,
"slewSpeed": 0.35
},
"stop": {
"commandId": "move",
"parameters": {
"vxSpeed": 0,
"vySpeed": 0,
"slew": 0
}
}
}
}
Static Mode
Available Keys
strafeLeft
, turnLeft
, forward
, backward
, turnRight
, and strafeRight
commandId The command to send when the key is pressed.
parameters The parameters to send with the command.
interval How often to execute the command when the key is held down.
JSON Configuration example:
{
"strafeLeft": {
"commandId": "move",
"parameters": {
"vx": "0",
"vy": "0.5",
"slew": "0"
},
"interval": 1000
},
"turnLeft": {
"commandId": "move",
"parameters": {
"vx": "0",
"vy": "0",
"slew": "0.25"
},
"interval": 1000
},
"forward": {
"commandId": "move",
"parameters": {
"vx": "0.5",
"vy": "0",
"slew": "0"
},
"interval": 1000
},
"backward": {
"commandId": "move",
"parameters": {
"vx": "-0.5",
"vy": "0",
"slew": "0"
},
"interval": 1000
},
"turnRight": {
"commandId": "move",
"parameters": {
"vx": "0",
"vy": "0",
"slew": "-0.25"
},
"interval": 1000
},
"strafeRight": {
"commandId": "move",
"parameters": {
"vx": "0",
"vy": "-0.5",
"slew": "0"
},
"interval": 1000
}
}