5#include <rclcpp/rclcpp.hpp>
7#include <mrs_lib/errorgraph/node_id.h>
8#include <mrs_msgs/msg/errorgraph_element.hpp>
9#include <mrs_lib/timer_handler.h>
31 struct error_wrapper_t
33 std::optional<error_id_t> id;
34 mrs_msgs::msg::ErrorgraphError msg;
47 ErrorPublisher(
const rclcpp::Node::SharedPtr node,
const rclcpp::Clock::SharedPtr clock,
const std::string& node_name,
const std::string& component_name,
48 const rclcpp::Rate& publish_period = rclcpp::Rate(1.0));
77 template <
typename enum_T>
78 requires(std::is_enum_v<enum_T> &&
sizeof(std::underlying_type_t<enum_T>) <=
sizeof(
error_id_t))
115 rclcpp::Node::SharedPtr node_;
116 rclcpp::Clock::SharedPtr clock_;
117 std::string node_name_;
118 std::string component_name_;
120 std::mutex errors_mtx_;
121 std::vector<error_wrapper_t> errors_;
123 rclcpp::CallbackGroup::SharedPtr cbkgrp_timers_;
125 rclcpp::Publisher<mrs_msgs::msg::ErrorgraphElement>::SharedPtr publisher_;
127 std::unique_ptr<mrs_lib::MRSTimer> timer_publisher_;
129 void publishErrors();
A helper class for aggregating and publishing errors to the Errorgraph. Report errors preventing your...
Definition error_publisher.h:23
void addWaitingForNodeError(const node_id_t &node_id)
Add a special error type waiting_for_node. Use this whenever your node is blocked because it waits fo...
Definition error_publisher.cpp:92
uint16_t error_id_t
Type of the ID used to avoid duplication of errors when using addGeneralError.
Definition error_publisher.h:28
void addGeneralError(const enum_T id, const std::string &description)
A convenience overload for custom enumeration types. This overload just casts the id parameter to the...
Definition error_publisher.h:79
void flushAndShutdown()
Publishes all aggregated errors and calls rclcpp::shutdown().
Definition error_publisher.cpp:35
void addGeneralError(const error_id_t id, const std::string &description)
Add a custom error to the list of aggregated errors to be published in the next period....
Definition error_publisher.cpp:44
void addOneshotError(const std::string &description)
Add an error that only appears once. This overload assumes that the error is unique,...
Definition error_publisher.cpp:63
void addWaitingForTopicError(const std::string &topic_name)
Add a special error type waiting_for_topic. You should prioritize using the addWaitingForNodeError() ...
Definition error_publisher.cpp:73
All mrs_lib functions, classes, variables and definitions are contained in this namespace.
Definition attitude_converter.h:24
Identifies a specific component within a ROS node for error reporting.
Definition node_id.h:21