Next Article in Journal
Methodology for Automating and Orchestrating Performance Evaluation of Kubernetes Container Network Interfaces
Previous Article in Journal
Navigating Digital Transformation in the UAE: Benefits, Challenges, and Future Directions in the Public Sector
Previous Article in Special Issue
Unraveling the Dynamics of Mental and Visuospatial Workload in Virtual Reality Environments
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Building an Accessible and Flexible Multi-User Robotic Simulation Framework with Unity-MATLAB Bridge

by
Arturo Haces-Garcia
1 and
Weihang Zhu
1,2,3,4,*
1
Department of Electrical and Computer Engineering, University of Houston, Houston, TX 77204, USA
2
Department of Engineering Technology, University of Houston, Houston, TX 77204, USA
3
Department of Mechanical and Aerospace Engineering, University of Houston, Houston, TX 77204, USA
4
Department of Industrial Engineering, University of Houston, Houston, TX 77204, USA
*
Author to whom correspondence should be addressed.
Computers 2024, 13(11), 282; https://doi.org/10.3390/computers13110282
Submission received: 30 August 2024 / Revised: 14 October 2024 / Accepted: 25 October 2024 / Published: 29 October 2024
(This article belongs to the Special Issue Extended or Mixed Reality (AR + VR): Technology and Applications)

Abstract

:
Multi-user collaborative robotic simulation has great potential for applications in industry and education. Unity is a powerful software for simulation and online multi-user experience, which can be enhanced with third-party mathematical analysis and multiplayer servers. Unity can become a much more capable and user-friendly robotic simulation package through integration with other software. These include MATLAB for computations and the Photon Unity Engine (PUN) for online multi-user capabilities. This study developed a flexible robotic simulation framework that can be adapted to different scenarios for industrial and educational applications. Several simulation scenarios were developed to identify the most efficient data communication methods between MATLAB and Unity. TCP/IP, Shared Memory, Firebase, and MQTT, were selected to assess their performance and interaction with data in Unity and MATLAB. Next, an independent PUN application was created. Both components were integrated into the simulator for evaluation and performance optimization. The performance of this simulation framework was assessed through two case studies. The results demonstrated that the integrated framework is viable, efficient, and flexible for robotic simulation and digital twins. Future research will expand the framework by adding diverse functionalities to provide users with a better interface, enhancing its performance, and integrating additional software packages.

1. Introduction

Multi-user collaborative robotic simulation has great potential for industrial and educational applications in Industry 4.0. Current software for robotic simulation do not possess these capabilities, which has had led developers to look for accessible alternatives. Custom robot simulations allow developers to tailor the software to their required strengths and for their target userbase [1]. Game development engines have emerged as popular options for custom robotic simulators because of their photorealistic graphics and physics engines [1]. These are desirable due to their cross-platform development, user-friendly interfaces, availability on most common operating systems, and low cost. Game engines have been used in previous studies for standalone robotic simulation in car manufacturing [2], digital twins [3], and medical robotics [4]. However, they lack the capabilities of standard simulators, such as specialized computations and advanced data analytics. Developers have mitigated these weaknesses by connecting the game engines with external applications [1]. Game engines feature open development engines, making them available at low costs and with fewer restrictions than some pre-built systems.
Unity has emerged as a promising game development engine for standalone simulation [5] and as a visualization tool for external simulators [1]. Unity’s user-friendly interface and usage of C# make it accessible to new developers. These features allow new developers to rapidly prototype and test their simulation scenarios. Unity features the capability to add external software packages, such as MLAgents, Robotics, and URDFImporter, which expand its capabilities for computation and simulation. Beyond these features, Unity appeals to new developers because of its excellent developer and community support for learning and troubleshooting. Unity is made to be an open development platform which gives developers freedom to create custom packages and solutions for problems that may arise. The source code has not been made available by the Unity company, but, in its current state, it supports several ways for developers to integrate their custom solutions for their problems. This type of environment is promising to developers due to the freedom it offers when customizing simulation environments.
Unity can independently execute simple simulation scenarios, such as a KUKA manipulator controller [5] and Turtlebot maze navigation [6]. It can also serve as a visualization and synthetic data generation tool for external software. For instance, researchers have integrated Unity with MATLAB to control a mobile robot via Shared Memory [7] and with ROS2 for mobile robot control through TCP/IP [8]. Additionally, different researchers connected Unity to external devices such as a robot arm and custom VR controllers using MQTT [9,10]. Each application leverages Unity’s strengths, including its realistic physics engine, the capability to create accurate models, function as a digital twin [7], and its ability to be a hub for multiple input devices [9,10].
These show Unity’s potential as a simulator for industrial and educational applications. For industrial applications, it can be implemented as a design and testing tool before robots are implemented in the real world [11]. Digital twins are useful after systems have been developed digitally to monitor the devices remotely and verify that they maintain normal operation [12]. These elements have been used in areas such as construction for collision detection [13], manufacturing to monitor milling machines [14], and industrial design for machinery [11]. In education, simulation reduces the need for physical hardware to effectively teach robotics. This includes individual hardware kits for students [15] and large machinery, which would be difficult for students to access [16]. Virtual scenarios can be used to study the design process of robots and how their components work at a deeper level [16].
Multi-user collaborative robotic simulation has potential for applications in industry and education. Online multi-user connectivity is useful for simulation because it enables simultaneous participation of multiple users in a shared virtual space. Simulators can use multi-user connectivity through peer-to-peer (P2P) connections or centralized client–server architectures. P2P connections allow players to connect directly, reducing latency and server costs, but can lead to security issues and increased loads on networks [17]. In contrast, server-based connections host the applications on remote dedicated servers, enhancing security and consistency, though resulting in potentially higher latency and infrastructure costs [17]. Server-based connections can be created with external services, which allows developers to focus on software development. Researchers have used online multiplayer platforms for educational purposes by turning simulators into multi-user spaces used to instruct students about manufacturing [18,19], and to create collaborative spaces to learn modern technologies [20].
Current researchers have shown that a multi-user robotic simulation environment based on Unity is feasible. These have focused on building systems that connect several users in aerial drone simulations [21], human–robot interactions in VR [22], and psychology treatments for mental health [23]. Researchers argued that existing simulators often do not reflect real operating conditions for robots, but by using Unity they could amend this. They showed that Unity’s abilities to create environments that closely resemble real-world environments would be indispensable for future simulations [23,24]. They also argued that new methods for multi-user simulation are needed, ones that can scale for large number of users and possess realistic physics capabilities [25]. As shown in the previous studies, Unity features these capabilities, making it ideal for this type of use case.
As shown in the literature by O. A. Aguirre et al. [21], Novitzky et al. [24], and Andaluz et al. [7], specialized simulators in Unity are valuable tools for the target tasks. This study uses a different approach by creating an open flexible robotic simulation framework to simplify the process of robotic simulation. Demonstrations for how to use the application, tools to streamline the addition of multiplayer and messaging applications, and sample robotics assets are also provided. This study presents an in-depth review of the readily accessible software that was used to build the simulation framework and how these can be adapted for a variety of users and systems.
The goal of this study is to build a framework for accessible robotics simulation with Unity. This framework will incorporate support from external software and multi-user robotic simulation. Multiple connection methods were compared to establish the benefits and drawbacks of each one when linking Unity with an external software. The chosen software must interface with diverse communication methods, robust data analysis capabilities, and be accessible to a wide range of users. Assessment of Unity as a viable, efficient, flexible, and accessible alternative to simulate robots at a low cost to the user is a relevant element of this study.
The rest of this paper is structured as follows. Section 2 presents the methodology for the developed framework. Section 3 shows results and discussion. The last section presents the conclusions along with a brief discussion of the ongoing and future research.

