No link elements found in urdf file

本文讲述了作者在配置UR5机器人MoveIt过程中遇到的报错,包括'Nonamegivenfortherobot'和'Nolinkelementsfoundinurdffile',通过深入分析urdf文件,发现宏定义问题并最终解决了加载ur5_robot.urdf.xacro的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档


背景

修改过后的ur5的机器人模型文件,想重新配置一下moveit,于是运行roslaunch ur5_moveit_config setup_assistant.launch ,加载的是ur5.urdf.xacro这个文件,一开始报错是(这个报错出现在命令行上):

[ERROR] [1649224909.076522137]: No name given for the robot.

打开ur5.urdf.xacro这个文件,确实robot标签里没有名字,于是手动加上

<robot name="ur5"  xmlns:xacro="http://wiki.ros.org/xacro">

再次load,报错[ERROR] [1649224996.611236726]: No link elements found in urdf file

[ERROR] [1649224996.611236726]: No link elements found in urdf file

在这里插入图片描述
在这里插入图片描述


提示:以下是本篇文章正文内容,下面案例可供参考

一、解决方案

这个报错的意思是urdf文件中没有链接元素,明明里面写了七八个link元素却报这个错,是为什么呢?这两个链接里给了答案:
ros answer的答案

github上的回答
这两个回答最终都指向一个,就是加载的ur5.urdf.xacro文件里面,是写了<xacro:macro name="ur5_robot" params="prefix joint_limited<xacro:macro name="cylinder_inertial"两个宏定义,而<xacro:macro name="ur5_robot" params="prefix joint_limited这个宏定义只有定义没有实例化.参考github回答里的这句话:

The create.urdf.xacro file just contains a macro for instantiating a create model, but does not call it. The intended use is to include the create.urdf.xacro file in your model and then instantiate it like so:

<xacro:include filename="$(find create_description)/urdf/create.urdf.xacro"/>
<create />

UR_description里的文件结构是,这部分的实例化写在了ur5_robot.urdf.xacro这个文件,所以需要加载的是这个文件.虽然这个文件里也包含了robot name,但我试了一下,如果删除ur5.urdf.xacro里的robot name ,第一个报错也就是之前我们第一步解决No name given for the robot还是会出现.所以为了保险起见,先在ur5.urdf.xacro添加robot name,也就是

<robot name="ur5"  xmlns:xacro="http://wiki.ros.org/xacro">

再加载ur5_robot.urdf.xacro这个文件
成功加载以后的图片如下:

在这里插入图片描述

yplros@yplros-VirtualBox:~/yplcar$ ros2 launch yplcar_description dispaly_robot.launch.py model:=/home/yplros/yplcar/install/yplcar_description/share/yplcar_description/urdf/yplcar_two/yplcar_two.urdf.xacro [INFO] [launch]: All log files can be found below /home/yplros/.ros/log/2025-03-27-17-18-26-128786-yplros-VirtualBox-5930 [INFO] [launch]: Default logging verbosity is set to INFO [INFO] [robot_state_publisher-1]: process started with pid [5932] [INFO] [joint_state_publisher-2]: process started with pid [5934] [INFO] [rviz2-3]: process started with pid [5936] [robot_state_publisher-1] Error: No link elements found in urdf file [robot_state_publisher-1] at line 206 in ./urdf_parser/src/model.cpp [robot_state_publisher-1] Failed to parse robot description using: urdf_xml_parser/URDFXMLParser [robot_state_publisher-1] terminate called after throwing an instance of 'std::runtime_error' [robot_state_publisher-1] what(): Unable to initialize urdf::model from robot description [rviz2-3] qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in "" [ERROR] [robot_state_publisher-1]: process has died [pid 5932, exit code -6, cmd '/opt/ros/humble/lib/robot_state_publisher/robot_state_publisher --ros-args --params-file /tmp/launch_params_8qpseil8']. [rviz2-3] [INFO] [1743067106.679287165] [rviz2]: Stereo is NOT SUPPORTED [rviz2-3] [INFO] [1743067106.679378435] [rviz2]: OpenGl version: 4.5 (GLSL 4.5) [joint_state_publisher-2] [INFO] [1743067106.704159000] [joint_state_publisher]: Waiting for robot_description to be published on the robot_description topic... [rviz2-3] [INFO] [1743067106.770849572] [rviz2]: Stereo is NOT SUPPORTED [INFO] [rviz2-3]: process has finished cleanly [pid 5936] ^C[WARNING] [launch]: user interrupted with ctrl-c (SIGINT) [INFO] [joint_state_publisher-2]: process has finished cleanly [pid 5934]
最新发布
03-28
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值