关于ROS机器人开发实践第六章xacro到URDF的转化,以及打开URDF所出现问题的解决

本人所用的是ubuntu20.04,Noetic

在《ROS机器人开发实践》的P128中

1.将xacro文件转化为URDF文件时: 

运行

$ rosrun xacro xacro.py mrobot.urdf.xacro > mrobot.urdf

产生的mrobot.urdf内容为:

[rosrun] Couldn't find executable named xacro.py below /opt/ros/noetic/share/xacro

解决方法:

rosrun xacro xacro mrobot.urdf.xacro > mrobot.urdf

2.运行launch文件

roslaunch mrobot_description display_mrobot.launch

出现:

[ERROR] [1692858420.387138318]: No link elements found in urdf file...

原因:Noetic版本的ROS在xacro宏定义语法中与之前版本不同调用宏的时候需要在开头添加xacro:,修改mrobot.urdf.xacro文件中调mrobot_body.urdf.xacro的语句::

	<!-- MRobot机器人平台 -->
	<mrobot_body />

改为:

	<!-- MRobot机器人平台 -->
	<xacro:mrobot_body />

3.在Rviz中显示xacro模型没有报错,但是缺失部件(小车的八根支柱没有显示)

原因:同上,版本不同导致宏调用语法的不同。需要调用宏时在开头添加xacro:,具体是在mrobot_body.urdf.xacro文件中调用支柱宏定义处,如图

 <mrobot_standoff_2in parent="base_link" number="1" x_loc="-${standoff_x/2 + 0.03}" y_loc="-${standoff_y - 0.03}" z_loc="${plate_height/2}"/>

改为:

<xacro:mrobot_standoff_2in parent="base_link" number="1" x_loc="-${standoff_x/2 + 0.03}" y_loc="-${standoff_y - 0.03}" z_loc="${plate_height/2}"/>

一共八处需要更改:

<xacro:mrobot_standoff_2in parent="base_link" number="1" x_loc="-${standoff_x/2 + 0.03}" y_loc="-${standoff_y - 0.03}" z_loc="${plate_height/2}"/>
<xacro:mrobot_standoff_2in parent="base_link" number="2" x_loc="-${standoff_x/2 + 0.03}" y_loc="${standoff_y - 0.03}" z_loc="${plate_height/2}"/>
<xacro:mrobot_standoff_2in parent="base_link" number="3" x_loc="${standoff_x/2}" y_loc="-${standoff_y}" z_loc="${plate_height/2}"/>
<xacro:mrobot_standoff_2in parent="base_link" number="4" x_loc="${standoff_x/2}" y_loc="${standoff_y}" z_loc="${plate_height/2}"/>
<xacro:mrobot_standoff_2in parent="standoff_2in_1_link" number="5" x_loc="0" y_loc="0" z_loc="${plate_height}"/>
<xacro:mrobot_standoff_2in parent="standoff_2in_2_link" number="6" x_loc="0" y_loc="0" z_loc="${plate_height}"/>
<xacro:mrobot_standoff_2in parent="standoff_2in_3_link" number="7" x_loc="0" y_loc="0" z_loc="${plate_height}"/>
<xacro:mrobot_standoff_2in parent="standoff_2in_4_link" number="8" x_loc="0" y_loc="0" z_loc="${plate_height}"/>

  • 6
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 8
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值