zoukankan      html  css  js  c++  java
  • 利用ROS内建SLAM建立地图

    ros中建地图方式有两种:

    首先1、首先下载hector_slam包到你工作空间的src下
    命令:

    cd ~/catkin/src
    git clone https://github.com/tu-darmstadt-ros-pkg/hector_slam.git
    cd ..
    catkin_make 
    

    在~/catkin_ws/src/hector_slam/hector_slam_launch/launch/新建一个demo.launch

    <?xml version="1.0"?>
    <launch>
     <include file="$(find rplidar_ros)/launch/rplidar.launch"/>
      <node pkg="tf" type="static_transform_publisher" name="map_to_odom" args="0.0 0.0 0.0 0 0 0.0 /odom /base_link 10"/>
      <node pkg="tf" type="static_transform_publisher" name="base_frame_laser" args="0 0 0 0 0 0 /base_link /laser 10"/>
      <!--<node pkg="rviz" type="rviz" name="rviz"
        args="-d $(find hector_slam_launch)/rviz_cfg/mapping_demo.rviz"/>-->
      <include file="$(find hector_mapping)/launch/mapping_default.launch"/>
      <node pkg="rviz" type="rviz" name="rviz" args="-d rviz_cfg.rviz"/>
      <include file="$(find hector_geotiff)/launch/geotiff_mapper.launch"/>
    </launch>
    

     修改~/catkin_ws/src/hector_slam/hector_mapping/launch/mapping_default.launch

    <?xml version="1.0"?>
    <launch>
     <arg name="tf_map_scanmatch_transform_frame_name" default="/scanmatcher_frame"/>
    <arg name="base_frame" default="base_link"/>
    <arg name="odom_frame" default="base_link"/>
    <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 base_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_occupied" value="0.7" />    
       <param name="map_update_distance_thresh" value="0.2"/>
    <param name="map_update_angle_thresh" value="0.9" />
     <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)"/>
        <param name="tf_map_scanmatch_transform_frame_name" value="$(arg tf_map_scanmatch_transform_frame_name)" />
     </node>
    </launch>
    

    我用的是rplidar激光雷达,主要价格比较便宜

    修改rplidar驱动文件
    在rplidar_ros/src/node.cpp中找到
    nh_private.param<std::string>("frame_id", frame_id, "laser_frame");
    将其改成:
    nh_private.param<std::string>("frame_id", frame_id, "laser");
    编译后运行:
    roslaunch hector_slam_launch demo.launch

  • 相关阅读:
    WPF快速指导10:WPF中的事件及冒泡事件和隧道事件(预览事件)的区别
    改善C#程序的建议1:非用ICloneable不可的理由
    WPF快速指导5:验证
    改善C#程序的建议4:C#中标准Dispose模式的实现
    我所入选的微软技术社区电子报
    C#中new, override, virtual的具体用法
    C#中FCL迭代器模式的一点问题
    WPF快速指导3:数据绑定
    WPF快速指导2:模板
    C#高效编程话题集2(每期10话题)
  • 原文地址:https://www.cnblogs.com/serser/p/7771893.html
Copyright © 2011-2022 走看看