Skip to content

Commit

Permalink
Use configurable timeout in other wait for service calls (#1073)
Browse files Browse the repository at this point in the history
* Use configurable timeout in other wait for service calls

Follow-up to #1072

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Update argument description

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
(cherry picked from commit 00d0d67)
  • Loading branch information
jacobperron authored and chapulina committed Jul 29, 2020
1 parent 305148d commit c071749
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gazebo_ros/scripts/spawn_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(self, args):
parser.add_argument('-robot_namespace', type=str, default=self.get_namespace(),
help='change ROS namespace of gazebo-plugins')
parser.add_argument('-timeout', type=float, default=30.0,
help='Number of seconds to wait for the spawn entity service to \
help='Number of seconds to wait for the spawn and delete services to \
become available')
parser.add_argument('-unpause', action='store_true',
help='unpause physics after spawning entity')
Expand Down Expand Up @@ -257,7 +257,7 @@ def entity_xml_cb(msg):
def _spawn_entity(self, entity_xml, initial_pose):
self.get_logger().info('Waiting for service %s/spawn_entity' % self.args.gazebo_namespace)
client = self.create_client(SpawnEntity, '%s/spawn_entity' % self.args.gazebo_namespace)
if client.wait_for_service(timeout_sec=5.0):
if client.wait_for_service(timeout_sec=self.args.timeout):
req = SpawnEntity.Request()
req.name = self.args.entity
req.xml = str(entity_xml, 'utf-8')
Expand All @@ -282,7 +282,7 @@ def _delete_entity(self):
self.get_logger().info('Deleting entity [{}]'.format(self.args.entity))
client = self.create_client(
DeleteEntity, '%s/delete_entity' % self.args.gazebo_namespace)
if client.wait_for_service(timeout_sec=5.0):
if client.wait_for_service(timeout_sec=self.args.timeout):
req = DeleteEntity.Request()
req.name = self.args.entity
self.get_logger().info(
Expand Down

0 comments on commit c071749

Please sign in to comment.