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::MockLightBarDriver Class Reference

#include <MockLightBarDriver.hpp>

Collaboration diagram for mock_drivers::MockLightBarDriver:
Collaboration graph

Public Member Functions

 MockLightBarDriver (ros::CARMANodeHandle node)
 
void publishData ()
 
void publishDriverStatus ()
 
string getNodeName ()
 
vector< string > getDriverTypesList ()
 

Private Member Functions

bool getDriverStatus_cb (cav_srvs::GetDriverStatusRequest &req, cav_srvs::GetDriverStatusResponse &resp)
 
bool bind_cb (cav_srvs::BindRequest &req, cav_srvs::BindResponse &resp)
 
bool getApiService_cb (cav_srvs::GetDriverApiRequest &req, cav_srvs::GetDriverApiResponse &resp)
 
bool setLightService_cb (cav_srvs::SetLightsRequest &req, cav_srvs::SetLightsResponse &resp)
 
bool getLightService_cb (cav_srvs::GetLightsRequest &req, cav_srvs::GetLightsResponse &resp)
 
cav_msgs::LightBarStatus getLightBarStatus ()
 
cav_msgs::DriverStatus getDriverStatus ()
 
vector< string > getDriverApi ()
 

Private Attributes

cav_msgs::DriverStatus driverStatus
 
ros::Publisher lbPub
 
string lbStatusTopic
 
ros::Publisher discoveryPub
 
ros::ServiceServer getLightsService
 
ros::ServiceServer setLightsService
 
ros::ServiceServer getApiService
 
ros::ServiceServer bindService
 
ros::ServiceServer getDriverStatusService
 
string lbGetLightService
 
string lbSetLightService
 
short EXPECTED_DATA_COL_COUNT
 
short SAMPLE_ID_IDX
 
bool greenFlash
 
bool yellowFlash
 
bool leftArrow
 
bool rightArrow
 
bool sidesSolid
 
bool greenSolid
 
bool yellowDim
 
bool takedown
 

Detailed Description

Definition at line 45 of file MockLightBarDriver.hpp.

Constructor & Destructor Documentation

◆ MockLightBarDriver()

mock_drivers::MockLightBarDriver::MockLightBarDriver ( ros::CARMANodeHandle  node)

Definition at line 35 of file MockLightBarDriver.cpp.

35 {
36 //lightbar topics and services
37 lbStatusTopic = "lightbar/light_bar_status";
38 lbGetLightService = "lightbar/get_lights";
39 lbSetLightService = "lightbar/set_lights";
40 //lightbar states
41 greenFlash = false;
42 yellowFlash = false;
43 leftArrow = false;
44 rightArrow = false;
45 sidesSolid = false;
46 greenSolid = false;
47 yellowDim = false;
48 takedown = false;
49 //topics published
50 lbPub = node.advertise<cav_msgs::LightBarStatus>(lbStatusTopic, 100);
51 discoveryPub = node.advertise<cav_msgs::DriverStatus>("driver_discovery",100);
52 //service server
53 getApiService = node.advertiseService("mock_lightbar/get_driver_api",&MockLightBarDriver::getApiService_cb, this);
54 bindService = node.advertiseService("mock_lightbar/bind",&MockLightBarDriver::bind_cb, this);
55 getDriverStatusService = node.advertiseService("mock_lightbar/get_status",&MockLightBarDriver::getDriverStatus_cb,this);
58 //publish driver status
59 driverStatus.status = cav_msgs::DriverStatus::OPERATIONAL;
61 }
bool getApiService_cb(cav_srvs::GetDriverApiRequest &req, cav_srvs::GetDriverApiResponse &resp)
bool setLightService_cb(cav_srvs::SetLightsRequest &req, cav_srvs::SetLightsResponse &resp)
bool getLightService_cb(cav_srvs::GetLightsRequest &req, cav_srvs::GetLightsResponse &resp)
bool getDriverStatus_cb(cav_srvs::GetDriverStatusRequest &req, cav_srvs::GetDriverStatusResponse &resp)
bool bind_cb(cav_srvs::BindRequest &req, cav_srvs::BindResponse &resp)

References bind_cb(), bindService, discoveryPub, driverStatus, getApiService, getApiService_cb(), getDriverStatus_cb(), getDriverStatusService, getLightService_cb(), getLightsService, greenFlash, greenSolid, lbGetLightService, lbPub, lbSetLightService, lbStatusTopic, leftArrow, publishDriverStatus(), rightArrow, setLightService_cb(), setLightsService, sidesSolid, takedown, yellowDim, and yellowFlash.

Here is the call graph for this function:

Member Function Documentation

◆ bind_cb()

bool mock_drivers::MockLightBarDriver::bind_cb ( cav_srvs::BindRequest &  req,
cav_srvs::BindResponse &  resp 
)
private

