Rosanswers logo

Hi there!

I'm using ROS2 Galactic and have a python package that simply spawn a robot. It works with a complex URDF model of a robot that have meshes and sensors, but what's driving me crazy is that it doesn't work with the following simple URDF model:

<?xml version="1.0"?>
<robot name="multipleshapes">
  <link name="base_link">
        <cylinder length="0.6" radius="0.2"/>

  <link name="right_leg">
        <box size="0.6 0.1 0.2"/>

  <joint name="base_to_right_leg" type="fixed">
    <parent link="base_link"/>
    <child link="right_leg"/>


The URDF files are both in the same place. When I run the launch file to spawn the model it seems to work but the model doesn't appear in Gazebo. I don't get errors.

ros@ubuntu:~/ros2_ws$ ros2 launch mars_robot mars_robot.launch.py
[INFO] [launch]: All log files can be found below /home/ros/.ros/log/2022-05-17-18-57-27-755134-ubuntu-24691
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [gzserver-1]: process started with pid [24693]
[INFO] [gzclient   -2]: process started with pid [24696]
[INFO] [robot_state_publisher-3]: process started with pid [24699]
[INFO] [spawn_entity.py-4]: process started with pid [24701]
[robot_state_publisher-3] Link right_leg had 0 children
[robot_state_publisher-3] [INFO] [1652806649.104605067] [robot_state_publisher]: got segment base_link
[robot_state_publisher-3] [INFO] [1652806649.106763959] [robot_state_publisher]: got segment right_leg
[spawn_entity.py-4] [INFO] [1652806650.703018213] [spawn_entity]: Spawn Entity started
[spawn_entity.py-4] [INFO] [1652806650.707231388] [spawn_entity]: Loading entity published on topic robot_description
[spawn_entity.py-4] [INFO] [1652806650.711765040] [spawn_entity]: Waiting for entity xml on robot_description
[spawn_entity.py-4] [INFO] [1652806650.713877199] [spawn_entity]: Waiting for service /spawn_entity, timeout = 5
[spawn_entity.py-4] [INFO] [1652806650.717389319] [spawn_entity]: Waiting for service /spawn_entity
[spawn_entity.py-4] [INFO] [1652806653.745771815] [spawn_entity]: Calling service /spawn_entity
[spawn_entity.py-4] [INFO] [1652806653.975522539] [spawn_entity]: Spawn status: SpawnEntity: Successfully spawned entity [mars_robot]
[spawn_entity.py-4] /opt/ros/galactic/lib/python3.8/site-packages/rclpy/qos.py:307: UserWarning: DurabilityPolicy.RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL is deprecated. Use DurabilityPolicy.TRANSIENT_LOCAL instead.
[spawn_entity.py-4]   warnings.warn(
[INFO] [spawn_entity.py-4]: process has finished cleanly [pid 24701]

The code of the launch file is the following:

import os
import xacro

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription 
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch_ros.actions import Node
from launch.actions import SetEnvironmentVariable
from launch.substitutions import EnvironmentVariable

def generate_launch_description():

    pkg_install_path = get_package_share_directory('mars_robot')

    if 'GAZEBO_MODEL_PATH' in os.environ:
        model_path =  os.environ['GAZEBO_MODEL_PATH'] + ':' + pkg_install_path
        model_path =  pkg_install_path

    xacro_robot_pkg_path = os.path.join(

    xacro_file = os.path.join(xacro_robot_pkg_path,

    doc = xacro.parse(open(xacro_file))

    node_robot_state_publisher = Node(
        parameters=[{'robot_description': doc.toxml()}]

    spawn_entity = Node(package='gazebo_ros', executable='spawn_entity.py',
                        arguments=['-topic', 'robot_description',
                                   '-entity', 'mars_robot'],

    gazebo = IncludeLaunchDescription(
                    get_package_share_directory('gazebo_ros'), 'launch', 'gazebo.launch.py')]),

    return LaunchDescription([

I've been trying to solve the problem for several days but I can't find the solution. Can someone point me to what I'm doing wrong?

Thanks for your help in advance.

Originally posted by joseecm on ROS Answers with karma: 130 on 2022-05-17

Post score: 0

Original comments

Comment by Joe28965 on 2022-05-18:
It might be that Gazebo doesn't like the model, since it doesn't have any collision nor any inertial tags.

I know Gazebo can be very finicky with that stuff. I'd recommend adding some and seeing what happens. Also, start with 1 link, just to make it easier, before adding others.


1 Answer 1


Rosanswers logo

Thanks @Joe28965 for your answer, you are right. If I add the inertial and collision tags the model appears in Gazebo. What was confusing me is that there are many packages that use urdf files where these tags do not appear, I suppose because they are designed to be used with RVIZ and not with GAZEBO.

Originally posted by joseecm with karma: 130 on 2022-05-19

This answer was ACCEPTED on the original site

Post score: 0


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.