Найти в Дзене

Software package for simulation modeling of mobile robots

Maksim Kuprin1[0000-0001-6183-092X], Igor Osipov1[0000-0002-8884-4421], Arkady Klyuchikov2[0000-0002-8657-6486], Nikita Samokhin1[0000-0001-7998-7079] 1Yuri Gagarin State Technical University of Saratov, 77 Politekhnicheskaya, Saratov, 410054, Russia 2 Saratov State University of Genetics, Biotechnology and Engineering named after N.I. Vavilov, Theatre Sq. 1, Saratov, 410012, Russia 1 kms0207@ya.ru, igoros7755@gmail.com, nikitasamokhin123@yandex.ru 2 Krok9407@mail.ru Abstract. In this article, the possibility of using Unity as a simulation environment for mobile robots is considered, the possibilities of Unity Editor for use in simulation modeling are determined. The possibility of using a standard set of development tools to simulate the behavior of mechanical connections, kinematic circuits and rigid body physics is evaluated. The architecture diagram of the developed simulation modeling system is compiled. The methods of implementation and functionality of simulating modules are des
Оглавление

Maksim Kuprin1[0000-0001-6183-092X], Igor Osipov1[0000-0002-8884-4421], Arkady Klyuchikov2[0000-0002-8657-6486], Nikita Samokhin1[0000-0001-7998-7079]

1Yuri Gagarin State Technical University of Saratov, 77 Politekhnicheskaya, Saratov, 410054, Russia

2 Saratov State University of Genetics, Biotechnology and Engineering named after N.I. Vavilov, Theatre Sq. 1, Saratov, 410012, Russia

1 kms0207@ya.ru, igoros7755@gmail.com, nikitasamokhin123@yandex.ru

2 Krok9407@mail.ru

Abstract. In this article, the possibility of using Unity as a simulation environment for mobile robots is considered, the possibilities of Unity Editor for use in simulation modeling are determined. The possibility of using a standard set of development tools to simulate the behavior of mechanical connections, kinematic circuits and rigid body physics is evaluated. The architecture diagram of the developed simulation modeling system is compiled. The methods of implementation and functionality of simulating modules are described, such as ModuleBaseScript for the simulation of rigid mechanical connections, HingeBaseScript for axial connections, ServoMotorScript and MotorBaseScript for electric motors and servos, respectively, MicrocontrollerBaseScript, GPIOBaseScript, DataTransferMasterScript for microcontrollers, MotorDriverScript for electric motor drivers, RangeFinderBaseScript for rangefinders and DataTransferSlaveScript for transmission protocols data. The received package of tools was tested, a virtual model of a mobile robot with a rangefinder was created. The shortcomings of the project have been identified and ways to solve problems have been proposed.

Keywords: simulation modeling, computer modeling, mobile robots, physics engine, Unity.

1 Introduction

Currently software tools are used to design each stage in the development of robotic systems, for example, creating drawings, 3d models of parts and elements, prototyping electronic circuits of the hardware, mathematical calculations, modeling of individual elements of a robot and testing the algorithms of the software component of the robotic complex. [1-2] In total these processes are used in simulation modeling.

Specialized programming software is used for simulation modeling process visualization. For this purpose, it is possible to use game engines. The most popular engines are Unity and Unreal Engine. Based on research findings [3-4], it is possible to use Unity to design simplified robotic systems for educational purposes.

2 Problem statement

In connection with the identified need for simulation in the field of designing mobile robots, a theoretical goal was set to study the possibility of using Unity as a simulation environment for mobile robots. The following tasks have been set:

· recreate close to realistic behavior of mechanics and electronics;

· develop microcontroller programming interface;

· develop a flexible system of settings for the elements of the simulated platform;

· provide a base of prepared elements with the possibility of creating extensions;

· develop data transfer protocols;

· develop odometry, measuring through sensors.

3 Analysis of the possibilities of using Unity game engine for the design of simulation systems

Unity is a cross-platform game engine for the development of 2D and 3D games and applications, but developers create plugins for robot modeling based on it [5]. NASA Curiosity rover simulation [6], 3D-planning system of 2014 Winter Olympics [7], US Navy Virtual Training [8] have been developed and used for research purposes.

Component-based development is used in Unity environment. Object properties on scene are defined by components. Default Unity tool kit is not sufficient to solve the problem, but it is possible to create your own components in Unity. C# and JavaScript are used for script programming.

One of the criteria affecting the quality of simulation modeling of robotic systems is the realism and accuracy of physical calculations. Unity uses the PhysX engine to determine the interaction of three-dimensional bodies and external forces of them [9]. PhysX has sufficient accuracy and stability to simulate simple robots [10-14]. Physical aspects are taken into account in the engine:

· rigidbody physics [15];

· collisions [16];

· joints [17];

· articulations [18].

Usage of these components, taking into account correlations and mathematical models of the system, allows to simulate mechanical joints of mobile robots and robot manipulators.

Standard Unity tools cannot simulate electronic parts, microcontrollers, electric motors and data transfer protocols. It is necessary to create specialized scripts that expand the capabilities of the development environment to simulate the hardware.

4 Architecture of the design system for simulation modeling of mobile robots

The development of the mechanical system of a robot is a time-consuming process and transferring into a development environment requires a number of additional steps. Specialized modules were developed in Unity for automation of adding and configuring mechanical joints. This script system allows you to simulate a mobile robotic system. The architecture scheme of the design system for simulation modeling of mobile robotic systems is shown in Figure 1.

Fig. 1. Architecture scheme
Fig. 1. Architecture scheme

5 Development of modules for simulating the mechanical part of a robotic complex

ModuleBaseScript and HingeBaseScript were developed as base modules to simplify user experience.

ModuleBaseScript connects two objects by fixing their position relative to each other. Logic is developed by using Fixed joint [19] component. If the connected elements do not have a RigidBody component, it will be added automatically by the RequireComponent [20] attribute.

HingeBaseScript connects two objects by creating an axial joint between them with one degree of freedom. Functioning is developed using Hinge joint [21].

When the scene is launched, these elements are added to all the necessary components and set the values of the joint parameters.

Using the Hinge joint allows you to simulate the rotation of a motor or servo. The component has the ability to adjust the torque and achieve the specified angular velocity or specified angle. Hinge joint also adjusts the restrictions on the angle of rotation of one body relative to another (Fig. 2).

Fig. 2. Hinge Joint set up
Fig. 2. Hinge Joint set up

Hinge joint has an excessive number of parameters. It makes the setup process time-consuming. For this reason, the scripts “ServoMotorScript'' and “MotorBaseScript” were developed. They simulate servo motor and electric motor.

The script “ServoMotorScript” accesses GPIOScript by using object reference to GPIO and receives port values with PortPWMId number. The resulting value is between 0 and 1 and used to calculate the end position of servo shaft. The required angle is the multiplication of control signal and the maximum angle of rotation of the shaft.

MotorBaseScript sets up Motor, maximum angular speed, torque and receives a control signal from the electric motor driver using “motorDriver” object reference. The multiplication of the control signal and the maximum angular velocity is transferred to the “Target velocity” parameter.

A microcontroller is used to control the hardware of the robot. The module that simulates it has the following properties:

· control of external devices through GPIO ports;

· data transfer through special protocols;

· programming and interaction with external devices;

· time control using timers.

“MicrocontrollerBaseScript”, “GPIOBaseScript”, “DataTransferMasterScript” are used to create a simulation of a microcontroller.

MicrocontollerBaseScript is the base script for microcontroller simulation. The script contains GPIOBaseScript and DataTransferMasterScript object references, controlling GPIO ports and data bus and also processes an algorithm according to program code.

GPIOBaseScript is used to simulate the general purpose I/O interface. The script stores two arrays of values: digital ports and with the possibility of pulse-width modulation. GPIO communicates and receives signals from external devices. Any device connected to GPIO can get port value and/or write it.

DataTransferMasterScript and DataTransferSlaveScript allow transferring a text through a data bus. The script contains the list of devices connected to the bus. The master can request data from slave devices and send data back. DataTransferSlaveScrpit allows to receive data from the master and send data to the master on request.

Power control of motors in robots is implemented by using a set of power keys (motor driver). This module is implemented in the MotorDriverScript in the software package. It is used for generating a control signal for the electric motor. The script connects to the GPIO pins of the microcontroller and receives data from two digital and one PWM ports. The data is used to determine the direction and speed of rotation of the motor shaft (Fig. 3).

 Fig. 3. Motor driver set up
Fig. 3. Motor driver set up

Also, in the package there is the possibility of modeling a rangefinder. The "Physics" [22] class in Unity contains the "Raycast" [23] method, which allows to cast a ray from a point in space in a target direction to detect obstacles and a distance to them. RangeFinderBaseScript allows the use of Raycast to measure distances and transfer the values using the data transfer protocol.

6 Approbation of the software package on the example of a mobile robot with an ultrasonic rangefinder

The current version of the software package allows you to simulate simplified constructions of mobile robots and test programs for microcontrollers. A mobile robot was developed to test the package. It has a four-wheeled platform, a microcontroller, a display, a rangefinder, a servo motor, and four drivers (Fig. 4). А video [24] with a demonstration of the work of a virtual robot.

Fig. 4. Basic mobile robot
Fig. 4. Basic mobile robot

During the simulation and testing of the robot, the following disadvantages of the software package were identified:

· Unity standard tool kit doesn't provide enough information about joints during setting up. It can be difficult to determine the direction of rotation of the wheels during setting up their joint to the motor shaft;

· code for simulating the operation of the microcontroller and the robot control program are located in one file. It is necessary to copy the microcontroller script file to create a new robot program;

· it is impossible to simulate omnidirectional and “Mecanum wheel” operations.

Currently the directions for the development of the project have been determined and ways to solve existing problems have been proposed.

It is necessary to create arrows by Unity tools which indicate the direction of the axis and the direction of rotation of the motor shaft with a positive value of the control signal to fix the first problem. This solution will provide clarity and simplify the tuning of electric motors.

The second problem can be solved by splitting the microcontroller modeling script into two files. First defines the operation of the microcontroller, the second defines a robot controlling algorithm. It can reduce the dependence of variables and make the system more flexible.

7 Conclusion

The developed tools have sufficient functionality for modeling robotic systems. During the tests, disadvantages and limitations were found and ways of improving the software package were developed.

Moreover, for further improvement of the software packages, the following tasks were suggested:

· add to MotorBaseScript the ability to attach the Rigidbody component to the wheels automatically;

· develop new programming tools for microcontrollers that allow to create firmware without creating additional components;

· implement the possibility of hinged joints of bodies using Unity physics tools;

· develop a new component simulating a motor including encoders operations;

· develop a component simulating the functionality of stepper motors and servo drives;

· create a tool modeling different type of wheels.

References

1. Bräunl T (2020) «Robot adventures in Python and C». Springer, Berlin

2. Shuai Guo, Hua-Wei Li, Jian-Cheng Ji & Zhi-Fa Ming (07 December 2014)«Kinematic analysis and simulation of a new-type robot with special structure» Adv. Manuf. 2, 295–302 (2014). https://doi.org/10.1007/s40436-014-0094-x

3. Manyuxina A. N. Game engine usage for robotic devices modeling systems development, conference «Integraciya mirovyh nauchnyh protsessov kak osnova obshetvennogo progressa», 2015, pp. 131–137. (in Russian)

4. Pedro V. F. Zawadniak, Luis Piardi, Thadeu Brito, José Lima, Pedro Costa, André L. R. Monteiro, Paulo Costa, Ana I. Pereira «Micromouse 3D simulator with dynamics capability: a Unity environment approach» Research Article, SN Applied Sciences (2021)

5. Mokaeva A.A., Hamukov Y.H., Shautsukova L.Z. Kinematic scheme development of cable control system of “trunk” manipulator device, Izvestiya Kabardino-Balkarsky Scientific Center Russian Academy of Sciences, 2015, № 6. (in Russian)

