Skip to content

Proposal to add support for managing simulation worlds #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

ayushgnv
Copy link

@ayushgnv ayushgnv commented Apr 1, 2025

Proposal for World Management Services for Simulation Interfaces Standard

These interfaces provide standardized world management across simulation_interfaces.

The proposed API introduces functionality to dynamically load and unload worlds, enabling automated testing across diverse simulation environments without restarting the simulator. This would allow for workflows where users can load a world file, spawn entities, and run SIL testing facilitating continuous operation on remote systems (sometimes in headless mode).

For Isaac Sim and O3DE (@adamdbrw), these services would likely be useful as these platforms support loading worlds dynamically.

Unlike Entities only one world should be loaded at a time. Attempting to load a world when a world already exists should result in automatically unloading the previously loaded world before loading the current one.

Change Summary:

  • New message: WorldResource
  • New services: LoadWorld, UnloadWorld, GetCurrentWorld, GetAvailableWorlds
  • Added corresponding feature flags (40-44) to SimulatorFeatures.msg
  • Added world_formats field to track supported world file formats

@ayushgnv ayushgnv changed the title Proposal to add support for modifying simulation worlds Proposal to add support for managing simulation worlds Apr 1, 2025
@pijaro
Copy link

pijaro commented Apr 8, 2025

I think it's a good idea.

However, I'm missing an additional simulator state. Setting up a new world will take time, and we should consider that. I suggest adding something like this to SimulationState.msg:

uint8 STATE_INITIALIZING = 4  # Simulation resources are being loaded; the simulation is not running and cannot be started, stopped, or paused.

@adamdbrw
Copy link
Contributor

adamdbrw commented Apr 9, 2025

Good PR, I would love to follow up and propose changes soon, will submit as a PR targeting this one.

@ayushgnv
Copy link
Author

I think it's a good idea.

However, I'm missing an additional simulator state. Setting up a new world will take time, and we should consider that. I suggest adding something like this to SimulationState.msg:

uint8 STATE_INITIALIZING = 4  # Simulation resources are being loaded; the simulation is not running and cannot be started, stopped, or paused.

@pijaro Thanks, great idea! Added STATE_INITIALIZING to SimulationState.msg

Signed-off-by: Adam Dąbrowski <adam.dabrowski@robotec.ai>
@adamdbrw
Copy link
Contributor

ayushgnv#1 - there's the PR

adamdbrw and others added 2 commits April 22, 2025 10:44
Signed-off-by: Adam Dąbrowski <adam.dabrowski@robotec.ai>
suggested changes to simulation interface worlds
@adamdbrw
Copy link
Contributor

@mjcarroll @peci1 @DLu could you take a look at this one?

Copy link
Contributor

@peci1 peci1 left a comment

Choose a reason for hiding this comment

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

I went through this and left a few comments.

ayushgnv and others added 3 commits May 2, 2025 00:38
Co-authored-by: Martin Pecka <peci1@seznam.cz>
Co-authored-by: Martin Pecka <peci1@seznam.cz>
ayushgnv and others added 3 commits May 5, 2025 17:05
@ayushgnv ayushgnv requested a review from peci1 May 6, 2025 10:59
@mjcarroll
Copy link
Collaborator

@peci1 any more feedback here or are we good?

Copy link
Contributor

@DLu DLu left a comment

Choose a reason for hiding this comment

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

Apologies for the late review.

The thing that confuses me is what actually goes in the URI. I imagined them as unique ids, but LoadWorld.srv specifies them as having a specific format, like SDF.

Comment on lines +16 to +17
uint8 STATE_NO_WORLD = 4 # Simulation world is currently unloaded and a new world has not finished loading yet.
# The simulation is inactive and cannot be started, stopped, or paused.
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like NO_WORLD is a little too specific in this context and STATE_TRANSITIONAL would be better.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
uint8 STATE_NO_WORLD = 4 # Simulation world is currently unloaded and a new world has not finished loading yet.
# The simulation is inactive and cannot be started, stopped, or paused.
uint8 STATE_NO_WORLD = 4 # Simulation world is currently unloaded, and/or a new world has not finished loading yet.
# The simulation is inactive and cannot be started, stopped, or paused.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not 100% sure with my English here. Would TRANSITIONAL also semantically cover the instant where no world is loaded and no world is commanded to be loading?

Comment on lines +11 to +12
# URI which will be accepted by LoadWorld service, unique per world.
string uri
Copy link
Contributor

Choose a reason for hiding this comment

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

So we already have the Spawnable.msg in this package that has a string uri, string description and a spawn_bounds. I think this would be cleaner if we eliminated the non-unique name from this message.

Copy link
Author

@ayushgnv ayushgnv May 13, 2025

Choose a reason for hiding this comment

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

