|
mrs_lib
Various reusable classes, functions and utilities for use in MRS projects
|
A directed graph representing error dependencies between ROS nodes and topics. More...
#include <errorgraph.h>
Classes | |
| struct | error_t |
| Represents a single error reported by a node. More... | |
| struct | node_info_t |
| Public view of a node element, returned by query methods. More... | |
| struct | topic_info_t |
| Public view of a topic element, returned by query methods. More... | |
| struct | element_t |
| Internal representation of a node or topic in the error dependency graph. More... | |
Public Types | |
| using | element_info_t = std::variant<node_info_t, topic_info_t> |
| Type-safe variant representing either a node or topic element info. | |
Public Member Functions | |
| Errorgraph (rclcpp::Clock::SharedPtr clock) | |
| Construct an empty Errorgraph. | |
| void | write_dot (std::ostream &os) |
| Write the graph in Graphviz DOT format. | |
| std::vector< element_info_t > | find_dependency_roots (const node_id_t &node_id, bool *loop_detected_out=nullptr) |
| Find the root-cause elements blocking the given node. | |
| std::vector< element_info_t > | find_error_roots () |
| Find all root-cause elements across the entire graph. | |
| std::vector< element_info_t > | find_roots () |
| Find all root elements (elements that are not exclusively waiting for something else). | |
| std::vector< element_info_t > | find_leaves () |
| Find all leaf elements (elements that nothing else in the graph depends on). | |
| std::optional< element_info_t > | find_element (const std::string &topic_name) |
| Find an element by topic name. | |
| std::optional< element_info_t > | find_element (const node_id_t &node_id) |
| Find an element by node ID. | |
| element_info_t | add_element_from_msg (const errorgraph_element_msg_t &msg) |
| Add or update an element from a received ROS message. | |
A directed graph representing error dependencies between ROS nodes and topics.
The Errorgraph aggregates error reports from nodes in the system (published as errorgraph_element_msg_t messages) and builds a dependency graph. Nodes report which other nodes or topics they are waiting for, allowing the graph to trace error propagation and identify root causes.
Typical usage:
|
inlineexplicit |
Construct an empty Errorgraph.
| clock | Clock used for timestamping and staleness detection. |
| Errorgraph::element_info_t mrs_lib::errorgraph::Errorgraph::add_element_from_msg | ( | const errorgraph_element_msg_t & | msg | ) |
Add or update an element from a received ROS message.
If an element with the same source node already exists, its errors and timestamp are updated. Otherwise, a new element is created and any dependency edges implied by the errors are added to the graph.
| msg | The received ErrorgraphElement message. |
| std::vector< Errorgraph::element_info_t > mrs_lib::errorgraph::Errorgraph::find_dependency_roots | ( | const node_id_t & | node_id, |
| bool * | loop_detected_out = nullptr ) |
Find the root-cause elements blocking the given node.
Traverses the dependency graph from the specified node, following "waiting for" edges. An element is returned as a root cause if it doesn't depend on anything else, or if it carries a genuine error of its own – even while it also depends on something else, in which case traversal continues past it to find further root causes down the chain too. If a genuine dependency loop is encountered (see DFS()), every element that is a member of that loop is returned as well, not just one representative – so a 3-element cycle with no genuine error anywhere in it yields 3 root-cause entries, one per member.
| node_id | The node to trace dependencies for. |
| loop_detected_out | If non-null, set to true when a cycle is detected. |
| std::optional< Errorgraph::element_info_t > mrs_lib::errorgraph::Errorgraph::find_element | ( | const node_id_t & | node_id | ) |
Find an element by node ID.
| node_id | The node ID to search for. |
| std::optional< Errorgraph::element_info_t > mrs_lib::errorgraph::Errorgraph::find_element | ( | const std::string & | topic_name | ) |
Find an element by topic name.
| topic_name | The topic name to search for. |
| std::vector< Errorgraph::element_info_t > mrs_lib::errorgraph::Errorgraph::find_error_roots | ( | ) |
Find all root-cause elements across the entire graph.
An element is excluded only if every one of its non-"no error" entries is a "waiting for" dependency (see element_t::is_only_waiting_for()); an element with at least one genuine error, or with no dependency at all, is always included. Unlike find_roots(), a healthy (no-error, actively-reporting) element with no other element waiting on it is also excluded, to avoid reporting uninteresting leaves as "root causes". As with find_roots(), every element that is a member of a genuine dependency loop (no genuine error anywhere in the loop) is included too, consistent with find_dependency_roots() – see DFS().
| std::vector< Errorgraph::element_info_t > mrs_lib::errorgraph::Errorgraph::find_leaves | ( | ) |
Find all leaf elements (elements that nothing else in the graph depends on).
An element is a leaf if no other element is waiting for it, i.e. its parents list is empty.
| std::vector< Errorgraph::element_info_t > mrs_lib::errorgraph::Errorgraph::find_roots | ( | ) |
Find all root elements (elements that are not exclusively waiting for something else).
An element is excluded only if every one of its non-"no error" entries is a "waiting for" dependency (see element_t::is_only_waiting_for()); an element with at least one genuine error, or with no dependency at all, is always included. Every element that is a member of a genuine dependency loop (no genuine error anywhere in the loop) is included too, consistent with find_dependency_roots() – otherwise such a loop would vanish from the result entirely; see DFS() for how a genuine loop is distinguished from mere reconvergence.
| void mrs_lib::errorgraph::Errorgraph::write_dot | ( | std::ostream & | os | ) |
Write the graph in Graphviz DOT format.
| os | Output stream to write the DOT representation to. |