0
$\begingroup$

I am trying to spawn custom urdf in ros2. I have following launch file

import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node

def generate_launch_description():
    use_sim_time = LaunchConfiguration('use_sim_time')
    # urdf_file_name = 'urdf/AMR.urdf'  # Relative path from the package
    urdf_file_name = 'urdf/AMR.urdf'  # Relative path from the package


    # print("urdf_file_name : {}".format(urdf_file_name))

    urdf = os.path.join(
        get_package_share_directory('amr_robot'),
        urdf_file_name)

    return LaunchDescription([
        DeclareLaunchArgument(
            'use_sim_time',
            default_value='true',
            description='Use simulation (Gazebo) clock if true'),

        ExecuteProcess(
            cmd=['gazebo', '--verbose', '-s', 'libgazebo_ros_factory.so'],
            output='screen'),

        Node(
            package='gazebo_ros',
            executable='spawn_entity.py',
            name='urdf_spawner',
            output='screen',
            arguments=[
                "-topic", "/robot_description",
                "-entity", "AMR",
                "-robot_namespace", "/"  # Optional, set if necessary
            ]
        )
    ])

when I launch it only gazebo open and robot does not spawn

$\endgroup$
2
  • 1
    $\begingroup$ Welcome to Robotics Stack Exchange! The robot can not be instantiated because there is no robot_description $\endgroup$
    – ravi
    Sep 3, 2023 at 7:53
  • $\begingroup$ can you kindly fix it and give the correct launch file in answer section. Thank you $\endgroup$
    – Mubashir
    Sep 3, 2023 at 7:54

1 Answer 1

1
$\begingroup$

The robot_state_publisher node is missing in the launch file. The spawn_entity.py node is waiting for a urdf string in the topic robot_description. But since robot_state_publisher is not included, there is no node publishing to that topic. Refer to this link for syntax/examples.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.