Class Phase

Nested Relationships

Nested Types

Inheritance Relationships

Base Type

  • public rmf_task::Phase

Derived Type

Class Documentation

class Phase : public rmf_task::Phase

A factory for generating execute::ActivePhase instances from descriptions.

Subclassed by rmf_task_sequence::phases::SimplePhase

Public Types

using ActivePtr = std::shared_ptr<Active>
using ActivatorPtr = std::shared_ptr<Activator>
using ConstActivatorPtr = std::shared_ptr<const Activator>
using ConstDescriptionPtr = std::shared_ptr<const Description>
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)
class Active : public rmf_task::Phase::Active, public rmf_task_sequence::Activity::Active

The interface for an Active phase within a phase sequence task.

class Description : public rmf_task_sequence::Activity::Description

Subclassed by rmf_task_sequence::phases::SimplePhase::Description