Home | Tutorials | Wiki | Issues
Ask Your Question
0

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="http://www.w3.org/2001/XInclude"
  <link name="bulb_livingroom">
   <inertial>
    <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" />
        </inertial>

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

    <gazebo reference="bulb_livingroom">
        <model:renderable name="light_livingroom">
            <xyz>7.6 4.2 1.5</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 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"/>
                        </light>
    </gazebo>

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 ?

Thanks.

edit retag flag offensive close merge delete

Comments

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
0

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

AndreiHaidu gravatar image

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

Hi,

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"/>
    </light>
    ...
  </world>
</gazebo>

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.

!!!UPDATE!!!

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>
            <attenuation>
                <range>20</range>
            </attenuation>
            <direction>0 0 -1</direction>
            <cast_shadows>true</cast_shadows>
        </light>
    ...
    <!-- OR import the light source from an external sdf model -->
    <!-- you should find the 'sun' models in ~./gazebo folder -->
    <include>
        <uri>model://sun</uri>
        <pose>0.3 0.2 5.0 0 0 0</pose>
    </include>
    ...
    </world>
</sdf>

Cheers, Andrei

edit flag offensive delete link more

Comments

@AndreiHaidu This is already there in the world file, empty.world. 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

Stats

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

Seen: 1,659 times

Last updated: Apr 01 '13