Skip to content
This repository was archived by the owner on Mar 18, 2025. It is now read-only.

Use world origin spherical coordinates from SDF if set#177

Merged
chapulina merged 1 commit intomainfrom
chapulina/world_spherical
Mar 30, 2022
Merged

Use world origin spherical coordinates from SDF if set#177
chapulina merged 1 commit intomainfrom
chapulina/world_spherical

Conversation

@chapulina
Copy link
Contributor

@chapulina chapulina commented Mar 23, 2022


Originally, WorldCommPlugin would set the world origin to coincide with the first spawned vehicle and ignore the coordinates set from SDF. This is useful for generic simulation worlds that can be used for multiple scenarios.

But for #146 , we're creating a world that has environment features that need to be precisely geolocated. This means that we need to set the world origin before any vehicles are spawned.

This PR makes sure we support both cases:

  • If <sperical_coordinates> isn't set from SDF, it will be set when the first vehicle is spawned.
  • If it is set, then all vehicles are spawned w.r.t. that origin

Test it

Case when there's on <spherical_coordinates>:

  1. ign gazebo empty_environment.sdf
  2. See on inspector that there are no spherical coordinates yet
  3. bin/LRAUV
  4. The vehicle is spawned at the origin and the world now has spherical coordinates

Case when there's <spherical_coordinates>:

  1. Edit empty_environment.sdf to add spherical coordinates:
    diff --git a/lrauv_ignition_plugins/worlds/empty_environment.sdf b/lrauv_ignition_plugins/worlds/empty_environment.sdf
    index ce76e0b..2a2f914 100644
    --- a/lrauv_ignition_plugins/worlds/empty_environment.sdf
    +++ b/lrauv_ignition_plugins/worlds/empty_environment.sdf
    @@ -56,6 +56,16 @@       
           name="tethys::TimeAnalysisPlugin">
         </plugin-->       
                                                                   
    +    <spherical_coordinates>                                                                                                                   
    +      <surface_model>EARTH_WGS84</surface_model>                                                                                              
    +      <world_frame_orientation>ENU</world_frame_orientation>                                                                                  
    +      <latitude_deg>36.803500000000</latitude_deg>                                                                                                                                                           
    +      <longitude_deg>-121.822200000000</longitude_deg>           
    +      <elevation>0</elevation>                                                                                                                
    +      <heading_deg>0</heading_deg>
    +    </spherical_coordinates>                                       
    +                                                                   
         <plugin                                                        
           filename="ScienceSensorsSystem"                    
           name="tethys::ScienceSensorsSystem">
  2. ign gazebo empty_environment.sdf
  3. See on inspector that there are spherical coordinates
  4. bin/LRAUV
  5. The vehicle is spawned far from the origin

Signed-off-by: Louise Poubel <louise@openrobotics.org>
@chapulina chapulina self-assigned this Mar 23, 2022
@chapulina chapulina mentioned this pull request Mar 23, 2022
10 tasks
@hidmic hidmic self-requested a review March 29, 2022 15:16
Copy link
Collaborator

@hidmic hidmic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM though I haven't tested it locally just yet.

@hidmic
Copy link
Collaborator

hidmic commented Mar 30, 2022

I tested it locally, this is ready to go @chapulina !

@chapulina
Copy link
Contributor Author

CI is broken for other reasons, but the spawn test passed. So merging.

@chapulina chapulina merged commit 3afb7c2 into main Mar 30, 2022
@chapulina chapulina deleted the chapulina/world_spherical branch March 30, 2022 19:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants