智能机器人(22):Hokuyo激光雷达urg_node方式

像 Hokuyo UST 10LX 这款比较新,urg_node支持不完善.
出了问题也搜不到办法。以下是经历。所以还是不要贪新。

1. 整体

The Hokuyo UST-10LX scanning laser rangefinder is a small, accurate, high-speed device for obstacle detection and localization of autonomous robots and automated material handling systems. This model uses Ethernet interface for communication and can obtain measurement data in a wide field of view up to a distance of 10 meters with millimeter resolution.

There are two cables – the ethernet and the a power cable. The power cable as 6 wires .
The ethernet wire is used for data reading and it can be connected to ethernet port of the pc.
For power, just connect the constant DC power supply to the corresponding pins and don’t connect the rest of the pins.
Then you can use “urg_node” package of ros for getting started with UST-10lx.

1.1 说明书
The main specifications are: supply voltage 10-30 V, measurement distance 10 m, field view 270° and interface Ethernet. The main features are: Extremely small and light-weight (130 g). Mid-detection range (10 m), wide detection angle (270°), fast response 25msec, high angular resolution (0.25°).
Detection range: 0.06m to 10m
Repeated accuracy: σ < 30mm (*1) Measurement steps: 1081 Scan angle: 270° Scan speed: 25ms (Motor speed 2400rpm) Angular resolution: 0.25° Brown: VIN+ 12/24 VDC Blue: VIN- IP Initial value : ip addr: 192.168.0.10 netmask: 255.255.255.0 gateway: 192.168.0.1 Port number:10940 To reset IP address to the factory default value: – connect IP RESET LINE to COM- for more than 2 sec. Light Blue: IP Reset Input Gray: COM- 1.2 指标说明 http://wiki.ros.org/hokuyo_node?action=AttachFile&do=view&target=URG-Series_SCIP2_Compatible_Communication_Specification_ENG.pdf pic. Measurement details: The scanner rotates in an anti-clockwise direction when viewed from top. Detection Range (E degree) is maximum angle the sensor scans for measurement. such as E = 270 degree. Angular Resolution is defined as the 360degree divided by the Slit Division (F). such as F = 1080. steps Measurement points are called Steps. Step 0 is the first measurement point. such as 0. Step A is the initial measurement point in the detection range. Step B is the sensor front step. Step C is the end point of the detection range. Step D is the last measurement point. 2. 测试网络连接 2.1 上电 找到个充电器, 刚好12V@1000mA。 加电。 把雷达的rj45接头插到笔记本的网口。 2.2 网络配置 ust-10LX 修改电脑的IP地址, 添加静态地址: $ sudo gedit /etc/network/interfaces 在 auto lo iface lo inet loopback 下面添加: auto eth0 allow-hotplug eth0 iface eth0 inet static address 192.168.0.17 netmask 255.255.255.0 gateway 192.168.0.1 2.3 测试 $ ping 192.168.0.10 PING 192.168.0.10 (192.168.0.10) 56(84) bytes of data. From 192.168.0.17 icmp_seq=1 Destination Host Unreachable From 192.168.0.17 icmp_seq=2 Destination Host Unreachable From 192.168.0.17 icmp_seq=3 Destination Host Unreachable … 不通。 2.4 尝试1 估计是雷达以前用过,被改过。 作初始化,把reset脚和com-脚短接十秒钟, 即亮蓝色和棕色。 按照产品说明,这样激光雷达应该是 192.168.0.10。 $ ping 192.168.0.10 From 192.168.0.17 icmp_seq=1 Destination Host Unreachable …依旧不同。 2.5 尝试2 找个路由器, 有个cisco的。 把ust 10LX和笔记本都经由网线连接到router, 在电脑扫描活动主机: $ sudo nmap -sP -PI -PT 192.168.1.0/24 Nmap scan report for 192.168.1.100 Host is up (0.00025s latency). MAC Address: 00:1D:XX:11:11:XX (Hokuyo Automatic Co.) 竟是1.100, 不清楚为什么硬件reset没有复位到10。 2.6. 测试连接 修改电脑网络: auto lo iface lo inet loopback auto eth0 allow-hotplug eth0 iface eth0 inet static address 192.168.1.17 netmask 255.255.255.0 gateway 192.168.1.1 auto wlan0 iface wlan0 inet dhcp 测试连接: $ ping 192.168.1.100 PING 192.168.1.100 (192.168.1.100) 56(84) bytes of data. 64 bytes from 192.168.1.100: icmp_seq=1 ttl=64 time=0.300 ms okay了。 3. 测试ros驱动 3.1 驱动 UST-10LX采用以太网接口,用的是新的驱动 – urg_node, 所以下载urg_node包: $ sudo apt-get install ros-indigo-urg-node 3.2 获取激光雷达数据 $ roscore $ rosrun urg_node urg_node _ip_address:=”192.168.1.100″ [ INFO] [1492741119.560309968]: Connected to network device with intensity and ID: H15309XY [ INFO] [1492741119.605980211]: Streaming data. 3.3 查看激光雷达检测数据 $ rostopic echo /scan header: seq: 2620 stamp: secs: 1492743470 nsecs: 716067997 frame_id: laser angle_min: -2.35619449615 angle_max: 2.35619449615 angle_increment: 0.00436332309619 time_increment: 1.73611151695e-05 scan_time: 0.0250000003725 range_min: 0.019999999553 range_max: 30.0 ranges: [ 3.4 激光雷达扫描的消息类型和消息结构 $ rostopic type /scan sensor_msgs/LaserScan $ rosmsg show sensor_msgs/LaserScan uint32 seq time stamp string frame_id float32 angle_min float32 angle_max float32 angle_increment float32 time_increment float32 scan_time float32 range_min float32 range_max float32[] ranges float32[] intensities 3.5 可配置参数 $ rosparam list urg_node /urg_node/angle_max /urg_node/angle_min /urg_node/cluster /urg_node/frame_id /urg_node/ip_address /urg_node/skip /urg_node/tf_prefix /urg_node/time_offset $ rosparam get urg_node/frame_id frame_id $ rosparam get urg_node/ip_address 192.168.1.100 3.6 launch中配置参数 Here using dynparam from a launch file. You can use dynparam with the set_from_parameter command to set parameters of an already running node from a launch file. For example to set the hokuyo scanning range

