SteveMacenski / slam_toolbox

Slam Toolbox for lifelong mapping and localization in potentially massive maps with ROS
GNU Lesser General Public License v2.1
1.61k stars 513 forks source link

Map drifting after moving robot in gazebo ignition with slam_toolbox and rtabmap_ros #496

Closed Marcelomm103 closed 2 years ago

Marcelomm103 commented 2 years ago

Steps to reproduce issue

I'm trying to do SLAM with an ackermann prius model in ignition gazebo. I'm bridging all the topics required to ros 2 with ros_ign_bridge, like clock, pointcloud, odometry, imu, etc... I'm using robot_localization to generate the odom -> base_link transform, and following this tutorial to do the slam: (https://navigation.ros.org/tutorials/docs/navigation2_with_slam.html). I'm pretty sure i have all params yaml configured right because if i try with a diff drive robot and 2D laser i can do the slam. Does anyone know or have an idea why this drift as shown in images below is happening?? I thought it was a problem of using pointcloud to laserscan conversion but the same happens with rtabmap which is a 3D slam. Screenshot from 2022-05-30 11-42-25 Screenshot from 2022-05-30 19-51-27

I can send echos of topics, log files and config files if anyone care to help. I'll appreciate all contributions. Thank you.

SteveMacenski commented 2 years ago

Probably because your map is super unrealistic / sparse, there's not enough features to match against. But also could be issues with your odometry / state estimates. You should make a real world you really want to localize within

Marcelomm103 commented 2 years ago

Thanks for the reply. I think it may be something with the odometry, but it's self generated by ackermann plugin in gazebo ignition. I thought it was something with the robot localization and went to program a odom -> base_link tf myself but it wasn't. I'm using sonoma map from open robotics and it still drifting so i may not be lack of features as seen from the img:

Screenshot from 2022-06-07 15-11-37

The strange thing is if i use a diff drive robot i can map perfectly, even using pointcloud_to_laserscan package to simulate 2D laser from 3D lidar.

SteveMacenski commented 2 years ago

I think then this is a ticket to file with the ackermann drive plugin?

Marcelomm103 commented 2 years ago

I noticed something, the map to odom shouldn't be in the same coordinates? because mine map tf is driving away from odom tf as the robot goes. Screenshot from 2022-06-07 16-25-30

SteveMacenski commented 2 years ago

It should drift over time, though it shouldn't be something you can watch and see it actively moving from frame to frame as you move. Its more about accounting for error (unless you don't have a global localizer set up)

Marcelomm103 commented 2 years ago

Thank you for your fast replies, no i dont have any gnss in my model. So the problem may be the odometry generated by the ackermann plugin ? Because i looked in to it with echo and it seems pretty good by the way the robot moves, if it moves in one ax or circles it account for it nicely. Could be something with the nav2 bringup ? I can use it well with diff drive robots

Marcelomm103 commented 2 years ago

If i use rtabmap for mapping it shows me the direction of the robot, and it's moving 90 degrees displaced. Do you know how i can change the direction of the mapping? or it should be in the odom frame? I dont know where i should be making changes. Screenshot from 2022-06-07 16-57-12

SteveMacenski commented 2 years ago

Unfortunately I don't have extra cycles to be able to dig into your system for you :/ If you don't have anything updating the map - odom transform for global localization, that should be staying static and you should only be seeing base link move. I can't tell you what's wrong specifically with your system, but I suspect something is not set up correctly

Marcelomm103 commented 2 years ago

No worries. I don't have anything updating map-odom besides the slam node. I will dig in trying to see if my model is somehow rotated 90 degrees. Thank you for all your help.

Marcelomm103 commented 2 years ago

Actually i managed to get it right now with a rotated lidar, the slam toolbox works fine now. Thank you for your insights.