2. Materials and Methods

The proposed framework is intended as a testing environment for developers to create collaborative multi-user physics-based robot simulations. Development was split into three stages: development in Unity, software integration using communication methods, and multi-user implementation with Photon Unity Network (PUN). PUN features an extensive list of features ideal for researchers and reliable servers. Additionally, PUN does not create any of the additional strain on the end user devices that a P2P implementation would require. Without loss of generality to other robot models, the Meca500 robot arm and Reeman Mobile Robot were selected as the target hardware for this collaborative framework development. MATLAB was chosen as the software for data analysis because it features user-friendly robotic and communication toolboxes, and it is available in many universities.

2.1. Unity and MATLAB Simulation Development

First, independent Unity and MATLAB robot simulators were created as foundational elements for the framework. The Unity simulators create scenarios to control the joints of the Meca500 robot arm [26,27] and to move the Reeman mobile robot [28] through different environments. The MATLAB simulators solve Inverse Kinematics (IK) for the Meca500 arm and manage the mobile robot navigation for the Reeman robot. The Unified Robotics Description Format (URDF) and 3D Computer-Aided Design (CAD) files are the basis for the robot models. The simulators utilize the Unity Robotics packages, MATLAB robotics library, and MATLAB navigation to interface these models with the virtual environments.
Unity Robot Arm Simulation: The Meca500 Unity simulator was developed in three stages: robot model import, robot control, and user interface. The robot was loaded into the scene with the URDF Importer package, which extracts the link and joint parameters from the URDF file. This process creates the robot skeleton and attaches the robot graphical elements to it. Figure 1 shows the imported robot model in Unity with the joint dimensions and end effector orientation displayed over it. The Denavit–Hartenberg (D-H) parameters in Table 1 were used to create this model. This table consists of four parameters which describe the position and rotation of the robot joints:
  • θ: the angle between the current joint’s X plane and the next joint’s X plane along the Z axis;
  • α: the angle between the current joint’s Z plane and the next joint’s Z plane along the Z axis;
  • R: the distance between the current joint and the next joint along the X axis;
  • D: the distance between the current joint and the next joint along the Z axis.
The individual joints are controlled with a script that receives a target position, compares it with the current position, and moves the joint accordingly. To add more realism to the simulator, the robot joints were given speed controls and range limits. Finally, the user interface was implemented in the form of sliders and buttons (Figure 2). Each slider was used to create a target position for each joint, and the buttons were programmed to stop all robot motion or to reset all joint angles to zero.
Unity Mobile Robot Simulation: The Reeman Unity simulator was developed in three steps: robot modeling, robot movement, and object detection with sensors. The model was created with an imported 3D CAD file of the mobile robot. This model was given physics-based properties and was assigned a Unity character controller for movement control. Figure 3a shows the digital model of the Reeman robot. The movement was designed to closely match the real robot. As such, the simulated robot only moves in the XY plane and turns to face the direction of movement. The controls for the robot are the four arrow keys in the keyboard for directional control, with other keys used to manage the speed. The LIDAR and Ultrasonic sensors are simulated using arrays of raycast objects, which are rays that operate as motion sensors. To accurately simulate the sensor and its circular shape, the rays in the arrays rotated by a given amount, which are obtained using Equations (1) and (2).
r o t a t i o n M o d = A n g l e A x i s r a y i n d e x n u m O f R a y s 1 a n g l e a n g l e , 0 , 1 , 0
o r i e n t a t i o n = r o t a t i o n r o t a t i o n M o d ( 0,0 , 1 )
Equation (1) returns rotationMod, a quaternion to represent how much the current raycast object needs to be rotated. It uses AngleAxis, a prebuilt function in Unity, to generate a rotation quaternion for a given raycast. In this function, rayindex is the current index of the raycast object array, numOfRays is the total number of raycast objects in the sensor array, and the angle is the LIDAR range. Equation (2) computes the desired orientation vector for the current raycast object by multiplying the current rotation vectors, the rotationMod obtained in Equation (1), and the vector (0,0,1). Orientation shows how the current ray should rotate to its respective orientation based on its index. This process is repeated for all the rays in the array. Figure 3 shows the process of instantiating LIDAR with an angle range of 135 degrees and a ray count of 240. Figure 3a represents the initial state for all the raycasts in the array before they are transformed. Figure 3b shows the LIDAR with the 240 raycasts transformed following Equation (2).
MATLAB Data Sampling: The MATLAB simulator was developed to provide a reliable system for constant data exchange and analysis with the Unity simulators. Figure 4 shows the process the simulators used to sample for new data. The first stage is a continuous loop surveying the communication method for new data and verifying the correctness of the data. The data analysis for the respective simulator is then initiated once the data are received and verified. The final stage sends the processed data to Unity and restarts the data-sampling loop.
MATLAB Computation for the Robot Arm: The Meca500 simulation first receives the position of user-controlled object and calculates its Inverse Kinematics with the built-in MATLAB function. Then, it uses Equations (3)–(7) to determine the speed for the robot, and finally transmit the data to Unity.
ξ = J q q v n 0 ω n 0 = J v q J ω q q 1 q n
J v i = z i 1 × o n o i 1
J ω i = z i 1
J v q J ω q = z 0 × o 6 o 0 z 1 × o 6 o 1 z 2 × o 6 o 2 z 0 z 1 z 2 z 3 × o 6 o 3 z 4 × o 6 o 4 z 5 × o 6 o 5 z 3 z 4 z 5
V = x i 2 + y i 2 + z i 2
Equation (3) calculates a 6 × 1 matrix which contains the XYZ components of the linear ( v n 0 ) and angular ( ω n 0 ) velocities of the end effector. This is accomplished by multiplying the 6 × 6 Jacobian matrix (J(q)) of the robot with the 6 × 1 velocity matrix of the joint (q). The Jacobian matrix returns the XYZ components of the linear and angular effects that the movement of each joint has on the subsequent joints. This matrix has two pieces: the top three elements use Equation (4) to return the linear components, and the bottom three elements use Equation (5) to return the angular components. In Equations (4) and (5), the Z and O elements, respectively, represent the third and fourth columns of the transformation matrix between the current joint and the robot’s origin. Equation (6) shows what the final Jacobian Matrix would look like before the transformation matrixes are plugged in. Equation (7) uses the XYZ components of the angular and linear velocity vectors to determine the velocity magnitude of each joint. This magnitude returns one singular speed, which determines the joint’s actual speed.
Figure 5 shows how MATLAB analyzes the data from Unity. In this process, MATLAB receives the Unity Robot joint angles and user object XYZ coordinates. This process initially receives the robot joint angles and user object XYZ coordinates from Unity. Afterwards, it uses these data to compute the inverse kinematics and its Jacobian matrix. Then, it determines the velocity magnitude for each joint from the Jacobian matrix. Finally, it streams the velocities and new joint positions to Unity.
MATLAB Computation for the Mobile Robot: The MATLAB simulator for the Reeman robot has a mapping mode and a navigation mode. The former uses sensor data to build a map which is used in the latter mode with a navigation algorithm.
  • The map is built by generating several LIDAR sensor readings, putting them into individual LIDAR scan objects, and using these objects to build a 2D binary occupancy map.
  • The path between the robot’s start and end positions is generated using the Hybrid A-star algorithm. This algorithm generates the path between the two positions and adds an extra perimeter to the map objects to avoid collisions. The path is stored as an array of positions in MATLAB, which is sent to Unity upon request.

