Class Task

Nested Relationships

Nested Types

Class Documentation

class Task

Pure abstract interface for an executable Task.

Public Types

using ConstBookingPtr = std::shared_ptr<const Booking>
using ConstTagPtr = std::shared_ptr<const Tag>
using ConstModelPtr = std::shared_ptr<const Model>
using ConstDescriptionPtr = std::shared_ptr<const Description>
using ActivePtr = std::shared_ptr<Active>
class Active

Public Types

using Backup = detail::Backup

Backup data for the task. The state of the task is represented by a string. The meaning and format of the string is up to the Task implementation to decide.

Each Backup is tagged with a sequence number. As the Task makes progress, it can issue new Backups with higher sequence numbers. Only the Backup with the highest sequence number will be kept.

using Resume = detail::Resume

The Resume class keeps track of when the Task is allowed to Resume. You can either call the Resume object’s operator() or let the object expire to tell the Task that it may resume.

Public Functions

virtual Event::Status status_overview() const = 0

Get a quick overview status of how the task is going.

virtual bool finished() const = 0

Check if this task is finished, which could include successful completion or cancellation.

virtual const std::vector<Phase::ConstCompletedPtr> &completed_phases() const = 0

Descriptions of the phases that have been completed.

virtual Phase::ConstActivePtr active_phase() const = 0

Interface for the phase that is currently active.

virtual std::optional<rmf_traffic::Time> active_phase_start_time() const = 0

Time that the current active phase started.

virtual const std::vector<Phase::Pending> &pending_phases() const = 0

Descriptions of the phases that are expected in the future.

virtual const ConstTagPtr &tag() const = 0

The tag of this Task.

virtual rmf_traffic::Duration estimate_remaining_time() const = 0

Estimate the overall finishing time of the task.

virtual Backup backup() const = 0

Get a backup for this Task.

virtual Resume interrupt(std::function<void()> task_is_interrupted) = 0

Tell this Task that it needs to be interrupted. An interruption means the robot may be commanded to do other tasks before this task resumes.

Interruptions may occur to allow operators to take manual control of the robot, or to engage automatic behaviors in response to emergencies, e.g. fire alarms or code blues.

Parameters:

task_is_interrupted[in] This callback will be triggered when the Task has reached a state where it is okay to start issuing other commands to the robot.

Returns:

an object to inform the Task when it is allowed to resume.

virtual void cancel() = 0

Tell the Task that it has been canceled. The behavior that follows a cancellation will vary between different Tasks, but generally it means that the robot should no longer try to complete its Task and should instead try to return itself to an unencumbered state as quickly as possible.

The Task may continue to perform some phases after being canceled. The pending_phases are likely to change after the Task is canceled, being replaced with phases that will help to relieve the robot so it can return to an unencumbered state.

The Task should continue to be tracked as normal. When its finished callback is triggered, the cancellation is complete.

virtual void kill() = 0

Kill this Task. The behavior that follows a kill will vary between different Tasks, but generally it means that the robot should be returned to a safe idle state as soon as possible, even if it remains encumbered by something related to this Task.

The Task should continue to be tracked as normal. When its finished callback is triggered, the killing is complete.

The kill() command supersedes the cancel() command. Calling cancel() after calling kill() will have no effect.

virtual void skip(uint64_t phase_id, bool value = true) = 0

Skip a specific phase within the task. This can be issued by operators if manual intervention is needed to unblock a task.

If a pending phase is specified, that phase will be skipped when the Task reaches it.

Parameters:
  • phase_id[in] The ID of the phase that should be skipped.

  • value[in] True if the phase should be skipped, false otherwise.

virtual void rewind(uint64_t phase_id) = 0

Rewind the Task to a specific phase. This can be issued by operators if a phase did not actually go as intended and needs to be repeated.

It is possible that the Task will rewind further back than the specified phase_id if the specified phase depends on an earlier one. This is up to the discretion of the Task implementation.

virtual ~Active() = default

Protected Static Functions

static Resume make_resumer(std::function<void()> callback)

Used by classes that inherit the Task interface to create a Resumer object

Parameters:

callback[in] Provide the callback that should be triggered when the Task is allowed to resume

class Booking

Basic information about how the task was booked, e.g. what its name is, when it should start, and what its priority is.

Public Functions

Booking(std::string id, rmf_traffic::Time earliest_start_time, ConstPriorityPtr priority, bool automatic = false, const std::vector<std::string> &labels = {})

Constructor

Parameters:
  • id[in] The identity of the booking

  • earliest_start_time[in] The earliest time that the task may begin

  • priority[in] The priority of the booking

  • automatic[in] Whether this booking was automatically generated

  • labels[in] Labels to describe the purpose of the task dispatch request.

Booking(std::string id, rmf_traffic::Time earliest_start_time, ConstPriorityPtr priority, const std::string &requester, rmf_traffic::Time request_time, bool automatic = false, const std::vector<std::string> &labels = {})

Constructor

Parameters:
  • id[in] The identity of the booking.

  • earliest_start_time[in] The earliest time that the task may begin.

  • priority[in] The priority of the booking.

  • requester[in] The identifier of the entity that requested this task.

  • request_time[in] The time that this task was booked.

  • automatic[in] Whether this booking was automatically generated, default value as false.

  • labels[in] Labels to describe the purpose of the task dispatch request.

const std::string &id() const

The unique id for this booking.

rmf_traffic::Time earliest_start_time() const

Get the earliest time that this booking may begin.

ConstPriorityPtr priority() const

Get the priority of this booking.

std::optional<std::string> requester() const

Get the identifier of the entity that requested this booking. Returns a nullopt if no requester was defined.

std::optional<rmf_traffic::Time> request_time() const

Get the time that this booking was requested. Returns a nullopt if no request time was defined.

bool automatic() const
std::vector<std::string> labels() const

Get the labels that describe the purpose of the task dispatch request.

class Description

An abstract interface to define the specifics of this task. This implemented description will differentiate this task from others.

Subclassed by rmf_task::requests::ChargeBattery::Description, rmf_task::requests::Clean::Description, rmf_task::requests::Delivery::Description, rmf_task::requests::Loop::Description

Public Functions

virtual ConstModelPtr make_model(rmf_traffic::Time earliest_start_time, const Parameters &parameters) const = 0

Generate a Model for the task based on the unique traits of this description

Parameters:
  • earliest_start_time[in] The earliest time this task should begin execution. This is usually the requested start time for the task.

  • parameters[in] The parameters that describe this AGV

virtual Info generate_info(const State &initial_state, const Parameters &parameters) const = 0

Generate a plain text info description for the task, given the predicted initial state and the task planning parameters.

Parameters:
  • initial_state[in] The predicted initial state for the task

  • parameters[in] The task planning parameters

virtual ~Description() = default
struct Info

Public Members

std::string category
std::string detail
class Model

An abstract interface for computing the estimate and invariant durations of this request

Public Functions

virtual std::optional<Estimate> estimate_finish(const State &initial_state, const Constraints &task_planning_constraints, const TravelEstimator &travel_estimator) const = 0

Estimate the state of the robot when the task is finished along with the time the robot has to wait before commencing the task

virtual rmf_traffic::Duration invariant_duration() const = 0

Estimate the invariant component of the task’s duration.

virtual ~Model() = default
class Tag

Basic static information about the task.

Public Functions

Tag(ConstBookingPtr booking_, Header header_)

Constructor.

const ConstBookingPtr &booking() const

The booking information of the request that this Task is carrying out.

const Header &header() const

The header for this Task.