0
$\begingroup$

Rosanswers logo

Hi, I am learning the tutorial about urdf. I am at the exercise 8 now. The error I have when run the launch file is:

[ERROR] [1478674779.727709696]: length [${bodylen}] is not a valid float
[ERROR] [1478674779.727814955]: Could not parse visual element for Link [base_link]
[ERROR] [1478674779.727917245]: radius [${width}] is not a valid float: bad lexical cast: source type value could not be interpreted as target
[ERROR] [1478674779.727969693]: Could not parse visual element for Link [head]

.....

I will include here to the code from start to base_link. Please help me point out the issue. I cannot find out what is wrong.

   <?xml version="1.0"?>
    <robot name="macroed" xmlns:xacro="http://ros.org/wiki/xacro">
    <!-- Convert to xacro-->
    <robot xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor"
              xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller"
              xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface"
              xmlns:xacro="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface" name="macroed">

        ...

Edit 1: I found the problem. I missed the 4 rows below the link but I got a new error and I don't understand what it is:

...
process[rviz-4]: started with pid [7571]
[ERROR] [1478753950.661833770]: Error reading end tag.
[robot_state_publisher-3] process has died [pid 7563, exit code -11, cmd /opt/ros/indigo/lib/robot_state_publisher/state_publisher __name:=robot_state_publisher __log:=/home/ubuntu/.ros/log/6a4eafd8-a702-11e6-98d1-00044b581868/robot_state_publisher-3.log].
log file: /home/ubuntu/.ros/log/6a4eafd8-a702-11e6-98d1-00044b581868/robot_state_publisher-3*.log
Traceback (most recent call last):
  File "/opt/ros/indigo/lib/joint_state_publisher/joint_state_publisher", line 343, in <module>
    jsp = JointStatePublisher()
  File "/opt/ros/indigo/lib/joint_state_publisher/joint_state_publisher", line 26, in __init__
    robot = xml.dom.minidom.parseString(description).getElementsByTagName('robot')[0]
  File "/usr/lib/python2.7/xml/dom/minidom.py", line 1928, in parseString
    return expatbuilder.parseString(string)
  File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 940, in parseString
    return builder.parseString(string)
  File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 223, in parseString
    parser.Parse(string, True)
xml.parsers.expat.ExpatError: no element found: line 239, column 0
[joint_state_publisher-2] process has died [pid 7555, exit code 1, cmd /opt/ros/indigo/lib/joint_state_publisher/joint_state_publisher __name:=joint_state_publisher __log:=/home/ubuntu/.ros/log/6a4eafd8-a702-11e6-98d1-00044b581868/joint_state_publisher-2.log].
log file: /home/ubuntu/.ros/log/6a4eafd8-a702-11e6-98d1-00044b581868/joint_state_publisher-2*.log
[ERROR] [1478753953.368324386]: No link elements found in urdf file

Edit 2: Full urdf xacro.

