Hector_slam+Hokuyo建图
程序员文章站
2024-03-25 10:41:06
...
之前调试了hokuyo的激光传感器,但是当时只是得到了点云,没有具体生成地图,今天把这个问题解决了一下:
在正常生成点云的情况下:
1、安装hector包:
mkdir -p ~/hector_ws/src
cd ~/hector_ws/src
git clone http://github.com/tu-darmstadt-ros-pkg/hector_slam.git
cd ..
catkin_make
2、刷新配置:
source ~/hector_ws/devel/setup.bash
source ~/.bashrc
3、编写接收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>
4、运行ros
roscore
5、给端口权限,连接激光传感器并打开新终端输入:
ls -l /dev/ttyACM0
sudo chmod a+rw /dev/ttyACM0
6、启动hokuyo节点,打开新终端,输入:
source ~/hector_ws/devel/setup.bash
rosrun hokuyo_node hokuyo_node
7、打开另一个终端,启动hector_slam:
source ~/hector_ws/devel/setup.bash
roslaunch hector_slam_launch tutorial.launch
不出意外的话就可以得到扫描地图了。