Mapping with two robots

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

Mapping with two robots

adhikaribibek87@gmail.com
I am trying to create a map of an unknown environment using 2 robots which are moving simultaneously. I am able to build map using one robot but how do I combine it with the map from other? How should I go about this?
Reply | Threaded
Open this post in threaded view
|

Re: Mapping with two robots

matlabbe
Administrator
Currently, you cannot combine maps on runtime, but you can offline. Assuming the robot 1 created a map called map_robot1.db and the robot 2created a map called map_robot2.db, then you can combine them together on command line with :
rtabmap-reprocess "map_robot1.db;map_robot2.db" combined_map.db

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

Re: Mapping with two robots

adhikaribibek87@gmail.com
Ok, thanks for the response. I am launching mapping mode for both robots but I am only able to visualize mapping from one robot at a time on rviz. How is it possible to build maps from 2 robot simultaneously?
Reply | Threaded
Open this post in threaded view
|

Re: Mapping with two robots

matlabbe
Administrator
Are the two robots running an independent ROS master? or are they running with same ROS master? If they run with same ROS master, you have to launch both rtabmap nodes in different namespaces (same for all nodes running on each robot actually). You should also change the name of the TF frames (map_frame_id) accordingly (including robot's static TF too).  Once the TF trees of the robots are in their respective namespace, you may launch two rviz, one with global frame set to root frame of robot 1, and the other one with root frame of robot 2.

If the robots are running their own ROS master, you may open two terminals on your remote computer and set the ROS_MASTER_URI accordingly in the terminals, then launch two rviz. I guess it is the easiest way to do it.

For more info, see also:
https://answers.ros.org/question/310266/best-practice-for-running-multiple-robots-in-a-class/
https://answers.ros.org/question/392374/how-to-launch-two-turtlebots-on-one-ros-master/
https://answers.ros.org/question/380423/multi-robot-tb3-one-ros-master/

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

Re: Mapping with two robots

adhikaribibek87@gmail.com
They are running on one ros-master and they have unique namespaces. After, I build the map which are w.r.t their /odom frame. How do I combine the maps build w.r.t /odom frame to one global frame (/map)?
Reply | Threaded
Open this post in threaded view
|

Re: Mapping with two robots

matlabbe
Administrator
Can you show the current TF tree you have?
rosrun tf2_tools view_frames.py

If you want to see both robots at the same time in RVIZ, you will need to add an arbitrary transform between the two map frames. Assuming the map frame of robot 1 is in "robot1" namespace and map from of robot 2 is in "robot2" namespace:
rosrun tf static_transform_publisher 0 0 0 0 0 0 world robot1/map 100
rosrun tf static_transform_publisher 0 20 0 0 0 0 world robot2/map 100
This will make robot2 starting 20 meters away from robot1 map to avoid overlapping the maps in RVIZ (and set global frame in rviz to "world").