<?xml version="1.0"?>
<robot name="macroed" xmlns:xacro="http://ros.org/wiki/xacro">
<robot xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor"
xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller"
xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface"
xmlns:xacro="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface" name="macroed">
<!-- Convert to xacro-->

    <xacro:property name="width" value="0.2" /> 
    <xacro:property name="leglen" value="0.6" />
    <xacro:property name="polelen" value="0.2" />
    <xacro:property name="bodylen" value="0.6" />
    <xacro:property name="baselen" value="0.4" />
    <xacro:property name="wheeldiam" value="0.07" />
    <xacro:property name="pi" value="3.1415" />
    
    <material name="blue">
        <color rgba="0 0 0.8 1"/>   
    </material>
    <material name="white">
        <color rgba="1 1 1 1"/> 
    </material>
    <material name="black">
        <color rgba="0 0 0 1"/> 
    </material>

    <xacro:macro name="default_intertial" params="mass">
        <inertial>
            <mass value="${mass}"/>
            <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
        </inertial>
    </xacro:macro>

    <link name = "base_link">
        <visual>
            <geometry>
                <cylinder radius="${width}" length="${bodylen}"/>
            </geometry>
            <material name="blue"/>
        </visual>
        <collision>
            <geometry>
                <cylinder radius="${width}" length="${bodylen}"/>
            </geometry>
        </collision>
        <xacro:default_intertial mass="10"/>
    </link>

    <xacro:macro name="wheel" params="prefix suffix reflect">
        <link name="${prefix}_${suffix}_wheel">
            <visual>
                <origin rpy="${pi/2} 0 0" xyz="0 0 0"/>
                    <geometry>
                    <cylinder length="0.1" radius="${wheeldiam/2}"/>
                    </geometry>

                    <material name="black"/>
                </visual>
            <collision>
                <origin rpy="${pi/2} 0 0" xyz="0 0 0"/>
                    <geometry>
                    <cylinder length="0.1" radius="${wheeldiam/2}"/>
                    </geometry>

                    <material name="black"/>
            </collision>
            <xacro:default_interial mass="1"/>
        </link>
        <joint name="${prefix}_${suffix}_wheel_joint" type="continuous">
            <axis rpy="0 0 0" xyz="0 1 0"/>
            <parent link="${prefix}_base"/>
            <child link="${prefix}_${suffix}_wheel"/>
            <origin rpy="0 0 0" xyz="${baselen*reflect/3} 0 -${wheeldiam/2+0.05}"/>
        </joint>
    </xacro:macro>

    <xacro:macro name="leg" params="prefix reflect">
        <link name="${prefix}_leg">
            <visual>
                <geometry>
                    <box size="${leglen} .1 .2" />
                </geometry>
                <origin rpy="0 ${pi/2} 0" xyz="0 0 -${leglen/2}" />
                <material name="white"/>
            </visual>
            <collision>
                <geometry>
                    <box size="${leglen} .1 .2" />
                </geometry>
                <origin rpy="0 ${pi/2} 0" xyz="0 0 -${leglen/2}" />
            </collision>
            <xacro:default_interial mass="10"/>
        </link>
        <joint name="base_to_${prefix}_leg" type="fixed">
            <parent link="base_link"/>
            <child link="${prefix}_leg"/>
            <origin xyz="0 ${reflect*(width+.02)} .25"/>
        </joint>
        <link name = "${prefix}_base">
            <visual>
                <geometry>
                    <box size="${baselen} .1 .1" />
                </geometry>
                <material name="white"/>
            </visual>
            <collision>
                <geometry>
                    <box size="${baselen} .1 .1" />
                </geometry>
            </collision>
            <xacro:default_interial mass="10"/>
        </link>
        <joint  name="${prefix}_base_joint" type="fixed">
            <parent link="${prefix}_leg"/>
            <child link="${prefix}_base"/>
            <origin xyz="0 0 -${leglen}"/>
        </joint>
        <xacro:wheel prefix="${prefix}" suffix="front" reflect="1"/>
        <xacro:wheel prefix="${prefix}" suffix="back" reflect="-1"/>
    </xacro:macro>

    <xacro:leg prefix="right" reflect="-1" />
    <xacro:leg prefix="left" reflect="1" />

    <link name="head">
        <visual>
            <geometry>
                <sphere radius="${width}"/>
            </geometry>
            <material name="white"/>
        </visual>
        <collision>
            <geometry>
                <sphere radius="${width}"/>
            </geometry>
        </collision>
        <xacro:default_inertial mass="2"/>
    </link>

    <joint name="head_swivel" type="continuous">
        <parent link="base_link"/>
        <child link="head"/>
        <origin xyz="0 0 ${bodylen/2}"/>
        <axis xyz="0 0 1"/>
    </joint>

    <link name="box">
        <visual>
            <geometry>
                <box size="0.08 0.08 0.08"/>
            </geometry>
            <material name="blue"/>
        </visual>
        <collision>
            <geometry>
                <box size="0.08 0.08 0.08"/>
            </geometry>
        </collision>
        <xacro:default_inertial mass="1"/>
    </link>

    <joint name="tobox" type="fixed">
        <parent link="head"/>
        <child link="box"/>
        <origin xyz="${.707*width+0.04} 0 ${.707*width}"/>
    </joint>

    <link name="gripper_pole">
        <visual>
            <geometry>
                <cylinder length="${polelen}" radius=".01"/>
            </geometry>
            <origin rpy="0 ${pi/2} 0" xyz="${polelen/2} 0 0"/>
        </visual>
        <collision>
            <geometry>
                <cylinder length="${polelen}" radius=".01"/>
            </geometry>
            <origin rpy="0 ${pi/2} 0" xyz="${polelen/2} 0 0"/>
        </collision>
        <xacro:default_inertial mass="0.05"/>
    </link>

    <joint name="gripper_extension" type="prismatic">
        <parent link="base_link"/>
        <child link="gripper_pole"/>
        <limit effort="1000.0" lower="-${width*2-.02}" upper="0" velocity="0.5"/>
        <origin rpy="0 0 0" xyz="${width-.01} 0 0.2"/>
    </joint>

    <xacro:macro name="gripper" params="prefix reflect">
        <link name="${prefix}_gripper">
            <visual>
                <origin rpy="${(reflect-1)/2*pi} 0 0" xyz="0 0 0"/>
                <geometry>
                    <mesh filename="package://pr2_description/meshes/gripper_v0/l_finger.dae"/>         
                </geometry>
            </visual>
            <collision>
                <origin rpy="${(reflect-1)/2*pi} 0 0" xyz="0 0 0"/>
                <geometry>
                    <mesh filename="package://pr2_description/meshes/gripper_v0/l_finger.dae"/>         
                </geometry>
            </collision>
            <xacro:default_inertial mass="0.05"/>
        </link> 
        <joint name="${prefix}_gripper_joint" type="revolute">
            <parent link="gripper_pole"/>
            <child link="${prefix}_gripper"/>
            <origin rpy="0 0 0" xyz="${polelen} ${reflect*.01} 0"/>
            <axis xyz="0 0 ${reflect}"/>
            <limit effort="1000.0" lower="0.0" upper="0.548" velocity="0.5"/>
        </joint>
        <link name="${prefix}_tip">
            <visual>
                <origin rpy="${(reflect-1)/2*pi} 0 0" xyz="0.09137 0.00495 0"/>
                <geometry>
                    <mesh filename="package://pr2_description/meshes/gripper_v0/l_finger_tip.dae"/>         
                </geometry>
            </visual>
            <collision>
                <origin rpy="${(reflect-1)/2*pi} 0 0" xyz="0.09137 0.00495 0"/>
                <geometry>
                    <mesh filename="package://pr2_description/meshes/gripper_v0/l_finger_tip.dae"/>         
                </geometry>
            </collision>
            <xacro:default_intertial mass="0.05"/>
        </link> 
        <joint name="${prefix}_tip_joint" type="fixed">
            <parent link="${prefix}_gripper"/>
            <child link="${prefix}_tip"/>
        </joint>
    </xacro:macro>
    
    <xacro:gripper prefix="left" reflect="1"/>
    <xacro:gripper prefix="right" reflect="-1"/>
