Gazebo | Ignition | Community
Ask Your Question

set light properties through ros topic or service interface?

asked 2016-03-14 18:53:03 -0500

updated 2016-03-15 11:13:13 -0500

Is it possible to set light properties through the ros topic or service interface on /gazebo? For example any of the properties set in the sdf file and available through menus in the gui I'd like to be able to adjust:

<light type="spot" name="base_light">
    <!--  Frames don't work in 5.0.1 XML Element[frame], child of element[light] not defined in SDF. Ignoring[frame]. You may have an incorrect SDF file, or an sdformat version that doesn't support this element. -->
    <!--frame name="base_link"-->
    <pose>0 0 0.1 1.57 0 0</pose>
    <diffuse>.9 .9 .9 1</diffuse>
    <specular>.1 .1 .1 1</specular>
    <direction>0 0 -1</direction>

If not that, what about gz command line or gazebojs?

I'm using Ubuntu 14.04 with ROS Jade and Gazebo 5.0.1.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-03-15 10:40:41 -0500

nkoenig gravatar image

Gazebo does not use ros topics or services directly. Try using the command line tools provided in Gazebo.

  1. Check if a topic exists that might offer a solution. In this case, just list the topics with gz topic -l

  2. The /gazebo/default/light/modify looks promising

  3. Let's see what message is advertised on the topic with gz topic -i /gazebo/default/light/modify

  4. Looks like we can send a Light message.

  5. Now try writing a program to send a light message.

edit flag offensive delete link more


I created two lights in my sdf, one directional and one spotlight, and they both have a `_light` in their names, and they appear in the gui. `gz topic --list` shows /gazebo/default/light, but no modify. There is a `/gazebo/world/modify`, and a default pose and model modify.

Lucas Walter gravatar imageLucas Walter ( 2016-03-15 11:12:21 -0500 )edit

The modify topic may only be in a newer version of gazebo. Sounds like you'll have to write a plugin to achieve the affect you desire.

nkoenig gravatar imagenkoenig ( 2016-03-15 11:23:03 -0500 )edit

I believe that in earlier gazebo versions, `/gazebo/default/light` works just like the new modify topic. But if you try to modify a light by giving the name of a light which doesn't exist, it will create a new light.

chapulina gravatar imagechapulina ( 2016-03-15 12:24:40 -0500 )edit
Login/Signup to Answer

Question Tools



Asked: 2016-03-14 18:53:03 -0500

Seen: 5,162 times

Last updated: Mar 15 '16