hokuyo激光雷达

Published: by Creative Commons Licence

hokuyo开发

hokuyo+Ubuntu16.04

Created 2018.09.19 by William Yu; Last modified: 2018.09.20-V1.0.2

Contact: windmillyucong@163.com

Copyleft! 2018 William Yu. Some rights reserved.


激光雷达(hokuyo)

型号UTM-30LX

hokuyo

Ubuntu1604安装Hokuyo

1.安装过程参考

carto@cartoPC:~/laser_ws$ cd src
carto@cartoPC:~/laser_ws/src$ mkdir hokuyo
carto@cartoPC:~/laser_ws/src$ cd hokuyo
carto@cartoPC:~/laser_ws/src/hokuyo$ git clone https://github.com/ros-drivers/driver_common.git
carto@cartoPC:~/laser_ws/src/hokuyo$ cd driver_common/driver_base
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_base$ mkdir build
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_base$ cd build
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_base/build$  cmake ..
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_base/build$ make
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_base/build$ sudo make install


carto@cartoPC:/$ cd ~/laser_ws
carto@cartoPC:~/laser_ws$ cd src
carto@cartoPC:~/laser_ws/src$ git clone  https://github.com/ros/genmsg.git
carto@cartoPC:~/laser_ws/src$ cd genmsg
carto@cartoPC:~/laser_ws/src/genmsg$ mkdir build
carto@cartoPC:~/laser_ws/src/genmsg$ cd build
carto@cartoPC:~/laser_ws/src/genmsg/build$ cmake ..
carto@cartoPC:~/laser_ws/src/genmsg/build$ make
carto@cartoPC:~/laser_ws/src/genmsg/build$ sudo make install

carto@cartoPC:~/laser_ws/src/genmsg/build$ cd ../../
carto@cartoPC:~/laser_ws/src$ cd hokuyo/driver_common/driver_base
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_base$ cd build
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_base/build$ cmake ..
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_base/build$ make
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_base/build$ sudo make install

carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_base/build$ cd ../../
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common$ cd driver_common
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_common$ mkdir build
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_common$ cd build
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_common/build$ cmake ..
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_common/build$ make
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_common/build$ sudo make install
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_common/build$ cd ../../
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common$ cd timestamp_tools
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/timestamp_tools$ mkdir build
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/timestamp_tools$ cd build
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/timestamp_tools/build$ cmake ..
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/timestamp_tools/build$ make
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/timestamp_tools/build$ sudo make install



carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/timestamp_tools/build$ cd ~/laser_ws
carto@cartoPC:~/laser_ws$ cd src/hokuyo
carto@cartoPC:~/laser_ws/src/hokuyo$ git clone https://github.com/ros-perception/laser_proc.git
carto@cartoPC:~/laser_ws/src/hokuyo$ git clone https://github.com/ros-drivers/urg_c.git
carto@cartoPC:~/laser_ws/src/hokuyo$ git clone https://github.com/ros-drivers/hokuyo_node.git


carto@cartoPC:~/laser_ws/src/hokuyo$ cd hokuyo_node
carto@cartoPC:~/laser_ws/src/hokuyo/hokuyo_node$ mkdir build
carto@cartoPC:~/laser_ws/src/hokuyo/hokuyo_node$ cd build
carto@cartoPC:~/laser_ws/src/hokuyo/hokuyo_node/build$ rosdep install --from-paths ~/laser_ws/src --ignore-src
我的路径是rosdep install --from-paths ~/code/ros/hokuyo_ws/src --ignore-src
#All required rosdeps installed successfully
carto@cartoPC:~/laser_ws/src/hokuyo/hokuyo_node/build$ catkin_make - DCATKIN_WHITELIST_PACKAGES="hokuyo_node"
Base path: /home/carto/laser_ws/src/hokuyo/hokuyo_node/build
The specified source space "/home/carto/laser_ws/src/hokuyo/hokuyo_node/build/src" does not exist
=====================场面一度比较尴尬===========================


carto@cartoPC:~/laser_ws/src/hokuyo/hokuyo_node/build$ cd ~/laser_ws
carto@cartoPC:~/laser_ws$ catkin_make install
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make install -j4 -l4" failed
====================场面接着十分尴尬====================

