Unity-ROS Communication

Communication between Unity and ROS is achieved by utilizing a Rosbridge websocket connection. Note that Rosbridge provides a JSON API to ROS functionality for non-ROS programs. This is the reason why handling of JSON messages is a critical component of Unity-ROS development.

There are a couple of key resources that must be understood and utilized for successful Unity-ROS communications.

1.) Rosbridge Protocol.

Please see the following page for the Rosbridge Version 2.0 Potocol Specification: https://github.com/RobotWebTools/rosbridge_suite/blob/groovy-devel/ROSBRIDGE_PROTOCOL.md

This protocol specification breaks down what the various rosbridge message types are and how they should be handled for successful communication.

2.) ROSBridgeLib

*This is the most important tool we have used in our GCS development (as E2SH) for the data pipeline between ROS and Unity.

Please see the following git repository for a very helpful Unity-Ros communications library.

https://github.com/MathiasCiarlo/ROSBridgeLib

There are instructions in the documentation on the github page for setting up a websocket connection with ROSBridge, publishing messages and subscribing to messages. These operations are the key operations that need to be accomplished when using ROSBridge with Unity.

ROSBridgeLib utilizes websocket-sharp to handle websocket connections and SimpleJSON to handle JSON messages. The library provides several types of ros messages as well as a method to publish and subscribe to ROS nodes from within Unity C# scripts.

This is an extremely helpful tool, but it is worth noting that not all message types needed for the development process are available. However, the library is easily extendable and custom messages and subscriber classes can be written to extend the library to fit our needs. To accomplish this, simply refer to the library and follow the structure and conventions as necessary to build the new message that is needed.

Here is an example of a project that utilizes ROSBridgeLib with turtlesim.

https://github.com/michaeljenkin/unityros

This is a handy project which can be used as a helpful reference when getting started with the library.

results matching ""

    No results matching ""