4 import mongodb_store_msgs.srv
as dc_srv
5 from mongodb_store_msgs.msg
import StringPair
6 import mongodb_store.util
as dc_util
7 from mongodb_store.message_store
import MessageStoreProxy
8 from geometry_msgs.msg
import Pose, Point, Quaternion
11 from strands_executive_msgs
import task_utils
20 from topological_navigation.msg
import GotoNodeAction
21 from copy
import deepcopy
22 from random
import random
24 from datetime
import *
25 from task_executor
import task_routine
31 add_tasks_srv_name =
'/task_executor/add_tasks'
32 set_exe_stat_srv_name =
'/task_executor/set_execution_status'
33 rospy.loginfo(
"Waiting for task_executor service...")
34 rospy.wait_for_service(add_tasks_srv_name)
35 rospy.wait_for_service(set_exe_stat_srv_name)
37 add_tasks_srv = rospy.ServiceProxy(add_tasks_srv_name, AddTasks)
38 set_execution_status = rospy.ServiceProxy(set_exe_stat_srv_name, SetExecutionStatus)
39 return add_tasks_srv, set_execution_status
42 master_task = Task(action=
'wait_action',start_node_id=
'WayPoint2',end_node_id=
'WayPoint3', max_duration=max_duration)
43 task_utils.add_time_argument(master_task, rospy.Time())
44 task_utils.add_duration_argument(master_task, max_duration)
49 Create an example of a task which we'll copy for other tasks later.
50 This is a good example of creating a task with a variety of arguments.
53 msg_store = MessageStoreProxy()
56 pose_name =
"my favourite pose"
59 message, meta = msg_store.query_named(pose_name, Pose._type)
62 message = Pose(Point(0, 1, 2), Quaternion(3, 4, 5, 6))
63 pose_id = msg_store.insert_named(pose_name, message)
68 master_task = Task(action=
'test_task',start_node_id=
'WayPoint2',end_node_id=
'WayPoint3', max_duration=max_duration)
69 task_utils.add_string_argument(master_task,
'hello world')
70 task_utils.add_object_id_argument(master_task, pose_id, Pose)
71 task_utils.add_int_argument(master_task, 24)
72 task_utils.add_float_argument(master_task, 63.678)
76 if __name__ ==
'__main__':
77 rospy.init_node(
"example_task_routine")
79 while not rospy.is_shutdown()
and rospy.get_rostime().secs == 0:
84 actual_action_duration = rospy.Duration(60)
86 action_server =
TestTaskAction(expected_action_duration=actual_action_duration, expected_drive_duration=actual_action_duration)
100 start = time(07,00, tzinfo=localtz)
101 end = time(20,00, tzinfo=localtz)
102 midday = time(12,00, tzinfo=localtz)
104 morning = (start, midday)
105 afternoon = (midday, end)
107 routine = task_routine.DailyRoutine(start, end)
117 routine.repeat_every_hour(task, times=10)
120 runner = task_routine.DailyRoutineRunner(start, end, add_tasks)
122 runner.add_tasks(routine.get_routine_tasks())
125 set_execution_status(
True)
def create_wait_task(max_duration)
def create_master_task(max_duration)