Carma-platform v4.2.0
CARMA Platform is built on robot operating system (ROS) and utilizes open source software (OSS) that enables Cooperative Driving Automation (CDA) features to allow Automated Driving Systems to interact and cooperate with infrastructure and other vehicles through communication.
mock_drivers::ROSComms< M, T > Class Template Reference

Class which serves as an abstraction of a service framework. More...

#include <ROSComms.h>

Collaboration diagram for mock_drivers::ROSComms< M, T >:
Collaboration graph

Public Member Functions

std::string getTopic ()
 Returns the name string (topic) associated with the service. More...
 
CommTypes getCommType ()
 returns the comms type of this object More...
 
bool callback (M req, T res)
 Callback function which is triggered to pass data into this comms abstraction. More...
 
getReqType ()
 Returns an instance of the type this object is parameterized on. This is used for forwarding the data type. More...
 
getResType ()
 Returns an instance of the type this object is parameterized on. This is used for forwarding the data type. More...
 
 ROSComms ()
 Default constructor. More...
 
 ROSComms (std::function< bool(M, T)> cbf, CommTypes ct, std::string t)
 Service constructor. More...
 

Private Attributes

std::function< void(M, T)> callback_function_
 
CommTypes comm_type_
 
std::string topic_
 

Detailed Description

template<typename M, typename T>
class mock_drivers::ROSComms< M, T >

Class which serves as an abstraction of a service framework.

Template Parameters
MRequest Type. This should be a base service request type
TResponse Type. This should be the base service response type

Definition at line 136 of file ROSComms.h.

Constructor & Destructor Documentation

◆ ROSComms() [1/2]

template<typename M , typename T >
mock_drivers::ROSComms< M, T >::ROSComms ( )

Default constructor.

◆ ROSComms() [2/2]

template<typename M , typename T >
mock_drivers::ROSComms< M, T >::ROSComms ( std::function< bool(M, T)>  cbf,
CommTypes  ct,
std::string  t 
)

Service constructor.

This version of the ROSComms object is used for services.

Parameters
cbfService callback function. First parameter is the service request. The second is the out parameter for the response.
ctThe comms type. Should be srv
tThe topic name

Definition at line 65 of file ROSComms.ipp.

66{
68 comm_type_ = ct;
69 topic_ = t;
70}
std::function< void(M, T)> callback_function_
Definition: ROSComms.h:139

Member Function Documentation

◆ callback()

template<typename M , typename T >
bool mock_drivers::ROSComms< M, T >::callback ( req,
res 
)

Callback function which is triggered to pass data into this comms abstraction.

Used to call the ROSComms callback function.

Parameters
reqThe request message to pass
resThe response message to pass
Returns
True if the callback was executed successfully

Definition at line 74 of file ROSComms.ipp.

75{
76 // call the callback_function_ function
77 this->callback_function_(req, res);
78}

◆ getCommType()

template<typename M , typename T >
CommTypes mock_drivers::ROSComms< M, T >::getCommType ( )
inline

returns the comms type of this object

Returns
Comms type enum

Definition at line 158 of file ROSComms.h.

159 {
160 return comm_type_;
161 }

◆ getReqType()

template<typename M , typename T >
M mock_drivers::ROSComms< M, T >::getReqType

Returns an instance of the type this object is parameterized on. This is used for forwarding the data type.

Used to get an object of the service request type that can then be decltyped.

Returns
Instance of M

Definition at line 90 of file ROSComms.ipp.

91{
92 M element;
93 return element;
94}

◆ getResType()

template<typename M , typename T >
T mock_drivers::ROSComms< M, T >::getResType

Returns an instance of the type this object is parameterized on. This is used for forwarding the data type.

Used to get an object of the service response type that can then be decltyped.

Returns
Instance of T

Definition at line 82 of file ROSComms.ipp.

83{
84 T element;
85 return element;
86}

◆ getTopic()

template<typename M , typename T >
std::string mock_drivers::ROSComms< M, T >::getTopic ( )
inline

Returns the name string (topic) associated with the service.

Returns
Topic name

Definition at line 149 of file ROSComms.h.

150 {
151 return topic_;
152 }

Member Data Documentation

◆ callback_function_

template<typename M , typename T >
std::function<void(M, T)> mock_drivers::ROSComms< M, T >::callback_function_
private

Definition at line 139 of file ROSComms.h.

◆ comm_type_

template<typename M , typename T >
CommTypes mock_drivers::ROSComms< M, T >::comm_type_
private

Definition at line 140 of file ROSComms.h.

◆ topic_

template<typename M , typename T >
std::string mock_drivers::ROSComms< M, T >::topic_
private

Definition at line 141 of file ROSComms.h.


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