Improve the localization accuracy of `hector_mapping`
I have a rplidar A2, I want to use it to provide localization information for my robot. I designed a track like the photo below, and the lidar will be moved 1 meter along the track every time I test.
If the hector_mapping
localization information is accurate, the trajectory observed in rviz
will have a high degree of coincidence with the the x-axis. However, I tested it many times and got the following trajectories, the result shows that the localization error is relatively large.
And this is the output of slam_out_pose
(The ideal value should be around (1,0), and he scan angle of the lidar is 360 degrees):
angel:360° x:0.97938 y:-0.20699
angel:360° x:0.98554 y:-0.16751
angel:360° x:1.00000 y:-0.07292
angel:360° x:0.98748 y:-0.17034
angel:360° x:0.93154 y:-0.37575
angel:360° x:0.96340 y:-0.28293
Also attach the launch file I use.
Is there a way to improve the localization accuracy of hector_mapping
?
<?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.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)"/>
<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="base_frame_laser" args="0 0 0 0 0 0 /base_link /laser_link 10"/>
</launch>
I've copied your launch file directly into your question, that the question is self-contained.
Yeah - understand what the code is doing is the first step, though. The code is all available, and it's not even that large in size. Have you tried reading it and investigating?