7 from std_msgs.msg
import String
8 from random
import shuffle
14 """ Repeatedly sends a randomised list of task to the task executor. These don't have tasks associated with them. If you want to add tasks, see fifo_tester.py for an example."""
17 rospy.Subscriber(
'topological_map', TopologicalMap, self.
map_callback)
21 rospy.loginfo(
'Patrolling the following nodes: %s' % self.
waypoints)
26 add_tasks_srv_name =
'task_executor/add_tasks'
27 set_exe_stat_srv_name =
'task_executor/set_execution_status'
28 rospy.loginfo(
"Waiting for task_executor service...")
29 rospy.wait_for_service(add_tasks_srv_name)
30 rospy.wait_for_service(set_exe_stat_srv_name)
32 self.
add_tasks_srv = rospy.ServiceProxy(add_tasks_srv_name, AddTasks)
33 set_execution_status_srv = rospy.ServiceProxy(set_exe_stat_srv_name, SetExecutionStatus)
40 set_execution_status_srv(
True)
41 except rospy.ServiceException, e:
42 print "Service call failed: %s"%e
46 print 'got map: %s' % len(msg.nodes)
47 self.
node_names = [node.name
for node
in msg.nodes]
56 rospy.loginfo(
"Sending next batch of patrol tasks")
58 patrol_tasks = [Task(start_node_id=wp, end_node_id=wp)
for wp
in self.
waypoints]
67 rospy.loginfo(
"Changed nodes to %s from %s" % (data.data, self.
current_waypoint))
77 if __name__ ==
'__main__':
78 rospy.init_node(
"patrol_scheduler")
def current_node_cb(self, data)
def map_callback(self, msg)