Home | Tutorials | Wiki | Issues
Ask Your Question
3

Is there a way to modify the default camera position in the world file?

asked 2012-12-04 21:16:33 -0500

mdedonato gravatar image

updated 2012-12-07 14:51:54 -0500

I would like to move the camera position to something other than what it defaults to. How would I go about this in the world file? There is some documentation but it is vague.

Here is the code I am using changing the camera pose does nothing. I needed to put a name in for the camera, because it would not parse otherwise:

<?xml version="1.0" ?>
<sdf version="1.3">
    <world name="default">
   <gui>
      <camera name="user_default">
            <pose>-1 0 -2 0 -5 0</pose>
      </camera>
    </gui>    
<scene>
<shadows>false</shadows>
</scene>    


        <include>
            <uri>model://ground_plane</uri>
        </include>
        <include>
            <uri>model://sun</uri>
        </include>
        <include>
            <uri>model://robopede</uri>
        <name>robot</name>
            <pose>-2.5 0 0 0 0 0</pose>
        </include>
        <include>
            <uri>model://wall</uri>
            <name>wall_0</name>
            <pose>-3 0.22 0 0 0 0</pose>
        </include>
    <include>
            <uri>model://wall</uri>
            <name>wall_1</name>
            <pose>-3 -0.22 0 0 0 0</pose>
        </include>
               <include>
            <uri>model://wall</uri>
            <name>wall_2</name>
            <pose>-2 0.22 0 0 0 .5</pose>
        </include>
    <include>
            <uri>model://wall</uri>
            <name>wall_4</name>
            <pose>-2 -0.22 0 0 0 .5</pose>
        </include>

    </world>
</sdf>
edit retag flag offensive close merge delete

Comments

This is very annoying in the new gazebo. Can someone post their code to move the camera? I tried the <camera> <pose> setting, but i cannot get it to work. I am most likely doing something wrong

mdedonato gravatar imagemdedonato ( 2012-12-07 00:53:34 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted
4

answered 2012-12-07 10:39:10 -0500

natepak gravatar image
<sdf version='1.3'>
  <world>
    <gui>
      <camera>
        <pose>my custom pose as a six-tuple(x,y,z,roll,pitch,yaw)</pose>
      </camera>
    </gui>    

  </world>
</sdf>
edit flag offensive delete link more

Comments

Is this documented anywhere? [sdformat.org](http://sdformat.org/spec?ver=1.5&elem=world#camera_pose) lists nothing. What is the default orientation that roll/pitch/yaw effects?

Cerin gravatar imageCerin ( 2015-05-02 14:11:59 -0500 )edit
2

I couldn't find it documented, but the pose is described with respect to the world. <pose>0 0 0 0 0 0</pose> is centered at world origin looking towards the positive X axis with Z up and Y to the left. Note that the initial camera pose is not zero.

chapulina gravatar imagechapulina ( 2015-05-03 23:36:24 -0500 )edit
nkoenig gravatar imagenkoenig ( 2015-05-04 11:39:25 -0500 )edit

With SDF1.4, data format is as what @chapulina mentions. I think tuple (that can be commonly embraced in parenthesis) stated in the answer might be a bit confusing.

IsaacS gravatar imageIsaacS ( 2015-06-20 02:35:09 -0500 )edit

I do not know when that changed, but camera tag needs to have name attribute otherwise SDF parse gives error. It should be like <camera name="user_camera"> .. </camera> Also it would be beneficial to mention that the pose x, y, z, roll, pitch, yaw will be separated from each other with space not comma. Another trick to set an appropriate camera position would be moving the camera by running the simulation and getting required pose by selecting the GUI on the model explorer.

okan gravatar imageokan ( 2018-06-30 07:53:09 -0500 )edit
1

answered 2018-08-20 01:48:38 -0500

Subodh Malgonde gravatar image

updated 2018-08-20 01:49:27 -0500

The answer provided by @natepak answers it. Just a few minor modifications and clarifications if you are using Gazebo 9+. My low karma does not allow me to make edits, so posting a separate answer here:

  1. The element camera requires a name attribute. It is 'user_camera' for the Gazebo view camera.
  2. The angles should be in radians
  3. Elements in pose should be separated by space. <pose>x y z roll pitch yaw</pose>

Example:

<world>
    <gui>
        <camera name="user_camera">
            <pose>-7.35 -3.59 39.73 0 1.417 0.124</pose>
        </camera>
    </gui>
</world>
edit flag offensive delete link more
0

answered 2012-12-14 12:13:33 -0500

nkoenig gravatar image
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

2 followers

Stats

Asked: 2012-12-04 21:16:33 -0500

Seen: 2,227 times

Last updated: Aug 20 '18