Export pose for every frame?

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

Export pose for every frame?

Manuel
Hi,

is it possible to generate and export a trajectory which stores the poses for every frame? I want to compute an optimized trajectory with RTAB-Map for a given .oni file and then use this trajectory as input for another program to integrate the depth maps into a dense model.

Thanks,
Manuel
Reply | Threaded
Open this post in threaded view
|

Re: Export pose for every frame?

matlabbe
Administrator
Hi,

See Edit -> Advanced -> "Export Poses..." menu.

cheers
Reply | Threaded
Open this post in threaded view
|

Re: Export pose for every frame?

Manuel
Thanks for the answer. Yes I saw that, but that are not the poses for all the camera input? I have a test oni file with over 800 frames and when I save the poses I get only around 300.
Reply | Threaded
Open this post in threaded view
|

Re: Export pose for every frame?

matlabbe
Administrator
Hi,

RTAB-Map is an online mapping tool. With default parameters, it will keep only 1 frame/second. If you export the poses in RGBD-SLAM format (from the Edit->"Export poses..." menu), you will have the timestamps to match with your frames in the oni file.

There is an option to add intermediate frames computed by odometry (at higher frequency) in Preferences->"RTAB-Map Settings" (Advanced), check "Create intermediate nodes if odometry is faster than the detection rate.". You will then get the poses of every frames processed by odometry. Note that odometry tries to process the frames received by the camera as fast as it can, so if the frame rate of the camera is higher as the odometry can process in real-time, some frames will be skipped.

You could also extract RGB+Depth images from the database (as well as the poses like the way above) using the Database Viewer to have synchronized frames directly. See Tools -> "Edit database...", open your saved database then click File->"Extract images...". You will then have all RGB (.jpg) and depth (.png) images with their corresponding poses (RTAB-Map doesn't keep RGB and depth images for intermediate nodes in database though).

cheers
Reply | Threaded
Open this post in threaded view
|

Re: Export pose for every frame?

Manuel
Ah yes did not see the intermediate node option. Is it possible to do post-processing when having intermediate nodes? It always says that some data is missing (I updated the cache).
Thank you for your help!
Reply | Threaded
Open this post in threaded view
|

Re: Export pose for every frame?

matlabbe
Administrator
Indeed, intermediate nodes don't have data. I opened an issue about this. In the mean time that I find a clean solution, if you have built RTAB-Map from source, you can comment the "return;" here in MainWindow.cpp. I don't think the code will crash after that (with missing data), but you will have a lot of errors on the console (saying that some data are not found...). The ICP refining of neighbors won't work, but all loop closure stuff may work (finding more loop closures or ICP on loop closures).

cheers,
Mathieu
Reply | Threaded
Open this post in threaded view
|

Re: Export pose for every frame?

Manuel
Hi again,
I assume the timestamps (when exporting the poses) store the times when the corresponding nodes were created and can be different for every run of the program, even for the same input oni file, right? Is there any way I can synchronize a pose to a frame of the oni file? The timestamps of the oni frames do not really fit very well to the pose timestamps....
An easy workaround would be of course to change the source so that the oni timestamps are used when creating a new node. However I am using the prebuilt version of RTAB-Map and building it on my own would be quite some work since I do not use Visual Studio 2010...
Reply | Threaded
Open this post in threaded view
|

Re: Export pose for every frame?

matlabbe
Administrator
Hi,

With OpenNI2, we could use the timestamp and frame index of each frame. Add them here in CameraRGBD.cpp. Then use "Mem/GenerateIds=false" to have directly the node ID = oni frame ID. I added an issue to add this feature.

The timestamps used by RTAB-Map are in seconds (epoch time). Those used by OpenNI2 seems to be in microseconds. They could be synchronized using the first frame.

As mentionned previously, you can also use the DatabaseViewer to extract the RGB and depth images corresponding to all nodes (this way, you can be sure that images and poses are synchronized).

Note that if you want to build RTAB-Map, it may be easier to do it under Ubuntu.

cheers
Reply | Threaded
Open this post in threaded view
|

Re: Export pose for every frame?

Manuel
Thank you very much for adding it so quickly to the code.
I managed to compile it now and will try it out :)
Reply | Threaded
Open this post in threaded view
|

Re: Export pose for every frame?

Timofejev
In reply to this post by matlabbe
matlabbe wrote
Hi,

See Edit -> Advanced -> "Export Poses..." menu.

cheers
Hi Mathieu, I assume this option is no longer present in the current rtabmap? Not a big deal, but could you confirm something about the way camera poses stored in the database?

