在学习B站赵虚左主讲的ROS基础课程—— URDF 结合 Xacro 实操时,在一个xacro文件中调用了封装好的圆柱惯性矩阵函数,出现了如下错误:
xacro: Traditional processing is deprecated. Switch to --inorder processing!
To check for compatibility of your document, use option --check-order.
For more infos, see http://wiki.ros.org/xacro#Processing_Order
can't multiply sequence by non-int of type 'unicode'
when evaluating expression 'm*(3*r*r + h*h) / 12'
when instantiating macro: cylinder_inertial_matrix (/home/qrx/catkin_ws/src/urdf02_gazebo/urdf/cylinder_test.urdf.xacro)
in file: /home/qrx/catkin_ws/src/urdf02_gazebo/urdf/cylinder_test.urdf.xacro
Invalid <param> tag: Cannot load command parameter [robot_description]: command [/opt/ros/kinetic/lib/xacro/xacro /home/qrx/catkin_ws/src/urdf02_gazebo/urdf/cylinder_test.urdf.xacro] returned with code [2].
Param xml is <param command="$(find xacro)/xacro $(find urdf02_gazebo)/urdf/cylinder_test.urdf.xacro" name="robot_description"/>
The traceback for the exception was written to the log file
惯性矩阵代码如下:
<robot name="base" xmlns:xacro="http://wiki.ros.org/xacro">
<!-- Macro for inertia matrix -->
<xacro:macro name="cylinder_inertial_matrix" params="m r h">
<inertial>
<mass value="${m}" />
<inertia ixx="${m*(3*r*r+h*h)/12}" ixy = "0" ixz = "0"
iyy="${m*(3*r*r+h*h)/12}" iyz = "0"
izz="${m*r*r/2}" />
</inertial>
</xacro:macro>
</robot>
所编写的demo08_cylinder.urdf.xacro文件代码如下:
<robot name="cylinder_test" xmlns:xacro="http://wiki.ros.org/xacro">
<xacro:property name="cylinder_radius" value="0.1"/>
<xacro:property name="cylinder_length" value="1"/>
<xacro:property name="cylinder_mass" value="1"/>
<link name="cylinder_link">
<visual>
<geometry>
<cylinder radius="cylinder_radius" length="cylinder_length"/>
</geometry>
<origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
<material>
<color rgba="0.3 0.3 0.6 1.0"/>
</material>
</visual>
<collision>
<geometry>
<cylinder radius="cylinder_radius" length="cylinder_length"/>
</geometry>
<origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
</collision>
<xacro:cylinder_inertial_matrix m="cylinder_mass" r="cylinder_radius" h="cylinder_length"/>
</link>
<gazebo reference="cylinder_link">
<material>Gazebo/Blue</material>
</gazebo>
</robot>
launch文件配置如下:
<launch>
<!-- 1.loanding attributes model in server -->
<param name="robot_description" command="$(find xacro)/xacro $(find urdf02_gazebo)/urdf/cylinder_test.urdf.xacro" />
<!-- 2.launch simulation environment -->
<include file="$(find gazebo_ros)/launch/empty_world.launch" />
<!-- 3. add robot model in Gazebo-->
<node pkg="gazebo_ros" type="spawn_model" name="spawn_model" args="-urdf -model cylinder_test -param robot_description" />
</launch>
由于测试文件与圆柱惯性矩阵函数是分开编写,所以需要包含一下,代码如下:
<robot name="cylinder_test" xmlns:xacro="http://wiki.ros.org/xacro">
<!-- include inertil matrix file -->
<xacro:include filename="head.urdf.xacro"/>
<xacro:include filename="demo08_cylinder.urdf.xacro"/>
</robot>
我已经找了好几个论坛,ROS官方论坛也找了,但没有结果,希望各位能帮我解答一下,万分感谢
运行环境:VM Workstation + Linux Ubuntu 16.04
Ros 版本:kinetic
编程语言:Python 3.5.2
编辑器:VS code
你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答
本次提问扣除的有问必答次数,已经为您补发到账户,我们后续会持续优化,扩大我们的服务范围,为您带来更好地服务。