If they are in same TF tree, you could lookup transform between "robot1/base_link" and "robot2/base_link" frames to get relative position between the robots. However in SLAM mode, as the robots won't detect online loop closures with other robots, you may add those static transforms "world->robot1/map" and "world->robot2/map" at start, but while each robot will detect their own loop closures in respective maps, the two maps would drift apart.
If you are interested in online multi-robot mapping, you may also check this project:
https://github.com/MISTLab/Swarm-SLAM