odom frame flickers when playing rtabmap with rosbag

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

odom frame flickers when playing rtabmap with rosbag

alexr
Hi,

I recorded a rosbag using data throttled topics with the robot, using kinect, odometry and depth_to_laser_scan.

$ rosbag record /data_throttled_image/compressed /data_throttled_image_depth/compressedDepth /data_throttled_camera_info /tf /odom /scan

When playing the rosbag , for half of the bag file the mapping is nice, later, the odom frame from where the robot started, starts to ficker and move around. This causes the point cloud to move a lot. However, the  map matching and ICP is not affected and loop closure is good.
My tf parameters are properly defined and when mapping real time, this does not happen. Only while playing back the rosbag this problem occurs.

What might cause the shifting of the odom frame?

Thanks

Alex
------ Alex
Reply | Threaded
Open this post in threaded view
|

Re: odom frame flickers when playing rtabmap with rosbag

matlabbe
Administrator

The TF transform "/map -> /odom" is updated on loop closures. On map correction, the point cloud/grid map should be updated. If large odometry errors are corrected, the "/map -> /odom" transform will be large.

  • If "RGBD/OptimizeFromGraphEnd" parameter is "false" (default), the map is corrected accordingly to first node of the map, updating "/map -> /odom" transform. It is the preferred mode when you want to keep the "/map" referential position where the robot has started mapping (like most SLAM algorithms).
  • If "RGBD/OptimizeFromGraphEnd" parameter is "true", the map is corrected accordingly to last node of the map, so "/map -> /odom" transform will be always Identity since the map is corrected according to last odometry node. It is the preferred mode when there are multiple maps.
Reply | Threaded
Open this post in threaded view
|

Re: odom frame flickers when playing rtabmap with rosbag

alexr
This post was updated on .
Dear Mathieu,

I am still facing this problem of odom link flickering and moving around when playing the rosbag file recorded.
I have the video of the problem. Please download from the link below

Dropbox link

From 20 seconds onward you can see the moving odom frame, and shifting of robot with the point cloud data. My odometry is good enough.

While recording and mapping  there is no problem and the mapping is smooth, however when I play the recorded bag file I have this problem of the robot moving a lot. I tested it with two robots - pioneer and turtlebot and the problem continues.

What might be the problem. I followed your advice from the previous post  to record the data.

I am using ros hydro.

Thanks

Alex
------ Alex
Reply | Threaded
Open this post in threaded view
|

Re: odom frame flickers when playing rtabmap with rosbag

matlabbe
Administrator
Hi Alex,

It looks like that /map -> /odom transform is published by more than one node (maybe the rosbag and the rtabmap node). Verify who is publishing /map -> /odom.

When you are recording the rosbag, is rtabmap running? If yes, you are recording /map -> /odom in the /tf messages. The rosbag should not include /map -> /odom transform, otherwise replaying the rosbag with rtabmap will make /map -> /odom published by the rosbag and rtabmap node. For example, in the post you mentioned, rtabmap is not running when recording.

Removing all /map frames in the rosbag:
rosbag filter input.bag output.bag 'topic != "/tf" or topic == "/tf" and m.transforms[0].header.frame_id != "/map"'

cheers
Reply | Threaded
Open this post in threaded view
|

Re: odom frame flickers when playing rtabmap with rosbag

alexr
This post was updated on .
Hi Matheiu,

When recording bag file, the rtabmap node is running. Since I am generating the odometry from the robot the required tf are published from the robot_state_publisher and the urdf.  Also, i am recording the tf , odom and scan with the throttled image messages.

The bag file runs perfectly when using the rtabmapviz using the sample demo_robot_mapping.launch file in the rtabmap_ros package , the main problem is using the rviz.

I used the rosbag filter to remove the map topic, but the result is same. I am not sure what am I doing wrong?

This is what  I am doing -
1) launch the rtabmap launch (including the robot, hokuyo scan, rviz )
2) launch the data throttle
3) record rosbag with data throttled topics, scan, tf and odom
4) play the recorded bag file

Are you saying, I should not be recording the odom and tf when recording the bag with rtabmap running??

Thanks
Alex
------ Alex
Reply | Threaded
Open this post in threaded view
|

Re: odom frame flickers when playing rtabmap with rosbag

matlabbe
Administrator
Hi Alex,

rtabmapviz doesn't use TF for the /map -> /odom transform but RVIZ uses it. So if there is a /map -> /odom transform in the bag, RVIZ would be affected when running rtabmap again with the bag. When you are running your rosbag alone, is there /map -> /odom transform published? For example, by doing this:
$ rostopic tf view_frames
you should only see /odom as the root. If there is a /map frame, either
1- you filter the /map frame from the bag (using the filtering method above), or
2- record your bag without rtabmap node, or
3- record your bag with "publish_tf" parameter set to "false" for rtabmap node in the launch file (so /map -> /odom will not be published).

For example, a launch file similar to az3_bag_record.launch was used to record data for the demo_robot_mapping.launch.

cheers
Reply | Threaded
Open this post in threaded view
|

Re: odom frame flickers when playing rtabmap with rosbag

alexr
Dear Mathieu,

I understood the problem. My rosbag shows the map frame connected to the odom frame when viewing the tf view_frames.

Somehow, the rosbag filter command is not able to remove the map topic from the recorded bag file. I am not sure why.

I will try to record a new  bag , this time only recording the messages and not launching  the rtabmap node.

I will report back soon.

Thank you for your time and help.

Regards
Alex
------ Alex
Reply | Threaded
Open this post in threaded view
|

Re: odom frame flickers when playing rtabmap with rosbag

alexr
This post was updated on .
Hi Mathieu,

Success!! following your suggestions I was able to reproduce the bag files and use with rtabmap.

I have one problem now. I tried to map a large map and recorded 3 bag files following your suggestions from this post .

The recorded bag files have a common corridor section. When playing the bags in order, there is a large deflection in the neighbor edges when the second bag file is run after the first one. Although for both the bag files ( 1 & 2 ) the start position is almost similar.  I kept the "RGBD/OptimizeFromGraphEnd" parameter as "false".  The third bag starts from a different location but has a common area from the bag 2. Again when playing the bag 3, a link is made from the first map to the third map and this  corrupts the whole global map.

I was killing the roscore and all the nodes (openni2, hokuyo, p3dx launch, and teleop) before recording subsequent bag files. The result is very different from your example of multi_mapping.

Can you suggest  me the correct way.

Thanks

Alex
------ Alex
Reply | Threaded
Open this post in threaded view
|

Re: odom frame flickers when playing rtabmap with rosbag

matlabbe
Administrator
Hi Alex,

In the multi-session example, each bag started exactly with Identity odometry, which is detected by rtabmap to start a new map automatically. Well, if your odometry is not reset to Identity, you can set the parameter "RGBD/NewMapOdomChangeDistance" to maybe 2 meters ("A new map is created if a change of odometry translation greater than X m is detected (0 m = disabled)."). So if there is a change about 2 meters of position between your bags (last odometry pose of the previous bag vs first odometry pose of the new bag), new maps should be created (without the neighbor link between the two maps/bags).

Note that with "RGBD/OptimizeFromGraphEnd=false" on multi-session experiments, the map referential may change when revisiting previous maps because the map will be always optimized from the oldest node. If the oldest node is now from a previous map (which had a different referential), the whole map/localization may jump accordingly to the oldest session.

cheers
Reply | Threaded
Open this post in threaded view
|

Re: odom frame flickers when playing rtabmap with rosbag

alexr
Hi Mathieu,

Thanks, this indeed solved the problem. Thank you very much.


Regards
Alex
------ Alex