contact@blackcoffeerobotics.com
14, Raghava Enclave, Transport Road, Secunderabad, Hyderabad (500009)
©2024 All Rights Reserved by BlackCoffeeRobotics
In an earlier blog post, I talked about the usage of simulations for robotics application development. While my focus was on ground vehicles, the general principle of using simulation for ease of development and testing applies to all robotic systems. In this article, I’ll dive into what a gaming engine such as Unity can offer towards the development of robot software and the state of the art with regards to using Unity alongside ROS/ROS2.
Most (if not all) autonomous robots today use visual information in some way shape or form — SLAM, Odometry, object identification, lane detection, and the list goes on. Unfortunately, several de-facto simulators such as Gazebo fail to provide any meaningful photo-realism for the development and testing of vision-based algorithms.
Unity-3D has been one of the two (other being Unreal Engine) go-to gaming engines used extensively by developers for over a decade. This means there is a huge library of rich assets, documentation, and user community to benefit from. In the context of simulating robots, this involves everything modeling the robot design through articulate bodies, setting up several types of joints, physics parameters like friction, colors, and lighting, modeling moving obstacles, and a huge arsenal of objects to model the environment, and the list goes on.
Alright, now that we have a use case for using Unity for robot simulations, there arises an obvious question — how? Like many other things, there is no single correct answer. Multiple open-source packages integrate Unity with ROS/robotics in different ways. ros2-for-unity for example does a really good job of facilitating communication in a native ROS2 manner, ZeroSimROSUnity provides a rich arsenal of resources and ROS communication but we found ourselves constrained while using that to develop new modules per our use case. Therefore, for now, we will be checking out the release from the horse’s mouth — the official Unity release for ROS integration. Let’s dive in!
ROS-TCP-Connector (Connector) is the official Unity-ROS interface, developed and maintained by Unity-Technologies themselves. Fundamentally it solves the communication problem between the Unity world and ROS world using TCP sockets. The setup only involves two steps —
The setup works out of the box without much change in configuration, the Github documentation covers it well. This setup allows you the ability to write ROS publishers/subscribers with standard and custom messages across the Unity-ROS world. Unity Robotics Hub also provides some other useful and complimentary packages, let’s check them out —
In addition to solving the paramount problem of Unity-ROS communication, I found the URDF importer to be pretty useful in terms of getting robot visuals, collisions, and link connections seamlessly into Unity-land. Scripts are useful in terms of showing some direction concerning more serious application development using these packages. There are still several questions and challenges to overcome to use the system with your ROS system, namely —
Gaming engines have a lot to offer to robotics, not least of all realistic scene rendering. However, using Unity to simulate your robotics stack would take some development, knowledge of C# (which unlike c++/python is not exactly the primary language of ROS developers), and an understanding of core Unity concepts.
As time goes by, we expect camera based algorithms and applications to be all the more prevalent in autonomous robot navigation. At Black Coffee Robotics, we have been actively addressing these issues in an attempt to make the transition from simulators like Gazebo to Unity for vision/AI-heavy applications. Here’s a little demo of a robot fleet carrying out intra-logistic operations in a warehouse setting!
If you’re looking to leverage some photo-realism and compute optimizations for your development, testing, and even demos, reach out to us!