Definition at line 70 of file MockLightBarDriver.cpp.

70 {
71 ROS_INFO_STREAM("bind received");
72 return true;
73 }

Referenced by MockLightBarDriver().

Here is the caller graph for this function:

◆ getApiService_cb()

bool mock_drivers::MockLightBarDriver::getApiService_cb ( cav_srvs::GetDriverApiRequest &  req,
cav_srvs::GetDriverApiResponse &  resp 
)
private

Definition at line 76 of file MockLightBarDriver.cpp.

76 {
77 resp.api_list = getDriverApi();
78 return true;
79 }

References getDriverApi().

Referenced by MockLightBarDriver().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDriverApi()

vector< string > mock_drivers::MockLightBarDriver::getDriverApi ( )
private

Definition at line 137 of file MockLightBarDriver.cpp.

137 {
138 vector<string> api;
139 api.push_back(lbStatusTopic);
140 api.push_back(lbGetLightService);
141 api.push_back(lbSetLightService);
142 return api;
143
144 }

References lbGetLightService, lbSetLightService, and lbStatusTopic.

Referenced by getApiService_cb().

Here is the caller graph for this function:

◆ getDriverStatus()

cav_msgs::DriverStatus mock_drivers::MockLightBarDriver::getDriverStatus ( )
private

Definition at line 119 of file MockLightBarDriver.cpp.

119 {
120 cav_msgs::DriverStatus status;
121 status.name = getNodeName();
122 status.status = driverStatus.status;
123 status.can = false;
124 status.radar = false;
125 status.gnss = false;
126 status.imu = false;
127 status.lidar = false;
128 status.roadway_sensor = false;
129 status.comms = false;
130 status.controller = false;
131 status.camera = false;
132 status.lightbar = true;
133 return status;
134
135 }

References driverStatus, and getNodeName().

Referenced by getDriverStatus_cb(), and publishDriverStatus().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDriverStatus_cb()

bool mock_drivers::MockLightBarDriver::getDriverStatus_cb ( cav_srvs::GetDriverStatusRequest &  req,
cav_srvs::GetDriverStatusResponse &  resp 
)
private

Definition at line 64 of file MockLightBarDriver.cpp.

64 {
65 resp.status = getDriverStatus();
66 return true;
67 }
cav_msgs::DriverStatus getDriverStatus()

References getDriverStatus().

Referenced by MockLightBarDriver().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDriverTypesList()

vector< string > mock_drivers::MockLightBarDriver::getDriverTypesList ( )

Definition at line 159 of file MockLightBarDriver.cpp.

159 {
160 vector<string> list;
161 list.push_back("lightbar");
162 return list;
163 }

◆ getLightBarStatus()

cav_msgs::LightBarStatus mock_drivers::MockLightBarDriver::getLightBarStatus ( )
private

Helper function to build the lightbar status message

Returns
The lightbar status message

Definition at line 105 of file MockLightBarDriver.cpp.

105 {
106 cav_msgs::LightBarStatus status;
107 status.green_solid = greenSolid? 1:0;
108 status.yellow_solid = yellowDim? 1:0;
109 status.right_arrow = rightArrow? 1:0;
110 status.left_arrow = leftArrow? 1:0;
111 status.sides_solid = sidesSolid? 1:0;
112 status.flash = yellowFlash? 1:0;
113 status.green_flash = greenFlash? 1:0;
114 status.takedown = takedown? 1:0;
115 return status;
116
117 }

References greenFlash, greenSolid, leftArrow, rightArrow, sidesSolid, takedown, yellowDim, and yellowFlash.

Referenced by getLightService_cb(), and publishData().

Here is the caller graph for this function:

◆ getLightService_cb()

bool mock_drivers::MockLightBarDriver::getLightService_cb ( cav_srvs::GetLightsRequest &  req,
cav_srvs::GetLightsResponse &  resp 
)
private

Definition at line 96 of file MockLightBarDriver.cpp.

96 {
97 resp.status = getLightBarStatus();
98 return true;
99 }
cav_msgs::LightBarStatus getLightBarStatus()

References getLightBarStatus().

Referenced by MockLightBarDriver().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNodeName()

string mock_drivers::MockLightBarDriver::getNodeName ( )

Definition at line 155 of file MockLightBarDriver.cpp.

155 {
156 return "MockLightBarDriver";
157 }

Referenced by getDriverStatus().

Here is the caller graph for this function:

◆ publishData()

void mock_drivers::MockLightBarDriver::publishData ( )

Definition at line 146 of file MockLightBarDriver.cpp.

146 {
147 cav_msgs::LightBarStatus status = getLightBarStatus();
148 lbPub.publish(status);
149 }

References getLightBarStatus(), and lbPub.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ publishDriverStatus()

void mock_drivers::MockLightBarDriver::publishDriverStatus ( )

Definition at line 151 of file MockLightBarDriver.cpp.

