Ask Your Question
0

Unable to import xacro elements in urdf [closed]

asked 2020-03-21 01:53:17 -0500

Hello

I am trying to import the xacro file of the robotiq 2f_85 gripper in my main urdf file. I would like to connect the base of the gripper robotiq_arg2f_base_link to the end effector of my manipulator. When launching in Rviz, I do not get any warnings or errors and the gripper is not part of the link tree when checking tf.

As suggested on other questions, the most common method is to create another xacro file where I would link the main urdf and the gripper. But is this really necessary? I think I just have some trouble importing the xacro file the right way and I would like to maintain the main urdf file at the top level.

All help would me much appreciated!

This is the main urdf robot file acro_mobile_manipulator.xacro:

<?xml version="1.0"?>

<robot name = "acro_mobile_manipulator" xmlns:xacro="http://ros.org/wiki/xacro">

<!-- Rest of URDF (not xacro) -->

<!-- Gripper -->

<xacro:include filename="$(find robotiq_2finger_grippers)/robotiq_2f_85_gripper_visualization/urdf/robotiq_arg2f_85_model_macro.xacro" />

<xacro:robotiq_arg2f_85 prefix=""/>

<xacro:macro name="end_eff_gripper">
    <joint name="end_eff_gripper" type="fixed">
        <origin xyz="0 0 0" rpy="3.1415 0 0" />
        <parent link="end_effector" />
        <child link="robotiq_arg2f_base_link" />
        <axis xyz="1 0 0" />
    </joint>
</xacro:macro>

</robot>
edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by student_Ros_melodic_mobile_manipulator
close date 2020-03-24 15:16:14.267720

Comments

As suggested on other questions, the most common method is to create another xacro file where I would link the main urdf and the gripper. But is this really necessary?

of course not.

Neither is using xacro. We could just put everything in a single file and duplicate blocks of URDF wherever we need them and then manually update all references to make sure we don't have any name clashes. Whenever you want to change something structurally in one of those blocks, make sure to copy-paste those changes to all the other locations you use that same block, and then don't forget to update all the references/names again.


Whether something is "really necessary" is not always the best question to ask when trying to determine whether something should be done.

I've exaggerated somewhat in my comment above of course, but using tools like xacro allows us ...(more)

gvdhoorn gravatar image gvdhoorn  ( 2020-03-21 06:05:26 -0500 )edit

.. to reuse parts, to make changes to parts that automatically get included in the larger composite, facilitating maintenance, etc, etc.

That's the reason we split up programs (ie: .cpp, .py, etc) instead of merging everything into a single file -- which would certainly be possible. That's the reason we create libraries and ROS packages.

Not because it's absolutely necessary, but because it offers us a lot of advantages, and we'd like to benefit from those advantages.

gvdhoorn gravatar image gvdhoorn  ( 2020-03-21 06:07:25 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-03-21 06:13:44 -0500

gvdhoorn gravatar image

Your problem is most likely caused by this:

...

<xacro:robotiq_arg2f_85 prefix=""/>

<xacro:macro name="end_eff_gripper">
    <joint name="end_eff_gripper" type="fixed">
        <origin xyz="0 0 0" rpy="3.1415 0 0" />
        <parent link="end_effector" />
        <child link="robotiq_arg2f_base_link" />
        <axis xyz="1 0 0" />
    </joint>
</xacro:macro>

Before this snippet, you've xacro:included the file which defines the robotiq_arg2f_85 macro.

With <xacro:robotiq_arg2f_85 prefix=""/> you "call" the macro, which causes the model it describes to be instantiated (ie: added to your scene).

With the <xacro:macro name="end_eff_gripper"> element (and its child elements), you create a new macro, called end_eff_gripper. In that macro, you define a joint, which will connect the end_effector link with the robotiq_arg2f_base_link one.

So far so good.

However -- and I'm going to assume this is everything you added -- your new macro is never actually called. You only define the macro, but don't instantiate it, leading to the end_eff_gripper joint to never be added to the model which is defined in the file.

When launching in Rviz, I do not get any warnings or errors and the gripper is not part of the link tree when checking tf.

If by this, you mean "I see the links but they're not connected to the main tree", then I hope you now understand why that is.

As the end_eff_gripper joint is never added to the model, there is no connection between the gripper and the robot.

You don't show us the TF tree, but I'm guessing you see two disconnected trees.

The solution would be to either:

  1. not wrap the end_eff_gripper joint in a macro, or if you really want to use the macro
  2. call the macro after defining it (ie: add a <xacro:end_eff_gripper />)
edit flag offensive delete link more

Comments

Thank you for your answer! This helped me to better understand the xacro language.

*When launching in Rviz, I do not get any warnings or errors and the gripper is not part of the link tree when checking tf. *

By this I mean the gripper is not at all present in either Rviz or the tf tree. My apology for not giving more information about the code:

  • The end_effector link is defined in the URDF above.
  • The robotiq_arg2f_base_link link is defined in the xacro file which I included.
  • If I don't wrap the end_eff_gripper joint in a macro I get the following error:

    Failed to build tree: child link [robotiq_arg2f_base_link] of joint [end_eff_gripper] not found

  • If I call the macro after defining it as <xacro:end_eff_gripper />, nothing seems to change: the gripper is still not part of the tf tree and Rviz can start without any errors and ...

(more)
student_Ros_melodic_mobile_manipulator gravatar image student_Ros_melodic_mobile_manipulator  ( 2020-03-21 10:56:34 -0500 )edit

I will edit my question to include the tf tree (same for original and not using macro)

--> I need 5 points to upload a file -_-

All I can say is that there is no single link of the gripper to be found in the tf tree. There are also not two separate trees, only the main one.

Thank you in advance for any help.

student_Ros_melodic_mobile_manipulator gravatar image student_Ros_melodic_mobile_manipulator  ( 2020-03-21 10:59:18 -0500 )edit

Sollution: forgot to add $(find xacro)/xacro --inorder in front of the urdf/xacro load:

$(find xacro)/xacro --inorder $(find location)/urdf/name.urdf.xacro"
student_Ros_melodic_mobile_manipulator gravatar image student_Ros_melodic_mobile_manipulator  ( 2020-05-05 11:19:43 -0500 )edit

Question Tools

Stats

Asked: 2020-03-21 01:53:17 -0500

Seen: 39 times

Last updated: Mar 21