Ask Your Question
0

URDF broken rendering in RVIZ

asked 2020-12-04 18:28:37 -0500

sisko gravatar image

updated 2021-04-24 02:54:07 -0500

miura gravatar image

I need help understanding why my urdf keeps breaking in Rviz. (I apologise for the length of this question).

The problem I am experiencing is my robot only part renders in Rviz. To make matters worse, I am loading the same urdf from two seperate packages and both result in widely difference output in Rviz.

I've followed and almost finished the ROS URDF tutorial. From that tutorial I have the following xacro:

<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="R2D2">

    <xacro:property name="bot" value="R2D2"/>

    <material name="blue">
        <color rgba="0.0 0.0 1.0 1.0"/>
    </material>
    <material name="white">
        <color rgba="1.0 1.0 1.0 1.0"/>
    </material>
    <material name="green">
        <color rgba="0.0 1.0 0.0 1.0"/>
    </material>
    <material name="red">
        <color rgba="1.0 0.0 0.0 1.0"/>
    </material>
    <material name="black">
        <color rgba="0.0 0.0 0.0 1.0"/>
    </material>

    <!-- Base Link -->

    <xacro:property name="base_link_radius" value="0.2"/>
    <xacro:property name="base_link_length" value="0.6"/>

    <link name="base_link">
        <visual name="">
            <geometry>
                <cylinder radius="${base_link_radius}" length="${base_link_length}"/>
            </geometry>
            <material name="blue"/>
        </visual>
        <collision>
            <geometry>
                <cylinder radius="${base_link_radius}" length="${base_link_length}"/>
            </geometry>
        </collision>
        <inertial>
            <mass value="10"/>
            <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
        </inertial>
    </link>

    <!-- LEGS -->
    <xacro:macro name="leg" params="prefix flip">

        <xacro:property name="leg_dimensions" value="0.6 0.1 0.2"/>

        <link name="${prefix}_leg_link">
            <visual>
                <geometry>
                    <box size="${leg_dimensions}"/>
                </geometry>
                <origin xyz="0.0 0.0 -0.3" rpy="0.0 1.57075 0.0"/>
                <material name="white"/>
            </visual>
            <collision>
                <geometry>
                    <box size="${leg_dimensions}"/>
                </geometry>
                <origin xyz="0.0 0.0 -0.3" rpy="0.0 1.57075 0.0"/>
            </collision>
            <inertial>
                <mass value="10"/>
                <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
            </inertial>
        </link>

        <joint name="base_to_${prefix}_leg" type="fixed">
            <parent link="base_link"/>
            <child link="${prefix}_leg_link"/>
            <origin xyz="0.0 ${flip * -0.22} 0.25" rpy="0.0 0.0 0.0"/>
        </joint>
    </xacro:macro>

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

    <!-- Leg bases -->
    <xacro:macro name="legbase" params="prefix switch">
        <xacro:property name="legbase_dimensions" value="0.4 0.1 0.1"/>
        <link name="${prefix}_leg_base_link">
            <visual name="">
                <geometry>
                    <box size="${legbase_dimensions}"/>
                </geometry>
                <material name="white"/>
            </visual>
            <collision>
                <geometry>
                    <box size="${legbase_dimensions}"/>
                </geometry>
            </collision>
            <inertial>
                <mass value="10.0"/>
                <inertia ixx="0.4" ixy="0.0 ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-12-05 00:02:53 -0500

gvdhoorn gravatar image

It's likely this is the problem:

<param name='robot_description' textfile="$(find sisko_mira_description)/urdf/r2d2.urdf.xacro"/>

A .xacro file is not a plain URDF, so it must be parsed by xacro before uploading it to the parameter server.

Your first .launch file treats it as a plain text file, so what gets uploaded to the parameter server is the raw contents of your r2d2.urdf.xacro, which is not a proper URDF.

Hence the complaints by RViz and the partial model (it does the best it can apparently).

Your second .launch file does this:

<param name="robot_description" command="$(find xacro)/xacro $(find sisko_mira_description)/urdf/r2d2.urdf.xacro"/>

Note how xacro is used here to parse your .xacro and then return the result. That result is valid URDF, so now consumers of that URDF will be able to parse it successfully.

As to the rest of what you describe: I don't know right now why RViz complains about missing transforms.

I would suggest you first fix the .launch file and then proceed with further debugging.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-12-04 18:28:37 -0500

Seen: 131 times

Last updated: Dec 05 '20