ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Error: Joint is missing a parent and/or child -> No TF data

asked 2018-11-26 15:14:20 -0600

jdeleon gravatar image

updated 2018-11-29 20:14:51 -0600

Hi all,

I'm trying to build a robotic arm, but I'm having troubles when I create the macro to simplify the code. I have the next error:

 Failed to build tree: Joint [module_1_length_yaw_joint] is missing a parent and/or child link specification.

I have try to solve it modifying the code as many times I imagine it could works, but anyway it didn't work.

EDIT: This part is solve at this moment, but after this solution, there is no TF data received. Although the robot is correctly display in Gazebo the is only TF for the 2 firsts links.


<?xml version="1.0"?>

    <!--arg name="robot_model"  default="summit_xl_std.urdf.xacro"/-->
    <arg name="robot_model"  default="robot.xacro"/>
    <arg name="x" default="2.0"/>
    <arg name="y" default="0.0"/>
    <arg name="z" default="0.0"/>

    <!-- Load the URDF into ROS parameter server -->
    <!--arg name="urdf_file" default="$(find xacro)/xacro '$(find summit_xl_description)/robots/$(arg robot_model)' inorder" /-->
    <arg name="urdf_file" default="$(find xacro)/xacro '$(find arm_description)/urdf/$(arg robot_model)'" />
    <param name="robot_description" command="$(arg urdf_file)" />

    <!-- Gazebo -->
    <include file="$(find gazebo_ros)/launch/empty_world.launch">
        <arg name="world_name" value="$(find arm_gazebo)/worlds/"/>

    <!-- Spawn a robot into Gazebo -->
    <node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model"
          args="-param robot_description
                -x '$(arg x)'
                -y '$(arg y)'
                -z '$(arg z)'
                -model fotokite"/>
    <!-- send fake joint values -->
    <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
    <!--param name="use_gui" value="FALSE"/-->

    <!-- convert joint states to TF transforms for rviz, etc -->
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"
          respawn="false" output="screen">
          <remap from="/joint_states" to="/fotokite/joint_states" />




<?xml version="1.0"?>
<robot name="fotokite" xmlns:xacro="">

    <xacro:include filename="$(find arm_description)/urdf/fotokite.urdf.xacro" />
        <plugin name="gazebo_ros_control" filename="">

    <link name="world"/>

    <!-- Fotokite -->
    <fotokite_arm parent="world">
            <origin xyz="0 0 0" rpy="0 0 0" />



Here is the code for the macro that is called to create the robotic arm:

-- CODE --
<?xml version="1.0"?>
<robot name="fotokite" xmlns:xacro="">

<xacro:macro name="fotokite_arm" params="parent *origin">

    <xacro:property name="PI" value="3.14159265359"/>

    <!-- Joints Control in Gazebo -->
        <plugin name="gazebo_ros_control" filename=""/>

    <!-- Geometrical properties -->
    <xacro:property name="link_side"    value="0.04"/>
    <xacro:property name="joint_radius" value="0.018"/>
    <xacro:property name="joint_length" value="0.025"/>
    <xacro:property name="length"       value="0.04"/>
    <xacro:property name="mass"       value="1.0"/>

    <!-- Materials -->
    <material name="orange">
        <color rgba="1.00 0.67 0.02 1.00"/>

    <material name="gray">
        <color rgba="0.80 0.80 0.80 1.00"/>

    <!-- Generates a box visual/collision/inertial -->
    <xacro:macro name="prism_vci" params="side length mass:=1 *origin">
        <xacro:macro name="prism_geometry">
            <xacro:insert_block name="origin"/>
                <box size="${side} ${side} ${length}"/>
            <material name="orange"/>

            <xacro:insert_block name="origin ...
edit retag flag offensive close merge delete


If I comment the first if for the child

<!--xacro:if value="${parent != 'length'}"-->
       <child link="${prefix}_${child}"/>

The error is different:

Failed to find root link: Two root links found: [base_footprint] and [module_3_yaw]
jdeleon gravatar image jdeleon  ( 2018-11-26 18:56:16 -0600 )edit

