JobManager package

The JobManager package contains the Python Modules as used by the Job Manager ROS node: Each Module with its functions is described in more detail below.

JobManager.ClosestMex module

The ClosestMex module is used to determine the which Mobile Executor is closest to a given move or transport order location. First it will retrieve an up-to-date MEx list and filter on their status, leaving only those with the STANDBY status. Next, for each suitable (STANDBY) MEx, it waits for the amcl_pose message (location) of that MEx and then plans the route from which it will calculate the length of the path. The result is apended to a distances list as a Distance instance with the accompanying MEx ID. After all path length distances have been retrieved, it will loop over all Distance class instances in the list and find the closest MEx, which is then returns as a tuple of closest MEx ID and distance.

class JobManager.ClosestMex.Distance(mex_id, distance)[source]

Distance class, containing Mobile Executor (MEx) ID and distance attributes. Instances from this class are added to the list where we choose the closest MEx to a location.

JobManager.ClosestMex.calculate_euclidian_distance(plan)[source]

Method to calculate Euclidian destance for each pair of poses from the MEx path. Loops over each pair and sums up the calculated Euclidian distances for a total path length. Returns path length.

JobManager.ClosestMex.call_get_mex_list()[source]

Function for retrieving the list of all MExs from the service provided by mex_sentinel node.

JobManager.ClosestMex.choose_closest_mex(location)[source]

The main method which call all other method in this module.

  1. Retrieve up-to-date MEx list and filter on their status (STANDBY is required).
  2. For each suitable MEx, Waits for the amcl_pose message (location) of that MEx, plans the route and calculates path length. Adding the result as a Distance instance.
  3. Loops over all Distance class instances in the list and finds the closest MEx.

Returns a tuple of closest MEx ID and distance.

JobManager.ClosestMex.get_plan(x_start, y_start, x_finish, y_finish, mex_id)[source]

Function to calculate path to a location using (!) /move_base/make_plan on a certain MEx. For this function to function, the specific MEx must have the move_base package running. Returns a move_base/make_plan plan.

JobManager.Job module

The Job module is used by the Job Manager ROS node. It contains the definitions of the Job Status and Job Priority enumerators as well as the Job class.

class JobManager.Job.Job(job_id, completion_cb, keyword, mex_id=None, priority=<JobPriority.LOW: 1>)[source]

Class which contains overall job details and a list of job-tasks for individual jobs.

add_task(task)[source]

Add a single task to the job’s task list and update task count.

add_tasks(list_of_tasks)[source]

Add a multiple tasks from a list to the job’s task list and update task count.

assign_mex(mex_id)[source]

Assign a mex_id to this job, if status is either pending or assigned.

info()[source]

Prints general Job information to the console.

next_task()[source]

Start executing the next task in the job’s task_list, if the status is still ACTIVE.

start_job()[source]

Start executing the first task in the job’s task_list if the status is ASSIGNED.

task_cb(data)[source]

Callback method for the tasks in the job’s task list to call upon completion/cancellation/abort.

class JobManager.Job.JobPriority[source]

Bases: enum.Enum

Class that acts as Enumerator for Job Priority levels.

CRITICAL = 4
HIGH = 3
LOW = 1
MEDIUM = 2
class JobManager.Job.JobStatus[source]

Bases: enum.Enum

Class that acts as Enumerator for Job status.

ABORTED = 4
ACTIVE = 2
ASSIGNED = 1
PENDING = 0
SUCCEEDED = 3

JobManager.JobActivation module

The Job Activation module consist of two functions, the Job Allocator and Job Refiner. The Job Allocator checks the Pending Jobs list and MExs list to assign a Job to a MEx. If the Job involves locomotion, such as MOVE and TRANSPORT Jobs, it will use the ClosestMEx module to retrieve the closest MEx instead. If a Job could be assigned, it is removed from the Pending Jobs list and passed along to the Job Refiner and a call is send to the MEx Sentinel service to update the allocated MEx’s state. The Job Refiner takes in the (rough) Job and further refines it based on the allocated MEx. It then starts the Job and calls the MEx Sentinel service to update the MEx state once more. Finally the Job is appended to the Active Jobs list.

