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

error when calling xacro command from python launch file

asked 2023-06-09 00:23:08 -0500

Sebastian-Schroder gravatar image

Currently Running ROS2 Humble & fortress ignition gazebo on 22.04 Ubuntu.

When I run xacro from a python launch file It returns an error. when I run the exact same command from the command line from the folder, it runs as expected, with no error. The goal of this is to use xacro to piece together sdf files for ignition gazebo. I've put a couple hours into this and am stumped. sorry if I haven't posted any crucial information, as I am new to ros in general

xacro_world_file = ExecuteProcess(
    cmd=[[' xacro ', world_name, ' -o sdf/',world_name,' -v']],
    cwd=urdf_path, # the location to do the command from

[ -v-2] XML parsing error: no element found: line 1, column 0

[ -v-2] when processing file: /home/sperospace/Git/Robotic_Arm/01_Prototypes/03_Gecko


[ -v-2] included from:

[ -v-2]

[ -v-2] Check that:

[ -v-2] - Your XML is well-formed

[ -v-2] - You have the xacro xmlns declaration: xmlns:xacro=""

[] Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2023-06-09 02:25:58 -0500

Sebastian-Schroder gravatar image

A way around this I found was to instead use the provided xacro import with the following code.

doc = xacro.process(os.path.join(urdf_path,world_name),)

with open(os.path.join(urdf_path,'sdf',world_name),"w+") as f:
edit flag offensive delete link more


if you need to run a command line function from a launch file, which method is better? using python, or creating a ExecuteProcess launch description.

Sebastian-Schroder gravatar image Sebastian-Schroder  ( 2023-06-09 02:31:22 -0500 )edit

Question Tools

1 follower


Asked: 2023-06-09 00:23:08 -0500

Seen: 224 times

Last updated: Jun 09 '23