Vous êtes sur la page 1sur 13

Using the Hokuyo Sensor

with ROS on the Raspberry Pi

Varanon Austin Pukasamsombut 留学生


Field Robotics Group, Tohoku University
Prof. Yoshida Kazuya, Assoc. Prof. Keiji Nagatani May 12, 2015
Basics
Required Skills:
• Basic Knowledge of C++
• Experience with the ROS system on the Raspberry Pi
http://wiki.ros.org/
My Methods:
• Raspberry Pi Model B+ running Raspbian
• ROS Indigo installed from Source UST-20LX

• Hokuyo UST-20LX Sensor with Ethernet Cable Connection


• (Other sensor models should work as well)
Installation
First install the following ROS packages:
• hokuyo_node [Main sensor package]
• http://wiki.ros.org/hokuyo_node
• urg_node [Updated version for newer sensor models]
• http://wiki.ros.org/urg_node

If you are using a new Hokuyo sensor model (ex. UST-20LX), use
urg_node. If you are using an older model that has a USB interface, you
will only need the hokuyo_node package.
Connecting the UST-20LX to the Raspberry Pi
• If you are using a Hokuyo Sensor with an Ethernet cable (UST-20LX),
connect it to the Raspberry Pi’s Ethernet port. You will need to edit
“/etc/network/interfaces” and add a static IP address for the eth0
port.
“192.168.0.10” is the default IP address
for the Hokuyo Sensor. So to use a static
IP address to connect with the Raspberry
Pi, use “192.168.0.XX” .
The last two digits should be different
from “10”.
Confirm the connection by pinging the sensor.
$ ping 192.168.9.10
Obtain Data from the Hokuyo Sensor
• Once you have powered the Hokuyo Sensor and properly established
connection to the Raspberry Pi, use urg_node to obtain data from the
Hokuyo Sensor through ROS.
$ rosrun urg_node urg_node _ip_address:=192.168.0.10

• If you cannot connect and get an error message, make sure that you
are connected to the Hokuyo Sensor (ping 192.168.0.10).
Connecting other Hokuyo Models
• If the Hokuyo connects via USB, it should automatically be able to
connect to the Raspberry Pi by just plugging it in.

• You can then use hokuyo_node to connect


to the sensor. You may need to change the
default parameters to connect.
http://wiki.ros.org/hokuyo_node
Reading Data from the Hokuyo Sensor
• If you successfully connect, open a new terminal window and type:
$rostopic echo /scan
to see the data from the sensor. (However, it will be too fast to read.)

• This image shows the


message details of the scan.

• Ranges and Intensities are


defined as arrays.
Understanding the Data [UST 20LX]
The data from the sensor is put into two arrays.
• ranges[ ] //Range = Distance
270° • intensities [ ]
Every “step” is 0.25°. [Look At Image]
• Step 0 = 0°
• Step 540 = 135° [Front of UST]
• Step 1080 = 270°
0° A Full 270 ° scan will have 1081 steps.
So the arrays have a size of 1081.
ranges[0], ranges[1], …. ranges[1080]
Measurement Steps: 1081 For example, to find the distance and intensity
Detection Angle: 270° directly in front of the UST sensor, use:
Angular Resolution: 0.25° float distance_front = ranges[540];
*Information on reading the sensor data can also be
found on the sensor’s data sheet.
float intensity_front = intensities[540];
Writing C++ Code to Obtain the Data in your
own ROS program.
• To obtain the sensor data in your own program, just subscribe to “/scan”.
• This is a basic ROS concept that can be learned from the wiki page.
http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29
• Make sure to also properly update your CMake and package files.

My sensor test code to obtain the Distance and Intensity of the front of the sensor
is shown in the next slide.
Test Code Output
Other Notes
• If you are using both USB and the Ethernet cable at the same time to
connect to an ip address, one will stop the other. To avoid this, enable
hotplug for both ports in /etc/network/interfaces.
End

More information and instructions for using urg_node and


hokuyo_node can be found on their respective wiki pages on
the ROS site.

If you have any questions, feel free to contact me at:


austinpuk@gmail.com

Varanon Austin Pukasamsombut 留学生


Field Robotics Group, Tohoku University
Prof. Yoshida Kazuya, Assoc. Prof. Keiji Nagatani May 12, 2015

Vous aimerez peut-être aussi