JobManager.JobActivation.job_allocator(pending_jobs_list, active_jobs_list, mexs_list)[source]

Job Allocator function. Check Pending Jobs list and MExs list to assign a Job to a MEx.

Loops through the Pending Jobs list, finds the first pending Job and matches it with an available MEx (Up to date mex_list retrieved from MEx Sentinel service). If succesful, it removes this Job from the Pending Jobs list and passes it along to the Job Refiner, sends an update to the MEx Sentinel to update the allocated MEx state. If unsuccesful it returns None. Should be called/triggered whenever a change is made to either list.

JobManager.JobActivation.job_refiner(active_jobs_list, mexs_list, rough_job)[source]

Job Refiner function. Takes in a rough job and based on the allocated MEx refines the Jobs Tasks to match MEx attributes. Starts the Job, sends update to the MEx Sentinel to update the MEx state and then adds the refined Job to the Active Jobs list.

JobManager.JobBuilder module

The Job Builder module is used by the Job Manager ROS node and contains the job_builder function. This function takes in orders from the order list and builds Job class instances with Task class instances based on the order type and attributes. It then appends these Job instances to the Pending Jobs list.

JobManager.JobBuilder.job_builder(pending_jobs_list, order, job_index, location_dict, completion_cb)[source]

Job Builder Takes in order consisting of: keyword, priority and arguments; and creates a Job class instance containing Task class instances depening on the keyword and arguments. Then inserts/appends the Job to the Pending Jobs list depening on the priority.

JobManager.JobServiceMethods module

The Job Service Methods module contains the functions used by the Job Manager to call the services as hosted by the MEx Sentinel. It contains functions for calling the following services:

  • get_mex_list
  • assign_job_to_mex
  • unassign_job_from_mex
  • change_mex_status
JobManager.JobServiceMethods.call_assign_job(job_id, mex_id)[source]

Function to send an update to the MEx Sentinel to assign a Job to an MEx.

JobManager.JobServiceMethods.call_change_mex_status(mex_id, status)[source]

Function to send an update to the MEx Sentinel to update an MEx’s status.

JobManager.JobServiceMethods.call_get_mex_list()[source]

Function to get most recent list of all MEx from service provided by mex_sentinel node.

JobManager.JobServiceMethods.call_unassign_job(mex_id)[source]

Function to send an update to the MEx Sentinel to unassign a MEx, no matter what the Job is.

JobManager.Location module

The Location module is used by the Job Manager ROS node as a means to store the information for each location in a Location class instance. Each Location instance has an unique ID, name, position and orientation.

class JobManager.Location.Location(id, name, x_coordinate, y_coordinate, theta)[source]

Class with location information (name, position, orientation) based on map reference frame.

info()[source]

Method which prints out general Location information to the console.

JobManager.Location.make_location_dict()[source]

Function to read locations info from ROS parameter server and turn them into a dictionary.

JobManager.MobileExecutor module

The MobileExecutor module is used by the Job Manager and MEx Sentinel ROS nodes to store information on Mobile Executors (MExs) in MobileExecutor class instances. Each instance has an unique MEx ID, MEx Status and Job ID. Additionally, the MEx Status class is defined in this module as an enumerator.

class JobManager.MobileExecutor.MExStatus[source]

Bases: enum.Enum

Class that acts as Enumerator for Mobile Executor (MEx) status.

ASSIGNED = 2
CHARGING = 1
ERROR = 4
EXECUTING_TASK = 3
STANDBY = 0
class JobManager.MobileExecutor.MobileExecutor(id, status=<MExStatus.STANDBY: 0>, job_id=None)[source]

Class with Mobile Executor (MEx) information (MEx id, status, assigned job id)

mex_info()[source]

Method which returns the general information of this MEx in string format.

JobManager.Order module

The Order module contains definitions for several enumerator types; the Order Response status, the Order keyword and the Order argument count.

