example_multi_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 def create_wait_task(node, secs=rospy.Duration(10)):
24  wait_task = Task(action='wait_action',start_node_id=node, end_node_id=node, max_duration=secs)
25  task_utils.add_time_argument(wait_task, rospy.Time())
26  task_utils.add_duration_argument(wait_task, secs)
27  return wait_task
28 
29 if __name__ == '__main__':
30  rospy.init_node("example_multi_add_client")
31 
32  # get services to call into execution framework
33  add_task, set_execution_status = get_services()
34 
35  nodes = ['h_2', 'v_2', 'h_-2']
36  tasks = map(create_wait_task, nodes)
37 
38  # wait_task = Task(action='',start_node_id=sys.argv[1], max_duration=max_duration)
39 
40  task_id = add_task(tasks)
41 
42  # Set the task executor running (if it isn't already)
43  resp = set_execution_status(True)
44 
45  # now let's stop execution while it's going on
46  # rospy.sleep(4)
47  # resp = set_execution_status(False)
48  # rospy.loginfo('Success: %s' % resp.success)
49  # rospy.loginfo('Wait: %s' % resp.remaining_execution_time)
50 
51  # # and start again
52  # rospy.sleep(2)
53  # set_execution_status(True)


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