Hector_Slam to AMCL
Hi All,
I am a newbie to ROS, but i was able to create a map with hector slam using RPlidarA2M6 on ros kinetic, Issues: - Mapping was smooth till it get a certain point where the robot was moving with the lidar but movement on the map was static hence mapping just a single point.. (Though i was able to maneuver my way through this by staying at this point for a while before finally moving) How do i fix this? - I created a fake odometry using laserscanmatcher but the odometry was stuck at the same point where it was stuck while mapping. how do i fix this? _ amcl is totally wrong,
I need help with these issues, please see the various launch files below.. Thanks
Hector SLAM - launch file
<?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 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_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="base_to_laser_broadcaster" args="0 0 0 0 0 0 base_link laser 100" />
</launch>
LaserScanmatcher Launch file:
<
<node pkg="laser_scan_matcher" type="laser_scan_matcher_node"
name="laser_scan_matcher_node" output="screen">
<param name="base_frame" value="base_link"/>
<param name="fixed_frame" value="odom"/>
<param name="use_alpha_beta" value="false"/>
<param name="use_odom" value="true"/>
<param name="use_imu" value="false"/>
<param name="max_iterations" value="4"/>
<param name="publish_pose" value="true"/>
<param name="publish_tf" value="true"/>
</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>
/>
AMCL Launch file:
<launch>
<node pkg="amcl" type="amcl" name="amcl" output="screen">
<!-- Publish scans from best pose at a max of 10 Hz -->
<param name="odom_model_type" value="diff"/>
<param name="odom_alpha5" value="0.1"/>
<param name="transform_tolerance" value="0.2" />
<param name="gui_publish_rate" value="10.0"/>
<param name="laser_max_beams" value="30"/>
<param name="min_particles" value="500"/>
<param name="max_particles" value="5000"/>
<param name="kld_err" value="0.05"/>
<param name="kld_z" value="0.99"/>
<param name="odom_alpha1" value="0.2"/>
<param name="odom_alpha2" value="0.2"/>
<!-- translation std dev, m -->
<param name="odom_alpha3" value="0.8"/>
<param name="odom_alpha4" value="0.2"/>
<param name="laser_z_hit" value="0.5"/>
<param name="laser_z_short" value="0.05"/>
<param name="laser_z_max" value="0.05"/>
<param name="laser_z_rand" value="0.5"/>
<param name="laser_sigma_hit" value="0.2"/>
<param name="laser_lambda_short" value="0.1"/>
<param name="laser_lambda_short" value="0.1"/>
<param name="laser_model_type" value="likelihood_field"/>
<!-- <param name="laser_model_type" value="beam"/> -->
<param name="laser_likelihood_max_dist" value="2.0"/>
<param name="update_min_d" value="0.2"/>
<param name="update_min_a" value="0.5"/>
<param name="odom_frame_id" value="odom"/>
<param name="resample_interval" value="1"/>
<param name="transform_tolerance" value="0.1"/>
<param name="recovery_alpha_slow" value="0.0"/>
<param name="recovery_alpha_fast" value="0.0"/>
</node>
<!--
<node pkg="tf" type="static_transform_publisher" name="map_to_odom_broadcaster" args="0 0 0 0 0 0 map odom 100" />-->
<node pkg="tf" type="static_transform_publisher" name="odom_to_base_footprint_broadcaster" args="0 0 0 0 0 0 odom base_link 100" />-->
<node pkg="tf" type="static_transform_publisher" name="base_footprint_to_base_link_broadcaster" args="0 0 0.3 0 0 0 base_link laser 100" />-->
-->
</launch>
Update:
Please see the link to the videos and bag file: https://drive.google.com/open?id=1yC-J3Llcngz9Kr9cxp4lPuI2QkBQhMvE
For Video ROS_test7: I used the launch file for AMCL which i posted above Issues: It fails to localize as can be seen in the video, it is stuck at one point on the map.... What could be the issue?
For ROS_test2: To launch AMCL for this, i used:
rosrun amcl amcl usesimtime:=true _usemaptopic:=true scan:=/scan _odomframeid:=/odom _baseframeid:=/baselink globalframeid:=/map _tfbroadcast:=false
Issues: 1.) WHen i insert the robot at any position in the map, it fails to localize, except i choose the initial position of the robot on the map, and this defeats the purpose of AMCL 2.) If i put the video at the initial position of the map, it works alright till it gets to a certain point and it stops updating (This is seen in the video at time 2:01).. the robot was moving but the position wasn't been updated on the map. WHat could be the issue here?
Asked by femitof on 2020-01-23 13:10:12 UTC
Answers
To resolve laser odometry issues, try using the default scan matching parameters (http://wiki.ros.org/laser_scan_matcher#Scan_matching).
Since you mentioned about fake odometry, I'm assuming you don't have wheel odometry. So use_odom
parameter must be set to false
in the laser scan matcher launch file.
Regarding AMCL, I think you are using only a small fraction of the laser returns by setting laser_max_beams
to 30
. This could be a reason by AMCL is not localizing. Instead try setting it to 266
(assuming the angular resolution of your RPlidar is 1.35. 360/1.35 ~= 266)
EDIT
I ran an AMCL instance using the map data and only the /scan data from your bag file and was able to localize successfully. See : https://drive.google.com/drive/folders/1ZuGp5d-XtD9XBQN_ZrgRcAciHaZOU2xn?usp=sharing
In the second video, I purposely gave a wrong initial orientation and it was able to converge to the correct pose after a while.
I noticed that somehow your recorded bag file's TF always have a ZERO static transform between map and odom. See below
You should double check your launch files to see if any of them is publishing an unwanted static transform between odom
and map
. Only AMCL should be publishing this transform. I've also uploaded the launch files I used in the same shared folder for your reference. localize.launch
is the main launch file.
Note however that your environment is somewhat challenging to localize overtime (Especially when the robot is in the middle of the corridor.) because your laser has only about 15 meter range. When the robot is in the middle of the corridor the laser can't see one end and all positions along the corridor might look the same.
Asked by Namal Senarathne on 2020-01-30 03:02:12 UTC
Comments
@Namal Senarathne Thanks. I made the changes as suggested, it still doesnt localize. Also, am i meant to set the initial poisiton of tjhe robot using the 2D pose estimate to the correct position on the map? or AMCL is meant to localize to the correct position successfully?
Asked by femitof on 2020-01-30 21:02:31 UTC
Also, i have successfully set up wheel odometry.. just need to figure out a way to link it to ROS.. Do you think it would be better than the laser_scanner_match i am currently using?
Asked by femitof on 2020-01-30 22:03:05 UTC
@Namal Senarathne Still awaiting your input to this. thanks
Asked by femitof on 2020-02-04 13:49:48 UTC
You can let AMCL to converge automatically or provide initial 2D pose manually. Both works initially as the robot is very close to the distinguishable corner in the environment. Again see the two videos in the shared folder mentioned in the edited answer.
You have to test whether your wheel odometry is better than laser odometry or not. It depends on the wheel odometry implemention. In long corridors with not many distinguishable features, wheel odometry might be more accurate.
Asked by Namal Senarathne on 2020-02-05 11:18:56 UTC
@Namal Senarathne Thank you very much for the inputs.. I am gonna try it out again, but what do you mean by "only AMCL should be publishing this transform?" should i add the static transform in my amcl launch file or AMCL already automatically publishes this transform?
transform here means from odom to map..
Asked by femitof on 2020-02-05 21:57:45 UTC
I meant AMCL to automatically publish the odom
to map
transform.
Asked by Namal Senarathne on 2020-02-06 03:29:03 UTC
I tried it without using the static transform publisher, but it outputs " No transform from map to odom" AMCL doesnt automatically publish it,..i dont know why
Asked by femitof on 2020-02-06 22:11:41 UTC
@Namal Senarathne Hi I have an IMU nodee running and working perfectly, can you direct me how i can utilize this to do mapping and localization? I seem to be stuck..
Thanks
Asked by femitof on 2020-02-11 00:45:23 UTC
@Namal Senarathne Any ideas? please
Asked by femitof on 2020-02-19 13:19:29 UTC
@Namal Senarathne Hi thanks for all the help.. I successfully did localization with Laser Scaner matcher alone. I am about trying Autonomous Navigation using ROS_ARDUINO_BRDIGE which publishes the odometry data from the encoders..and this always distorts the localization, and it starts shaking and eventually ends up all over the place..
ANy idea on what could be wrong? See link attached: https://drive.google.com/file/d/1O4y53knDq_Lnsc-lDZgVXy2mtHSo0MYQ/view?usp=sharing
Asked by femitof on 2020-03-27 13:26:49 UTC
@Namal Senarathne Hi Namal, Whenever my wheelchair doesnt start from the initial position, it fails to localize, the scans been generated do not match the static map.
Any ideas on how to fix this?
Asked by femitof on 2020-06-05 15:17:39 UTC
Hi @femitof please post this as a separate question with more details so other people can also see and comment. Thanks.
Asked by Namal Senarathne on 2020-06-08 17:52:02 UTC
Comments
I editted your title to follow our community guidelines. Please do not add excessive "!", its not productive.
Asked by stevemacenski on 2020-01-23 13:40:49 UTC
Hi, there can be many reasons why your setup is not working. Please post your launch files and error messages to give any sort of useful answer.
Asked by Namal Senarathne on 2020-01-23 21:40:30 UTC
Thanks Namal for your comment.. I have edited the post and posted the launch files..
I used laser_match to create a fake odometry, but it seems to be stuck at a place on the map and the amcl is totally wrong..what could be wrong?
Asked by femitof on 2020-01-24 19:24:20 UTC
@femitof: could you clarify how #q342504 and this question are related?
Asked by gvdhoorn on 2020-01-25 04:52:56 UTC
@gvdhoorn deleted... Can you please help me? @Namal Senarathne @gvdhoorn
Thanks
Asked by femitof on 2020-01-25 15:20:34 UTC
Thanks for uploading the launch files, but I don't see any error messages apart form your description of the error. Can you post any error messages you see and better yet upload a rosbag file capturing the exact erroneous phase during localization.
Anyway my hunch is that your robot is passing through a "feature sparse" location which both hector mapping and amcl is finding difficult to match to its existing map. May be you can try using some other tool for mapping and localization like https://github.com/SteveMacenski/slam_toolbox
Asked by Namal Senarathne on 2020-01-28 22:14:30 UTC
Yeah, there are no error messages, but AMCL just doesn't localize correctly..it is totally incorrect.. Any ideas what could be wrong? Also do you haver an idea of how i could upload a video or something? @Namal Senarathne
Asked by femitof on 2020-01-29 18:30:20 UTC
Hi, you can probably upload your bag files and videos to some web storage (like google drive, dropbox) and provide a link in your question. Also please update your question with information about how you initialize AMCL with the initial pose of the robot to figure out the reasons for failure in localization.
Asked by Namal Senarathne on 2020-01-30 00:41:45 UTC
@Namal Senarathne I updated the question, and uploaded two videos,.. Please check them out.. Also, i decided to use two different ways to implement AMCL which i explained in the updated question. I really do appreciate your time Sir. Thank you again...
Asked by femitof on 2020-01-30 21:00:56 UTC