I think semantically any Spawnable object is spawned while simulation is running. Whereas a world would be something you load by stopping sim, opening a new world which resets the current simulation. We could look into renaming or updating the descriptions in Spawnable.msg if we would still like to reuse this message type for loading worlds.

@adamdbrw @peci1 @mjcarroll any thoughts on this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think what repeats here is uri and description, which could be abstracted into "Resource", but a world is essentially quite a different type of thing - something that is required for spawning anything (in it).

Copy link
Contributor

Choose a reason for hiding this comment

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

I think its fine to have Spawnable and WorldResource. My point was to highlight the difference that both have a uri and description, but only worlds have names.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm also okay with keeping this separate message. However, see further.

string uri

# Simulation world passed as a string. This field is used if the uri field is empty.
string resource_string
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make more sense to have two separate services.

  1. Add World, which takes in a resource_string and makes it available for use
  2. Load World, which only takes a uri

Copy link
Author

Choose a reason for hiding this comment

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

Would does "makes it available for use" entail for the simulator? Is there any pre-processing that needs to happen before loading a world in your case?

Copy link
Contributor

Choose a reason for hiding this comment

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

Does "adding" have a value from the perspective of external interface node / automation? I am of opinion that it is an implementation detail, some resources need to be downloaded and other will be available; I would expect the simulator to handle that.

Perhaps it would be useful to document that loading can take a bit and make things clearer through error codes, suggesting async service call etc, what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

So from an abstract perspective, here's what I imagine.

As an external client, I call GetAvailableWorlds.srv and get a list of unique world uri.

worlds: [
  - {uri: 'factory1'}
  - {uri: 'competition_2'}
  - {uri: 'moon}
]

I could then call LoadWorld.srv with uri: 'moon'. However, if instead I wanted to load in some other world that is not specified yet, I could call AddWorld.srv with the resource_string (which I assume would be SDF or similar), and then that new world be listed in the available worlds.

The core issue here is that I think it is semantically cleaner to run separate Add/Load calls than it is to have the single Load call with different behavior if the uri field is empty or not. Also, what happens when uri is nonempty and resource_string is nonempty?

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems to me it could be beneficial to create a Resource message like this:

string uri
string resource_string  # only used if uri is empty

This could then be used in Spawnable, WorldResource and here.

The proposal with AddWorld/LoadWorld seems too complicated to me.

@ayushgnv
Copy link
Author

ayushgnv commented May 13, 2025

Apologies for the late review.

The thing that confuses me is what actually goes in the URI. I imagined them as unique ids, but LoadWorld.srv specifies them as having a specific format, like SDF.

@DLu At least from an Isaac Sim perspective we would load USD files by accessing the filepaths in the URI field. Happy to update the LoadWorld.srv message type or description to be something more permissive.

@DLu
Copy link
Contributor

DLu commented May 13, 2025

Apologies for the late review.
The thing that confuses me is what actually goes in the URI. I imagined them as unique ids, but LoadWorld.srv specifies them as having a specific format, like SDF.

@DLu At least from an Isaac Sim perspective we would load USD files by accessing the filepaths in the URI field. Happy to update the LoadWorld.srv message type or description to be something more permissive.

Might just be me, but I could benefit from a description of how you envision these services being used, similar to the "call this one, then this one" example I gave above.

Comment on lines +11 to +12
# URI which will be accepted by LoadWorld service, unique per world.
string uri
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm also okay with keeping this separate message. However, see further.


# Optional field for additional sources (local or remote) to search,
# specified as standard URIs if possible.
string[] sources
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
string[] sources
string[] additional_sources

Also, it's not clear to me what should I type in this field. Is it https://app.gazebosim.org/fuel/worlds or https://fuel.gazebosim.org/1.0 or something else?

Last, what to do if there are standard online source (like the Fuel database), but we'd like to allow these use-cases without the user needing to look up docs for some particular URI?

  1. Search only locally available worlds, not connecting to the Internet
  2. Search also the default online locations

As one possibility, I think the worlds could get a virtual tag LOCAL or ONLINE which would tell whether they are locally available or not. The implementations could then first check for this particular tag filter and skip the online search when it is not needed. But what if the implementation doesn't support world tags?

Comment on lines +16 to +17
uint8 STATE_NO_WORLD = 4 # Simulation world is currently unloaded and a new world has not finished loading yet.
# The simulation is inactive and cannot be started, stopped, or paused.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not 100% sure with my English here. Would TRANSITIONAL also semantically cover the instant where no world is loaded and no world is commanded to be loading?

string uri

# Simulation world passed as a string. This field is used if the uri field is empty.
string resource_string
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems to me it could be beneficial to create a Resource message like this:

string uri
string resource_string  # only used if uri is empty

This could then be used in Spawnable, WorldResource and here.

The proposal with AddWorld/LoadWorld seems too complicated to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants