-
Notifications
You must be signed in to change notification settings - Fork 366
User_App_ROS_UnitySimulationExample
2.4 Unity Simulation Example
Note: This tutorial assumes that you have completed tutorials:
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.
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.
-
/sensor_msgs/joy
-
/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#.
Setting up the Unity scene
- Compose the Unity scene
UnitySimulationScene
by following this video. - You can use Assets/RosSharp/Scenes/UnitySimulationScene.unity for reference. Please note that meshes and textures of the robot are not included in this Unity project. Instead please import them yourself as described in Section 2.1.
- 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:
Above you can see that the topic/joy
is published by the ROS nodemouse_to_joy
and sent to Unity usingrosbridge_websocket
.
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.
Next tutorial: 3. Application examples without ROS communication
© Siemens AG, 2017-2018 Author: Verena Röhrl (verena.roehrl@siemens.com)
1. Installation and Configuration
1.1 Unity on Windows
1.2 Ubuntu on Oracle VM
1.3 ROS on Ubuntu
1.4 Gazebo Setup on VM
1.5 TurtleBot2
1.6 Shadow Hand
1.7 Gazebo Simulation Example Setup
1.8 Unity Simulation Example Setup
2. Application examples with ROS communication
2.1 Transfer a URDF from ROS to Unity
2.2 Transfer a URDF from Unity to ROS
2.3 Gazebo Simulation Example
2.4 Unity Simulation Example
2.5 Fibonacci Action Client
2.6 Fibonacci Action Server
3. Application examples without ROS communication
3.1 Import a URDF on Windows
3.2 Create, Modify and Export a URDF Model
3.3 Animate a Robot Model in Unity
ROS-Unity Coordinate System Conversions
How to add new Message Types
RosBridgeClient Protocols
RosBridgeClient Serializers
Message Handling Code Map
Action Server State Machine Model
License Headers