Skip to content

User_App_ROS_UnitySimulationExample

Suzannah Smith edited this page Sep 28, 2018 · 10 revisions

2.4 Unity Simulation Example

Note: This tutorial assumes that you have completed tutorials:

Overview

This application of ROS# illustrates the communication between Unity and ROS in which the real time simulation takes place in Unity. The following figure illustrates the general schema of the application.

General Picture

The control signals are sent from ROS to Unity. Consequently, the outcomes of Unity are captured by ROS to illustrate them using rviz as an example.

  • Messages to be subscribed by Unity using ROS#:

  • /sensor_msgs/joy

  • Topics to be published by Unity using ROS#:

  • /odom

  • /joint_states

  • /unity_image/compressed

The movement of the mouse cursor in Ubuntu is used to control the TurtleBot2 in Unity. Therefore, the ROS node mouse_to_joy.py maps the movement of the mouse cursor to messages of the type sensor_msgs/joy. These are sent to the rosbridge_websocket to be captured by Unity.

In Unity the robot will move according to the captured movement of the mouse cursor in Ubuntu and the topics /odom, /joint_states and /unity_image/compressed are published for further processing using ROS#.

Preparation

Setting up the Unity scene

Execution

  • Run the following command in your terminal:
$ roslaunch unity_simulation_scene unity_simulation_scene.launch

This will launch rosbridge_websocket, file_server, mouse_to_joy and rqt_graph.

As soon as all ROS nodes are launched, the robot in Unity is ready to move.

  • When the Play button in pressed and the mouse cursor in Ubuntu is moved the TurtleBot2 will move in Unity.
  • After clicking the refresh button in the rqt_graph, a network similar to the following figure appears: rqt_graph
    Above you can see that the topic/joy is published by the ROS node mouse_to_joy and sent to Unity using rosbridge_websocket. playbutton

The topics /odom, /joint_states and /unity_image/compressed are published by Unity using ROS# for further processing. This and the whole process of preparation and execution is demonstrated in the video mentioned above.


© Siemens AG, 2017-2018 Author: Verena Röhrl (verena.roehrl@siemens.com)

Clone this wiki locally