26 : rclcpp::Node(
"system_controller", options),
27 lifecycle_mgr_(get_node_base_interface(), get_node_graph_interface(), get_node_logging_interface(), get_node_services_interface())
41 RCLCPP_INFO(get_logger(),
"Initializing SystemControllerNode");
50 rclcpp::PublisherOptions intra_proc_disabled;
51 intra_proc_disabled.use_intra_process_comm = rclcpp::IntraProcessSetting::Disable;
54 auto pub_qos_transient_local = rclcpp::QoS(rclcpp::KeepLast(5));
55 pub_qos_transient_local.transient_local();
65 RCLCPP_INFO_STREAM(get_logger(),
"Config: " <<
config_);
78 catch (
const std::exception &e)
95 std::string reason =
"Uncaught exception: " + std::string(e.what());
98 get_logger(), reason);
102 rclcpp::shutdown(
nullptr, reason);
109 RCLCPP_INFO(get_logger(),
"Attempting to configure system...");
120 get_logger(),
"System could not be configured on startup. Shutting down.");
123 rclcpp::shutdown(
nullptr,
"System could not be configured on startup. Shutting down.");
132 get_logger(),
"System could not be activated. Shutting down.");
135 rclcpp::shutdown(
nullptr,
"System could not be activated. Shutting down.");
139 RCLCPP_INFO(get_logger(),
"System configured successfully");
141 catch (
const std::exception &e)
150 if (!get_node_base_interface())
151 throw std::runtime_error(
"get_node_base_interface() returned null pointer. May indicate ROS2 bug.");
153 msg.source_node = get_node_base_interface()->get_fully_qualified_name();
165 get_logger(),
"Received SystemAlert message of type: " <<
static_cast<int>(msg->type) <<
" with message: " << msg->description);
169 || ( msg->type == carma_msgs::msg::SystemAlert::FATAL
174 RCLCPP_INFO_STREAM( get_logger(),
"Shutting down");
178 carma_msgs::msg::SystemAlert shutdown_msg;
181 shutdown_msg.description =
"SHUTDOWN " + msg->description;
185 std::this_thread::sleep_for(std::chrono::milliseconds(5));
187 rclcpp::shutdown(
nullptr,
"System Alert requested shutdown");
190 catch (
const std::exception &e)
198#include "rclcpp_components/register_node_macro.hpp"
void set_config(SystemControllerConfig config)
Reset the configurations of this node. This is mean to support testing or other non-standard launch m...
SystemControllerNode()=delete
void startup_delay_callback()
Callback to be triggered when the startup delay has passed.
std::shared_ptr< rclcpp::Publisher< carma_msgs::msg::SystemAlert > > system_alert_pub_
System alert publisher.
rclcpp::TimerBase::SharedPtr startup_timer_
Timer which triggers when the startup delay has passed.
rclcpp::Subscription< carma_msgs::msg::SystemAlert >::SharedPtr system_alert_sub_
The subscriber for the system alert topic.
void on_system_alert(const carma_msgs::msg::SystemAlert::UniquePtr msg)
Callback for system alert messages used to evaluate system fault handling.
ros2_lifecycle_manager::Ros2LifecycleManager lifecycle_mgr_
Lifecycle Manager which will track the managed nodes and call their lifecycle services on request.
void initialize()
Initialize this node by loading parameters from the ROS Network.
void publish_system_alert(carma_msgs::msg::SystemAlert msg)
Publishes a SystemAlert message to the rest of the carma-platform system. NOTE: This callback will au...
void on_error(const std::exception &e)
Exception handling method for processing all internal exceptions;.
SystemControllerConfig config_
The configuration of this node.
const std::string system_alert_topic_
The default topic name for the system alert topic.
std::chrono::milliseconds std_msec
Stuct containing the algorithm configuration values for the SystemController.
uint64_t service_timeout_ms
Timeout in ms for service availability.
uint64_t call_timeout_ms
Timeout in ms for service calls.
double signal_configure_delay
Time in seconds to wait before telling all nodes to configure.
std::vector< std::string > required_subsystem_nodes
List of nodes to consider required and who's failure shall result in system shutdown.