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.
|
#include <lightbar_manager_worker.hpp>
Public Member Functions | |
LightBarManagerWorker () | |
Default constructor for LightBarManager. More... | |
LightBarState | getCurrentState () |
Get current state of the LightBarStateMachine. More... | |
void | next (const LightBarEvent &event) |
Transition to the next state of the LightBarStateMachine Not used at the moment as state machine fully handles everything. More... | |
void | handleStateChange (const carma_planning_msgs::msg::GuidanceState &msg) |
This function relays the state change msg to the state maching. It triggers the transitioning to the next state in LightBarStateMachine based on the guidance state change. More... | |
std::vector< lightbar_manager::LightBarIndicator > | handleTurnSignal (const automotive_platform_msgs::msg::TurnSignalCommand &msg) |
This function checks if the turn signal should be changed on the lightbar. More... | |
void | releaseControl (std::vector< LightBarIndicator > ind_list, std::string owner_name) |
Releases the specified owner plugin or component's control of the given indicator list. This function handles successful transitioning of next ownership when that happens. More... | |
std::vector< LightBarIndicator > | requestControl (std::vector< LightBarIndicator > ind_list, std::string requester_name) |
Requests the control of the given list of indicators to the requester. This function handles successful transitioning of next ownership and illogical requests such as mutually exclusive indicators. More... | |
std::vector< IndicatorStatus > | setIndicator (LightBarIndicator ind, IndicatorStatus ind_status, std::string requester_name) |
Try to turn the given indicator ON or OFF (locally) upon the given component's request. More... | |
LightBarIndicator | getIndicatorFromCDAType (LightBarCDAType cda_type) |
Helper functions that translates an indicator to its corresponding CDA msg type The mapping between indicators and CDA types are configured through ROS params. More... | |
LightBarCDAType | getCDATypeFromIndicator (LightBarIndicator indicator) |
Helper functions that translates a CDA msg type to its corresponding indicator The mapping between indicators and CDA types are configured through ROS params. More... | |
std::map< LightBarCDAType, LightBarIndicator > | setIndicatorCDAMap (const std::vector< std::string > &lightbar_cda_table, const std::vector< std::string > &lightbar_ind_table) |
Helper function that initializes CDAType to Indicator Mapping (updates internal copy) More... | |
std::map< LightBarIndicator, std::string > | getIndicatorControllers () |
Helper function that gets all current owners of the indicator. More... | |
void | setIndicatorControllers () |
Helper function that initializes supporting Indicators and their owner mapping as empty strings. More... | |
void | setIndicatorControllers (std::map< LightBarIndicator, std::string > ind_ctrl_map) |
Helper function that resets Indicators and their owner mapping. More... | |
bool | hasHigherPriority (std::string requester, std::string controller) |
Helper function that checks if the first input component has higher priority than the second. More... | |
void | handleControlChange (LightBarIndicator indicator, std::string controller, IndicatorControlEvent event) |
Helper function that handles control lost/gained event of a component. This function registers/removes controller's name to all mutually inexclusive indicators. e.g. If registering a component as controller of YELLOW_ARROW_OUT, it will be registered for YELLOW_ARROW_LEFT/RIGHT/FLASH too. More... | |
carma_driver_msgs::msg::LightBarStatus | getLightBarStatusMsg (std::vector< IndicatorStatus > indicators) |
Helper function that translates IndicatorStatus vector into LightBarStatus.msg, a lightbar driver compatible msg. More... | |
std::vector< carma_msgs::msg::LightBarIndicator > | getMsg (std::vector< LightBarIndicator > indicators) |
Helper function that translates LightBarIndicator vector into LightBarIndicator.msg vector. More... | |
std::vector< carma_msgs::msg::LightBarCDAType > | getMsg (std::vector< LightBarCDAType > cda_types) |
Helper function that translates LightBarIndicator vector into LightBarIndicator.msg vector. More... | |
carma_msgs::msg::LightBarIndicatorControllers | getMsg (std::map< LightBarIndicator, std::string > ind_ctrl_map) |
Helper function that translates mapping of indicators to their owners into Msg. More... | |
Public Attributes | |
std::vector< std::string > | control_priorities |
std::vector< IndicatorStatus > | light_status |
Private Member Functions | |
FRIEND_TEST (LightBarManagerNodeTest, testSetIndicator) | |
FRIEND_TEST (LightBarManagerNodeTest, testTurnOffAll) | |
FRIEND_TEST (LightBarManagerNodeTest, testTurnSignalCallback) | |
Private Attributes | |
LightBarManagerStateMachine | lbsm_ |
std::map< LightBarIndicator, std::string > | ind_ctrl_map_ |
std::map< LightBarCDAType, LightBarIndicator > | cda_ind_map_ |
uint8_t | current_turn_signal_ = automotive_platform_msgs::msg::TurnSignalCommand::NONE |
std::map< std::string, LightBarCDAType > | cda_type_dict_ |
std::map< std::string, LightBarIndicator > | ind_dict |
Definition at line 48 of file lightbar_manager_worker.hpp.
lightbar_manager::LightBarManagerWorker::LightBarManagerWorker | ( | ) |
Default constructor for LightBarManager.
Definition at line 22 of file lightbar_manager_worker.cpp.
|
private |
|
private |
|
private |
LightBarCDAType lightbar_manager::LightBarManagerWorker::getCDATypeFromIndicator | ( | LightBarIndicator | indicator | ) |
Helper functions that translates a CDA msg type to its corresponding indicator
The mapping between indicators and CDA types are configured through ROS params.
Definition at line 390 of file lightbar_manager_worker.cpp.
References cda_ind_map_.
LightBarState lightbar_manager::LightBarManagerWorker::getCurrentState | ( | ) |
Get current state of the LightBarStateMachine.
Definition at line 29 of file lightbar_manager_worker.cpp.
References lightbar_manager::LightBarManagerStateMachine::getCurrentState(), and lbsm_.
std::map< LightBarIndicator, std::string > lightbar_manager::LightBarManagerWorker::getIndicatorControllers | ( | ) |
Helper function that gets all current owners of the indicator.
Definition at line 106 of file lightbar_manager_worker.cpp.
References ind_ctrl_map_.
LightBarIndicator lightbar_manager::LightBarManagerWorker::getIndicatorFromCDAType | ( | LightBarCDAType | cda_type | ) |
Helper functions that translates an indicator to its corresponding CDA msg type
The mapping between indicators and CDA types are configured through ROS params.
Definition at line 385 of file lightbar_manager_worker.cpp.
References cda_ind_map_.
carma_driver_msgs::msg::LightBarStatus lightbar_manager::LightBarManagerWorker::getLightBarStatusMsg | ( | std::vector< IndicatorStatus > | indicators | ) |
Helper function that translates IndicatorStatus vector into LightBarStatus.msg, a lightbar driver compatible msg.
Definition at line 349 of file lightbar_manager_worker.cpp.
References lightbar_manager::GREEN_FLASH, lightbar_manager::GREEN_SOLID, lightbar_manager::OFF, lightbar_manager::ON, lightbar_manager::YELLOW_ARROW_LEFT, lightbar_manager::YELLOW_ARROW_OUT, lightbar_manager::YELLOW_ARROW_RIGHT, lightbar_manager::YELLOW_DIM, lightbar_manager::YELLOW_FLASH, and lightbar_manager::YELLOW_SIDES.
carma_msgs::msg::LightBarIndicatorControllers lightbar_manager::LightBarManagerWorker::getMsg | ( | std::map< LightBarIndicator, std::string > | ind_ctrl_map | ) |
Helper function that translates mapping of indicators to their owners into Msg.
Definition at line 57 of file lightbar_manager_worker.cpp.
References lightbar_manager::GREEN_FLASH, lightbar_manager::GREEN_SOLID, lightbar_manager::YELLOW_ARROW_LEFT, lightbar_manager::YELLOW_ARROW_OUT, lightbar_manager::YELLOW_ARROW_RIGHT, lightbar_manager::YELLOW_DIM, lightbar_manager::YELLOW_FLASH, and lightbar_manager::YELLOW_SIDES.
std::vector< carma_msgs::msg::LightBarCDAType > lightbar_manager::LightBarManagerWorker::getMsg | ( | std::vector< LightBarCDAType > | cda_types | ) |
Helper function that translates LightBarIndicator vector into LightBarIndicator.msg vector.
Definition at line 46 of file lightbar_manager_worker.cpp.
std::vector< carma_msgs::msg::LightBarIndicator > lightbar_manager::LightBarManagerWorker::getMsg | ( | std::vector< LightBarIndicator > | indicators | ) |
Helper function that translates LightBarIndicator vector into LightBarIndicator.msg vector.
Definition at line 34 of file lightbar_manager_worker.cpp.
void lightbar_manager::LightBarManagerWorker::handleControlChange | ( | LightBarIndicator | indicator, |
std::string | controller, | ||
IndicatorControlEvent | event | ||
) |
Helper function that handles control lost/gained event of a component. This function registers/removes controller's name to all mutually inexclusive indicators. e.g. If registering a component as controller of YELLOW_ARROW_OUT, it will be registered for YELLOW_ARROW_LEFT/RIGHT/FLASH too.
Definition at line 262 of file lightbar_manager_worker.cpp.
References lightbar_manager::CONTROL_GAINED, lightbar_manager::GREEN_FLASH, lightbar_manager::GREEN_SOLID, hasHigherPriority(), ind_ctrl_map_, lightbar_manager::YELLOW_ARROW_LEFT, lightbar_manager::YELLOW_ARROW_OUT, lightbar_manager::YELLOW_ARROW_RIGHT, and lightbar_manager::YELLOW_FLASH.
Referenced by releaseControl(), and requestControl().
void lightbar_manager::LightBarManagerWorker::handleStateChange | ( | const carma_planning_msgs::msg::GuidanceState & | msg | ) |
This function relays the state change msg to the state maching. It triggers the transitioning to the next state in LightBarStateMachine based on the guidance state change.
Definition at line 72 of file lightbar_manager_worker.cpp.
References lightbar_manager::LightBarManagerStateMachine::handleStateChange(), and lbsm_.
std::vector< lightbar_manager::LightBarIndicator > lightbar_manager::LightBarManagerWorker::handleTurnSignal | ( | const automotive_platform_msgs::msg::TurnSignalCommand & | msg | ) |
This function checks if the turn signal should be changed on the lightbar.
Definition at line 78 of file lightbar_manager_worker.cpp.
References current_turn_signal_, lightbar_manager::YELLOW_ARROW_LEFT, and lightbar_manager::YELLOW_ARROW_RIGHT.
bool lightbar_manager::LightBarManagerWorker::hasHigherPriority | ( | std::string | requester, |
std::string | controller | ||
) |
Helper function that checks if the first input component has higher priority than the second.
Definition at line 167 of file lightbar_manager_worker.cpp.
References control_priorities.
Referenced by handleControlChange(), and requestControl().
void lightbar_manager::LightBarManagerWorker::next | ( | const LightBarEvent & | event | ) |
Transition to the next state of the LightBarStateMachine Not used at the moment as state machine fully handles everything.
Definition at line 24 of file lightbar_manager_worker.cpp.
References lbsm_, and lightbar_manager::LightBarManagerStateMachine::next().
void lightbar_manager::LightBarManagerWorker::releaseControl | ( | std::vector< LightBarIndicator > | ind_list, |
std::string | owner_name | ||
) |
Releases the specified owner plugin or component's control of the given indicator list. This function handles successful transitioning of next ownership when that happens.
Definition at line 233 of file lightbar_manager_worker.cpp.
References lightbar_manager::CONTROL_LOST, handleControlChange(), and ind_ctrl_map_.
std::vector< LightBarIndicator > lightbar_manager::LightBarManagerWorker::requestControl | ( | std::vector< LightBarIndicator > | ind_list, |
std::string | requester_name | ||
) |
Requests the control of the given list of indicators to the requester. This function handles successful transitioning of next ownership and illogical requests such as mutually exclusive indicators.
Definition at line 189 of file lightbar_manager_worker.cpp.
References lightbar_manager::CONTROL_GAINED, lightbar_manager::CONTROL_LOST, handleControlChange(), hasHigherPriority(), and ind_ctrl_map_.
std::vector< IndicatorStatus > lightbar_manager::LightBarManagerWorker::setIndicator | ( | LightBarIndicator | ind, |
IndicatorStatus | ind_status, | ||
std::string | requester_name | ||
) |
Try to turn the given indicator ON or OFF (locally) upon the given component's request.
Definition at line 308 of file lightbar_manager_worker.cpp.
References lightbar_manager::GREEN_FLASH, lightbar_manager::GREEN_SOLID, ind_ctrl_map_, light_status, lightbar_manager::OFF, lightbar_manager::YELLOW_ARROW_LEFT, lightbar_manager::YELLOW_ARROW_OUT, lightbar_manager::YELLOW_ARROW_RIGHT, and lightbar_manager::YELLOW_FLASH.
std::map< LightBarCDAType, LightBarIndicator > lightbar_manager::LightBarManagerWorker::setIndicatorCDAMap | ( | const std::vector< std::string > & | lightbar_cda_table, |
const std::vector< std::string > & | lightbar_ind_table | ||
) |
Helper function that initializes CDAType to Indicator Mapping (updates internal copy)
Definition at line 112 of file lightbar_manager_worker.cpp.
References cda_ind_map_, cda_type_dict_, process_bag::i, ind_dict, lightbar_manager::TYPE_A, lightbar_manager::TYPE_B, lightbar_manager::TYPE_C, lightbar_manager::TYPE_D, lightbar_manager::YELLOW_DIM, lightbar_manager::YELLOW_FLASH, and lightbar_manager::YELLOW_SIDES.
void lightbar_manager::LightBarManagerWorker::setIndicatorControllers | ( | ) |
Helper function that initializes supporting Indicators and their owner mapping as empty strings.
Definition at line 370 of file lightbar_manager_worker.cpp.
References process_bag::i, ind_ctrl_map_, and INDICATOR_COUNT.
void lightbar_manager::LightBarManagerWorker::setIndicatorControllers | ( | std::map< LightBarIndicator, std::string > | ind_ctrl_map | ) |
Helper function that resets Indicators and their owner mapping.
Definition at line 380 of file lightbar_manager_worker.cpp.
References ind_ctrl_map_.
|
private |
Definition at line 189 of file lightbar_manager_worker.hpp.
Referenced by getCDATypeFromIndicator(), getIndicatorFromCDAType(), and setIndicatorCDAMap().
|
private |
Definition at line 195 of file lightbar_manager_worker.hpp.
Referenced by setIndicatorCDAMap().
std::vector<std::string> lightbar_manager::LightBarManagerWorker::control_priorities |
Definition at line 174 of file lightbar_manager_worker.hpp.
Referenced by hasHigherPriority().
|
private |
Definition at line 192 of file lightbar_manager_worker.hpp.
Referenced by handleTurnSignal().
|
private |
Definition at line 186 of file lightbar_manager_worker.hpp.
Referenced by getIndicatorControllers(), handleControlChange(), releaseControl(), requestControl(), setIndicator(), and setIndicatorControllers().
|
private |
Definition at line 201 of file lightbar_manager_worker.hpp.
Referenced by setIndicatorCDAMap().
|
private |
Definition at line 183 of file lightbar_manager_worker.hpp.
Referenced by getCurrentState(), handleStateChange(), and next().
std::vector<IndicatorStatus> lightbar_manager::LightBarManagerWorker::light_status |
Definition at line 177 of file lightbar_manager_worker.hpp.
Referenced by setIndicator().