6. Unity Powers NASA Virtual Mars Rover Experience [Online] // Unity Real-Time Development Platform | 3D, 2D VR & AR Engine. 2012. URL: https://unity.com/our-company/newsroom/unity-powers-nasa-virtual-mars-rover-experience. (accessed 05.09.2022)

7. Olympic 3D. The thorny path from the disclosure of sudden to the solution of the tasks of national projects. [Online] // CG EVENT — Main event in computer modeling sphere. URL: https://cgevent.ru/archives/8134 (accessed 05.09.2022) (in Russian)

8. Assembly/disassembly of the Navy - Heartwood drive [Online] // Train Faster, Smarter with Interactive Simulations URL: https://hwd3d.com/videos/navy-actuator-virtual-training/ (accessed 05.09.2022)

9. Unity - Manual: Physics [Online] // Unity - Manual: Unity User Manual 2021.3 (LTS). URL: https://docs.unity3d.com/2020.3/Documentation/Manual/PhysicsSection.html (accessed 06.09.2022) (in Russian)

10. A. Roennau, F. Sutter, G. Heppner, J. Oberlaender and R. Dillmann, “Evaluation of Physics Engines for Robotic Simulations With a Special Focus on the Dynamics of Walking Robots,” in International Conference on Advanced Robotics (ICAR), Montevideo, 2013.

11. Drumwright, E. An evaluation of methods for modeling contact in multibody simulation / E. Drumwright, D. Shell // IEEE Int. Conf. on Robotics and Automation, 2011. – P. 1695–1701.

12. Erez, T. Simulation Tools for Model-based Robotics: Comparison of Bullet, Havok, MuJoCo, ODE and PhysX / T. Erez,

13. Hummel J. An Evaluation of Open Source Physics Engines for Use in Virtual Reality Assembly Simulations

14. Seugling A. Evaluation of physics engines and implementation of a physics module in a 3d-authoring tool

15. Unity - Manual: Rigidbody [Online] // Unity User Manual 2021.3 (LTS). URL: https://docs.unity3d.com/Manual/class-Rigidbody.html (accessed 06.09.2022)

16. Unity - Manual: Introduction to collision [Online] // Unity User Manual 2021.3 (LTS) URL: https://docs.unity3d.com/Manual/CollidersOverview.html (accessed 06.09.2022)

17. Unity - Manual: Introduction to joints [Online] // Unity User Manual 2021.3 (LTS) URL: https://docs.unity3d.com/Manual/Joints.html (accessed 06.09.2022)

18. Unity - Manual: Introduction to physics articulations [Online] // Unity User Manual 2021.3 (LTS) URL: https://docs.unity3d.com/Manual/physics-articulations.html (accessed 06.09.2022)

19. Unity - Manual: Fixed Joint component reference [Online] // Unity User Manual 2021.3 (LTS) URL: https://docs.unity3d.com/Manual/class-FixedJoint.html (accessed 07.09.2022)

20. Unity - Scripting API: RequireComponent [Online] // Unity Scripting API 2021.3 (LTS) URL: https://docs.unity3d.com/ScriptReference/RequireComponent.html (accessed 07.09.2022)

21. Unity - Manual: Hinge Joint component reference [Online] // Unity User Manual 2021.3 (LTS) URL: https://docs.unity3d.com/2021.3/Documentation/Manual/class-HingeJoint.html (accessed 07.09.2022)

22. Unity - Scripting API: Physics [Online] // Unity Scripting API 2022.1 (LTS) URL: https://docs.unity3d.com/2022.1/Documentation/ScriptReference/Physics.html (accessed 08.09.2022)

23. Unity - Scripting API: Physics.Raycast [Online] // Unity Scripting API 2021.3 (LTS) URL: https://docs.unity3d.com/ScriptReference/Physics.Raycast.html (accessed 08.09.2022)

24. RSMA: Simple mobile robot [demonstration of the software package] // YouTube. September 24, 2022 (URL: https://www.youtube.com/watch?v=4CZjw4ji71s&t=50s)