Skip to content

Commit c0940cd

Browse files
committed
Replace BatchSpawnEntities with SpawnEntities using SpawnEntity/SpawnResult messages.
Signed-off-by: Michał Pełka <michal.pelka@robotec.ai>
1 parent ffdec5b commit c0940cd

7 files changed

Lines changed: 60 additions & 45 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ set(msg_files
2727
"msg/Result.msg"
2828
"msg/SimulationState.msg"
2929
"msg/SimulatorFeatures.msg"
30+
"msg/SpawnEntity.msg"
31+
"msg/SpawnResult.msg"
3032
"msg/Spawnable.msg"
3133
"msg/TagsFilter.msg"
3234
"msg/WorldResource.msg"
3335
)
3436

3537
set(srv_files
36-
"srv/BatchSpawnEntities.srv"
3738
"srv/DeleteEntity.srv"
3839
"srv/GetAvailableWorlds.srv"
3940
"srv/GetCurrentWorld.srv"
@@ -53,6 +54,7 @@ set(srv_files
5354
"srv/SetEntityState.srv"
5455
"srv/SetSimulationState.srv"
5556
"srv/SpawnEntity.srv"
57+
"srv/SpawnEntities.srv"
5658
"srv/StepSimulation.srv"
5759
"srv/UnloadWorld.srv"
5860
)

msg/SimulatorFeatures.msg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ uint8 WORLD_UNLOADING = 43 # Supports UnloadWorld interface
3838
uint8 WORLD_INFO_GETTING = 44 # Supports GetCurrentWorld interface
3939
uint8 AVAILABLE_WORLDS = 45 # Supports GetAvailableWorlds interface
4040

41-
uint8 SPAWNING_BATCH = 50 # Support batch spawning (SpawnEntities)
41+
uint8 SPAWNING_ENTITIES = 50 # Support spawn multiple entities
4242

4343
uint16[] features # A list of simulation features as specified by the list above.
4444

msg/SpawnEntity.msg

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Information about spawning an individual entity.
2+
3+
string name # A name to give to the spawned entity.
4+
# If empty, the name field in the URI file or resource_string will be used,
5+
# if supported and not empty (e.g. "name" field in SDFormat, URDF).
6+
# If the name is still empty or not unique (as determined by the simulator),
7+
# the service returns a generated name in the entity_name response field if the
8+
# allow_renaming field is set to true. Otherwise, the service call fails and an
9+
# error is returned.
10+
bool allow_renaming # Determines whether the spawning succeeds with a non-unique name.
11+
# If it is set to true, the user should always check entity_name response field
12+
# and use it for any further interactions.
13+
14+
Resource entity_resource # Resource such as SDFormat, URDF, USD or MJCF file, a native prefab, etc.
15+
# Valid URIs can be determined by calling GetSpawnables first.
16+
# Check simulator format support via the spawn_formats field in GetSimulatorFeatures.
17+
# Using resource_string is supported if GetSimulatorFeatures includes
18+
# the SPAWNING_RESOURCE_STRING feature.
19+
20+
string entity_namespace # Spawn the entity with all its interfaces under this namespace.
21+
geometry_msgs/PoseStamped initial_pose # Initial entity pose.
22+
# The header contains a reference frame, which defaults to global "world" frame.
23+
# This frame must be known to the simulator, e.g. of an object spawned earlier.
24+
# The timestamp field in the header is ignored.

msg/SpawnResult.msg

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Result of spawning.
2+
uint8 NAME_NOT_UNIQUE = 101 # Given name is already taken by entity and allow_renaming is false.
3+
uint8 NAME_INVALID = 102 # Given name is invalid in the simulator (e.g. does not meet naming
4+
# requirements such as allowed characters). This is also returned if name is
5+
# empty and allow_renaming is false.
6+
uint8 UNSUPPORTED_FORMAT = 103 # Format for uri or resource string is unsupported. Check supported formats
7+
# through GetSimulatorFeatures service, in spawn_formats field.
8+
uint8 NO_RESOURCE = 104 # Both uri and resource string are empty.
9+
uint8 NAMESPACE_INVALID = 105 # Namespace does not meet namespace naming standards.
10+
uint8 RESOURCE_PARSE_ERROR = 106 # Resource file or string failed to parse.
11+
uint8 MISSING_ASSETS = 107 # At least one of resource assets (such as meshes) was not found.
12+
uint8 UNSUPPORTED_ASSETS = 108 # At least one of resource assets (such as meshes) is not supported.
13+
uint8 INVALID_POSE = 109 # initial_pose is invalid, such as when the quaternion is invalid or position
14+
# exceeds simulator world bounds.
15+
16+
Result result
17+
string entity_name # Spawned entity full name, guaranteed to be unique in the simulation.
18+
# If allow_renaming is true, it may differ from the request name field.

srv/BatchSpawnEntities.srv

Lines changed: 0 additions & 42 deletions
This file was deleted.

srv/SpawnEntities.srv

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Spawn multiple entities (robots, objects) by name or URI.
2+
# Support for this interface is indicated through the SPAWNING_ENTITIES value in GetSimulatorFeatures.
3+
4+
SpawnEntity spawn_requests[] # List of spawn requests.
5+
6+
---
7+
8+
# Additional result.result_code values for this service. Check result.error_message for further details.
9+
uint8 ENTITIES_SPAWN_FAILED = 120 # There was at least one failed spawn request. Check individual results in the `results`.
10+
11+
Result result # If one or more requests failed, it will give ENTITIES_SPAWN_FAILED otherwise RESULT_OK
12+
SpawnResult results[] # List of results for each spawn request.

srv/SpawnEntity.srv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Spawn an entity (a robot, other object) by name or URI
2+
# This interface is deprecated in favour of SpawnEntities.srv
23
# Support for this interface is indicated through the SPAWNING value in GetSimulationFeatures.
34

45
string name # A name to give to the spawned entity.
5-
# If empty, a name field in the uri file or resource_string will be used,
6+
# If empty, the name field in the URI file or resource_string will be used,
67
# if supported and not empty (e.g. "name" field in SDFormat, URDF).
78
# If the name is still empty or not unique (as determined by the simulator),
89
# the service returns a generated name in the entity_name response field if the

0 commit comments

Comments
 (0)