I am trying to reconstruct the map created by rtabmap in another program. I also use the PCLVisualizer and I am extracting images and poses data straight from the database created by Rtabmap. I am able to successfully retrieve the pose 3x4 matrix, however when I try to project clouds in the scene, the clouds are not aligned. It looks like some rotation axes are switched, but I cannot find the place in code where you change the coordinate system in PCLVisualizer - so I assume you also use the default one.

What I do is:

1) read the pose blob from the database file
2) convert it to a float 3x4 matrix. The data after the conversion is the same that is shown in the Rtabmap Database Viewer, so this step works fine
3) append a 0 0 0 1 row to the matrix
4) read rgb and depth for the same ID and create a point cloud
5) transform the point cloud by the 4x4 matrix from 3) by using pcl::transformPointCloud:
    Eigen::Matrix<double,4,4> T;
    cv::cv2eigen(transform, T);
    PointCloud::Ptr cloud(new PointCloud);
    pcl::transformPointCloud(*tmp, *cloud, T);

This approach works with the dataset "7 scenes" if I read the images from and poses from files. But for data produced by Rtabmap I cannot get the clouds properly aligned to each other.
Reply | Threaded
Open this post in threaded view
|

Re: Export pose for every frame?

matlabbe
Administrator
Hi,

The Export Poses action is now under File menu. You will have also the choice to export poses directly in camera frame (instead of robot frame) so that optical rotation of the camera is included in the pose. Otherwise, you would have to do an optical rotation to correctly rotate the point clouds from image coordinates (x-right, y-down, z-forward) to ROS/RTAB-Map coordinates (x-forward, y-left and z-up). Poses are in ROS/RTAB-Map coordinates.

Note that poses in database are odometry poses, they are not the optimized ones after loop closures.

cheers,
Mathieu
Reply | Threaded
Open this post in threaded view
|

Re: Export pose for every frame?

Timofejev
ah ok, that makes sense, I will use the export function then. Thank you!
Reply | Threaded
Open this post in threaded view
|

Re: Export pose for every frame?

Timofejev
This post was updated on .
UPDATE: Ok, I have found the obvious solution. By default no new nodes are created for poses that are close to each other. By setting the threshold distance and angle to 0 I am able to write all input frames into nodes and export their poses afterwards.
I leave my original posting in place in case somebody else will have the same problem:

so now I have the same problem as thread starter I guess. I have set the settings as you have recommended:

Rtabmap/ComputeRMSE= true
Rtabmap/CreateIntermediateNodes= true
Rtabmap/DetectionRate= 0
Rtabmap/ImageBufferSize= 0

and from 1000 input image pair I only get 74 poses:

WM: 74 nodes and 37411 words
Global graph: 74 poses and 99 links

As I am processing the images offline, I am able set the input source rate to 1 Hz so my CPU is quite relaxed (I am monitoring the usage). It should be able to process every frame. "Synchronize capture rate with timestamps" is also set to false. I am probably missing something very obvious?
Reply | Threaded
Open this post in threaded view
|

Re: Export pose for every frame?

brunoeducsantos
Is there any function in Rtabmap that allows to obtain for each frame the position in world coordinates from Poses file?
Thanks,

Bruno
Reply | Threaded
Open this post in threaded view
|

Re: Export pose for every frame?

matlabbe
Administrator
Hi,

On ros, subscribe to /rtabmap/mapGraph topic. Those are poses of all nodes in /map frame.

"for each frame", do you mean each camera frame? each frame processed by visual odometry or each frame processed by rtabmap? By default it is the later ("each frame processed by rtabmap"). When setting "Rtabmap/CreateIntermediateNodes= true" like above, poses from odometry will be also saved in the graph, so exporting the graph you will have "for each frame processed by odometry".

cheers,
Mathieu
Reply | Threaded
Open this post in threaded view
|

Re: Export pose for every frame?

nezagrizly
Hi. I'm facing the same issue with standalone version of rtab mal when I export poses in kitti format there are significantly defference in number of frames and poses. I've tried to set image buffer and frequency to 0 and enable mode creation, but It didn't help. Can you please explain how I can solve this issue?
Reply | Threaded
Open this post in threaded view
|

Re: Export pose for every frame?

matlabbe
Administrator
You can also try with RGBD/AngularUpdate and RGBD/LinearUpdate set to 0. Otherwise, if you have a database to share that you know you don't get the correct number of poses, we could take a look.