Skip to content

Commit 63a5e91

Browse files
ayushgnvpeci1adamdbrwzakmat
committed
add support for managing simulation worlds (back-port #4)
Co-authored-by: Martin Pecka <[email protected]> Co-authored-by: Adam Dąbrowski <[email protected]> Co-authored-by: Mateusz Żak <[email protected]> Signed-off-by: Mateusz Żak <[email protected]>
1 parent 628bdf9 commit 63a5e91

12 files changed

+138
-16
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,19 @@ set(msg_files
2323
"msg/EntityInfo.msg"
2424
"msg/EntityState.msg"
2525
"msg/NamedPose.msg"
26+
"msg/Resource.msg"
2627
"msg/Result.msg"
2728
"msg/SimulationState.msg"
2829
"msg/SimulatorFeatures.msg"
2930
"msg/Spawnable.msg"
3031
"msg/TagsFilter.msg"
32+
"msg/WorldResource.msg"
3133
)
3234

3335
set(srv_files
3436
"srv/DeleteEntity.srv"
37+
"srv/GetAvailableWorlds.srv"
38+
"srv/GetCurrentWorld.srv"
3539
"srv/GetEntities.srv"
3640
"srv/GetEntitiesStates.srv"
3741
"srv/GetEntityBounds.srv"
@@ -42,12 +46,14 @@ set(srv_files
4246
"srv/GetSimulationState.srv"
4347
"srv/GetSimulatorFeatures.srv"
4448
"srv/GetSpawnables.srv"
49+
"srv/LoadWorld.srv"
4550
"srv/ResetSimulation.srv"
4651
"srv/SetEntityInfo.srv"
4752
"srv/SetEntityState.srv"
4853
"srv/SetSimulationState.srv"
4954
"srv/SpawnEntity.srv"
5055
"srv/StepSimulation.srv"
56+
"srv/UnloadWorld.srv"
5157
)
5258

5359
set(action_files

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ service mechanism itself.
1111

1212
## Suggested interface implementation priorities
1313

14-
[GetSimulatorFeatures](msg/GetSimulationFeatures.msg) should be implemented first, as it provides users with information about
14+
[GetSimulatorFeatures](srv/GetSimulatorFeatures.srv) should be implemented first, as it provides users with information about
1515
the state of support for all standard simulation interfaces.
1616

1717
Following that, aim for maintaining consistency within the implemented feature, such as enabling both
@@ -22,4 +22,9 @@ Some interfaces represent optional utility and are considered lower priority:
2222
- [GetNamedPoseBounds](srv/GetNamedPoseBounds.srv)
2323
- [GetNamedPoses](srv/GetNamedPoses.srv)
2424
- [GetSpawnables](srv/GetSpawnables.srv)
25-
- [SetEntityInfo](srv/SetEntityInfo.srv)
25+
- [SetEntityInfo](srv/SetEntityInfo.srv)
26+
- [GetAvailableWorlds](srv/GetAvailableWorlds.srv)
27+
- [LoadWorld](srv/LoadWorld.srv)
28+
- [UnloadWorld](srv/UnloadWorld.srv)
29+
- [GetCurrentWorld](srv/GetCurrentWorld.srv)
30+

msg/Resource.msg

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This message is used to specify a resource, either by a URI or by its string content.
2+
3+
string uri # If uri field is empty, resource_string must not be empty.
4+
5+
string resource_string # An entity definition file passed as a string, only used if uri is empty.
6+
# If uri field is not empty, resource_string field will be ignored.
7+
# Simulators may support spawning from a file generated on the fly (e.g. XACRO).

msg/SimulationState.msg

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
# Simulation states used in SetSimulationState and returned in GetSimulationState
22

3-
uint8 STATE_STOPPED = 0 # Simulation is stopped, which is equivalent to pausing and resetting with ALL.
4-
# This is typically the default state when simulator is launched.
5-
# Stopped simulation can be played. It can also be paused, which means
6-
# starting simulation in a paused state immediately,
7-
# without any time steps for physics or simulated clock ticks.
8-
uint8 STATE_PLAYING = 1 # Simulation is playing, can be either paused or stopped.
9-
uint8 STATE_PAUSED = 2 # Simulation is paused, can be either stopped (which will reset it) or played.
10-
uint8 STATE_QUITTING = 3 # Closing the simulator application. Switching from STATE_PLAYING or STATE_PAUSED
11-
# states is expected to stop the simulation first, and then exit.
12-
# Simulation interfaces will become unavailable after quitting.
13-
# Running simulation application is outside of the simulation interfaces as
14-
# there is no service to handle the call when the simulator is not up.
3+
uint8 STATE_STOPPED = 0 # Simulation is stopped, which is equivalent to pausing and resetting with ALL_PAUSED.
4+
# This is typically the default state when simulator is launched.
5+
# Stopped simulation can be played. It can also be paused, which means
6+
# starting simulation in a paused state immediately,
7+
# without any time steps for physics or simulated clock ticks.
158

9+
uint8 STATE_PLAYING = 1 # Simulation is playing, can be either paused or stopped.
10+
11+
uint8 STATE_PAUSED = 2 # Simulation is paused, can be either stopped (which will reset it) or played.
12+
13+
uint8 STATE_QUITTING = 3 # Closing the simulator application. Switching from STATE_PLAYING or STATE_PAUSED
14+
# states is expected to stop the simulation first, and then exit.
15+
# Simulation interfaces will become unavailable after quitting.
16+
# Running simulation application is outside of the simulation interfaces as
17+
# there is no service to handle the call when the simulator is not up.
18+
19+
uint8 STATE_NO_WORLD = 4 # Simulation world is currently unloaded.
20+
# The simulation is inactive and cannot be started, stopped, or paused.
21+
22+
uint8 STATE_LOADING_WORLD = 5 # Simulation world is currently loading.
23+
# The simulation is inactive while world is loading and cannot be started, stopped, or paused.
1624
uint8 state

msg/SimulatorFeatures.msg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ uint8 STEP_SIMULATION_MULTIPLE = 32 # Supports multi-stepping through simu
3131
# service or through SimulateSteps action.
3232
uint8 STEP_SIMULATION_ACTION = 33 # Supports SimulateSteps action interface.
3333

34+
uint8 WORLD_LOADING = 40 # Supports LoadWorld interface
35+
uint8 WORLD_RESOURCE_STRING = 41 # Supports LoadWorld resource_string field
36+
uint8 WORLD_TAGS = 42 # Supports world tags and tag filtering
37+
uint8 WORLD_UNLOADING = 43 # Supports UnloadWorld interface
38+
uint8 WORLD_INFO_GETTING = 44 # Supports GetCurrentWorld interface
39+
uint8 AVAILABLE_WORLDS = 45 # Supports GetAvailableWorlds interface
3440

3541
uint16[] features # A list of simulation features as specified by the list above.
3642

msg/Spawnable.msg

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Robot or other object which can be spawned in simulation runtime.
22

3-
string uri # URI which will be accepted by SpawnEntity service.
3+
string uri # Resource such as SDFormat, URDF, USD or MJCF file, a native prefab, etc.
4+
# Valid URIs can be determined by calling GetSpawnables first, and you can check
5+
# the simulator format support by reading SimulatorFeatures spawn_formats field.
6+
47
string description # Optional description for the user, e.g. "robot X with sensors A,B,C".
8+
59
Bounds spawn_bounds # Optional spawn area bounds which fully encompass this object.

msg/WorldResource.msg

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# World is a virtual environment in which the simulation happens.
2+
# Worlds are also known as scenes or levels in some simulators.
3+
# Depending on the world format, loading of a world might be associated with changes
4+
# in certain parameters, including physics settings such as gravity.
5+
# World resources may be defined in standard or simulation-specific formats,
6+
# and, depending on the simulator, loaded from local or remote repositories.
7+
8+
9+
string name # World name, which is not necessarily unique.
10+
11+
Resource world_resource # The resource for the world to be loaded.
12+
13+
string description # Optional custom description of the world
14+
15+
string[] tags # Optional tags describing the world (e.g., "indoor", "outdoor", "warehouse")

package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
33
<package format="3">
44
<name>simulation_interfaces</name>
5-
<version>1.0.1</version>
5+
<version>1.1.0</version>
66
<description>A package containing simulation interfaces including messages, services and actions</description>
77
<maintainer email="[email protected]">Adam Dabrowski</maintainer>
88
<license>Apache License 2.0</license>

srv/GetAvailableWorlds.srv

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Return a list of available world resources which can be used with LoadWorld.
2+
# Support for this interface is indicated through the AVAILABLE_WORLDS value in GetSimulatorFeatures.
3+
# By default, a simulator will search its default local and online sources. If some
4+
# default sources can't be accessed (e.g. due to connectivity issues), the
5+
# DEFAULT_SOURCES_FAILED error result code will be returned.
6+
7+
string[] additional_sources # Optional field for additional sources (local or remote) to search,
8+
# specified as standard URIs if possible.
9+
10+
TagsFilter filter # Only get worlds with tags matching the filter. The filter is optional and matches everything by default.
11+
# This feature is supported if WORLD_TAGS feature is included in output of GetSimulatorFeatures.
12+
13+
bool offline_only # If true, only offline/local sources should be searched. Defaults to false.
14+
15+
bool continue_on_error # If true, the simulator will continue to search sources even if some fail.
16+
# The service will return success if any source yielded worlds. Defaults to false.
17+
---
18+
19+
uint8 DEFAULT_SOURCES_FAILED = 101 # Some default sources could not be accessed.
20+
21+
Result result # Standard result message. A specific result code should be used if some sources were not accessible.
22+
23+
WorldResource[] worlds # Available world resources.

srv/GetCurrentWorld.srv

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Get information about the currently loaded world in the simulation.
2+
# Support for this interface is indicated through the WORLD_INFO_GETTING value in GetSimulatorFeatures.
3+
4+
---
5+
6+
uint8 NO_WORLD_LOADED = 101 # No world is loaded at the moment.
7+
8+
Result result # Standard result message
9+
10+
WorldResource world # Information about the currently loaded world. Only valid if result is RESULT_OK.

0 commit comments

Comments
 (0)