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
12 from strands_executive_msgs
import task_utils
21 from topological_navigation.msg
import GotoNodeAction, GotoNodeResult
22 from copy
import deepcopy
23 from random
import random
30 add_tasks_srv_name =
'/task_executor/add_tasks'
31 set_exe_stat_srv_name =
'/task_executor/set_execution_status'
32 rospy.loginfo(
"Waiting for task_executor service...")
33 rospy.wait_for_service(add_tasks_srv_name)
34 rospy.wait_for_service(set_exe_stat_srv_name)
36 add_tasks_srv = rospy.ServiceProxy(add_tasks_srv_name, AddTasks)
37 set_execution_status = rospy.ServiceProxy(set_exe_stat_srv_name, SetExecutionStatus)
38 return add_tasks_srv, set_execution_status
42 Publish a topological map for testing.
49 test_nodes = topological_navigation.testing.create_cross_map(width = width, height = height, nodeSeparation = nodeSeparation)
52 msg_store = MessageStoreProxy(collection=
'topological_maps')
54 map_name =
'test_top_map'
57 meta[
'map'] = map_name
58 meta[
'pointset'] = map_name
60 for (nodeName, node)
in test_nodes.iteritems():
61 meta[
"node"] = nodeName
62 node.map = meta[
'map']
63 node.pointset = meta[
'pointset']
64 msg_store.insert(node,meta)
67 ps = map_publisher(map_name)
75 Create an example of a task which we'll copy for other tasks later.
76 This is a good example of creating a task with a variety of arguments.
79 msg_store = MessageStoreProxy()
82 pose_name =
"my favourite pose"
85 message, meta = msg_store.query_named(pose_name, Pose._type)
88 message = Pose(Point(0, 1, 2), Quaternion(3, 4, 5, 6))
89 pose_id = msg_store.insert_named(pose_name, message)
93 master_task = Task(action=
'test_task')
94 task_utils.add_string_argument(master_task,
'hello world')
95 task_utils.add_object_id_argument(master_task, pose_id, Pose)
96 task_utils.add_int_argument(master_task, 24)
97 task_utils.add_float_argument(master_task, 63.678)
101 if __name__ ==
'__main__':
102 rospy.init_node(
"example_task_client")
105 actual_action_duration = rospy.Duration(20)
106 actual_drive_duration = rospy.Duration(1)
114 start_of_window = rospy.get_rostime()
116 max_action_duration = actual_drive_duration + actual_action_duration + actual_action_duration
118 end_of_window = start_of_window + rospy.Duration(max_action_duration.secs * (task_count + 1))
124 scheduled_duration = rospy.Duration(actual_action_duration.secs / 4)
131 for task_id
in range(task_count):
133 timed_task = deepcopy(master_task)
134 task_node = random.choice(test_nodes).name
135 timed_task.start_node_id=task_node
136 timed_task.end_node_id=task_node
137 timed_task.start_after = start_of_window
138 timed_task.end_before = end_of_window
140 timed_task.max_duration = scheduled_duration
141 tasks.append(timed_task)
152 task_ids = add_tasks(tasks)
153 print "Added %s" % task_ids
157 action_server =
TestTaskAction(expected_action_duration=actual_action_duration, expected_drive_duration=actual_drive_duration)
161 set_execution_status(
True)
def publish_topological_map()