carto@cartoPC:~/laser_ws$ cd src/hokuyo/laser_proc
carto@cartoPC:~/laser_ws/src/hokuyo/laser_proc$ mkdir build
carto@cartoPC:~/laser_ws/src/hokuyo/laser_proc$ cd build
carto@cartoPC:~/laser_ws/src/hokuyo/laser_proc/build$ cmake ..
carto@cartoPC:~/laser_ws/src/hokuyo/laser_proc/build$ make
carto@cartoPC:~/laser_ws/src/hokuyo/laser_proc/build$ sudo make install



carto@cartoPC:~/laser_ws/src/hokuyo/laser_proc/build$ cd ../../
carto@cartoPC:~/laser_ws/src/hokuyo$ cd hokuyo_node
carto@cartoPC:~/laser_ws/srcarto@cartoPC:~/laser_ws$ cd src
carto@cartoPC:~/laser_ws/src$ mkdir hokuyo
carto@cartoPC:~/laser_ws/src$ cd hokuyo
carto@cartoPC:~/laser_ws/src/hokuyo$ git clone https://github.com/ros-drivers/driver_common.git
carto@cartoPC:~/laser_ws/src/hokuyo$ cd driver_common/driver_base
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_base$ mkdir build
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_base$ cd build
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_base/build$  cmake ..
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_base/build$ make
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_base/build$ sudo make install


carto@cartoPC:/$ cd ~/laser_ws
carto@cartoPC:~/laser_ws$ cd src
carto@cartoPC:~/laser_ws/src$ git clone  https://github.com/ros/genmsg.git
carto@cartoPC:~/laser_ws/src$ cd genmsg
carto@cartoPC:~/laser_ws/src/genmsg$ mkdir build
carto@cartoPC:~/laser_ws/src/genmsg$ cd build
carto@cartoPC:~/laser_ws/src/genmsg/build$ cmake ..
carto@cartoPC:~/laser_ws/src/genmsg/build$ make
carto@cartoPC:~/laser_ws/src/genmsg/build$ sudo make install

carto@cartoPC:~/laser_ws/src/genmsg/build$ cd ../../
carto@cartoPC:~/laser_ws/src$ cd hokuyo/driver_common/driver_base
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_base$ cd build
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_base/build$ cmake ..
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_base/build$ make
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_base/build$ sudo make install

carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_base/build$ cd ../../
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common$ cd driver_common
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_common$ mkdir build
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_common$ cd build
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_common/build$ cmake ..
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_common/build$ make
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_common/build$ sudo make install
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/driver_common/build$ cd ../../
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common$ cd timestamp_tools
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/timestamp_tools$ mkdir build
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/timestamp_tools$ cd build
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/timestamp_tools/build$ cmake ..
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/timestamp_tools/build$ make
carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/timestamp_tools/build$ sudo make install



carto@cartoPC:~/laser_ws/src/hokuyo/driver_common/timestamp_tools/build$ cd ~/laser_ws
carto@cartoPC:~/laser_ws$ cd src/hokuyo
carto@cartoPC:~/laser_ws/src/hokuyo$ git clone https://github.com/ros-perception/laser_proc.git
carto@cartoPC:~/laser_ws/src/hokuyo$ git clone https://github.com/ros-drivers/urg_c.git
carto@cartoPC:~/laser_ws/src/hokuyo$ git clone https://github.com/ros-drivers/hokuyo_node.git


carto@cartoPC:~/laser_ws/src/hokuyo$ cd hokuyo_node
carto@cartoPC:~/laser_ws/src/hokuyo/hokuyo_node$ mkdir build
carto@cartoPC:~/laser_ws/src/hokuyo/hokuyo_node$ cd build
carto@cartoPC:~/laser_ws/src/hokuyo/hokuyo_node/build$ rosdep install --from-paths ~/laser_ws/src --ignore-src
我的路径是rosdep install --from-paths ~/code/ros/hokuyo_ws/src --ignore-src
#All required rosdeps installed successfully
carto@cartoPC:~/laser_ws/src/hokuyo/hokuyo_node/build$ catkin_make - DCATKIN_WHITELIST_PACKAGES="hokuyo_node"
Base path: /home/carto/laser_ws/src/hokuyo/hokuyo_node/build
The specified source space "/home/carto/laser_ws/src/hokuyo/hokuyo_node/build/src" does not exist
====================场面接着十分尴尬====================


