## 3 Marker-Assisted Region Scanning
### Update Robot State
This process is repeated for all measurements within the defined field of view, ensuring the robot has a clear and updated view of nearby obstacles. The detection is continuous, allowing the robot to adjust its path as necessary to avoid collisions. The obstacle position information is then used by the robot's control system to efficiently avoid obstacles. ### Movement Control Update

The robot's movement control is based on the angular speeds of the wheels: \(vR\) (right wheel) and \(vL\) (left wheel). This control is adjusted according to obstacle detection and autonomous navigation using the MARS-SLAM method. The robot alternates between avoiding obstacles and navigating toward predefined markers, depending on environmental conditions. Initially, the algorithm checks if the mapping process has been completed. If the mapping is complete, the robot stops its movement, setting \(vR\) and \(vL\) to zero. If the mapping is still ongoing, the robot continues navigating by adjusting its movement according to the marker position and obstacles in the environment. This control mechanism allows the robot to follow the exploration strategy and avoid obstacles simultaneously, ensuringthat the robot navigates smoothly through the environment while maintaining safety and efficient exploration. ### Environment Mapping

During navigation, the robot uses the LiDAR sensor to scan its surrounding environment. This mapping process involves continuous data capture, which are stored in a dataframe, serving as the main repository of simulation data. Each row in the dataframe records a state of the robot at a given time instance, including information such as position, orientation, and LiDAR readings. The structure of these data allows for a detailed analysis of the robot's behavior over time and enables precise tracking of the environment's exploration. The LiDAR performs measurements within a 180-degree field of view, ranging from \(-90^{\circ}\) to \(+90^{\circ}\) relative to the robot's current orientation. At each simulation step, a set of distance readings is generated, where each reading corresponds to the distance to the nearest obstacle along a specific direction. These readings, along with the robot's coordinates \((x,y)\) and its orientation \((\theta)\), are stored in the dataframe, which is updated at each simulation step. The captured data include:

* Distance readings: The distances measured by the LiDAR to the detected obstacles along each scan angle. * Coordinates \((x,y)\): The robot's actual position in the environment. * Orientation \((\theta)\): The angle representing the robot's direction. * Timestamp: A time record that allows synchronization and temporal analysis of the data. The data collected by the LiDAR are used to build a grid map of the environment. This map is composed of pixels where white pixels represent free space and black pixels represent obstacles. For each LiDAR measurement, the distance to the nearest obstacle and the corresponding scan angle (relative to the robot's orientation) are used to calculate the position of the obstacle. The position of the obstacle is determined using the following equations:

\[x_{o}=x_{p}+d\cdot\cos(\theta_{p}+\alpha) \tag{4}\] \[y_{o}=y_{p}+d\cdot\sin(\theta_{p}+\alpha),\]

where \(d\) is the distance measured by the LiDAR, \(\alpha\) is the scan angle, \((x_{p},y_{p})\) are the coordinates of the pose, \(\theta_{p}\) is the orientation of the pose. After calculating the position of the obstacle, a line of free space is drawn from the pose's coordinates to the obstacle. This line draws each pixel along the path as free (white). This ensures that the robot has clear information about the explored areas without obstacles. Once the free space is marked, the position of the obstacle is updated in the grid map by marking a black point at the calculated obstacle position. This point represents the detected obstacle at that particular scan angle. This process is repeated for every LiDAR measurement at each pose.