Drake
Event< T > Class Template Referenceabstract

Abstract base class that represents an event. More...

#include <drake/systems/framework/event.h>

Inheritance diagram for Event< T >:
[legend]

Classes

struct  PeriodicAttribute
 A token describing an event that recurs on a fixed period. More...
 

Public Types

enum  TriggerType {
  kUnknown, kForced, kTimed, kPeriodic,
  kPerStep, kWitness
}
 Predefined types of triggers. More...
 

Public Member Functions

void operator= (const Event &)=delete
 
 Event (Event &&)=delete
 
void operator= (Event &&)=delete
 
virtual ~Event ()
 
std::unique_ptr< EventClone () const
 Clones this instance. More...
 
TriggerType get_trigger_type () const
 Returns the trigger type. More...
 
bool has_attribute () const
 Returns true if this event has an associated attribute. More...
 
const AbstractValueget_attribute () const
 Returns a const pointer to the AbstractValue attribute. More...
 
template<typename DataType >
const DataType & get_attribute () const
 Returns a const reference to the underlying attribute. More...
 
void set_attribute (std::unique_ptr< AbstractValue > attribute)
 Sets and transfers the ownership of attribute. More...
 
virtual void add_to_composite (CompositeEventCollection< T > *events) const =0
 Adds this event to the event collection events. More...
 

Protected Member Functions

 Event (const Event &other)
 
 Event (const TriggerType &trigger)
 Constructs an Event with the specified trigger. More...
 
virtual EventDoClone () const =0
 Derived classes must implement this method to clone themselves. More...
 

Detailed Description

template<typename T>
class drake::systems::Event< T >

Abstract base class that represents an event.

The base event contains two main pieces of information: an enum trigger type and an optional attribute of AbstractValue that can be used to explain why the event is triggered. Derived classes should contain a function pointer to an optional callback function that handles the event. No-op is the default handling behavior. Currently, the System framework only supports three concrete event types: PublishEvent, DiscreteEvent and UnrestrictedUpdateEvent distinguished by their callback functions' access level to the context.

Member Enumeration Documentation

enum TriggerType
strong

Predefined types of triggers.

Used at run time to determine why the associated event has occurred.

Enumerator
kUnknown 
kForced 

This trigger indicates that an associated event is triggered by directly calling the corresponding public system API for event handling (e.g.

Publish(context)).

kTimed 

This trigger indicates that an associated event is triggered by the system proceeding to a single, arbitrary time.

Timed events are commonly created in System::CalcNextUpdateTime().

kPeriodic 

This type indicates that an associated event is triggered by the system proceeding to a time t ∈ {tᵢ = t₀ + p * i} for some period p, time offset t₀, and i is a non-negative integer.

See also
PeriodicAttribute. Periodic events are commonly created in System::CalcNextUpdateTime().
kPerStep 

This trigger indicates that an associated event is triggered whenever a solver takes a step.

A solver is an abstract construct that controls the time and state evolution of a System. For example, a simulator is a solver. Its step advances time a finite duration by integrating a system, modifying its state accordingly. Per-step events are most commonly created in System::GetPerStepEvents(). A very common use of such per-step events is to update a discrete or abstract state variable that changes whenever the continuous state advances; examples are computing the "min" or "max" of some state variable, recording a signal in a delay buffer, or publishing. Per-step events are also useful to implement feedback controllers interfaced with physical devices; the controller can be implemented in the event handler, and the "step" would correspond to receiving sensory data from the hardware.

kWitness 

This trigger indicates that an associated event is triggered by the zero crossing of a witness function.

Witness events are commonly created by WitnessFunction::AddEvent().

Constructor & Destructor Documentation

Event ( Event< T > &&  )
delete
virtual ~Event ( )
inlinevirtual
Event ( const Event< T > &  other)
inlineprotected

Here is the call graph for this function:

Event ( const TriggerType trigger)
inlineexplicitprotected

Constructs an Event with the specified trigger.

Here is the call graph for this function:

Member Function Documentation

virtual void add_to_composite ( CompositeEventCollection< T > *  events) const
pure virtual

Adds this event to the event collection events.

See derived implementations for more details.

Implemented in UnrestrictedUpdateEvent< T >, DiscreteUpdateEvent< T >, and PublishEvent< T >.

Here is the caller graph for this function:

std::unique_ptr<Event> Clone ( ) const
inline

Clones this instance.

Here is the call graph for this function:

virtual Event* DoClone ( ) const
protectedpure virtual

Derived classes must implement this method to clone themselves.

Any Event-specific data is cloned using the Clone() method. Data specific to the class derived from Event must be cloned by the implementation.

Here is the caller graph for this function:

const AbstractValue* get_attribute ( ) const
inline

Returns a const pointer to the AbstractValue attribute.

The returned value can be nullptr, which means this event does not have an associated attribute.

const DataType& get_attribute ( ) const
inline

Returns a const reference to the underlying attribute.

Exceptions
std::logic_errorif there is no underlying attribute.
std::bad_castif
Template Parameters
DataTypedoes not match the underlying attribute type.
TriggerType get_trigger_type ( ) const
inline

Returns the trigger type.

Here is the caller graph for this function:

bool has_attribute ( ) const
inline

Returns true if this event has an associated attribute.

void operator= ( const Event< T > &  )
delete
void operator= ( Event< T > &&  )
delete
void set_attribute ( std::unique_ptr< AbstractValue attribute)
inline

Sets and transfers the ownership of attribute.

Here is the call graph for this function:

Here is the caller graph for this function:


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