hector-slam安装与使⽤(ubuntu16.04)(使⽤数据包运⾏
hector-slam)
安装hector-slam需要ros系统,⾸先通过官⽅教程进⾏安装,需要根据系统好对应的ros系统版本,Ubuntu16.04对应Kinetic版本,安装教程如下():
ROS Kinetic ONLY supports Wily (Ubuntu 15.10), Xenial (Ubuntu 16.04) and Jessie (Debian 8) for debian packages.
sudo sh -c 'echo "deb /ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
curl -sSL 'keyserver.ubuntu/pks/lookup?op=get&search=0xC1CF6E31E6BADE8868B172B4F42ED6FBAB17C654' | sudo apt-key add -sudo apt-get update
sudo apt-get install ros-kinetic-desktop-full
安装完成ros之后开始安装hector-slam:
⾸先创建⼯作⽬录以及配置环境
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
mkdir -p catkin_ws/src
cd catkin_ws
catkin_make
echo "source /home/robot/catkin_ws/devel/setup.bash" >> ~/.bashrc
下载安装hector-slam
cd src
sudo apt install git
git clone
cd ../
catkin_make
编译过程中报错
c++: internal compiler error: Killed (program cc1plus)
是因为系统内存不够导致的,参考这篇⽂章
ubuntu安装教程
执⾏完之后重新运⾏catkin_make
⾄此编译完成
Hector-slam使⽤
hector-slam针对⾼频率激光设备效果较好,低频建图基本不太准确。
hector-slam官⽅介绍有三种使⽤⽅式:
1. Use in place of gmapping(通过gmapping发布map到odom的tf变换)
2. Use without odom frame(不使⽤odom⾥程计信息)
3. Use without Broadcasting of transformations(不使⽤任何tf数据)
因为我使⽤机器⼈录制了⼀下⼚房的数据包,其中包括了激光数据和odom数据,这⾥暂时不使⽤odom(其实是没看出来在哪⾥使⽤/(ㄒo ㄒ)/~~)。
⾸先进⼊hector_slam的launch⽬录下,查看⼀下launch⽂件:
roscd hector_slam_launch/launch
默认的是使⽤tutorial.launch ,打开⽂件查看⽂件内容:
这⾥开到它包含了mapping_default.launch⽂件,查看⽂件内容:
odom_frame也不需要改,程序会⾃⼰发布,最后scan_topic根据⾃⼰的激光主题发布,因为这⾥发布的主题就是scan所以不做改动。
更改⽂件之后运⾏报错,提⽰
这说明没有laser scan 到base_frame的tf变换,添加下⾏到launch⽂件中,发布⼀个静态变换:
<node pkg="tf" type="static_transform_publisher" name="base_frame_laser" args="0 0 0 0 0 0 /base_footprint /velodyne 100" />
这⾥提⽰⼀下,laser scan对应的不应该是scan的主题,⽽是scan的frama_id,因为我使⽤的是velodyne激光,所以这⾥对应的改
成/velodyne.
改完之后的两个⽂件:
<?xml version="1.0"?>
<launch>
<arg name="geotiff_map_file_path" default="$(find hector_geotiff)/maps"/>
<param name="/use_sim_time" value="true"/>
<node pkg="tf" type="static_transform_publisher" name="base_frame_laser" args="0 0 0 0 0 0 /base_footprint
/velodyne 100" />
<!--node pkg="tf" type="static_transform_publisher" name="map_to_odom" args="0.0 0.0 0.0 0 0 0.0 /odom
/base_footprint 100" /-->
<node pkg="rosbag" type="play" name="bagplayer" args="--clock /home/robot/rosbag/whole-room_2020-02-27-11-31-12.bag"/>
<node pkg="rviz" type="rviz" name="rviz"
args="-d $(find hector_slam_launch)/rviz_cfg/mapping_demo.rviz"/>
<include file="$(find hector_mapping)/launch/whole_room_mapping.launch"/>
<include file="$(find hector_geotiff)/launch/geotiff_mapper.launch">
<arg name="trajectory_source_frame_name" value="scanmatcher_frame"/>
<arg name="map_file_path" value="$(arg geotiff_map_file_path)"/>
</include>
</launch>
hector_slam/hector_slam_launch/launch/whole_room.launch
<?xml version="1.0"?>
<launch>
<arg name="tf_map_scanmatch_transform_frame_name" default="scanmatcher_frame"/>
<arg name="base_frame" default="base_footprint"/>
<arg name="odom_frame" default="odom"/>
<arg name="pub_map_odom_transform" default="true"/>
<arg name="scan_subscriber_queue_size" default="5"/>
<arg name="scan_topic" default="scan"/>
<arg name="map_size" default="2048"/>
<node pkg="hector_mapping" type="hector_mapping" name="hector_mapping" output="screen">
<!-- Frame names -->
<param name="map_frame" value="map" />
<param name="base_frame" value="$(arg base_frame)" />
<param name="odom_frame" value="$(arg odom_frame)" />
<!-- Tf use -->
<param name="use_tf_scan_transformation" value="true"/>
<param name="use_tf_pose_start_estimate" value="false"/>
<param name="pub_map_odom_transform" value="$(arg pub_map_odom_transform)"/>
<!-- Map size / start point -->
<param name="map_resolution" value="0.050"/>
<param name="map_size" value="$(arg map_size)"/>
<param name="map_start_x" value="0.5"/>
<param name="map_start_y" value="0.5" />
<param name="map_multi_res_levels" value="2" />
<!-- Map update parameters -->
<param name="update_factor_free" value="0.4"/>
<param name="update_factor_free" value="0.4"/>
<param name="update_factor_occupied" value="0.9" />
<param name="map_update_distance_thresh" value="0.4"/>
<param name="map_update_angle_thresh" value="0.06" />
<param name="laser_z_min_value" value = "-1.0" />
<param name="laser_z_max_value" value = "1.0" />
<!-- Advertising config -->
<param name="advertise_map_service" value="true"/>
<param name="scan_subscriber_queue_size" value="$(arg scan_subscriber_queue_size)"/>
<param name="scan_topic" value="$(arg scan_topic)"/>
<!-- Debug parameters -->
<!--
<param name="output_timing" value="false"/>
<param name="pub_drawings" value="true"/>
<param name="pub_debug_output" value="true"/>
-->
<param name="tf_map_scanmatch_transform_frame_name" value="$(arg
tf_map_scanmatch_transform_frame_name)" />
</node>
<!--<node pkg="tf" type="static_transform_publisher" name="map_nav_broadcaster" args="0 0 0 0 0 0 map nav 100"/>-->
</launch>
"/home/robot/catkin_ws/src/hector_slam/hector_mapping/launch/whole_room_mapping.launch"
建图结果: