Exemplo n.º 1
0
 def test_example_requester_(self):
     """ Initialize ROCON scheduler node for example requester. """
     self.number_of_requests = 3     # number of requests desired
     self.queued_request = None
     rospy.init_node("test_example_requester")
     self.sch = Scheduler(self.callback)
     rospy.spin()                    # spin in the main thread
 def __init__(self):
     rospy.init_node("example_scheduler")
     # simplifying assumptions: all requests want a single robot,
     # and any of these will do:
     self.avail = deque([  # FIFO queue of available robots
         Resource(rapp='example_rapp', uri='rocon:/turtlebot/roberto'),
         Resource(rapp='example_rapp', uri='rocon:/turtlebot/marvin')
     ])
     self.ready_queue = deque()  # FIFO queue of waiting requests
     self.sch = Scheduler(self.callback)
     rospy.spin()
 def test_timeout_scheduler(self):
     """ Initialize ROCON scheduler node for timeout test. """
     rospy.init_node("timeout_scheduler")
     # simplifying assumptions: all requests want a single robot,
     # and any of these will do:
     self.avail = deque(  # FIFO queue of available robots
         [
             Resource(rapp='example_rapp', uri='rocon:/turtlebot/roberto'),
             Resource(rapp='example_rapp', uri='rocon:/turtlebot/marvin')
         ])
     self.ready_queue = deque()  # FIFO queue of waiting requests
     self.seen_requester = False
     self.timer = rospy.Timer(rospy.Duration(2.0), self.check_finished)
     self.sch = Scheduler(self.callback, frequency=1.0)
     rospy.spin()
Exemplo n.º 4
0
    def __init__(self,
                 node_name='simple_scheduler',
                 period=rospy.Duration(1.0)):
        """ Constructor. """
        rospy.init_node(node_name)
        self.ready_queue = PriorityQueue()
        """ Queue of waiting requests. """
        self.blocked_queue = PriorityQueue()
        """ Queue of blocked requests. """
        self.period = period
        """ Time duration between periodic rescheduling. """
        self.notification_set = set()
        """ Set of requester identifiers to notify. """
        self.timer = rospy.Timer(self.period, self.reschedule)
        self.lock = threading.RLock()
        """ Big Scheduler Lock. """
        self.pool = SchedulerClients(lock=self.lock)
        """ Resource pool of known ROCON clients. """
        self.sch = Scheduler(self.callback, lock=self.lock)
        """ Scheduler request handler. """

        # Handle messages until canceled.
        rospy.spin()