Hello to everyone,
I am struggling a bit with my gazebo project. Please any kind of help would be welcomed.
What I am trying to do:
I want to have multiple robot_descriptions as publisher for multiple robots of the same type. My goal is to visualize every robot and their scan data to rviz2.
What I have so far:
I have multiple robots in my gazebo simulation. I am using launch file to launch spawners to spawn the entities. I have sdf file xml of my model.
This is include description of the robot in my launcher:
spawn_entity1 = Node(package='robot_spawner_pkg', executable='spawn_demo',
arguments=['WarehouseBot1', 'robot1', '-4', '-3', '0.0'],
output='screen')
spawn_entity2 = Node(package='robot_spawner_pkg', executable='spawn_demo',
arguments=['WarehouseBot2', 'robot2', '-4', '-2', '0.0'],
output='screen')
return LaunchDescription([
gazebo,
spawn_entity1,
spawn_entity2,
IncludeLaunchDescription(
PythonLaunchDescriptionSource([launch_file_dir, '/robot_state_publisher.launch.py']),
launch_arguments={'use_sim_time': use_sim_time}.items(),
),
])
This is my robot_state_publisher:
def generate_launch_description():
use_sim_time = LaunchConfiguration('use_sim_time', default='false')
urdf_file_name = 'turtlebot3_burger.urdf'
print('urdf_file_name : {}'.format(urdf_file_name))
urdf = os.path.join(
get_package_share_directory('turtlebot3_description'),
'urdf',
urdf_file_name)
return LaunchDescription([
DeclareLaunchArgument(
'use_sim_time',
default_value='false',
description='Use simulation (Gazebo) clock if true'),
Node(
package='robot_state_publisher',
executable='robot_state_publisher',
name='robot_state_publisher',
output='screen',
parameters=[{'use_sim_time': use_sim_time}],
arguments=[urdf]),
])
One thing poped up in my mind. It is to make separate sdf file for every robot with specific namespace and then publish separate robot_descriptions for every one. I am not sure if it would be working.
Al so I am kind of beginner in the terms of ros programming so I apologize for wrong formulations.
My setup:
ROS2 foxy
Python
Gazebo 11.9
Edit:
Eventually, in rviz I can specify tf prefix (I suppose frame_prefix now) for every robot_description to visualize the model. However, I would like to have something like "/robot1/tf" "robot2/tf". Is it even possible in ROS2?
According to this it is not very possible: https://answers.ros.org/question/388550/a-definitive-guide-to-launching-multi-robot-operations-in-ros2/?sort=latest
Question: "When should you use frame_prefix? When should you add a prefix directly in your URDF/Xacro files? Where do you need to apply a frame_prefix or namespace? (Gazebo plugins, ros2_control config files, robot_state_publisher)? When should you use fully qualified vs relative names? Are there any common cases other than /tf where you would not want to use relative topic names? When should you use a single tf tree for all robots, and when should you use a different tf tree for each robot?"
Answer: "Can't answer that one articulately at the moment. The prevailing standard set up by OSRF is that they've removed "prefix" in TF2, which I disagree with for exactly these multirobot situations. So there's conflict there that needs more explicit discussion. I would want to bin my TF messages either by having different /<my_robot>/tf topics or having sub-namespaces to the frames in the TF topic to be easily able to distinguish one robot from another's updates. I would prefer different topics for obvious bandwidth reasons, but I think those were implicitly removed from ROS 2 as a parameter. "