Input Controller Component
The input controller API provides an API for configuring callbacks for events, allowing you to configure input devices to control your machines.
If you have a keyboard, mouse, elevator button panel, light power switch, joystick, gamepad, or video game controllers with which you want to control a robotic base, use an input controller component.
This component supports devices like gamepads and joysticks that contain one or more Control
s representing the individual axes and buttons on the device.
To use the controller’s inputs, you must register callback functions to the Control
s with the input
API.
The callback functions can then handle the Events that are sent when the Control
is activated or moved.
For example, when a specific button is pushed, the callback function registered to it can move another component, or print a specific output.
The base remote control service implements an input controller as a remote control for a base.
Configuration
To use an input controller to control your machine’s actions, you need to add it to your machine’s configuration.
Go to your machine’s CONFIGURE page, and add a model that supports your input controller.
The following list shows the available input controller models. For additional configuration information, click on the model name:
Add support for other models
If none of the existing models fit your use case, you can create a modular resource to add support for it.
Support Notice
There is currently no support for this component in viam-micro-server
.
API
The input controller API supports the following methods:
Method Name | Description |
---|---|
GetControls | Get a list of the Controls that your controller provides. |
GetEvents | This method returns the current state of the controller as a map of Event Objects, representing the most recent event that has occurred on each available Control. |
TriggerEvent | Directly send an Event Object from external code. |
GetGeometries | Get all the geometries associated with the input controller in its current configuration, in the frame of the input controller. |
RegisterControlCallback | Defines a callback function to execute whenever one of the EventTypes selected occurs on the given Control. |
Reconfigure | Reconfigure this resource. |
GetResourceName | Get the ResourceName for this input controller with the given name. |
Close | Safely shut down the resource and prevent further use. |
Troubleshooting
If your input controller is not working as expected, follow these steps:
- Check your machine logs on the LOGS tab to check for errors.
- Review your input controller model’s documentation to ensure you have configured all required attributes.
- Click on the TEST panel on the CONFIGURE or CONTROL tab and test if you can use the input controller there.
If none of these steps work, reach out to us on the Community Discord and we will be happy to help.
Next steps
For general configuration, development, and usage info, see:
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!