2.2. Communication Methods and Complex Simulation

The second stage of framework development involved determining which method would be the most suitable method to exchange data between MATLAB and Unity. Based on the literature review, TCP/IP, Shared Memory (SHM), Firebase, and MQTT were selected to be evaluated in the test scenarios. TCP/IP, SHM, and MQTT were chosen based on their usage in similar applications to this one. Firebase, on the other hand, was selected after reviewing its usage in a smart home environment [29] and an application for streaming music and playing games together [30].
  • TCP/IP uses a client/server mode and a static IP address to connect Unity and MATLAB so they can share messages [31]. MATLAB connects to the IP address using built-in commands from the Instrument Control Toolbox. Unity connects to the IP address with the System.Net.Sockets library. To establish the TCP/IP communication, one simulator must be considered as the server and the other as the client. In this study, Unity and MATLAB were both tested as servers and clients.
  • SHM assigns applications to the same memory space in the RAM. This allows applications to make their data available to other applications in the same space [7]. SHM was implemented by saving the MATLAB application as a DLL (Dynamic-Link Library) file. This file was then imported into the Unity project and used in the C# scripts with function calls.
  • Google Firebase is a real-time NoSQL database which allows users to read and write data using a web interface [29,30]. MATLAB and Unity connect to this database using the REST API, which allows the applications to access the web addresses without a specialized library. Data sharing works by having one application send data with the write or put commands. The database stores these until newer data overwrite it. The other application uses a read command to retrieve the latest version of the data stored in the database.
  • MQTT is a publish–subscribe messaging protocol that connects applications through web-based applications [10]. NodeRed is used as the MQTT host application; Unity connects to it using the M2MQTT custom package, and MATLAB connects with the built-in commands from the Instrument Control Toolbox. To share data, both applications first connect to the MQTT host using the broker address, and then they interface with a MQTT topic to read or write data. MQTT topics are filters to which clients subscribe to so they can share data with other subscribed clients. If the application writes, then the current data are copied and sent to the server where these can be held. And if it reads, then data are requested and obtained from the server. Two MQTT flows were built, one where MATLAB sends data to Unity, and the other where Unity sends data to MATLAB.
These communication protocols were evaluated in two stages. The first stage quantifies each method’s interaction latency, reliability, and flexibility. The second stage compares the best-performing methods using two tests to determine their feasibility for simulation. Test A created a simulation scenario that sent and received messages to control the Meca500 robot (Figure 6). Test B created a mapping and navigation scenario for the Reeman Robot (Figure 7). Each test was designed to operate with the following parameters:
  • Test A: Meca500 simulation.
    A player controller sphere was added to the Unity scene, the location of which is continuously streamed to the MATLAB application (Figure 6a). MATLAB uses these continuous pose data to repeatedly compute the Inverse Kinematics and speed for the robot (Figure 6b). Back in Unity, the user can press a button at any moment to retrieve the newest joint position and apply it to the robot (Figure 6b). The messages in this simulator contain fifteen data points. Six for the robot joint positions, six for the joint velocities, and three for the points object’s location.
  • Test B: Reeman Mobile robot simulation.
    Mapping mode: The user maneuvers the robot through the scene, scanning it with the LIDAR sensors whose data are streamed continuously to MATLAB (Figure 7a). Once the user has collected sufficient sensor data, they press a button in Unity which signals the MATLAB application to generate the map. Figure 7b shows a plot of the received LIDAR scans by MATLAB before they are used to create the map. Each message in this simulator contained 726 data points. A total of 720 points came from the LIDAR, which streamed the object distance, X rotation angle, and Y rotation angle from each of the 240 raycast object in the array. The remaining six points were from the XYZ cartesian coordinates of the robot, and three rotation angles for the robot orientation.
    Navigation Mode: In Unity, a pointer object was added to the scene to indicate the robot’s desired end position (Figure 7a). The user moves this object to the desired location and presses a button to send the object’s and the robot’s data to MATLAB. These data are processed and used to create a path between the two points. The path is then sent to Unity as an array of robot location and orientation coordinates (Figure 7c). Finally, the robot follows the received path until it reaches the end position. The result of the map and data generation process can be observed in Figure 7c. This figure shows the map generated from the LIDAR scans in Figure 7b with a path generated between the robot’s start position and end position from Figure 7a. The messages in this simulator contain three arrays of varying size. Two of these arrays represent the XY coordinates of each step in the path and the third array contains the orientation of the robot at each step of the path.

2.3. Photon Unity Network

The multiplayer client for the Unity players was created using the Photon Unity Network (PUN) servers. PUN works in Unity by having each instance connect to the same server using its unique API key. When the applications connect to the server, they join a shared virtual space and are given a random user ID. This allows users to see and interact with each other through network objects, whose data are streamed to all the connected instances of the application. These objects are categorized as server-owned or user-owned. These categorizations determine which users can modify each network object. Figure 8 shows the differences on how the PUN implementations interact with the MQTT simulator (Figure 8a) and with the Firebase simulator (Figure 8b).
Figure 8a shows that each computer only connects to the PUN remote server and handles the remaining processes internally. The Unity-MATLAB communication process in each computer is isolated from the other systems connected to the PUN server. Figure 8b shows each computer connecting to the PUN and Firebase servers simultaneously. The servers are hosted on separate web addresses; so, they do not interact while the application runs. Firebase allows systems to share data with each other through its server.
The PUN implementations for the Meca500 and Reeman simulators focused on converting their scene objects into network objects and implementing methods so all users could interact with the objects. In Test A, the pointer sphere became scene-owned, the robot became user-owned, and the sliders became player-owned. In Test B, the pointer became scene-owned, and the robot became player-owned. The robots were set up as player-owned objects to ensure they could only receive instructions from one user. An ownership takeover system was implemented to ensure that non-owner users could still access the robot. This system allows non-owner users to press a button to request ownership of the robot, and robot ownership is transferred to them if it is not in motion.
The ownership switching model includes methods to deal with user’s losing connection to the server. This method stores the network object positions globally in case a user disconnects the simulation. If the current owner of an object disconnects, then its ownership will be assigned to the user that connected next. This system will keep the application functional in the event that a user has network issues.

