Simulating the Husarion Panther rover in the ERC Mars Yard using Unity and ROS2.
- Operating System: Ubuntu (with ROS2 installed, humble/jazzy)
- Hardware: A high-core-count CPU and a dedicated NVIDIA GPU is recommended
git clone https://github.com/iitbmartian/erc_unity_project.git
cd erc_unity_projectDownload and Install Unity Hub. Once Unity Hub is installed it should ask you for login and licenses. Register for Unity's student plan and get your free student license. It will then guide you through with activating that license in the Unity Hub.
Once installed:
- Open Unity Hub →
Add→Add project from disk - Select the cloned
erc_unity_projectfolder - Unity will prompt you to install the required editor version
Tip
If you don't see the erc world loaded in unity, then go to Assets/Scenes and double click on ERC WORLD
Build the ros2 ws:
cd erc_ws
colcon build
source install/setup.bashLaunch the TCP server:
ros2 run ros_tcp_endpoint default_server_endpoint --ros-args -p ROS_IP:=127.0.0.1 -p ROS_TCP_PORT:=10000Launch the static TF publisher:
ros2 run unity_sim static_tf_publisherIn Unity:
- Go to
Robotics→ROS Settings - Select
ROS2 - Set
ROS IPto127.0.0.1 - Set
ROS TCP Portto10000 - Start the simulation
Tip
If the Robotics tab is missing or packages are not found, refer to the Unity Packages section to download the required packages.
This simulation includes multiple sensors with data published via ROS2 topics.
- Source: UnitySensors package
- Data Published:
/panther/imu/data- IMU data
- Data Published:
/panther/cx/lslidar_point_cloud- Lidar point cloud
- Data Published:
/panther/camera_front/image_raw- Front camera/panther/camera_back/image_raw- Back camera/panther/camera_left/image_raw- Left camera/panther/camera_right/image_raw- Right camera
- Data Published:
/panther/odometry/filtered - Behavior: Uses Unity’s absolute position and rotation to publish accurate odometry with zero drift
- Toggle: Can be disabled from the
PantherGameObject’s Inspector
- Use WASD keys to drive the rover using Unity
- Also subscribes to
/panther/cmd_vel, so you can use Teleop keyboard or any other interface that publishes TwistStamped msg to/panther/cmd_vel - PID Controller: The rover movement is now controlled using a PID system, making driving via
/panther/cmd_velsmooth and realistic
Movement logic is located in:
Assets/Scripts/CarControl.cs
You can modify this script to customize the robot's control logic.
Once the simulation is running and data is publishing, you should be able to visualize the following in RVIZ2:
/panther/odometry/filtered/panther/cx/lslidar_point_cloud/panther/camera_front/image_raw/panther/camera_back/image_raw/panther/camera_left/image_raw/panther/camera_right/image_raw
- The world contains ArUco markers placed throughout the Mars Yard for testing localization and perception
- Additional interactive objects have been added:
- Mallet
- Cone
- Screwdriver
- These are useful for developing and benchmarking the object detection and identification pipeline
- The simulation is highly optimized to run at a stable frame rate
- All ROS2 topics are published without frame drops
- The topic types and names are exactly the same as the real Husarion Panther rover, ensuring seamless integration with existing pipelines
- ROS-TCP-Connector – for ROS2 communication
- UnitySensors – for IMU and other cool sensors that you can directly integrate if you want
- No data in RViz2: Check if ROS TCP Endpoint is running on correct IP/port, and correct topic is selected. For more help refer to ROS Unity Integration.
- Simulation lagging: Try reducing the frame rate and publishing frequency to ros2

