18#include <gtest/gtest.h>
20#include <rclcpp/rclcpp.hpp>
21#include <carma_ros2_utils/carma_lifecycle_node.hpp>
26#include <carma_msgs/msg/light_bar_cda_type.hpp>
27#include <carma_msgs/msg/light_bar_indicator.hpp>
28#include <carma_msgs/msg/light_bar_indicator_controllers.hpp>
29#include <carma_driver_msgs/msg/light_bar_status.hpp>
30#include <carma_planning_msgs/msg/guidance_state.hpp>
31#include <automotive_platform_msgs/msg/turn_signal_command.hpp>
33#include <carma_msgs/srv/request_indicator_control.hpp>
34#include <carma_msgs/srv/release_indicator_control.hpp>
35#include <carma_driver_msgs/srv/set_light_bar_indicator.hpp>
36#include <carma_driver_msgs/srv/set_lights.hpp>
39#define INDICATOR_COUNT 8
40#define CDA_MSG_TYPE_COUNT 4
46class LightBarManagerStateMachine;
79 std::vector<lightbar_manager::LightBarIndicator>
handleTurnSignal(
const automotive_platform_msgs::msg::TurnSignalCommand& msg);
85 void releaseControl(std::vector<LightBarIndicator> ind_list, std::string owner_name);
92 std::vector<LightBarIndicator>
requestControl(std::vector<LightBarIndicator> ind_list, std::string requester_name);
118 std::map<LightBarCDAType, LightBarIndicator>
setIndicatorCDAMap(
const std::vector<std::string>& lightbar_cda_table,
const std::vector<std::string>& lightbar_ind_table);
153 carma_driver_msgs::msg::LightBarStatus
getLightBarStatusMsg(std::vector<IndicatorStatus> indicators);
159 std::vector<carma_msgs::msg::LightBarIndicator>
getMsg(std::vector<LightBarIndicator> indicators);
165 std::vector<carma_msgs::msg::LightBarCDAType>
getMsg(std::vector<LightBarCDAType> cda_types);
171 carma_msgs::msg::LightBarIndicatorControllers
getMsg(std::map<LightBarIndicator, std::string> ind_ctrl_map);
201 std::map<std::string, LightBarIndicator>
ind_dict = {
std::vector< IndicatorStatus > light_status
void handleControlChange(LightBarIndicator indicator, std::string controller, IndicatorControlEvent event)
Helper function that handles control lost/gained event of a component. This function registers/remove...
std::map< LightBarCDAType, LightBarIndicator > cda_ind_map_
LightBarCDAType getCDATypeFromIndicator(LightBarIndicator indicator)
Helper functions that translates a CDA msg type to its corresponding indicator The mapping between ...
carma_driver_msgs::msg::LightBarStatus getLightBarStatusMsg(std::vector< IndicatorStatus > indicators)
Helper function that translates IndicatorStatus vector into LightBarStatus.msg, a lightbar driver com...
FRIEND_TEST(LightBarManagerNodeTest, testSetIndicator)
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.
std::map< std::string, LightBarIndicator > ind_dict
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)
std::vector< std::string > control_priorities
void setIndicatorControllers()
Helper function that initializes supporting Indicators and their owner mapping as empty strings.
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.
std::vector< carma_msgs::msg::LightBarIndicator > getMsg(std::vector< LightBarIndicator > indicators)
Helper function that translates LightBarIndicator vector into LightBarIndicator.msg vector.
LightBarIndicator getIndicatorFromCDAType(LightBarCDAType cda_type)
Helper functions that translates an indicator to its corresponding CDA msg type The mapping between...
FRIEND_TEST(LightBarManagerNodeTest, testTurnOffAll)
void next(const LightBarEvent &event)
Transition to the next state of the LightBarStateMachine Not used at the moment as state machine full...
FRIEND_TEST(LightBarManagerNodeTest, testTurnSignalCallback)
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....
uint8_t current_turn_signal_
std::map< LightBarIndicator, std::string > ind_ctrl_map_
LightBarManagerStateMachine lbsm_
LightBarState getCurrentState()
Get current state of the LightBarStateMachine.
LightBarManagerWorker()
Default constructor for LightBarManager.
std::map< LightBarIndicator, std::string > getIndicatorControllers()
Helper function that gets all current owners of the indicator.
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 ...
std::map< std::string, LightBarCDAType > cda_type_dict_
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 successf...
bool hasHigherPriority(std::string requester, std::string controller)
Helper function that checks if the first input component has higher priority than the second.