0
$\begingroup$

I try to visualize turtlebot2 urdf in ros2 humble by following the command ros2 launch urdf_tutorial display.launch.py model:=turtlebot2.urdf. I source my both workspace source /opt/ros/humble/setup.bash & ros2_ws and also done sudo apt install ros-humble-urdf* but still get the following error

display.launch.py model:=turtlebot2.urdf
[INFO] [launch]: All log files can be found below /home/dell/.ros/log/2024-01-11-18-57-33-817547-ubuntu22-24635
[INFO] [launch]: Default logging verbosity is set to INFO
[ERROR] [launch]: Caught exception in launch (see debug for traceback): executed command failed. Command: xacro /opt/ros/humble/share/urdf_tutorial/turtlebot2.urdf
Captured stderr output: Traceback (most recent call last):
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/xacro/__init__.py", line 1012, in parse
    inp = f = open(filename)
FileNotFoundError: [Errno 2] No such file or directory: '/opt/ros/humble/share/urdf_tutorial/turtlebot2.urdf'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/xacro/__init__.py", line 1119, in _process
    doc = process_file(input_file_name, **opts)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/xacro/__init__.py", line 1096, in process_file
    doc = parse(None, input_file_name)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/xacro/__init__.py", line 1016, in parse
    raise XacroException(e.strerror + ": " + e.filename, exc=e)
xacro.XacroException: No such file or directory: /opt/ros/humble/share/urdf_tutorial/turtlebot2.urdf [Errno 2] No such file or directory: '/opt/ros/humble/share/urdf_tutorial/turtlebot2.urdf'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/ros/humble/bin/xacro", line 33, in <module>
    sys.exit(load_entry_point('xacro==2.0.8', 'console_scripts', 'xacro')())
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/xacro/__init__.py", line 1171, in main
    _process(input_file_name, vars(opts))
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/xacro/__init__.py", line 1124, in _process
    except xml.parsers.expat.ExpatError as e:
AttributeError: module 'xml' has no attribute 'parsers'
$\endgroup$

3 Answers 3

0
$\begingroup$

"FileNotFoundError: [Errno 2] No such file or directory: '/opt/ros/humble/share/urdf_tutorial/turtlebot2.urdf'"

Did you try from the folder in which you have turtlebot2.urdf

run the following command: ros2 launch urdf_tutorial display.launch.py model:=/path_to_your_urdf_file/turtlebot2.urdf

path_to_your_urdf_file= go to the folder where the turtlebot2.urdf file is.

$pwd

and copy the exact path from there

$\endgroup$
0
$\begingroup$

Some things to make sure of :

  • Check if you have xacro installed : sudo apt-get install ros-humble-xacro
  • If you have the URDF file in your own ROS package, check that you have added the URDF directory to be copied over when you build. To do that, check the <package_name>_description/CMakeLists.txt and in the install section, verify that you have added the URDF directory
  • Check that the file turtlebot2.urdf is indeed present in your package install location. This is something that strikes me, because I took a look at the source of the pacakge, and I could not find a file named turtlebot.urdf. Maybe you are referring to a wrong package?

xacro /opt/ros/humble/share/urdf_tutorial/turtlebot2.urdf Captured stderr output: Traceback (most recent call last):

This line tells us that the xacro program itself failed to parse the URDF. So, maybe you have a malformed xacro file, take a look at the source xacro file to make sure.

NOTE: A trick that comes in handy while writing a xacro file is to periodically verify that the xacro tool can parse it and generate a valid URDF. To do this, go to your description package, and call the xacro tool directly on the file itself. If you have a file called turtlebot.xacro in your <package_name>/xacro directory, you can do : xacro xacro/turtlebot.xacro from the root of your package, and see if xacro can indeed parse it or not.

$\endgroup$
0
$\begingroup$

I found the xacro_live package which helps me a lot while creating my URDF.

Because the original did not work with Humble I created a pull request.

Hope this helps.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.