## 3 Marker-Assisted Region Scanning
### Update Robot State
Algorithm 2 describes the simulation's execution flow, divided into six stages. The algorithm starts with initializing the simulation environment and instantiating the robot, with its properties specific to each map, including LiDAR range, obstacle avoidance distance, motor speed parameters, and a conversion factor for meters to pixels. During the simulation, the robot captures user events, clears the screen, updates its position, detects obstacles, updates movement control, and maps the environment. In each iteration, the robot is graphically rendered on the screen, and the map display is updated, providing a visual representation of the navigation progress. ```
1:simulation environment initialization [Section 4.1]
2:robot instantiation [Section 4.2]
3:while simulation running do
4: capture user events
5: clear the screen
6: robot position update [Section 4.3]
7: detect obstacles [Section 4.4]
8: movement control update [Section 4.5]
9: environment mapping [Section 4.6]
10: render robot on the screen
11: update map display
12:endwhile
13:endsimulation
```
**Algorithm 2** MARS-SLAM Simulation

### Simulation Environment Initialization

The virtual environment used in MARS-SLAM simulations is generated from a grayscale PNG image, with dimensions of 900 by 1600 pixels. Each pixel of the image corresponds to a unique coordinate in the simulated environment, representing a position on the map that the robot will explore. The image is loaded and processed by the simulator, which interprets the different grayscale values to define the navigability of the environment. White pixels (255, 255, 255) indicate free areas, where the robot can move without restric

Figure 4: The set of images shows the process of locating the optimized path using the pose list. The goal is to identify a path from the red star (starting point) to the blue star (target point). The red points represent the list of posed already traversed by the robot. The green path represents the currently constructed route. tions, while black pixels (0, 0, 0) represent obstacles on the map, marking regions where the robot cannot enter. Among the various mapping techniques, metric maps stand out for their detailed and precise nature [36]. Metric maps provide a detailed representation of the environment's geometry, describing the shape, dimensions, and arrangement of objects. Metric maps are essential in robotics for describing the environment's geometry with high accuracy. Mathematically, a metric map is modeled as a matrix where each cell, or pixel, represents a specific state of the environment. This text describes how a metric map works, focusing on the mathematical representation and the states of the pixels. A metric map is represented as a matrix \(M\) of size \(m\times n\), where each element \(M_{ij}\) represents a cell in the environment. The cell \(M_{ij}\) can be in one of three states:

* Free (White \(\mid\) 255, 255, 255): The cell is free of obstacles. * Occupied (Black \(\mid\) 0, 0, 0): The cell contains an obstacle. * Unknown (Gray \(\mid\) 150, 150, 150): The state of the cell has not been determined. By using this image as a base, the simulator transforms the graphical representation into a coordinate grid, where each pixel is associated with a cell in the occupancy map. This approach allows the robot to accurately locate its position in the environment and update the map according to the explored or avoided areas. The simulation platform allows real-time graphical rendering of the environment and the robot. The map image is loaded into memory, and its visualization is configured so that the regions explored by the robot during the simulation are overlaid on the base map. Thus, the exploration progress is displayed in real time, with the path traveled and the mapped areas highlighted. ### Robot Instantiation

The robot is modeled based on a simple kinematic system, where the left and right motor speeds control its direction and linear velocity. The initial speed of both motors is set as \(vL,vR\), while the maximum configured speed is \(vM\).