How-to guides
UI input (a stick or button in the browser)
If the value is given by the user in the browser (remote-control stick, button, key), the Komod declares a UI input:
[Input("ui", FromUi = true, Deadline = "00:00:00.500")]
public required IInput<DriveCommand> Ui { get; init; }
The UI sends the value to the server with KomodComponentBase.InjectAsync:
await InjectAsync("ui", new DriveCommand(Steering: 0.2, Throttle: 0.6));
Rules
- A UI input cannot be linked in the graph; the editor does not even draw it.
- Only an Operator (or Admin) can send into it.
- Send continuously (e.g. 20 Hz) and always have a
Deadline: if the browser disappears,OnInputTimeoutputs the Komod into a safe state. - On the server side the UI input is read like any other (
ReadAllAsync,Latest).
Typical pattern
- The UI repeatedly sends the current stick/key value from a timer (or a JS event).
- The Komod's
ExecuteAsyncreads it and passes it on an output (for example aDriveCommand). - When the
Deadlineelapses,OnInputTimeoutpublishes a neutral value (throttle 0).
Periodic sending and keyboard or gamepad handling is easiest in the Komod's own JS module (UI → JavaScript).