Connecting Hokuyo URG-04lx laser scanner with ROS using hokuyo-node

Getting started with hokuyo laser scanner and ROS. Step-by-step guide to visualize the laser scan for the first time.

Recently, I was working with hokuyo 5m range indoor laser scanner. I had some problem while connecting my laser scanner to ROS for the first time. That’s why I am writing this tutorial to help you guys so that you don’t face the same problem again. We will take help from the official ROS webpage : http://wiki.ros.org/hokuyo_node/Tutorials

Step 1: The first step would be to update and upgrade your system by using the following commands.

sudo apt-get update

    sudo apt-get upgrade

Step 2: Assuming that ROS is already installed on your system and the ‘roscore’ command is working successfully, we will now install the ‘hokuyo_node’ package to be able to use the hokuyo in ROS. For this we will first install the ‘hokuyo_node’ package using the following command.

sudo apt-get install ros-distro-hokuyo-node

(Note: ‘distro’ specifies the version of ROS you are using, for e.g. if you are using ‘indigo’ version of ROS, then simply substitute ‘distro’ by ‘indigo’)

Once the package is successfully installed, turn on the laser scanner.

Step 3: Now the next step is to locate the serial port at which laser scanner is connected upon. You can either check it manually in Computer > dev > ttyACM0, or type the following command in the terminal.

ls -l /dev/ttyACM0

If you see something meaningful, then the laser scanner is connected to the system.

Step 4 : Next step is to configure laser scanner and give permission to hokuyo_node to access it. For this write the following command in the terminal.

sudo chmod 777 /dev/ttyACM0

With this the laser scanner is ready to use, and we can perform a check by doing the following.

Step A : Open a new terminal and type the following.

roscore

Step B: Run the hokuyo_node package by typing the following command in the terminal.

    rosrun hokuyo_node hokuyo_node

If you get the success message on the terminal saying “Connected to device with ID: ….”, then the laser scanner in working correctly and you can visualize the laser scanner data in rviz using the following command.

    rosrun rviz rviz

Set ‘Frame’ > /laser & ‘Topic’ > /scan, and you will see the scan data on the rviz window. You can alter the parameters on the left panel according to your requirements.

Hope you do good with hokuyo and hokuyo_node.