3.7 源代码中配置参数
Using dynamic_reconfigure from code
Python code:
import dynamic_reconfigure.client
rospy.init_node(‘myconfig_py’, anonymous=True)
client = dynamic_reconfigure.client.Client()
params = { ‘my_string_parameter’ : ‘value’, ‘my_int_parameter’ : 5 }
config = client.update_configuration(params)

C++ code:
system(“rosrun dynamic_reconfigure dynparam set_from_parameters camera_synchronizer_node narrow_stereo_trig_mode 3”);

3.8 在rviz中查看激光数据:
$ rosrun rviz rviz
Add中依次添加LaserScan和话题/scan下的LaserScan

7. 应用案例 – 在turtlebot建图

7.3 准备激光模型 – hokuyo.urdf.xacro文件
Add new file:
$ sudo vi /opt/ros/indigo/share/turtlebot_description/urdf/sensors/hokuyo.urdf.xacro
为hokuyo.urdf.xacro添加以下内容

< /robot>

以上turtlebot_library.urdf.xacro文件的代码主要是添加一个laser的joint和base_laser_link的link,维护一个单独的文件是考虑良好扩展性, 当然也可以直接硬编码写到下面的turtlebot_library.urdf.xacro 文件里面。

7.4 Add LiDAR to robot
修改机器人模型 – turtlebot_library.urdf.xacro ,把激光模型 – hokuyo.urdf.xacro添加进去
$ sudo vi /opt/ros/indigo/share/turtlebot_description/urdf/turtlebot_library.urdf.xacro
最下面添加

7.2 修改urdf模型,添加雷达sensor_hokuyo NOT needed in slam.
添加雷达的连接
$ sudo vi /opt/ros/indigo/share/turtlebot_description/robots/kobuki_hexagons_kinect.urdf.xacro

< xacro:include filename=”$(find turtlebot_description)/urdf/turtlebot_library.urdf.xacro” /> ————-

