Visualizing The LiDAR Data

You’ve setup your robot and remote PC, now the fun begins. Let’s visualize the robot laser data!

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:

ROS_MASTER_URI=http://localhost:11311

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:

export ROS_MASTER_URI=http://ubuntu:11311

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.

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:

rostopic list

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

Which shows:

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

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!

Leave a Reply

Your email address will not be published. Required fields are marked *