I am working on a multi-robot AMR simulation using ROS 2, Gazebo, and Nav2 AMCL.
When running a single robot without a namespace, everything works perfectly. However, when I scale it up to a multi-robot system using namespaces (robot_1 and robot_2), my TF tree breaks. In RViz, I get the following error for every link on the robot:
No transform from [robot_1/caster_front_left] to [map]
No transform from [robot_1/base_link] to [map]
even though I changed the TF Prefix
If I change the Fixed Frame in RViz from map to robot_1/odom, the robot model loads correctly and the error goes away, but the global map disappears so the local robot transform tree (robot_1/odom → robot_1/base_link → joints) is working, but the link connecting the robot to the map is completely missing.
And this is happening for every robot and every link.
Okay , I found the problem and the solution guys , basically you have to namespace the sensors topics in gazebo , so instead of this :
def get_namespaced_urdf(urdf_str, r_name):
s = urdf_str.replace('<frame_id>odom</frame_id>', f'<frame_id>{r_name}/odom</frame_id>')
s = s.replace('<child_frame_id>base_footprint</child_frame_id>', f'<child_frame_id>{r_name}/base_footprint</child_frame_id>')
s = s.replace('<child_frame_id>base_link</child_frame_id>', f'<child_frame_id>{r_name}/base_link</child_frame_id>')
s = s.replace('<gz_frame_id>laser_front</gz_frame_id>', f'<gz_frame_id>{r_name}/laser_front</gz_frame_id>')
s = s.replace('<gz_frame_id>laser_rear</gz_frame_id>', f'<gz_frame_id>{r_name}/laser_rear</gz_frame_id>')
s = s.replace('<gz_frame_id>imu_link</gz_frame_id>', f'<gz_frame_id>{r_name}/imu_link</gz_frame_id>')
return s
we add this :
def get_namespaced_urdf(urdf_str, r_name):
s = urdf_str.replace('<frame_id>odom</frame_id>', f'<frame_id>{r_name}/odom</frame_id>')
s = s.replace('<child_frame_id>base_footprint</child_frame_id>', f'<child_frame_id>{r_name}/base_footprint</child_frame_id>')
s = s.replace('<child_frame_id>base_link</child_frame_id>', f'<child_frame_id>{r_name}/base_link</child_frame_id>')
s = s.replace('<gz_frame_id>laser_front</gz_frame_id>', f'<gz_frame_id>{r_name}/laser_front</gz_frame_id>')
s = s.replace('<gz_frame_id>laser_rear</gz_frame_id>', f'<gz_frame_id>{r_name}/laser_rear</gz_frame_id>')
s = s.replace('<gz_frame_id>imu_link</gz_frame_id>', f'<gz_frame_id>{r_name}/imu_link</gz_frame_id>')
# namespace sensor topic in gazebo
s = s.replace('<topic>scan_front</topic>', f'<topic>/model/{r_name}/scan_front</topic>')
s = s.replace('<topic>/scan_front</topic>', f'<topic>/model/{r_name}/scan_front</topic>')
s = s.replace('<topic>scan_rear</topic>', f'<topic>/model/{r_name}/scan_rear</topic>')
s = s.replace('<topic>/scan_rear</topic>', f'<topic>/model/{r_name}/scan_rear</topic>')
return s
Hi @Yesser_Hmidi,
What version of rosbot_ros and rosbot_autonomy_ros/rosbot-autonomy are you running?