Gazebo | Ignition | Community
Ask Your Question

Addiing light models in ros-fuerte

asked 2013-04-01 06:37:12 -0500

prasanna.kumar gravatar image

I was working for sometime in electric and I used the following light.urdf to spawn the model of light in gazebo.

<?xml version="1.0" ?>

<robot name="light_livingroom" xmlns:xi=""
  <link name="bulb_livingroom">
    <mass value="1" />
            <com xyz="7.6 4.2 1.5" />
            <inertia ixx="1" ixy="0.0" ixz="0.0" iyy="1" iyz="0.0" izz="1" />

            <origin xyz="7.6 4.2 1.5" rpy="0 0 0" />  <!--   definition of the visual postion of the object!! -->
                <sphere radius="0.0001" />
            <origin xyz="7.6 4.2 1.5" rpy="0 0 0" />
                <sphere radius="0.0001" />

    <gazebo reference="bulb_livingroom">
        <model:renderable name="light_livingroom">
            <xyz>7.6 4.2 1.5</xyz>
                <diffuseColor>0.1 0.1 0.1</diffuseColor>
                <specularColor>.01 .01 .01</specularColor>
                <attenuation>0.1 0.1 0.0001</attenuation>

When I try to spawn the same file in gazebo fuerte. The bulb model seens to oscillate under the ground. I tried replacing the content replacing model content with this

<gazebo reference="bulb_livingroom">
            <light type="directional" name="light_livingroom" cast_shadows="false">
                                <origin pose="7.6 4.2 1.5 0 0 0"/>
                                <diffuse rgba=".9 .9 .9 1"/>
                                <specular rgba=".1 .1 .1 1"/>
                                <attenuation range="20"/>
                                <direction xyz="0 0 -1"/>

Now, the bulb goes to (7.6, 4.2, 1.5) but no light comes out. Is my code wrong ? and is there a way to spawn custom light models in gazebo-fuerte ? Could someone give me a sample snippet if possible ?


edit retag flag offensive close merge delete


With what gazebo version are you working?

AndreiHaidu gravatar imageAndreiHaidu ( 2013-04-01 06:51:40 -0500 )edit

I am using ros-fuerte. I guess it is gazebo 1.0.2. I see a folder named gazebo-1.0.2 inside gazebo/gazebo/share.

prasanna.kumar gravatar imageprasanna.kumar ( 2013-04-01 07:29:14 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2013-04-01 07:48:13 -0500

AndreiHaidu gravatar image

updated 2013-04-01 10:58:04 -0500


try adding this to the world file, not to the robot:

<?xml version="1.0"?> 
<gazebo version="1.0">
  <world name="default">
    <light type="directional" name="my_light" cast_shadows="false">
      <origin pose="0 0 30 0 0 0"/>
      <diffuse rgba=".9 .9 .9 1"/>
      <specular rgba=".1 .1 .1 1"/>
      <attenuation range="20"/>
      <direction xyz="0 0 -1"/>

I would also suggest that you switch to a newer version of gazebo ( v1.3 which comes with groovy or installing v1.5 from source), that way you could get more help in future problems, because I don't think version 1.0 is used by a lot of people.


If you are going to switch to groovy you could add light sources the following way:

Add to the .world file:

<?xml version="1.0" ?>
<sdf version="1.3">
    <world name="my_world">
        <!--the light source created in the world file-->
        <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>
            <direction>0 0 -1</direction>
    <!-- OR import the light source from an external sdf model -->
    <!-- you should find the 'sun' models in ~./gazebo folder -->
        <pose>0.3 0.2 5.0 0 0 0</pose>

Cheers, Andrei

edit flag offensive delete link more


@AndreiHaidu This is already there in the world file, Say I move to groovy, could you please tell me how to spawn a light source through .urdf or .model file ? There should be possibility (like the one I posted in the question for electric).

prasanna.kumar gravatar imageprasanna.kumar ( 2013-04-01 10:37:49 -0500 )edit
<@prasanna.kumar">p>@prasanna.kumar Did you find a way to achieve this (spawning the light through a urdf or an sdf file)? I searched all over but couldn't find any snippet which gives me that functionality. I want to spawn a light as part of the robot through say a urdf, sdf or a gazebo file at run time using rosservice. As @AndreiHaidu has pointed out, it's possible to spawn the lights as part of the world, but I was unsuccessful through urdf or sdf file.

cgnarendiran gravatar imagecgnarendiran ( 2018-04-26 03:10:15 -0500 )edit

@cgnarendiran do you have an update for how to add a light through a xacro\urdf\sdf file?

srsidd gravatar imagesrsidd ( 2018-10-09 00:24:31 -0500 )edit
Login/Signup to Answer

Question Tools


Asked: 2013-04-01 06:37:12 -0500

Seen: 3,663 times

Last updated: Apr 01 '13