3. Results and Discussion

In this section, evaluation results are presented for the framework components as outlined in the Methods section. Section 3.1 discusses the results of Tests A and B. Section 3.2 focuses on the performance of the communication methods with the Meca500 and Reeman simulators. Section 3.3 discusses how the PUN was added to the Unity-MATLAB simulators. Section 3.4 discusses the integration of all the components.
The tests from this section were performed using professional-grade and consumer-grade computers to determine the usability of these for diverse users.
  • The specification of the professional-grade computers is AMD Ryzen 9 5950X 16-core processor, 64 GB of RAM, and a NVIDIA RTX 3090 with 24 GB of VRAM.
  • The specification of the consumer-grade computers is AMD Ryzen7 3800X 8-core processor, 32 GB of RAM, and an AMD Radeon RX 5600 XT with 6 GB of VRAM.

3.1. Unity and MATLAB Simulation

The goal of our Unity simulators is to create a digital twin of real robots. The simulators were created by analyzing the real robots’ function and replicating them in the Unity digital world. Once the process was completed, the digital models were tested by synchronizing the Meca500 and Reeman robots with their simulated counterparts and evaluating the accuracy of their motion. This process was replicated multiple times to test for repeatability and accuracy over time.
The Meca500 model was tested by giving it specific joint configurations and comparing them with recordings of the real robot performing the same motion. After several iterations, this test showed that the joint positions and motion of the simulated robot were accurate compared to the real robot. Figure 9 shows the result of two tests, one comparing how the arms extend to their full reach (Figure 9a) and one comparing how the arms performed a complex motion (Figure 9b). These results highlight the importance of accurate robot models, such as URDF, and accurate kinematic models to increase the effectiveness of simulation.
The Reeman mobile robot model (Test B) was tested in two steps: (1) a test for the motion, and (2) a test for the LIDAR. Robot motion was tested by moving the digital model in straight lines, curves, and sharp turns, and then comparing the differences in trajectories with recordings of the real robot. This test uncovered an issue where the simulated robot’s turn point was located at the front wheels (red line in Figure 10a), which is offset from the one in the real robot. This was corrected by inserting a game object in the correct spot (blue line in Figure 10a) and setting it as the turn point. Figure 10b shows a comparison test of one robot with the original turn point (red robot) and another one with the new turn point (blue robot). Both robots started at the same origin and rotated 45 degrees to the left. The results in Figure 10 show that the adjustment made the model’s turn more realistic. This adjustment was tested with repeated motions to verify its accuracy and usefulness for simulation.
The simulated LIDAR was tested by comparing its object detection with the one shown by the web interface offered by Reeman robot vendor. This test compared the two sensors standing still at several locations and verified that the digital one matched the specifications of the real one. The performance of the LIDAR was found to closely resemble what was shown in the web interface. The tests for the MATLAB simulators focused on optimizing the performance of the applications. These showed that the data-sampling loop and analysis processes were performing more slowly than expected. These slowdowns were addressed by adjusting the applications data usage.

3.2. Data Communication Methods

This section focuses on analyzing the implementations for each method and discussing their performance in the two stages of tests. The first test analyzed the basic integration, reliability, and flexibility of the four methods. The second test implemented the best-performing methods into the robot simulators and analyzed how they handle large datasets, fast update frequency, and performance over time.
The first test showed that the four communication methods had straightforward integrations with Unity and MATLAB. Some of the methods had issues in reliability and flexibility. TCP/IP had two reliability issues: lack of bidirectional communication and messages only being sent in one string. The first issue was fixed by creating two server–client pairs, one with Unity as the server and MATLAB as the client, and the other with MATLAB as the server and Unity as the client. The second issue was addressed by adding text markers to the string and using these to detect the necessary information. MQTT also showed reliability issues where the software would not receive data because their timings were not synchronized. This was fixed by adding a JSON file storage node to hold the received data until the other software called it. SHM lacks flexibility because the DLL requires the user to recompile and reimport it after each modification.
The results of the first test showed that all the four methods could efficiently exchange data between the two applications. However, SHM and TCP/IP presented critical flaws during testing. The DLL in SHM cannot be adjusted rapidly, which impacts the developer’s ability to rapidly prototype their simulator. For TCP/IP, the additional computational power and time required to parse the message strings made it an unviable option. On the other hand, Firebase and MQTT performed well in all facets of testing after their issues were addressed. Both methods store data in a JSON format, which enables efficient data parsing, and both allow for efficient modification to their applications. Therefore, MQTT and Firebase were selected for the second round of testing.
The follow-up test results on Firebase and MQTT showed that the Unity applications with continuous data streaming would become unstable in the consumer-grade computer. Figure 11 shows that the Reeman application with Firebase would randomly disconnect from the server. This occurred because Unity could not properly stream 726 data points per message with its variable streaming frequency of 600 Hz to 800 Hz. This caused the user to stream an average of 139.28 Megabytes (MB) worth of messages every minute and approximately 6 GB of data every hour to Firebase (Table 2). This excessive data usage was deemed the primary cause of the instability in the simulator (Figure 11). This was resolved by modulating the streaming frequency and message size which created the excessive volume of data. Furthermore, Firebase allocates a limited amount of free storage to the user per month which, if exceeded, requires the user to pay a fee for each GB over the exceeded allocation.
Message size was modulated by reducing the LIDAR ray count from 240 to 135. This reduced the streamed data points per message to 415 and kept one ray per degree of the LIDAR. The feasible streaming frequency was determined by testing and comparing the following frequencies: 200 Hz, 100 Hz, 50 Hz, 20 Hz, and 10 Hz. The frequencies were tested using a two-hour trial that analyzed data usage, stability, and update rate for the slower speeds. A programming command was used in the Unity C# scripts to make sure that the data transmission remained at the given frequencies. The command creates a function that is updated at a set rate that is independent from the rest of the application. This makes sure that the application never updates at a faster or slower rate than it should be. This solution was implemented with all the frequencies analyzed during this process.
Due to the Firebase data usage constraints, it was defined that a frequency will be considered acceptable if it streams less than 1 GB of data per hour. Furthermore, to verify their usefulness, frequencies should maintain stability throughout the two-hour trial. This final parameter is crucial because an instability due to hardware issues can create further synchronization complications. This issue occurred during the test shown in Figure 11, where the device performing the simulation had to be restarted. The results of each frequency, which can be observed in Figure 12, are discussed in the section below.
  • 200 Hz: The test results showed that applications with 200 Hz streaming became unstable in the second hour of testing. Despite data streaming remaining stable (Figure 12), the application showed error messages and experienced slowdowns. The application also saw exceedingly high data usage, with 5.7 GB of data streamed during the one hour of stability.
  • 100 Hz: The results in Figure 12 show the application streaming data at 100 Hz briefly disconnected from the network. This can be attributed to the application briefly becoming unstable due to stutters caused by message parsing. Table 3 shows that the application streamed an average of 3 GB of data per hour, which was deemed higher than acceptable for the application.
  • 50 Hz: The results showed 50 Hz streaming completed the two-hour trial with no stability issues. These also showed that it used 1.5 GB of data per hour (Table 3), which is considered outside of the acceptable parameters.
  • 20 Hz: The test results showed that streaming at 20 Hz had consistent data streams (Figure 12) at a low data usage, with a maximum of 12 MB per minute and an average of 10 MB per minute (Table 3). The results also showed that 20 Hz provides sufficient updates per minute with the mapping application to create an acceptable map.
  • 10 Hz: The results show that 10 Hz has the best data usage at 5 MB streamed per minute (Figure 12). The results also show that streaming at 10 Hz on real-time applications leads to insufficient information for effective data processing.
Due to their instability with high volumes of data, it was determined that 200 Hz and 100 Hz streaming would not be viable. Additionally, neither applications could process messages at that speed, leading to lost data. Streaming below 100 Hz showed improved stability and acceptable data usage. Furthermore, 50 Hz had high data usage for the Reeman simulator but it is useful for simulators with smaller datasets. The Meca500 simulator performs well with this dataset because its dataset contains fifteen points. In addition, 20 Hz was deemed suitable for the application due to its acceptable data usage, lack of instability after multiple trials, and real-time responsiveness. Additionally, 10 Hz was slow for real-time applications but has uses for applications where real-time communication is not necessary. These results indicate that 50 to 10 Hz is the ideal range to connect Unity and MATLAB. The streaming frequency for each application will change based on the complexity of the application. The chosen frequency should minimize data usage while maintaining normal operation of the application. If a frequency above 100 Hz were used, it is recommended to use MQTT or some other local method with a high-end computer that can handle the fast computations.

3.3. Photon Unity Engine

This section will discuss the details of the PUN implementation, the improvements made to them, and the user experience for the network clients. The initial PUN implementations for the simulators were completed by following the procedure outlined in the literature [32] and tested using two network clients. The PUN server utilized can handle up to 20 concurrent users and 60 GB of traffic per month. The results showed that network objects in both simulators would lose synchronization for non-owner users and the object movement would be delayed for them. This delay was mitigated using the latency compensation computation in Equation (8).
p o s = v e l c u r r T i m e p r e v T i m e
Equation (8) calculates which is the rate at which the object’s velocity is sped up or slowed down for the affected users. This equation multiplies the current velocity (vel) of the object with the absolute value of the time difference. This difference is obtained by subtracting the current time (currTime) and when the instruction was sent (prevTime).
The test in the Meca500 simulator showed that the positional sliders from non-owner users would transmit their unique values to the robot. This would cause the model to perform an erroneous motion. The fix for this was to disable the sliders of non-owner users and to add the request ownership protocol, which re-enables the sliders of the user. The Reeman simulator showed that if a user took over ownership of the robot, the position would reset to the one the new owner last recorded instead of continuing the movement from the new position. This was fixed by implementing a system that would override the last stored position from that user with the last stored position from the previous owner.
The stability of the PUN simulator was tested using 5 of the 20 possible concurrent users during a 2 h period. During testing, the server performance remained stable with no slowdowns occurring while the number of users increased. The game experience remained the same and the monitoring graph showed that all the users remained connected. The evaluation showed that all users had a 100 ms delay when interacting with non-owned network objects. This delay was expected to occur and did not hinder user experience during testing. This test generated minimal traffic on the PUN server because all users utilized the same object. The PUN server did not show major increase in data utilization while all five users were connected to the server. This showed that there was no time limit for these applications but one could occur if a large number of network objects were to be utilized.
The connection stability test showed that the prevention methods worked as intended. When a user disconnected from the server, ownership of game objects was transferred without causing issues to the application. Users that disconnected from the server would reconnect as inexperienced users, causing them to lose their status in the application. Future iterations of this study will focus on restoring users to their status before disconnecting and mitigating delay/desynchronization.

3.4. Performance Test

A core aspect of the proposed framework for this research is verifying that it can be accessible to users with diverse computer configurations. This was tested with the two computers configurations, as mentioned in Section 3. The load from simulators was analyzed while the applications were active. The test was evaluated under two diverse criteria, one focusing on the standalone communication methods, and the other on the simulator applications.
The tests MQTT and Firebase showed that they had negligible resource usage on both computers. MQTT through Node-Red was shown to only use 0.1–0.4% of the CPU and maximum 65 MB/s of RAM (Figure 13). Firebase did not use any hardware components, as shown in Figure 13; the only impact it had on the computer was using up to 1.1 MBPS of networking. This is attributed to Firebase being a web server with no local services needed.
The results of the performance test in Table 4 show the impact the Unity and MATLAB applications had on the computers. The Unity editor used to run the applications generated a moderate-to-high load on the CPU, GPU, and RAM on both systems. The CPU usage is higher than ideal but still acceptable for current computers. RAM usage scaled up in each system based on their available resources, as greater usage allows the application to run smoother. The GPU usage had high variance based on the visual complexity of the application. The Meca500 application shows a much higher usage because it had to render the six robot joints, which was a more complex task than that of the mobile robot from the Reeman simulator. All of these metrics stayed in what is deemed acceptable for the application in both computers considering their specifications.
For systems with lower computational power, the Unity editor simulation environment can be run by using the Unity development build instead. This is a lighter version of the application that runs preset scenarios. To modify the built application, users must go back to the Unity editor, make the desired changes, and rebuild it. This ensures that the application remains lightweight. This application uses 4–5% of CPU, 145 to 167 MB of RAM, and 5% of the GPU (Figure 14). This low usage in contrast with the unity editor is due to the simulator running without the overhead from the Unity editor.
The two MATLAB applications show the impact that varying computational complexities can have on the computers. These tests were run using a myriad of datasets to analyze how the application performed under different loads. As seen in Table 4, the Meca500 application did not create a heavy load due to its small dataset used and the more manageable calculation process. In contrast to this, the Reeman application had high resource utilization because of the frequent sampling of the large dataset generated by the LIDAR and the calculations required to process the data. This high usage was handled well by both computers, but it raised concerns about the viability of simulation with Unity and MATLAB simultaneously for less powerful computers. This can impact users such as students or schools who may not have access to higher-capacity systems but still want to execute large simulation models. This issue was solved by using Firebase to offload the computations to a more powerful remote computer. To accomplish this, the user must load the Unity and MATLAB applications on separate computers and then connect them to the Firebase server. The test results (Figure 15) show that this solution is viable for multi-device environments, such as classrooms, where one computer is dedicated to computations and the rest performs the simulations.
The results in this section show that the applications in the proposed framework can be modified to fit the needs of the user’s computer specifications. This allows users with varying degrees of computer configurations to effectively access the simulators and interact with the digital robots.

