Skip to content

hardik01shah/Unity-ROS-Basic-Simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

Unity-ROS-Basic-Simulation

Setting up the Unity Game Engine as a robotics simulator using Robot Operating System(ROS) and ROS#.

Overview:

The Unity Game Engine is the world's most popular development platform for creating 2D and 3D multiplatform games.
The platform is known for the highly accurate PhysX Engine and also the great user interface.
These advantages can be used for setting up complex simulation environments fo robots. Robots can be extensively tested on a platform like Unity. In this repository a simulation platform for robots was developed on the Unity Game Engine and essential features of a simulation environment were incorporated into the framework. A complete end to end framework of ROS and Unity was set-up to achieve this task.

Goal:

This project sets up the motion of a simple differential drive robot in Unity and is controlled from the ROS side using teleoperation.

  1. Installation:
    1. ROS-Melodic
    2. Unity3D
    3. rosbridge webserver
    4. ROS#
  2. Communication between ROS and Unity is set-up using RosBridge webserver(on the ROS side) and Ros#(on the Unity side).
  3. Essential sensor data i.e. the pose of the bot in Unity is communicated to ROS and is published on a topic.
  4. Velocity commands on the cmd_vel topic are subscribed on the Unity side and a control script ensures traversal of the bot with accordance to the subscribed commands.

Installation and Requirements:

The set-up was done on a Ubuntu 18.04 system.
ROS-melodic and Unity 2019.4.7 version were used.

Rosbridge webserver installation:

Rosbridge server facilitates communication on the ROS side. Simply using sudo-apt

sudo apt-get install ros-<rosdistro>-rosbridge-server

For tutorials: http://wiki.ros.org/rosbridge_suite

ROS# installation:

ROS# are a set of tools that facilitate communication on the Unity side.
ROS# can be installed using the Unity Asset Store in the Unity Project itself (Window->Asset Store) or by cloning the ROS# repository in the Assets folder of the unity project.

git clone https://github.com/siemens/ros-sharp.git

ROS-UNITY setup:

The commmunication is setup by launching rosbridge server.

roslaunch rosbridge_server rosbridge_websocket.launch

Pose conversation:

The Pose_Stamped_Publisher script of ROS# is used to send pose of the bot to ROS. The script is simply attached to the gameObject(The robot here) and some minor settings in the inspector and the script facilitates sending of pose to ROS.

Velocity conversation:

The velocity commands are accepted from the user using the turtlebot3 teleoperation package.

export TURTLEBOT3_MODEL=waffle_pi
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch

On the Unity side, Twist_Subscriber script of the ROS# package subscribes to the incoming Twist messages on cmd_vel. A control script written in C# (updown.cs) makes sure that the velocity commands recieved are converted to motion.

Simulations:

Below are screen captures for the simulation. A similar simulation is also done in gazebo to point out that Unity has equal or maybe more capabilties than Gazebo for robot simulations.

Unity Simulation:

Unity_SIm.mp4

The rqt_graph for the same:
rosgraph_unity

Gazebo Simulation:

Gazebo_sim.mp4

The rqt_graph for the same:
rosgraph_gazebo

Files:

UnityROS is the complete Unity Project.

Releases

No releases published

Packages

No packages published

Languages