智能机器人(23):Hokuyo 激光雷达Laser Sensor
II — Adding a Hokuyo Laser to your Turtlebot – URG
This assumes that you have a TurtleBot which has already been brought up.
1. Setup udev
Create the file /etc/udev/rules.d/50-laser.rules, add the following to it:
KERNEL==”ttyACM[0-9]*”, MODE=”0777″
or,
$ sudo echo ‘KERNEL==”ttyACM[0-9]*”, MODE=”0777″‘ >> /etc/udev/rules.d/50-laser.rules
Restart udev to take on the new rules with:
$ sudo /etc/init.d/udev restart
2. Now plug in your laser.
Check it’s file permissions. They should be read/write/execute for all.
Start by listing the permissions of the Hokuyo:
$ ls -l /dev/ttyACM0
— 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 not:
$ sudo chmod a+rw /dev/ttyACM0
3. Edit your turtlebot description
$ roscd turtlebot_description
Edit ./urdf/turtlebot_library.urdf.xacro , add the laser to the robot model, add the following right above the tag
NOTE:
The stock files will have your kinect’s virutal laser scan publishing on the same topic that other tutorials want to use,
and I would rather the laser data would come from the hokuyo laser.
This can be prevented by changing the topic that the Kinect laser publishes on with the following:
$ vi turtlebot_bringup/launch/3dsensor.launch
edit 3dsensor.launch and look for the line that looks like this:
Remove it and replace it with:
Then edit minimal.launch, for we now need to add the hokuyo node to it.
At the bottom of the file right before , add the following:
This should bring up the hokuyo node when you launch it.
4. Bringup your new config
$ roslaunch turtlebot_bringup minimal.launch
— process[laser_driver-9]: started with pid [8288]
In another terminal, you can bring up the kinect sensor by running:
$ roslaunch turtlebot_bringup 3dsensor.launch
5. Check your results with rviz
Now run rviz. You should now have a block that appears on your turtlebot.
Add two LaserScan visuilizations.
Subscribe one of them to the /kinect_scan topic and set it’s Color to “2; 255; 255”
Subscribe the other topic to /scan. Leave it’s Color “255; 255; 255″
III — Adding Hokuyo Laser Range Finder to Turtlebot
Keyword: Hokuyo Node (UTM-04G)
Add Hokuyo laser range finder (LRF) sensor to TurtleBot, explains how to write URDF description of the Hokuyo LRF, modify the URDF of the Turtlebot robot to account for the addition of the Hokuyo sensor.
Hokuyo LRF added on top of the Turtlebot.
http://www.iroboapp.org/index.php?title=File:Hokuyo_Turtlebot.jpg
1 Hokuyo-Related Pre-required
UTM-04G is a laser scanner that can scan with an opening up to 270 degrees with a range up to 4 meters.
Alough TurtleBot comes with the Kinect sensor that has a laser scanner with a scan opening up to 57 degrees with practical range of 3 meters.
Hokuyo LRF is more accurate than the Kinect sensor and it would be more useful in making maps with gmapping and SLAM applications.
ROS provides a driver for Hokyuo LRF, referred to as urg_node, install the urg_node as follows:
$ sudo apt-get install ros-indigo-urg-* <— this is special for URG class It is also possible to use the hokuyo_node and for this you need to install hokuyo_node as follows: $ sudo apt-get install ros-indigo-hokuyo-node Here we used later Hokuyo node. hokuyo_node Published Topics on /scan. The Command-Line Tools getID program can be used to get information about a hokuyo laser scanner: $ rosrun hokuyo_node getID /dev/ttyACM0 — Device at /dev/ttyACM0 has ID H0807228 or, in a script friendly way: $ rosrun hokuyo_node getID /dev/ttyACM0 — — H0807228 2 udev rules The getID program can be used to get the hardware ID of a Hokuyo device given its port. Combined with udev, this allows a consistent device name to be given to each device, even if the order in which they are plugged in varies. On the PR2 we use the following udev rule: SUBSYSTEMS==”usb”, KERNEL==”ttyACM[0-9]*”, ACTION==”add”, ATTRS{idVendor}==”15d1″, ATTRS{idProduct}==”0000″, MODE=”666″, PROGRAM=”/opt/ros/indigo/lib/urg_node/getID /dev/%k q”, SYMLINK+=”sensors/hokuyo_%c”, GROUP=”dialout” This udev rule sets up a device name that is based on the Hokuyo’s hardware ID. The PR2 then has a symlink to that name that gets changed if the Hokuyo is replaced: $ ls -l /etc/ros/sensors/base_hokuyo — lrwxrwxrwx 1 root root 28 2010-01-12 15:53 /etc/ros/sensors/base_hokuyo -> /dev/sensors/hokuyo_H0902620
$ ls -l /dev/sensors/hokuyo_H0902620
— lrwxrwxrwx 1 root root 10 2010-04-12 12:34 /dev/sensors/hokuyo_H0902620 -> ../ttyACM1
3 Setting
After the installation of above package is completed, we should now make the changes in Turtlebot URDF.
Two things: one is description about Hokuyo that is in meshes folder, and other is the defining join with its location and its relation with parent frame (joint).
3.1 First we should add the hokuyo.dae file into /opt/ros/indigo/share/turtlebot_description/meshes folder. need administrative and write privileges to do it . These meshes file contain all the properties that are needed to define hokuyo_node.
3.2 Then add and edit the Hokuyo URDF file
First go the folder /opt/ros/hydro/share/turtlebot_description/urdf/sensors , and , create a new file called as hokuyo.urdf.xacro(administrative privileges to do)
$ sudo vi hokuyo.urdf.xacro
The code focuses on two things:
the one is description about Hokuyo that is in meshes folder. hokuyo.dae,
the other is the defining join with its location and its relation with parent frame (joint).
For finding the location of hokuyo sensor, you may need to calculate the location that will be in meters and the representation is in x,y,z .
Turtlebot assumes 0 0 0 at it base center, like blow.
Above Collision do provide the opportunity to take a decision before going to collide.In above code we have defined collisions for more explanation look into Adding Collisions.It is necessary to set the parameters to avoid collisions.
Above code, first thing we did is specifying the joint name that is Hokuyo (but can be changed to any other thing), the type we select as fixed then we defined where the Hokuyo is attached with respect to origin,
Next thing the joints are defined by parent and child, You can also specify some fixed frame like map or base_footprint or make it link to default parent
4. Add Hokuyo URDF description to Turtlebot URDF description
In order to be Hokuyo a part of URDF description, we need to add Hokuyo LRF description to the Turtlebot URDF so that it can be visualized in rivz and other simulators. For that purpose, go to the folder /opt/ros/indigo/share/turtlebot_description/urdf and add the following line in turtlebot_library.urdf.xacro file:
$ vi turtlebot_library.urdf.xacro
add:
Above will call the hokuyo description created in urdf.
In order to launch the description , it is just required to launch mininal.launch and it will work.
NOTE:
In order to see a hokuyo sensor in rviz we need to add its definition in gazebo, but not covered here,
but can be borrowed from Building Visual Robot:
http://wiki.ros.org/urdf/Tutorials/Building%20a%20Visual%20Robot%20Model%20with%20URDF%20from%20Scratch
5. Create Launch File for Hokuyo Node
Its is better to create a Hokuyo Launch file in order to launch the Hokuyo node.
It will also allow Hokuyo node dynamic re-configuration of Hokuyo node.
$ vi hokuyo.launch
6. Use SLAM With Hokuyo LIDAR Sensor
利用hokuyo laser创建地图. In order to use Hokuyo for SLAM as described in tutorial Building SLAM, following below:
a)
$ roslaunch turtlebot_bringup minimal.launch
b)run the Hokuyo node
$ roslaunch turtlebot_test_launch hokuyo.launch
c) Launch the gmapping for map building
$ roslaunch turtlebot_navigation gmapping_demo.launch
d) View the map at workstation using rviz
$ roslaunch turtlebot_rviz_launchers view_navigation.launch
e)
$ roslaunch turtlebot_teleop keyboard_teleop.launch
f) 地图构建完成之后保存 :
$ rosrun map_server map_saver -f /tmp/my_map
已知地图下的自动导航:
a)
$ roslaunch turtlebot_navigation amcl_demo.launch map_file:=/tmp/my_map.ymal
b)
$ roslaunch turtlebot_rviz_launchers view_navigation.launch
c) 2D Pose Estimate
d) 2D Nav Goal
ABOVE REF:
http://www.iroboapp.org/index.php?title=Adding_Hokuyo_Laser_Range_Finder_to_Turtlebot
REF:
http://www.voidcn.com/blog/jie_sky_2015/article/p-5698136.html
http://wiki.ros.org/turtlebot/Tutorials/hydro/Adding%20a%20Hokuyo%20laser%20to%20your%20Turtlebot
IIII —
1. 创建串口别名
a)
$ lsusb
— Bus 001 Device 006: ID 15d1:0000
确认idVendor和idProduct,ID后面的部分idVendor:idProduct.
b)
新建 /etc/udev/rules.d/hokuyo.rules文件,内容如下:(别名为hokuyo,实际名称为:/dev/hokuyo)
KERNEL==”ttyACM[0-9]*”, ACTION==”add”, ATTRS{idVendor}==”15d1″, MODE=”0666″, GROUP=”dialout”, SYMLINK+=”hokuyo”
c)
增加当前用户对串口的默认访问权限:
$ sudo usermod -a -G dialout 用户名
d)
使UDEV配置生效:(使串口的默认访问权限生效,需要重启机器)
$ sudo service udev reload
$ sudo service udev restart
2. 制作驱动的启动文件
复制hokuyo_node的hokuyo_test.launch到hokuyo_laser.launch,并增加TF定义
$ roscd turtlebot_navigation
$ mkdir -p laser/driver
$ sudo cp ~/turtlebot_ws/src/hokuyo_node/hokuyo_test.launch laser/driver/hokuyo_laser.launch
打开hokuyo_laser.launch,并修改
$ vi turtlebot_navigation hokuyo_laser.launch
检查frame_id是否指定为laser
查看port是否指定正确端口,使用别名
检查端口:,设置好别名,或直接端口/dev/ttyACM0
增加TF:
修改为args=”0.0 0.0 0.18 0 0.0 0.0 为自己的实际安装位置。详情查看,static_transform_publisher部分
static_transform_publisher x y z qx qy qz qw frame_id child_frame_id period_in_ms
这里假设底盘的中心点为0,雷达放在机器人托盘中心位置,X为0,高度为18CM,Z为0.18m, TF的单位使用米的,测量单位是CM
完整代码如下:
增加hokuyo_gmapping_demo.launch文件,用于启动gmapping.
$ roscd turtlebot_navigation
$ touch launch/hokuyo_gmapping_demo.launch
$ vi launch/hokuyo_gmapping_demo.launch
FOCUS: 设置laser_type为hokuyo.
增加hokuyo_gmapping.launch.xml文件,执行gmapping建图
$ roscd turtlebot_navigation
$ touch launch/includes/gmapping/hokuyo_gmapping.launch.xml
$ vi launch/includes/gmapping/hokuyo_gmapping.launch.xml
测试激光雷达gmapping构建地图
启动turtlebot
$ roslaunch turtlebot_bringup minimal.launch
启动gmapping,用于构建地图
$ roslaunch turtlebot_navigation hokuyo_gmapping_demo.launch
启动键盘操作Turtlebot
$ roslaunch turtlebot_teleop keyboard_teleop.launch
启动rviz,实时查看建图情况
$ roslaunch turtlebot_rviz_launchers view_navigation.launch
保存地图
$ rosrun map_server map_saver -f /tmp/hokuyo_gmapping
利用地图进行AMCL
REF 3:
http://www.ncnynl.com/archives/201611/1097.html
V —
others topic to be viewed:
http://amanbreakingthings.blogspot.hk/2014/11/adding-hokuyo-lidar-to-turtlebot-in-ros.html
http://www.iheartrobotics.com/2012/03/in-stock-even-more-turtlebot.html