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::ROS2SensorComponentBase< EventSourceT > Class Template Reference

#include <ROS2SensorComponentBase.h>

Inherits AZ::Component.

Public Types

using SensorBaseType = ROS2SensorComponentBase< EventSourceT >
 

Public Member Functions

 AZ_COMPONENT_DECL ((ROS2SensorComponentBase, AZ_CLASS))
 
void Activate () override
 
void Deactivate () override
 

Static Public Member Functions

static void Reflect (AZ::ReflectContext *context)
 
static void GetRequiredServices (AZ::ComponentDescriptor::DependencyArrayType &required)
 

Protected Member Functions

void StartSensor (float sensorFrequency, typename EventSourceT::AdaptedCallbackType adaptedCallback, typename EventSourceT::SourceCallbackType sourceCallback=nullptr)
 
void StopSensor ()
 Stops sensor and disconnects event callbacks passed through RSO2::ROS2SensorComponentBase::StartSensor.
 
AZStd::string GetNamespace () const
 Returns a complete namespace for this sensor topics and frame ids.
 
AZStd::string GetFrameID () const
 Returns this sensor frame ID. The ID contains namespace.
 

Protected Attributes

SensorConfiguration m_sensorConfiguration
 Basic sensor configuration.
 
EventSourceAdapter< EventSourceT > m_eventSourceAdapter
 Adapter for selected event source (see this class documentation).
 
EventSourceT::SourceEventHandlerType m_sourceEventHandler
 Handler for source event. Requires manual assignment and connecting to source event in derived class.
 
EventSourceT::AdaptedEventHandlerType m_adaptedEventHandler
 Handler for adapted event. Requires manual assignment and connecting to adapted event in derived class.
 

Detailed Description

template<class EventSourceT>
class ROS2::ROS2SensorComponentBase< EventSourceT >

Base sensor component class for all specific sensor implementations. Developer working on the new sensor should derive from this class, defining necessary event source type (EventSourceT template parameter). Available sources are e.g. TickBasedSource or PhysicsBasedSource. Chosen event source is wrapped into EventSourceAdapter, making it possible to work with specific frequency. Derived implementation should call ROS2::ROS2SensorComponentBase::StartSensor at the end of Activate (or whenever sensor configuration is already set up) and StopSensor in Deactivate. Starting sensor base requires passing two parameters:

  • sensor working frequency - how often sensor logic should be processed,
  • adapted event callback - what should be done in sensor logic processing. Optionally, user can pass third parameter, which is source event callback - this will be called with source event frequency (check chosen event source implementation).
    See also
    ROS2::TickBasedSource
    ROS2::PhysicsBasedSource

Member Function Documentation

◆ StartSensor()

template<class EventSourceT >
void ROS2::ROS2SensorComponentBase< EventSourceT >::StartSensor ( float  sensorFrequency,
typename EventSourceT::AdaptedCallbackType  adaptedCallback,
typename EventSourceT::SourceCallbackType  sourceCallback = nullptr 
)
inlineprotected

Starts sensor with passed frequency and adapted event callback. Optionally, user can pass source event callback, that will be called with event source frequency.

Parameters
sensorFrequencySensor working frequency.
adaptedCallbackAdapted event callback - called with sensor working frequency.
sourceCallbackSource event callback - called with event source frequency.

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