unpause_simulation.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # Copyright (c) 2016 The UUV Simulator Authors.
3 # All rights reserved.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 from __future__ import print_function
17 import rospy
18 from std_srvs.srv import Empty
19 import time
20 import sys
21 
22 
23 if __name__ == '__main__':
24  rospy.init_node('unpause_simulation')
25 
26  if rospy.is_shutdown():
27  rospy.ROSException('ROS master is not running!')
28 
29  timeout = 0.0
30  if rospy.has_param('~timeout'):
31  timeout = rospy.get_param('~timeout')
32  if timeout <= 0:
33  raise rospy.ROSException('Unpause time must be a positive floating point value')
34 
35  print('Unpause simulation - Time = {} s'.format(timeout))
36 
37  start_time = time.time()
38  while time.time() - start_time < timeout:
39  time.sleep(0.1)
40 
41  try:
42  # Handle for retrieving model properties
43  rospy.wait_for_service('/gazebo/unpause_physics', 100)
44  unpause = rospy.ServiceProxy('/gazebo/unpause_physics', Empty)
45  except rospy.ROSException:
46  print('/gazebo/unpause_physics service is unavailable')
47  sys.exit()
48 
49  unpause()
50  print('Simulation unpaused...')


uuv_assistants
Author(s): Musa Morena Marcusso Manhaes , Sebastian Scherer , Luiz Ricardo Douat
autogenerated on Mon Jul 1 2019 19:39:08