introlab / rtabmap_ros

RTAB-Map's ROS package.
http://wiki.ros.org/rtabmap_ros
BSD 3-Clause "New" or "Revised" License
1.01k stars 558 forks source link

How do I publish an amcl_pose topic? #1115

Open yemerge opened 9 months ago

yemerge commented 9 months ago

I am trying to estimate the location of go1 by modifying deco_unitree_quadruped_robot.launch. Added map server, pointCloud to LaserScan and amcl. An error occurs when running rostopic echo /rtabmap/amcl_pose. But /clock and use_sim_time are normal. rostopic echo /rtabmap/scan data is displayed. Publisher and subscriber associations have been verified with topic information. How do I do 2D pose estimation in rviz? Screenshot from 2024-01-31 08-32-13 Screenshot from 2024-02-01 10-23-08 Screenshot from 2024-01-31 08-32-28 Screenshot from 2024-01-31 15-44-37 Screenshot from 2024-01-31 14-31-13 Screenshot from 2024-01-31 14-33-09 Screenshot from 2024-01-31 15-48-50 Screenshot from 2024-01-31 14-26-55 Screenshot from 2024-01-30 19-12-25 frames rosgraph

matlabbe commented 9 months ago

You should use either map_server+amcl or rtabmap node, not both approaches at the same time. If you want to use AMCL, remove rtabmap node. You may also remove rgbd_odometry as your odometry seems coming from gazebo already (based on your tf tree).

So, if you remove all rtabmap parts, you may follow this AMCL tutorial directly to set the 2D pose estimate. In your case, I think it didn't work becasue the amcl node was launched in /rtabmap namespace, so its input initialpose topic is rtabmap/initialpose instead. Either move amcl outside rtabmap namespace, or change the topic of 2d pose estimate button in rviz tool's properties.

yemerge commented 9 months ago

I use a 2D map converted from the rtabmap database. Can I do 2d-pose-estimate on rviz without using amcl node? I don't understand why I have to choose either map_server+amcl or rtabmap node.

I tried running it after commenting out and in demo_unitree_quadruped_robot_navigation.launch, but it does not work properly.

yemerge commented 9 months ago

How can I do rtabmap localization?(without amcl)

matlabbe commented 9 months ago

You can relaunch rtabmap in localization mode by adding Mem/IncrementalMemory parameter set to false. Make sure you removed --delete_db-on_start argument if you used it to not delete the database. You don't need to start another map_server or amcl if you do so.

In your original workflow, if you exported the 2d occupancy grid and used map_server to publish it in localization session, you would need to add amcl node to localize in it (this would only work if the robot has a 2D lidar). The 2D pose estimate topic from RVIZ is sending on /initialpose topic by default, which is the one amcl is using.

yemerge commented 9 months ago
<param name="Mem/InitWMWithAllNodes" type="string" value="$(arg localization)"/>
<remap from="grid_map" to="/map"/>
<include file="$(find unitree_move_base)/launch/pointCloud2LaserScan.launch"/>
<include file="$(find unitree_move_base)/launch/move_base.launch"/>

By adding , the 2D Nav goal was successful in rviz.

I tried changing the initial position of the robot using rostopic pub /rtabmap/initialpose geometry_msgs/PoseWithCovarianceStamped, but the robot changes to that position and then returns to the previous position. Does localization mode automatically estimate the location? Is there a way to adjust the robot's position if the robot's position on the rviz and the robot's position on the gazebo do not match?

matlabbe commented 9 months ago

Localization mode still continue to do global localization even if you set an initial pose. For example, we can roughly set the location of the robot with 2D Pose estimate button, but the localization approach may refine that location and correct it if needed. If the robot is jumping back to a wrong location after setting the initial pose, there is something wrong the the localization. Is it the whole launch file that you are using? If AMCL+map_server is used, I cannot really say why the robot would jump back.