There are two ways to build a map of Ros:
First of all 1, first download Hector_slam package to your work space under the SRC
Command:
Create a new demo.launch in ~/catkin_ws/src/hector_slam/hector_slam_launch/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"/> <node pkg= "TF" type= "Static_transform_publisher" name= "Base_frame_laser" args= "0 0 0 0 0 0/base_link/laser 10"/& gt; <!--<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>
Modify ~/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--< ;p Aram Name= "Map_frame" value= "map"/> <param name= "Base_frame" value= "$ (arg base_frame)"/> <param name= "od Om_frame "value=" $ (arg base_frame) "/> <!--Tf Use--and <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_mu Lti_res_levels "value=" 2 "/> <!--Map update parameters-to <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 "/& Gt <param name= "Laser_z_max_value" value = "1.0"/> <!--advertising config---<param name= "Advertise_ma P_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>
I use Rplidar lidar, the main price is relatively cheap
modifying Rplidar driver files
Found in Rplidar_ros/src/node.cpp
Nh_private.param<std::string> ("frame_id", frame_id, "laser_frame");
Change it to:
Nh_private.param<std::string> ("frame_id", frame_id, "laser");
Run after compilation:
Roslaunch Hector_slam_launch Demo.launch
Build maps using Ros Hector_mapping