Hi, I am beginning to learn ROS and have encountered a strange issue. I have created 2 packages called, my_first_cpp_pkg and urdf_example, which contain xacro xmls of their own for URDF creation. I am getting to know the functionality of the launch file for ease.
I have an xacro file called example_urdf.robot.xacro in the package urdf_example, which if I try to run via command line to create the robot_description topic
ros2 run robot_state_publisher robot_state_publisher --ros-args -p robot_description:="$(xacro ros_articubot_tutorial/urdf_example/description/example_robot.urdf.xacro)"
throws the following error:-
[rcutils|error_handling.c:65] an error string (message, file name, or formatted message) will be truncated
[ERROR] [1659504478.236363109] [rcl]: Failed to parse global arguments
terminate called after throwing an instance of 'rclcpp::exceptions::RCLInvalidROSArgsError'
what(): failed to initialize rcl: Couldn't parse parameter override rule: '-p robot_description:=<?xml version="1.0" ?
<!-- =================================================================================== -->
<!-- | This document was autogenerated by xacro from ros_articubot_tutorial/urdf_example/description/example_robot.urdf.xacro | -->
<!-- | EDITING THIS FILE BY HAND IS NOT RECOMMENDED | -->
<!-- =================================================================================== -->
<robot name="robot">
<!-- This is an example of a URDF. -->
<!-- As we move through the file, new things to note will be pointed out. -->
<!-- It's not meant an example of GOOD design, but an example of some of the various features of URDF/xacro. -->
<!-- Thi, at /tmp/binarydeb/ros-foxy-rcl-1.1.13/src/rcl/arguments.c:325
However, if I run via a launch file, it works properly-
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch_ros.actions import Node
import xacro
def generate_launch_description():
# Specify the name of the package and path to xacro file within the package
pkg_name = 'urdf_example'
file_subpath = 'description/example_robot.urdf.xacro'
# Use xacro to process the file
xacro_file = os.path.join(get_package_share_directory(pkg_name),file_subpath)
robot_description_raw = xacro.process_file(xacro_file).toxml()
# Configure the node
node_robot_state_publisher = Node(
package='robot_state_publisher',
executable='robot_state_publisher',
output='screen',
parameters=[{'robot_description': robot_description_raw}] # add other parameters here if required
)
# Run the node
return LaunchDescription([
node_robot_state_publisher
])
I wanted to see if it's the issue while processing of xacro file, so I manually parsed it and it works. Then I wanted to test if it's the issue with the command, then I tested the same robot_state_publisher command but gave the path of urdf of the package my_first_cpp_pkg/urdf_path and it works.
So, if it's neither an issue with xml parsing nor an issue with command, then I am not able to identify what is the additional information provided by launch file which makes it work without throwing any error?
Originally posted by manish.nayak on ROS Answers with karma: 3 on 2022-08-03
Post score: 0