A directed graph representing error dependencies between ROS nodes and topics.
More...
#include <errorgraph.h>
|
| struct | element_t |
| | Internal representation of a node or topic in the error dependency graph. More...
|
| |
| 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...
|
| |
|
|
using | element_info_t = std::variant< node_info_t, topic_info_t > |
| | Type-safe variant representing either a node or topic element info.
|
| |
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:
- Subscribe to error messages from all nodes in the system.
- Feed each received message to add_element_from_msg().
- Query the graph using find_error_roots(), find_dependency_roots(), etc.
- Optionally export the graph in DOT format using write_dot() for visualization.
- Note
- Return types: Query methods return element_info_t (a
std::variant<node_info_t, topic_info_t>) which contains a copy of the element's data. Use std::get<node_info_t>(element_info) or std::get<topic_info_t>(element_info) to access the specific type.
- See also
- ErrorPublisher for the publishing side that nodes use to report errors.
-
ErroGraphViewer at https://github.com/ctu-mrs/mrs_errorgraph_viewer/blob/ros2/src/errorgraph_viewer.cpp for an example of using the Errorgraph and visualizing it.
◆ Errorgraph()
| mrs_lib::errorgraph::Errorgraph::Errorgraph |
( |
rclcpp::Clock::SharedPtr |
clock | ) |
|
|
inlineexplicit |
Construct an empty Errorgraph.
- Parameters
-
| clock | Clock used for timestamping and staleness detection. |
◆ add_element_from_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.
- Parameters
-
| msg | The received ErrorgraphElement message. |
- Returns
- A copy of the added or updated element info.
◆ find_dependency_roots()
Find the root-cause elements blocking the given node.
Traverses the dependency graph from the specified node to find leaf elements (elements with errors that don't depend on anything else).
- Parameters
-
| node_id | The node to trace dependencies for. |
| loop_detected_out | If non-null, set to true when a cycle is detected. |
- Returns
- Copies of root-cause element info as type-safe variants.
◆ find_element() [1/2]
Find an element by node ID.
- Parameters
-
| node_id | The node ID to search for. |
- Returns
- A copy of the element info, or std::nullopt if not found.
◆ find_element() [2/2]
Find an element by topic name.
- Parameters
-
| topic_name | The topic name to search for. |
- Returns
- A copy of the element info, or std::nullopt if not found.
◆ find_error_roots()
Find all root-cause elements across the entire graph.
- Returns
- Copies of elements that have errors and are not blocked by other elements.
◆ find_leaves()
Find all leaf elements (elements with no children in the dependency graph).
- Returns
- Copies of leaf element info as type-safe variants.
◆ find_roots()
Find all root elements (elements with no parents in the dependency graph).
- Returns
- Copies of root element info as type-safe variants.
◆ write_dot()
| void mrs_lib::errorgraph::Errorgraph::write_dot |
( |
std::ostream & |
os | ) |
|
Write the graph in Graphviz DOT format.
- Parameters
-
| os | Output stream to write the DOT representation to. |
The documentation for this class was generated from the following files:
- include/mrs_lib/errorgraph/errorgraph.h
- src/errorgraph/errorgraph.cpp