Xacro Error: NoneType object has no attribute getitem
I'm trying to convert my tortoisebot.urdf.xacro
file to a tortoisebot.urdf
file by running rosrun xacro xacro tortoisebot.urdf.xacro > tortoisebot.urdf
When I run this command I get this error:
~/tortoisebot_ws/src/tortoisebot_description/robots$ rosrun xacro xacro tortoisebot.urdf.xacro > tortoisebot.urdf
Traceback (most recent call last):
File "/opt/ros/indigo/lib/xacro/xacro", line 55, in <module>
xacro.main()
File "/opt/ros/indigo/lib/python2.7/dist-packages/xacro/__init__.py", line 696, in main
eval_self_contained(doc)
File "/opt/ros/indigo/lib/python2.7/dist-packages/xacro/__init__.py", line 626, in eval_self_contained
eval_all(doc.documentElement, macros, symbols)
File "/opt/ros/indigo/lib/python2.7/dist-packages/xacro/__init__.py", line 553, in eval_all
eval_all(body, macros, scoped)
File "/opt/ros/indigo/lib/python2.7/dist-packages/xacro/__init__.py", line 609, in eval_all
result = eval_text(at[1], symbols)
File "/opt/ros/indigo/lib/python2.7/dist-packages/xacro/__init__.py", line 483, in eval_text
results.append(handle_expr(lex.next()[1][2:-1]))
File "/opt/ros/indigo/lib/python2.7/dist-packages/xacro/__init__.py", line 470, in handle_expr
return eval_expr(lex, symbols)
File "/opt/ros/indigo/lib/python2.7/dist-packages/xacro/__init__.py", line 444, in eval_expr
result = eval_term(lex, symbols)
File "/opt/ros/indigo/lib/python2.7/dist-packages/xacro/__init__.py", line 418, in eval_term
result = eval_factor(lex, symbols)
File "/opt/ros/indigo/lib/python2.7/dist-packages/xacro/__init__.py", line 402, in eval_factor
result = eval_expr(lex, symbols)
File "/opt/ros/indigo/lib/python2.7/dist-packages/xacro/__init__.py", line 439, in eval_expr
if lex.peek()[0] == lex.OP:
TypeError: 'NoneType' object has no attribute '__getitem__'
Here is my Xacro file:
<?xml version="1.0"?>
<robot name="tortoisebot" xmlns:xacro="http://www.ros.org/wiki/xacro" >
<xacro:property name="pi" value="3.14159265" />
<xacro:property name="body_radius" value="0.17" />
<xacro:property name="body_height" value="0.2" />
<xacro:property name="body_mass" value="2.0" />
<xacro:property name="rear_caster_radius" value="0.01" />
<xacro:property name="rear_caster_mass" value="0.1" />
<xacro:property name="wheel_radius" value="0.036" />
<xacro:property name="wheel_height" value="0.025" />
<xacro:property name="wheel_mass" value="0.1" />
<xacro:property name="right_wheel_color" value="${red}" />
<xacro:property name="left_wheel_color" value="${white}" />
<xacro:macro name="inertia_cylinder" params="mass radius height">
<inertial>
<mass value="${mass}"/>
<inertia ixx="${(${mass} / 12)*((3 * ${radius} * ${radius}) + (${height} * ${height}))}"
ixy="0.0" ixz="0.0" iyy="${(${mass} / 12)*((3 * ${radius} * ${radius}) + (${height} * ${height}))}"
iyz="0.0" izz="${(${mass} * ${radius} * ${radius}) / 2}"/>
</inertial>
</xacro:macro>
<xacro:macro name="inertia_sphere" params="mass radius">
<inertial>
<mass value="${mass}"/>
<inertia ixx="${2 * ${mass} * ${radius} * ${radius} / 5}"
ixy="0.0" ixz="0.0" iyy="${2 * ${mass} * ${radius} * ${radius} / 5}"
iyz="0.0" izz="${2 * ${mass} * ${radius} * ${radius} / 5}"/>
</inertial>
</xacro:macro>
<xacro:property name="white">
<material name="white">
<color rgba="1, 1, 1, 1"/>
</material>
</xacro:property>
<xacro:property name="green">
<material name="green">
<color rgba="0.05 0.75 0.05 1"/>
</material>
</xacro:property>
<xacro:property name="black">
<material name="black">
<color rgba="1, 1, 1, 1"/>
</material>
</xacro ...
for error text, console copy-pastes, code and urdf/xacros: please use the Preformatted Text button. It's the one with
101010
on it.Could you please move the contents of the gists to your question body? Thanks.
A quick look at your
xacro
shows that you are trying to mixurdf
andsdf
. That is not supported. I wouldn't be surprised if that is the cause of your error.I've updated my question with the code inserted. Thanks for your input on
sdf
I removed the section of the file that I think was SDF and tried rerunning the code with the same error. Any idea as to what is causing this?