在ROS indigo下用hector_slam绘制地图

 

我使用的是 rplidar A1

 

1.安装激光的驱动

 

$ git clone https://github.com/robopeak/rplidar_ros

$ cd ~/catkin_ws

$ catkin_make

2.安装hector_slam

直接通过apt-get 安装

         $  sudo apt-get install ros-indigo-hector-slam

3.安装map_server

         $ sudo apt-get  install ros-indigo-map-server

4.在hector_slam_launch 包 launch 目录 ,增加三个launch文件

slam.launch

<?xml version="1.0"?>
<launch>

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


<include file="$(find hector_slam_launch)/launch/hector_mapping.launch"/>
<include file="$(find hector_slam_launch)/launch/geotiff_mapper.launch">

  <arg name="trajectory_source_frame_name" value="scanmatcher_frame"/>

</include>
 

</launch>

geotiff_mapper.launch

<?xml version="1.0"?>
<launch>
<arg name="trajectory_source_frame_name" default="/base_link"/>
<arg name="trajectory_update_rate" default="4"/>
<arg name="trajectory_publish_rate" default="0.25"/>

<node pkg="hector_trajectory_server" type="hector_trajectory_server" name="hector_trajectory_server" output="screen">
<param name="target_frame_name" type="string" value="/map" />
<param name="source_frame_name" type="string" value="$(arg trajectory_source_frame_name)" />
<param name="trajectory_update_rate" type="double" value="$(arg trajectory_update_rate)" />
<param name="trajectory_publish_rate" type="double" value="$(arg trajectory_publish_rate)" />

</node>

 

<node pkg="hector_geotiff" type="geotiff_node" name="hector_geotiff_node" output="screen" launch-prefix="nice -n 15">

<remap from="map" to="/dynamic_map" />

<param name="map_file_path" type="string" value="$(find hector_geotiff)/maps" />

<param name="map_file_base_name" type="string" value="uprobotics" />

<param name="geotiff_save_period" type="double" value="0" />

<param name="draw_background_checkerboard" type="bool" value="true" />

<param name="draw_free_space_grid" type="bool" value="true" />

</node>

</launch>

 


hector_mapping.launch
<?xml version="1.0"?>
<launch>

<node pkg="hector_mapping" type="hector_mapping" name="hector_mapping"   output="screen">

  <param name="pub_map_odom_transform" value="true"/>

  <param name="map_frame" value="map" />

  <param name="base_frame" value="base_link" />

  <param name="odom_frame" value="base_link" />

 

  <!-- Map size / start point -->

    <param name="map_resolution" value="0.050"/>

    <param name="map_size" value="1048"/>

    <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_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" />

 

</node>

<node pkg="tf" type="static_transform_publisher" name="base_to_laser_broadcaster" args="0 0 0 0 0 0 /base_link /laser 100" /> 

 

</launch>

5.$ cd  ~/catkin_ws

    $ source devel/setup.bash

    $ roslaunch rplidar_ros rplidar.launch (启动激光)

    $ roslaunch hector_slam_launch slam.launch(启动rviz和hector_mapping

6.保存地图

   在扫描完成后

    $ rosrun map_server map_saver –f  /tmp/my_map (保存地图)

 

 

注意:在启动激光的时候,要先开端口权限  $ sudo chmod 777 -R /dev/ttyUSB0

 

 

 

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页