Friday, March 24, 2023

Hector Slam Mapping and Indoor Positioning ROBOT with ROS and Lidar

Ashwini Kumar Sinha

- Advertisement -

ashwiniWhile 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.

Video Tutorial:

Bill of Materials 

- Advertisement -

To begin working on the project, shop the following components

Bill of material ros robot

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

cd YDLidar-SDK/build

cmake .


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

cd ~/ydlidar_ws


echo “source ~/ydlidar_ws/devel/setup.bash” >> ~/.bashrc 

source ~/.bashrc

cd ~/ydlidar_ws/src/ydlidar_ros_driver/startup

sudo chmod +x

sudo 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.

Hector slam for lidar scanning
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.

Lidar Mapping using ROS
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”

Map created by ROS abd Hector SLAM Robot
Fig 3. Map created by ROS and Hector SLAM robot
Ros Robot hector SLAM
Fig 4.Map created by ROS abd Hector SLAM robot
.Map created in Hector SLAM robot
Fig 5.Map created by ROS abd Hector SLAM robot



What's New @

Truly Innovative Tech

MOst Popular Videos

Electronics Components

Tech Contests