example_add_client.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import rospy
4 from strands_executive_msgs import task_utils
5 from strands_executive_msgs.msg import Task
6 from strands_executive_msgs.srv import AddTasks, SetExecutionStatus
7 from strands_navigation_msgs.msg import *
8 import sys
9 
11  # get services necessary to do the jon
12  add_tasks_srv_name = '/task_executor/add_tasks'
13  set_exe_stat_srv_name = '/task_executor/set_execution_status'
14  rospy.loginfo("Waiting for task_executor service...")
15  rospy.wait_for_service(add_tasks_srv_name)
16  rospy.wait_for_service(set_exe_stat_srv_name)
17  rospy.loginfo("Done")
18  add_tasks_srv = rospy.ServiceProxy(add_tasks_srv_name, AddTasks)
19  set_execution_status = rospy.ServiceProxy(set_exe_stat_srv_name, SetExecutionStatus)
20  return add_tasks_srv, set_execution_status
21 
22 
23 if __name__ == '__main__':
24  rospy.init_node("example_add_client")
25 
26  # get services to call into execution framework
27  add_task, set_execution_status = get_services()
28 
29  print 'Requesting wait at ', sys.argv[1]
30 
31  max_duration = rospy.Duration(int(sys.argv[2]))
32  wait_task = Task(action='wait_action',start_node_id=sys.argv[1], max_duration=max_duration)
33  task_utils.add_time_argument(wait_task, rospy.Time())
34  task_utils.add_duration_argument(wait_task, max_duration)
35 
36 
37  # wait_task = Task(action='',start_node_id=sys.argv[1], max_duration=max_duration)
38 
39  task_id = add_task([wait_task])
40 
41  # Set the task executor running (if it isn't already)
42  set_execution_status(True)
43 
44  # now let's stop execution while it's going on
45  rospy.sleep(int(sys.argv[2])/2)
46  set_execution_status(False)


task_executor
Author(s): Nick Hawes
autogenerated on Tue Mar 17 2015 20:08:13