Unity Simulation Setup

Hello everyone,
IITB Mars Rover Team here

We would like to share the simulation pipeline we have built in Unity that integrates with ROS2, providing a more advanced and flexible simulation environment compared to Gazebo.

Additional features you get using Unity as compared to previous Gazebo Based solutions:

• Photorealistic visuals: Unity provides high-quality rendering (PBR materials, advanced lighting, HDR, shadows, reflections), creating far more realistic environments than Gazebo. This allows for better testing of computer vision, AI/ML algorithms and sensor models with lighting and textures closer to real-world conditions.

• Better performance: Gazebo often struggles with performance in large-scale simulations (e.g., the ERC world mesh file) due to heavy CPU load and limited rendering optimizations. Unity, being GPU-optimized, handles large meshes, complex environments, and high quality textures while providing high frame rate even on mid-range hardware.

• Simpler world building & asset management: Unity’s asset store, and editor make creating, importing, and managing complex worlds much easier compared to Gazebo. Terrain generation, vegetation, obstacles, and environmental details can be added quickly, making the simulation more realistic and easily adaptable for various scenarios.

We have shared this Unity simulation on our GitHub with a complete guide on setting up Unity and running the simulation. You can directly import this project and start using the ROS2 topics for mapping, autonomous navigation and computer vision.

Suggestions and feedback are most welcome.

Thanks
Rishabh
IITB Mars Rover Team

5 Likes

Hi,

Just a friendly reminder that husarion_ugv_ros (and most husarion repos) is licensed under the Apache 2.0 license. If you copy any files from this repository to another repo, please make sure to follow the terms of the Apache 2.0 license.

This includes providing appropriate attribution, and it’s best to add a comment in the file itself or include a note in the NOTICE file of your project.

Hi,

Thanks for the reminder.
Although we haven’t really used anything directly from any of the Husarion repos, we did use the CAD models of Panther available on Husarion’s website. Credits for that have been added in the NOTICE file.

Rishabh
IITB Mars Rover Team

1 Like

Thank you for this outstanding submission. We’ve added points for you, considering the usefulness of such environment for both Challenges (as it was submitted before the Challenge 2 was dropped).

Below you’ll find some extra feedback from one of our experts:

Done well

  • All the key functionalities (/cmd_vel, /imu, /clock, ZED video, depth, point clouds, etc.) are working good. It is a solid simulation, which for sure will be very useful in development.
  • The Mars Yard and Panther models are beautifully imported with full color and detail.
  • The vehicle physics are quite realistic, and the Panther model behaves well on flat terrain.
  • Your custom implementation of the ZED sensors is well made with shaders and the GPU->C#->ROS extraction script. It was a nice touch to do point cloud generation right there in Unity.
  • Excellent reasons for choosing Unity over Gazebo. Particularly the photorealistic visuals will surely be helpful for testing CV.

Suggestions for improvement

Vehicle physics

Currently Panther struggles to climb slopes due to low tire friction:

  • Consider increasing friction stiffness, as well as increasing wheel torque and damping for better traction.
  • Lowering the center of mass should help with stability on slopes. You can do that by unchecking “Automatic Center of Mass” in Panther’s RB.
    If cmd_vel messages stop, it would be safer for the robot to stop after a timeout, instead of continuing to drive indefinitely.
    When using WSAD to control Panther directly in Unity, it’s not possible to press W + A/D together to drive in a curve

ROS integration

These are mostly performance related:

The Unity->ROS image publisher currently doesn’t support image_transport compression. Only image_raw is published, which might hurt performance. A particular problem might occur if that limitation causes you to subscribe raw in deployment, in which scenario ROS might start struggling with bandwidth while the images are being sent over WiFi.
The camera frame rate is capped at 10 FPS even with low resolution, while CPU usage remains low.

  • This may be due to bottlenecks in your image processing pipeline or overhead from C# in Unity or Python in ROS-TCP-Endpoint.
  • Consider offloading large per-pixel loops like point cloud generation and depth rescaling from C# to shaders or C++ code.
  • Regarding ROS-TCP-Endpoint performance issues: ROS-TCP-Endpoint performance issue #172.

Architecture

Currently, Panther’s and ZED’s object hierarchies are defined directly inside of the Mars Yard scene. Turning these into prefabs would aid reusability.
Would be great if the project was a ROS2 package, with a launch file that starts Unity alongside ROS-TCP-Endpoint, which would make it quicker and easier to run the simulation.

1 Like