151 {
152 discoveryPub.publish(getDriverStatus());
153 }

References discoveryPub, and getDriverStatus().

Referenced by MockLightBarDriver(), and main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setLightService_cb()

bool mock_drivers::MockLightBarDriver::setLightService_cb ( cav_srvs::SetLightsRequest &  req,
cav_srvs::SetLightsResponse &  resp 
)
private

Definition at line 82 of file MockLightBarDriver.cpp.

82 {
83 cav_msgs::LightBarStatus lightstatus = req.set_state;
84 greenFlash = lightstatus.green_flash == 1;
85 yellowFlash = lightstatus.flash == 1;
86 leftArrow = lightstatus.left_arrow == 1;
87 rightArrow = lightstatus.right_arrow== 1;
88 sidesSolid = lightstatus.sides_solid == 1;
89 greenSolid = lightstatus.green_solid == 1;
90 yellowDim = lightstatus.yellow_solid == 1;
91 takedown = lightstatus.takedown == 1;
92 return true;
93 }

References greenFlash, greenSolid, leftArrow, rightArrow, sidesSolid, takedown, yellowDim, and yellowFlash.

Referenced by MockLightBarDriver().

Here is the caller graph for this function:

Member Data Documentation

◆ bindService

ros::ServiceServer mock_drivers::MockLightBarDriver::bindService
private

Definition at line 61 of file MockLightBarDriver.hpp.

Referenced by MockLightBarDriver().

◆ discoveryPub

ros::Publisher mock_drivers::MockLightBarDriver::discoveryPub
private

Definition at line 55 of file MockLightBarDriver.hpp.

Referenced by MockLightBarDriver(), and publishDriverStatus().

◆ driverStatus

cav_msgs::DriverStatus mock_drivers::MockLightBarDriver::driverStatus
private

Definition at line 51 of file MockLightBarDriver.hpp.

Referenced by MockLightBarDriver(), and getDriverStatus().

◆ EXPECTED_DATA_COL_COUNT

short mock_drivers::MockLightBarDriver::EXPECTED_DATA_COL_COUNT
private

Definition at line 65 of file MockLightBarDriver.hpp.

◆ getApiService

ros::ServiceServer mock_drivers::MockLightBarDriver::getApiService
private

Definition at line 60 of file MockLightBarDriver.hpp.

Referenced by MockLightBarDriver().

◆ getDriverStatusService

ros::ServiceServer mock_drivers::MockLightBarDriver::getDriverStatusService
private

Definition at line 62 of file MockLightBarDriver.hpp.

Referenced by MockLightBarDriver().

◆ getLightsService

ros::ServiceServer mock_drivers::MockLightBarDriver::getLightsService
private

Definition at line 58 of file MockLightBarDriver.hpp.

Referenced by MockLightBarDriver().

◆ greenFlash

bool mock_drivers::MockLightBarDriver::greenFlash
private

◆ greenSolid

bool mock_drivers::MockLightBarDriver::greenSolid
private

◆ lbGetLightService

string mock_drivers::MockLightBarDriver::lbGetLightService
private

Definition at line 63 of file MockLightBarDriver.hpp.

Referenced by MockLightBarDriver(), and getDriverApi().

◆ lbPub

ros::Publisher mock_drivers::MockLightBarDriver::lbPub
private

Definition at line 53 of file MockLightBarDriver.hpp.

Referenced by MockLightBarDriver(), and publishData().

◆ lbSetLightService

string mock_drivers::MockLightBarDriver::lbSetLightService
private

Definition at line 64 of file MockLightBarDriver.hpp.

Referenced by MockLightBarDriver(), and getDriverApi().

◆ lbStatusTopic

string mock_drivers::MockLightBarDriver::lbStatusTopic
private

Definition at line 54 of file MockLightBarDriver.hpp.

Referenced by MockLightBarDriver(), and getDriverApi().

◆ leftArrow

bool mock_drivers::MockLightBarDriver::leftArrow
private

◆ rightArrow

bool mock_drivers::MockLightBarDriver::rightArrow
private

◆ SAMPLE_ID_IDX

short mock_drivers::MockLightBarDriver::SAMPLE_ID_IDX
private

Definition at line 66 of file MockLightBarDriver.hpp.

◆ setLightsService

ros::ServiceServer mock_drivers::MockLightBarDriver::setLightsService
private

Definition at line 59 of file MockLightBarDriver.hpp.

Referenced by MockLightBarDriver().

◆ sidesSolid

bool mock_drivers::MockLightBarDriver::sidesSolid
private

◆ takedown

bool mock_drivers::MockLightBarDriver::takedown
private

◆ yellowDim

bool mock_drivers::MockLightBarDriver::yellowDim
private

◆ yellowFlash

bool mock_drivers::MockLightBarDriver::yellowFlash
private

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