# Auto-explore
The auto-explore sample enables a wheeled robot to build a 2D map automatically.
The sample uses an RPLIDAR A3M1 to get the surrounding obstacle edge information, takes the partial map to determine the potential goals, and publishes messages of target point to control the robot complete mapping. The robot will return to the configured starting point after completing the mapping.
The figure shows the pipeline of the auto-explore sample.
- Five ROS nodes build a complete `tf` tree: `map->odom->base_footprint->base_link->laser`.
- The `auto-explore` sets the target point according to the map information given by `slam_gmapping` and the obstacle edge information given by `rplidar`.
- Then, `nav2_bringup` plans the path and sends the velocity and angular to the robot.

**Figure : Auto-explore pipeline**
For information on the ROS nodes and topics used in the pipeline flow, see [Pipeline flow for auto-explore](https://docs.qualcomm.com/doc/80-70017-265/topic/auto-explore_5_3_5.html#pipeline-autoexplore).
## Use cases
**Prerequisites:**
- The QIRP SDK and dependencies are installed, see [Build the software](https://docs.qualcomm.com/doc/80-70017-265/topic/build-the-software_4_1.html#build-the-software-4-1) and [Flash and install](https://docs.qualcomm.com/doc/80-70017-265/topic/flash-and-install_4_3.html#flash-and-install-4-3).
- `SSH` is enabled in ‘Permissive’ mode with the steps mentioned in [Log in using SSH](https://docs.qualcomm.com/bundle/publicresource/topics/80-70017-254/how_to.html#use-ssh).
- The RPLIDAR A3M1 is available.
- The slam-gmapping function is enabled with the steps in [Generate and install slam-gmapping IPKs](https://docs.qualcomm.com/doc/80-70017-265/topic/generate-and-install-slam-gmapping-ipks_5_1_2.html#generate-and-install-slam-gmapping-ipks-5-1-2).
**Case 1: Run out-of-the-box auto-explore**
**Steps:**
The sample follows this node sequence.
qti-robot-amr-ctrl
rplidar-ros2
slam-gmapping
nav2-bringup
auto-explore
rviz2
Copy to clipboard
1. Connect the RPLIDAR A3M1 and boot up your robot.
2. Start five terminals, and run the following commands in each terminal to set up QIRP SDK and ROS2 environment on the device.
Value range of `ROS_DOMAIN_ID`: [0, 232].
ssh root@[ip-addr]
(ssh) mount -o remount,rw /usr
(ssh) export HOME=/home
(ssh) source /usr/share/qirp-setup.sh
(ssh) source /usr/bin/ros_setup.bash
(ssh) export ROS_DOMAIN_ID=xx
Copy to clipboard
Note
In the following steps 3 to 7, each step is run in a separate terminal window that is set up in this step.
3. In terminal 1, launch the `qti_robot_amr_ctrl` node.
(ssh) ros2 launch qti_robot_amr_ctrl qti_robot_amr_ctrl.launch.py
Copy to clipboard
Note
Replace this step with your robot bring-up commands.
4. In terminal 2, launch the `rplidar_ros` node.
(ssh) ros2 launch rplidar_ros rplidar_a3_launch.py
Copy to clipboard
5. In terminal 3, launch the `slam_gmapping` node.
(ssh) source /usr/share/slam_gmapping/local_setup.bash
(ssh) ros2 launch slam_gmapping slam_gmapping.launch.py
Copy to clipboard
6. In terminal 4, launch the `nav2_bringup` node.
(ssh) ros2 launch nav2_bringup navigation_launch.py 'use_sim_time:=false'
Copy to clipboard
7. In terminal 5, run `auto-explore`.
(ssh) cd /usr/lib/auto-explore
(ssh) chmod 777 auto-explore
(ssh) ./auto-explore
Copy to clipboard
The following log is shown in the terminal.
Once the map is created completely, it is automatically saved in the path `/usr/share/auto-explore` on your device.

8. To show the result in Rviz2 on your Ubuntu PC, perform the following configurations.
1. Install Rviz2 according to [Install Rviz2](https://docs.qualcomm.com/doc/80-70017-265/topic/install-rviz2_5_1_3.html#install-rviz2-5-1-3).
2. Select the frame as `/map`.
3. Add `/map`, `/scan`, `/plan`, `/received_global_plan`,
`goal_pose` by topic.
4. Add `TF`, `Grid` by display type.

Table : Default configuration and output file for auto-explore
| Files | Default path | Description |
| --- | --- | --- |
| Configuration file | /usr/share/auto-explore/Configuration/aeconfiguration.yaml
Copy to clipboard |
The .yaml file contains information about the auto-explore algorithm.
The .pgm file stores the map image.
Executes path planning according to the subscribed-to /goal_pose ROS topic.
Publishes the /cmd_vel ROS topic to the robot.