0
$\begingroup$

I have an issue when trying to execute a python launch file. Whenever I execute the file I get the following error:

[INFO] [launch]: All log files can be found below /home/jonas/.ros/log/2024-03-03-11-26-59-235308-jonas-30810
[INFO] [launch]: Default logging verbosity is set to INFO
[ERROR] [launch]: Caught exception in launch (see debug for traceback): Caught multiple exceptions when trying to load file of format [py]:
 - XacroException: No such file or directory: ./mercury_description.urdf.xacro [Errno 2] No such file or directory: './mercury_description.urdf.xacro'
 - InvalidFrontendLaunchFileError: The launch file may have a syntax error, or its format is unknown

I already checked that xacro_file generates the correct path and corresponds to the path mercury_gazebo.urdf.xacro which is located in the share urdf folder. Here is the path (generated in xacro_file and this is the same for the actual file): /home/jonas/ros2_ws/install/tr_robot_description/share/tr_robot_description/urdf/mercury_gazebo.urdf.xacro

For the second error I don't have an idea what I have to check.

What could I try to resolve this issue?

Here is the complete launch file:

import os

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import ExecuteProcess, IncludeLaunchDescription, RegisterEventHandler
from launch.event_handlers import OnProcessExit
from launch.launch_description_sources import PythonLaunchDescriptionSource
import xacro


def generate_launch_description():

    mercury_description_path = os.path.join(
        get_package_share_directory('tr_robot_description'))

    xacro_file = os.path.join(mercury_description_path,
                              'urdf',
                              'mercury_gazebo.urdf.xacro') 

    doc = xacro.parse(open(xacro_file))
    xacro.process_doc(doc)
    robot_description_config = doc.toxml()
    robot_description = {'robot_description': robot_description_config}

    node_robot_state_publisher = Node(
        package='robot_state_publisher',
        executable='robot_state_publisher',
        output='screen',
        parameters=[robot_description]
    )

    spawn_entity = Node(package='gazebo_ros', executable='spawn_entity.py',
                        arguments=['-topic', 'robot_description',
                                   '-entity', 'robot'],
                        output='screen')

    joint_state_broadcaster_spawner = Node(
        package="controller_manager",
        executable="spawner",
        arguments=["joint_state_broadcaster",
                   "--controller-manager", "/controller_manager"],
    )

    robot_controller_spawner = Node(
        package="controller_manager",
        executable="spawner",
        arguments=["position_trajectory_controller", "-c", "/controller_manager"],
    )


    return LaunchDescription([
        RegisterEventHandler(
            event_handler=OnProcessExit(
                target_action=spawn_entity,
                on_exit=[joint_state_broadcaster_spawner],
            )
        ),
        RegisterEventHandler(
            event_handler=OnProcessExit(
                target_action=joint_state_broadcaster_spawner,
                on_exit=[robot_controller_spawner],
            )
        ),
        spawn_entity,
        node_robot_state_publisher,
    ])
$\endgroup$

1 Answer 1

1
$\begingroup$

Oh I maybe just saw the issue. I guess there is an issue in the mercury_gazebo.urdf.xacro

Adding $(find tr_robot_description)/urdf/ in front of every xacro include recolved all the xacro errors

$\endgroup$
0

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.