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

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
    shell=True,
)

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

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

/04_simulation/monke_gazebo/install/monke_gazebo_load/share/monke_gazebo_load/urdf/sdf/monke_gz.sdf

[monke_sim.world -v-2] included from: monke_sim.world

[monke_sim.world -v-2]

[monke_sim.world -v-2] Check that:

[monke_sim.world -v-2] - Your XML is well-formed

[monke_sim.world -v-2] - You have the xacro xmlns declaration: xmlns:xacro="http://www.ros.org/wiki/..."

[monke_sim.world-3] 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
0

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:
    f.write(doc);
edit flag offensive delete link more

Comments

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

Stats

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

Seen: 224 times

Last updated: Jun 09 '23