3.5. Integration Test Results

The next section focuses on the PUN integration with the robot simulators using MQTT and Firebase. The simulators were tested on how PUN interacted with the communication methods. The results in Table 5 show the benefits from Firebase and MQTT, and how they can be used together to serve a diverse set of users.
Table 5 shows that MQTT provides a better option for users who wish to perform all analysis locally, and Firebase works best for users who wish to share their data or need to offload computations. As a local process, MQTT requires all instances of the PUN simulators to run MATLAB and perform their own data analysis. This is useful for developers who wish to handle all computations locally and keep data private. As a web-based server, Firebase allows the PUN simulators to operate with only one instance of performing the data analysis in MATLAB. This can be utilized in classroom or industrial demos where only the instructors need to perform the computations and the remaining users can just visualize the scenario. This comparison highlights two important drawbacks for Firebase, the limited data usage and users having to take turns to use the service. These issues will be explored in the future by implementing an alternative web-based communication method. Future work will also focus on interfacing additional software with the framework. This will focus on adding ROS2 and Gazebo support to the Unity framework so their simulation tools can be used in the multi-user environment. Incorporating these and improving remote computations will improve the accessibility of the framework.

4. Conclusions

A multi-user robotic simulation framework connecting Unity to external applications is developed and evaluated in this research. The two simulation scenarios show that Unity has the capability to manage complex simulation scenarios. The addition of external software through messaging applications shows how the strengths of third-party software can be leveraged to improve the framework. Testing of the messaging methods showed that supporting MQTT and Firebase allowed the simulator to operate in a larger number of devices. The multi-user servers were shown to create a remote collaborative digital environment that can be leveraged by several applications. These factors created a flexible framework that can be adapted to varying simulation complexities on several types of computer configurations.
The results here demonstrate that Unity can be used in a robotic simulation framework for complex kinematics. Future efforts will aim to create a robotics simulation hub where users can expand their understanding of robotics and have immersive collaborative experiences. The framework will be expanded to support existing robotic simulators such as ROS2 and other programming languages such as Python. For the extension of this work, it will be necessary to first define the requirements for their desired simulation. The established parameters should be used to create the Unity and data analysis applications. These should be tested to determine their computational needs and if the current computer can handle them. If the system is shown to be insufficient, users can reduce the complexity of simulation or offload parts of the process to a different system. The multiplayer service may be changed to a solution which will provide smoother connections and better options to handle users’ desynchronization. Firebase may be replaced with a different web server with increased data streaming limits. Finally, Unity will be compared with existing simulators such as Gazebo and RoboDK on how they handle visual robot representation and physics simulation.

Author Contributions

Conceptualization, A.H.-G. and W.Z.; methodology, A.H.-G.; software, A.H.-G.; validation, A.H.-G.; formal analysis, A.H.-G.; resources, A.H.-G. and W.Z.; writing—original draft preparation, A.H.-G.; writing—review and editing, W.Z.; visualization, A.H.-G.; supervision, W.Z; project administration, W.Z.; funding acquisition, W.Z. All authors have read and agreed to the published version of the manuscript.

Funding

This work was partially supported by the United States Department of Agriculture grants #2021-67022-34889, 2022-67022-37867, and 2023-51300-40853, the United States Department of Education grant P116S230007, and the University of Houston Infrastructure Grant. The APC was funded by the Computers journal.

Data Availability Statement

No new data were created during this study.

Acknowledgments

I would like to thank Francisco Haces-Fernandez and Francisco Haces-Garcia for their additional revisions of this paper and for their contributions to improving the written text.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Platt, J.; Ricks, K. Comparative Analysis of ROS-Unity3D and ROS-Gazebo for Mobile Ground Robot Simulation. J. Intell. Robot. Syst. Theory Appl. 2022, 106, 80. [Google Scholar] [CrossRef]
  2. Peruzzini, M.; Grandi, F.; Cavallaro, S.; Pellicciari, M. Using virtual manufacturing to design human-centric factories: An industrial case. Int. J. Adv. Manuf. Technol. 2021, 115, 873–887. [Google Scholar] [CrossRef]
  3. Wang, Z.; Han, K.; Tiwari, P. Digital twin simulation of connected and automated vehicles with the unity game engine. In Proceedings of the 2021 IEEE 1st International Conference on Digital Twins and Parallel Intelligence, Beijing, China, 15 July–15 August 2021; pp. 180–183. [Google Scholar] [CrossRef]
  4. Fan, K.; Marzullo, A.; Pasini, N.; Rota, A.; Pecorella, M.; Ferrigno, G.; de Momi, E. A Unity-based da Vinci Robot Simulator for Surgical Training. In Proceedings of the IEEE RAS and EMBS International Conference on Biomedical Robotics and Biomechatronics, Seoul, Republic of Korea, 21–24 August 2022. [Google Scholar] [CrossRef]
  5. Lin, M.; San, L.; Ding, Y. Construction of Robotic Virtual Laboratory System Based on Unity3D. IOP Conf. Ser. Mater. Sci. 2020, 768, 072084. [Google Scholar] [CrossRef]
  6. Cleaver, A.; Tang, D.; Chen, V.; Sinapov, J. HAVEN: A Unity-based Virtual Robot Environment to Showcase HRI-based Augmented Reality. arXiv 2020, arXiv:2011.03464. [Google Scholar] [CrossRef]
  7. Andaluz, V.; Chicaiza, F.; Gallardo, C.; Quevedo, W.; Varela Aldás, J.; Sánchez, J.; Arteaga, O. Unity3D-MATLAB Simulator in Real Time for Robotics Applications. In Augmented Reality, Virtual Reality, and Computer Graphics: Third International Conference, AVR 2016, Lecce, Italy, 15–18 June 2016; Proceedings, Part I 3; Springer: Berlin/Heidelberg, Germany, 2016; pp. 246–263. Available online: http://www.springer.com/series/7412 (accessed on 2 March 2024).
  8. de La Peña López, D.; Paredes Orta, C.A.; Chávez, F.M.; Valentín Coronado, L.M. ROS2 and Unity based Simulation for telepresence robot. In Proceedings of the 2022 International Conference on Electrical, Computer, Communications and Mechatronics Engineering, ICECCME 2022, Male, Maldives, 16–18 November 2022. [Google Scholar] [CrossRef]
  9. Caiza, G.; Bonilla-Vasconez, P.; Garcia, G.A. Augmented Reality for Robot Control in Low-cost Automation Context and IoT. In Proceedings of the 25th IEEE International Conference on Emerging Technologies and Factory Automation (ETFA), Vienna, Austria, 8–11 September 2020; pp. 1461–1464. [Google Scholar]
  10. Panchi, F.; Hernández, K.; Chávez, D. MQTT Protocol of IoT for Real Time Bilateral Teleoperation Applied to Car-Like Mobile Robot. In Proceedings of the 2018 IEEE Third Ecuador Technical Chapters Meeting (ETCM), Cuenca, Ecuador, 17–19 October 2018; pp. 1–6. [Google Scholar]
  11. Togias, T.; Gkournelos, C.; Angelakis, P.; Michalos, G.; Makris, S. “Virtual reality environment for industrial robot control and path design. Procedia CIRP 2021, 100, 133–138. [Google Scholar] [CrossRef]
  12. Caiza, G.; Sanz, R. Digital Twin for Monitoring an Industrial Process Using Augmented Reality. In Proceedings of the 2022 17th Iberian Conference on Information Systems and Technologies (CISTI), Madrid, Spain, 22–25 June 2022; pp. 1–5. [Google Scholar]
  13. Messi, L.; Naticchia, B.; Alessandro, C.; Luigi, R.; Di Giuda, G.M.M. Development of a digital twin model for real-time assessment of Collision Hazards. In Proceedings of the Creative Construction e-Conference (2020); Budapest University of Technology and Economics & Diamond Congress Ltd.: Budapest, Hungary, 2020; pp. 14–19. [Google Scholar]
  14. Zhu, Z.; Lin, Z.; Huang, J.; Zheng, L.; He, B. A digital twin-based machining motion simulation and visualization monitoring system for milling robot. Int. J. Adv. Manuf. Technol. 2023, 127, 4387–4399. [Google Scholar] [CrossRef]
  15. Bin, S.; Yanwu, W.; Xiyong, Z.; Huabin, C. Virtual Reality Design of industrial robot teaching based on unity3D. In Proceedings of the 2021 7th International Symposium on Mechatronics and Industrial Informatics (ISMII), Zhuhai, China, 22–24 January 2021; pp. 1–4. [Google Scholar]
  16. Tselegkaridis, S.; Sapounidis, T. Simulators in Educational Robotics: A Review. Educ. Sci. 2021, 11, 11. [Google Scholar] [CrossRef]
  17. Tikhomirov, A. Developing an Online Multiplayer Game in Unity; South-Eastern Finland University of Applied Sciences: Kouvola, Finland, 2023. [Google Scholar]
  18. Kim, H.; Hartleb, T.; Bello, K.; Aqlan, F.; Zhao, R.; Yang, H. Behavioral Modeling of Collaborative Problem Solving in Multiplayer Virtual Reality Manufacturing Simulation Games. J. Comput. Inf. Sci. Eng. 2024, 24, 031006. [Google Scholar] [CrossRef]
  19. Zhao, R.; Aqlan, F.; Elliott, L.; Baxter, E. Multiplayer Physical and Virtual Reality Games for Team-based Manufacturing Simulation. ASEE Annu. Conf. Proc. June 22 2020. [Google Scholar] [CrossRef]
  20. Gueddiche, S.; Boton, C. Collaborative virtual reality in construction comparative study of two remote multi-user systems. In Proceedings of the Creative Construction Conference 2023, Keszthely, Hungary, 20–23 June 2023; pp. 684–693. [Google Scholar] [CrossRef]
  21. Aguirre, O.A.; Ñacato, J.C.; Andaluz, V.H. Virtual Simulator for Collaborative Tasks of Aerial Manipulator Robots. In Proceedings of the 2020 15th Iberian Conference on Information Systems and Technologies (CISTI), Seville, Spain, 24–27 June 2020; pp. 1–6. [Google Scholar]
  22. Coronado, E.; Itadera, S.; Ramirez-Alpizar, I.G. Integrating Virtual, Mixed, and Augmented Reality to Human–Robot Interaction Applications Using Game Engines: A Brief Review of Accessible Software Tools and Frameworks. Appl. Sci. 2023, 13, 1292. [Google Scholar] [CrossRef]
  23. Ozgur, A.G.; Khodr, H.; Akeddar, M.; Roust, M.; Dillenbourg, P. Designing Online Multiplayer Games with Haptically and Virtually Linked Tangible Robots to Enhance Social Interaction in Therapy. In Proceedings of the 2022 31st IEEE International Conference on Robot and Human Interactive Communication (RO-MAN), Napoli, Italy, 29 August–2 September 2022; pp. 358–364. [Google Scholar]
  24. Novitzky, M.; Semmens, R.; Franck, N.H.; Chewar, C.M.; Korpela, C. Virtual Reality for Immersive Human Machine Teaming with Vehicles. In Virtual, Augmented and Mixed Reality. Design and Interaction: 12th International Conference, VAMR 2020, Held as Part of the 22nd HCI International Conference, HCII 2020, Copenhagen, Denmark, 19–24 July 2020; Proceedings, Part I 22; Chen, J.Y.C., Fragomeni, G., Eds.; Springer: Cham, Switzerland, 2020; Volume 12190. [Google Scholar]
  25. Gao, J.; Liu, Q.; Chen, H.; Deng, H.; Zhang, L.; Sun, L.; Huang, J. Digital Battle: A Three-Layer Distributed Simulation Architecture for Heterogeneous Robot System Collaboration. Drones 2024, 8, 156. [Google Scholar] [CrossRef]
  26. Mecademic Company. MECA500 (R3 & R4) User Manual; Mecademic Company: Montréal, QC, Canada, 2 November 2022. [Google Scholar]
  27. Mecademic Company. Mecademic Industrial Robots Programming Manual; Mecademic Company: Montréal, QC, Canada, 2 November 2022. [Google Scholar]
  28. Reeman Robot. Big Dog Chassis Navigation Manual. 25 October 2022; Word File. [Google Scholar]
  29. Guedira, Y.; Rouillard, J. Multimodal Interaction Framework Based on Firebase Real-Time Database. In Multimodal Interaction Framework Based on Firebase Real-Time Database; Springer: Cham, Switzerland, 2021; pp. 367–384. Available online: http://www.springer.com/series/7409 (accessed on 1 October 2024).
  30. Hannula, T. Unity Mobile Application with a Serverless Firebase Backend; South-Eastern Finland University of Applied Sciences: Kouvola, Finland, 2021. [Google Scholar]
  31. Tyagi, A. TCP/IP Protocol Suite. Int. J. Sci. Res. Comput. Sci. Eng. Inf. Technol. 2021, 6, 59–71. [Google Scholar] [CrossRef]
  32. PUN Getting Started. Available online: https://doc.photonengine.com/pun/current/demos-and-tutorials/pun-basics-tutorial/intro (accessed on 10 April 2024).
Figure 1. Meca500 robot model with real dimensions.
Figure 1. Meca500 robot model with real dimensions.
Computers 13 00282 g001
Figure 2. User interface for the Meca500 simulator with buttons and sliders.
Figure 2. User interface for the Meca500 simulator with buttons and sliders.
Computers 13 00282 g002
Figure 3. (a) The initial state of the LIDAR; and (b) the final state of the LIDAR sensor.
Figure 3. (a) The initial state of the LIDAR; and (b) the final state of the LIDAR sensor.
Computers 13 00282 g003
Figure 4. MATLAB data-sampling process for Meca500 and Reeman simulators.
Figure 4. MATLAB data-sampling process for Meca500 and Reeman simulators.
Computers 13 00282 g004
Figure 5. Workflow of how the MATLAB simulator analyzes data from Unity and returns new data.
Figure 5. Workflow of how the MATLAB simulator analyzes data from Unity and returns new data.
Computers 13 00282 g005
Figure 6. (a) MATLAB simulator solving inverse kinematics; and (b) the simulator once it receives the new joint positions from MATLAB.
Figure 6. (a) MATLAB simulator solving inverse kinematics; and (b) the simulator once it receives the new joint positions from MATLAB.
Computers 13 00282 g006
Figure 7. (a) The Unity scenario used in the Mobile robot test; (b) the plotted LIDAR scans that MATLAB received; and (c) the generated map with a robot trajectory.
Figure 7. (a) The Unity scenario used in the Mobile robot test; (b) the plotted LIDAR scans that MATLAB received; and (c) the generated map with a robot trajectory.
Computers 13 00282 g007
Figure 8. (a) PUN interacting with the MQTT simulator; and (b) the Firebase simulator.
Figure 8. (a) PUN interacting with the MQTT simulator; and (b) the Firebase simulator.
Computers 13 00282 g008
Figure 9. Results of the comparison test: (a) for arm extension; and (b) complex movement.
Figure 9. Results of the comparison test: (a) for arm extension; and (b) complex movement.
Computers 13 00282 g009
Figure 10. (a) Comparison the of the previous rotation origin to the new one; and (b) an overlay showing how changing the turn point affects the rotation of the car.
Figure 10. (a) Comparison the of the previous rotation origin to the new one; and (b) an overlay showing how changing the turn point affects the rotation of the car.
Computers 13 00282 g010
Figure 11. Data usage over time for streaming at 600 Hz.
Figure 11. Data usage over time for streaming at 600 Hz.
Computers 13 00282 g011
Figure 12. Data usage over time for all frequencies.
Figure 12. Data usage over time for all frequencies.
Computers 13 00282 g012
Figure 13. The resources used by MQTT through Node-Red (top image) and the networking used by Firebase while running on Unity.
Figure 13. The resources used by MQTT through Node-Red (top image) and the networking used by Firebase while running on Unity.
Computers 13 00282 g013
Figure 14. The Reeman simulator (a) and the Meca500 simulator (b) running as built applications using fewer resources.
Figure 14. The Reeman simulator (a) and the Meca500 simulator (b) running as built applications using fewer resources.
Computers 13 00282 g014
Figure 15. (a) Diagram showing Firebase used to connect instances of the MATLAB and Unity simulations running on separate computers. (b) Two computers used to showcase this principle.
Figure 15. (a) Diagram showing Firebase used to connect instances of the MATLAB and Unity simulations running on separate computers. (b) Two computers used to showcase this principle.
Computers 13 00282 g015
Table 1. Denavit–Hartenberg parameters table.
Table 1. Denavit–Hartenberg parameters table.
Jointθ (deg)α (deg)R (mm)D (mm)
J1θ10090
J2θ2−90045
J3θ301350
J4θ4−90380
J5θ5900120
J6θ6−90070
Table 2. Data usage analytics for streaming at 600 Hz.
Table 2. Data usage analytics for streaming at 600 Hz.
Statistics per MinuteData Usage
Maximum163.61 MB
Average139.28 MB
Minimum0 MB
Data sent int time interval5.936 GB
Table 3. Statistics for all the analyzed frequencies.
Table 3. Statistics for all the analyzed frequencies.
Data Usage10 Hz20 Hz50 Hz100 Hz200 Hz
Maximum per minute (MB)6.3112.7527.0763.8108.63
Average per minute (MB)4.792210.059024.220949.804197.0666
Minimum per minute (MB)5.527.4921.36047.26
Data sent in 1 h (GB)0.2880.6041.4583.0195.791
Data sent in 2 h (GB)0.5751.2072.9065.97611.648
Table 4. How many resources each Unity and MATLAB application used on both computers.
Table 4. How many resources each Unity and MATLAB application used on both computers.
Unity Editor-Meca500Unity Editor-ReemanMATLAB-Meca500MATLAB-Reeman
Consumer-Grade ComputerMin CPU30.1%24.9%1.5%27.9
Max CPU35.7%27.1%3.8%37.3
Min RAM753.3 MB539.7 MB1.63 GB1.711 GB
Max RAM763.1 MB744.5 MB1.66 GB1.751 GB
Min GPU43.9%45%N/AN/A
Max GPU56.8%52%N/AN/A
Professional-Grade computerMin CPU27%22.5%1.4%36.9%
Max CPU30.1%25.6%2.8%43.1%
Min RAM1.314 GB1.316 GB1.752 GB1.814 GB
Max RAM1.314 GB1.316 GB1.761 GB1.837 GB
Min GPU10.6%7.1%N/AN/A
Max GPU32%24.2%N/AN/A
Table 5. Benefits and disadvantages of integrating Firebase and MQTT with PUN.
Table 5. Benefits and disadvantages of integrating Firebase and MQTT with PUN.
ProtocolBenefitsDrawbacks
MQTTLocal communication.
Lightweight process.
Faster communication.
No added latency from network.
Users can perform analysis independently.
Requires all connected PCs to run MATLAB.
Additional strain on all computers.
FirebaseOnly one computer needs MATLAB.
Users with weak hardware can join simulation.
Synchronized data for all users.
Little additional programing.
Data streams cause additional strain on network.
Users must take turns sending data.
Limited Firebase data usage.
Possible latency in communication.
MQTT and FirebaseOffers flexibility to the user.
Supports diverse range of users.
No interference between protocols.
Increased development complexity.
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Haces-Garcia, A.; Zhu, W. Building an Accessible and Flexible Multi-User Robotic Simulation Framework with Unity-MATLAB Bridge. Computers 2024, 13, 282. https://doi.org/10.3390/computers13110282

AMA Style

Haces-Garcia A, Zhu W. Building an Accessible and Flexible Multi-User Robotic Simulation Framework with Unity-MATLAB Bridge. Computers. 2024; 13(11):282. https://doi.org/10.3390/computers13110282

Chicago/Turabian Style

Haces-Garcia, Arturo, and Weihang Zhu. 2024. "Building an Accessible and Flexible Multi-User Robotic Simulation Framework with Unity-MATLAB Bridge" Computers 13, no. 11: 282. https://doi.org/10.3390/computers13110282

APA Style

Haces-Garcia, A., & Zhu, W. (2024). Building an Accessible and Flexible Multi-User Robotic Simulation Framework with Unity-MATLAB Bridge. Computers, 13(11), 282. https://doi.org/10.3390/computers13110282

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop