Class Activator¶
Defined in File Activator.hpp
Class Documentation¶
-
class
rmf_task
::
Activator
¶ A factory for generating Task::Active instances from requests.
Public Types
-
using
Activate
= std::function<Task::ActivePtr(const std::function<State()> &get_stateconst ConstParametersPtr ¶meters, const Task::ConstBookingPtr &booking, const Description &description, std::optional<std::string> backup_state, std::function<void(Phase::ConstSnapshotPtr)> update, std::function<void(Task::Active::Backup)> checkpoint, std::function<void(Phase::ConstCompletedPtr)> phase_finished, std::function<void()> task_finished)>¶ Signature for activating a task
- Return
an active, running instance of the requested task.
- Template Parameters
Description
: A class that implements the Task::Description interface
- Parameters
[in] get_state
: A callback for retrieving the current state of the robot[in] parameters
: A reference to the parameters for the robot[in] booking
: An immutable reference to the booking information for the task[in] description
: The down-casted description of the task[in] backup_state
: The serialized backup state of the Task, if the Task is being restored from a crash or disconnection. If the Task is not being restored, a std::nullopt will be passed in here.[in] update
: A callback that will be triggered when the task has a significant update in its status.[in] checkpoint
: A callback that will be triggered when the task has reached a task checkpoint whose state is worth backing up.[in] finished
: A callback that will be triggered when the task has finished.
Public Functions
-
Activator
()¶ Construct an empty TaskFactory.
-
template<typename
Description
>
voidadd_activator
(Activate<Description> activator)¶ Add a callback to convert from a Description into an active Task.
- Template Parameters
Description
: A class that implements the Request::Description interface
- Parameters
[in] activator
: A callback that activates a Task matching the Description
-
Task::ActivePtr
activate
(const std::function<State()> &get_stateconst ConstParametersPtr ¶meters, const Request &request, std::function<void(Phase::ConstSnapshotPtr)> update, std::function<void(Task::Active::Backup)> checkpoint, std::function<void(Phase::ConstCompletedPtr)> phase_finished, std::function<void()> task_finished) const¶ Activate a Task object based on a Request.
- Return
an active, running instance of the requested task.
- Parameters
[in] get_state
: A callback for retrieving the current state of the robot[in] parameters
: A reference to the parameters for the robot[in] request
: The task request[in] update
: A callback that will be triggered when the task has a significant update[in] checkpoint
: A callback that will be triggered when the task has reached a task checkpoint whose state is worth backing up.[in] phase_finished
: A callback that will be triggered whenever a task phase is finished[in] task_finished
: A callback that will be triggered when the task has finished
-
Task::ActivePtr
restore
(const std::function<State()> &get_stateconst ConstParametersPtr ¶meters, const Request &request, std::string backup_state, std::function<void(Phase::ConstSnapshotPtr)> update, std::function<void(Task::Active::Backup)> checkpoint, std::function<void(Phase::ConstCompletedPtr)> phase_finished, std::function<void()> task_finished) const¶ Restore a Task that crashed or disconnected.
- Return
an active, running instance of the requested task.
- Parameters
[in] get_state
: A callback for retrieving the current state of the robot[in] parameters
: A reference to the parameters for the robot[in] request
: The task request[in] backup_state
: The serialized backup state of the Task[in] update
: A callback that will be triggered when the task has a significant update[in] checkpoint
: A callback that will be triggered when the task has reached a task checkpoint whose state is worth backing up.[in] phase_finished
: A callback that will be triggered whenever a task phase is finished[in] task_finished
: A callback that will be triggered when the task has finished
-
using