Note: The ‘FOLLOW’ OrderKeyword and OrderTypeArgCount are not actively implemented.

class JobManager.Order.OrderKeyword[source]

Bases: enum.Enum

Class that acts as Enumerator for Order keywords.

FOLLOW = 2
LOAD = 3
MOVE = 1
TRANSPORT = 0
UNLOAD = 4
class JobManager.Order.OrderResponseStatus[source]

Bases: enum.Enum

Class that acts as Enumerator for Order Response status.

ERROR = 1
SUCCES = 0
class JobManager.Order.OrderTypeArgCount[source]

Bases: enum.Enum

Class that acts as Constants for Order types and the number of arguments associated with them.

FOLLOW = 1
LOAD = 0
MOVE = 1
TRANSPORT = 2
UNLOAD = 0

JobManager.Tasks module

The Tasks module is used by the Job Manager ROS node and Job module to store information and status of Tasks as class instances. Each Task has its own class, which inherits from a base Task class. For more information on each class see the descriptions below. Next to the Task classes the module also contains class definitions for the Task Type and Task Status enumerators.

class JobManager.Tasks.AwaitingLoadCompletion[source]

Bases: JobManager.Tasks.Task

Task class: AwaitingLoadCompletion, waits for input from user or system to mark loading of the MEx as succeeded, cancelled, aborted. Used by the higher level Job class to populate a list with its job tasks.

child_start()[source]

Start the task’s specific action, subscribing to the /LoadInput topic on the MEx’s namespace.

input_cb(data)[source]

Callback method for any user or system input. Updates the instance status and calls the higher level job_callback. load status option: PENDING=0 ACTIVE=1, CANCELLED=2, SUCCEEDED=3, ABORTED=4.

class JobManager.Tasks.AwaitingUnloadCompletion[source]

Bases: JobManager.Tasks.AwaitingLoadCompletion

Task class: AwaitingUnloadCompletion, waits for input from user or system to mark unloading of the MEx as succeeded, cancelled, aborted. Used by the higher level Job class to populate a list with its job tasks. Inherets from AwaitingLoadCompletion.

child_start()[source]

Start the task’s specific action, subscribing to the /UnloadInput topic on the MEx’s namespace.

class JobManager.Tasks.RobotMoveBase(location)[source]

Bases: JobManager.Tasks.Task

Task class: RobotMoveBase, implements move_base action calls to robot navigation stack. Used by the higher level Job class to populate a list with its job tasks.

active_cb()[source]

Callback for starting move_base action. Connected to actionlib send_goal call.

done_cb(status, result)[source]

Callback for stopping of goal. Connected to actionlib send_goal call. move_base callback status options: PENDING=0, ACTIVE=1, PREEMPTED=2, SUCCEEDED=3, ABORTED=4, REJECTED=5, PREEMPTING=6, RECALLING=7, RECALLED=8, LOST=9.

feedback_cb(feedback)[source]

Callback for continuous feedback of move_base position. Connected to actionlib send_goal call.

get_status()[source]

Overwrites base class get_status, but inherits using super(). Retrieve the status of the move_base action.

move_robot()[source]

Start a move_base action using actionlib.

class JobManager.Tasks.Task(tasktype, child_start)[source]

Bases: object

Base class from which specific child task classes inherit.

get_status()[source]

Return the status of the task.

start(mex_id, task_id, job_callback)[source]

Start the task’s specific action. All job tasks should have this method (through inheritance): ‘start’, with these arguments: ‘self’, ‘mex_id’, ‘task_id’, ‘job_callback’.

class JobManager.Tasks.TaskStatus[source]

Bases: enum.Enum

Class that acts as Enumerator for Task status.

ABORTED = 4
ACTIVE = 1
CANCELLED = 2
PENDING = 0
SUCCEEDED = 3
class JobManager.Tasks.TaskType[source]

Bases: enum.Enum

Class that acts as an enum for the different kinds of tasks.

AWAITINGLOADCOMPLETION = 1
AWAITINGUNLOADCOMPLETION = 2
ROBOTMOVEBASE = 0