</robot>

Originally posted by Thang Nguyen on ROS Answers with karma: 93 on 2016-11-09

Post score: 0


Original comments

Comment by mgruhler on 2016-11-09:
I'm not quite sure, but I don't think that this substitution stuff actualy works with floats without leading 0. Can you try with adding this?

Comment by Thang Nguyen on 2016-11-09:
I will try and let you know.

Comment by Thang Nguyen on 2016-11-10:
I found the issue. I missed the 4 lines after . But then I got the new error and I cannot understand what it is. I added Edit 1.

Comment by rbbg on 2016-11-10:
Perhaps it would help if you post the full urdf, the tutorial you are using and how you fixed the previous error. From the error you are getting now I would suspect some of the tags are not being closed properly.

Comment by Thang Nguyen on 2016-11-10:
I have just added the full Urdf file. This is come from tutorial ex8 Using Xacro to Clean Up a URDF File

Comment by Thang Nguyen on 2016-11-10:
The problem is the error didn't tell where it found the problem. With a long urdf file, I have no idea how to find the issue.

Comment by Inounx on 2016-11-10:
You can use gzsdf to help debug your urdf file see here Gazebo ROS urdf, "Verifying the Gazebo Model Works"

You need gazebo installed, and then : gzsdf print MODEL.urdf (gazebo2) or gz sdf -p MODEL.urdf (Gazebo 3+)

Comment by Thang Nguyen on 2016-11-10:
@Inounx: Does it check xacro macro? Or I have to convert to urdf first?

Comment by Inounx on 2016-11-11:
Yes, you will need to convert to urdf your files (and this is maybe a part of your problem: I think you cannot use a raw xacro urdf, you have to convert to urdf first) try this : rosrun xacro xacro.py -o model_out.urdf model_in.urdf.xacro And then run gzsdf.

Comment by Thang Nguyen on 2016-11-11:
@Inounx: I tried with rosrun xacro xacro 08-macroed.urdf.xacro > 08-macroed.urdf then using check_urdf 08-macroed.urdf and got a good result. This makes me confused. Do you think gazebo gzsdf will return better result? I am trying to install gazebo but I have error.

Comment by Inounx on 2016-11-11:
I don't know, I have never used check_urdf. Did you try to use the file 08-macroed.urdf (output of rosrun xacro xacro...) where before you had an error ?

Comment by Thang Nguyen on 2016-11-11:
I have not tried to use 08-macroed.urdf since I want to use the xacro instead. Maybe I should try it. Since I cannot install full package, I have to install gazebo separately. I am using Ubuntu 14.04 with Indigo. What version of Gazebo should I install?

Comment by Inounx on 2016-11-11:
AFAIK you need to convert your xacro to urdf in order to be able to use it. Xacro is just a way to clean your urdf. See here: Using Xacro to clean urdf file, first paragraph. Test your converted urdf if it's ok

Comment by Inounx on 2016-11-11:
If you convert your xacro when you load it into a ROS param in your launch file like they say, your urdf model will always be up to date, and when you will modify the xacro, the modifications will be applied on next launch.

Comment by Thang Nguyen on 2016-11-11:
lnounx: Thanks lnounx, I ddin't read it carefully. Thanks for your help. If you change this to answer, I will mark this as answer.

Comment by Thang Nguyen on 2016-11-11:
Could you please tell me about the xacro version to install to?

Comment by Inounx on 2016-11-12:
You're welcome ;). I don't understand why you ask this, the version you have is not ok ?

Comment by Thang Nguyen on 2016-11-12:
I installed base package so there is no gazebo in it.

Comment by Inounx on 2016-11-14:
I have the same environment than yours (Ubuntu 14.04 / ROS Indigo) and to install Gazebo, I just installed the version provided with ROS. I currently have ros-indigo-gazebo-msgs ros-indigo-gazebo-plugins ros-indigo-gazebo-ros ros-indigo-gazebo-ros-control ros-indigo-gazebo-ros-pkgs installed.

Comment by Inounx on 2016-11-14:
Concerning Xacro the package is ros-indigo-xacro

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

How to check your Xacro / urdf model

To be able to check your model, you have to convert your xacro file to plain urdf:

rosrun xacro xacro.py -o model_out.urdf model_in.urdf.xacro

Then you can use:

How to use your Xacro model

To use your xacro model, you have to convert it first to plain urdf. The best way is to convert it at the time you load you model into a ros parameter, so your urdf model will always be up to date, as any modifications on the xacro will be applied on next launch.

See here: Using Xacro to clean urdf file, first paragraph.


Originally posted by Inounx with karma: 293 on 2016-11-12

This answer was ACCEPTED on the original site

Post score: 3

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.