Hi,
The statistics are published in /rtabmap/info topic, in statKeys and statValues fields (
http://docs.ros.org/en/noetic/api/rtabmap_ros/html/msg/Info.html). They can also appear in rtabmap_ros/Info rviz display.
It depends on what kind of robot. For an outdoor robot, maybe an RTK GPS. For indoor robot, if you have OptiTrack or VICON systems, that could make a very accurate ground truth. For both approaches, if the ground truth is published though TF, say /world -> /base_link_track, you can set ground_truth_frame_id and ground_truth_base_frame_id respectively to save the ground truth in rtabmap database. RTAB-Map can then compute RMSE directly (that will appear in Statistics) and you can compare both paths (slam vs ground truth) in rtabmapviz or rtabmap-databaseViewer.
cheers,
Mathieu