ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

Launching xml file from python launch file

asked 2022-07-26 05:14:05 -0500

SonicBoom gravatar image

updated 2022-07-26 05:48:56 -0500

I'm trying to launch an xml launch file from a python launch file, but it's getting stuck on the <launch> section of the xml.

Is there a different way of doing this?

Code:

def generate_launch_description():
    return LaunchDescription([ 
        IncludeLaunchDescription(PythonLaunchDescriptionSource(
        os.path.join(get_package_share_directory('rosbridge_server'),
         'launch/rosbridge_websocket_launch.xml')))

    ])

Error:

  File "/opt/ros/foxy/share/rosbridge_server/launch/rosbridge_websocket_launch.xml", line 1
    <launch>
    ^
SyntaxError: invalid syntax
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2022-07-28 10:15:31 -0500

JeremieBourque gravatar image

To include an XML file, you need to use FrontendLaunchDescriptionSource instead of PythonLaunchDescriptionSource, which can be imported with from launch.launch_description_sources import FrontendLaunchDescriptionSource.

So the correct code would be:

def generate_launch_description():
    return LaunchDescription([ 
        IncludeLaunchDescription(FrontendLaunchDescriptionSource(
        os.path.join(get_package_share_directory('rosbridge_server'),
         'launch/rosbridge_websocket_launch.xml')))
    ])
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2022-07-26 05:14:05 -0500

Seen: 208 times

Last updated: Jul 28 '22