From 105b00aae400799e03f14dec665257777613ef7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pe=C5=82ka?= Date: Mon, 27 Oct 2025 17:28:16 +0100 Subject: [PATCH 1/4] Add array spawn service. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Pełka --- msg/SimulatorFeatures.msg | 2 ++ srv/SpawnEntities.srv | 46 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 srv/SpawnEntities.srv diff --git a/msg/SimulatorFeatures.msg b/msg/SimulatorFeatures.msg index 2ea1ce3..3ca5341 100644 --- a/msg/SimulatorFeatures.msg +++ b/msg/SimulatorFeatures.msg @@ -38,6 +38,8 @@ uint8 WORLD_UNLOADING = 43 # Supports UnloadWorld interface uint8 WORLD_INFO_GETTING = 44 # Supports GetCurrentWorld interface uint8 AVAILABLE_WORLDS = 45 # Supports GetAvailableWorlds interface +uint8 SPAWNING_ARRAY = 50 # Support array spawning (SpawnEntities) + uint16[] features # A list of simulation features as specified by the list above. # A list of additional supported formats for spawning, which might be empty. Values may include diff --git a/srv/SpawnEntities.srv b/srv/SpawnEntities.srv new file mode 100644 index 0000000..f5c08de --- /dev/null +++ b/srv/SpawnEntities.srv @@ -0,0 +1,46 @@ +# Spawn entities (a robot, other object) by name or URI +# Support for this interface is indicated through the SPAWNING_ARRAY value in GetSimulationFeatures. + +string names[] # A list of names given to every entity + # If string is empty, a name field in the uri file or resource_string will be used, + # if supported and not empty (e.g. "name" field in SDFormat, URDF). + # If the name is still empty or not unique (as determined by the simulator), + # the service returns a generated name in the entity_name response field if the + # allow_renaming field is set to true. Otherwise, the service call fails and an + # error is returned. +bool allow_renaming[] # Determines whether the spawning succeeds with a non-unique name. + # If it is set to true, the user should always check entity_name response field + # and use it for any further interactions. + +Resource entity_resources[] # List of resources such as SDFormat, URDF, USD or MJCF file, a native prefab, etc. + # Valid URIs can be determined by calling GetSpawnables first. + # Check simulator format support via the spawn_formats field in GetSimulatorFeatures. + # Using resource_string is supported if GetSimulatorFeatures includes + # the SPAWNING_RESOURCE_STRING feature. + +string entity_namespaces[] # Spawn entities with theirs interfaces under those namespaces. +geometry_msgs/PoseStamped initial_poses[] # Array of initial poses for every enttiy. + # The header contains a reference frame, which defaults to global "world" frame. + # This frame must be known to the simulator, e.g. of an object spawned earlier. + # The timestamp field in the header is ignored. + +--- + +# Additional result.result_code values for this service. Check result.error_message for further details. +uint8 NAME_NOT_UNIQUE = 101 # Given name is already taken by entity and allow_renaming is false. +uint8 NAME_INVALID = 102 # Given name is invalid in the simulator (e.g. does not meet naming + # requirements such as allowed characters). This is also returned if name is + # empty and allow_renaming is false. +uint8 UNSUPPORTED_FORMAT = 103 # Format for uri or resource string is unsupported. Check supported formats + # through GetSimulatorFeatures service, in spawn_formats field. +uint8 NO_RESOURCE = 104 # Both uri and resource string are empty. +uint8 NAMESPACE_INVALID = 105 # Namespace does not meet namespace naming standards. +uint8 RESOURCE_PARSE_ERROR = 106 # Resource file or string failed to parse. +uint8 MISSING_ASSETS = 107 # At least one of resource assets (such as meshes) was not found. +uint8 UNSUPPORTED_ASSETS = 108 # At least one of resource assets (such as meshes) is not supported. +uint8 INVALID_POSE = 109 # initial_pose is invalid, such as when the quaternion is invalid or position + # exceeds simulator world bounds. + +Result results[] +string entity_names[] # List of names of spawned entities, guaranteed to be unique in the simulation. + # If allow_renaming is true, it may differ from the request name field. From ffdec5b31579954b8e75762c869aee6d7aef7d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pe=C5=82ka?= Date: Fri, 6 Mar 2026 12:02:51 +0100 Subject: [PATCH 2/4] review comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Pełka --- CMakeLists.txt | 1 + msg/SimulatorFeatures.msg | 2 +- ...awnEntities.srv => BatchSpawnEntities.srv} | 38 +++++++++---------- 3 files changed, 19 insertions(+), 22 deletions(-) rename srv/{SpawnEntities.srv => BatchSpawnEntities.srv} (58%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 18eb7dc..70dcf88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,7 @@ set(msg_files ) set(srv_files + "srv/BatchSpawnEntities.srv" "srv/DeleteEntity.srv" "srv/GetAvailableWorlds.srv" "srv/GetCurrentWorld.srv" diff --git a/msg/SimulatorFeatures.msg b/msg/SimulatorFeatures.msg index 3ca5341..b1d4957 100644 --- a/msg/SimulatorFeatures.msg +++ b/msg/SimulatorFeatures.msg @@ -38,7 +38,7 @@ uint8 WORLD_UNLOADING = 43 # Supports UnloadWorld interface uint8 WORLD_INFO_GETTING = 44 # Supports GetCurrentWorld interface uint8 AVAILABLE_WORLDS = 45 # Supports GetAvailableWorlds interface -uint8 SPAWNING_ARRAY = 50 # Support array spawning (SpawnEntities) +uint8 SPAWNING_BATCH = 50 # Support batch spawning (SpawnEntities) uint16[] features # A list of simulation features as specified by the list above. diff --git a/srv/SpawnEntities.srv b/srv/BatchSpawnEntities.srv similarity index 58% rename from srv/SpawnEntities.srv rename to srv/BatchSpawnEntities.srv index f5c08de..9485e16 100644 --- a/srv/SpawnEntities.srv +++ b/srv/BatchSpawnEntities.srv @@ -1,5 +1,5 @@ -# Spawn entities (a robot, other object) by name or URI -# Support for this interface is indicated through the SPAWNING_ARRAY value in GetSimulationFeatures. +# Spawn entities (a robot, other object) by name or URI in a batch. +# Support for this interface is indicated through the SPAWNING_BATCH value in GetSimulationFeatures. string names[] # A list of names given to every entity # If string is empty, a name field in the uri file or resource_string will be used, @@ -7,40 +7,36 @@ string names[] # A list of names given to every entity # If the name is still empty or not unique (as determined by the simulator), # the service returns a generated name in the entity_name response field if the # allow_renaming field is set to true. Otherwise, the service call fails and an - # error is returned. + # error is returned. bool allow_renaming[] # Determines whether the spawning succeeds with a non-unique name. # If it is set to true, the user should always check entity_name response field - # and use it for any further interactions. + # and use it for any further interactions. Number of elements have to match Number + # of elements in names. Resource entity_resources[] # List of resources such as SDFormat, URDF, USD or MJCF file, a native prefab, etc. # Valid URIs can be determined by calling GetSpawnables first. # Check simulator format support via the spawn_formats field in GetSimulatorFeatures. # Using resource_string is supported if GetSimulatorFeatures includes - # the SPAWNING_RESOURCE_STRING feature. + # the SPAWNING_RESOURCE_STRING feature. Number of elements have to match Number + # of elements in names. -string entity_namespaces[] # Spawn entities with theirs interfaces under those namespaces. +string entity_namespaces[] # Spawn entities with theirs interfaces under those namespaces. Number of elements have to match Number + # of elements in names. geometry_msgs/PoseStamped initial_poses[] # Array of initial poses for every enttiy. # The header contains a reference frame, which defaults to global "world" frame. # This frame must be known to the simulator, e.g. of an object spawned earlier. - # The timestamp field in the header is ignored. + # The timestamp field in the header is ignored. Number of elements have to match Number + # of elements in names. --- # Additional result.result_code values for this service. Check result.error_message for further details. -uint8 NAME_NOT_UNIQUE = 101 # Given name is already taken by entity and allow_renaming is false. -uint8 NAME_INVALID = 102 # Given name is invalid in the simulator (e.g. does not meet naming - # requirements such as allowed characters). This is also returned if name is - # empty and allow_renaming is false. -uint8 UNSUPPORTED_FORMAT = 103 # Format for uri or resource string is unsupported. Check supported formats - # through GetSimulatorFeatures service, in spawn_formats field. -uint8 NO_RESOURCE = 104 # Both uri and resource string are empty. -uint8 NAMESPACE_INVALID = 105 # Namespace does not meet namespace naming standards. -uint8 RESOURCE_PARSE_ERROR = 106 # Resource file or string failed to parse. -uint8 MISSING_ASSETS = 107 # At least one of resource assets (such as meshes) was not found. -uint8 UNSUPPORTED_ASSETS = 108 # At least one of resource assets (such as meshes) is not supported. -uint8 INVALID_POSE = 109 # initial_pose is invalid, such as when the quaternion is invalid or position - # exceeds simulator world bounds. -Result results[] +uint8 BATCH_SPAWN_MISMATCH = 110 # There is a mismatch in number of elements in names, allow_renaming, entity_resources, + # entity_namespaces, initial_poses. +uint8 BATCH_SPAWN_FAILED = 120 # There was at least one failed spawn request. Check individual results in results. + +Result result # If all spawning request succeeded it will give RESULT_OK or BATCH_SPAWN_FAILED +Result results[] # Individual spawn request results. Supported return codes are in SpanwEntity.srv. string entity_names[] # List of names of spawned entities, guaranteed to be unique in the simulation. # If allow_renaming is true, it may differ from the request name field. From c0940cd03141d4e01c8cb50632e52300e048f486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pe=C5=82ka?= Date: Thu, 26 Mar 2026 12:16:49 +0100 Subject: [PATCH 3/4] Replace BatchSpawnEntities with SpawnEntities using SpawnEntity/SpawnResult messages. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Pełka --- CMakeLists.txt | 4 +++- msg/SimulatorFeatures.msg | 2 +- msg/SpawnEntity.msg | 24 ++++++++++++++++++++++ msg/SpawnResult.msg | 18 ++++++++++++++++ srv/BatchSpawnEntities.srv | 42 -------------------------------------- srv/SpawnEntities.srv | 12 +++++++++++ srv/SpawnEntity.srv | 3 ++- 7 files changed, 60 insertions(+), 45 deletions(-) create mode 100644 msg/SpawnEntity.msg create mode 100644 msg/SpawnResult.msg delete mode 100644 srv/BatchSpawnEntities.srv create mode 100644 srv/SpawnEntities.srv diff --git a/CMakeLists.txt b/CMakeLists.txt index 70dcf88..57f0727 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,13 +27,14 @@ set(msg_files "msg/Result.msg" "msg/SimulationState.msg" "msg/SimulatorFeatures.msg" + "msg/SpawnEntity.msg" + "msg/SpawnResult.msg" "msg/Spawnable.msg" "msg/TagsFilter.msg" "msg/WorldResource.msg" ) set(srv_files - "srv/BatchSpawnEntities.srv" "srv/DeleteEntity.srv" "srv/GetAvailableWorlds.srv" "srv/GetCurrentWorld.srv" @@ -53,6 +54,7 @@ set(srv_files "srv/SetEntityState.srv" "srv/SetSimulationState.srv" "srv/SpawnEntity.srv" + "srv/SpawnEntities.srv" "srv/StepSimulation.srv" "srv/UnloadWorld.srv" ) diff --git a/msg/SimulatorFeatures.msg b/msg/SimulatorFeatures.msg index b1d4957..1073dee 100644 --- a/msg/SimulatorFeatures.msg +++ b/msg/SimulatorFeatures.msg @@ -38,7 +38,7 @@ uint8 WORLD_UNLOADING = 43 # Supports UnloadWorld interface uint8 WORLD_INFO_GETTING = 44 # Supports GetCurrentWorld interface uint8 AVAILABLE_WORLDS = 45 # Supports GetAvailableWorlds interface -uint8 SPAWNING_BATCH = 50 # Support batch spawning (SpawnEntities) +uint8 SPAWNING_ENTITIES = 50 # Support spawn multiple entities uint16[] features # A list of simulation features as specified by the list above. diff --git a/msg/SpawnEntity.msg b/msg/SpawnEntity.msg new file mode 100644 index 0000000..845e1e5 --- /dev/null +++ b/msg/SpawnEntity.msg @@ -0,0 +1,24 @@ +# Information about spawning an individual entity. + +string name # A name to give to the spawned entity. + # If empty, the name field in the URI file or resource_string will be used, + # if supported and not empty (e.g. "name" field in SDFormat, URDF). + # If the name is still empty or not unique (as determined by the simulator), + # the service returns a generated name in the entity_name response field if the + # allow_renaming field is set to true. Otherwise, the service call fails and an + # error is returned. +bool allow_renaming # Determines whether the spawning succeeds with a non-unique name. + # If it is set to true, the user should always check entity_name response field + # and use it for any further interactions. + +Resource entity_resource # Resource such as SDFormat, URDF, USD or MJCF file, a native prefab, etc. + # Valid URIs can be determined by calling GetSpawnables first. + # Check simulator format support via the spawn_formats field in GetSimulatorFeatures. + # Using resource_string is supported if GetSimulatorFeatures includes + # the SPAWNING_RESOURCE_STRING feature. + +string entity_namespace # Spawn the entity with all its interfaces under this namespace. +geometry_msgs/PoseStamped initial_pose # Initial entity pose. + # The header contains a reference frame, which defaults to global "world" frame. + # This frame must be known to the simulator, e.g. of an object spawned earlier. + # The timestamp field in the header is ignored. diff --git a/msg/SpawnResult.msg b/msg/SpawnResult.msg new file mode 100644 index 0000000..5b79c96 --- /dev/null +++ b/msg/SpawnResult.msg @@ -0,0 +1,18 @@ +# Result of spawning. +uint8 NAME_NOT_UNIQUE = 101 # Given name is already taken by entity and allow_renaming is false. +uint8 NAME_INVALID = 102 # Given name is invalid in the simulator (e.g. does not meet naming + # requirements such as allowed characters). This is also returned if name is + # empty and allow_renaming is false. +uint8 UNSUPPORTED_FORMAT = 103 # Format for uri or resource string is unsupported. Check supported formats + # through GetSimulatorFeatures service, in spawn_formats field. +uint8 NO_RESOURCE = 104 # Both uri and resource string are empty. +uint8 NAMESPACE_INVALID = 105 # Namespace does not meet namespace naming standards. +uint8 RESOURCE_PARSE_ERROR = 106 # Resource file or string failed to parse. +uint8 MISSING_ASSETS = 107 # At least one of resource assets (such as meshes) was not found. +uint8 UNSUPPORTED_ASSETS = 108 # At least one of resource assets (such as meshes) is not supported. +uint8 INVALID_POSE = 109 # initial_pose is invalid, such as when the quaternion is invalid or position + # exceeds simulator world bounds. + +Result result +string entity_name # Spawned entity full name, guaranteed to be unique in the simulation. + # If allow_renaming is true, it may differ from the request name field. \ No newline at end of file diff --git a/srv/BatchSpawnEntities.srv b/srv/BatchSpawnEntities.srv deleted file mode 100644 index 9485e16..0000000 --- a/srv/BatchSpawnEntities.srv +++ /dev/null @@ -1,42 +0,0 @@ -# Spawn entities (a robot, other object) by name or URI in a batch. -# Support for this interface is indicated through the SPAWNING_BATCH value in GetSimulationFeatures. - -string names[] # A list of names given to every entity - # If string is empty, a name field in the uri file or resource_string will be used, - # if supported and not empty (e.g. "name" field in SDFormat, URDF). - # If the name is still empty or not unique (as determined by the simulator), - # the service returns a generated name in the entity_name response field if the - # allow_renaming field is set to true. Otherwise, the service call fails and an - # error is returned. -bool allow_renaming[] # Determines whether the spawning succeeds with a non-unique name. - # If it is set to true, the user should always check entity_name response field - # and use it for any further interactions. Number of elements have to match Number - # of elements in names. - -Resource entity_resources[] # List of resources such as SDFormat, URDF, USD or MJCF file, a native prefab, etc. - # Valid URIs can be determined by calling GetSpawnables first. - # Check simulator format support via the spawn_formats field in GetSimulatorFeatures. - # Using resource_string is supported if GetSimulatorFeatures includes - # the SPAWNING_RESOURCE_STRING feature. Number of elements have to match Number - # of elements in names. - -string entity_namespaces[] # Spawn entities with theirs interfaces under those namespaces. Number of elements have to match Number - # of elements in names. -geometry_msgs/PoseStamped initial_poses[] # Array of initial poses for every enttiy. - # The header contains a reference frame, which defaults to global "world" frame. - # This frame must be known to the simulator, e.g. of an object spawned earlier. - # The timestamp field in the header is ignored. Number of elements have to match Number - # of elements in names. - ---- - -# Additional result.result_code values for this service. Check result.error_message for further details. - -uint8 BATCH_SPAWN_MISMATCH = 110 # There is a mismatch in number of elements in names, allow_renaming, entity_resources, - # entity_namespaces, initial_poses. -uint8 BATCH_SPAWN_FAILED = 120 # There was at least one failed spawn request. Check individual results in results. - -Result result # If all spawning request succeeded it will give RESULT_OK or BATCH_SPAWN_FAILED -Result results[] # Individual spawn request results. Supported return codes are in SpanwEntity.srv. -string entity_names[] # List of names of spawned entities, guaranteed to be unique in the simulation. - # If allow_renaming is true, it may differ from the request name field. diff --git a/srv/SpawnEntities.srv b/srv/SpawnEntities.srv new file mode 100644 index 0000000..8c7d678 --- /dev/null +++ b/srv/SpawnEntities.srv @@ -0,0 +1,12 @@ +# Spawn multiple entities (robots, objects) by name or URI. +# Support for this interface is indicated through the SPAWNING_ENTITIES value in GetSimulatorFeatures. + +SpawnEntity spawn_requests[] # List of spawn requests. + +--- + +# Additional result.result_code values for this service. Check result.error_message for further details. +uint8 ENTITIES_SPAWN_FAILED = 120 # There was at least one failed spawn request. Check individual results in the `results`. + +Result result # If one or more requests failed, it will give ENTITIES_SPAWN_FAILED otherwise RESULT_OK +SpawnResult results[] # List of results for each spawn request. diff --git a/srv/SpawnEntity.srv b/srv/SpawnEntity.srv index cab2afa..a92e5d2 100644 --- a/srv/SpawnEntity.srv +++ b/srv/SpawnEntity.srv @@ -1,8 +1,9 @@ # Spawn an entity (a robot, other object) by name or URI +# This interface is deprecated in favour of SpawnEntities.srv # Support for this interface is indicated through the SPAWNING value in GetSimulationFeatures. string name # A name to give to the spawned entity. - # If empty, a name field in the uri file or resource_string will be used, + # If empty, the name field in the URI file or resource_string will be used, # if supported and not empty (e.g. "name" field in SDFormat, URDF). # If the name is still empty or not unique (as determined by the simulator), # the service returns a generated name in the entity_name response field if the From 8cfa18b2542d8b9a250c164654a932f20f7911b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pe=C5=82ka?= Date: Thu, 26 Mar 2026 13:16:30 +0100 Subject: [PATCH 4/4] Update error code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Pełka --- srv/SpawnEntities.srv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srv/SpawnEntities.srv b/srv/SpawnEntities.srv index 8c7d678..61dc388 100644 --- a/srv/SpawnEntities.srv +++ b/srv/SpawnEntities.srv @@ -6,7 +6,7 @@ SpawnEntity spawn_requests[] # List of spawn requests. --- # Additional result.result_code values for this service. Check result.error_message for further details. -uint8 ENTITIES_SPAWN_FAILED = 120 # There was at least one failed spawn request. Check individual results in the `results`. +uint8 ENTITIES_SPAWN_FAILED = 150 # There was at least one failed spawn request. Check individual results in the `results`. Result result # If one or more requests failed, it will give ENTITIES_SPAWN_FAILED otherwise RESULT_OK SpawnResult results[] # List of results for each spawn request.