Have you tried converting your xacro file into urdf to directly see the values of the variables ? You would directly see all the children and parents like that (see #q10401).

Delb gravatar image Delb  ( 2018-11-27 01:37:34 -0600 )edit

Hi @Delb, I had the same error if I try to convert to URDF.

jdeleon gravatar image jdeleon  ( 2018-11-28 21:31:47 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-11-26 16:58:49 -0600

FelipeNascimento gravatar image

updated 2018-11-29 14:22:12 -0600

Your joint is missing a child. Every joint must have a child and a parent link.

Try it with a useless link like

<link name="${child}_link" />

and insert in the joint

<child link = "${child}_link" />

Let me know if it works.

Edit: I see that you insert a child link in the joint, but you don't declare it anywhere.

Edit 2: I made it work here. The apostrophe indicate its a string type, if you're using a number, don't use it. Change the code

<xacro:if value="${parent == 'length'}">
                <xacro:if value="${index == '1'}">
                    <child link="module_${index + 1}_${child}"/>
                <xacro:if value="${index == '2'}">
                    <child link="module_${index + 1}_${child}"/>
                <xacro:if value="${index == '3'}">
                    <child link="wrist_${child}"/>


<xacro:if value="${parent == 'length'}">
                <xacro:if value="${index == 1}">
                    <child link="module_${index + 1}_${child}"/>
                <xacro:if value="${index == 2}">
                    <child link="module_${index + 1}_${child}"/>
                <xacro:if value="${index == 3}">
                    <child link="wrist_${child}"/>

Edit 3: Tf tree

image description

Edit 4: You declared a macro named "fotokite_arm" but never instanced one. I added the following lines before </robot> and it worked

<link name="world">
    <origin xyz="0 0 0" rpy="0 0 0"/>

<xacro:fotokite_arm parent="world">
    <origin xyz="0 0 0" rpy="0 0 0"/>

Edit 5: Here is the launcher I'm using. I'm calling the urdf "teste_2"


    <param name="robot_description" command="$(find xacro)/xacro --inorder '$(find test_package)/urdf/teste_2.urdf.xacro'"/>

    <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />

    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" />

edit flag offensive delete link more



I have edit the question, the macro definition was not insert as code. Now you can see that I declare the child variable.

<xacro:macro name="arm_joint" params="prefix child parent dist:=0 axis joint_type lower upper index">
jdeleon gravatar image jdeleon  ( 2018-11-26 18:49:37 -0600 )edit

I solved it, I guess. The Index value is a number, so its not supposed to be inside ''. I'll edit the answer.

FelipeNascimento gravatar image FelipeNascimento  ( 2018-11-27 13:32:13 -0600 )edit

Hi @FelipeNascimiento, finally your solution is right!!

But the problem is that now I can't get the TFs of the robot, I only get the world->module_1_yaw, but not the rest...

Do you know if there is any problem for calling the macro from another .xacro?

Thank you

jdeleon gravatar image jdeleon  ( 2018-11-28 10:35:19 -0600 )edit

Hey there, I'm getting the tfs right here. Of course I don't have the prism_vci and cylinder_vci macros you made, so I used a default origin for the link only for test. I'm updating the answer with a image of the tf tree.

FelipeNascimento gravatar image FelipeNascimento  ( 2018-11-28 16:51:42 -0600 )edit

There is no problem in calling a macro in another macro, so it should be ok. Maybe double check your macros and make sure you're assigning an origin to the links

FelipeNascimento gravatar image FelipeNascimento  ( 2018-11-28 16:57:21 -0600 )edit

If try changing the links (visual and collision) to the standard xacro form, and neither I can't get the TFs.

I update the original post with the prism_vci and cylinder_vci, to see if you can detect where is the error.

Thank you

jdeleon gravatar image jdeleon  ( 2018-11-28 22:23:28 -0600 )edit

You never instanced a 'fotokite_arm' macro, only declared one. I instanced one after the macro declaration and it worked here. I edited the answer.

FelipeNascimento gravatar image FelipeNascimento  ( 2018-11-28 23:07:20 -0600 )edit

I have in another xacro what you say:

<!--Import Fotokite arm -->
<xacro:include filename="$(find arm_description)/urdf/fotokite.urdf.xacro" />
<link name="world"/>
<xacro:fotokite_arm parent="world">
  <origin xyz="0 0 0" rpy="0 0 0" />
jdeleon gravatar image jdeleon  ( 2018-11-29 10:47:20 -0600 )edit

Question Tools



Asked: 2018-11-26 15:14:20 -0600

Seen: 1,765 times

Last updated: Nov 29 '18