Class Event
Defined in File Event.hpp
Nested Relationships
Nested Types
Inheritance Relationships
Base Type
public rmf_task::Event
Derived Type
public rmf_task_sequence::events::Bundle
(Class Bundle)
Class Documentation
-
class Event : public rmf_task::Event
Subclassed by rmf_task_sequence::events::Bundle
Public Types
-
using Description = Activity::Description
-
using ConstDescriptionPtr = std::shared_ptr<const Description>
-
using InitializerPtr = std::shared_ptr<Initializer>
-
using ConstInitializerPtr = std::shared_ptr<const Initializer>
-
class Active : public rmf_task_sequence::Activity::Active
Public Functions
-
virtual ConstStatePtr state() const = 0
Get the state of this event. The state object returned by this function must always be the same state object, and it must remain the same state object that would have been provided by the Event::Standby that kicked off this Event::Active.
-
virtual rmf_traffic::Duration remaining_time_estimate() const = 0
Estimate how much longer this event will take to complete.
-
virtual ~Active() = default
-
virtual ConstStatePtr state() const = 0
-
class Initializer
The Event::Initializer class is the Event equivalent to the rmf_task::Activator class. It consumes an Event::Description and produces
Public Types
-
template<typename Description>
using Initialize = std::function<StandbyPtr(const AssignIDPtr &id, const std::function<rmf_task::State()> &get_state, const ConstParametersPtr ¶meters, const Description &description, std::function<void()> update)> Signature for initializing an Event
Warning
The update function must not be triggered during initialization because upstream event handlers will not be ready to handle it. The event state will always be checked right after initialization is finished anyway, so there is no need to trigger this.
- Template Parameters:
Description – A class that implements the Event::Description interface
- Param id:
[in] An object to help assign an ID to each event
- Param get_state:
[in] A callback for retrieving the current state of the robot
- Param parameters:
[in] A reference to the parameters for the robot
- Param description:
[in] The down-casted description of the event
- Param backup_state:
[in] The serialized backup state of the Event, if the Event is being restored from a crash or disconnection. If the Event is not being restored, a std::nullopt will be passed in here.
- Param update:
[in] A callback that will be triggered when a notable change happens for this event.
- Return:
-
template<typename Description>
using Restore = std::function<ActivePtr(const AssignIDPtr &id, const std::function<rmf_task::State()> &get_state, const ConstParametersPtr ¶meters, const Description &description, const nlohmann::json &backup_state, std::function<void()> update, std::function<void()> checkpoint, std::function<void()> finished)> Signature for restoring an Event
Warning
The update function must not be triggered during initialization because upstream event handlers will not be ready to handle it. The event state will always be checked right after initialization is finished anyway, so there is no need to trigger this.
- Template Parameters:
Description – A class that implements the Event::Description interface
- Param id:
[in] An object to help assign an ID to each event
- Param get_state:
[in] A callback for retrieving the current state of the robot
- Param parameters:
[in] A reference to the parameters for the robot
- Param description:
[in] The down-casted description of the event
- Param backup_state:
[in] The backup state of the Event.
- Param update:
[in] A callback that will be triggered when a notable change happens for this event.
- Param checkpoint:
[in] A callback that will be triggered when the event reaches a “checkpoint” meaning that the task state should be backed up.
- Param finished:
[in] A callback that will be triggered when the event reaches a Finished state
- Return:
Public Functions
-
Initializer()
Construct an empty Initializer.
-
template<typename Desc>
void add(Initialize<Desc> initializer, Restore<Desc> restorer) Add a callback to convert from a Description to an event in standby mode.
-
StandbyPtr initialize(const AssignIDPtr &id, const std::function<rmf_task::State()> &get_state, const ConstParametersPtr ¶meters, const Event::Description &description, std::function<void()> update) const
Initialize an event
Warning
The update function must not be triggered during initialization because upstream event handlers will not be ready to handle it. The event state will always be checked right after initialization is finished anyway, so there is no need to trigger this.
- Parameters:
id – [in] An object to help assign an ID to each event
get_state – [in] A callback for retrieving the current state of the robot
parameters – [in] A reference to the parameters for the robot
description – [in] The description of the event
update – [in] A callback that will be triggered when a notable change happens for this event.
- Returns:
-
ActivePtr restore(const AssignIDPtr &id, const std::function<rmf_task::State()> &get_state, const ConstParametersPtr ¶meters, const Event::Description &description, const nlohmann::json &backup, std::function<void()> update, std::function<void()> checkpoint, std::function<void()> finished) const
Signature for restoring an Event
Warning
The update function must not be triggered during initialization because upstream event handlers will not be ready to handle it. The event state will always be checked right after initialization is finished anyway, so there is no need to trigger this.
- Parameters:
id – [in] An object to help assign an ID to each event
get_state – [in] A callback for retrieving the current state of the robot
parameters – [in] A reference to the parameters for the robot
description – [in] The down-casted description of the event
backup_state – [in] The backup state of the Event.
update – [in] A callback that will be triggered when a notable change happens for this event.
checkpoint – [in] A callback that will be triggered when the event reaches a “checkpoint” meaning that the task state should be backed up.
finished – [in] A callback that will be triggered when the event reaches a Finished state
- Returns:
-
template<typename Description>
-
class Standby
The interface of an event that is in a standby mode. This interface is what will be provided by the Event::Initializer. When the right conditions are met for the event to begin, the owner of the event should trigger the begin() function.
Public Functions
-
virtual ConstStatePtr state() const = 0
Get the state of this event. The state object returned by this function must always be the same state object, and it must remain the relevant state object for this Event after begin(~) has been called.
-
virtual rmf_traffic::Duration duration_estimate() const = 0
Estimate how long this event will take once it has started.
-
virtual ActivePtr begin(std::function<void()> checkpoint, std::function<void()> finished) = 0
Tell this event to begin. This function should be implemented to always return the same Event::Active instance if it gets called more than once.
- Parameters:
checkpoint – [in] A callback that will be triggered when the event reaches a “checkpoint” meaning that the task state should be backed up.
finished – [in] A callback that will be triggered when the event reaches a Finished state
-
virtual ~Standby() = default
-
virtual ConstStatePtr state() const = 0
-
using Description = Activity::Description