Module API - concert_schedulers

This is the top-level namespace of the concert_schedulers ROS package. It contains various requester-scheduler implementations and a library of scheduler launchers.

common

Common modules for the concert_schedulers package.

common.concert_client

This module wraps the concert_msgs data structure for a concert client in a python class for convenient handling inside a scheduler node.

class concert_schedulers.common.concert_client.ConcertClient(msg)[source]

Bases: object

Envelops the concert client msg data structure that is published to the rest of the concert with a few extra fields and methods useful for management by the scheduler.

__init__(msg)[source]

Initialise this concert client with the data from a msg received from the concert conductor.

Parameters:msg (concert_msgs.ConcertClient) –
abandon()[source]

Abandon the resource. Usually called after a request is cancelled or on shutdown. This stops the rapp.

allocate(request_id, request_priority, resource)[source]

Allocate the resource. This involves also starting the rapp.

Parameters:
  • request_id (str) –
  • request_priority (int) – usually one of scheduler_msgs.Request.XXX_PRIORITY values
  • resource (str) –
Raises:

FailedToAllocateException if the start_rapp service failed.

allocated

Whether or not it is currently allocated.

allocated_priority

If allocated, this indicates its priority.

gateway_name

The concert client’s name on the gateway network (typically has postfixed uuid)

is_compatible(resource)[source]

Simple boolean test to check if the client can run the specified resource.

Parameters:resource (str) –
Returns:true if compatible, false otherwise
Return type:bool
msg

The subscribed data structure describing a concert client.

name

The human readable concert alias for this client.

reallocate(request_id, request_priority, resource)[source]

Ungraceful reallocation. Stops the rapp and starts the new one. Should be sending a request off to the service to gracefully cancel the request at the time of its choosing instead.

Parameters:
  • request_id (str) –
  • request_priority (int) – usually one of scheduler_msgs.Request.XXX_PRIORITY values
  • resource (str) –
Returns:

the old request id (so the requester can be updated)

Return type:

str

toMsg()[source]

Convert this instances to a scheduler_msgs.CurrentStatus msg type. The scheduler typically uses this to publish the resource on it’s scheduler_resources_pool topic.

Returns:the message, with updated status if allocated.
Return type:concert_msgs.ConcertClient

common.exceptions

This module defines exceptions raised by the concert_schedulers package.

exception concert_schedulers.common.exceptions.FailedToAllocateException[source]

A more general catchall for allocation failure.

exception concert_schedulers.common.exceptions.FailedToStartRappsException[source]

Internally used to indicate when a rapp failed to start.

exception concert_schedulers.common.exceptions.InvalidResourceGroupException[source]

Used by the resource group requester to identify invalid resource group specifications.

common.utils

Simple utilities for the concert schedulers and requesters.

concert_schedulers.common.utils.is_compatible(concert_client, resource)[source]

Checks to see if a client is compatible for the implementation’s node rule.

Parameters:
  • resource (scheduler_msgs.Resource) –
  • concert_msgs.ConcertClient – concert_client
Returns:

true if compatible, false otherwise

Return type:

bool

compatibility_tree_scheduler

Supporting modules for the compatibility tree scheduler.

compatibility_tree_scheduler.compatibility_tree

This module is the engine behind the resource allocation selection algorithm.

class concert_schedulers.compatibility_tree_scheduler.compatibility_tree.CompatibilityTree(branches)[source]

Bases: object

Stores the resource - concert client list compatibility tree with algorithms to manipulate it.

Here a branch is a resource, e.g. rocon_apps/teleop, on which leaves are the concert clients that can run that resource (i.e. compatible).

add_leaf(leaf)[source]

Just add to the first compatible branch (worry about more intelligent adding later)

Parameters:leaf (common.ConcertClient.) –
branches = None

The branches on the tree (dict like objects of {resource : clients} type.

is_valid()[source]

Checks to see if the compatibility tree is a valid tree. Note this has nothing to do with allocatability, just checks that minimum leaves are met and there are no duplicate leaves. :returns: valid or not :rtype: bool

leaves()[source]

Return a list of all the leaves (concert clients) on the tree. :returns: leaves :rtype: common.ConcertClient

remove_leaf(leaf)[source]

Just remove the first matching leaf name. Assumption is the name is unique of course (guaranteed by the conductor).

Parameters:leaf (common.ConcertClient.) –
concert_schedulers.compatibility_tree_scheduler.compatibility_tree.create_compatibility_tree(resources, concert_clients)[source]

Checks off implementation node rules and matches them to potential clients fulfilling the required conditions (platform tuple, app, optionally name)

Parameters:
  • resources
  • concert_clients (concert_msgs.ConcertClient[]) – name indexed dictionary of concert client information
Returns:

list of tuples, each of which is a node and list of clients that satisfy requirements for that node.

Return type:

CompatibilityTree

concert_schedulers.compatibility_tree_scheduler.compatibility_tree.prune_compatibility_tree(compatibility_tree, verbosity=False)[source]

Recursive function that checks rule min/max allotments and prunes the compatibility tree. It assumes none are currently fixed, so pruning can happen anywhere.

Parameters:
  • compatibility_tree (CompatibilityTree) – branches listing compatible resource - clients relationships
  • verbosity (bool) – adds some pretty printed output to screen for debugging.
Returns:

the pruned branches

Return type:

[CompatibilityBranch]

compatibility_tree_scheduler.ros_parameters

Ros parameter parsing for the scheduler.

concert_schedulers.compatibility_tree_scheduler.ros_parameters.setup_ros_parameters()[source]

Returns validated parameters for this module from the ros param server.

Returns:parameter dictionary
Rtype dict:

compatibility_tree_scheduler.scheduler

The compatibility tree scheduler node.

class concert_schedulers.compatibility_tree_scheduler.scheduler.CompatibilityTreeScheduler(concert_clients_topic_name, requests_topic_name)[source]

Bases: object

An implementation of the concert_scheduler_requests abstract Scheduler that uses the compatibility tree algorithm.

It has the following characteristics:

  • attempts to resolve the highest priority request first
  • requests are resolved singly (resolving across multiple request being quite difficult)
  • if the highest priority requests are unresolved, lower priority requests are blocked
  • compatibility tree resolution of a single request works across:
  • branches - the required resource (e.g. rocon_apps/teleop)
  • leaves - concert clients that can satisfy that resource (e.g. turtlebot_1)
  • resource allocation follows the two rules:
  • always consider leaves on the lowest count branches first.
  • always take the least visible leaf away from low count branches.
__init__(concert_clients_topic_name, requests_topic_name)[source]
Parameters:
  • concert_clients_topic_name (str) – concert client joining/leaving notifications
  • requests_topic_name (str) – incoming requests for resources topic

resource_pool_requester

Supporting modules for the resource pool requester.

resource_pool_requester.requester

The resource pool requester.

class concert_schedulers.resource_pool_requester.requester.ResourcePoolRequester(resource_groups, feedback, high_priority=10000, low_priority=-10000, uuid=None, topic='rocon_scheduler', frequency=0.25)[source]

Bases: object

A variant on the basic requester that can handle some higher level formulation and management of requests.

__init__(resource_groups, feedback, high_priority=10000, low_priority=-10000, uuid=None, topic='rocon_scheduler', frequency=0.25)[source]

Loads the requester up with a collecation of resource groups that have min/max requirements for each resource type.

Parameters:
  • resource_groups (resource_group.MinMaxResourceGroup[]) – many resource groups that will form the bases for this requester
  • feedback (func) – external feedback callback function
  • high_priority (int) – priority to set for necessary (minimum) resource requirements
  • low_priority (int) – priority to set for optional resource requirements
cancel_all_requests()[source]

Exactly as it says! Used typically when shutting down or when it’s lost more allocated resources than the minimum required (in which case it cancels everything and starts reissuing new requests).

concert_schedulers.resource_pool_requester.requester.request_completely_unallocated(request)[source]

Quick check to see if a request’s resources have been entirely lost (i.e. unallocated). This will trigger the responder to cleanup (i.e. release the request).

Parameters:request (scheduler_msgs.Request) –
Returns:true or false if entirely unallocated or not.
Return type:bool