[foxy] Different results when using xacro from launch and command line
Hello,
I have a .xacro file I want to convert to .urdf in order to launch a robot_state_publisher node with it.
If i use xacro in command line then launch the node with the resulting urdf file, everything works fine:
xacro path/to/xacro/suitee.xacro > out.urdf
ros2 run robot_state_publisher robot_state_publisher out.urdf
I have however created a launch file that consists of the following:
from ament_index_python import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration, Command
from launch_ros.actions import Node
import os
def generate_launch_description():
use_sim_time = LaunchConfiguration('use_sim_time', default='false')
suitee_xacro = os.path.join(get_package_share_directory('s_description'), 'urdf', 'suitee.xacro')
return LaunchDescription([
DeclareLaunchArgument(
'use_sim_time',
default_value='false',
description='Use simulation (Gazebo) clock if true'),
Node(
package='robot_state_publisher',
executable='robot_state_publisher',
name='robot_state_publisher_robot',
output='screen',
parameters=[{
'use_sim_time': use_sim_time,
'robot_description': Command(['xacro', ' ', suitee_xacro])
}]),
])
When I try to launch this file, I have the following error:
yaml.scanner.ScannerError: while scanning for the next token
found character '\t' that cannot start any token
in "<unicode string>", line 47, column 1:
<xacro:insert_block name="s ...
^
I dont know why this happens here and not when i convert xacro on command line, any insights on this ?
I can provide xacro file if needed.
I encountered the same issue. With a similar launch setup, I used the xacro file found here.
I got an error:
The word "truck" is part of an XML comment block at the beginning of the file. Removing the comment avoids the error. Is there a better workaround? Why must the output of xacro be parsed as yaml?