example_demand_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 DemandTask, SetExecutionStatus
7 # import strands_executive_msgs
8 
10  # get services necessary to do the jon
11  demand_task_srv_name = '/task_executor/demand_task'
12  set_exe_stat_srv_name = '/task_executor/set_execution_status'
13  rospy.loginfo("Waiting for task_executor service...")
14  rospy.wait_for_service(demand_task_srv_name)
15  rospy.wait_for_service(set_exe_stat_srv_name)
16  rospy.loginfo("Done")
17  add_tasks_srv = rospy.ServiceProxy(demand_task_srv_name, DemandTask)
18  set_execution_status = rospy.ServiceProxy(set_exe_stat_srv_name, SetExecutionStatus)
19  return add_tasks_srv, set_execution_status
20 
21 
22 
23 
24 if __name__ == '__main__':
25  rospy.init_node("example_demand_client")
26 
27 
28  # get services to call into execution framework
29  demand_task, set_execution_status = get_services()
30 
31  # Set the task executor running (if it isn't already)
32  set_execution_status(True)
33  print 'set execution'
34 
35 
36  #
37  demanded_wait = Task(action='wait_action', max_duration=rospy.Duration(60), start_node_id='h_2')
38  resp = demand_task(demanded_wait)
39  print 'demanded task as id: %s' % resp.task_id
40  rospy.loginfo('Success: %s' % resp.success)
41  rospy.loginfo('Wait: %s' % resp.remaining_execution_time)
42 


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