Class Phase::Activator

Nested Relationships

This class is a nested type of Class Phase.

Class Documentation

class Activator

Public Types

template<typename Description>
using Activate = std::function<ActivePtr(const std::function<State()> &get_state, const ConstParametersPtr &parameters, ConstTagPtr tag, const Description &description, std::optional<nlohmann::json> backup_state, std::function<void(rmf_task::Phase::ConstSnapshotPtr)> update, std::function<void(Active::Backup)> checkpoint, std::function<void()> finished)>

Signature for activating a phase

Template Parameters:

Description – A class that implements the sequence::PhaseDescription interface

Param get_state:

[in] A callback for getting the current state of the robot

Param parameters:

[in] A reference to the parameters for the robot

Param tag:

[in] The tag of this phase

Param description:

[in] An immutable reference to the relevant Description instance

Param backup_state:

[in] The serialized backup state of the Phase, if the Phase is being restored from a crash or disconnection. If the Phase is not being restored, a std::nullopt will be passed in here.

Param update:

[in] A callback that will be triggered when the phase has a significant update in its status. The callback will be given a snapshot of the active phase. This snapshot can be safely read in parallel to the phase execution.

Param checkpoint:

[in] A callback that will be triggered when the phase has reached a task checkpoint whose state is worth backing up.

Param finished:

[in] A callback that will be triggered when the phase has finished.

Return:

an active, running instance of the described phase.

Public Functions

Activator()

Construct an empty Activator.

template<typename Description>
void add_activator(Activate<Description> activator)

Add a callback to convert from a PhaseDescription into an active phase.

Template Parameters:

Description – A class that implements the sequence::PhaseDescription interface

ActivePtr activate(const std::function<State()> &get_state, const ConstParametersPtr &parameters, ConstTagPtr tag, const Description &description, std::optional<nlohmann::json> backup_state, std::function<void(rmf_task::Phase::ConstSnapshotPtr)> update, std::function<void(Active::Backup)> checkpoint, std::function<void()> finished) const

Activate a phase based on a description of the phase.

Parameters:
  • get_state[in] A callback for getting the current state of the robot

  • parameters[in] A reference to the parameters for the robot

  • tag[in] The tag of this phase

  • description[in] The description of the phase

  • backup_state[in] If the phase is being restored, pass its backup state in here. Otherwise if the phase is being freshly activated, pass a nullopt.

  • update[in] A callback that will be triggered when the phase has a notable update. The callback will be given a snapshot of the active phase.

  • checkpoint[in] A callback that will be triggered when the phase has reached a task checkpoint whose state is worth backing up.

  • finished[in] A callback that will be triggered when the phase has finished.

Returns:

an active, running instance of the described phase.

template<typename Desc>
void add_activator(Activate<Desc> activator)