Open 3D Engine ROS2 Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
ROS2::EventSourceAdapter< EventSourceT > Class Template Reference

#include <EventSourceAdapter.h>

Public Member Functions

void Start ()
 
void Stop ()
 
void SetFrequency (float adaptedFrequency)
 
void ConnectToSourceEvent (typename EventSourceT::SourceEventHandlerType &sourceEventHandler)
 
void ConnectToAdaptedEvent (typename EventSourceT::AdaptedEventHandlerType &adaptedEventHandler)
 

Static Public Member Functions

static void Reflect (AZ::ReflectContext *context)
 

Detailed Description

template<class EventSourceT>
class ROS2::EventSourceAdapter< EventSourceT >

Class adapting event source (ROS2::SensorEventSource) to configurable working frequency. This is handled via adapted event, in a similar manner like it is done in SensorEventSource. EventSourceAdapter has its internal handler that connects to SensorEventSource source event, and signals adapted event according to frequency set (ROS2::EventSourceAdapter::SetFrequency). User can connect to this event using ROS2::EventSourceAdapter::ConnectToAdaptedEvent method. This class should be used, instead of using directly a class derived from SensorEventSource, when specific working frequency is required. Following this path, user can still use source event - ROS2::EventSourceAdapter::ConnectToSourceEvent. This template has to be resolved using a class derived from SensorEventSource specialization.

See also
ROS2::SensorEventSource

Member Function Documentation

◆ ConnectToAdaptedEvent()

template<class EventSourceT >
void ROS2::EventSourceAdapter< EventSourceT >::ConnectToAdaptedEvent ( typename EventSourceT::AdaptedEventHandlerType &  adaptedEventHandler)
inline

Connects given event handler to adapted event (ROS2::EventSourceAdapter). This event is signalled with a frequency set with ROS2::EventSourceAdapter::SetFrequency method.

Parameters
adaptedEventHandlerEvent handler for adapted event.

◆ ConnectToSourceEvent()

template<class EventSourceT >
void ROS2::EventSourceAdapter< EventSourceT >::ConnectToSourceEvent ( typename EventSourceT::SourceEventHandlerType &  sourceEventHandler)
inline

Connects given event handler to source event (ROS2::SensorEventSource). That event is signalled regardless of adapted frequency set for event source adapter (ROS2::EventSourceAdapter::SetFrequency). Its frequency depends only on specific event source implementation. If different working frequency is required (main purpose of ROS2::EventSourceAdapter), user should see ROS2::EventSourceAdapter::ConnectToAdaptedEvent method.

Parameters
sourceEventHandlerEvent handler for source event (frequency not managed by event source adapter).
See also
ROS2::SensorEventSource

◆ SetFrequency()

template<class EventSourceT >
void ROS2::EventSourceAdapter< EventSourceT >::SetFrequency ( float  adaptedFrequency)
inline

Sets adapter working frequency. By design, adapter will not work correctly, if this frequency will be greater than used event source frequency - e.g. adapter will be requested to work in 60Hz, when using event source working in 30Hz. In general, adapted frequency should be equal or lower than event source frequency - this is forced internally (ROS2::EventSourceAdapter::IsPublicationDeadline). Optimal (highest precision in timing events) working conditions take place when event source frequency is an integer multiple of adapted frequency.

Parameters
adaptedFrequencyAdapter working frequency. When set to zero or less adapter will be assumed to work in 1Hz.

◆ Start()

template<class EventSourceT >
void ROS2::EventSourceAdapter< EventSourceT >::Start ( )
inline

Starts event source adapter - assigns internal adapted event handler and starts managed event source. Adapted frequency can be set using ROS2::EventSourceAdapter::SetFrequency method.

◆ Stop()

template<class EventSourceT >
void ROS2::EventSourceAdapter< EventSourceT >::Stop ( )
inline

Stops event source adapter - stops event source and disconnects internal adapted event handler from source event. If it will be necessary, this implementation allows multiple consecutive calls of Start / Stop, however user must also investigate specific event source implementation with such case in mind.


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