Revision history [back]

Adding light source as a model in Groovy-Gazebo

I have been trying find an answer to this question for a very long time but I still haven't! "How to add light sources in the gazebo world dynamically ?" I am using ROS-Groovy (Gazebo 1.5.0).

In electric there was this <model:renderable> option where I was able to spawn light source as a model after launch the gazebo world in any pose I wanted.

<?xml version="1.0" ?>
<robot name="light_balcony">
<inertial>
<mass value="1" />
<com xyz="11.27 3.15 2.25" />
<inertia ixx="0" ixy="0.0" ixz="0.0" iyy="0" iyz="0.0" izz="0" />
</inertial>

<visual>
<origin xyz="11.27 3.15 2.25" rpy="0 0 0" />  <!--   definition of the visual postion of the object!! -->
<geometry>
</geometry>
</visual>
<collision>
<origin xyz="11.27 3.15 2.25" rpy="0 0 0" />
<geometry>
</geometry>
</collision>

<gazebo reference="bulb_balcony">
<model:renderable name="light_balcony">
<xyz>11.27 3.15 2.25</xyz>
<static>true</static>
<light>
<type>point</type>
<diffuseColor>0.1 0.1 0.1</diffuseColor>
<specularColor>.01 .01 .01</specularColor>
<attenuation>0.1 0.1 0.0001</attenuation>
<range>4</range>
</light>
</model:renderable>
</gazebo>
</robot>


