Gazebo | Ignition | Community
Ask Your Question
0

Set orientation in a .world file

asked 2017-03-28 04:57:35 -0500

jony gravatar image

updated 2017-03-29 12:49:27 -0500

Hi! Using tum_simulator for indigo I'm trying to create my own world. I can import my meshes and lights using the sdf syntax, but when I try to change orientation of a spot light (pitch in particular), nothing happens in Gazebo (orientation is setted on [0 0 0]). This is my .world file:

<?xml version="1.0" ?>
<sdf version='1.4'>
  <world name='default'>
    <light name='sun' type='directional'>
      <cast_shadows>1</cast_shadows>
      <pose>0 0 10 0 -0 0</pose>
      <diffuse>0.8 0.8 0.8 1</diffuse>
      <specular>0.2 0.2 0.2 1</specular>
      <attenuation>
        <range>1000</range>
        <constant>0.9</constant>
        <linear>0.01</linear>
        <quadratic>0.001</quadratic>
      </attenuation>
      <direction>-0.5 0.1 -0.9</direction>
    </light>
    <light name='spot1' type='spot'>
      <cast_shadows>1</cast_shadows>
      <pose>2.5 7.9 4.0 0 -0.5 0</pose>
      <diffuse>0.8 0.8 0.8 1</diffuse>
      <specular>0.2 0.2 0.2 1</specular>
      <attenuation>
        <range>20</range>
        <constant>0.5</constant>
        <linear>0.01</linear>
        <quadratic>0.001</quadratic>
      </attenuation>
    </light>
    <model name='ground_plane'>
      <static>1</static>
      <link name='link'>
        <collision name='collision'>
          <geometry>
            <plane>
              <normal>0 0 1</normal>
              <size>100 100</size>
            </plane>
          </geometry>
          <surface>
            <friction>
              <ode>
                <mu>100</mu>
                <mu2>50</mu2>
              </ode>
            </friction>
            <bounce/>
            <contact>
              <ode/>
            </contact>
          </surface>
          <max_contacts>10</max_contacts>
        </collision>
        <visual name='visual'>
          <cast_shadows>0</cast_shadows>
          <geometry>
            <plane>
              <normal>0 0 1</normal>
              <size>100 100</size>
            </plane>
          </geometry>
          <material>
            <script>
              <uri>file://media/materials/scripts/gazebo.material</uri>
              <name>Gazebo/Grey</name>
            </script>
          </material>
        </visual>
        <velocity_decay>
          <linear>0</linear>
          <angular>0</angular>
        </velocity_decay>
        <self_collide>0</self_collide>
        <kinematic>0</kinematic>
        <gravity>1</gravity>
      </link>
    </model>
    <physics type='ode'>
      <max_step_size>0.001</max_step_size>
      <real_time_factor>1</real_time_factor>
      <real_time_update_rate>1000</real_time_update_rate>
      <gravity>0 0 -9.8</gravity>
    </physics>
    <scene>
      <ambient>0.4 0.4 0.4 1</ambient>
      <background>0.7 0.7 0.7 1</background>
      <shadows>1</shadows>
    </scene>
    <model name='Museum'>
      <static>1</static>
      <link name='link'>
        <collision name='collision'>
          <geometry>
            <mesh>
              <uri>model://museum/meshes/museum.dae</uri>
            </mesh>
          </geometry>
          <max_contacts>10</max_contacts>
          <surface>
            <bounce/>
            <friction>
              <ode/>
            </friction>
            <contact>
              <ode/>
            </contact>
          </surface>
        </collision>
        <visual name='visual'>
          <geometry>
            <mesh>
              <uri>model://museum/meshes/museum.dae</uri>
            </mesh>
          </geometry>
        </visual>
        <velocity_decay>
          <linear>0</linear>
          <angular>0</angular>
        </velocity_decay>
        <self_collide>0</self_collide>
        <kinematic>0</kinematic>
        <gravity>1</gravity>
      </link>
      <pose>0 0 0 0 -0 0</pose>
    </model>    
    <gui fullscreen='0'>
      <camera name='user_camera'>
        <pose>1.49016 -3.72367 3.62379 -2.88294e-17 0.273797 1.4042</pose>
        <view_controller>orbit</view_controller>
      </camera>
    </gui>
  </world>
</sdf>

and the light named "spot1" is created into Gazebo with orientation 0 0 0. Can someone help me? Thank you ;)

EDIT:

Once updated Gazebo (on version 7), I have issue on spawning a model of a robot. This is the launch file that creates problem:

 <launch>
   <arg name="model" default="$(find cvg_sim_gazebo)/urdf/quadrotor.urdf.xacro"/>
   <arg name="x" default="0"/>
   <arg name="y" default="0"/>
   <arg name="z" default="0 ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2017-03-28 12:09:06 -0500

chapulina gravatar image

I suppose you're using an old version of Gazebo (probably Gazebo 2.2?). You can check the version running:

gazebo --version

I loaded your world on Gazebo 7.6 and the spotlight has a non-zero orientation. I suggest you upgrade your Gazebo version, because the oldest supported version right now is Gazebo 7.

Here's a handy tutorial on how to use a different version of Gazebo with ROS:

http://gazebosim.org/tutorials?tut=ro...

edit flag offensive delete link more

Comments

Duh, I just saw you tagged the question with gazebo_2, so my supposition was correct :)

chapulina gravatar imagechapulina ( 2017-03-28 12:12:52 -0500 )edit

@chapulina thanks for the answer. Yes, I use Gazebo 2.2.6. And I use the package tum_simulator, too. Installing a different version of Gazebo can produce compatibility problems?

jony gravatar imagejony ( 2017-03-29 10:34:08 -0500 )edit

@chapulina effectively with Gazebo7 spot light are well oriented. But using tum_simulator, ardrone model are not spawning.

jony gravatar imagejony ( 2017-03-29 11:44:13 -0500 )edit

I'm not familiar with the tum_simulator. You could get in touch with the maintainers to get it upgraded to ROS Kinetic and Gazebo 7.

chapulina gravatar imagechapulina ( 2017-03-29 12:38:17 -0500 )edit

@chapulina I edited the answer with the spawning launch file that creates problems.

jony gravatar imagejony ( 2017-03-29 12:45:35 -0500 )edit

@jony, I'm afraid that migration from Gazebo 2 to Gazebo 7 could require a lot of changes to the package you're using.

chapulina gravatar imagechapulina ( 2017-03-29 12:56:54 -0500 )edit

@chapulina ok, so I return to my original unresolved question: there is a way to modify spot light orientation using tum_simulator and Gazebo 2.2.6?

jony gravatar imagejony ( 2017-03-29 16:15:16 -0500 )edit

I think the only way would be to publish a Gazebo message to change the light pose after the world has been loaded.

chapulina gravatar imagechapulina ( 2017-03-29 18:47:04 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-03-28 04:57:35 -0500

Seen: 1,397 times

Last updated: Mar 29 '17