I want to implement a scenario in which the robot moves in a square motion.
When the robot moves forward (in +x direction of map frame) it works fine. But when the robot rotates and moves in -x direction, the x value of the robot pose doesn't decrease due to which sometimes I get the wrong robot pose. Hence the mapCorrection in the map_optimizer node becomes erroneous and /map -> /odom tf becomes non zero.
What could be the issue according to you? I have just used the visual odometry withoutt IMU or wheel encoders, to calculate the robot pose. The output just relies on the images from kinect.
Do you rotate 180 degrees then go back on the same path? Normally, no loop closures can be found with the camera looking backward (images are not similar). If you add rtabmap_ros/Info plugin in RVIZ, how many loop closures and proximity detections are detected?
No I rotate the robot by 90 degrees then move forward and then again rotate 90 degrees then move forward. And in the rtabmap_ros/Info plugin it says loop closures to be zero.
That means without loop closure, /map -> /odom tf becomes non zero. The problem is in optimization process. If I dont update /map -> /odom tf in map_optimizer node and subscribe to mapData topic in rviz, everything works fine.
What I want to do is to not optimize the graph at each step but optimize only when loop closure has been detected. According to you, is this is a good idea?
Even if you optimize at every frames, /map -> /odom should stay null if no loop closures were detected. If each node in the graph is linked to only its neighbors, the graph after optimization would look exactly the same as the input (unless you activated "RGBD/NeighborLinkRefining", which can change edge transformations).
But yes, you can optimize only when a loop closure is added (this what rtabmap node does). You may subscribe to rtabmap/info message to know when a loop closure is detected.
I want to clarify that rtabmap node optimizes the graph only when the loop closure is detected but if we use map_optimizer node, then by default the graph is optimized at every step even if there is no loop closure. Is that right?