carto@cartoPC:~/laser_ws/src/hokuyo/hokuyo_node/build$ cd ~/laser_ws
carto@cartoPC:~/laser_ws$ catkin_make install
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make install -j4 -l4" failed
====================场面接着十分尴尬====================

carto@cartoPC:~/laser_ws$ cd src/hokuyo/laser_proc
carto@cartoPC:~/laser_ws/src/hokuyo/laser_proc$ mkdir build
carto@cartoPC:~/laser_ws/src/hokuyo/laser_proc$ cd build
carto@cartoPC:~/laser_ws/src/hokuyo/laser_proc/build$ cmake ..
carto@cartoPC:~/laser_ws/src/hokuyo/laser_proc/build$ make
carto@cartoPC:~/laser_ws/src/hokuyo/laser_proc/build$ sudo make install



carto@cartoPC:~/laser_ws/src/hokuyo/laser_proc/build$ cd ../../
carto@cartoPC:~/laser_ws/src/hokuyo$ cd hokuyo_node
carto@cartoPC:~/laser_ws/src/hokuyo/hokuyo_node$ cd build
carto@cartoPC:~/laser_ws/src/hokuyo/hokuyo_node/build$ rosdep install --from-paths ~/laser_ws/src --ignore-src
#All required rosdeps installed successfully



carto@cartoPC:~/laser_ws/src/hokuyo/hokuyo_node/build$ cd ~/laser_ws
carto@cartoPC:~/laser_ws$ catkin_make installc/hokuyo/hokuyo_node$ cd build
carto@cartoPC:~/laser_ws/src/hokuyo/hokuyo_node/build$ rosdep install --from-paths ~/laser_ws/src --ignore-src
#All required rosdeps installed successfully



carto@cartoPC:~/laser_ws/src/hokuyo/hokuyo_node/build$ cd ~/laser_ws
carto@cartoPC:~/laser_ws$ catkin_make install

2.总结脚本一枚

https://github.com/YuYuCong/Scripts/blob/master/shell/install_laser_hokuyo-UTM-30LX_in_ubuntu1604.sh

可自行下载安装!上述安装过程的错误基本修复!


Configuring the Hokuyo 配置

1.配置环境变量

$ vim ~/.zshrc #由于我使用的是zsh
#末尾添加一句
source /home/will/code/ros/hokuyo_ws/devel/setup.zsh #注意改成自己的路径
#然后保存退出
$ source ~/.zshrc

2.链接串口

Make sure that the hokuyo_node will be able to access the Hokuyo laser scanner.

Start by listing the permissions of the Hokuyo:

$ ls -l /dev/ttyACM0

You will see something similar to:

$ crw-rw-XX- 1 root dialout 166, 0 2009-10-27 14:18 /dev/ttyACM0

If XX is rw: the laser is configured properly.

If XX is –: the laser is not configured properly and you need to:

$ sudo chmod a+rw /dev/ttyACM0

临时修改,开机后清除。

$ ls -l /dev/ttyACM0
$ sudo chmod a+rw /dev/ttyACM0

永久修改

$ sudo cp 20-urglidar.rules /etc/udev/rules.d/
$ sudo /etc/init.d/udev restart

rviz显示雷达数据

180923-23:00:03.png

  1. 打开一个新终端,运行hokuyo_node节点
$ source ~/catkin_ws/devel/setup.bash
$ rosrun hokuyo_node hokuyo_node
  1. 打开一个新终端,查看是否正常接收雷达数据
$ source ~/catkin_ws/devel/setup.bash
$ rostopic echo /scan
  1. 在rviz中显示/laser_scan消息包含雷达数据点,打开一个新终端,运行rviz
$ surce ~/catkin_ws/devel/setup.bash
$ rosrun rviz rviz
  1. 添加/laser_scan消息并以点云的形式显示出来

– 点击rviz左下角Add,添加LaserScan;

– 点击Global Option下方的Fixed Frame,将右边的参数改为laser;

– 点击LaserScan下面的Topic,改为/scan;

– 点击LaserScan下面的Style,改为Point;

– 一切正常的话结果如上图所示。


References

See also


Contact

Feel free to contact me anytime for anything.


License

CC0