Updated on November 13, 2019
Visualizing The LiDAR Data On Your Mapping Robot
You’ve setup your robot and remote PC, now the fun begins. Let’s visualize the robot laser data on our autonomous LiDAR mapping robot!
If you’ve not already done so, power up your robot, initialize it and run the mapping script (see our Tutorials for more details). With the robot now running (and the on-robot lidar device scanning), follow this procedure:
First, make sure that the remote PC is configured to work with your robot. Switch to your remote PC and open up a terminal window in Ubuntu. In the terminal, type:
env | grep ROS
In our example, here is what we got:
From this, we can see that our remote PC is currently configured to work with a ROS master that would be located on the same machine. Specifically, the line:
That shows us that this host expects to find its ROS master locally. Well, that’s not how we want to work with our robot (we want to make our robot the ROS master). So let’s go ahead and change that, by running the following command:
The above command tells our remote PC that the ROS master is to be found on the host with the hostname ‘ubuntu’. So now, when we run ROS commands, these commands will go to our robot (whose default name is: ubuntu). If you have renamed your robot, you will want to replace the robot name with whatever name you used.
Examining ROS Topics
Having configured our remote PC to use the robot as the ROS master, let’s quickly examine what ROS topics are being published by our robot:
The above command yields the following response:
This lists out several ROS topics that are running, including the ‘/scan’ topic which is where our laser data is presented. Let’s have a quick look at that laser data, by typing the following:
rostopic echo /scan
That’s the tail end of a ROS topic ‘/scan’ showing the data point “intensities”. We’ll skip over the details of just what that is.
Visualizing the LiDAR Data
For now, let’s visualize the scan data in the graphical package RViz, by typing:
rosrun rviz rviz
This will start the ROS RViz program, where we will be visualizing the robot laser data from our autonomous lidar mapping robot…
If all went well, you should be seeing something similar to the above. If not, you will want to check your ROS connectivity (see our Tutorials for more details). Enjoy!