ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Hi @myboyhood,
I had the same issue, and I ended in the same post you linked. I tried their solution and did not work so I decided to include in the gazebo tag a direct reference to the SDF format to avoid the conversion from URDF, because when I use it as a xacro, when converting form URDF to SDF the parser always warned me saying the light link did not exist, thus omiting the generation of the plugin. I will place here my approach but may not be the best.
<?xml version="1.0"?>
<robot name="mol" xmlns:xacro="http://www.ros.org/wiki/xacro">
<!-- Base Link -->
<link name="base_link">
<collision>
<origin xyz="0 0 0" rpy="0 0 0"/>
<geometry>
<box size="1 1 1"/>
</geometry>
</collision>
<visual>
<origin xyz="0 0 0" rpy="0 0 0"/>
<geometry>
<box size="1 1 1"/>
</geometry>
</visual>
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="1"/>
<inertia
ixx="1.0" ixy="0.0" ixz="0.0"
iyy="1.0" iyz="0.0"
izz="1.0"/>
</inertial>
</link>
<gazebo>
<model name='flashlight'>
<pose>0 0 0 0 0 0</pose>
<link name='light_source'>
<pose>0 0 0.0 0.01 0 0</pose>
<inertial>
<mass>0.0025</mass>
<inertia>
<ixx>1.0e-05</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>1.0e-05</iyy>
<iyz>0</iyz>
<izz>1.0e-05</izz>
</inertia>
</inertial>
<light name='lamp' type='spot'>
<pose>0 0 0.0 0 0 0</pose>
<attenuation>
<range>15</range>
<linear>0</linear>
<constant>0.1</constant>
<quadratic>0.01</quadratic>
</attenuation>
<diffuse>0.8 0.8 0.5 1</diffuse>
<specular>0.8 0.8 0.5 1</specular>
<spot>
<inner_angle>1</inner_angle>
<outer_angle>1.1</outer_angle>
<falloff>1</falloff>
</spot>
<direction>0 0 -1</direction>
</light>
<visual name='lamp'>
<geometry>
<cylinder>
<radius>0.019</radius>
<length>0.005</length>
</cylinder>
</geometry>
<transparency>0.0</transparency>
<material>
<ambient>1 1 1 1</ambient>
<diffuse>1 1 1 1</diffuse>
<specular>1 1 1 1</specular>
<emissive>0.8 0.8 0.5 1</emissive>
</material>
</visual>
</link>
<plugin name='light_control' filename='libFlashLightPlugin.so'>
<enable>true</enable>
<light>
<id>light_source/lamp</id>
<duration>0.5</duration>
<interval>0.5</interval>
</light>
</plugin>
</model>
</gazebo>
<gazebo>
<joint name='flashlight_joint' type='fixed'>
<parent>base_link</parent>
<child>flashlight::light_source</child>
</joint>
</gazebo>
</robot>
Also I found this reference from a DARPA challenge but they are using directly some ROS custom plugins instead of Gazebo ones. Furthermore, they were manage to implement a Xacro for Flashlights and Leds, you may want to take a look at that, maybe you find some inspiration to make up a good solution.