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]

Public Types

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

Public Member Functions

 Event ()
 Constructs an Event with no trigger type and no event data. More...
 
void operator= (const Event &)=delete
 
 Event (Event &&)=delete
 
void operator= (Event &&)=delete
 
virtual bool is_discrete_update () const =0
 Returns true if this is a DiscreteUpdateEvent. More...
 
virtual ~Event ()
 An object passed. More...
 
std::unique_ptr< EventClone () const
 Clones this instance. More...
 
TriggerType get_trigger_type () const
 Returns the trigger type. More...
 
bool has_event_data () const
 Returns true if this event has associated data. More...
 
const EventDataget_event_data () const
 Returns a const pointer to the event data. More...
 
EventDataget_mutable_event_data ()
 Returns a mutable pointer to the event data. 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)
 
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, DiscreteUpdateEvent, 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 
kInitialization 

This trigger indicates that an associated event is triggered at system initialization.

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
PeriodicEventData. 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.

Constructor & Destructor Documentation

Event ( )
inline

Constructs an Event with no trigger type and no event data.

Event ( Event< T > &&  )
delete
virtual ~Event ( )
inlinevirtual

An object passed.

Event ( const Event< T > &  other)
inlineprotected

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 >.

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

Clones this instance.

Here is the caller 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.

const EventData* get_event_data ( ) const
inline

Returns a const pointer to the event data.

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

EventData* get_mutable_event_data ( )
inline

Returns a mutable pointer to the event data.

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

TriggerType get_trigger_type ( ) const
inline

Returns the trigger type.

bool has_event_data ( ) const
inline

Returns true if this event has associated data.

virtual bool is_discrete_update ( ) const
pure virtual
void operator= ( const Event< T > &  )
delete
void operator= ( Event< T > &&  )
delete

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