40    if (base_return != carma_ros2_utils::CallbackReturn::SUCCESS) {
 
   41      RCLCPP_ERROR(get_logger(), 
"Localization Controller could not configure");
 
   54    std::string json_string;
 
   55    get_parameter<std::string>(
"sensor_fault_map", json_string);
 
   57    RCLCPP_INFO_STREAM(get_logger(), 
"Loaded sensor_fault_map json string: " << json_string);
 
   61    RCLCPP_INFO_STREAM(get_logger(), 
"Loaded localization config: " << 
config_);
 
   67    return carma_ros2_utils::CallbackReturn::SUCCESS;
 
   72    carma_msgs::msg::SystemAlert alert = *msg; 
 
   73    carma_msgs::msg::SystemAlert output_alert;
 
   79      RCLCPP_INFO_STREAM(get_logger(), 
"Alert not from a sensor node. Alerting node: " << alert.source_node);
 
   84    if (alert.type == carma_msgs::msg::SystemAlert::FATAL) {
 
   89    std::vector<SensorBooleanStatus> current_sensor_status;
 
   96      RCLCPP_INFO_STREAM(get_logger(), 
"Failure does not match with fault configuration. Assuming system remains operational ");
 
  102    output_alert.description = 
"Localization optional sensor failure from: " + alert.source_node;
 
  104    switch(alert_status) {
 
  106        output_alert.type = carma_msgs::msg::SystemAlert::FATAL;
 
  107        output_alert.description = 
"Localization subsystem failed due to sensor failure from: " + alert.source_node;
 
  110        output_alert.type = carma_msgs::msg::SystemAlert::CAUTION;
 
  113        output_alert.type = carma_msgs::msg::SystemAlert::WARNING;
 
  120    output_alert.source_node =  get_node_base_interface()->get_fully_qualified_name();
 
  121    publish_system_alert(output_alert);
 
  128    rapidjson::Document d;
 
  130    if(d.Parse(json_string.c_str()).HasParseError())
 
  132        RCLCPP_WARN(get_logger(), 
"Failed to parse sensor_fault map. Invalid json structure");
 
  136    if (!d.HasMember(
"sensor_fault_map")) {
 
  137      RCLCPP_WARN(get_logger(), 
"No sensor_fault_map found in localization config");
 
  141    rapidjson::Value& map_value = d[
"sensor_fault_map"];
 
  143    if (!map_value.IsArray()) {
 
  144      RCLCPP_WARN(get_logger(), 
"sensor_fault_map cannot be read as array");
 
  148    if (map_value.Size() == 0) {
 
  149      RCLCPP_WARN(get_logger(), 
"sensor_fault_map has zero size");
 
  153    for (rapidjson::SizeType 
i = 0; 
i < map_value.Size(); 
i++) {
 
  154      if (!map_value[
i].IsArray()) {
 
  155        RCLCPP_WARN(get_logger(), 
"sensor_fault_map rows are not arrays");
 
  159      if (map_value[
i].Size() < 2) {
 
  160        RCLCPP_WARN(get_logger(), 
"sensor_fault_map rows do not contain more than 1 element");
 
  164      std::vector<SensorBooleanStatus> statuses; 
 
  165      statuses.reserve(map_value[
i].Size()-1);
 
  166      for (rapidjson::SizeType j = 0; j < map_value[
i].Size() - 1; j++) {
 
  167        if (!map_value[
i][j].IsInt()) {
 
  168          RCLCPP_WARN_STREAM(get_logger(), 
"sensor_fault_map row " << 
i << 
" element " << j << 
" is not an int");
 
  175      rapidjson::Value& alert = map_value[
i][map_value[
i].Size() - 1];
 
  177      if (!alert.IsInt()) {
 
  178        RCLCPP_WARN_STREAM(get_logger(), 
"sensor_fault_map alert type is not an int in row " << 
i);
 
  190#include "rclcpp_components/register_node_macro.hpp" 
A base class for all subsystem_controllers which provides default lifecycle behavior for subsystems.
virtual carma_ros2_utils::CallbackReturn handle_on_configure(const rclcpp_lifecycle::State &prev_state)
virtual void on_system_alert(const carma_msgs::msg::SystemAlert::UniquePtr msg)
std::unordered_map< std::vector< SensorBooleanStatus >, SensorAlertStatus, VectorHash > sensor_fault_map_from_json(std::string json_string)
Helper function to convert a json string into an unordered map of sensor status's to required alerts ...
std::unordered_map< std::string, SensorBooleanStatus > sensor_status_
LocalizationControllerConfig config_
void on_system_alert(const carma_msgs::msg::SystemAlert::UniquePtr msg)
LocalizationControllerNode()=delete
carma_ros2_utils::CallbackReturn handle_on_configure(const rclcpp_lifecycle::State &prev_state)
Stuct containing the algorithm configuration values for the BaseSubsystemController.
std::unordered_map< std::vector< SensorBooleanStatus >, SensorAlertStatus, VectorHash > sensor_fault_map
std::vector< std::string > sensor_nodes
sensor_nodes