Controls

The Controls tab sets what each gamepad button does in TeleOp.

The Controls tab: both gamepads, each button labelled with what it runs, and the chosen button's events on the right.
The Controls tab: both gamepads, each button labelled with what it runs, and the chosen button's events on the right.

Bind a button

  1. Click a button on the Gamepad 1 or Gamepad 2 drawing.
  2. Pick the event to bind (table below).
  3. In the Palette, on the left, pick a command or script, then click Assign (or double-click it).

For anything longer than one command, make a script on the Scripts tab first.

EventStartsStops
PressWhen the button is pressedWhen it ends by itself
ReleaseWhen the button is releasedWhen it ends by itself
HoldWhen the button is pressedWhen it is released
ToggleOn one pressOn the next press, of the same button

Each toggle stops only the run it started: two buttons that toggle the same script don't stop each other, and Problems warns of it. It also warns when the Press, Hold and Toggle of one button need the same subsystem, since they start on the same press and the later one cancels the earlier.

  • Clear unbinds the chosen event.
  • Parameters shows the settings of the command it runs. One that comes from the robot's Defaults reads Use default (3250) until you type a number in its place.
  • Problems lists what is wrong, such as a Press binding that never ends (use Hold or Toggle instead). Click a problem to go to its binding. It shrinks to one line when there is nothing to fix.
  • A bound button is filled in on the drawing, with a note saying what it runs.

Swap the two gamepads

Swap Gamepad 1 and 2, above the drawings, gives each gamepad the other's bindings, for when the drivers change places. It saves at once; click it again to swap back. What your robot code reads (see below) and the simulator's keys stay where they are: the code reads the same gamepads whoever holds them, and the keys belong to the keyboard.

Triggers and sticks

  • A trigger counts as pressed once you pull it past 0.1 (0 is let go, 1 is all the way), so one that rests a little above zero isn't held down. Once pressed it stays pressed until it falls to half that. Hover over a trigger on the drawing to see its threshold. To give a trigger its own, from 0.01 to 0.95, add it to controls.json:
    "triggerThresholds": { "gamepad1": { "LEFT_TRIGGER": 0.2 } }

    A value outside that range is refused: Problems says so, the robot reports it, and that trigger keeps 0.1.

  • A command that reads its input also gets how far the trigger is pressed, from 0 to 1. Its palette tooltip says so. On a button it gets 1.
  • A released trigger reads 0, so a trigger's Release can't run anything that reads its input.
  • Sticks can't be bound.

Say what your robot code reads

Your robot's own code may read some inputs itself, such as the sticks to drive or a trigger for turbo. Robot Designer doesn't guess which; you tell it:

  1. Click the stick or control on the drawing.
  2. Type what the code uses it for in Robot code reads it for, such as Drive or Turbo. Leave it blank if the code doesn't read it.

The word shows under the stick, or beside the trigger. A binding on a control your code reads runs alongside it, and Problems notes that. It is saved in controls.json under driveUses; the robot ignores it.

Give a control a keyboard key

With no controller plugged in, the keyboard drives the simulated robot from the Live Robot tab. Each control, and each way of each stick, has a key: W A S D for the left stick, Space for A, and so on (see Live Robot, "Drive with the keyboard").

  1. Click the control or stick on the drawing.
  2. Under Keyboard (simulator), click the key's button, then press the new key. Escape keeps the old one, and × takes the key away.

A key stands for one thing: giving it to another control takes it from the one that had it. The keys are saved in controls.json under keyboard; the robot ignores them.

A TeleOp's own set

A TeleOp can have bindings of its own, chosen on the TeleOp tab. The Bindings list at the top of this tab picks what you edit: Robot controls, or a TeleOp's set. A set replaces controls.json for that TeleOp, so it holds everything that TeleOp needs.

With a set chosen, two buttons appear:

  • Copy from robot controls replaces the set with a copy of controls.json.
  • Clear removes every binding from the set.

Each asks once, in the row above the gamepads, before it changes anything. Undo and Redo (Ctrl+Z, Ctrl+Shift+Z) step through the changes made since you chose the bindings.

Where bindings are saved

  • Each robot has its own bindings. The tab shows the active robot's: the one in the Robot list at the bottom right of the window.
  • They are saved in controls.json in that robot's folder (<TeamCode>/robot_designs/<robot>/). Every edit saves at once.
  • If the file was changed somewhere else (an editor, say), the tab reloads it instead of saving over it, and tells you. Make your edit again.
  • Sync copies it to /sdcard/Controls/controls.json on the robot, and each TeleOp's set (controls_<TeleOp>.json) beside it.

If the project keeps controls.json in autons/Controls, a note at the top asks you to move it. Until then the tab is read-only and Sync skips it. Click Move it, then commit the move.