ROS Services
The Bridge node autodetects all available ROS services of all discovered ROS nodes, and the Web UI then provides various tools to call them with custom data payloads. Service calls can be even mapped to keyboard keys, gamepad and touch UI buttons.
In order to be able to call any ROS service, the Bridge node needs to have access to its type definitions. See Custom message & Service types for more info.
The most basic service types (e.g. std_srvs/srv/Empty, std_srvs/srv/Trigger or std_srvs/srv/SetBool) come with pre-defined user interface out of the box to make calling them as simple as possible. For services that take more complex input data, we first need to define the payload.
Implementing Custom Widgets
On top of the above mentioned options, you may want to create a completely unique controls for a ROS service. The best way to do that would be to create a custom service widget, which is then used in the service dropdown menu in a similar fashion to the buttons.
Custom service widgets should be implemented by extending the CustomServiceInput class. See the bridge_ui_extras repo and in particular custom-service-slider-widget.js to get an idea of what a service widget class can look like. Here’s the ServiceInput_ExampleSlider in action:
To register your custom service widgets, use the custom_service_widgets and service_widgets parameters in your phntm_bridge.yaml config file as shown below:
custom_service_widgets: # first, add widget classes to load
- 'ServiceInput_ExampleSlider https://my-domain.com:443/custom-service-slider-widget.js' # class name, space, source file URL to be loaded
service_widgets: # then map services to widget classes
- '/camera/set_ir_exposure ServiceInput_ExampleSlider {"min": 1, "max": 3000, "value_read_srv": "/camera/get_ir_exposure"}' # service id, space, class name, space, custom JSON data to pass
- '/camera/set_ir_gain ServiceInput_ExampleSlider {"min": 0, "max": 20000, "value_read_srv": "/camera/get_ir_gain"}'
Note
The services API provides a reliable way of calling ROS services, however, it is not designed with speed nor low latency in mind. All service requests are queued and processed in sequential order by the Bridge node which also waits for every service reply. If no reply arrives withing 10s, you will receive a timeout error. If you need to call a service say several times per second, you should probably use topic messages instead.