Again, I found the code provided in official tutorial to be suboptimal. Below you can see the code from official tutorial commented out, along with a suggested alternative:
# urdf defined in globals.py # urdf = os.path.join(bringup_dir,'description','robot.urdf.xacro') #start_robot_state_publisher_cmd = Node( # condition=IfCondition(use_robot_state_pub), # package='robot_state_publisher', # executable='robot_state_publisher', # name='robot_state_publisher', # namespace=namespace, # output='screen', # parameters=[{'use_sim_time': use_sim_time}], # remappings=remappings, # arguments=[urdf]) # Alternative: robot_description_config = xacro.process_file(urdf) params = {'robot_description': robot_description_config.toxml(), 'use_sim_time': use_sim_time} start_robot_state_publisher_cmd = Node( condition=IfCondition(use_robot_state_pub), package='robot_state_publisher', executable='robot_state_publisher', #name='robot_state_publisher', namespace=namespace, output='screen', remappings=remappings, parameters=[params] )
This is not a big deal, but at least we do not see the message about using an approach that is about to be discontinued. However, the next part is much more serious:
spawn_entity_cmd = Node(package='gazebo_ros', executable='spawn_entity.py', arguments=['-topic', 'robot_description', '-entity', 'navigation_bot_04'], parameters=[{'use_sim_time': use_sim_time}], output='screen')
In the code above, we spawn the robot, so it shows up in a Gazebo. This conflicts with the code from the previous section (bringing up client and server in two separate calls) that I replaced with a single call. Keep in mind, that most likely, if you go deep into ROS2 launch files, you will see that this "single call" calls same two functions, just with different set of parameters; I was just too lazy to track it all, so I used an alternative approach.
As with Gazebo, let's comment out unrelated commands and only bring up the robot (in a Gazebo that we already started):
ld = LaunchDescription() # Declare the launch options ld.add_action(declare_namespace_cmd) ld.add_action(declare_use_namespace_cmd) #ld.add_action(declare_slam_cmd) #ld.add_action(declare_map_yaml_cmd) ld.add_action(declare_use_sim_time_cmd) #ld.add_action(declare_params_file_cmd) #ld.add_action(declare_bt_xml_cmd) #ld.add_action(declare_autostart_cmd) #ld.add_action(declare_rviz_config_file_cmd) ld.add_action(declare_use_simulator_cmd) ld.add_action(declare_use_robot_state_pub_cmd) #ld.add_action(declare_use_rviz_cmd) ld.add_action(declare_simulator_cmd) ld.add_action(declare_world_cmd) # Add any conditioned actions #ld.add_action(start_gazebo_server_cmd) #ld.add_action(start_gazebo_client_cmd) ld.add_action(gazebo) # Add the actions to launch all of the navigation nodes ld.add_action(start_robot_state_publisher_cmd) ld.add_action(spawn_entity_cmd) #ld.add_action(rviz_cmd) #ld.add_action(bringup_cmd) return ld