硬件:Hokuyo URG-04LX-UG01

OS: ROS indigo

$ sudo apt-get installros-indigo-hokuyo-node //安装hokuyo串口驱动

$ sudo apt-get installros-indigo-hector-slam //安装hector_slam

然后编写接收scan topic的hector_slam launch文件

tutorial.launch

<launch>

  <include file="$(find hector_mapping)/launch/mapping_default.launch">
    <arg name="base_frame" value="base_frame"/>
    <arg name="odom_frame" value="base_frame"/>  //要把odom值换成base_frame,这样就不需要odemetry,不然会报错
  </include>

  <include file="$(find hector_geotiff)/launch/geotiff_mapper.launch">
    <arg name="trajectory_source_frame_name" value="base_frame"/> 
  </include>

  <node pkg="tf" type="static_transform_publisher"       name="base_frame_to_laser_broadcaster" args="0 0 0 0 0 0 base_frame laser 100"/>

  <node pkg="rviz" type="rviz" name="rviz"
    args="-d $(find hector_slam_launch)/rviz_cfg/mapping_demo.rviz"/>

</launch>

编写完成后,运行:

$ roscore

打开另一个终端

$ source ~/catkin_ws/devel/setup.bash
$ rosrun hokuyo_node hokuyo_node

如果出错提示串口没有打开‘运行

$ sudo chmod a+rw /dev/ttyACM0

再运行以下命令行

$ls -l /dev/ttyACM0

出现以下信息则没问题了

·crw-rw-rw- 1 root dialout 166, 02009-10-27 14:18 /dev/ttyACM0

打开另一个终端

$ source ~/catkin_ws/devel/setup.bash
$ roslaunch laser tutorial.launch




更多推荐