If we want to interact with the ROS framework from our web browser, there should be some system that can convert the web browser commands to the ROS topics/services. rosbridge provides a JSON interface to ROS, allowing any client to send JSON commands (http://www.json.org/) to publish or subscribe to ROS topics, call ROS services, and more. rosbridge supports a variety of transport layers, including WebSockets (https://en.wikipedia.org/wiki/WebSocket) and TCP.
The rosbridge_suite (http://wiki.ros.org/rosbridge_suite) is a meta-ROS package having an implementation of the rosbridge protocol. The JSON commands are converted to ROS topics/services using a node called rosbridge_server. This node can send or receive JSON commands from web browsers to ROS over web sockets. The rosbridge_server is the intermediate layer between the ROS system and web browser. The complete description of the rosbridge and rosbridge_suit can be found at https://github.com/RobotWebTools/rosbridge_suite.
The following figure shows how the communication between the rosbridge server and web browser happens:
The rosbridge server can communicate with the ROS nodes. It can be a robot controller or ROS nodes. The rosbridge can also receive data from ROS which can send to web browser.
The rosbridge_suite collection consists of three packages:
- rosbridge_library: This package contains Python APIs to convert JSON messages to ROS messages and vice versa.
- rosbridge_server: This package has the WebSocket implementation of the rosbridge library. We have to start this tool for communicating with the web browser.
- rosapi: This provides service calls to fetch meta-information from ROS, such as a list of ROS topics and ROS parameters.
In the web browser, we can see rosbridge client. A rosbridge client is a program that communicates with rosbridge using its JSON API. In the preceding figure, we are using roslibjs as the client. Let's understand the main capabilities of these clients.