ros1 Ubuntu xacro
<robot name="my_base" xmlns:xacro="http://www.ros.org/wiki/xacro">
<xacro:property name="PI" value="3.141"/>
<material name="black">
<color rgba="0.0 0.0 0.0 1.0" />
</material>
<xacro:property name="base_footprint_radius" value="0.001" />
<xacro:property name="base_link_radius" value="0.1" />
<xacro:property name="base_link_length" value="0.08" />
<xacro:property name="earth_space" value="0.015" />
<link name="base_footprint">
<visual>
<geometry>
<sphere radius="${base_footprint_radius}" />
</geometry>
</visual>
</link>
<link name="base_link">
<visual>
<geometry>
<cylinder radius="${base_link_radius}" length="${base_link_length}" />
</geometry>
<origin xyz="0 0 0" rpy="0 0 0" />
<material name="yellow">
<color rgba="0.5 0.3 0.0 0.5" />
</material>
</visual>
</link>
<joint name="base_link2base_footprint" type="fixed">
<parent link="base_footprint" />
<child link="base_link" />
<origin xyz="0 0 ${earth_space + base_link_length / 2 }" />
</joint>
<xacro:property name="wheel_radius" value="0.0325" />
<xacro:property name="wheel_length" value="0.015" />
<xacro:macro name="add_wheels" params="name flag">
<link name="${name}_wheel">
<visual>
<geometry>
<cylinder radius="${wheel_radius}" length="${wheel_length}" />
</geometry>
<origin xyz="0.0 0.0 0.0" rpy="${PI / 2} 0.0 0.0" />
<material name="black" />
</visual>
</link>
<joint name="${name}_wheel2base_link" type="continuous">
<parent link="base_link" />
<child link="${name}_wheel" />
<origin xyz="0 ${flag * base_link_radius} ${-(earth_space + base_link_length / 2 - wheel_radius) }" />
<axis xyz="0 1 0" />
</joint>
</xacro:macro>
<xacro:add_wheels name="left" flag="1" />
<xacro:add_wheels name="right" flag="-1" />
<xacro:property name="support_wheel_radius" value="0.0075" />
<xacro:macro name="add_support_wheel" params="name flag" >
<link name="${name}_wheel">
<visual>
<geometry>
<sphere radius="${support_wheel_radius}" />
</geometry>
<origin xyz="0 0 0" rpy="0 0 0" />
<material name="black" />
</visual>
</link>
<joint name="${name}_wheel2base_link" type="continuous">
<parent link="base_link" />
<child link="${name}_wheel" />
<origin xyz="${flag * (base_link_radius - support_wheel_radius)} 0 ${-(base_link_length / 2 + earth_space / 2)}" />
<axis xyz="1 1 1" />
</joint>
</xacro:macro>
<xacro:add_support_wheel name="front" flag="1" />
<xacro:add_support_wheel name="back" flag="-1" />
</robot>
Error: radius [${base_footprint_radius}] is not a valid float
at line 126 in /build/urdfdom-VnCcob/urdfdom-1.0.4+ds/urdf_parser/src/link.cpp
Error: Could not parse visual element for Link [base_footprint]
at line 453 in /build/urdfdom-VnCcob/urdfdom-1.0.4+ds/urdf_parser/src/link.cpp
Error: length [${base_link_length}] is not a valid float
at line 173 in /build/urdfdom-VnCcob/urdfdom-1.0.4+ds/urdf_parser/src/link.cpp
Error: Could not parse visual element for Link [base_link]
at line 453 in /build/urdfdom-VnCcob/urdfdom-1.0.4+ds/urdf_parser/src/link.cpp
Error: Unable to parse component [${earth_space] to a double (while parsing a vector value)
at line 102 in /build/urdfdom-VnCcob/urdfdom-1.0.4+ds/urdf_parser/src/pose.cpp
Error: Malformed parent origin element for joint [base_link2base_footprint]
at line 362 in /build/urdfdom-VnCcob/urdfdom-1.0.4+ds/urdf_parser/src/joint.cpp
Error: joint xml is not initialized correctly
at line 233 in /build/urdfdom-VnCcob/urdfdom-1.0.4+ds/urdf_parser/src/model.cpp
ERROR: Model Parsing the xml failed
应该是xacro:property的问题 别的代码这一行也不好使 但是好像能正常转换为urdf文件 [${base_footprint_radius}] 也被成功替换,但check_urdf时还是显示有错误
运行也没有问题,rviz打开的模型也是正确的
赵老师的ros课吧?我也碰到了一样的问题。你看看你check的是哪个文件,要check的是demo05_car_base.urdf,你可能check成demo05_car_base.urdf.xacro了。
jint_state_publisher 关节状态发布节点 取消注释就好了
要先把xacro文件转换为urdf文件
这个错误的原因是你的"radius"属性值是一个字符串,而不是一个数值。请确保你的xacro文件中的所有属性值都是有效的数字,而不是字符串。在你的代码中,可以看到你使用了一个名为"base_footprint_radius"的属性,确保它是一个有效的数值。