Finding the Way in Maze (MATLAB task)
The first step in carrying out a task is its preparation. For the task of finding a way through the labyrinth, a configurable maze is prepared in the virtual environment of the laboratory. This maze can be changed using the maze generation feature in the UI in the settings, under the "Generate" button (see picture below this paragraph). In order to work with the created maze, it needs to be saved in a text file. This can be done using the save maze function located under the "Save maze" button. Next, it is necessary to move the rover to the initial position from which it will search for a path. To do this, you can use the teleport function, which is also found in UI in settings. Now it is convenient to save the entire configuration using the "Save" button for future use.The second step is to create a function in MATLAB to find the path and to send commands to the rover model to execute. The path finding task is solved by initializing the maze from a text file to a matrix and then introducing a state space to evaluate the best path. The resulting path is then converted into commands for the rover. This is done by analyzing the path created and using conditions to determine the direction.
The last step is to send the created commands via the UDP server to the rover application, but in the right order and at the right moment. To move the rover, the commands of the highest level of wheel control (movement by squares and rotation by degrees) are used. In order for the commands to go at the right time, the "IsReady" command is used, which checks if the rover is ready to continue after the movement. Figure below this paragraph shows an example of the command sending function. After each command, the rover is checked every 0.25 seconds to see if it is ready to continue. Now everything is ready and you only need to turn on the server using the switch in the settings and run the program.