Skip to content

ROSBridge Library

rajat edited this page Oct 5, 2021 · 1 revision

ROSBridge Libray

Two ROSBridge libraries are used in this project. One on the unity side and the other one on the ROS side. Both of them are named the same. For the sake of simplicity, we will use RosBridgeUnity and RosBridgeRos to denote the library of Unity and ROS, respectively.

What is RosBridge Library in general?

The documentation of the rosbridge_suite (i.e., RosBridgeRos) states, "rosbridge provides a JSON interface to ROS, allowing any client to send JSON to publish or subscribe to ROS topics, call ROS services, and more. rosbridge supports a variety of transport layers, including WebSockets and TCP."

In simpler terms, you can send data over a socket to and receive data from ROS using this library. We send data, including parameters, control inputs, or video feed, between Unity3D and ROS, enabling Unity to simulate an actual hardware. This allows to test the algorithms using the data sent over the socket.

The RosBridgeUnity is a C# based library that serves as the other end of this exchange. It was forked from @MathiasCiarlo and @michaeljenkin. It comes with some primitive scripts to get the connection running, and the user can then use them as a base for their own project. You can find the original repository here: https://github.com/MathiasCiarlo/ROSBridgeLib .

More details on ROsBridgeROS can be found on the 'ROS 1 and ROS 2' page of the wiki. This section will focus on ROsBridgeUnity.

This project uses RosBridgeUnity to send video feeds, depth feed, and vehicle parameters from Unity to ROS and receives control commands from ROS. The setup includes using the 'RosInitializer' script to input the target IP address and call all the subscriber and publisher scripts in Unity. RosInitializer.cs also projects the camera feed to 2D textures to be transferred to ROS as a compressed image.

To use RosBridgeUnity in your Unity project, copy the RosBridgeLib folder to your Assets folder along with the 'RosBFolder' in the scripts folder, which contains the required scripts to launch your connection.

Clone this wiki locally