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

Using the Hokuyo Sensor with ROS on the Raspberry Pi Varanon Austin Pukasamsombut 留学生 Field Robotics Group, Tohoku University Prof. Yoshida Kazuya, Assoc

Embed Size (px)

Citation preview

Page 1: Using the Hokuyo Sensor with ROS on the Raspberry Pi Varanon Austin Pukasamsombut 留学生 Field Robotics Group, Tohoku University Prof. Yoshida Kazuya, Assoc

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

Page 2: Using the Hokuyo Sensor with ROS on the Raspberry Pi Varanon Austin Pukasamsombut 留学生 Field Robotics Group, Tohoku University Prof. Yoshida Kazuya, Assoc

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• Hokuyo UST-20LX Sensor with Ethernet Cable Connection• (Other sensor models should work as well)

UST-20LX

Page 3: Using the Hokuyo Sensor with ROS on the Raspberry Pi Varanon Austin Pukasamsombut 留学生 Field Robotics Group, Tohoku University Prof. Yoshida Kazuya, Assoc

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.

Page 4: Using the Hokuyo Sensor with ROS on the Raspberry Pi Varanon Austin Pukasamsombut 留学生 Field Robotics Group, Tohoku University Prof. Yoshida Kazuya, Assoc

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

Page 5: Using the Hokuyo Sensor with ROS on the Raspberry Pi Varanon Austin Pukasamsombut 留学生 Field Robotics Group, Tohoku University Prof. Yoshida Kazuya, Assoc

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

Page 6: Using the Hokuyo Sensor with ROS on the Raspberry Pi Varanon Austin Pukasamsombut 留学生 Field Robotics Group, Tohoku University Prof. Yoshida Kazuya, Assoc

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

Page 7: Using the Hokuyo Sensor with ROS on the Raspberry Pi Varanon Austin Pukasamsombut 留学生 Field Robotics Group, Tohoku University Prof. Yoshida Kazuya, Assoc

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.

Page 8: Using the Hokuyo Sensor with ROS on the Raspberry Pi Varanon Austin Pukasamsombut 留学生 Field Robotics Group, Tohoku University Prof. Yoshida Kazuya, Assoc

Understanding the Data [UST 20LX]

Measurement Steps: 1081Detection Angle: 270°Angular Resolution: 0.25°

The data from the sensor is put into two arrays.• ranges[ ] //Range = Distance• intensities [ ]

Every “step” is 0.25°. [Look At Image]• Step 0 = 0° • Step 540 = 135° [Front of UST]• Step 1080 = 270°

270°

A Full 270 ° scan will have 1081 steps. So the arrays have a size of 1081. ranges[0], ranges[1], …. ranges[1080]

For example, to find the distance and intensity directly in front of the UST sensor, use: float distance_front = ranges[540]; float intensity_front = intensities[540];*Information on reading the sensor data can also be

found on the sensor’s data sheet.

Page 9: Using the Hokuyo Sensor with ROS on the Raspberry Pi Varanon Austin Pukasamsombut 留学生 Field Robotics Group, Tohoku University Prof. Yoshida Kazuya, Assoc

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.

Page 10: Using the Hokuyo Sensor with ROS on the Raspberry Pi Varanon Austin Pukasamsombut 留学生 Field Robotics Group, Tohoku University Prof. Yoshida Kazuya, Assoc
Page 11: Using the Hokuyo Sensor with ROS on the Raspberry Pi Varanon Austin Pukasamsombut 留学生 Field Robotics Group, Tohoku University Prof. Yoshida Kazuya, Assoc

Test Code Output

Page 12: Using the Hokuyo Sensor with ROS on the Raspberry Pi Varanon Austin Pukasamsombut 留学生 Field Robotics Group, Tohoku University Prof. Yoshida Kazuya, Assoc

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.

Page 13: Using the Hokuyo Sensor with ROS on the Raspberry Pi Varanon Austin Pukasamsombut 留学生 Field Robotics Group, Tohoku University Prof. Yoshida Kazuya, Assoc

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:

[email protected]

End

Varanon Austin Pukasamsombut 留学生Field Robotics Group, Tohoku University

Prof. Yoshida Kazuya, Assoc. Prof. Keiji Nagatani May 12, 2015