Unable to import xacro elements in urdf [closed]
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>
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).. 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.