C++ YASMIN (Yet Another State MachINe)
Loading...
Searching...
No Matches
DelayedStartStateMachine Class Reference

Small helper state machine that delays its start. More...

Inheritance diagram for DelayedStartStateMachine:
Collaboration diagram for DelayedStartStateMachine:

Public Member Functions

 DelayedStartStateMachine (std::chrono::milliseconds start_delay)
std::string execute (yasmin::Blackboard::SharedPtr blackboard) override
 Executes the state's specific logic.
Public Member Functions inherited from yasmin::StateMachine
 StateMachine (const Outcomes &outcomes, bool handle_sigint=false)
 Shared pointer type for StateMachine.
 StateMachine (const std::string &name, const Outcomes &outcomes, bool handle_sigint=false)
 Construct a new StateMachine object.
 ~StateMachine ()
 Destroy the StateMachine object.
void add_state (const std::string &name, State::SharedPtr state, const Transitions &transitions={}, const Remappings &remappings={}, const ParameterMappings &parameter_mappings={})
 Adds a state to the state machine with specified transitions.
void set_name (const std::string &name)
 Sets the name of the state machine.
const std::string & get_name () const noexcept
 Gets the name of the state machine.
void set_start_state (const std::string &state_name)
 Sets the start state for the state machine.
std::string const & get_start_state () const noexcept
 Retrieves the name of the start state.
StateMap const & get_states () const noexcept
 Gets a constant reference to the map of states.
TransitionsMap const & get_transitions () const noexcept
 Gets a constant reference to the map of transitions.
std::string const & get_current_state () const
 Retrieves the current state name.
void add_start_cb (StartCallbackType cb)
 Adds a callback function to be called when the state machine starts.
void add_transition_cb (TransitionCallbackType cb)
 Adds a callback function for state transitions.
void add_end_cb (EndCallbackType cb)
 Adds a callback function to be called when the state machine ends.
void set_parameter_mappings (const std::string &state_name, const ParameterMappings &parameter_mappings)
 Sets parameter mappings for a child state.
const ParameterMappingsMap & get_parameter_mappings () const noexcept
 Gets all parameter mappings.
void validate (bool strict_mode=false)
 Validates the state machine configuration.
void configure () override
 Executes the state machine.
std::string execute (Blackboard::SharedPtr blackboard) override
 Executes the state's specific logic.
std::string execute ()
 Executes the state machine using a default blackboard.
std::string operator() ()
 Invokes the state machine using a default blackboard.
void cancel_state () override
 Cancels the currently active child state.
void cancel_state_machine ()
 Cancels the complete state machine execution.
void set_sigint_handler (bool handle=true)
 Sets whether the state machine should handle SIGINT for cancel.
std::string to_string () const override
 Converts the state machine to a string representation.
std::string operator() (Blackboard::SharedPtr blackboard)
 Executes the state and returns the outcome.
Public Member Functions inherited from yasmin::State
 State (const Outcomes &outcomes)
 Shared pointer type for State.
virtual ~State ()
 Virtual destructor.
Blackboard::SharedPtr get_parameters_blackboard () const
 Gets the private parameter blackboard of this state.
bool is_idle () const noexcept
 Checks if the state is idle.
bool is_running () const noexcept
 Checks if the state is currently running.
bool is_canceled () const noexcept
 Checks if the state has been canceled.
bool is_completed () const noexcept
 Checks if the state has completed execution.
std::string operator() (Blackboard::SharedPtr blackboard)
 Executes the state and returns the outcome.
Outcomes const & get_outcomes () const noexcept
 Gets the set of possible outcomes for this state.
void set_description (const std::string &description)
 Sets the description for this state.
const std::string & get_description () const
 Gets the description of this state.
void set_outcome_description (const std::string &outcome, const std::string &description)
 Sets a human-readable description for an outcome.
const std::string & get_outcome_description (const std::string &outcome) const
 Gets the human-readable description for an outcome.
const std::unordered_map< std::string, std::string > & get_outcome_descriptions () const
 Gets all outcome descriptions.
void add_input_key (const BlackboardKeyInfo &key_info)
 Adds an input key to the state's metadata.
void add_input_key (const std::string &key_name)
 Adds an input key with a name only.
void add_input_key (const std::string &key_name, const std::string &description)
 Adds an input key with a name and description.
template<typename T>
void add_input_key (const std::string &key_name, const std::string &description, T default_value)
 Adds an input key with a name, default value and description.
void add_output_key (const BlackboardKeyInfo &key_info)
 Adds an output key to the state's metadata.
void add_output_key (const std::string &key_name)
 Adds an output key with a name only.
void add_output_key (const std::string &key_name, const std::string &description)
 Adds an output key with a name and description.
const std::vector< BlackboardKeyInfo > & get_input_keys () const
 Gets the input keys metadata.
const std::vector< BlackboardKeyInfo > & get_output_keys () const
 Gets the output keys metadata.
void declare_parameter (const BlackboardKeyInfo &parameter_info)
 Declares a parameter in the state metadata.
void declare_parameter (const std::string &parameter_name)
 Declares a parameter with a name only.
void declare_parameter (const std::string &parameter_name, const std::string &description)
 Declares a parameter with a name and description.
template<typename T>
void declare_parameter (const std::string &parameter_name, const std::string &description, T default_value)
 Declares a parameter with a name, description, and default value.
bool has_parameter (const std::string &parameter_name) const
 Checks if a parameter exists in the state-local parameter storage.
template<typename T>
T get_parameter (const std::string &parameter_name) const
 Gets a parameter from the state-local parameter storage.
template<typename T>
void set_parameter (const std::string &parameter_name, T value)
 Sets a parameter in the state-local parameter storage.
bool is_parameter_declared (const std::string &parameter_name) const
 Checks whether a parameter was declared in the state metadata.
void copy_parameter_from (const State &source_state, const std::string &source_parameter_name, const std::string &target_parameter_name)
 Copies a parameter value from another state.
const std::vector< BlackboardKeyInfo > & get_parameters () const
 Gets the declared parameter metadata.
const StateMetadata & get_metadata () const
 Gets the complete state metadata.

Private Attributes

std::chrono::milliseconds start_delay

Additional Inherited Members

Public Types inherited from yasmin::StateMachine
using StartCallbackType
 Alias for a callback function executed before running the state machine.
using TransitionCallbackType
 Alias for a callback function executed before changing the state.
using EndCallbackType
 Alias for a callback function executed after running the state machine.
Protected Attributes inherited from yasmin::State
Outcomes outcomes
 The possible outcomes of this state.

Detailed Description

Small helper state machine that delays its start.

The delay makes the scheduling of the two concurrent branches less symmetric, which helps to reproduce bugs caused by shared remapping state.

Constructor & Destructor Documentation

◆ DelayedStartStateMachine()

DelayedStartStateMachine::DelayedStartStateMachine ( std::chrono::milliseconds start_delay)
inlineexplicit

Member Function Documentation

◆ execute()

std::string DelayedStartStateMachine::execute ( yasmin::Blackboard::SharedPtr blackboard)
inlineoverridevirtual

Executes the state's specific logic.

Parameters
blackboardA shared pointer to the Blackboard to use during execution.
Returns
A string representing the outcome of the execution.

This method is intended to be overridden by derived classes to provide specific execution logic.

Reimplemented from yasmin::State.

Member Data Documentation

◆ start_delay

std::chrono::milliseconds DelayedStartStateMachine::start_delay
private

The documentation for this class was generated from the following file: