transitions

This module tracks resource request state transitions, which occur as scheduler_msgs/Request messages flow between schedulers and requesters.

As individual Request messages are passed back and forth between the original requester and the scheduler, their status passes through several state transitions. Gray states are created by the scheduler via solid transitions. The dashed cancel transitions may be initiated by either the requester or the scheduler.

digraph state_transitions {
   New [peripheries=2]
   Reserved [peripheries=2]
   Reserved -> Waiting [label="wait"]
   Reserved -> Granted [label="grant"]
   Reserved -> Canceling [label="cancel", style="dashed"]
   New -> Waiting [label="wait"]
   New -> Granted [label="grant"]
   New -> Canceling [label="cancel", style="dashed"]
   Waiting [style="filled", color="grey"]
   Waiting -> Granted [label="grant"]
   Waiting -> Canceling [label="cancel", style="dashed"]
   Granted [style="filled", color="grey"]
   Granted -> Preempting [label="preempt"]
   Granted -> Canceling [label="cancel", style="dashed"]
   Preempting [style="filled", color="grey"]
   Preempting -> Canceling [label="cancel", style="dashed"]
   Canceling
   Canceling -> Closed [label="close"]
   Closed [peripheries=2, style="filled", color="grey"]
}

class rocon_scheduler_requests.transitions.RequestBase(msg)[source]

Base class for tracking the status of a single resource request.

Not for general use.

Parameters:msg (scheduler_msgs/Request) – ROCON scheduler request message.

Requesters and schedulers will use one of the following derived classes, with higher-level interfaces creating it automatically:

str(rq)
Returns :String representation of this resource request.
msg = None

Corresponding scheduler_msgs/Request message.

uuid = None

The uuid.UUID of this request.

cancel(reason=None)[source]

Cancel a previously-requested resource.

Parameters:reason – Reason code for cancellation, or None.

Always valid for both requesters and schedulers.

class rocon_scheduler_requests.transitions.ResourceRequest(msg)[source]

This represents a single resource request created by and for its original requester.

Parameters:msg (scheduler_msgs/Request) – ROCON scheduler request message.

Provides all attributes defined for RequestBase.

reconcile(update)[source]

Reconcile scheduler updates with requester status for a merge operation.

Parameters:update (ResourceRequest or None) – Latest information for this request, or None if no longer present.

Only the requester creates new requests. If something is missing from the scheduler feedback, that just means the scheduler has not gotten to it yet.

class rocon_scheduler_requests.transitions.ActiveRequest(msg)[source]

This represents a single active resource known to the scheduler.

Parameters:msg (scheduler_msgs/Request) – ROCON scheduler request message.

Provides all attributes defined for RequestBase.

allocations = None

List of resources actually allocated for this request (not just those requested).

close()[source]

Close resource request.

Raises :TransitionError
grant(resources)[source]

Grant some specific requested resources.

Parameters:resources (list of scheduler_msgs/Resource) – Exact resources granted.
Raises :TransitionError

The caller is responsible for ensuring that the granted resources really do fully satisfy this request.

reconcile(update)[source]

Reconcile updated request with current scheduler status for a merge operation.

Parameters:update (ActiveRequest or None) – Latest information for this request, or None if no longer present.
preempt(reason=0)[source]

Preempt a previously granted request.

Parameters:reason (int) – Reason for preemption.

Always valid for the scheduler, but has no effect unless the request was previously granted.

wait(reason=0)[source]

Put request in wait status until a suitable resource is available.

Parameters:reason (int) – Reason for waiting.
Raises :TransitionError
class rocon_scheduler_requests.transitions.RequestSet(reqs, requester_id=None, contents=<class 'rocon_scheduler_requests.transitions.ResourceRequest'>)[source]

This class is a container for all the resource requests or responses for a single requester. It acts like a dictionary.

Parameters:
  • reqs – Either a SchedulerRequests message or a list of Request messages, like the requests component of a SchedulerRequests message.
  • requester_id – (uuid.UUID) Unique ID this requester or None.
  • contents – Class from which to instantiate set members, either ResourceRequest (the default) for a requester or ActiveRequest for a scheduler.
Raises :

TypeError if the requester_id is not specified explicitly or as part of a SchedulerRequests message.

RequestSet supports these standard container operations:

len(rset)
Returns :The number of requests in the set.
rset[uuid]
Returns :The item corresponding to uuid.
Raises :KeyError if no such request.
rset[uuid] = msg

Assign a Request message for this uuid.

Param uuid:(uuid.UUID) UUID of the request.
Param msg:(scheduler_msgs/Request) message to add.
rset == other
Returns :

True if rset and other have the same contents.

Ignores the difference between request and reply messages.

rset != other
Returns :

True if rset and other have different contents.

Ignores the difference between request and reply messages.

str(rset)
Returns :String representation of RequestSet.
uuid in rset
Returns :True if rset has a key uuid, else False.
uuid not in rset

Equivalent to not uuid in rset.

These attributes are also provided:

contents = None

Type of objects this request set contains.

stamp = None

ROS time (rospy.Time) of last update, or time zero.

requester_id = None

uuid.UUID of this requester.

requests = None

Dictionary of active requests.

cancel_all(reason=None)[source]

Cancel every active request in this set.

Parameters:reason – Reason code for mass cancellation, or None.
cancel_out_of_date(reason=None)[source]

Cancel every out-of-date request in this set.

Only requests in a starting state are preserved. This is done whenever a requester first connects to the scheduler. If it presents requests that had previously been granted or preempted, they will be canceled and then closed.

Parameters:reason – Reason code for mass cancellation, or None.
get(uuid, default=None)[source]

Get request, if known.

Parameters:
  • uuid (uuid.UUID) – UUID of desired request.
  • default – value to return if no such request.
Returns:

named item, if successful; else default.

items()[source]
Returns:all (key, value) pairs for this RequestSet.
Return type:list (Python2) or dictionary view (Python3)
keys()[source]
Returns:all UUIDs for this RequestSet.
Return type:list (Python2) or dictionary view (Python3)
merge(updates)[source]

Merge new request information into this RequestSet.

Parameters:updates (RequestSet) – Request set containing updated information.

This is not a set.update() or set.union() operation:

  • New elements from the updates will be added, but only if they are in an initial state (NEW or RESERVED).
  • Existing elements will be reconciled with the corresponding updates status.
  • Any element reaching a terminal status known by both sides of the protocol will be deleted.
to_msg(stamp=None)[source]

Convert to ROS scheduler_msgs/SchedulerRequest message.

Parameters:stamp (rospy.Time) – Time stamp for message header. If None, use current time.
Returns:corresponding scheduler_msgs/SchedulerRequests
values()[source]
Returns:all requests for this RequestSet.
Return type:list (Python2) or dictionary view (Python3)

Previous topic

scheduler

Next topic

Change history

This Page