Apollo  6.0
Open source self driving car software
Public Member Functions | Friends | List of all members
apollo::cyber::Node Class Reference

Node is the fundamental building block of Cyber RT. every module contains and communicates through the node. A module can have different types of communication by defining read/write and/or service/client in a node. More...

#include <node.h>

Collaboration diagram for apollo::cyber::Node:
Collaboration graph

Public Member Functions

virtual ~Node ()
 
const std::string & Name () const
 Get node's name. More...
 
template<typename MessageT >
auto CreateWriter (const proto::RoleAttributes &role_attr) -> std::shared_ptr< Writer< MessageT >>
 Create a Writer with specific message type. More...
 
template<typename MessageT >
auto CreateWriter (const std::string &channel_name) -> std::shared_ptr< Writer< MessageT >>
 Create a Writer with specific message type. More...
 
template<typename MessageT >
auto CreateReader (const std::string &channel_name, const CallbackFunc< MessageT > &reader_func=nullptr) -> std::shared_ptr< cyber::Reader< MessageT >>
 Create a Reader with specific message type with channel name qos and other configs used will be default. More...
 
template<typename MessageT >
auto CreateReader (const ReaderConfig &config, const CallbackFunc< MessageT > &reader_func=nullptr) -> std::shared_ptr< cyber::Reader< MessageT >>
 Create a Reader with specific message type with reader config. More...
 
template<typename MessageT >
auto CreateReader (const proto::RoleAttributes &role_attr, const CallbackFunc< MessageT > &reader_func=nullptr) -> std::shared_ptr< cyber::Reader< MessageT >>
 Create a Reader object with RoleAttributes More...
 
template<typename Request , typename Response >
auto CreateService (const std::string &service_name, const typename Service< Request, Response >::ServiceCallback &service_callback) -> std::shared_ptr< Service< Request, Response >>
 Create a Service object with specific service_name More...
 
template<typename Request , typename Response >
auto CreateClient (const std::string &service_name) -> std::shared_ptr< Client< Request, Response >>
 Create a Client object to request Service with service_name More...
 
void Observe ()
 Observe all readers' data. More...
 
void ClearData ()
 clear all readers' data More...
 
template<typename MessageT >
auto GetReader (const std::string &channel_name) -> std::shared_ptr< Reader< MessageT >>
 Get the Reader object that subscribe channel_name More...
 

Friends

template<typename M0 , typename M1 , typename M2 , typename M3 >
class Component
 
class TimerComponent
 
bool Init (const char *)
 
std::unique_ptr< NodeCreateNode (const std::string &, const std::string &)
 

Detailed Description

Node is the fundamental building block of Cyber RT. every module contains and communicates through the node. A module can have different types of communication by defining read/write and/or service/client in a node.

Warning
Duplicate name is not allowed in topo objects, such as node, reader/writer, service/clinet in the topo.

Constructor & Destructor Documentation

◆ ~Node()

virtual apollo::cyber::Node::~Node ( )
virtual

Member Function Documentation

◆ ClearData()

void apollo::cyber::Node::ClearData ( )

clear all readers' data

◆ CreateClient()

template<typename Request , typename Response >
auto Node::CreateClient ( const std::string &  service_name) -> std::shared_ptr<Client<Request, Response>>

Create a Client object to request Service with service_name

Template Parameters
RequestMessage Type of the Request
ResponseMessage Type of the Response
Parameters
service_namespecific service name to a Service
Returns
std::shared_ptr<Client<Request, Response>> result Client

◆ CreateReader() [1/3]

template<typename MessageT >
auto Node::CreateReader ( const std::string &  channel_name,
const CallbackFunc< MessageT > &  reader_func = nullptr 
) -> std::shared_ptr<cyber::Reader<MessageT>>

Create a Reader with specific message type with channel name qos and other configs used will be default.

Template Parameters
MessageTMessage Type
Parameters
channel_namethe channel of the reader subscribed.
reader_funcinvoked when message receive invoked when the message is received.
Returns
std::shared_ptr<cyber::Reader<MessageT>> result Reader Object

◆ CreateReader() [2/3]

template<typename MessageT >
auto Node::CreateReader ( const ReaderConfig config,
const CallbackFunc< MessageT > &  reader_func = nullptr 
) -> std::shared_ptr<cyber::Reader<MessageT>>

Create a Reader with specific message type with reader config.

Template Parameters
MessageTMessage Type
Parameters
configinstance of ReaderConfig, include channel name, qos and pending queue size
reader_funcinvoked when message receive
Returns
std::shared_ptr<cyber::Reader<MessageT>> result Reader Object

◆ CreateReader() [3/3]

template<typename MessageT >
auto Node::CreateReader ( const proto::RoleAttributes &  role_attr,
const CallbackFunc< MessageT > &  reader_func = nullptr 
) -> std::shared_ptr<cyber::Reader<MessageT>>

Create a Reader object with RoleAttributes

Template Parameters
MessageTMessage Type
Parameters
role_attrinstance of RoleAttributes, includes channel name, qos, etc.
reader_funcinvoked when message receive
Returns
std::shared_ptr<cyber::Reader<MessageT>> result Reader Object

◆ CreateService()

template<typename Request , typename Response >
auto Node::CreateService ( const std::string &  service_name,
const typename Service< Request, Response >::ServiceCallback &  service_callback 
) -> std::shared_ptr<Service<Request, Response>>

Create a Service object with specific service_name

Template Parameters
RequestMessage Type of the Request
ResponseMessage Type of the Response
Parameters
service_namespecific service name to a serve
service_callbackinvoked when a service is called
Returns
std::shared_ptr<Service<Request, Response>> result Service

◆ CreateWriter() [1/2]

template<typename MessageT >
auto Node::CreateWriter ( const proto::RoleAttributes &  role_attr) -> std::shared_ptr<Writer<MessageT>>

Create a Writer with specific message type.

Template Parameters
MessageTMessage Type
Parameters
role_attris a protobuf message RoleAttributes, which includes the channel name and other info.
Returns
std::shared_ptr<Writer<MessageT>> result Writer Object

◆ CreateWriter() [2/2]

template<typename MessageT >
auto Node::CreateWriter ( const std::string &  channel_name) -> std::shared_ptr<Writer<MessageT>>

Create a Writer with specific message type.

Template Parameters
MessageTMessage Type
Parameters
channel_namethe channel name to be published.
Returns
std::shared_ptr<Writer<MessageT>> result Writer Object

◆ GetReader()

template<typename MessageT >
auto Node::GetReader ( const std::string &  channel_name) -> std::shared_ptr<Reader<MessageT>>

Get the Reader object that subscribe channel_name

Template Parameters
MessageTMessage Type
Parameters
channel_namechannel name
Returns
std::shared_ptr<Reader<MessageT>> result reader

◆ Name()

const std::string& apollo::cyber::Node::Name ( ) const

Get node's name.

Warning
duplicate node name is not allowed in the topo.

◆ Observe()

void apollo::cyber::Node::Observe ( )

Observe all readers' data.

Friends And Related Function Documentation

◆ Component

template<typename M0 , typename M1 , typename M2 , typename M3 >
friend class Component
friend

◆ CreateNode

std::unique_ptr<Node> CreateNode ( const std::string &  ,
const std::string &   
)
friend

◆ Init

bool Init ( const char *  )
friend

◆ TimerComponent

friend class TimerComponent
friend

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