When I switched to fuerte, it was no longer an option and even in groovy, I am not able to find a way out :( I am able to add a light to my world file but what I really want is adding it dynamically similar to adding a model. Taking advise from @AndreiHaidu and others (here, and many other pages), I tried a lot like adding

<include>
<uri>model://sun</uri>
<pose>0.3 0.2 5.0 0 0 0</pose>
</include>


or

<light type="directional" name="my_light">
<pose>0 0 30 0 0 0</pose>
<diffuse>.9 .9 .9 1</diffuse>
<specular>.1 .1 .1 1</specular>
<attenuation>
<range>20</range>
</attenuation>
<direction>0 0 -1</direction>
</light>


I have tried these in different sdf formats too. All threw errors. Finally when I tried this,

    <gazebo version='1.0'>
<model name='apartment_floor0' static='1'>
<origin pose='-5 -5 0 0 0 0'/>
<origin pose='0 0 0 0 0 0'/>
<collision name='ow_2_geom' laser_retro='0.000000'>
<origin pose='3.300000 0.150000 1.500000 0.000000 -0.000000 0.000000'/>
<geometry>
<box size='2.400000 0.300000 3.000000'/>
</geometry>
<surface>
<friction>
<ode mu='-1.000000' mu2='-1.000000' fdir1='0.000000 0.000000 0.000000' slip1='0.000000' slip2='0.000000'/>
</friction>
<bounce restitution_coefficient='0.000000' threshold='100000.000000'/>
<contact>
<ode soft_cfm='0.000000' soft_erp='0.200000' kp='1000000000000.000000' kd='1.000000' max_vel='100.000000' min_depth='0.001000'/>
</contact>
</surface>
</collision>
<origin pose='6.850000 1.500000 1.500000 0.000000 -0.000000 1.570800'/>
<geometry>
<box size='2.400000 0.300000 3.000000'/>
</geometry>
<material script='Gazebo/White'/>
</visual>
</model>
<light name='my_light' type='directional'>
<pose>0.000000 0.000000 30.000000 0.000000 0.000000 0.000000</pose>
<diffuse>0.900000 0.900000 0.900000 1.000000</diffuse>
<specular>0.100000 0.100000 0.100000 1.000000</specular>
<attenuation>
<range>20.000000</range>
</attenuation>
<direction>0.000000 0.000000 -1.000000</direction>
</light>
</gazebo>


I did not get any error but I was only able to see the ow_2_body on the world and the light did not appear at all.

Is there any mistake I am doing that I am not seeing ? Is there any other way out or should I accept the cold truth that there is no way out ?

I repeat, I don't want to spawn it with the world, I want to spawn it as model after launching gazebo world. I am using ROS groovy now with gazebo 1.5 and I also have a standalone gazebo 1.8 installed.

Thanks,

Prasanna

Adding light source as a model in Groovy-Gazebo

I have been trying find an answer to this question for a very long time but I still haven't! "How to add light sources in the gazebo world dynamically ?" I am using ROS-Groovy (Gazebo 1.5.0).

In electric (pre-1.0 SDF) there was this <model:renderable> option where I was able to spawn light source as a model after launch the gazebo world in any pose I wanted.

<?xml version="1.0" ?>
<robot name="light_balcony">
<inertial>
<mass value="1" />
<com xyz="11.27 3.15 2.25" />
<inertia ixx="0" ixy="0.0" ixz="0.0" iyy="0" iyz="0.0" izz="0" />
</inertial>

<visual>
<origin xyz="11.27 3.15 2.25" rpy="0 0 0" />  <!--   definition of the visual postion of the object!! -->
<geometry>
</geometry>
</visual>
<collision>
<origin xyz="11.27 3.15 2.25" rpy="0 0 0" />
<geometry>
</geometry>
</collision>

<gazebo reference="bulb_balcony">
<model:renderable name="light_balcony">
<xyz>11.27 3.15 2.25</xyz>
<static>true</static>
<light>
<type>point</type>
<diffuseColor>0.1 0.1 0.1</diffuseColor>
<specularColor>.01 .01 .01</specularColor>
<attenuation>0.1 0.1 0.0001</attenuation>
<range>4</range>
</light>
</model:renderable>
</gazebo>
</robot>


When I switched to fuerte, it was no longer an option and even in groovy, I am not able to find a way out :( I am able to add a light to my world file but what I really want is adding it dynamically similar to adding a model. Taking advise advice from @AndreiHaidu and others (here, and many other pages), I tried a lot like adding

<include>
<uri>model://sun</uri>
<pose>0.3 0.2 5.0 0 0 0</pose>
</include>


or

<light type="directional" name="my_light">
<pose>0 0 30 0 0 0</pose>
<diffuse>.9 .9 .9 1</diffuse>
<specular>.1 .1 .1 1</specular>
<attenuation>
<range>20</range>
</attenuation>
<direction>0 0 -1</direction>
</light>


I have tried these in different sdf formats too. All threw errors. Finally when I tried this,

    <gazebo version='1.0'>
<model name='apartment_floor0' static='1'>
<origin pose='-5 -5 0 0 0 0'/>
<origin pose='0 0 0 0 0 0'/>
<collision name='ow_2_geom' laser_retro='0.000000'>
<origin pose='3.300000 0.150000 1.500000 0.000000 -0.000000 0.000000'/>
<geometry>
<box size='2.400000 0.300000 3.000000'/>
</geometry>
<surface>
<friction>
<ode mu='-1.000000' mu2='-1.000000' fdir1='0.000000 0.000000 0.000000' slip1='0.000000' slip2='0.000000'/>
</friction>
<bounce restitution_coefficient='0.000000' threshold='100000.000000'/>
<contact>
<ode soft_cfm='0.000000' soft_erp='0.200000' kp='1000000000000.000000' kd='1.000000' max_vel='100.000000' min_depth='0.001000'/>
</contact>
</surface>
</collision>
<origin pose='6.850000 1.500000 1.500000 0.000000 -0.000000 1.570800'/>
<geometry>
<box size='2.400000 0.300000 3.000000'/>
</geometry>
<material script='Gazebo/White'/>
</visual>
</model>
<light name='my_light' type='directional'>
<pose>0.000000 0.000000 30.000000 0.000000 0.000000 0.000000</pose>
<diffuse>0.900000 0.900000 0.900000 1.000000</diffuse>
<specular>0.100000 0.100000 0.100000 1.000000</specular>
<attenuation>
<range>20.000000</range>
</attenuation>
<direction>0.000000 0.000000 -1.000000</direction>