While various GPS-based maps facilitate autonomous robots and vehicles for accurate positioning when outdoors, they are unable to do the same indoors. Robots tasked with things like moving packets in a warehouse or floor cleaning robots cannot perform well without a real-time accurate mapping of rooms and buildings.
So in today’s project, we will counter that by devising a low-cost system for creating real-time maps of indoor environments. This will allow a robot to operate without collisions and navigate by avoiding any obstacles.
Bill of Materials
To begin working on the project, shop the following components
Preparing hector slam
Before installing the Hector SLAM, first, install the Robot Operating Software (ROS).
Read here to learn how to do so.
After preparing the ROS environment, install the drivers and SDK of LiDAR. If you are using the RPI Lidar, then no need to follow these steps. Instead, you can jump to installing the Hector SLAM. But if using the YD Lidar, then continue to the below steps.
Installing LIDAR SDK
git clone https://github.com/YDLIDAR/YDLidar-SDK
sudo make install
Next, create the ROS workspace for the LiDAR and then install the ROS driver using the following commands in the LXTerminal.
mkdir -p ~/ydlidar_ws/src
echo “source ~/ydlidar_ws/devel/setup.bash” >> ~/.bashrc
sudo chmod +x initenv.sh
sudo sh initenv.sh
Installing Hector Slam
Open a new LXTerminal and run the following command to install Hector SLAM.
sudo apt-get install ros-kinetic-hector-slam
The Hector SLAM is now ready. Modify some LiDAR settings in the lidar launch file for indoor positioning. To do so, first, go to the YD Lidar workspace and open the src file. Then open all_nodes.launch file and change the parameters as per the pic below.
Fig 1. Setting for Lidar
Connect the YD lidar to the USB of the RPi board, power it and obtain its desktop GUI.
For indoor robot positioning, run the following command in LXTerminal.
roslaunch ydlidar_ros_driver all_nodes.launch
You will then get a map of the robot’s current position and its surroundings.
Fig 2.Lidar mapping
To test the Hector SLAM and obtain a real-time map, run the following commands
roslaunch hector_slam_launch tutorial.launch
rosbag play Team_Hector_MappingBox_RoboCup_2011_Rescue_Arena.bag –clock
rostopic pub syscommand std_msgs/String “savegeotiff”
Fig 3. Map created by ROS and Hector SLAM robotFig 4.Map created by ROS abd Hector SLAM robotFig 5.Map created by ROS abd Hector SLAM robot