< stack_hexagons parent=”base_link”/>

< /robot>
其中:
< xacro:include filename=”$(find turtlebot_description)/urdf/turtlebot_library.urdf.xacro” />加载
增加

7.1 launch文件添加urg_node驱动
添加hokuyo的节点, edit minimal.launch to add laser node, for we now need to add the hokuyo node to it.
$ sudo vi /opt/ros/indigo/share/turtlebot_bringup/launch/minimal.launch
< !– remap from=”scan” to=”base_scan” ==This is no longer needed / –>
< /node>
This should bring up the hokuyo node when you launch it.
其中:,检查frame_id是否指定为base_laser_link.
其中:包括激光雷达的ip地址,连接端口,坐标系的转换关系,检测角度范围,具体的范围值可以算一遍。这款雷达的测量角度范围是270°,那么一边的测量范围就是π*270/180/2.

7.5 修改代价地图的参数
$ sudo vi /opt/ros/indigo/share/turtlebot_navigation/param/costmap_common_param.yaml
修改后
observation_sources: hokuyo kinect bump
hokuyo:
data_type: LaserScan
#topic: /hokuyo_urg_node/scan
topic: scan
marking: true
clearing: true
# min was 0.25 and max was 0.35 changed to fix hokuyo lidar
min_obstacle_height: 0.0
max_obstacle_height: 0.5
raytrace_range: 10.0 #override range for this sensor
obstacle_range: 10.0 #override range for this sensor
kinect:
data_type: LaserScan
#topic: /camera/camera_nodelet_manager/scan
topic: kinect_scan
marking: false
clearing: false
# min was 0.25 and max was0.35
min_obstacle_height: 0.0
max_obstacle_height: 0.5
bump:
data_type: PointCloud2
topic: mobile_base/sensors/bumper_pointcloud
marking: true
clearing: false
min_obstacle_height: 0.0
max_obstacle_height: 0.15

7.6 修改完成后就可以按照正常的步骤进行建图
建图:
on robot
$ roslaunch turtlebot_bringup minimal.launch
$ roslaunch turtlebot_navigation gmapping_demo.launch
on pc
$ roslaunch turtlebot_rviz_launchers view_navigation.launch
$ roslaunch turtlebot_teleop keyboard_teleop.launch

on robot
$ rosrun map_server map_saver -f /tmp/my_map

导航:
on robot
$ roslaunch turtlebot_bringup minimal.launch
$ roslaunch turtlebot_navigation amcl_demo.launch map_file:=/tmp/my_map.yaml
on pc
$ roslaunch turtlebot_rviz_launchers view_navigation.launch –screen

总结

利用激光雷达导航

1. 初级方法

不在机器人模型urdf里面添加雷达模型,通过一个通过静态tf变换实现

1.1 Launch文件用于加载node驱动 – hokuyo_laser.launch
$ vi hokuyo_laser.launch

1.2 建图的配置文件 – hokuyo_gmapping.launch.xml

—指定topic为scan

1.3 建图的启动文件中加载hokuyo_laser.launch驱动 – hokuyo_gmapping_demo.launch


— 指定参数

— 加载驱动

1.4 建图
$ roslaunch turtlebot_bringup minimal.launch
$ roslaunch turtlebot_navigation hokuyo_gmapping_demo.launch
$ roslaunch turtlebot_teleop keyboard_teleop.launch
$ roslaunch turtlebot_rviz_launchers view_navigation.launch
$ rosrun map_server map_saver -f /tmp/hokuyo_gmapping

2. 中级方法

在机器人模型urdf中直接添加激光雷达。

2.1 把激光雷达加入机器人模型
$ roscd turtlebot_description
$ sudo cp urdf/turtlebot_library.urdf.xacro urdf/turtlebot_library.urdf.xacro.bak
$ sudo vi urdf/turtlebot_library.urdf.xacro
—————–指定关节
——关节父
—–关节子
———————-指定躯干

2.2 在minimal.launch中加载node驱动
$ sudo vi /opt/ros/indigo/share/turtlebot_bringup/launch/minimal.launch
—————指定框架为激光雷达< !– remap from=”scan” to=”base_scan” ==This is no longer needed / –>
< /node>

