# add visual plugin to urdf

I wrote a visual plugin that sets the visibility of a visual element to GZ_VISIBILITY_GUI. I tested it by placing it in an SDF and it worked as intended - I could see the model in the GUI, however it was invisible to a simulated camera.

I am working with ROS and have everything described using URDFs. And, I would like to apply the plugin to visual elements in a URDF. However, I am having problems getting this to work. (Several tools that I'm using require that they are URDFs, so switching everything over to SDFs isn't possible. And, I don't want to make a set of each and maintain them both.)

I've included a basic SDF and URDF of an identical box. The plugin works great in the SDF, but not in the URDF, i.e. both appear in the GUI, but only the model described by the SDF in invisible to the simulated camera. I've tried many different combinations of where to place the <gazebo> tag, removed the names in the <visual> tag, as well as many other small adjustments to try to get it working. Can someone point me in the right direction?

box.sdf

<?xml version='1.0'?>
<sdf version="1.4">

<model name="box_sdf">

<pose>0 0 0 0 0 0</pose>
<static>true</static>

<inertial>
<mass>0.001</mass>
<inertia>
<ixx>0.000083</ixx>
<ixy>0.0</ixy>
<ixz>0.0</ixz>
<iyy>0.000083</iyy>
<iyz>0.0</iyz>
<izz>0.000083</izz>
</inertia>
</inertial>

<collision name="collision">
<geometry>
<box>
<size>0.1 0.1 0.1</size>
</box>
</geometry>
</collision>

<visual name="visual">
<plugin name="set_visibility_gui" filename="libset_visibility_gui.so" />
<geometry>
<box>
<size>0.1 0.1 0.1</size>
</box>
</geometry>
</visual>

</model>
</sdf>


box.urdf.xacro

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

<inertial>
<origin xyz="0 0 0" rpy="0 0 0" />
<mass value="0.001" />
<inertia
ixx="0.000083"
ixy="0.0"
ixz="0.0"
iyy="0.000083"
iyz="0.0"
izz="0.000083" />
</inertial>

<collision name="collision">
<origin xyz="0 0 0" rpy="0 0 0 " />
<geometry>
<box size="0.1 0.1 0.1" />
</geometry>
</collision>

<visual name="visual">
<origin xyz="0 0 0" rpy="0 0 0 " />
<geometry>
<box size="0.1 0.1 0.1" />
</geometry>
</visual>

<joint name="joint_box_urdf" type="fixed">
<origin xyz="0 0 0" rpy="0 0 0" />
</joint>

<visual name="visual">
<plugin name="set_visibility_gui" filename="libset_visibility_gui.so" />
</visual>
</gazebo>

</robot>

edit retag close merge delete