ROS中 FileNotFoundError: [Errno 2] No such file or directory: ‘/opt/ros/noetic/lib/xacro/xacro

博主在ROS中进行urdf文件和xacro文件转换,把urdf转化成xacro后,运行launch文件报错如下:

Traceback (most recent call last):
File “/opt/ros/noetic/lib/python3/dist-packages/roslaunch/init.py”, line 347, in main
p.start()
File “/opt/ros/noetic/lib/python3/dist-packages/roslaunch/parent.py”, line 305, in start
self._start_infrastructure()
File “/opt/ros/noetic/lib/python3/dist-packages/roslaunch/parent.py”, line 254, in _start_infrastructure
self._load_config()
File “/opt/ros/noetic/lib/python3/dist-packages/roslaunch/parent.py”, line 156, in _load_config
self.config = roslaunch.config.load_config_default(self.roslaunch_files, self.port,
File “/opt/ros/noetic/lib/python3/dist-packages/roslaunch/config.py”, line 461, in load_config_default
loader.load(f, config, argv=args, verbose=verbose)
File “/opt/ros/noetic/lib/python3/dist-packages/roslaunch/xmlloader.py”, line 761, in load
self._load_launch(launch, ros_config, is_core=core, filename=filename, argv=argv, verbose=verbose)
File “/opt/ros/noetic/lib/python3/dist-packages/roslaunch/xmlloader.py”, line 733, in _load_launch
self._recurse_load(ros_config, launch.childNodes, self.root_context, None, is_core, verbose)
File “/opt/ros/noetic/lib/python3/dist-packages/roslaunch/xmlloader.py”, line 679, in _recurse_load
self._param_tag(tag, context, ros_config, verbose=verbose)
File “/opt/ros/noetic/lib/python3/dist-packages/roslaunch/xmlloader.py”, line 96, in call
return f(*args, **kwds)
File “/opt/ros/noetic/lib/python3/dist-packages/roslaunch/xmlloader.py”, line 271, in _param_tag
value = self.param_value(verbose, name, ptype, *vals)
File “/opt/ros/noetic/lib/python3/dist-packages/roslaunch/loader.py”, line 478, in param_value
with open(textfile, ‘r’) as f:
FileNotFoundError: [Errno 2] No such file or directory: ‘/opt/ros/noetic/lib/xacro/xacro /home/yzxie/桌面/Autobot_ws/src/robot_model/urdf/car.xacro’

主要是最后一行,报错的两个文件都能够打开。
原本以为功能包缺少xacro依赖,添加后发现依然报错。
后来发现在launch文件中,加载参数服务器时,urdf和xacro文件的查找命令是不一样的:

<param name="robot_description" command="$(find xacro)/xacro $(find robot_model)/urdf/car.xacro"/>
<param name="robot_description" textfile="$(find robot_model)/urdf/car.urdf"/>

在这里博主把textfile忘记更改为command,从而出现的错误!

你可能感兴趣的:(ros,机器人)