2.2.a — 修改代价地图参数 —
$ sudo vi /opt/ros/indigo/share/turtlebot_navigation/param/costmap_common_params.yaml
observation_sources: hokuyo kinect bump
hokuyo:
data_type: LaserScan
#topic: /hokuyo_urg_node/scan
topic: scan
marking: true
clearing: true
kinect:
data_type: LaserScan
#topic: /camera/camera_nodelet_manager/scan
topic: kinect_scan
marking: false
clearing: false
bump:
data_type: PointCloud2
topic: mobile_base/sensors/bumper_pointcloud
marking: true
clearing: false

2.3 建图
$ roscore
$ roslaunch turtlebot_bringup minimal.launch
$ roslaunch turtlebot_navigation gmapping_demo.launch
$ roslaunch turtlebot_rviz_launchers view_navigation.launch
$ roslaunch turtlebot_teleop keyboard_teleop.launch
$ rosrun map_server map_saver -f /tmp/my_map

3. 高级方法

在机器人模型中加入激光雷达模型。

3.1 借用雷达模型文件 – hokuyo.dae file
Copy the hokuyo.dae file from driver to /opt/ros/indigo/share/turtlebot_description/meshes folder.
$ sudo cp …..somewhere/hokuyo.dae /opt/ros/indigo/share/turtlebot_description/meshes

3.2 新建激光雷达URDF模型 – hokuyo.urdf.xacro
$ sudo vi /opt/ros/indigo/share/turtlebot_description/urdf/sensors/hokuyo.urdf.xacro


———-


————— ——————“base_laser_link” ———-指定躯干

—– 指定mesh文件

—————– “laser”——–指定关节

————躯干父
—————– “base_laser_link” ——躯干子

以上turtlebot_library.urdf.xacro的代码主要是添加一个laser的joint和kink。
维护一个单独的文件是考虑良好扩展性。
当然, 也可以直接硬编码写在机器人模型turtlebot_library.urdf.xacro 文件里面。

3.3 把雷达模型加入机器人模型
修改机器人模型 – turtlebot_library.urdf.xacro ,把激光模型 – hokuyo.urdf.xacro添加进去
In order to be Hokuyo a part of URDF robot description, need to add Hokuyo LRF description to Turtlebot URDF so that it can be visualized in rivz and other simulators.

$ sudo vi /opt/ros/indigo/share/turtlebot_description/urdf/turtlebot_library.urdf.xacro
最下面添加:
—–加载模型

3.4 加载雷达node驱动
单独文件的话,可以建一个Launch来加载Hokuyo Node driver:
$ vi hokuyo.launch

这样单独一个文件单独启动是没问题,
但是更正常做法是从minimal.launch文件里面加载node driver。

Edit minimal.launch to add laser node:
$ sudo vi /opt/ros/indigo/share/turtlebot_bringup/launch/minimal.launch
—————指定框架
< !– remap from=”scan” to=”base_scan” ==This is no longer needed / –>
< /node>

3.5 修改代价地图参数
$ sudo vi /opt/ros/indigo/share/turtlebot_navigation/param/costmap_common_param.yaml
observation_sources: hokuyo kinect bump
hokuyo:
data_type: LaserScan
#topic: /hokuyo_urg_node/scan
topic: scan
marking: true
clearing: true
kinect:
data_type: LaserScan
#topic: /camera/camera_nodelet_manager/scan
topic: kinect_scan
marking: false
clearing: false
bump:
data_type: PointCloud2
topic: mobile_base/sensors/bumper_pointcloud
marking: true
clearing: false

3.5 建图
$ roslaunch turtlebot_bringup minimal.launch
$ roslaunch turtlebot_test_launch hokuyo.launch ———–if necessory
$ roslaunch turtlebot_navigation gmapping_demo.launch
$ roslaunch turtlebot_rviz_launchers view_navigation.launch
$ roslaunch turtlebot_teleop keyboard_teleop.launch
$ rosrun map_server map_saver -f /tmp/my_map

0 回复

发表评论

Want to join the discussion?
Feel free to contribute!

发表评论